mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-17 21:04:19 -05:00
OS X: Restore main window when clicking on the docker icon.
Apparently this worked previously. Maybe a regression in Qt? Refs #326
This commit is contained in:
parent
840642394f
commit
58ed99d562
@ -24,9 +24,15 @@
|
|||||||
|
|
||||||
Application::Application(int& argc, char** argv)
|
Application::Application(int& argc, char** argv)
|
||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
|
, m_mainWindow(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setMainWindow(QWidget* mainWindow)
|
||||||
|
{
|
||||||
|
m_mainWindow = mainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::event(QEvent* event)
|
bool Application::event(QEvent* event)
|
||||||
{
|
{
|
||||||
// Handle Apple QFileOpenEvent from finder (double click on .kdbx file)
|
// Handle Apple QFileOpenEvent from finder (double click on .kdbx file)
|
||||||
@ -34,6 +40,16 @@ bool Application::event(QEvent* event)
|
|||||||
Q_EMIT openFile(static_cast<QFileOpenEvent*>(event)->file());
|
Q_EMIT openFile(static_cast<QFileOpenEvent*>(event)->file());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
// restore main window when clicking on the docker icon
|
||||||
|
else if ((event->type() == QEvent::ApplicationActivate) && m_mainWindow) {
|
||||||
|
m_mainWindow->ensurePolished();
|
||||||
|
m_mainWindow->setWindowState(m_mainWindow->windowState() & ~Qt::WindowMinimized);
|
||||||
|
m_mainWindow->show();
|
||||||
|
m_mainWindow->raise();
|
||||||
|
m_mainWindow->activateWindow();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return QApplication::event(event);
|
return QApplication::event(event);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ class Application : public QApplication
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Application(int& argc, char** argv);
|
Application(int& argc, char** argv);
|
||||||
|
void setMainWindow(QWidget* mainWindow);
|
||||||
|
|
||||||
bool event(QEvent* event) Q_DECL_OVERRIDE;
|
bool event(QEvent* event) Q_DECL_OVERRIDE;
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
@ -37,6 +38,9 @@ public:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void openFile(const QString& filename);
|
void openFile(const QString& filename);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget* m_mainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_APPLICATION_H
|
#endif // KEEPASSX_APPLICATION_H
|
||||||
|
@ -82,6 +82,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
app.setMainWindow(&mainWindow);
|
||||||
|
|
||||||
QObject::connect(&app, SIGNAL(openFile(QString)), &mainWindow, SLOT(openDatabase(QString)));
|
QObject::connect(&app, SIGNAL(openFile(QString)), &mainWindow, SLOT(openDatabase(QString)));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user