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.uuid = uuid
|
||||
params.profileTitle = sender.getTitle()
|
||||
params.profileHeader = sender.getHeader()
|
||||
|
||||
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.TrustLevel
|
||||
import com.muwire.gui.CopyPasteSupport
|
||||
import griffon.core.artifact.GriffonController
|
||||
import griffon.core.controller.ControllerAction
|
||||
import griffon.inject.MVCMember
|
||||
|
@ -25,6 +26,11 @@ class ViewProfileController {
|
|||
model.register()
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void copyFull() {
|
||||
CopyPasteSupport.copyToClipboard(model.persona.toBase64())
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void addContact() {
|
||||
String reason = JOptionPane.showInputDialog(trans("ENTER_REASON_OPTIONAL"))
|
||||
|
|
|
@ -76,5 +76,9 @@ class ChatRoomModel {
|
|||
ChatPOP other = (ChatPOP)o
|
||||
persona == other.persona
|
||||
}
|
||||
|
||||
public MWProfileHeader getHeader() {
|
||||
profileHeaders[persona]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -951,6 +951,10 @@ class MainFrameModel {
|
|||
return icon
|
||||
}
|
||||
|
||||
MWProfileHeader getHeader() {
|
||||
profileHeader
|
||||
}
|
||||
|
||||
public int speed() {
|
||||
|
||||
if (finished)
|
||||
|
@ -1150,7 +1154,7 @@ class MainFrameModel {
|
|||
|
||||
@Override
|
||||
Icon getThumbnail() {
|
||||
MWProfileHeader header = core.trustService.getProfileHeader(getPersona())
|
||||
MWProfileHeader header = getHeader()
|
||||
if (header == null)
|
||||
return null
|
||||
if (icon == null)
|
||||
|
@ -1164,6 +1168,11 @@ class MainFrameModel {
|
|||
return HTMLSanitizer.sanitize(title)
|
||||
}
|
||||
|
||||
@Override
|
||||
MWProfileHeader getHeader() {
|
||||
core.trustService.getProfileHeader(getPersona())
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof SubscriptionPOP))
|
||||
return false
|
||||
|
|
|
@ -261,6 +261,7 @@ class SearchTabModel {
|
|||
final Persona sender
|
||||
private final Icon avatar
|
||||
private final String profileTitle
|
||||
private final MWProfileHeader profileHeader
|
||||
private final int rowIdx
|
||||
final List<UIResultEvent> results = []
|
||||
private int lastUpdatedIdx
|
||||
|
@ -268,6 +269,7 @@ class SearchTabModel {
|
|||
SenderBucket(Persona sender, MWProfileHeader profileHeader,int rowIdx) {
|
||||
this.sender = sender
|
||||
this.rowIdx = rowIdx
|
||||
this.profileHeader = profileHeader
|
||||
if (profileHeader != null) {
|
||||
Icon icon = null
|
||||
try {
|
||||
|
@ -293,6 +295,10 @@ class SearchTabModel {
|
|||
profileTitle
|
||||
}
|
||||
|
||||
MWProfileHeader getHeader() {
|
||||
profileHeader
|
||||
}
|
||||
|
||||
List<UIResultEvent> getPendingResults() {
|
||||
if (lastUpdatedIdx == results.size())
|
||||
return Collections.emptyList()
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muwire.core.profile.MWProfile
|
|||
import com.muwire.gui.HTMLSanitizer
|
||||
|
||||
import javax.imageio.ImageIO
|
||||
import javax.swing.Icon
|
||||
import javax.swing.JLabel
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.JTextArea
|
||||
|
@ -41,6 +42,7 @@ class ViewProfileView {
|
|||
JFrame mainFrame
|
||||
|
||||
JPanel mainPanel
|
||||
JPanel thumbnailPanel
|
||||
JLabel titleLabel
|
||||
JPanel imagePanel
|
||||
JTextArea bodyArea
|
||||
|
@ -58,6 +60,12 @@ class ViewProfileView {
|
|||
borderLayout()
|
||||
panel(border: titledBorder(title : trans("PROFILE_VIEWER_HEADER"), border: etchedBorder(),
|
||||
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)
|
||||
titleLabel = label(text: trans("PROFILE_VIEWER_HEADER_MISSING"))
|
||||
else
|
||||
|
@ -86,22 +94,26 @@ class ViewProfileView {
|
|||
}
|
||||
}
|
||||
panel(constraints: BorderLayout.SOUTH) {
|
||||
borderLayout()
|
||||
panel(constraints: BorderLayout.WEST) {
|
||||
gridLayout(rows:1, cols: 4)
|
||||
panel {
|
||||
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"),
|
||||
addContactAction)
|
||||
button(text: trans("PROFILE_VIEWER_BLOCK"), toolTipText: trans("TOOLTIP_PROFILE_VIEWER_BLOCK"),
|
||||
blockAction)
|
||||
}
|
||||
panel(constraints: BorderLayout.EAST) {
|
||||
panel {
|
||||
button(text : trans("CLOSE"), closeAction)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.setPreferredSize([dimX, dimY] as Dimension)
|
||||
}
|
||||
|
||||
|
@ -127,6 +139,14 @@ class ViewProfileView {
|
|||
def mainImage = ImageScaler.scaleToMax(rawImage)
|
||||
|
||||
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()
|
||||
imagePanel.getGraphics().drawImage(mainImage,
|
||||
(int) (imgDim.getWidth() / 2) - (int) (mainImage.getWidth() / 2),
|
||||
|
|
|
@ -48,4 +48,9 @@ class MWMessageStatus implements PersonaOrProfile {
|
|||
return null
|
||||
return HTMLSanitizer.sanitize(profileHeader.getTitle())
|
||||
}
|
||||
|
||||
@Override
|
||||
MWProfileHeader getHeader() {
|
||||
profileHeader
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muwire.gui.profile
|
||||
|
||||
import com.muwire.core.Persona
|
||||
import com.muwire.core.profile.MWProfileHeader
|
||||
import com.muwire.core.search.UIResultEvent
|
||||
import com.muwire.gui.HTMLSanitizer
|
||||
|
||||
|
@ -32,4 +33,9 @@ class ResultPOP implements PersonaOrProfile {
|
|||
String 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())
|
||||
}
|
||||
|
||||
@Override
|
||||
public MWProfileHeader getHeader() {
|
||||
trustEntry.getProfileHeader()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muwire.gui.profile;
|
||||
|
||||
import com.muwire.core.Persona;
|
||||
import com.muwire.core.profile.MWProfileHeader;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
@ -8,4 +9,8 @@ public interface PersonaOrProfile {
|
|||
Persona getPersona();
|
||||
Icon getThumbnail();
|
||||
String getTitle();
|
||||
|
||||
default MWProfileHeader getHeader() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue