Compare commits

...

3 Commits

Author SHA1 Message Date
9296faf0ff mac menu 2025-01-08 19:13:31 +08:00
eb04ac362b
fix: should center window according to available geometry 2025-01-04 13:36:01 +08:00
6d7d0e4e1d chore(macOS): change close-window behavior
On macOS, now closing the window will actually hide the window
instead of quit the application, thus it will match to some other
macOS application's behavior.

Additionally, since our binary is not signed, this could avoid
seeing the request permission dialogs everytime user attempts to
open an image file inside a private place (e.g. places like the
"Downloads" folder and "access data from other apps").
2025-01-03 18:57:25 +08:00
3 changed files with 23 additions and 2 deletions

View File

@ -83,6 +83,8 @@ void ActionManager::setupAction(MainWindow *mainWindow)
#undef CREATE_NEW_ACTION
#undef CREATE_NEW_THEMEICON_ACTION
actionSettings->setMenuRole(QAction::PreferencesRole);
retranslateUi(mainWindow);
QMetaObject::connectSlotsByName(mainWindow);

View File

@ -63,7 +63,12 @@ int main(int argc, char *argv[])
FileOpenEventHandler * fileOpenEventHandler = new FileOpenEventHandler(&a);
a.installEventFilter(fileOpenEventHandler);
a.connect(fileOpenEventHandler, &FileOpenEventHandler::fileOpen, [&w](const QUrl & url){
if (w.isHidden()) w.showNormal();
if (w.isHidden()) {
w.setWindowOpacity(1);
w.showNormal();
} else {
w.activateWindow();
}
w.showUrls({url});
w.initWindowSize();
});

View File

@ -37,6 +37,8 @@
#include <QProcess>
#include <QDesktopServices>
#include <QMessageBox>
#include <QMenuBar>
#include <QLayout>
#ifdef HAVE_QTDBUS
#include <QDBusInterface>
@ -71,7 +73,11 @@ MainWindow::MainWindow(QWidget *parent)
m_exitAnimationGroup->addAnimation(m_fadeOutAnimation);
m_exitAnimationGroup->addAnimation(m_floatUpAnimation);
connect(m_exitAnimationGroup, &QParallelAnimationGroup::finished,
#ifdef Q_OS_MAC
this, &QWidget::hide);
#else
this, &QWidget::close);
#endif
GraphicsScene * scene = new GraphicsScene(this);
@ -122,6 +128,14 @@ MainWindow::MainWindow(QWidget *parent)
m_am->setupAction(this);
QMenuBar * menuBar = new QMenuBar(this);
QMenu* fileMenu = menuBar->addMenu("File");
fileMenu->addAction(m_am->actionOpen);
fileMenu->addAction(m_am->actionSettings);
QMenu* helpMenu = menuBar->addMenu("Help");
helpMenu->addAction(m_am->actionHelp);
layout()->setMenuBar(menuBar);
m_bottomButtonGroup = new BottomButtonGroup({
m_am->actionActualSize,
m_am->actionToggleMaximize,
@ -559,7 +573,7 @@ void MainWindow::centerWindow()
Qt::LeftToRight,
Qt::AlignCenter,
this->size(),
qApp->screenAt(QCursor::pos())->geometry()
qApp->screenAt(QCursor::pos())->availableGeometry()
)
);
}