summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp22
-rw-r--r--Swift/QtUI/QtLoginWindow.h1
-rw-r--r--Swift/QtUI/QtSettingsProvider.cpp12
-rw-r--r--Swift/QtUI/QtSettingsProvider.h1
4 files changed, 35 insertions, 1 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index a3e52dc..c3fdac2 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -193,7 +193,11 @@ bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) {
if (obj == username_->view() && event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace) {
- QMessageBox::information(this, "Remove profile", "Remove the profile '" + username_->view()->currentIndex().data().toString() + "'?");
+ QString jid(username_->view()->currentIndex().data().toString());
+ int result = QMessageBox::question(this, "Remove profile", "Remove the profile '" + jid + "'?", QMessageBox::Yes | QMessageBox::No);
+ if (result == QMessageBox::Yes) {
+ onPurgeSavedLoginRequest(Q2PSTRING(jid));
+ }
return true;
}
}
@@ -221,6 +225,22 @@ void QtLoginWindow::selectUser(const String& username) {
}
}
+void QtLoginWindow::removeAvailableAccount(const String& jid) {
+ QString username = P2QSTRING(jid);
+ int index = -1;
+ for (int i = 0; i < usernames_.count(); i++) {
+ if (username == usernames_[i]) {
+ index = i;
+ }
+ }
+ if (index >= 0) {
+ usernames_.removeAt(index);
+ passwords_.removeAt(index);
+ certificateFiles_.removeAt(index);
+ username_->removeItem(index);
+ }
+}
+
void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) {
QString username = P2QSTRING(defaultJID);
int index = -1;
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 90defd1..6987906 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -34,6 +34,7 @@ namespace Swift {
virtual void loggedOut();
virtual void setMessage(const String& message);
virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate);
+ virtual void removeAvailableAccount(const String& jid);
virtual void setLoginAutomatically(bool loginAutomatically);
virtual void setIsLoggingIn(bool loggingIn);
void selectUser(const String& user);
diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp
index ea0013a..4bddce3 100644
--- a/Swift/QtUI/QtSettingsProvider.cpp
+++ b/Swift/QtUI/QtSettingsProvider.cpp
@@ -60,6 +60,18 @@ void QtSettingsProvider::createProfile(const String& profile) {
settings_.setValue("profileList", stringList);
}
+void QtSettingsProvider::removeProfile(const String& profile) {
+ QString profileStart(P2QSTRING(profile) + ":");
+ foreach (QString key, settings_.allKeys()) {
+ if (key.startsWith(profileStart)) {
+ settings_.remove(key);
+ }
+ }
+ QStringList stringList = settings_.value("profileList").toStringList();
+ stringList.removeAll(P2QSTRING(profile));
+ settings_.setValue("profileList", stringList);
+}
+
QSettings* QtSettingsProvider::getQSettings() {
return &settings_;
}
diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h
index 5cdafd5..d1dbc5e 100644
--- a/Swift/QtUI/QtSettingsProvider.h
+++ b/Swift/QtUI/QtSettingsProvider.h
@@ -25,6 +25,7 @@ class QtSettingsProvider : public SettingsProvider {
virtual void storeInt(const String &settingPath, int settingValue);
virtual std::vector<String> getAvailableProfiles();
virtual void createProfile(const String& profile);
+ virtual void removeProfile(const String& profile);
QSettings* getQSettings();
private:
QSettings settings_;