mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
#11682 open new window on Mac if there is none and LyX is activated via dock
This commit is contained in:
parent
233cfed333
commit
4d4dc96b06
@ -944,7 +944,7 @@ public:
|
||||
struct GuiApplication::Private
|
||||
{
|
||||
Private(): language_model_(nullptr), meta_fake_bit(NoModifier),
|
||||
global_menubar_(nullptr)
|
||||
global_menubar_(nullptr), last_state_(Qt::ApplicationInactive)
|
||||
{
|
||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
||||
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
||||
@ -1011,6 +1011,8 @@ struct GuiApplication::Private
|
||||
|
||||
/// Only used on mac.
|
||||
QMenuBar * global_menubar_;
|
||||
/// Holds previous application state on Mac
|
||||
Qt::ApplicationState last_state_;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
/// Linkback mime handler for MacOSX.
|
||||
@ -1084,6 +1086,10 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||
setupApplescript();
|
||||
appleCleanupEditMenu();
|
||||
appleCleanupViewMenu();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
|
||||
connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||
this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_X11) || defined(QPA_XCB)
|
||||
@ -3293,6 +3299,36 @@ void GuiApplication::onLastWindowClosed()
|
||||
}
|
||||
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
|
||||
void GuiApplication::onApplicationStateChanged(Qt::ApplicationState state)
|
||||
{
|
||||
std::string name = "unknown";
|
||||
switch (state) {
|
||||
case Qt::ApplicationSuspended:
|
||||
name = "ApplicationSuspended";
|
||||
break;
|
||||
case Qt::ApplicationHidden:
|
||||
name = "ApplicationHidden";
|
||||
break;
|
||||
case Qt::ApplicationInactive:
|
||||
name = "ApplicationInactive";
|
||||
break;
|
||||
case Qt::ApplicationActive:
|
||||
name = "ApplicationActive";
|
||||
/// The Dock icon click produces 2 sequential QEvent::ApplicationStateChangeEvent events.
|
||||
/// cmd+tab only one QEvent::ApplicationStateChangeEvent event
|
||||
if (d->views_.empty() && d->last_state_ == state) {
|
||||
LYXERR(Debug::GUI, "Open new window...");
|
||||
createView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
LYXERR(Debug::GUI, "onApplicationStateChanged..." << name);
|
||||
d->last_state_ = state;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void GuiApplication::startLongOperation() {
|
||||
d->key_checker_.start();
|
||||
}
|
||||
|
@ -228,6 +228,10 @@ private Q_SLOTS:
|
||||
void onLocaleChanged();
|
||||
///
|
||||
void slotProcessFuncRequestQueue() { processFuncRequestQueue(); }
|
||||
///
|
||||
#if (QT_VERSION >= 0x050100)
|
||||
void onApplicationStateChanged(Qt::ApplicationState state);
|
||||
#endif
|
||||
|
||||
private:
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user