diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 7af51650..5f41a230 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -1062,6 +1062,17 @@ class MainFrameController { mvcGroup.createMVCGroup("chat-favorites", params) } + @ControllerAction + void showUpdate() { + if (application.mvcGroupManager.findGroup("update") == null) { + Map args = new HashMap<>() + args['core'] = core + args['available'] = model.updateAvailableEvent + args['downloaded'] = model.updateDownloadedEvent + mvcGroup.createMVCGroup("update", "update", args).destroy() + } + } + void saveMuWireSettings() { core.saveMuSettings() } diff --git a/gui/griffon-app/i18n/messages.properties b/gui/griffon-app/i18n/messages.properties index 2ae90fcc..480148b7 100644 --- a/gui/griffon-app/i18n/messages.properties +++ b/gui/griffon-app/i18n/messages.properties @@ -772,6 +772,7 @@ TOOLTIP_TOTAL_UP_SPEED=Total upload speed TOOLTIP_UNREAD_MESSAEGS=Unread messages TOOLTIP_CONNECTIONS=Connections to other MuWire nodes TOOLTIP_SEARCH_BOX=Search for keywords, search phrase or regular expression +TOOLTIP_UPDATE=Update MuWire ### Tooltips for browse files tab TOOLTIP_COPY_SENDER_FULL_ID=Copy the full ID of the sender to clipboard diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 17e3d934..be213230 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -10,6 +10,7 @@ import com.muwire.core.trust.TrustServiceLoadedEvent import com.muwire.gui.profile.PersonaOrProfile import com.muwire.gui.profile.ThumbnailIcon import com.muwire.gui.profile.TrustPOP +import griffon.core.controller.ControllerAction import javax.swing.DefaultListModel import javax.swing.Icon @@ -206,6 +207,9 @@ class MainFrameModel { @Observable int downSpeed @Observable int upSpeed + + @Observable UpdateDownloadedEvent updateDownloadedEvent + @Observable UpdateAvailableEvent updateAvailableEvent private final Set downloadInfoHashes = new ConcurrentHashSet<>() @@ -411,16 +415,18 @@ class MainFrameModel { void onUpdateDownloadedEvent(UpdateDownloadedEvent e) { runInsideUIAsync { - if (application.mvcGroupManager.findGroup("update") == null) { - Map args = new HashMap<>() - args['core'] = core - args['available'] = null - args['downloaded'] = e - mvcGroup.createMVCGroup("update", "update", args).destroy() - } + updateDownloadedEvent = e + updateAvailableEvent = null } } + void onUpdateAvailableEvent(UpdateAvailableEvent e) { + runInsideUIAsync { + updateDownloadedEvent = null + updateAvailableEvent = e + } + } + void onUIResultEvent(UIResultEvent e) { MVCGroup resultsGroup = results.get(e.uuid) resultsGroup?.model.handleResult(e) @@ -798,18 +804,6 @@ class MainFrameModel { } } - void onUpdateAvailableEvent(UpdateAvailableEvent e) { - runInsideUIAsync { - if (application.mvcGroupManager.findGroup("update") == null) { - Map args = new HashMap<>() - args['core'] = core - args['available'] = e - args['downloaded'] = null - mvcGroup.createMVCGroup("update", "update", args).destroy() - } - } - } - void onRouterDisconnectedEvent(RouterDisconnectedEvent e) { if (core.getShutdown().get()) return diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index daf42680..d3c6af51 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -735,6 +735,9 @@ class MainFrameView { panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) { borderLayout() panel (constraints : BorderLayout.WEST) { + button(text: trans("UPDATE"), toolTipText: trans("TOOLTIP_UPDATE"), + enabled: bind {model.updateAvailableEvent != null || model.updateDownloadedEvent != null}, + showUpdateAction) button(text: "", icon: imageIcon('/edit_profile.png'), toolTipText: trans("TOOLTIP_PROFILE_EDITOR"), editProfileAction) }