Il 10/03/2012 13:30, Stephan Witt ha scritto:
Am 09.03.2012 um 01:31 schrieb Jerry:

Another problem with the colored buttons. A black dot in the red button 
indicates that a document has been edited but not saved to disk. Here are the 
two versions for a focused and unfocused window:

<PastedGraphic-14.pdf><PastedGraphic-15.pdf>

and after saving:

<PastedGraphic-16.pdf><PastedGraphic-17.pdf>

LyX does not do this--the main document button are always

<PastedGraphic-20.pdf>
Attached is a patch to solve that problem.

This produces an ugly warning on the output because if you use the setWindowModified(), Qt complains about not finding in the windowTitle() the "[*]" sequence. The attached patch suppresses these warnings inserting always that "[*]" placeholder (docs say the * is not displayed if the setModified() is set to false so it seems safe to add it always).

However, I can spot similarities and/or duplication of functionality with GuiWorkArea.cpp, specifically where you see the calls to Buffer::isClean() and the addition of the " (changed)" suffix to the file name in tab titles. Specifically, check whether the iteration you do in GuiView::isClean() is the same or different from the one made in GuiWorkArea::updateWindowTitle(). I'd say at a glance that LyX made the choice to not rely on the "standard" *-based indication of a modified buffer, but rather used its own custom " (changed)" title suffix. However, I have no objections to using a more widely used and (Qt-level) standardized indication of the modified buffer.

I'm replying with a more insightful title, perhaps others will comment better on this point.

    T.

Index: src/frontends/qt4/GuiView.cpp
===================================================================
--- src/frontends/qt4/GuiView.cpp	(revisione 40911)
+++ src/frontends/qt4/GuiView.cpp	(copia locale)
@@ -303,17 +303,17 @@
 		bg_widget_->setFocus();
 	}
 
-	int tabWorkAreaCount()
+	int tabWorkAreaCount() const
 	{
 		return splitter_->count();
 	}
 
-	TabWorkArea * tabWorkArea(int i)
+	TabWorkArea * tabWorkArea(int i) const
 	{
 		return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
 	}
 
-	TabWorkArea * currentTabWorkArea()
+	TabWorkArea * currentTabWorkArea() const
 	{
 		int areas = tabWorkAreaCount();
 		if (areas == 1)
@@ -342,6 +342,16 @@
 	}
 #endif
 
+	bool isClean() const
+	{
+		QVector<GuiWorkArea*> areas = guiWorkAreas();
+		bool result = true;
+		for (int i = 0; i < areas.size(); ++i) {
+			result &= areas[i]->bufferView().buffer().isClean();
+		}
+		return result;
+	}
+	
 public:
 	GuiView * gv_;
 	GuiWorkArea * current_work_area_;
@@ -408,7 +418,7 @@
 				   Buffer::ExportStatus (Buffer::*syncFunc)(string const &, bool) const,
 				   Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const);
 
-	QVector<GuiWorkArea*> guiWorkAreas();
+	QVector<GuiWorkArea*> guiWorkAreas() const;
 };
 
 QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
@@ -523,7 +533,7 @@
 }
 
 
-QVector<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
+QVector<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas() const
 {
 	QVector<GuiWorkArea*> areas;
 	for (int i = 0; i < tabWorkAreaCount(); i++) {
@@ -1015,8 +1025,9 @@
 	if (wa != d.current_work_area_
 		|| wa->bufferView().buffer().isInternal())
 		return;
-	setWindowTitle(qt_("LyX: ") + wa->windowTitle());
+	setWindowTitle(qt_("LyX: ") + wa->windowTitle() + qt_("[*]"));
 	setWindowIconText(wa->windowIconText());
+	setWindowModified(!d.isClean());
 }
 
 

Reply via email to