summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp23
-rw-r--r--Swift/QtUI/QtLoginWindow.h4
-rw-r--r--Swift/QtUI/QtLoginWindowFactory.cpp4
-rw-r--r--Swift/QtUI/QtLoginWindowFactory.h2
-rw-r--r--Swift/QtUI/QtSettingsProvider.cpp17
-rw-r--r--Swift/QtUI/QtSettingsProvider.h2
6 files changed, 36 insertions, 16 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 62e0484..d25f732 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -16,7 +16,7 @@
namespace Swift{
-QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) : QMainWindow() {
+QtLoginWindow::QtLoginWindow() : QMainWindow() {
setWindowTitle("Swift");
resize(200, 500);
setContentsMargins(0,0,0,0);
@@ -58,10 +58,7 @@ QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPass
certificateButton_ = new QToolButton(this);
certificateButton_->setCheckable(true);
certificateButton_->setIcon(QIcon(":/icons/certificate.png"));
- certificateFile_ = P2QSTRING(defaultCertificate);
- if (!certificateFile_.isEmpty()) {
- certificateButton_->setChecked(true);
- }
+
credentialsLayout->addWidget(certificateButton_);
connect(certificateButton_, SIGNAL(clicked(bool)), SLOT(handleCertficateChecked(bool)));
@@ -71,9 +68,6 @@ QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPass
loginButton_->setDefault(true);
layout->addWidget(loginButton_);
- username_->setText(P2QSTRING(defaultJID));
- password_->setText(P2QSTRING(defaultPassword));
-
message_ = new QLabel(this);
message_->setTextFormat(Qt::RichText);
message_->setWordWrap(true);
@@ -81,7 +75,6 @@ QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPass
layout->addStretch();
remember_ = new QCheckBox(tr("Remember Password?"), this);
- remember_->setChecked(defaultPassword != "");
layout->addWidget(remember_);
connect(loginButton_, SIGNAL(clicked()), SLOT(loginClicked()));
stack_->addWidget(wrapperWidget);
@@ -102,12 +95,20 @@ QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPass
connect(quitAction, SIGNAL(activated()), SLOT(handleQuit()));
swiftMenu_->addAction(quitAction);
-
-
setInitialMenus();
this->show();
}
+void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) {
+ username_->setText(P2QSTRING(defaultJID));
+ password_->setText(P2QSTRING(defaultPassword));
+ certificateFile_ = P2QSTRING(defaultCertificate);
+ if (!certificateFile_.isEmpty()) {
+ certificateButton_->setChecked(true);
+ }
+ remember_->setChecked(defaultPassword != "");
+}
+
void QtLoginWindow::loggedOut() {
if (stack_->count() > 1) {
QWidget* current = stack_->currentWidget();
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 153f757..a4ec606 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -20,12 +20,12 @@ namespace Swift {
class QtLoginWindow : public QMainWindow, public LoginWindow {
Q_OBJECT
public:
- QtLoginWindow(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate);
+ QtLoginWindow();
void morphInto(MainWindow *mainWindow);
virtual void loggedOut();
virtual void setMessage(const String& message);
-
+ virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate);
private slots:
void loginClicked();
void handleCertficateChecked(bool);
diff --git a/Swift/QtUI/QtLoginWindowFactory.cpp b/Swift/QtUI/QtLoginWindowFactory.cpp
index 2405dd6..e351f43 100644
--- a/Swift/QtUI/QtLoginWindowFactory.cpp
+++ b/Swift/QtUI/QtLoginWindowFactory.cpp
@@ -8,8 +8,8 @@ QtLoginWindowFactory::QtLoginWindowFactory(QSplitter* splitter, QtSystemTray* sy
systemTray_ = systemTray;
}
-LoginWindow* QtLoginWindowFactory::createLoginWindow(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) {
- QtLoginWindow* window = new QtLoginWindow(defaultJID, defaultPassword, defaultCertificate);
+LoginWindow* QtLoginWindowFactory::createLoginWindow() {
+ QtLoginWindow* window = new QtLoginWindow();
if (splitter_) {
splitter_->insertWidget(0, window);
}
diff --git a/Swift/QtUI/QtLoginWindowFactory.h b/Swift/QtUI/QtLoginWindowFactory.h
index 7513ab6..0ae8284 100644
--- a/Swift/QtUI/QtLoginWindowFactory.h
+++ b/Swift/QtUI/QtLoginWindowFactory.h
@@ -11,7 +11,7 @@ namespace Swift {
Q_OBJECT
public:
QtLoginWindowFactory(QSplitter* splitter, QtSystemTray* systemTray);
- LoginWindow* createLoginWindow(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate);
+ LoginWindow* createLoginWindow();
private:
QSplitter* splitter_;
QtSystemTray* systemTray_;
diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp
index cf02d83..7012288 100644
--- a/Swift/QtUI/QtSettingsProvider.cpp
+++ b/Swift/QtUI/QtSettingsProvider.cpp
@@ -1,6 +1,8 @@
#include "QtSettingsProvider.h"
#include "QtSwiftUtil.h"
+#include <QStringList>
+
namespace Swift {
QtSettingsProvider::QtSettingsProvider() {
@@ -28,5 +30,20 @@ void QtSettingsProvider::storeBool(const String &settingPath, bool settingValue)
settings_.setValue(P2QSTRING(settingPath), settingValue);
}
+std::vector<String> QtSettingsProvider::getAvailableProfiles() {
+ std::vector<String> profiles;
+ QVariant profilesVariant = settings_.value("profileList");
+ foreach(QString profileQString, profilesVariant.toStringList()) {
+ profiles.push_back(Q2PSTRING(profileQString));
+ }
+ return profiles;
+}
+
+void QtSettingsProvider::createProfile(const String& profile) {
+ QStringList stringList = settings_.value("profileList").toStringList();
+ stringList.append(P2QSTRING(profile));
+ settings_.setValue("profileList", stringList);
+}
+
}
diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h
index fec4101..a8d5bcc 100644
--- a/Swift/QtUI/QtSettingsProvider.h
+++ b/Swift/QtUI/QtSettingsProvider.h
@@ -15,6 +15,8 @@ class QtSettingsProvider : public SettingsProvider {
virtual void storeString(const String &settingPath, const String &settingValue);
virtual bool getBoolSetting(const String &settingPath, bool defaultValue);
virtual void storeBool(const String &settingPath, bool settingValue);
+ virtual std::vector<String> getAvailableProfiles();
+ virtual void createProfile(const String& profile);
private:
QSettings settings_;
};