r20077 by craig - #13062: Apply patch for message box buttons

scribus-commit scribus-commit at lists.scribus.net
Tue May 12 21:00:11 UTC 2015


Author: craig
Date: Tue May 12 21:00:11 2015
New Revision: 20077

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20077
Log:
#13062: Apply patch for message box buttons

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/cmddialog.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmddialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20077&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmddialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmddialog.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmddialog.cpp Tue May 12 21:00:11 2015
@@ -77,18 +77,30 @@
 	char *message = const_cast<char*>("");
 	uint result;
 	QMessageBox::Icon ico = QMessageBox::NoIcon;
-	int butt1 = QMessageBox::Ok|QMessageBox::Default;
-	int butt2 = QMessageBox::NoButton;
-	int butt3 = QMessageBox::NoButton;
+	int butt[3] = { QMessageBox::Ok|QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton };
+	QMessageBox::StandardButtons buttons = QMessageBox::StandardButtons(0);
+	enum QMessageBox::StandardButton defaultButton = QMessageBox::NoButton;
 	char* kwargs[] = {const_cast<char*>("caption"), const_cast<char*>("message"),
 						const_cast<char*>("icon"), const_cast<char*>("button1"),
 						const_cast<char*>("button2"), const_cast<char*>("button3"), NULL};
-	if (!PyArg_ParseTupleAndKeywords(args, kw, "eses|iiii", kwargs, "utf-8", &caption, "utf-8", &message, &ico, &butt1, &butt2, &butt3))
+	if (!PyArg_ParseTupleAndKeywords(args, kw, "eses|iiii", kwargs, "utf-8", &caption, "utf-8", &message, &ico, &butt[0], &butt[1], &butt[2]))
 		return NULL;
 	QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor));
 	// ScMessageBox mb(ico, butt1, butt2, butt3, ScCore->primaryMainWindow());
-	ScMessageBox mb(ico, QString::fromUtf8(caption), QString::fromUtf8(message), QMessageBox::Ok, ScCore->primaryMainWindow());
-	mb.setDefaultButton(QMessageBox::Ok);
+	for (int bi = 0; bi < 3; bi++) {
+		enum QMessageBox::StandardButton b = static_cast<QMessageBox::StandardButton>(butt[bi]);
+		if (b != QMessageBox::NoButton) {
+			if ((b & QMessageBox::Default) != 0) {
+				b = QMessageBox::StandardButton(b & ~QMessageBox::Default);
+				defaultButton = b;
+			}
+			buttons |= b;
+		}
+	}
+	ScMessageBox mb(ico, QString::fromUtf8(caption), QString::fromUtf8(message), buttons, ScCore->primaryMainWindow());
+	if (defaultButton != QMessageBox::NoButton) {
+		mb.setDefaultButton(defaultButton);
+	}
 	result = mb.exec();
 //	QApplication::restoreOverrideCursor();
 	return PyInt_FromLong(static_cast<long>(result));

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20077&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Tue May 12 21:00:11 2015
@@ -675,6 +675,7 @@
 	PyDict_SetItemString(d, const_cast<char*>("BUTTON_ABORT"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::Abort));
 	PyDict_SetItemString(d, const_cast<char*>("BUTTON_RETRY"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::Retry));
 	PyDict_SetItemString(d, const_cast<char*>("BUTTON_IGNORE"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::Ignore));
+	PyDict_SetItemString(d, const_cast<char*>("BUTTON_DEFAULT"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::Default));
 	PyDict_SetItemString(d, const_cast<char*>("ICON_NONE"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::NoIcon));
 	PyDict_SetItemString(d, const_cast<char*>("ICON_INFORMATION"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::Information));
 	PyDict_SetItemString(d, const_cast<char*>("ICON_WARNING"), Py_BuildValue(const_cast<char*>("i"), QMessageBox::Warning));




More information about the scribus-commit mailing list