[kmymoney/5.0] kmymoney: Improve handling of the backup feature on MS windows
Thomas Baumgart
null at kde.org
Sun Mar 22 18:27:58 GMT 2020
Git commit c195e0cda57949891207f5c7f2c817d2b6fbe298 by Thomas Baumgart.
Committed on 22/03/2020 at 18:27.
Pushed by tbaumgart into branch '5.0'.
Improve handling of the backup feature on MS windows
On windows the option to mount a device is not available. So the GUI
elements have been removed in this case and the label is adjusted to be
more precise.
GUI:
BUG: 419082
FIXED-IN: 5.0.9
M +10 -0 kmymoney/dialogs/kbackupdlg.cpp
M +15 -35 kmymoney/dialogs/kbackupdlg.ui
M +15 -3 kmymoney/kmymoney.cpp
https://commits.kde.org/kmymoney/c195e0cda57949891207f5c7f2c817d2b6fbe298
diff --git a/kmymoney/dialogs/kbackupdlg.cpp b/kmymoney/dialogs/kbackupdlg.cpp
index b19ea45c2..1966c361c 100644
--- a/kmymoney/dialogs/kbackupdlg.cpp
+++ b/kmymoney/dialogs/kbackupdlg.cpp
@@ -2,6 +2,7 @@
* Copyright 2001-2003 Michael Edwardes <mte at users.sourceforge.net>
* Copyright 2001-2002 Felix Rodriguez <frodriguez at users.sourceforge.net>
* Copyright 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz at gmail.com>
+ * Copyright 2020 Thomas Baumgart <tbaumgart at kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -52,6 +53,15 @@ KBackupDlg::KBackupDlg(QWidget* parent) :
ui->setupUi(this);
readConfig();
+#ifdef Q_OS_WIN
+ // in windows we don't have a mount capability so
+ // we hide that option from the user and deactivate it
+ ui->mountCheckBox->setChecked(false);
+ ui->mountCheckBox->hide();
+ ui->txtAutoMount->hide();
+ ui->lblMountPoint->setText(i18n("Backup location:"));
+#endif
+
ui->chooseButton->setIcon(Icons::get(Icon::Folder));
connect(ui->chooseButton, &QAbstractButton::clicked, this, &KBackupDlg::chooseButtonClicked);
diff --git a/kmymoney/dialogs/kbackupdlg.ui b/kmymoney/dialogs/kbackupdlg.ui
index 706691fd4..0a0615305 100644
--- a/kmymoney/dialogs/kbackupdlg.ui
+++ b/kmymoney/dialogs/kbackupdlg.ui
@@ -7,53 +7,23 @@
<x>0</x>
<y>0</y>
<width>641</width>
- <height>301</height>
+ <height>369</height>
</rect>
</property>
<property name="windowTitle">
<string>Backup</string>
</property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="leftMargin">
- <number>11</number>
- </property>
- <property name="topMargin">
- <number>11</number>
- </property>
- <property name="rightMargin">
- <number>11</number>
- </property>
- <property name="bottomMargin">
- <number>11</number>
- </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="TextLabel1">
<property name="text">
- <string>Use this dialog to backup your data.
+ <string>Use this dialog to backup your data.
Please make sure you have a disk inserted and that the drive is ready. Then choose the mount point from either the Choose button or by entering the path in the available box.
-Click OK to perform the backup. If your system does not use an automounter, make sure you mark the checkbox below to "mount this directory before backing up."</string>
+Click OK to perform the backup.</string>
</property>
<property name="alignment">
<set>Qt::AlignTop</set>
@@ -63,6 +33,16 @@ Click OK to perform the backup. If your system does not use an automounter, make
</property>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="txtAutoMount">
+ <property name="text">
+ <string>If your system does not use an automounter, make sure you mark the checkbox below to "mount this directory before backing up."</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp
index 8d4a3fa2f..4382950a9 100644
--- a/kmymoney/kmymoney.cpp
+++ b/kmymoney/kmymoney.cpp
@@ -2,7 +2,7 @@
kmymoney.cpp
-------------------
copyright : (C) 2000 by Michael Edwardes <mte at users.sourceforge.net>
- (C) 2002-2019 by Thomas Baumgart <tbaumgart at kde.org>
+ (C) 2002-2020 by Thomas Baumgart <tbaumgart at kde.org>
(C) 2017-2018 by Łukasz Wojniłowicz <lukasz.wojnilowicz at gmail.com>
****************************************************************************/
@@ -2339,9 +2339,8 @@ void KMyMoneyApp::slotBackupFile()
QPointer<KBackupDlg> backupDlg = new KBackupDlg(this);
int returncode = backupDlg->exec();
- if (returncode == QDialog::Accepted && backupDlg != 0) {
-
+ if (returncode == QDialog::Accepted && backupDlg != 0) {
d->m_backupMount = backupDlg->mountCheckBoxChecked();
d->m_proc.clearProgram();
d->m_backupState = BACKUP_MOUNTING;
@@ -2382,6 +2381,19 @@ bool KMyMoneyApp::slotBackupWriteFile()
QString backupfile = d->m_mountpoint + '/' + d->m_storageInfo.url.fileName();
KMyMoneyUtils::appendCorrectFileExt(backupfile, today);
+#ifdef Q_OS_WIN
+ // on windows, a leading slash is a problem if a drive letter follows
+ // eg. "/Z:/path". In case we detect such a pattern, we simply remove
+ // the leading slash
+ const QRegularExpression re(QStringLiteral("/(?<path>\\w+:/.+)"),
+ QRegularExpression::CaseInsensitiveOption|QRegularExpression::UseUnicodePropertiesOption
+ );
+ const auto match = re.match(backupfile);
+ if (match.hasMatch() && !match.captured(QStringLiteral("path")).isEmpty()) {
+ backupfile = match.captured(QStringLiteral("path"));
+ }
+#endif
+
// check if file already exists and ask what to do
QFile f(backupfile);
if (f.exists()) {
More information about the kde-doc-english
mailing list