http://www.lyx.org/trac/ticket/3218

I propose to backport this (r29324) to branch (patch attached).

The simple reason is that I'm using beamer-article with included beamer 
document regularly now, and the "Included document has different textclass" 
message is driving me nuts.

Objections?

Jürgen
Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py	(Revision 29907)
+++ development/scons/scons_manifest.py	(Arbeitskopie)
@@ -950,6 +950,7 @@
     TextLayoutUi.ui
     ThesaurusUi.ui
     TocUi.ui
+    ToggleWarningUi.ui
     VSpaceUi.ui
     ViewSourceUi.ui
     WrapUi.ui
Index: src/insets/InsetInclude.cpp
===================================================================
--- src/insets/InsetInclude.cpp	(Revision 29907)
+++ src/insets/InsetInclude.cpp	(Arbeitskopie)
@@ -497,7 +497,7 @@
 				included_file.displayName(),
 				from_utf8(tmp->params().documentClass().name()),
 				from_utf8(masterBuffer->params().documentClass().name()));
-			Alert::warning(_("Different textclasses"), text);
+			Alert::warning(_("Different textclasses"), text, true);
 		}
 
 		// Make sure modules used in child are all included in master
Index: src/frontends/alert.h
===================================================================
--- src/frontends/alert.h	(Revision 29907)
+++ src/frontends/alert.h	(Arbeitskopie)
@@ -37,8 +37,11 @@
 /**
  * Display a warning to the user. Title should be a short (general) summary.
  * Only use this if the user cannot perform some remedial action.
+ * \p askshowagain will display a check box where the user can turn off the
+ * warning for future cases. Ponder carefully if this is feasible.
  */
-void warning(docstring const & title, docstring const & message);
+void warning(docstring const & title, docstring const & message,
+	     bool const & askshowagain = false);
 
 /**
  * Display a warning to the user. Title should be a short (general) summary.
Index: src/frontends/qt4/GuiAlert.cpp
===================================================================
--- src/frontends/qt4/GuiAlert.cpp	(Revision 29907)
+++ src/frontends/qt4/GuiAlert.cpp	(Arbeitskopie)
@@ -4,6 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author John Levon
+ * \author Jürgen Spitzmüller
  * \author Abdelrazak Younes
  *
  * Full author contact details are available in file CREDITS.
@@ -18,6 +19,7 @@
 #include "qt_helpers.h"
 #include "LyX.h" // for lyx::use_gui
 #include "ui_AskForTextUi.h"
+#include "ui_ToggleWarningUi.h"
 #include "support/gettext.h"
 
 #include "support/debug.h"
@@ -25,9 +27,11 @@
 #include "support/lstrings.h"
 
 #include <QApplication>
+#include <QCheckBox>
 #include <QMessageBox>
 #include <QLineEdit>
 #include <QInputDialog>
+#include <QSettings>
 
 #include <iomanip>
 #include <iostream>
@@ -39,6 +43,17 @@
 namespace frontend {
 
 
+class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi
+{
+public:
+	GuiToggleWarningDialog(QWidget * parent) : QDialog(parent)
+	{
+		Ui::ToggleWarningUi::setupUi(this);
+		QDialog::setModal(true);
+	}
+};
+
+
 static docstring const formatted(docstring const & text)
 {
 	const int w = 80;
@@ -99,6 +114,29 @@
 }
 
 
+void toggleWarning(docstring const & title, docstring const & msg)
+{
+	if (!use_gui)
+		return;
+
+	QSettings settings;
+	if (settings.value("hidden_warnings/" + toqstr(msg), false).toBool())
+		return;
+
+	GuiToggleWarningDialog * dlg =
+		new GuiToggleWarningDialog(qApp->focusWidget());
+
+	dlg->setWindowTitle(toqstr(title));
+	dlg->messageLA->setText(toqstr(formatted(msg)));
+	dlg->dontShowAgainCB->setChecked(false);
+
+	if (dlg->exec() == QDialog::Accepted)
+		if (dlg->dontShowAgainCB->isChecked())
+			settings.setValue("hidden_warnings/"
+				+ toqstr(msg), true);
+}
+
+
 namespace Alert {
 
 int prompt(docstring const & title0, docstring const & question,
@@ -145,7 +183,8 @@
 }
 
 
-void warning(docstring const & title0, docstring const & message)
+void warning(docstring const & title0, docstring const & message,
+	     bool const & askshowagain)
 {
 	lyxerr << "Warning: " << title0 << '\n'
 	       << "----------------------------------------\n"
@@ -165,9 +204,12 @@
 			toqstr(formatted(message)));
 		return;
 	}
-	QMessageBox::warning(qApp->focusWidget(),
-			     toqstr(title),
-			     toqstr(formatted(message)));
+	if (!askshowagain)
+		QMessageBox::warning(qApp->focusWidget(),
+				toqstr(title),
+				toqstr(formatted(message)));
+	else
+		toggleWarning(title, message);
 }
 
 
Index: src/frontends/qt4/Makefile.am
===================================================================
--- src/frontends/qt4/Makefile.am	(Revision 29907)
+++ src/frontends/qt4/Makefile.am	(Arbeitskopie)
@@ -301,6 +301,7 @@
 	TextLayoutUi.ui \
 	ThesaurusUi.ui \
 	TocUi.ui \
+	ToggleWarningUi.ui \
 	ViewSourceUi.ui \
 	VSpaceUi.ui \
 	WrapUi.ui
Index: src/frontends/qt4/ui/ToggleWarningUi.ui
===================================================================
--- src/frontends/qt4/ui/ToggleWarningUi.ui	(Revision 0)
+++ src/frontends/qt4/ui/ToggleWarningUi.ui	(Revision 0)
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ToggleWarningUi</class>
+ <widget class="QDialog" name="ToggleWarningUi">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>310</width>
+    <height>140</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>LyX: Enter text</string>
+  </property>
+  <property name="sizeGripEnabled">
+   <bool>true</bool>
+  </property>
+  <layout class="QGridLayout">
+   <property name="margin">
+    <number>9</number>
+   </property>
+   <property name="spacing">
+    <number>6</number>
+   </property>
+   <item row="2" column="0" colspan="3">
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>247</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="3" column="0" colspan="3">
+    <widget class="QCheckBox" name="dontShowAgainCB">
+     <property name="toolTip">
+      <string>If you check this, LyX will not warn you again in the given case.</string>
+     </property>
+     <property name="text">
+      <string>&amp;Do not show this warning again!</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="3">
+    <widget class="QLabel" name="messageLA">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" colspan="3">
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>247</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="0">
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>81</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="1">
+    <widget class="QPushButton" name="okPB">
+     <property name="text">
+      <string>&amp;OK</string>
+     </property>
+     <property name="default">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="2">
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>81</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <includes>
+  <include location="local">qt_i18n.h</include>
+ </includes>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>okPB</sender>
+   <signal>clicked()</signal>
+   <receiver>ToggleWarningUi</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>134</x>
+     <y>116</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>134</x>
+     <y>69</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Reply via email to