mirror of https://github.com/zlatinb/muwire
Expose profile header in POP interface. Show thumbnail in profile view. Add copy-full-id button in profile view.
parent
e10029a82e
commit
b22dbcf4d0
|
@ -118,6 +118,7 @@ class SearchTabController {
|
||||||
params.persona = sender.getPersona()
|
params.persona = sender.getPersona()
|
||||||
params.uuid = uuid
|
params.uuid = uuid
|
||||||
params.profileTitle = sender.getTitle()
|
params.profileTitle = sender.getTitle()
|
||||||
|
params.profileHeader = sender.getHeader()
|
||||||
|
|
||||||
mvcGroup.createMVCGroup("view-profile", uuid.toString(), params)
|
mvcGroup.createMVCGroup("view-profile", uuid.toString(), params)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muwire.gui.profile
|
||||||
|
|
||||||
import com.muwire.core.trust.TrustEvent
|
import com.muwire.core.trust.TrustEvent
|
||||||
import com.muwire.core.trust.TrustLevel
|
import com.muwire.core.trust.TrustLevel
|
||||||
|
import com.muwire.gui.CopyPasteSupport
|
||||||
import griffon.core.artifact.GriffonController
|
import griffon.core.artifact.GriffonController
|
||||||
import griffon.core.controller.ControllerAction
|
import griffon.core.controller.ControllerAction
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
|
@ -25,6 +26,11 @@ class ViewProfileController {
|
||||||
model.register()
|
model.register()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void copyFull() {
|
||||||
|
CopyPasteSupport.copyToClipboard(model.persona.toBase64())
|
||||||
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void addContact() {
|
void addContact() {
|
||||||
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
||||||
|
|
|
@ -76,5 +76,9 @@ class ChatRoomModel {
|
||||||
ChatPOP other = (ChatPOP)o
|
ChatPOP other = (ChatPOP)o
|
||||||
persona == other.persona
|
persona == other.persona
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MWProfileHeader getHeader() {
|
||||||
|
profileHeaders[persona]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -951,6 +951,10 @@ class MainFrameModel {
|
||||||
return icon
|
return icon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWProfileHeader getHeader() {
|
||||||
|
profileHeader
|
||||||
|
}
|
||||||
|
|
||||||
public int speed() {
|
public int speed() {
|
||||||
|
|
||||||
if (finished)
|
if (finished)
|
||||||
|
@ -1150,7 +1154,7 @@ class MainFrameModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Icon getThumbnail() {
|
Icon getThumbnail() {
|
||||||
MWProfileHeader header = core.trustService.getProfileHeader(getPersona())
|
MWProfileHeader header = getHeader()
|
||||||
if (header == null)
|
if (header == null)
|
||||||
return null
|
return null
|
||||||
if (icon == null)
|
if (icon == null)
|
||||||
|
@ -1164,6 +1168,11 @@ class MainFrameModel {
|
||||||
return HTMLSanitizer.sanitize(title)
|
return HTMLSanitizer.sanitize(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
MWProfileHeader getHeader() {
|
||||||
|
core.trustService.getProfileHeader(getPersona())
|
||||||
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof SubscriptionPOP))
|
if (!(o instanceof SubscriptionPOP))
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -261,6 +261,7 @@ class SearchTabModel {
|
||||||
final Persona sender
|
final Persona sender
|
||||||
private final Icon avatar
|
private final Icon avatar
|
||||||
private final String profileTitle
|
private final String profileTitle
|
||||||
|
private final MWProfileHeader profileHeader
|
||||||
private final int rowIdx
|
private final int rowIdx
|
||||||
final List<UIResultEvent> results = []
|
final List<UIResultEvent> results = []
|
||||||
private int lastUpdatedIdx
|
private int lastUpdatedIdx
|
||||||
|
@ -268,6 +269,7 @@ class SearchTabModel {
|
||||||
SenderBucket(Persona sender, MWProfileHeader profileHeader,int rowIdx) {
|
SenderBucket(Persona sender, MWProfileHeader profileHeader,int rowIdx) {
|
||||||
this.sender = sender
|
this.sender = sender
|
||||||
this.rowIdx = rowIdx
|
this.rowIdx = rowIdx
|
||||||
|
this.profileHeader = profileHeader
|
||||||
if (profileHeader != null) {
|
if (profileHeader != null) {
|
||||||
Icon icon = null
|
Icon icon = null
|
||||||
try {
|
try {
|
||||||
|
@ -293,6 +295,10 @@ class SearchTabModel {
|
||||||
profileTitle
|
profileTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWProfileHeader getHeader() {
|
||||||
|
profileHeader
|
||||||
|
}
|
||||||
|
|
||||||
List<UIResultEvent> getPendingResults() {
|
List<UIResultEvent> getPendingResults() {
|
||||||
if (lastUpdatedIdx == results.size())
|
if (lastUpdatedIdx == results.size())
|
||||||
return Collections.emptyList()
|
return Collections.emptyList()
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.muwire.core.profile.MWProfile
|
||||||
import com.muwire.gui.HTMLSanitizer
|
import com.muwire.gui.HTMLSanitizer
|
||||||
|
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
|
import javax.swing.Icon
|
||||||
import javax.swing.JLabel
|
import javax.swing.JLabel
|
||||||
import javax.swing.JPanel
|
import javax.swing.JPanel
|
||||||
import javax.swing.JTextArea
|
import javax.swing.JTextArea
|
||||||
|
@ -41,6 +42,7 @@ class ViewProfileView {
|
||||||
JFrame mainFrame
|
JFrame mainFrame
|
||||||
|
|
||||||
JPanel mainPanel
|
JPanel mainPanel
|
||||||
|
JPanel thumbnailPanel
|
||||||
JLabel titleLabel
|
JLabel titleLabel
|
||||||
JPanel imagePanel
|
JPanel imagePanel
|
||||||
JTextArea bodyArea
|
JTextArea bodyArea
|
||||||
|
@ -58,6 +60,12 @@ class ViewProfileView {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
panel(border: titledBorder(title : trans("PROFILE_VIEWER_HEADER"), border: etchedBorder(),
|
panel(border: titledBorder(title : trans("PROFILE_VIEWER_HEADER"), border: etchedBorder(),
|
||||||
titlePosition: TitledBorder.TOP), constraints: BorderLayout.NORTH) {
|
titlePosition: TitledBorder.TOP), constraints: BorderLayout.NORTH) {
|
||||||
|
if (model.profileHeader == null)
|
||||||
|
thumbnailPanel = panel(preferredSize: [ProfileConstants.MAX_THUMBNAIL_SIZE, ProfileConstants.MAX_THUMBNAIL_SIZE])
|
||||||
|
else {
|
||||||
|
Icon thumbNail = new ThumbnailIcon(model.profileHeader.getThumbNail())
|
||||||
|
thumbnailPanel = panel(icon: thumbNail.image)
|
||||||
|
}
|
||||||
if (model.profileTitle == null)
|
if (model.profileTitle == null)
|
||||||
titleLabel = label(text: trans("PROFILE_VIEWER_HEADER_MISSING"))
|
titleLabel = label(text: trans("PROFILE_VIEWER_HEADER_MISSING"))
|
||||||
else
|
else
|
||||||
|
@ -86,22 +94,26 @@ class ViewProfileView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel(constraints: BorderLayout.SOUTH) {
|
panel(constraints: BorderLayout.SOUTH) {
|
||||||
borderLayout()
|
gridLayout(rows:1, cols: 4)
|
||||||
panel(constraints: BorderLayout.WEST) {
|
panel {
|
||||||
label(text : bind { model.status == null ? "" : trans(model.status.name())})
|
label(text : bind { model.status == null ? "" : trans(model.status.name())})
|
||||||
}
|
}
|
||||||
panel(constraints: BorderLayout.CENTER) {
|
panel {
|
||||||
|
button(text: trans("COPY_FULL_ID"), copyFullAction)
|
||||||
|
}
|
||||||
|
panel {
|
||||||
button(text: trans("ADD_CONTACT"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_ADD_CONTACT"),
|
button(text: trans("ADD_CONTACT"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_ADD_CONTACT"),
|
||||||
addContactAction)
|
addContactAction)
|
||||||
button(text: trans("PROFILE_VIEWER_BLOCK"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_BLOCK"),
|
button(text: trans("PROFILE_VIEWER_BLOCK"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_BLOCK"),
|
||||||
blockAction)
|
blockAction)
|
||||||
}
|
}
|
||||||
panel(constraints: BorderLayout.EAST) {
|
panel {
|
||||||
button(text : trans("CLOSE"), closeAction)
|
button(text : trans("CLOSE"), closeAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setPreferredSize([dimX, dimY] as Dimension)
|
window.setPreferredSize([dimX, dimY] as Dimension)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +139,14 @@ class ViewProfileView {
|
||||||
def mainImage = ImageScaler.scaleToMax(rawImage)
|
def mainImage = ImageScaler.scaleToMax(rawImage)
|
||||||
|
|
||||||
SwingUtilities.invokeLater {
|
SwingUtilities.invokeLater {
|
||||||
|
|
||||||
|
Icon thumbNail = new ThumbnailIcon(profile.getHeader().getThumbNail())
|
||||||
|
def thumbDim = thumbnailPanel.getSize()
|
||||||
|
thumbnailPanel.getGraphics().drawImage(thumbNail.image,
|
||||||
|
(int)(thumbDim.getWidth() / 2) - (int)(thumbNail.getIconHeight() / 2),
|
||||||
|
(int)(thumbDim.getHeight() / 2) - (int)(thumbNail.getIconHeight() / 2),
|
||||||
|
null)
|
||||||
|
|
||||||
def imgDim = imagePanel.getSize()
|
def imgDim = imagePanel.getSize()
|
||||||
imagePanel.getGraphics().drawImage(mainImage,
|
imagePanel.getGraphics().drawImage(mainImage,
|
||||||
(int) (imgDim.getWidth() / 2) - (int) (mainImage.getWidth() / 2),
|
(int) (imgDim.getWidth() / 2) - (int) (mainImage.getWidth() / 2),
|
||||||
|
|
|
@ -48,4 +48,9 @@ class MWMessageStatus implements PersonaOrProfile {
|
||||||
return null
|
return null
|
||||||
return HTMLSanitizer.sanitize(profileHeader.getTitle())
|
return HTMLSanitizer.sanitize(profileHeader.getTitle())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
MWProfileHeader getHeader() {
|
||||||
|
profileHeader
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muwire.gui.profile
|
package com.muwire.gui.profile
|
||||||
|
|
||||||
import com.muwire.core.Persona
|
import com.muwire.core.Persona
|
||||||
|
import com.muwire.core.profile.MWProfileHeader
|
||||||
import com.muwire.core.search.UIResultEvent
|
import com.muwire.core.search.UIResultEvent
|
||||||
import com.muwire.gui.HTMLSanitizer
|
import com.muwire.gui.HTMLSanitizer
|
||||||
|
|
||||||
|
@ -32,4 +33,9 @@ class ResultPOP implements PersonaOrProfile {
|
||||||
String getTitle() {
|
String getTitle() {
|
||||||
return HTMLSanitizer.sanitize(event.profileHeader?.getTitle())
|
return HTMLSanitizer.sanitize(event.profileHeader?.getTitle())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
MWProfileHeader getHeader() {
|
||||||
|
return event.profileHeader
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ class TrustPOP implements PersonaOrProfile {
|
||||||
return HTMLSanitizer.sanitize(trustEntry.getProfileHeader()?.getTitle())
|
return HTMLSanitizer.sanitize(trustEntry.getProfileHeader()?.getTitle())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MWProfileHeader getHeader() {
|
public MWProfileHeader getHeader() {
|
||||||
trustEntry.getProfileHeader()
|
trustEntry.getProfileHeader()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muwire.gui.profile;
|
package com.muwire.gui.profile;
|
||||||
|
|
||||||
import com.muwire.core.Persona;
|
import com.muwire.core.Persona;
|
||||||
|
import com.muwire.core.profile.MWProfileHeader;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
@ -8,4 +9,8 @@ public interface PersonaOrProfile {
|
||||||
Persona getPersona();
|
Persona getPersona();
|
||||||
Icon getThumbnail();
|
Icon getThumbnail();
|
||||||
String getTitle();
|
String getTitle();
|
||||||
|
|
||||||
|
default MWProfileHeader getHeader() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue