[rkward/frameworks] rkward: Use RKDialogButtonBox in most standard cases.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Feb 17 14:50:07 UTC 2016


Git commit 1d5184276173ee14173398ff73e3b7eaf92d60d1 by Thomas Friedrichsmeier.
Committed on 17/02/2016 at 14:49.
Pushed by tfry into branch 'frameworks'.

Use RKDialogButtonBox in most standard cases.

M  +2    -4    rkward/dialogs/rkerrordialog.cpp
M  +2    -6    rkward/dialogs/rkreadlinedialog.cpp
M  +2    -4    rkward/dialogs/rkrecoverdialog.cpp
M  +3    -5    rkward/dialogs/rkselectlistdialog.cpp
M  +4    -7    rkward/dialogs/startupdialog.cpp
M  +3    -4    rkward/misc/editformatdialog.cpp
M  +2    -4    rkward/misc/editlabelsdialog.cpp
M  +2    -6    rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp

http://commits.kde.org/rkward/1d5184276173ee14173398ff73e3b7eaf92d60d1

diff --git a/rkward/dialogs/rkerrordialog.cpp b/rkward/dialogs/rkerrordialog.cpp
index a44ac61..35e93d6 100644
--- a/rkward/dialogs/rkerrordialog.cpp
+++ b/rkward/dialogs/rkerrordialog.cpp
@@ -33,6 +33,7 @@
 #include "../rbackend/rinterface.h"
 #include "../rbackend/rksessionvars.h"
 #include "../misc/rkprogresscontrol.h"
+#include "../misc/rkdialogbuttonbox.h"
 #include "../rkglobals.h"
 #include "../rkward.h"
 #include "../version.h"
@@ -62,12 +63,9 @@ public:
 		label->setOpenExternalLinks (true);
 		layout->addWidget (label);
 
-		QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+		RKDialogButtonBox *buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
 		buttons->button (QDialogButtonBox::Ok)->setText (i18n ("Report issue"));
 		buttons->button (QDialogButtonBox::Ok)->setIcon (QIcon::fromTheme("tools-report-bug"));
-		connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
-		buttons->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
-		connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
 		layout->addWidget (buttons);
 
 		connect (this, &QDialog::finished, this, &RKBugzillaReportDialog::deleteLater);
diff --git a/rkward/dialogs/rkreadlinedialog.cpp b/rkward/dialogs/rkreadlinedialog.cpp
index 771bed1..44e0fa1 100644
--- a/rkward/dialogs/rkreadlinedialog.cpp
+++ b/rkward/dialogs/rkreadlinedialog.cpp
@@ -26,13 +26,12 @@
 #include <QTimer>
 #include <QVBoxLayout>
 #include <QFontDatabase>
-#include <QDialogButtonBox>
-#include <QPushButton>
 
 #include <klocale.h>
 #include <kglobalsettings.h>
 
 #include "../rbackend/rcommand.h"
+#include "../misc/rkdialogbuttonbox.h"
 
 #include "../debug.h"
 
@@ -79,10 +78,7 @@ RKReadLineDialog::RKReadLineDialog (QWidget *parent, const QString &caption, con
 	input->setFocus ();
 	layout->addWidget (input);
 
-	QDialogButtonBox *box = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	connect (box->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
-	connect (box->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
-	box->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
+	RKDialogButtonBox *box = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
 	layout->addWidget (box);
 }
 
diff --git a/rkward/dialogs/rkrecoverdialog.cpp b/rkward/dialogs/rkrecoverdialog.cpp
index c454f66..1d4e716 100644
--- a/rkward/dialogs/rkrecoverdialog.cpp
+++ b/rkward/dialogs/rkrecoverdialog.cpp
@@ -30,6 +30,7 @@
 
 #include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkcommonfunctions.h"
+#include "../misc/rkdialogbuttonbox.h"
 
 #include "../debug.h"
 
@@ -52,16 +53,13 @@ RKRecoverDialog::RKRecoverDialog (const QStringList &recovery_files) : QDialog (
 	label->setWordWrap (true);
 	layout->addWidget (label);
 
-	QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Discard);
+	RKDialogButtonBox *buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Discard, this);
 	buttons->button (QDialogButtonBox::Ok)->setText (i18n ("Recover"));
 	RKCommonFunctions::setTips (i18n ("Saves the recovery file(s), and opens it (or the most recent one)"), buttons->button (QDialogButtonBox::Ok));
 	buttons->button (QDialogButtonBox::Cancel)->setText (i18n ("Save for later"));
 	RKCommonFunctions::setTips (i18n ("Saves the recovery file(s) for later use, but does not open it"), buttons->button (QDialogButtonBox::Cancel));
 	buttons->button (QDialogButtonBox::Discard)->setText (i18n ("Delete"));
 	RKCommonFunctions::setTips (i18n ("Deletes the recovery file(s)"), buttons->button (QDialogButtonBox::Discard));
-	connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
-	buttons->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
-	connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
 	connect (buttons->button (QDialogButtonBox::Discard), &QPushButton::clicked, this, &RKRecoverDialog::deleteButtonClicked);
 	layout->addWidget (buttons);
 }
diff --git a/rkward/dialogs/rkselectlistdialog.cpp b/rkward/dialogs/rkselectlistdialog.cpp
index 0af0443..f83d7f5 100644
--- a/rkward/dialogs/rkselectlistdialog.cpp
+++ b/rkward/dialogs/rkselectlistdialog.cpp
@@ -20,12 +20,13 @@
 #include <QListWidget>
 #include <QLabel>
 #include <QVBoxLayout>
-#include <QDialogButtonBox>
 #include <QPushButton>
 #include <QScrollBar>
 
 #include <klocale.h>
 
+#include "../misc/rkdialogbuttonbox.h"
+
 #include "../debug.h"
 
 /** A QListWidget with a sane sizeHint() */
@@ -59,10 +60,7 @@ RKSelectListDialog::RKSelectListDialog (QWidget *parent, const QString &caption,
 	}
 	layout->addWidget (input);
 
-	buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
-	connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
-	buttons->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
+	buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
 	layout->addWidget (buttons);
 
 	connect (input, &QListWidget::itemSelectionChanged, this, &RKSelectListDialog::updateState);
diff --git a/rkward/dialogs/startupdialog.cpp b/rkward/dialogs/startupdialog.cpp
index efa1f1d..7fa0a1a 100644
--- a/rkward/dialogs/startupdialog.cpp
+++ b/rkward/dialogs/startupdialog.cpp
@@ -31,11 +31,12 @@
 #include <klocale.h>
 #include <krecentfilesaction.h>
 #include <KConfigGroup>
-#include <QDialogButtonBox>
 #include <QPushButton>
 
 #include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkcommonfunctions.h"
+#include "../misc/rkdialogbuttonbox.h"
+
 #include "../debug.h"
 
 StartupDialog::StartupDialog (QWidget *parent, StartupDialogResult *result, KRecentFilesAction *recent_files) : QDialog (parent) {
@@ -89,12 +90,8 @@ StartupDialog::StartupDialog (QWidget *parent, StartupDialogResult *result, KRec
 	choser_layout->addWidget (file_list);
 	choser_layout->addWidget (remember_box = new QCheckBox (i18n ("Always do this on startup"), choser_box));
 
-	QDialogButtonBox *buttonBox = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	QPushButton *okButton = buttonBox->button (QDialogButtonBox::Ok);
-	okButton->setDefault (true);
-	okButton->setShortcut (Qt::CTRL | Qt::Key_Return);
-	connect (buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
-	connect (buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+	RKDialogButtonBox *buttonBox = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
+	buttonBox->button (QDialogButtonBox::Ok)->setDefault (true);
 	vbox->addWidget (buttonBox);
 }
 
diff --git a/rkward/misc/editformatdialog.cpp b/rkward/misc/editformatdialog.cpp
index 7a6e042..c3643ec 100644
--- a/rkward/misc/editformatdialog.cpp
+++ b/rkward/misc/editformatdialog.cpp
@@ -30,6 +30,8 @@
 
 #include "../core/rkvariable.h"
 #include "../rkglobals.h"
+#include "../misc/rkdialogbuttonbox.h"
+
 #include "../debug.h"
 
 EditFormatDialog::EditFormatDialog (QWidget *parent) : QDialog (parent) {
@@ -67,10 +69,7 @@ EditFormatDialog::EditFormatDialog (QWidget *parent) : QDialog (parent) {
 	group_layout->addWidget (precision_field);
 	precision_group->button ((int) RKVariable::FormattingOptions::PrecisionDefault)->setChecked (true);
 
-	QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
-	buttons->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
-	connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
+	RKDialogButtonBox *buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
 	layout->addWidget (buttons);
 }
 
diff --git a/rkward/misc/editlabelsdialog.cpp b/rkward/misc/editlabelsdialog.cpp
index 1efe09c..e10ca9e 100644
--- a/rkward/misc/editlabelsdialog.cpp
+++ b/rkward/misc/editlabelsdialog.cpp
@@ -30,6 +30,7 @@
 
 #include "../core/rkvariable.h"
 #include "../dataeditor/rktextmatrix.h"
+#include "../misc/rkdialogbuttonbox.h"
 #include "celleditor.h"
 
 #include "../debug.h"
@@ -219,10 +220,7 @@ EditLabelsDialog::EditLabelsDialog (QWidget *parent, const RObject::ValueLabels&
 	table = new RKVarLevelsTable (this, labels);
 	layout->addWidget (table);
 
-	QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
-	buttons->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
-	connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
+	RKDialogButtonBox *buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
 	layout->addWidget (buttons);
 }
 
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
index 9fc80e7..656df30 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
@@ -20,11 +20,9 @@
 #include <QGraphicsScene>
 #include <QGraphicsView>
 #include <QGraphicsRectItem>
-#include <QPushButton>
 #include <QHBoxLayout>
 #include <QMouseEvent>
 #include <QDialog>
-#include <QDialogButtonBox>
 
 #include <klocale.h>
 #include <sys/stat.h>
@@ -32,6 +30,7 @@
 #include "rkgraphicsdevice_protocol_shared.h"
 #include "../rinterface.h"
 #include "../../rkglobals.h"
+#include "../../misc/rkdialogbuttonbox.h"
 
 #include "../../debug.h"
 
@@ -321,10 +320,7 @@ void RKGraphicsDevice::confirmNewPage () {
 	QVBoxLayout *layout = new QVBoxLayout (dialog);
 	layout->addWidget (new QLabel (msg, dialog));
 
-	QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-	connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, dialog, &QDialog::accept);
-	buttons->button (QDialogButtonBox::Ok)->setShortcut (Qt::CTRL | Qt::Key_Return);
-	connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, dialog, &QDialog::reject);
+	RKDialogButtonBox *buttons = new RKDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, dialog);
 	layout->addWidget (buttons);
 
 //	dialog->setWindowModality (Qt::WindowModal);        // not good: Grays out the plot window



More information about the rkward-tracker mailing list