[rkward] /: Add overwrite confirmation checkbox to <browser>
Thomas Friedrichsmeier
null at kde.org
Fri Oct 19 15:59:09 BST 2018
Git commit 8e4761c956ed440a8b0fb2446ec301a71ef64803 by Thomas Friedrichsmeier.
Committed on 19/10/2018 at 14:57.
Pushed by tfry into branch 'master'.
Add overwrite confirmation checkbox to <browser>
M +1 -0 ChangeLog
M +11 -1 rkward/plugin/rkpluginbrowser.cpp
M +2 -0 rkward/plugin/rkpluginbrowser.h
https://commits.kde.org/rkward/8e4761c956ed440a8b0fb2446ec301a71ef64803
diff --git a/ChangeLog b/ChangeLog
index eafe1d6d..3014cf07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
--- Version 0.7.1 - UNRELEASED
+- <browser> element in save file mode gains checkbox to control overwriting of existing files
- Fixed: <browser> element could not be set to not required
- Fixed: max.print option was not saved, correctly, when set from RKWard settings
- Add command-line option --autoreuse to avoid shipping two separate .desktop files
diff --git a/rkward/plugin/rkpluginbrowser.cpp b/rkward/plugin/rkpluginbrowser.cpp
index 8c023ad1..94a09e30 100644
--- a/rkward/plugin/rkpluginbrowser.cpp
+++ b/rkward/plugin/rkpluginbrowser.cpp
@@ -20,6 +20,7 @@
#include <QVBoxLayout>
#include <QUrl>
#include <QDir>
+#include <QCheckBox>
#include <KLocalizedString>
@@ -63,6 +64,11 @@ RKPluginBrowser::RKPluginBrowser (const QDomElement &element, RKComponent *paren
vbox->addWidget (selector);
+ overwrite_confirm = new QCheckBox (this);
+ connect (overwrite_confirm, &QCheckBox::toggled, this, &RKPluginBrowser::validateInput);
+ vbox->addWidget (overwrite_confirm);
+ overwrite_confirm->setVisible (mode == GetFileNameWidget::SaveFile);
+
validation_timer.setSingleShot (true);
connect (&validation_timer, &QTimer::timeout, this, &RKPluginBrowser::validateInput);
@@ -137,6 +143,8 @@ void RKPluginBrowser::validateInput () {
}
} else {
RK_ASSERT (mode == GetFileNameWidget::SaveFile);
+ overwrite_confirm->setText (i18n ("Overwrite?"));
+ overwrite_confirm->setEnabled (false);
if (!(fi.isWritable () || (!fi.exists () && QFileInfo (fi.dir ().absolutePath ()).isWritable ()))) {
tip = i18n ("The specified file is not writable.");
status = RKComponentBase::Unsatisfied;
@@ -144,9 +152,11 @@ void RKPluginBrowser::validateInput () {
tip = i18n ("You have to specify a filename (not directory) to write to.");
status = RKComponentBase::Unsatisfied;
} else if (fi.exists ()) {
+ overwrite_confirm->setText ("Overwrite? (The given file already exists)");
+ overwrite_confirm->setEnabled (true);
// TODO: soft warning (icon)
tip = i18n ("<b>Note:</b> The given file already exists, and will be modified / overwritten.");
- status = RKComponentBase::Satisfied;
+ status = overwrite_confirm->isChecked () ? RKComponentBase::Satisfied : RKComponentBase::Unsatisfied;
} else {
status = RKComponentBase::Satisfied;
}
diff --git a/rkward/plugin/rkpluginbrowser.h b/rkward/plugin/rkpluginbrowser.h
index 722822f1..f7ea870e 100644
--- a/rkward/plugin/rkpluginbrowser.h
+++ b/rkward/plugin/rkpluginbrowser.h
@@ -26,6 +26,7 @@
class GetFileNameWidget;
class QDomElement;
+class QCheckBox;
/** RKComponent to select one or more file(s) or directories
@@ -58,6 +59,7 @@ private:
bool updating;
bool only_local;
QString label_string;
+ QCheckBox* overwrite_confirm;
};
#endif
More information about the rkward-tracker
mailing list