[rkward/frameworks] rkward: Remove more kdelibs4support code
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 28 19:35:09 UTC 2016
Git commit 5873a27acae1b8635ac027cdb0e9b5fe8fedc189 by Thomas Friedrichsmeier.
Committed on 28/01/2016 at 19:35.
Pushed by tfry into branch 'frameworks'.
Remove more kdelibs4support code
M +1 -1 rkward/misc/CMakeLists.txt
M +1 -1 rkward/misc/getfilenamewidget.cpp
M +1 -3 rkward/misc/rkcommonfunctions.cpp
M +74 -34 rkward/misc/rkprogresscontrol.cpp
M +13 -9 rkward/misc/rksaveobjectchooser.cpp
M +22 -14 rkward/misc/rkspecialactions.cpp
M +2 -2 rkward/misc/rkspecialactions.h
M +4 -3 rkward/rkglobals.cpp
http://commits.kde.org/rkward/5873a27acae1b8635ac027cdb0e9b5fe8fedc189
diff --git a/rkward/misc/CMakeLists.txt b/rkward/misc/CMakeLists.txt
index 7ace6e5..b990ae5 100644
--- a/rkward/misc/CMakeLists.txt
+++ b/rkward/misc/CMakeLists.txt
@@ -31,7 +31,7 @@ SET(misc_STAT_SRCS
)
ADD_LIBRARY(misc STATIC ${misc_STAT_SRCS})
-TARGET_LINK_LIBRARIES(misc Qt5::Widgets KF5::KDELibs4Support)
+TARGET_LINK_LIBRARIES(misc Qt5::Widgets KF5::WidgetsAddons KF5::KIOWidgets Qt5::Xml KF5::ConfigCore KF5::Parts KF5::KDELibs4Support)
########### install files ###############
diff --git a/rkward/misc/getfilenamewidget.cpp b/rkward/misc/getfilenamewidget.cpp
index 716532a..c68f9f9 100644
--- a/rkward/misc/getfilenamewidget.cpp
+++ b/rkward/misc/getfilenamewidget.cpp
@@ -21,8 +21,8 @@
#include <QFileDialog>
#include <klocale.h>
-#include <KLineEdit>
#include <kurlrequester.h>
+#include <KLineEdit>
#include "../settings/rksettingsmodulegeneral.h"
diff --git a/rkward/misc/rkcommonfunctions.cpp b/rkward/misc/rkcommonfunctions.cpp
index 88693bb..cc24cc6 100644
--- a/rkward/misc/rkcommonfunctions.cpp
+++ b/rkward/misc/rkcommonfunctions.cpp
@@ -23,8 +23,6 @@
#include <klocale.h>
#include <kxmlguiclient.h>
-#include <kglobal.h>
-#include <kstandarddirs.h>
#include "../settings/rksettingsmodulegeneral.h"
@@ -149,7 +147,7 @@ namespace RKCommonFunctions {
}
QString getRKWardDataDir () {
- return (KGlobal::dirs ()->findResourceDir ("data", "rkward/resource.ver") + "rkward/");
+ return (QStandardPaths::locate (QStandardPaths::AppDataLocation, "resource.ver").replace ("resource.ver", QString ()));
}
QString getUseableRKWardSavefileName (const QString &prefix, const QString &postfix) {
diff --git a/rkward/misc/rkprogresscontrol.cpp b/rkward/misc/rkprogresscontrol.cpp
index 955579f..c49d967 100644
--- a/rkward/misc/rkprogresscontrol.cpp
+++ b/rkward/misc/rkprogresscontrol.cpp
@@ -22,9 +22,10 @@
#include <QVBoxLayout>
#include <QScrollBar>
#include <QTimer>
+#include <QDialog>
+#include <QDialogButtonBox>
#include <klocale.h>
-#include <kdialog.h>
#include "../rkglobals.h"
#include "../rbackend/rinterface.h"
@@ -32,9 +33,8 @@
#include "../debug.h"
-
/** This class provides the dialog shown as part of an RKProgressControl. Generally you should not use this class directly, but rather use RKProgressControl. */
-class RKProgressControlDialog : public KDialog {
+class RKProgressControlDialog : public QDialog {
public:
/** constructor. */
RKProgressControlDialog (const QString &text, const QString &caption, int mode_flags, bool modal);
@@ -42,14 +42,19 @@ public:
~RKProgressControlDialog ();
public:
void addOutput (const ROutput *output);
- void setCloseTextToClose ();
void finished ();
protected:
void closeEvent (QCloseEvent *e) override;
void scrollDown ();
+ void toggleDetails ();
private:
+/** Replace "Cancel" button text with "Close" (to be called, when underlying command has finished */
+ void setCloseTextToClose ();
+
QLabel *error_indicator;
QTextEdit *output_text;
+ QWidget *detailsbox;
+ QDialogButtonBox *buttons;
QString output_button_text;
@@ -226,31 +231,39 @@ QString RKProgressControl::fullCommandOutput() {
#include <qlayout.h>
#include <QTextEdit>
#include <qlabel.h>
+#include <QPushButton>
-#include <kvbox.h>
#include <kstandardguiitem.h>
-RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QString &caption, int mode_flags, bool modal) : KDialog (0) {
+RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QString &caption, int mode_flags, bool modal) : QDialog (0) {
RK_TRACE (MISC);
setAttribute (Qt::WA_DeleteOnClose, true);
setModal (modal);
- setCaption (caption);
+ setWindowTitle (caption);
+
+ QVBoxLayout *layout = new QVBoxLayout (this);
- KVBox *vbox = new KVBox (this);
- vbox->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
- setMainWidget (vbox);
+ QWidget *mainbox = new QWidget (this);
+ QVBoxLayout *mainboxlayout = new QVBoxLayout (mainbox);
+ mainbox->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
+ mainboxlayout->setContentsMargins (0, 0, 0, 0);
- QLabel *label = new QLabel (text, vbox);
+ QLabel *label = new QLabel (text, mainbox);
label->setWordWrap (true);
+ mainboxlayout->addWidget (label);
- error_indicator = new QLabel (i18n ("<b>There have been errors and / or warnings. See below for a transcript</b>"), vbox);
+ error_indicator = new QLabel (i18n ("<b>There have been errors and / or warnings. See below for a transcript</b>"), mainbox);
QPalette palette = error_indicator->palette ();
palette.setColor (error_indicator->foregroundRole (), QColor (255, 0, 0));
error_indicator->setPalette (palette);
error_indicator->hide ();
+ mainboxlayout->addWidget (error_indicator);
+
+ detailsbox = new QWidget (this);
+ QVBoxLayout *detailsboxlayout = new QVBoxLayout (detailsbox);
+ detailsboxlayout->setContentsMargins (0, 0, 0, 0);
- KVBox* output_box = new KVBox ();
QString ocaption;
if (mode_flags & RKProgressControl::IncludeRegularOutput) {
output_button_text = i18n ("Output");
@@ -259,28 +272,32 @@ RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QSt
output_button_text = i18n ("Errors / Warnings");
ocaption = i18n ("Errors / Warnings:");
}
- new QLabel (ocaption, output_box);
+ label = new QLabel (ocaption, detailsbox);
+ detailsboxlayout->addWidget (label);
- output_text = new QTextEdit (output_box);
+ output_text = new QTextEdit (detailsbox);
output_text->setReadOnly (true);
output_text->setPlainText (QString ());
output_text->setUndoRedoEnabled (false);
output_text->setLineWrapMode (QTextEdit::NoWrap);
output_text->setMinimumWidth (QFontMetrics (output_text->font ()).averageCharWidth () * RKSettingsModuleR::getDefaultWidth ());
- output_box->setStretchFactor (output_text, 10);
-
- setDetailsWidget (output_box);
- // it's important to use a queued connection, here. Otherwise, if the details widget gets shown due to error output, scrollDown() would only scroll to the position directly *above* the new output.
- connect (this, &KDialog::aboutToShowDetails, this, &RKProgressControlDialog::scrollDown, Qt::QueuedConnection);
-
- KDialog::ButtonCodes button_codes = KDialog::Cancel;
- if (mode_flags & RKProgressControl::OutputSwitchable) button_codes |= KDialog::Details;
- setButtons (button_codes);
- if (button_codes & KDialog::Details) setButtonText (KDialog::Details, output_button_text);
- if (mode_flags & RKProgressControl::AllowCancel) setButtonText (KDialog::Cancel, i18n ("Cancel"));
+ detailsboxlayout->addWidget (output_text);
+ detailsboxlayout->setStretchFactor (output_text, 10);
+
+ buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, this);
+ connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
+ if (mode_flags & RKProgressControl::OutputSwitchable) {
+ QPushButton* button = buttons->addButton (output_button_text, QDialogButtonBox::HelpRole);
+ connect (button, &QPushButton::clicked, this, &RKProgressControlDialog::toggleDetails);
+ }
+ if (mode_flags & RKProgressControl::AllowCancel) buttons->button (QDialogButtonBox::Cancel)->setText (i18n ("Cancel"));
else (setCloseTextToClose ());
- if (mode_flags & RKProgressControl::OutputShownByDefault) setDetailsWidgetVisible (true);
+ detailsbox->setVisible (mode_flags & RKProgressControl::OutputShownByDefault);
+
+ layout->addWidget (mainbox);
+ layout->addWidget (detailsbox);
+ layout->addWidget (buttons);
prevent_close = (mode_flags & RKProgressControl::PreventClose);
@@ -297,8 +314,10 @@ void RKProgressControlDialog::addOutput (const ROutput *output) {
// scrolled all the way to the bottom?
bool at_end = true;
- QScrollBar *bar = output_text->verticalScrollBar ();
- if (bar && (bar->value () < bar->maximum ())) at_end = false;
+ if (detailsbox->isVisible ()) {
+ QScrollBar *bar = output_text->verticalScrollBar ();
+ if (bar && (bar->value () < bar->maximum ())) at_end = false;
+ }
if (output->type != last_output_type) {
last_output_type = output->type;
@@ -308,7 +327,7 @@ void RKProgressControlDialog::addOutput (const ROutput *output) {
output_text->setTextColor (Qt::black);
} else {
output_text->setTextColor (Qt::red);
- if (!isDetailsWidgetVisible ()) setDetailsWidgetVisible (true);
+ if (!detailsbox->isVisible ()) toggleDetails ();
error_indicator->show ();
}
}
@@ -319,6 +338,25 @@ void RKProgressControlDialog::addOutput (const ROutput *output) {
if (at_end && output_text->isVisible ()) scrollDown ();
}
+void RKProgressControlDialog::toggleDetails () {
+ RK_TRACE (MISC);
+
+ int new_height = height ();
+ if (detailsbox->isVisible ()) {
+ new_height -= detailsbox->height ();
+ detailsbox->hide ();
+ } else {
+ int h = detailsbox->height ();
+ if (h <= 0) h = detailsbox->sizeHint ().height ();
+ new_height += h;
+ detailsbox->show ();
+ scrollDown ();
+ }
+
+ layout ()->activate ();
+ resize (width (), new_height);
+}
+
void RKProgressControlDialog::scrollDown () {
RK_TRACE (MISC);
@@ -329,8 +367,10 @@ void RKProgressControlDialog::scrollDown () {
void RKProgressControlDialog::setCloseTextToClose () {
RK_TRACE (MISC);
- setButtonGuiItem (KDialog::Cancel, KStandardGuiItem::ok ());
- setButtonText (KDialog::Cancel, i18n ("Done"));
+ buttons->removeButton (buttons->button (QDialogButtonBox::Cancel));
+ QPushButton *done_button = buttons->addButton (QDialogButtonBox::Ok);
+ done_button->setText (i18n ("Done"));
+ connect (done_button, &QPushButton::clicked, this, &QDialog::reject);
}
void RKProgressControlDialog::finished () {
@@ -338,7 +378,7 @@ void RKProgressControlDialog::finished () {
is_done = true;
setCloseTextToClose ();
- if (!isDetailsWidgetVisible ()) reject ();
+ if (!detailsbox->isVisible ()) reject ();
}
void RKProgressControlDialog::closeEvent (QCloseEvent *e) {
@@ -347,7 +387,7 @@ void RKProgressControlDialog::closeEvent (QCloseEvent *e) {
if (prevent_close && (!is_done)) {
e->ignore ();
} else {
- KDialog::closeEvent (e);
+ QDialog::closeEvent (e);
}
}
diff --git a/rkward/misc/rksaveobjectchooser.cpp b/rkward/misc/rksaveobjectchooser.cpp
index 029757b..f5e52e1 100644
--- a/rkward/misc/rksaveobjectchooser.cpp
+++ b/rkward/misc/rksaveobjectchooser.cpp
@@ -23,10 +23,10 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QTimer>
+#include <QDialog>
+#include <QDialogButtonBox>
#include <klocale.h>
-#include <kdialog.h>
-#include <kvbox.h>
#include "../core/robjectlist.h"
#include "../core/renvironmentobject.h"
@@ -98,18 +98,22 @@ void RKSaveObjectChooser::selectRootObject () {
RK_TRACE (MISC);
// TODO: not very pretty, yet
- KDialog *dialog = new KDialog (this);
- dialog->setButtons (KDialog::Ok|KDialog::Cancel);
- dialog->setCaption (i18n ("Select parent object"));
+ QDialog *dialog = new QDialog (this);
+ dialog->setWindowTitle (i18n ("Select parent object"));
dialog->setModal (true);
- KVBox *page = new KVBox (dialog);
- dialog->setMainWidget (page);
+ QVBoxLayout *layout = new QVBoxLayout (dialog);
- RKObjectListView* list_view = new RKObjectListView (false, page);
+ RKObjectListView* list_view = new RKObjectListView (false, dialog);
list_view->setSelectionMode (QAbstractItemView::SingleSelection);
list_view->initialize ();
list_view->setObjectCurrent (root_object);
- connect (list_view, &QAbstractItemView::doubleClicked, dialog, &KDialog::accept);
+ connect (list_view, &QAbstractItemView::doubleClicked, dialog, &QDialog::accept);
+ layout->addWidget (list_view);
+
+ QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, dialog);
+ connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, dialog, &QDialog::accept);
+ connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, dialog, &QDialog::reject);
+ layout->addWidget (buttons);
dialog->exec ();
diff --git a/rkward/misc/rkspecialactions.cpp b/rkward/misc/rkspecialactions.cpp
index 93ba472..6bb2adc 100644
--- a/rkward/misc/rkspecialactions.cpp
+++ b/rkward/misc/rkspecialactions.cpp
@@ -53,22 +53,20 @@ void RKPasteSpecialAction::doSpecialPaste () {
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
-
-#include <kvbox.h>
-#include <khbox.h>
+#include <QDialogButtonBox>
+#include <QPushButton>
#include "../dataeditor/rktextmatrix.h"
#include "../core/robject.h"
-RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent) {
+RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : QDialog (parent) {
RK_TRACE (MISC);
- setCaption (i18n ("Paste Special..."));
- setButtons (KDialog::Ok | KDialog::Cancel);
+ setWindowTitle (i18n ("Paste Special..."));
- KVBox* page = new KVBox (this);
- setMainWidget (page);
- KHBox* row = new KHBox (page);
+ QVBoxLayout *pagelayout = new QVBoxLayout (this);
+ QHBoxLayout *rowlayout = new QHBoxLayout ();
+ pagelayout->addLayout (rowlayout);
QGroupBox* box;
QVBoxLayout* group_layout;
@@ -76,7 +74,7 @@ RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent)
QRadioButton* rbutton;
// Mode box
- box = new QGroupBox (i18n ("Paste Mode"), row);
+ box = new QGroupBox (i18n ("Paste Mode"), this);
group_layout = new QVBoxLayout (box);
dimensionality_group = new QButtonGroup (box);
rbutton = new QRadioButton (i18n ("Single string"), box);
@@ -90,11 +88,12 @@ RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent)
rbutton->setChecked (true);
group_layout->addWidget (rbutton);
connect (dimensionality_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKPasteSpecialDialog::updateState);
+ rowlayout->addWidget (box);
const QMimeData* clipdata = QApplication::clipboard ()->mimeData ();
// Separator box
- box = new QGroupBox (i18n ("Field Separator"), row);
+ box = new QGroupBox (i18n ("Field Separator"), this);
group_layout = new QVBoxLayout (box);
separator_group = new QButtonGroup (box);
rbutton = new QRadioButton (i18n ("Tab"), box);
@@ -119,11 +118,13 @@ RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent)
h_layout->addWidget (separator_freefield);
group_layout->addLayout (h_layout);
connect (separator_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKPasteSpecialDialog::updateState);
+ rowlayout->addWidget (box);
- row = new KHBox (page);
+ rowlayout = new QHBoxLayout;
+ pagelayout->addLayout (rowlayout);
// Quoting box
- box = new QGroupBox (i18n ("Quoting"), row);
+ box = new QGroupBox (i18n ("Quoting"), this);
group_layout = new QVBoxLayout (box);
quoting_group = new QButtonGroup (box);
rbutton = new QRadioButton (i18n ("Do not quote values"), box);
@@ -137,9 +138,10 @@ RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent)
quoting_group->addButton (rbutton, QuoteAll);
group_layout->addWidget (rbutton);
connect (quoting_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKPasteSpecialDialog::updateState);
+ rowlayout->addWidget (box);
// further controls
- box = new QGroupBox (i18n ("Transformations"), row);
+ box = new QGroupBox (i18n ("Transformations"), this);
group_layout = new QVBoxLayout (box);
reverse_h_box = new QCheckBox (i18n ("Reverse horizontally"), box);
group_layout->addWidget (reverse_h_box);
@@ -150,6 +152,12 @@ RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent)
insert_nas_box = new QCheckBox (i18n ("Insert NAs where needed"), box);
insert_nas_box->setChecked (true);
group_layout->addWidget (insert_nas_box);
+ rowlayout->addWidget (box);
+
+ QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
+ connect (buttons->button (QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
+ connect (buttons->button (QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
+ pagelayout->addWidget (buttons);
updateState (); // initialize
}
diff --git a/rkward/misc/rkspecialactions.h b/rkward/misc/rkspecialactions.h
index 75711fb..31b363a 100644
--- a/rkward/misc/rkspecialactions.h
+++ b/rkward/misc/rkspecialactions.h
@@ -37,14 +37,14 @@ signals:
};
-#include <kdialog.h>
+#include <QDialog>
class QButtonGroup;
class QLineEdit;
class QCheckBox;
/** Dialog used in RKPasteSpecialAction */
-class RKPasteSpecialDialog : public KDialog {
+class RKPasteSpecialDialog : public QDialog {
Q_OBJECT
public:
explicit RKPasteSpecialDialog (QWidget* parent);
diff --git a/rkward/rkglobals.cpp b/rkward/rkglobals.cpp
index d549652..c62333e 100644
--- a/rkward/rkglobals.cpp
+++ b/rkward/rkglobals.cpp
@@ -22,13 +22,14 @@ RInterface *RKGlobals::rinter;
RKModificationTracker *RKGlobals::mtracker;
QVariantMap RKGlobals::startup_options;
-#include <kdialog.h>
+#include <QApplication>
+#include <QStyle>
int RKGlobals::marginHint () {
- return KDialog::marginHint ();
+ return QApplication::style ()->pixelMetric (QStyle::PM_DefaultChildMargin);
}
int RKGlobals::spacingHint () {
- return KDialog::spacingHint ();
+ return QApplication::style ()->pixelMetric (QStyle::PM_DefaultLayoutSpacing);
}
More information about the rkward-tracker
mailing list