Skip to content

Commit

Permalink
chore(macOS): change close-window behavior
Browse files Browse the repository at this point in the history
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").
  • Loading branch information
BLumia committed Jan 3, 2025
1 parent ff4f71c commit 6d7d0e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
4 changes: 4 additions & 0 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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);

Expand Down

0 comments on commit 6d7d0e4

Please sign in to comment.