mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
Merge pull request #2806 from defnax/macos-fixes
Added logo for retroshare-service on macOS
This commit is contained in:
commit
081782c97c
4 changed files with 62 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <QMenuBar>
|
||||||
|
|
||||||
#include <retroshare/rsplugin.h>
|
#include <retroshare/rsplugin.h>
|
||||||
#include <retroshare/rsconfig.h>
|
#include <retroshare/rsconfig.h>
|
||||||
|
@ -377,6 +378,10 @@ MainWindow::~MainWindow()
|
||||||
delete sysTrayStatus;
|
delete sysTrayStatus;
|
||||||
delete trayIcon;
|
delete trayIcon;
|
||||||
delete trayMenu;
|
delete trayMenu;
|
||||||
|
#if defined(Q_OS_DARWIN)
|
||||||
|
delete menuBar;
|
||||||
|
delete dockMenu;
|
||||||
|
#endif
|
||||||
// delete notifyMenu; // already deleted by the deletion of trayMenu
|
// delete notifyMenu; // already deleted by the deletion of trayMenu
|
||||||
StatisticsWindow::releaseInstance();
|
StatisticsWindow::releaseInstance();
|
||||||
|
|
||||||
|
@ -651,10 +656,48 @@ void MainWindow::createTrayIcon()
|
||||||
trayIcon->setContextMenu(trayMenu);
|
trayIcon->setContextMenu(trayMenu);
|
||||||
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
||||||
|
|
||||||
|
#if defined(Q_OS_DARWIN)
|
||||||
|
createMenuBar();
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
||||||
trayIcon->show();
|
trayIcon->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_DARWIN)
|
||||||
|
/** Creates a new menubar for macOS */
|
||||||
|
void MainWindow::createMenuBar()
|
||||||
|
{
|
||||||
|
/* Mac users sure like their shortcuts. */
|
||||||
|
actionMinimize = new QAction(tr("Minimize"),this);
|
||||||
|
actionMinimize->setShortcutContext(Qt::ApplicationShortcut);
|
||||||
|
actionMinimize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
||||||
|
actionMinimize->setShortcutVisibleInContextMenu(true);
|
||||||
|
connect(actionMinimize,SIGNAL(triggered()),this,SLOT(showMinimized())) ;
|
||||||
|
|
||||||
|
menuBar = new QMenuBar(this);
|
||||||
|
QMenu *fileMenu = menuBar->addMenu("");
|
||||||
|
fileMenu->addAction(actionMinimize);
|
||||||
|
|
||||||
|
dockMenu = new QMenu(this);
|
||||||
|
dockMenu->setAsDockMenu();
|
||||||
|
dockMenu->addAction(tr("Open Messages"), this, SLOT(Mess()));
|
||||||
|
dockMenu->addAction(tr("Bandwidth Graph"), this, SLOT(showBandwidthGraph()));
|
||||||
|
dockMenu->addAction(tr("Statistics"), this, SLOT(showStatisticsWindow()));
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void MainWindow::showBandwidthGraph()
|
void MainWindow::showBandwidthGraph()
|
||||||
{
|
{
|
||||||
if(_bandwidthGraph == NULL)
|
if(_bandwidthGraph == NULL)
|
||||||
|
@ -1220,7 +1263,11 @@ void MainWindow::updateMenu()
|
||||||
|
|
||||||
void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
|
void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_DARWIN)
|
||||||
|
if (e == QSystemTrayIcon::DoubleClick) {
|
||||||
|
#else
|
||||||
if (e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
|
if (e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
|
||||||
|
#endif
|
||||||
if (isHidden() || isMinimized()) {
|
if (isHidden() || isMinimized()) {
|
||||||
show();
|
show();
|
||||||
if (isMinimized()) {
|
if (isMinimized()) {
|
||||||
|
|
|
@ -308,6 +308,10 @@ private:
|
||||||
void initStackedPage();
|
void initStackedPage();
|
||||||
void addPage(MainPage *page, QActionGroup *grp, QList<QPair<MainPage *, QPair<QAction *, QListWidgetItem *> > > *notify);
|
void addPage(MainPage *page, QActionGroup *grp, QList<QPair<MainPage *, QPair<QAction *, QListWidgetItem *> > > *notify);
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
|
#if defined(Q_OS_DARWIN)
|
||||||
|
/** Creates a default menubar on Mac */
|
||||||
|
void createMenuBar();
|
||||||
|
#endif
|
||||||
void createNotifyIcons();
|
void createNotifyIcons();
|
||||||
static MainWindow *_instance;
|
static MainWindow *_instance;
|
||||||
|
|
||||||
|
@ -324,6 +328,13 @@ private:
|
||||||
|
|
||||||
QString nameAndLocation;
|
QString nameAndLocation;
|
||||||
|
|
||||||
|
#if defined(Q_OS_DARWIN)
|
||||||
|
/** The menubar (Mac OS X only). */
|
||||||
|
QMenuBar *menuBar;
|
||||||
|
QMenu *dockMenu;
|
||||||
|
QAction* actionMinimize;
|
||||||
|
#endif
|
||||||
|
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
QMenu *notifyMenu;
|
QMenu *notifyMenu;
|
||||||
QMenu *trayMenu;
|
QMenu *trayMenu;
|
||||||
|
|
BIN
retroshare-service/src/logo.icns
Normal file
BIN
retroshare-service/src/logo.icns
Normal file
Binary file not shown.
|
@ -70,6 +70,10 @@ macx {
|
||||||
#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||||
LIBS += -lz
|
LIBS += -lz
|
||||||
#LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan
|
#LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan
|
||||||
|
RC_FILE = $$files($$PWD/logo.icns)
|
||||||
|
mac_icon.files = $$files($$PWD/logo.icns)
|
||||||
|
mac_icon.path = Contents/Resources
|
||||||
|
QMAKE_BUNDLE_DATA += mac_icon
|
||||||
|
|
||||||
for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a}
|
for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue