X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt%2FGuiApplication.cpp;h=26288a5f55dd1cf148b1153fa56493f947480c7f;hb=2b0841b0c910506b9b4ceaf9edf107b163447da5;hp=1b29eec412a5fff4f2e57386c5464568959f822c;hpb=17b24cf480ca864a746cc2cbb808209d8c976a55;p=lyx.git diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index 1b29eec412..26288a5f55 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -71,6 +71,7 @@ #include "support/lassert.h" #include "support/lstrings.h" #include "support/lyxalgo.h" // sorted +#include "support/mute_warning.h" #include "support/textutils.h" #include "support/Messages.h" #include "support/os.h" @@ -1028,10 +1029,7 @@ public: struct GuiApplication::Private { Private(): language_model_(nullptr), meta_fake_bit(NoModifier), - global_menubar_(nullptr) - #if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) - , last_state_(Qt::ApplicationInactive) - #endif + global_menubar_(nullptr), last_state_(Qt::ApplicationInactive) { #if (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) @@ -1112,10 +1110,8 @@ struct GuiApplication::Private /// Only used on mac. QMenuBar * global_menubar_; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) /// Holds previous application state on Mac Qt::ApplicationState last_state_; -#endif #if defined(Q_OS_MAC) && (QT_VERSION < 0x060000) /// Linkback mime handler for MacOSX. @@ -1156,7 +1152,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv) QCoreApplication::setOrganizationName(app_name); QCoreApplication::setOrganizationDomain("lyx.org"); QCoreApplication::setApplicationName(lyx_package); -#if QT_VERSION >= 0x050100 && QT_VERSION < 0x060000 +#if QT_VERSION < 0x060000 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif @@ -1195,11 +1191,9 @@ 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(QPA_XCB) // doubleClickInterval() is 400 ms on X11 which is just too long. @@ -1275,6 +1269,11 @@ docstring Application::mathIcon(docstring const & c) return qstring_to_ucs4(findImg(toqstr(c))); } +void Application::applyPrefs() +{ + if (lyxrc.ui_style != "default") + lyx::frontend::GuiApplication::setStyle(toqstr(lyxrc.ui_style)); +} FuncStatus GuiApplication::getStatus(FuncRequest const & cmd) const { @@ -1825,7 +1824,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) createView(QString(), false); // keep hidden current_view_->newDocument(to_utf8(cmd.argument())); current_view_->show(); - setActiveWindow(current_view_); + current_view_->activateWindow(); } else { current_view_->newDocument(to_utf8(cmd.argument())); } @@ -1908,12 +1907,6 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) } case LFUN_LYXFILES_OPEN: { - // This is the actual reason for this method (#12106). - validateCurrentView(); - if (!current_view_ - || (!lyxrc.open_buffers_in_tabs - && current_view_->documentBufferView() != nullptr)) - createView(); string arg = to_utf8(cmd.argument()); if (arg.empty()) // set default @@ -2270,17 +2263,15 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) case LFUN_DIALOG_SHOW: { string const name = cmd.getArg(0); - - if ( name == "aboutlyx" - || name == "prefs" - || name == "texinfo" - || name == "progress" - || name == "compare") + // Workaround: on Mac OS the application + // is not terminated when closing the last view. + // With the following dialogs which should still + // be usable, create a new one to be able + // to dispatch LFUN_DIALOG_SHOW to this view. + if (name == "aboutlyx" || name == "compare" + || name == "lyxfiles" || name == "prefs" + || name == "progress" || name == "texinfo") { - // work around: on Mac OS the application - // is not terminated when closing the last view. - // Create a new one to be able to dispatch the - // LFUN_DIALOG_SHOW to this view. if (current_view_ == nullptr) createView(); } @@ -2619,7 +2610,7 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow, if (autoShow) { view->show(); - setActiveWindow(view); + view->activateWindow(); } if (!geometry_arg.isEmpty()) { @@ -2683,7 +2674,7 @@ QPixmap GuiApplication::getScaledPixmap(QString imagedir, QString name) const QPixmap pm = getPixmap(imagedir, name, "svgz,png"); FileName fname = imageLibFileSearch(imagedir, name, "svgz,png"); QString fpath = toqstr(fname.absFileName()); - if (!fpath.isEmpty()) { + if (!fpath.isEmpty() && !fpath.endsWith(".png")) { QSvgRenderer svgRenderer(fpath); if (svgRenderer.isValid()) { pm = QPixmap(pm.size() * dpr); @@ -2954,11 +2945,7 @@ namespace { QFont const GuiApplication::typewriterSystemFont() { -#if QT_VERSION >= 0x050200 QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); -#else - QFont font("monospace"); -#endif if (!isFixedPitch(font)) { // try to enforce a real monospaced font font.setStyleHint(QFont::Monospace); @@ -3452,7 +3439,6 @@ void GuiApplication::onLastWindowClosed() } -#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) void GuiApplication::onApplicationStateChanged(Qt::ApplicationState state) { std::string name = "unknown"; @@ -3479,7 +3465,6 @@ void GuiApplication::onApplicationStateChanged(Qt::ApplicationState state) LYXERR(Debug::GUI, "onApplicationStateChanged..." << name); d->last_state_ = state; } -#endif void GuiApplication::startLongOperation() { @@ -3508,7 +3493,7 @@ bool GuiApplication::longOperationStarted() { #if defined(QPA_XCB) bool GuiApplication::nativeEventFilter(const QByteArray & eventType, - void * message, long *) + void * message, QINTPTR *) { if (!current_view_ || eventType != "xcb_generic_event_t") return false;