]> git.lyx.org Git - features.git/commitdiff
Display externally modified status
authorGuillaume Munch <gm@lyx.org>
Tue, 28 Feb 2017 21:58:44 +0000 (22:58 +0100)
committerGuillaume Munch <gm@lyx.org>
Fri, 10 Mar 2017 23:50:57 +0000 (00:50 +0100)
src/frontends/WorkAreaManager.cpp
src/frontends/WorkAreaManager.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea_Private.h
src/frontends/qt4/Menus.cpp

index f938db4eb9d80306f6da263e11be708325b934d7..a1c244ece7215c716771f39d9e2ac59999ec0bd2 100644 (file)
@@ -33,10 +33,8 @@ void WorkAreaManager::remove(WorkArea * wa)
 
 void WorkAreaManager::redrawAll(bool update_metrics)
 {
-       iterator it = work_areas_.begin();
-       iterator const en = work_areas_.end();
-       for (; it != en; ++it)
-               (*it)->redraw(update_metrics);
+       for (WorkArea * wa : work_areas_)
+               wa->redraw(update_metrics);
 }
 
 
@@ -50,12 +48,11 @@ void WorkAreaManager::closeAll()
 
 void WorkAreaManager::updateTitles()
 {
-       iterator it = work_areas_.begin();
-       iterator const en = work_areas_.end();
-       for (; it != en; ++it)
-               (*it)->updateWindowTitle();
+       for (WorkArea * wa : work_areas_)
+               wa->updateWindowTitle();
 }
 
+
 } // namespace frontend
 } // namespace lyx
 
index dfef00e6f69168cb2b679f1eff37b6845bbac2b8..e8952f2eae2276a4884f5a7f5db91b06ddc8eca1 100644 (file)
@@ -38,7 +38,8 @@ public:
        void redrawAll(bool update_metrics);
        ///
        void closeAll();
-       /// Update window titles of all users.
+       /// Update window titles of all users and the external modifications
+       /// warning.
        void updateTitles();
 
 private:
index c5956324ca78638104a9088a06e8136d4bdbb569..7ff8e04b1c38a2f8c5f3338759afb79ce2a25966 100644 (file)
@@ -1121,6 +1121,12 @@ void GuiView::updateWindowTitle(GuiWorkArea * wa)
        Buffer const & buf = wa->bufferView().buffer();
        // Set the windows title
        docstring title = buf.fileName().displayName(130) + from_ascii("[*]");
+       if (buf.notifiesExternalModification()) {
+               title = bformat(_("%1$s (modified externally)"), title);
+               // If the external modification status has changed, then maybe the status of
+               // buffer-save has changed too.
+               updateToolbars();
+       }
 #ifndef Q_WS_MAC
        title += from_ascii(" - LyX");
 #endif
index bb8de83dc072ad5d50e07855b11d97b565a7dc0e..050eae761f186fa50ddeaa384937128fd6d5489f 100644 (file)
@@ -251,7 +251,7 @@ GuiWorkArea::Private::Private(GuiWorkArea * parent)
   need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
   pixel_ratio_(1.0),
   completer_(new GuiCompleter(p, p)), dialog_mode_(false),
-  read_only_(false), clean_(true)
+  read_only_(false), clean_(true), externally_modified_(false)
 {
 }
 
@@ -1390,12 +1390,16 @@ QVariant GuiWorkArea::inputMethodQuery(Qt::InputMethodQuery query) const
 void GuiWorkArea::updateWindowTitle()
 {
        Buffer const & buf = bufferView().buffer();
-       if (buf.fileName() != d->file_name_ || buf.isReadonly() != d->read_only_
-           || buf.lyxvc().vcstatus() != d->vc_status_ || buf.isClean() != d->clean_) {
+       if (buf.fileName() != d->file_name_
+           || buf.isReadonly() != d->read_only_
+           || buf.lyxvc().vcstatus() != d->vc_status_
+           || buf.isClean() != d->clean_
+           || buf.notifiesExternalModification() != d->externally_modified_) {
                d->file_name_ = buf.fileName();
                d->read_only_ = buf.isReadonly();
                d->vc_status_ = buf.lyxvc().vcstatus();
                d->clean_ = buf.isClean();
+               d->externally_modified_ = buf.notifiesExternalModification();
                Q_EMIT titleChanged(this);
        }
 }
@@ -2052,9 +2056,14 @@ void TabWorkArea::updateTabTexts()
                QString tab_tooltip = it->abs();
                if (buf.isReadonly()) {
                        setTabIcon(tab_index, QIcon(getPixmap("images/", "emblem-readonly", "svgz,png")));
-                       tab_tooltip = qt_("%1 (read only)").arg(it->abs());
+                       tab_tooltip = qt_("%1 (read only)").arg(tab_tooltip);
                } else
                        setTabIcon(tab_index, QIcon());
+               if (buf.notifiesExternalModification()) {
+                       QString const warn = qt_("%1 (modified externally)");
+                       tab_tooltip = warn.arg(tab_tooltip);
+                       tab_text += QChar(0x26a0);
+               }
                setTabText(tab_index, tab_text);
                setTabToolTip(tab_index, tab_tooltip);
        }
index 712af883e9d0932c0e8d1d8a022f6680a681e956..a3cc7b338dc67c0ec47eb7efe94218769ebd06c9 100644 (file)
@@ -196,6 +196,8 @@ struct GuiWorkArea::Private
        docstring vc_status_;
        ///
        bool clean_;
+       ///
+       bool externally_modified_;
 
 }; // GuiWorkArea
 
index 30f493bb5e392836f2565e97c6ee5eb0f794022b..a0eaa65a84853cef21555ba6a6f46440e5ca1e8f 100644 (file)
@@ -990,6 +990,8 @@ void MenuDefinition::expandDocuments()
                QString label = toqstr(b.fileName().displayName(20));
                if (!b.isClean())
                        label += "*";
+               if (b.notifiesExternalModification())
+                       label += QChar(0x26a0);
                if (i < 10)
                        label = QString::number(i) + ". " + label + '|' + QString::number(i);
                add(MenuItem(MenuItem::Command, label,
@@ -1007,6 +1009,8 @@ void MenuDefinition::expandDocuments()
                        QString label = toqstr(b->fileName().displayName(20));
                        if (!b->isClean())
                                label += "*";
+                       if (b->notifiesExternalModification())
+                               label += QChar(0x26a0);
                        if (i < 10)
                                label = QString::number(i) + ". " + label + '|' + QString::number(i);
                        item.submenu().add(MenuItem(MenuItem::Command, label,