From 50c6b4a8aa4f74d4f5787602af696fd268d9224a Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Wed, 20 Dec 2023 21:12:18 +0100 Subject: [PATCH 01/11] Added needed feedreader depencies --- build_scripts/OSX/MacOS_X_InstallGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index b3dc0e88d..24c111acc 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -101,7 +101,7 @@ For VOIP Plugin: For FeedReader Plugin: $ brew install libxslt - + $ brew install libxml2 ## Last Settings From 48510e381822a4b463094a7fca0d4c02cd9395ee Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Wed, 20 Dec 2023 12:30:42 -0800 Subject: [PATCH 02/11] Added Feedreader include path for libxml2 --- build_scripts/OSX/MacOS_X_InstallGuide.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 24c111acc..7f8b389a4 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -153,6 +153,9 @@ alternative via Terminal CONFIG+=release \ .. +For FeedReader Plugin: + + INCLUDEPATH += "/usr/local/opt/libxml2/include/libxml2" With plugins: From 0ec569216b80fea10e423c1c8eb3e1e4dfa149cb Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Sat, 23 Dec 2023 09:23:53 +0100 Subject: [PATCH 03/11] Added cmake install to the guide --- build_scripts/OSX/MacOS_X_InstallGuide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 7f8b389a4..35c89a7eb 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -86,6 +86,10 @@ Install HomeBrew following this guide: [HomeBrew](http://brew.sh/) $ brew install libmicrohttpd $ brew install rapidjson $ brew install sqlcipher + +#### Install CMake + + $ brew install cmake If you have error in linking, run this: From eb4a5a4e4d25a640d3412e9328a9fff1300053b1 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:54:05 +0100 Subject: [PATCH 04/11] Fix show messages on macos --- retroshare-gui/src/gui/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 31fa13467..8cdd2ac66 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -681,7 +681,7 @@ void MainWindow::createMenuBar() dockMenu = new QMenu(this); dockMenu->setAsDockMenu(); - dockMenu->addAction(tr("Open Messages"), this, SLOT(Mess())); + dockMenu->addAction(tr("Open Messages"), this, SLOT(showMess())); dockMenu->addAction(tr("Bandwidth Graph"), this, SLOT(showBandwidthGraph())); dockMenu->addAction(tr("Statistics"), this, SLOT(showStatisticsWindow())); dockMenu->addAction(tr("Options"), this, SLOT(showSettings())); From 4af12b14e1b7738eebac93a813da2e0a5a48c2c0 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Sun, 24 Dec 2023 22:01:03 +0100 Subject: [PATCH 05/11] Set fusion style for macos --- retroshare-gui/src/gui/settings/rsharesettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 586d4df4f..28a29300c 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -109,7 +109,7 @@ void RshareSettings::initSettings() setDefault(SETTING_STYLE, "GTK+"); #else #if defined(Q_OS_MAC) - setDefault(SETTING_STYLE, "macintosh (aqua)"); + setDefault(SETTING_STYLE, "Fusion"); #else static QStringList styles = QStyleFactory::keys(); #if defined(Q_OS_WIN) From 17407f7ea3adc91105e14b5cffa31d4a2ca4f9ca Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:53:53 +0100 Subject: [PATCH 06/11] removed not needed dependency libmicrohttp --- build_scripts/OSX/MacOS_X_InstallGuide.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 35c89a7eb..eb19df093 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -66,7 +66,6 @@ Install MacPort following this guide: [MacPort](http://guide.macports.org/#insta $ sudo port -v selfupdate $ sudo port install openssl $ sudo port install miniupnpc - $ sudo port install libmicrohttpd For VOIP Plugin: @@ -83,7 +82,6 @@ Install HomeBrew following this guide: [HomeBrew](http://brew.sh/) $ brew install openssl $ brew install miniupnpc - $ brew install libmicrohttpd $ brew install rapidjson $ brew install sqlcipher From 3615ebf05eba1e79c74aabcb8466b865cacd4ae3 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Wed, 27 Dec 2023 22:50:22 +0100 Subject: [PATCH 07/11] Added retroshare-service compile with cmake to guide --- build_scripts/OSX/MacOS_X_InstallGuide.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index eb19df093..4afa90e2c 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -212,3 +212,13 @@ For Qt Creator -> QtCreator Projects -> Build -> Build Settings -> Build Steps - ./plugins/VOIP/lib/libVOIP.dylib \ ./plugins/RetroChess/lib/libRetroChess.dylib \ ./retroshare-gui/src/RetroShare.app/Contents/Resources/ + +### Compile Retroshare-Service & Webui with CMake +before you can compile overwrite the file "asio/include/asio/detail/config.hpp" here is a fix for macos [ +asio fix](https://github.com/chriskohlhoff/asio/commit/68df16d560c68944809bb2947360fe8035e9ae0a) + + $ cd retroshare-service + $ mkdir build-dir + $ cd build-dir + $ cmake -DRS_WEBUI=ON -DCMAKE_BUILD_TYPE=Release .. + $ make From 79977a0c3731048e85499f63959343e50fa25df2 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 29 Dec 2023 21:34:54 +0100 Subject: [PATCH 08/11] Fixed minimize on macOS with CTRL + M shortcut --- retroshare-gui/src/gui/MainWindow.cpp | 9 ++++++++- retroshare-gui/src/gui/MainWindow.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 8cdd2ac66..9e5671598 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -673,7 +673,7 @@ void MainWindow::createMenuBar() actionMinimize->setShortcutContext(Qt::ApplicationShortcut); actionMinimize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); actionMinimize->setShortcutVisibleInContextMenu(true); - connect(actionMinimize,SIGNAL(triggered()),this,SLOT(showMinimized())) ; + connect(actionMinimize,SIGNAL(triggered()),this,SLOT(minimizeWindow())) ; menuBar = new QMenuBar(this); QMenu *fileMenu = menuBar->addMenu(""); @@ -698,6 +698,13 @@ void MainWindow::createMenuBar() } #endif +#if defined(Q_OS_DARWIN) +void MainWindow::minimizeWindow() +{ + setWindowState(windowState() | Qt::WindowMinimized); +} +#endif + void MainWindow::showBandwidthGraph() { if(_bandwidthGraph == NULL) diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 692d7ed55..7525a0e30 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -265,6 +265,10 @@ private slots: void toggleVisibility(QSystemTrayIcon::ActivationReason e); void toggleVisibilitycontextmenu(); +#if defined(Q_OS_DARWIN) + void minimizeWindow(); +#endif + /** Toolbar fns. */ void addFriend(); //void newRsCollection(); From 75ef4dceb535ee35e5e164d3f12aa6bb1022bd0e Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 30 Dec 2023 00:15:28 +0100 Subject: [PATCH 09/11] Added close window shortcut --- retroshare-gui/src/gui/MainWindow.cpp | 17 ++++++++++++++++- retroshare-gui/src/gui/MainWindow.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 9e5671598..be53e41c9 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -673,11 +673,18 @@ void MainWindow::createMenuBar() actionMinimize->setShortcutContext(Qt::ApplicationShortcut); actionMinimize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); actionMinimize->setShortcutVisibleInContextMenu(true); - connect(actionMinimize,SIGNAL(triggered()),this,SLOT(minimizeWindow())) ; + connect(actionMinimize,SIGNAL(triggered()),this,SLOT(minimizeWindow())) ; + + actionCloseWindow = new QAction(tr("Close window"),this); + actionCloseWindow->setShortcutContext(Qt::ApplicationShortcut); + actionCloseWindow->setShortcut(QKeySequence::Close); + actionCloseWindow->setShortcutVisibleInContextMenu(true); + connect(actionCloseWindow,SIGNAL(triggered()),this,SLOT(closeWindow())) ; menuBar = new QMenuBar(this); QMenu *fileMenu = menuBar->addMenu(""); fileMenu->addAction(actionMinimize); + fileMenu->addAction(actionCloseWindow); dockMenu = new QMenu(this); dockMenu->setAsDockMenu(); @@ -705,6 +712,14 @@ void MainWindow::minimizeWindow() } #endif +#if defined(Q_OS_DARWIN) +void MainWindow::closeWindow() +{ + // On macOS window close is basically equivalent to window hide. + close(); +} +#endif + void MainWindow::showBandwidthGraph() { if(_bandwidthGraph == NULL) diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 7525a0e30..64211d67d 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -267,6 +267,7 @@ private slots: #if defined(Q_OS_DARWIN) void minimizeWindow(); + void closeWindow(); #endif /** Toolbar fns. */ @@ -337,6 +338,7 @@ private: QMenuBar *menuBar; QMenu *dockMenu; QAction* actionMinimize; + QAction* actionCloseWindow; #endif QSystemTrayIcon *trayIcon; From 15f2ea4e29e3d946add9fc285928a48c53230615 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 2 Jan 2024 12:58:11 +0100 Subject: [PATCH 10/11] Added to fix from Dock Icon to Show/Hide for macOS platform --- retroshare-gui/src/gui/MainWindow.cpp | 18 +++++-- .../src/gui/common/MacDockIconHandler.h | 27 ++++++++++ .../src/gui/common/MacDockIconHandler.mm | 53 +++++++++++++++++++ retroshare-gui/src/retroshare-gui.pro | 3 ++ 4 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 retroshare-gui/src/gui/common/MacDockIconHandler.h create mode 100644 retroshare-gui/src/gui/common/MacDockIconHandler.mm diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index be53e41c9..d69e2bb42 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -33,6 +33,10 @@ #include #include +#if defined(Q_OS_DARWIN) +#include "gui/common/MacDockIconHandler.h" +#endif + #ifdef MESSENGER_WINDOW #include "MessengerWindow.h" #endif @@ -381,6 +385,7 @@ MainWindow::~MainWindow() #if defined(Q_OS_DARWIN) delete menuBar; delete dockMenu; + MacDockIconHandler::cleanup(); #endif // delete notifyMenu; // already deleted by the deletion of trayMenu StatisticsWindow::releaseInstance(); @@ -656,6 +661,15 @@ void MainWindow::createTrayIcon() trayIcon->setContextMenu(trayMenu); trayIcon->setIcon(QIcon(IMAGE_NOONLINE)); +#if defined(Q_OS_DARWIN) + // Note: On macOS, the Dock icon is used to provide the tray's functionality. + MacDockIconHandler* dockIconHandler = MacDockIconHandler::instance(); + connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] { + show(); + activateWindow(); + }); +#endif + #if defined(Q_OS_DARWIN) createMenuBar(); #endif @@ -694,10 +708,6 @@ void MainWindow::createMenuBar() dockMenu->addAction(tr("Options"), this, SLOT(showSettings())); dockMenu->addAction(tr("Help"), this, SLOT(showHelpDialog())); - dockMenu->addSeparator(); - QObject::connect(dockMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); - toggleVisibilityAction = dockMenu->addAction(tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu())); - dockMenu->addSeparator(); QMenu *statusMenu = dockMenu->addMenu(tr("Status")); initializeStatusObject(statusMenu, true); diff --git a/retroshare-gui/src/gui/common/MacDockIconHandler.h b/retroshare-gui/src/gui/common/MacDockIconHandler.h new file mode 100644 index 000000000..d9d4d41f5 --- /dev/null +++ b/retroshare-gui/src/gui/common/MacDockIconHandler.h @@ -0,0 +1,27 @@ +// Copyright (c) 2011-2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef MACDOCKICONHANDLER_H +#define MACDOCKICONHANDLER_H + +#include + +/** macOS-specific Dock icon handler. + */ +class MacDockIconHandler : public QObject +{ + Q_OBJECT + +public: + static MacDockIconHandler *instance(); + static void cleanup(); + +Q_SIGNALS: + void dockIconClicked(); + +private: + MacDockIconHandler(); +}; + +#endif // MACDOCKICONHANDLER_H diff --git a/retroshare-gui/src/gui/common/MacDockIconHandler.mm b/retroshare-gui/src/gui/common/MacDockIconHandler.mm new file mode 100644 index 000000000..51a26135d --- /dev/null +++ b/retroshare-gui/src/gui/common/MacDockIconHandler.mm @@ -0,0 +1,53 @@ +// Copyright (c) 2011-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "MacDockIconHandler.h" + +#include +#include + +static MacDockIconHandler *s_instance = nullptr; + +bool dockClickHandler(id self, SEL _cmd, ...) { + Q_UNUSED(self) + Q_UNUSED(_cmd) + + Q_EMIT s_instance->dockIconClicked(); + + // Return NO (false) to suppress the default macOS actions + return false; +} + +void setupDockClickHandler() { + Class delClass = (Class)[[[NSApplication sharedApplication] delegate] class]; + SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:"); + class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:"); +} + +MacDockIconHandler::MacDockIconHandler() : QObject() +{ + setupDockClickHandler(); +} + +MacDockIconHandler *MacDockIconHandler::instance() +{ + if (!s_instance) + s_instance = new MacDockIconHandler(); + return s_instance; +} + +void MacDockIconHandler::cleanup() +{ + delete s_instance; +} + +/** + * Force application activation on macOS. With Qt 5.5.1 this is required when + * an action in the Dock menu is triggered. + * TODO: Define a Qt version where it's no-longer necessary. + */ +void ForceActivation() +{ + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; +} diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 93734b454..b27102d42 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -304,6 +304,9 @@ macx { #DEFINES *= MAC_IDLE # for idle feature CONFIG -= uitools + + OBJECTIVE_SOURCES += gui/common/MacDockIconHandler.mm + OBJECTIVE_HEADERS += gui/common/MacDockIconHandler.h } ##################################### FreeBSD ###################################### From 020e9e5927f86ef8439bd34e3f0f6231c1ceb3a0 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:30:32 +0100 Subject: [PATCH 11/11] Enabled delete CFBundleGetInfoString, to update Version string --- build_scripts/OSX/makeOSXPackage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_scripts/OSX/makeOSXPackage.sh b/build_scripts/OSX/makeOSXPackage.sh index b599df3c3..24808d487 100644 --- a/build_scripts/OSX/makeOSXPackage.sh +++ b/build_scripts/OSX/makeOSXPackage.sh @@ -18,7 +18,7 @@ rm -rf obj rm -rf qrc # This sets the CFBundleVersion & CFBundleShortVersionString string -#/usr/libexec/PlistBuddy -c "Delete :CFBundleGetInfoString" retroshare.app/Contents/Info.plist +/usr/libexec/PlistBuddy -c "Delete :CFBundleGetInfoString" retroshare.app/Contents/Info.plist /usr/libexec/PlistBuddy -c "Add :CFBundleVersion string $RSVERSION" retroshare.app/Contents/Info.plist /usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string $RSVERSION" retroshare.app/Contents/Info.plist