[rkward/frameworks] rkward: Next round of KDELibs4Support code removal. Mostly KDialog->QDialog

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Fri Feb 12 07:47:54 UTC 2016


Git commit a03999067ac60f7f9613a242a85a70ae1c9e505e by Thomas Friedrichsmeier.
Committed on 12/02/2016 at 07:47.
Pushed by tfry into branch 'frameworks'.

Next round of KDELibs4Support code removal. Mostly KDialog->QDialog

M  +1    -1    rkward/dialogs/CMakeLists.txt
M  +17   -14   rkward/dialogs/rkerrordialog.cpp
M  +24   -16   rkward/dialogs/rkrecoverdialog.cpp
M  +2    -3    rkward/dialogs/rkrecoverdialog.h
M  +0    -3    rkward/misc/CMakeLists.txt
M  +15   -9    rkward/misc/editformatdialog.cpp
M  +3    -3    rkward/misc/editformatdialog.h
M  +17   -12   rkward/misc/editlabelsdialog.cpp
M  +2    -3    rkward/misc/editlabelsdialog.h
M  +0    -1    rkward/misc/rkxmlguisyncer_p.h
M  +1    -0    rkward/rkward.cpp

http://commits.kde.org/rkward/a03999067ac60f7f9613a242a85a70ae1c9e505e

diff --git a/rkward/dialogs/CMakeLists.txt b/rkward/dialogs/CMakeLists.txt
index 5baf039..08a8b21 100644
--- a/rkward/dialogs/CMakeLists.txt
+++ b/rkward/dialogs/CMakeLists.txt
@@ -11,4 +11,4 @@ SET(dialogs_STAT_SRCS
    )
 
 ADD_LIBRARY(dialogs STATIC ${dialogs_STAT_SRCS})
-TARGET_LINK_LIBRARIES(dialogs Qt5::Widgets KF5::ConfigWidgets KF5::KDELibs4Support)
+TARGET_LINK_LIBRARIES(dialogs Qt5::Widgets KF5::Parts KF5::ConfigWidgets)
diff --git a/rkward/dialogs/rkerrordialog.cpp b/rkward/dialogs/rkerrordialog.cpp
index ca3aa5c..285143d 100644
--- a/rkward/dialogs/rkerrordialog.cpp
+++ b/rkward/dialogs/rkerrordialog.cpp
@@ -17,10 +17,8 @@
 
 #include "rkerrordialog.h"
 
-#include <kdialog.h>
 #include <klocale.h>
 #include <kmessagebox.h>
-#include <kvbox.h>
 #include <ktoolinvocation.h>
 
 #include <QIcon>
@@ -30,6 +28,7 @@
 #include <QTextStream>
 #include <QPushButton>
 #include <QDialog>
+#include <QVBoxLayout>
 
 #include "../rbackend/rinterface.h"
 #include "../rbackend/rksessionvars.h"
@@ -42,18 +41,14 @@
 
 #define SUBMIT_ADDRESS "https://bugs.kde.org/enter_bug.cgi"
 
-class RKBugzillaReportDialog : public KDialog {
+class RKBugzillaReportDialog : public QDialog {
 public:
-	RKBugzillaReportDialog (QWidget* parent, const QString& report_template) : KDialog (parent) {
+	RKBugzillaReportDialog (QWidget* parent, const QString& report_template) : QDialog (parent) {
 		RK_TRACE (DIALOGS);
 
 		RKBugzillaReportDialog::report_template = report_template;
-		setCaption (i18n ("Reporting bugs in RKWard"));
-		setButtons (KDialog::Ok | KDialog::Cancel);
-		setButtonText (KDialog::Ok, i18n ("Report issue"));
-		setButtonIcon (KDialog::Ok, QIcon::fromTheme("tools-report-bug"));
-		KVBox *vbox = new KVBox (this);
-		setMainWidget (vbox);
+		setWindowTitle (i18n ("Reporting bugs in RKWard"));
+		QVBoxLayout *layout = new QVBoxLayout (this);
 		QLabel *label = new QLabel (i18n ("<p><b>Where should I report bugs or wishes?</b></p><p>Thank you for taking the time to help improve RKWard. To help us "
 		                                  "handle your request, efficiently, please submit your bug reports or wishes in the "
 		                                  "<a href=\"%1\">KDE bugtracking system</a>. Note that you need a user account for this, so that we will be able to contact you, "
@@ -62,14 +57,22 @@ public:
 		                         QString ("http://bugs.kde.org"), QString ("https://bugs.kde.org/createaccount.cgi"), QString ("http://rkward.kde.org/bugs/"))
 		                          + i18n ("<p><b>What information should I provide, and how?</b></p>Clicking \"Report issue\" will take you to the "
 		                                  "KDE bugtracking system. After logging in, some information will already be pre-filled into the report form. Please make sure "
-		                                  "to fill in the missing bits - in English - where indicated, especially in the \"Comment\" field.</p>"), vbox);
+		                                  "to fill in the missing bits - in English - where indicated, especially in the \"Comment\" field.</p>"), this);
 		label->setWordWrap (true);
 		label->setOpenExternalLinks (true);
+		layout->addWidget (label);
+
+		QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+		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);
 	}
 
-	// KF5 TODO: add override keyword
 	void accept () override {
 		// The report template is just too large to pass it via GET, so we use a local proxy page to pass it in a POST request
 		QTemporaryFile proxy;
@@ -89,7 +92,7 @@ public:
 		proxy.close ();
 
 		KToolInvocation::invokeBrowser (QUrl::fromLocalFile (proxy.fileName ()).toEncoded ());
-		KDialog::accept ();
+		QDialog::accept ();
 	}
 private:
 	QString report_template;
@@ -117,7 +120,7 @@ void RKErrorDialog::reportableErrorMessage (QWidget* parent_widget, const QStrin
 
 	int ret = KMessageBox::createKMessageBox (dialog, buttonbox, QMessageBox::Critical, user_message, QStringList(), QString(), 0, options, details);
 
-	if (ret == KDialog::No) {
+	if (ret == QDialogButtonBox::No) {
 		reportBug (parent_widget, (message_code.isEmpty () ? QString () : i18n ("Message code: %1\n", message_code)) + user_message);
 	}
 }
diff --git a/rkward/dialogs/rkrecoverdialog.cpp b/rkward/dialogs/rkrecoverdialog.cpp
index 638addf..c454f66 100644
--- a/rkward/dialogs/rkrecoverdialog.cpp
+++ b/rkward/dialogs/rkrecoverdialog.cpp
@@ -19,35 +19,30 @@
 
 #include <krun.h>
 #include <klocale.h>
+#include <kmessagebox.h>
 
 #include <QDir>
 #include <QFileInfo>
 #include <QLabel>
-#include <kmessagebox.h>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QDateTime>
 
 #include "../settings/rksettingsmodulegeneral.h"
+#include "../misc/rkcommonfunctions.h"
 
 #include "../debug.h"
 
-RKRecoverDialog::RKRecoverDialog (const QStringList &recovery_files) {
+RKRecoverDialog::RKRecoverDialog (const QStringList &recovery_files) : QDialog () {
 	RK_TRACE (DIALOGS);
 	RK_ASSERT (!recovery_files.isEmpty ());
 	files = recovery_files;
 
+	QVBoxLayout *layout = new QVBoxLayout (this);
+
 	const QString caption = i18n ("Crash recovery file detected");
-	setCaption (caption);
-	setButtons (KDialog::Ok | KDialog::Cancel | KDialog::User1);
-	setButtonText (KDialog::Ok, i18n ("Recover"));
-	setButtonToolTip (KDialog::Ok, i18n ("Saves the recovery file(s), and opens it (or the most recent one)"));
-	setButtonWhatsThis (KDialog::Ok, buttonToolTip (KDialog::Ok));
-	setButtonText (KDialog::Cancel, i18n ("Save for later"));
-	setButtonToolTip (KDialog::Cancel, i18n ("Saves the recovery file(s) for later use, but does not open it"));
-	setButtonWhatsThis (KDialog::Cancel, buttonToolTip (KDialog::Cancel));
-	setButtonText (KDialog::User1, i18n ("Delete"));
-	setButtonToolTip (KDialog::User1, i18n ("Deletes the recovery file(s)"));
-	setButtonWhatsThis (KDialog::User1, buttonToolTip (KDialog::User1));
-	
-	connect (this, &KDialog::user1Clicked, this, &RKRecoverDialog::deleteButtonClicked);
+	setWindowTitle (caption);
+
 	QLabel *label = new QLabel (this);
 	QString text = QString ("<p><b>%1</b></p>").arg (caption);
 	text.append (i18n ("<p>It looks like RKWard has crashed, recently. We are sorry about that! However, not everything is lost, and with a bit of luck, your data has been saved in time.</p>"));
@@ -55,7 +50,20 @@ RKRecoverDialog::RKRecoverDialog (const QStringList &recovery_files) {
 	text.append (i18n ("<p>Do you want to open this file, now, save it for later (as <i>%1</i>), or discard it?</p>", saveFileFor (recovery_files.first ())));
 	label->setText (text);
 	label->setWordWrap (true);
-	setMainWidget (label);
+	layout->addWidget (label);
+
+	QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Discard);
+	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);
 }
 
 RKRecoverDialog::~RKRecoverDialog () {
diff --git a/rkward/dialogs/rkrecoverdialog.h b/rkward/dialogs/rkrecoverdialog.h
index 6f021f3..779b6d5 100644
--- a/rkward/dialogs/rkrecoverdialog.h
+++ b/rkward/dialogs/rkrecoverdialog.h
@@ -18,12 +18,11 @@
 #ifndef RKRECOVERDIALOG_H
 #define RKRECOVERDIALOG_H
 
-#include <kdialog.h>
-
+#include <QDialog>
 #include <QStringList>
 
 /** Dialog to offer loading of recovery files during startup. */
-class RKRecoverDialog : public KDialog {
+class RKRecoverDialog : public QDialog {
 	Q_OBJECT
 public:
 /** Check whether a crash recovery file is available. If so, display a dialog, offering to load the recovery file.
diff --git a/rkward/misc/CMakeLists.txt b/rkward/misc/CMakeLists.txt
index 2fe7a11..2bd092d 100644
--- a/rkward/misc/CMakeLists.txt
+++ b/rkward/misc/CMakeLists.txt
@@ -1,8 +1,5 @@
 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}    )
 
-
-########### next target ###############
-
 SET(misc_STAT_SRCS
    rkspinbox.cpp
    getfilenamewidget.cpp
diff --git a/rkward/misc/editformatdialog.cpp b/rkward/misc/editformatdialog.cpp
index 857fbcd..7a6e042 100644
--- a/rkward/misc/editformatdialog.cpp
+++ b/rkward/misc/editformatdialog.cpp
@@ -23,22 +23,23 @@
 #include <qstringlist.h>
 #include <QVBoxLayout>
 #include <QTimer>
+#include <QDialogButtonBox>
+#include <QPushButton>
 
 #include <klocale.h>
-#include <kvbox.h>
 
 #include "../core/rkvariable.h"
 #include "../rkglobals.h"
 #include "../debug.h"
 
-EditFormatDialog::EditFormatDialog (QWidget *parent) : KDialog (parent) {
+EditFormatDialog::EditFormatDialog (QWidget *parent) : QDialog (parent) {
 	RK_TRACE (EDITOR);
 
-	KVBox *vbox = new KVBox ();
-	setMainWidget (vbox);
+	QVBoxLayout *layout = new QVBoxLayout (this);
 
 	alignment_group = new QButtonGroup (this);
-	QGroupBox* alignment_box = new QGroupBox (i18n ("Alignment"), vbox);
+	QGroupBox* alignment_box = new QGroupBox (i18n ("Alignment"), this);
+	layout->addWidget (alignment_box);
 	QVBoxLayout* group_layout = new QVBoxLayout (alignment_box);
 	group_layout->setContentsMargins (0, 0, 0, 0);
 	QRadioButton* button;
@@ -51,7 +52,8 @@ EditFormatDialog::EditFormatDialog (QWidget *parent) : KDialog (parent) {
 	alignment_group->button ((int) RKVariable::FormattingOptions::AlignDefault)->setChecked (true);
 
 	precision_group = new QButtonGroup (this);
-	QGroupBox* precision_box = new QGroupBox (i18n ("Decimal Places"), vbox);
+	QGroupBox* precision_box = new QGroupBox (i18n ("Decimal Places"), this);
+	layout->addWidget (precision_box);
 	group_layout = new QVBoxLayout (precision_box);
 	precision_group->addButton (button = new QRadioButton (i18n ("Default setting"), precision_box), (int) RKVariable::FormattingOptions::PrecisionDefault);
 	group_layout->addWidget (button);
@@ -65,7 +67,11 @@ EditFormatDialog::EditFormatDialog (QWidget *parent) : KDialog (parent) {
 	group_layout->addWidget (precision_field);
 	precision_group->button ((int) RKVariable::FormattingOptions::PrecisionDefault)->setChecked (true);
 
-	setButtons (KDialog::Ok | KDialog::Cancel);
+	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);
+	layout->addWidget (buttons);
 }
 
 EditFormatDialog::~EditFormatDialog () {
@@ -75,7 +81,7 @@ EditFormatDialog::~EditFormatDialog () {
 void EditFormatDialog::initialize (const RKVariable::FormattingOptions& options, const QString& varname) {
 	RK_TRACE (EDITOR);
 
-	setCaption (i18n ("Formatting options for '%1'", varname));
+	setWindowTitle (i18n ("Formatting options for '%1'", varname));
 
 	EditFormatDialog::options = options;
 
@@ -96,7 +102,7 @@ void EditFormatDialog::accept () {
 		options.precision = 0;
 	}
 
-	KDialog::accept ();
+	QDialog::accept ();
 }
 
 void EditFormatDialog::precisionFieldChanged (int) {
diff --git a/rkward/misc/editformatdialog.h b/rkward/misc/editformatdialog.h
index ec23efe..7c009d1 100644
--- a/rkward/misc/editformatdialog.h
+++ b/rkward/misc/editformatdialog.h
@@ -17,7 +17,7 @@
 #ifndef EDITFORMATDIALOG_H
 #define EDITFORMATDIALOG_H
 
-#include <kdialog.h>
+#include <QDialog>
 
 #include "../core/rkvariable.h"
 #include "rktableview.h"
@@ -30,13 +30,13 @@ Allows editing of format-attributes for an RKVariable
 
 @author Thomas Friedrichsmeier
 */
-class EditFormatDialog : public KDialog {
+class EditFormatDialog : public QDialog {
 	Q_OBJECT
 public slots:
 	void precisionFieldChanged (int);
 protected:
 /** reimplemented to make the newly selected options available */
-	void accept ();
+	void accept () override;
 
 friend class EditFormatDialogProxy;
 /** ctor */
diff --git a/rkward/misc/editlabelsdialog.cpp b/rkward/misc/editlabelsdialog.cpp
index 6ed7e79..1efe09c 100644
--- a/rkward/misc/editlabelsdialog.cpp
+++ b/rkward/misc/editlabelsdialog.cpp
@@ -17,17 +17,16 @@
 #include "editlabelsdialog.h"
 
 #include <klocale.h>
-#include <kdialog.h>
-#include <QAction>
 #include <kactioncollection.h>
-#include <kvbox.h>
 
 #include <qlabel.h>
-#include <qlayout.h>
 #include <QHeaderView>
 #include <QTimer>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
+#include <QAction>
+#include <QDialogButtonBox>
+#include <QPushButton>
 
 #include "../core/rkvariable.h"
 #include "../dataeditor/rktextmatrix.h"
@@ -207,18 +206,24 @@ QVariant RKVarLevelsTableModel::headerData (int section, Qt::Orientation orienta
 
 //////////////// EditLabelsDialog ///////////////////////
 
-EditLabelsDialog::EditLabelsDialog (QWidget *parent, const RObject::ValueLabels& labels, const QString& varname) : KDialog (parent) {
+EditLabelsDialog::EditLabelsDialog (QWidget *parent, const RObject::ValueLabels& labels, const QString& varname) : QDialog (parent) {
 	RK_TRACE (EDITOR);
 
-	KVBox *mainvbox = new KVBox ();
-	setMainWidget (mainvbox);
-	QLabel *label = new QLabel (i18n ("Levels can be assigned only to consecutive integers starting with 1 (the index column is read only). To remove levels at the end of the list, just set them to empty."), mainvbox);
+	setWindowTitle (i18n ("Levels / Value labels for '%1'", varname));
+
+	QVBoxLayout *layout = new QVBoxLayout (this);
+	QLabel *label = new QLabel (i18n ("Levels can be assigned only to consecutive integers starting with 1 (the index column is read only). To remove levels at the end of the list, just set them to empty."), this);
 	label->setWordWrap (true);
+	layout->addWidget (label);
 
-	table = new RKVarLevelsTable (mainvbox, labels);
+	table = new RKVarLevelsTable (this, labels);
+	layout->addWidget (table);
 
-	setButtons (KDialog::Ok | KDialog::Cancel);
-	setCaption (i18n ("Levels / Value labels for '%1'", varname));
+	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);
+	layout->addWidget (buttons);
 }
 
 EditLabelsDialog::~EditLabelsDialog () {
@@ -229,7 +234,7 @@ void EditLabelsDialog::accept () {
 	RK_TRACE (EDITOR);
 
 	table->setCurrentIndex (QModelIndex ());	// should flush editing
-	KDialog::accept ();
+	QDialog::accept ();
 }
 
 ////////////////// EditLabelsDialogProxy /////////////////////////
diff --git a/rkward/misc/editlabelsdialog.h b/rkward/misc/editlabelsdialog.h
index 3b50270..46999fa 100644
--- a/rkward/misc/editlabelsdialog.h
+++ b/rkward/misc/editlabelsdialog.h
@@ -17,8 +17,7 @@
 #ifndef EDITLABELSDIALOG_H
 #define EDITLABELSDIALOG_H
 
-#include <kdialog.h>
-
+#include <QDialog>
 #include <QAbstractTableModel>
 
 #include "../core/robject.h"
@@ -72,7 +71,7 @@ Allows editing of value labels / factor levels for an RKVariable. Use EditLabels
 
 @author Thomas Friedrichsmeier
 */
-class EditLabelsDialog : public KDialog {
+class EditLabelsDialog : public QDialog {
 protected:
 friend class EditLabelsDialogProxy;
 /** constructor., the variable to work on.
diff --git a/rkward/misc/rkxmlguisyncer_p.h b/rkward/misc/rkxmlguisyncer_p.h
index 9714f3f..21265d6 100644
--- a/rkward/misc/rkxmlguisyncer_p.h
+++ b/rkward/misc/rkxmlguisyncer_p.h
@@ -22,7 +22,6 @@
 #include <kxmlguifactory.h>
 #include <kactioncollection.h>
 #include <kdirwatch.h>
-#include <kapplication.h>
 
 #include <QDir>
 #include <QMultiHash>
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 58614cf..cc20273 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -44,6 +44,7 @@
 #include <kactionmenu.h>
 #include <QIcon>
 #include <KSharedConfig>
+#include <kdialog.h>
 
 // application specific includes
 #include "rkward.h"



More information about the rkward-tracker mailing list