]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiView.cpp
Remove ugly frame around word count (#12625).
[lyx.git] / src / frontends / qt / GuiView.cpp
index 9a353117a364e55f14b2b906a019771ae6d81e3f..17ae3f00acefdf35359a8f84f4f939fce3f62552 100644 (file)
@@ -157,7 +157,7 @@ public:
                        return;
                /// The text to be written on top of the pixmap
                QString const htext = qt_("The Document\nProcessor[[welcome banner]]");
-               QString const htextsize = qt_("1.0[[possibly scale the welcome banner text size]]");
+               QString const htextsize = qt_("1.0[[translating this to different value scales the welcome banner text size for your language]]");
                /// The text to be written on top of the pixmap
                QString const text = lyx_version ?
                        qt_("version ") + lyx_version : qt_("unknown version");
@@ -651,15 +651,12 @@ GuiView::GuiView(int id)
 
        stat_counts_ = new GuiClickableLabel(statusBar());
        stat_counts_->setAlignment(Qt::AlignCenter);
-       stat_counts_->setFrameStyle(QFrame::StyledPanel);
        stat_counts_->hide();
        statusBar()->addPermanentWidget(stat_counts_);
 
        connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed()));
 
        zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
-       // Small size slider for macOS to prevent the status bar from enlarging
-       zoom_slider_->setAttribute(Qt::WA_MacSmallSize);
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
        zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15);
 #else
@@ -691,14 +688,22 @@ GuiView::GuiView(int id)
        zoom_out_->setFixedSize(s);
        zoom_out_->setAlignment(Qt::AlignCenter);
 
-       statusBar()->addPermanentWidget(zoom_out_);
+
+       zoom_widget_ = new QWidget(statusBar());
+       zoom_widget_->setAttribute(Qt::WA_MacSmallSize);
+       zoom_widget_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+       zoom_widget_->setLayout(new QHBoxLayout());
+       zoom_widget_->layout()->setSpacing(5);
+       zoom_widget_->layout()->setContentsMargins(0,0,0,0);
+       zoom_widget_->layout()->addWidget(zoom_out_);
+       zoom_widget_->layout()->addWidget(zoom_slider_);
+       zoom_widget_->layout()->addWidget(zoom_in_);
+       statusBar()->addPermanentWidget(zoom_widget_);
        zoom_out_->setEnabled(currentBufferView()
                              && zoom_slider_->value() > zoom_slider_->minimum());
-       statusBar()->addPermanentWidget(zoom_slider_);
        zoom_slider_->setEnabled(currentBufferView());
        zoom_in_->setEnabled(currentBufferView()
                             && zoom_slider_->value() < zoom_slider_->maximum());
-       statusBar()->addPermanentWidget(zoom_in_);
 
        connect(zoom_slider_, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int)));
        connect(zoom_slider_, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int)));
@@ -993,7 +998,7 @@ void GuiView::saveLayout() const
        settings.setValue("layout", saveState(0));
        settings.setValue("icon_size", toqstr(d.iconSize(iconSize())));
        settings.setValue("zoom_value_visible", zoom_value_->isVisible());
-       settings.setValue("zoom_slider_visible", zoom_slider_->isVisible());
+       settings.setValue("zoom_slider_visible", zoom_widget_->isVisible());
        settings.setValue("word_count_enabled", word_count_enabled_);
        settings.setValue("char_count_enabled", char_count_enabled_);
        settings.setValue("char_nb_count_enabled", char_nb_count_enabled_);
@@ -1044,9 +1049,7 @@ bool GuiView::restoreLayout()
        zoom_value_->setVisible(settings.value("zoom_value_visible", true).toBool());
 
        bool const show_zoom_slider = settings.value("zoom_slider_visible", true).toBool();
-       zoom_slider_->setVisible(show_zoom_slider);
-       zoom_in_->setVisible(show_zoom_slider);
-       zoom_out_->setVisible(show_zoom_slider);
+       zoom_widget_->setVisible(show_zoom_slider);
 
        word_count_enabled_ = settings.value("word_count_enabled", true).toBool();
        char_count_enabled_ = settings.value("char_count_enabled", true).toBool();
@@ -1118,11 +1121,9 @@ void GuiView::updateLockToolbars()
                if (tb && tb->isMovable())
                        toolbarsMovable_ = true;
        }
-#if QT_VERSION >= 0x050200
        // set unified mac toolbars only when not movable as recommended:
        // https://doc.qt.io/qt-5/qmainwindow.html#unifiedTitleAndToolBarOnMac-prop
        setUnifiedTitleAndToolBarOnMac(!toolbarsMovable_);
-#endif
 }
 
 
@@ -1288,6 +1289,9 @@ void GuiView::closeEvent(QCloseEvent * close_event)
 {
        LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
 
+       // FIXME Bug #12828 bites here. If there is some other View open, then
+       // we really should only refuse to close if one of the Buffers open here
+       // is being processed.
        if (!GuiViewPrivate::busyBuffers.isEmpty()) {
                Alert::warning(_("Exit LyX"),
                        _("LyX could not be closed because documents are being processed by LyX."));
@@ -1745,12 +1749,6 @@ bool GuiView::event(QEvent * e)
                return QMainWindow::event(e);
        }
 
-       case QEvent::ApplicationPaletteChange: {
-               // runtime switch from/to dark mode
-               refillToolbars();
-               return QMainWindow::event(e);
-       }
-
        case QEvent::Gesture: {
                QGestureEvent *ge = static_cast<QGestureEvent*>(e);
                QGesture *gp = ge->gesture(Qt::PinchGesture);
@@ -1772,6 +1770,25 @@ bool GuiView::event(QEvent * e)
                return QMainWindow::event(e);
        }
 
+       // dark/light mode runtime switch support, OS-dependent.
+       // 1. Mac OS X
+       // Limit to Q_OS_MAC as this unnecessarily would also
+       // trigger on Linux with grave performance issues
+#ifdef Q_OS_MAC
+       case QEvent::ApplicationPaletteChange: {
+               // We need to update metrics here to avoid a crash (#12786)
+               theBufferList().changed(true);
+               refillToolbars();
+               return QMainWindow::event(e);
+       }
+#endif
+       // 2. Linux
+       case QEvent::StyleChange: {
+               // We need to update metrics here to avoid a crash (#12786)
+               theBufferList().changed(true);
+               return QMainWindow::event(e);
+       }
+
        default:
                return QMainWindow::event(e);
        }
@@ -1862,7 +1879,8 @@ TabWorkArea * GuiView::addTabWorkArea()
        QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
                         this, SLOT(on_lastWorkAreaRemoved()));
 
-       d.splitter_->addWidget(twa);
+       d.splitter_->insertWidget(d.splitter_->indexOf(d.currentTabWorkArea()) + 1,
+                                 twa);
        d.stack_widget_->setCurrentWidget(d.splitter_);
        return twa;
 }
@@ -2446,6 +2464,14 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        }
 
+       case LFUN_CHANGES_TRACK: {
+               if (!doc_buffer) {
+                       enable = false;
+                       break;
+               }
+               return doc_buffer->getStatus(cmd, flag);
+       }
+
        case LFUN_VIEW_SPLIT:
                if (cmd.getArg(0) == "vertical")
                        enable = doc_buffer && (d.splitter_->count() == 1 ||
@@ -2545,7 +2571,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                if (cmd.argument() == "zoomlevel") {
                        flag.setOnOff(zoom_value_ ? zoom_value_->isVisible() : false);
                } else if (cmd.argument() == "zoomslider") {
-                       flag.setOnOff(zoom_slider_ ? zoom_slider_->isVisible() : false);
+                       flag.setOnOff(zoom_widget_ ? zoom_widget_->isVisible() : false);
                } else if (cmd.argument() == "statistics-w") {
                        flag.setOnOff(word_count_enabled_);
                } else if (cmd.argument() == "statistics-cb") {
@@ -2823,7 +2849,7 @@ void GuiView::openDocuments(string const & fname, int origin)
                QStringList const filter({
                                qt_("LyX Documents (*.lyx)"),
                                qt_("LyX Document Backups (*.lyx~)"),
-                               qt_("All Files (*.*)")
+                               qt_("All Files") + " " + wildcardAllFiles()
                });
                FileDialog::Results results =
                        dlg.openMulti(toqstr(initpath), filter);
@@ -4528,6 +4554,15 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        doc_buffer->runChktex();
                        break;
 
+               case LFUN_CHANGES_TRACK: {
+                       // the actual dispatch is done in Buffer
+                       dispatchToBufferView(cmd, dr);
+                       // but we inform the GUI (document settings) if this is toggled
+                       LASSERT(doc_buffer, break);
+                       Q_EMIT changeTrackingToggled(doc_buffer->params().track_changes);
+                       break;
+               }
+
                case LFUN_COMMAND_EXECUTE: {
                        command_execute_ = true;
                        minibuffer_focus_ = true;
@@ -4564,7 +4599,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                FileDialog dlg(qt_("Select file to insert"));
 
                                FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
-                                       QStringList(qt_("All Files (*)")));
+                                       QStringList(qt_("All Files")+ " " + wildcardAllFiles()));
 
                                if (result.first == FileDialog::Later || result.second.isEmpty()) {
                                        dr.setMessage(_("Canceled."));
@@ -4843,6 +4878,9 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                ? Qt::Vertical : Qt::Horizontal);
                        TabWorkArea * twa = addTabWorkArea();
                        GuiWorkArea * wa = twa->addWorkArea(*doc_buffer, *this);
+
+                       wa->bufferView().copySettingsFrom(*bv);
+                       dr.screenUpdate(Update::ForceAll);
                        setCurrentWorkArea(wa);
                        break;
                }
@@ -5029,12 +5067,8 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
 
                case LFUN_CITATION_OPEN: {
-                       string pdfv, psv;
-                       if (theFormats().getFormat("pdf"))
-                               pdfv = theFormats().getFormat("pdf")->viewer();
-                       if (theFormats().getFormat("ps"))
-                               psv = theFormats().getFormat("ps")->viewer();
-                       frontend::showTarget(argument, pdfv, psv);
+                       LASSERT(doc_buffer, break);
+                       frontend::showTarget(argument, *doc_buffer);
                        break;
                }
 
@@ -5078,9 +5112,7 @@ bool GuiView::lfunUiToggle(string const & ui_component)
        } else if (ui_component == "zoomlevel") {
                zoom_value_->setVisible(!zoom_value_->isVisible());
        } else if (ui_component == "zoomslider") {
-               zoom_slider_->setVisible(!zoom_slider_->isVisible());
-               zoom_in_->setVisible(zoom_slider_->isVisible());
-               zoom_out_->setVisible(zoom_slider_->isVisible());
+               zoom_widget_->setVisible(!zoom_widget_->isVisible());
        } else if (ui_component == "statistics-w") {
                word_count_enabled_ = !word_count_enabled_;
                if (statsEnabled())
@@ -5268,14 +5300,17 @@ Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
                return dialog;
 
        dialog = build(name);
-       d.dialogs_[name].reset(dialog);
-       // Force a uniform style for group boxes
-       // On Mac non-flat works better, on Linux flat is standard
-       flatGroupBoxes(dialog->asQWidget(), guiApp->platformName() != "cocoa");
-       if (lyxrc.allow_geometry_session)
-               dialog->restoreSession();
-       if (hide_it)
-               dialog->hideView();
+       if (dialog) {
+
+               d.dialogs_[name].reset(dialog);
+               // Force a uniform style for group boxes
+               // On Mac non-flat works better, on Linux flat is standard
+               flatGroupBoxes(dialog->asQWidget(), guiApp->platformName() != "cocoa");
+               if (lyxrc.allow_geometry_session)
+                       dialog->restoreSession();
+               if (hide_it)
+                       dialog->hideView();
+               }
        return dialog;
 }