Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit de303fa

Browse files
committed
Various fixes for mac with new UI
1 parent cb0f9a3 commit de303fa

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

src/main.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifdef Q_OS_WIN
88
#include "FramelessWindow/QWinWidget.h"
99
#else
10-
#include "UI/mainwindow.h"
10+
#include "mainwindow.h"
1111
#endif
1212

1313
#ifdef __APPLE__
@@ -20,6 +20,13 @@
2020

2121
int main(int argc, char *argv[])
2222
{
23+
//This has the app draw at HiDPI scaling on HiDPI displays, usually two pixels for every one logical pixel
24+
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
25+
26+
//This has QPixmap images use the @2x images when available
27+
//See this bug for more details on how to get this right: https://bugreports.qt.io/browse/QTBUG-44486#comment-327410
28+
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
29+
2330
DuApplication a(argc, argv);
2431

2532
// process CLI arguments
@@ -107,13 +114,12 @@ int main(int argc, char *argv[])
107114

108115
#else
109116
//On OS X / Linux, the widget can handle everything itself so just create Widget as normal
110-
MainWindow *w = new MainWindow( args );
117+
MainWindow *w = new MainWindow( a.arguments() );
111118

112119
// Restore Geometry and state
113120
w->restoreGeometry( DuSettingsManager::instance()->uiWindowGeometry() );
114121
w->restoreState(DuSettingsManager::instance()->uiWindowState());
115-
// But hide the docks for a cleaner look
116-
w->hideAllDocks();
122+
117123
#endif
118124

119125
w->show();

src/mainwindow.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ void MainWindow::duqf_initUi()
698698
{
699699
DuMenu *trayMenu = new DuMenu(QString(STR_INTERNALNAME),this);
700700
QSettings settings;
701+
701702
#ifdef Q_OS_LINUX
702703
QString trayIconType = settings.value("appearance/trayIconType", "light").toString();
703704
#else
@@ -732,7 +733,7 @@ void MainWindow::duqf_initUi()
732733
//drag window
733734
duqf_toolBarClicked = false;
734735

735-
#ifdef Q_OS_LINUX
736+
#ifndef Q_OS_WIN
736737
mainToolBar->installEventFilter(this);
737738
#endif
738739

@@ -764,7 +765,6 @@ void MainWindow::duqf_initUi()
764765
minWidget->setObjectName("windowButton");
765766
mainToolBar->layout()->setAlignment(minWidget, Qt::AlignTop);
766767

767-
#ifndef Q_OS_MAC
768768
m_maximizeAction = new QAction(this);
769769
QIcon maximizeIcon;
770770
maximizeIcon.addFile(":/icons/maximize", QSize(), QIcon::Normal, QIcon::Off);
@@ -776,7 +776,6 @@ void MainWindow::duqf_initUi()
776776
maxWidget->setFixedSize(24,24);
777777
maxWidget->setObjectName("windowButton");
778778
mainToolBar->layout()->setAlignment(maxWidget, Qt::AlignTop);
779-
#endif // NOT MAC
780779

781780
m_closeAction = new QAction(this);
782781
m_closeAction->setIcon(QIcon(":/icons/close-simple"));
@@ -786,7 +785,7 @@ void MainWindow::duqf_initUi()
786785
closeWidget->setObjectName("windowButton");
787786
mainToolBar->layout()->setAlignment(closeWidget, Qt::AlignTop);
788787

789-
#endif // Not LINUX
788+
#endif // Not linux
790789

791790
// ===== STATUSBAR ======
792791

@@ -893,14 +892,19 @@ void MainWindow::duqf_initUi()
893892
DuApplication *app = qobject_cast<DuApplication*>(qApp);
894893
duqf_updateAvailable(app->updateInfo());
895894

896-
#ifndef Q_OS_LINUX
895+
#ifdef Q_OS_WIN
897896
connect(m_minimizeAction, &QAction::triggered, this, &MainWindow::minimizeTriggered);
898-
#ifndef Q_OS_MAC
899897
connect(m_maximizeAction, &QAction::triggered, this, &MainWindow::maximizeTriggered);
900-
#endif // Not mac
901898
connect(m_closeAction, &QAction::triggered, this, &MainWindow::close);
899+
#endif
900+
901+
#ifdef Q_OS_MAC
902+
connect(m_minimizeAction, &QAction::triggered, this, &QMainWindow::showMinimized);
903+
connect(m_maximizeAction, &QAction::triggered, this, &MainWindow::maximize);
904+
connect(m_closeAction, &QAction::triggered, this, &MainWindow::close);
905+
#endif
906+
902907
connect(qApp, &QCoreApplication::aboutToQuit, this, &MainWindow::onQuit);
903-
#endif // Not linux
904908
}
905909

906910
void MainWindow::duqf_setStyle()
@@ -1063,6 +1067,12 @@ void MainWindow::duqf_updateAvailable(QJsonObject updateInfo)
10631067
}
10641068
}
10651069

1070+
void MainWindow::maximize(bool m)
1071+
{
1072+
if (m) showMaximized();
1073+
else showNormal();
1074+
}
1075+
10661076
void MainWindow::log(DuQFLog m)
10671077
{
10681078
QString message = m.message();

src/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ private slots:
193193
void duqf_showHide();
194194
void duqf_askBeforeClose();
195195
void duqf_updateAvailable(QJsonObject updateInfo);
196+
void maximize(bool m);
196197

197198
void log(DuQFLog m);
198199

0 commit comments

Comments
 (0)