diff options
-rw-r--r-- | accounts/maildir/maildirsettings.cpp | 14 | ||||
-rw-r--r-- | accounts/maildir/maildirsettings.h | 8 |
2 files changed, 12 insertions, 10 deletions
diff --git a/accounts/maildir/maildirsettings.cpp b/accounts/maildir/maildirsettings.cpp index 18abaebb..c8b892d7 100644 --- a/accounts/maildir/maildirsettings.cpp +++ b/accounts/maildir/maildirsettings.cpp | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <QDebug> | 24 | #include <QDebug> |
25 | #include <QUuid> | 25 | #include <QUuid> |
26 | #include <QDir> | 26 | #include <QDir> |
27 | #include <QUrl> | ||
27 | 28 | ||
28 | MaildirSettings::MaildirSettings(QObject *parent) | 29 | MaildirSettings::MaildirSettings(QObject *parent) |
29 | : QObject(parent) | 30 | : QObject(parent) |
@@ -65,17 +66,18 @@ QByteArray MaildirSettings::accountIdentifier() const | |||
65 | return mAccountIdentifier; | 66 | return mAccountIdentifier; |
66 | } | 67 | } |
67 | 68 | ||
68 | void MaildirSettings::setPath(const QString &path) | 69 | void MaildirSettings::setPath(const QUrl &path) |
69 | { | 70 | { |
70 | if (mPath != path) { | 71 | auto normalizedPath = path.path(); |
71 | mPath = path; | 72 | if (mPath != normalizedPath) { |
73 | mPath = normalizedPath; | ||
72 | emit pathChanged(); | 74 | emit pathChanged(); |
73 | } | 75 | } |
74 | } | 76 | } |
75 | 77 | ||
76 | QString MaildirSettings::path() const | 78 | QUrl MaildirSettings::path() const |
77 | { | 79 | { |
78 | return mPath; | 80 | return QUrl(mPath); |
79 | } | 81 | } |
80 | 82 | ||
81 | QValidator *MaildirSettings::pathValidator() const | 83 | QValidator *MaildirSettings::pathValidator() const |
@@ -83,7 +85,7 @@ QValidator *MaildirSettings::pathValidator() const | |||
83 | class PathValidator : public QValidator { | 85 | class PathValidator : public QValidator { |
84 | State validate(QString &input, int &pos) const { | 86 | State validate(QString &input, int &pos) const { |
85 | Q_UNUSED(pos); | 87 | Q_UNUSED(pos); |
86 | if (QDir(input).exists()) { | 88 | if (!input.isEmpty() && QDir(input).exists()) { |
87 | return Acceptable; | 89 | return Acceptable; |
88 | } else { | 90 | } else { |
89 | return Intermediate; | 91 | return Intermediate; |
diff --git a/accounts/maildir/maildirsettings.h b/accounts/maildir/maildirsettings.h index 063fb9da..9e5b6a4c 100644 --- a/accounts/maildir/maildirsettings.h +++ b/accounts/maildir/maildirsettings.h | |||
@@ -26,8 +26,8 @@ class MaildirSettings : public QObject | |||
26 | Q_OBJECT | 26 | Q_OBJECT |
27 | Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier) | 27 | Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier) |
28 | Q_PROPERTY(QByteArray accountIdentifier READ accountIdentifier WRITE setAccountIdentifier) | 28 | Q_PROPERTY(QByteArray accountIdentifier READ accountIdentifier WRITE setAccountIdentifier) |
29 | Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) | 29 | Q_PROPERTY(QUrl path READ path WRITE setPath NOTIFY pathChanged) |
30 | Q_PROPERTY(QValidator* pathValidator READ pathValidator) | 30 | Q_PROPERTY(QValidator* pathValidator READ pathValidator CONSTANT) |
31 | 31 | ||
32 | public: | 32 | public: |
33 | MaildirSettings(QObject *parent = 0); | 33 | MaildirSettings(QObject *parent = 0); |
@@ -38,8 +38,8 @@ public: | |||
38 | void setAccountIdentifier(const QByteArray &); | 38 | void setAccountIdentifier(const QByteArray &); |
39 | QByteArray accountIdentifier() const; | 39 | QByteArray accountIdentifier() const; |
40 | 40 | ||
41 | void setPath(const QString &); | 41 | void setPath(const QUrl &); |
42 | QString path() const; | 42 | QUrl path() const; |
43 | QValidator *pathValidator() const; | 43 | QValidator *pathValidator() const; |
44 | 44 | ||
45 | Q_INVOKABLE void save(); | 45 | Q_INVOKABLE void save(); |