Introduce settingspage for editing core accounts
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 6 Nov 2009 08:58:05 +0000 (09:58 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 28 Nov 2009 23:39:41 +0000 (00:39 +0100)
src/qtui/mainwin.cpp
src/qtui/settingspages/coreaccounteditdlg.ui [new file with mode: 0644]
src/qtui/settingspages/coreaccountsettingspage.cpp [new file with mode: 0644]
src/qtui/settingspages/coreaccountsettingspage.h [new file with mode: 0644]
src/qtui/settingspages/coreaccountsettingspage.ui [new file with mode: 0644]
src/qtui/settingspages/settingspages.inc

index 2ff5701..21d4959 100644 (file)
 #include "settingspages/chatmonitorsettingspage.h"
 #include "settingspages/chatviewsettingspage.h"
 #include "settingspages/connectionsettingspage.h"
 #include "settingspages/chatmonitorsettingspage.h"
 #include "settingspages/chatviewsettingspage.h"
 #include "settingspages/connectionsettingspage.h"
+#include "settingspages/coreaccountsettingspage.h"
 #include "settingspages/generalsettingspage.h"
 #include "settingspages/highlightsettingspage.h"
 #include "settingspages/identitiessettingspage.h"
 #include "settingspages/generalsettingspage.h"
 #include "settingspages/highlightsettingspage.h"
 #include "settingspages/identitiessettingspage.h"
@@ -311,9 +312,9 @@ void MainWin::setupActions() {
   connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool)));
 
   coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll,
   connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool)));
 
   coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll,
-                                               0, 0, QKeySequence::Find))->setCheckable(true);
+                                                0, 0, QKeySequence::Find))->setCheckable(true);
   coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
   coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
-                                           this, SLOT(showAwayLog())));
+                                            this, SLOT(showAwayLog())));
   coll->addAction("ToggleMenuBar", new Action(SmallIcon("show-menu"), tr("Show &Menubar"), coll,
                                                 0, 0, tr("Ctrl+M")))->setCheckable(true);
 
   coll->addAction("ToggleMenuBar", new Action(SmallIcon("show-menu"), tr("Show &Menubar"), coll,
                                                 0, 0, tr("Ctrl+M")))->setCheckable(true);
 
@@ -893,6 +894,10 @@ void MainWin::showSettingsDlg() {
   dlg->registerSettingsPage(new AliasesSettingsPage(dlg));
   dlg->registerSettingsPage(new IgnoreListSettingsPage(dlg));
 
   dlg->registerSettingsPage(new AliasesSettingsPage(dlg));
   dlg->registerSettingsPage(new IgnoreListSettingsPage(dlg));
 
+  if(Quassel::runMode() != Quassel::Monolithic) {
+    dlg->registerSettingsPage(new CoreAccountSettingsPage(dlg));
+  }
+
   dlg->show();
 }
 
   dlg->show();
 }
 
diff --git a/src/qtui/settingspages/coreaccounteditdlg.ui b/src/qtui/settingspages/coreaccounteditdlg.ui
new file mode 100644 (file)
index 0000000..9477c08
--- /dev/null
@@ -0,0 +1,336 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CoreAccountEditDlg</class>
+ <widget class="QDialog" name="CoreAccountEditDlg">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>378</width>
+    <height>455</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Edit Core Account</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Account Details</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_3">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>Account Name:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" colspan="3">
+       <widget class="QLineEdit" name="accountName">
+        <property name="text">
+         <string>Local Core</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>Hostname:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" colspan="3">
+       <widget class="QLineEdit" name="hostName">
+        <property name="text">
+         <string>localhost</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>Port:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QSpinBox" name="port">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimum">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <number>65535</number>
+        </property>
+        <property name="value">
+         <number>4242</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="2">
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>63</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="3" column="0">
+       <widget class="QLabel" name="label_4">
+        <property name="text">
+         <string>User:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1" colspan="2">
+       <widget class="QLineEdit" name="user"/>
+      </item>
+      <item row="4" column="0">
+       <widget class="QLabel" name="label_10">
+        <property name="text">
+         <string>Password:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="1" colspan="2">
+       <widget class="QLineEdit" name="password">
+        <property name="echoMode">
+         <enum>QLineEdit::Password</enum>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="3">
+       <widget class="QCheckBox" name="rememberPassword">
+        <property name="text">
+         <string>Remember</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="useProxy">
+     <property name="title">
+      <string>Use a Proxy</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_5">
+        <property name="text">
+         <string>Proxy Type:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" colspan="2">
+       <widget class="QComboBox" name="proxyType">
+        <item>
+         <property name="text">
+          <string>Socks 5</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>HTTP</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item row="0" column="3">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>89</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="label_6">
+        <property name="text">
+         <string>Hostname:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" colspan="4">
+       <widget class="QLineEdit" name="proxyHostName">
+        <property name="text">
+         <string>localhost</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_7">
+        <property name="text">
+         <string>Port:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QSpinBox" name="proxyPort">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimum">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <number>65535</number>
+        </property>
+        <property name="value">
+         <number>8080</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="2" colspan="2">
+       <spacer name="horizontalSpacer_3">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>98</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="3" column="0">
+       <widget class="QLabel" name="label_8">
+        <property name="text">
+         <string>User:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1" colspan="3">
+       <widget class="QLineEdit" name="proxyUser"/>
+      </item>
+      <item row="4" column="0">
+       <widget class="QLabel" name="label_9">
+        <property name="text">
+         <string>Password:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="1" colspan="3">
+       <widget class="QLineEdit" name="proxyPassword">
+        <property name="echoMode">
+         <enum>QLineEdit::Password</enum>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="4">
+       <spacer name="horizontalSpacer_4">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="4" column="4">
+       <spacer name="horizontalSpacer_5">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>4</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>CoreAccountEditDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>275</x>
+     <y>521</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>207</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>CoreAccountEditDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>343</x>
+     <y>521</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>207</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/src/qtui/settingspages/coreaccountsettingspage.cpp b/src/qtui/settingspages/coreaccountsettingspage.cpp
new file mode 100644 (file)
index 0000000..cd488a3
--- /dev/null
@@ -0,0 +1,231 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by the Quassel Project                             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "coreaccountsettingspage.h"
+
+#include "client.h"
+#include "clientsettings.h"
+#include "coreaccountmodel.h"
+#include "iconloader.h"
+
+CoreAccountSettingsPage::CoreAccountSettingsPage(QWidget *parent)
+: SettingsPage(tr("Misc"), tr("Core Accounts"), parent),
+_lastAccountId(0),
+_lastAutoConnectId(0)
+{
+  ui.setupUi(this);
+  initAutoWidgets();
+  ui.addAccountButton->setIcon(SmallIcon("list-add"));
+  ui.editAccountButton->setIcon(SmallIcon("document-edit"));
+  ui.deleteAccountButton->setIcon(SmallIcon("edit-delete"));
+
+  _model = new CoreAccountModel(Client::coreAccountModel(), this);
+  ui.accountView->setModel(_model);
+  ui.autoConnectAccount->setModel(_model);
+
+  connect(model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), SLOT(rowsAboutToBeRemoved(QModelIndex, int, int)));
+  connect(model(), SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(rowsInserted(QModelIndex, int, int)));
+
+  connect(ui.accountView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(setWidgetStates()));
+  setWidgetStates();
+}
+
+void CoreAccountSettingsPage::load() {
+  _model->update(Client::coreAccountModel());
+
+  SettingsPage::load();
+  ui.accountView->setCurrentIndex(model()->index(0, 0));
+  ui.accountView->selectionModel()->select(model()->index(0, 0), QItemSelectionModel::Select);
+  setWidgetStates();
+}
+
+void CoreAccountSettingsPage::save() {
+  SettingsPage::save();
+  Client::coreAccountModel()->update(_model);
+  Client::coreAccountModel()->save();
+  CoreAccountSettings s;
+}
+
+QVariant CoreAccountSettingsPage::loadAutoWidgetValue(const QString &widgetName) {
+  if(widgetName == "autoConnectAccount") {
+    CoreAccountSettings s;
+    AccountId id = s.autoConnectAccount();
+    if(id <= 0)
+      return QVariant();
+    ui.autoConnectAccount->setCurrentIndex(model()->accountIndex(id).row());
+    return id.toInt();
+  }
+  return SettingsPage::loadAutoWidgetValue(widgetName);
+}
+
+void CoreAccountSettingsPage::saveAutoWidgetValue(const QString &widgetName, const QVariant &v) {
+  CoreAccountSettings s;
+  if(widgetName == "autoConnectAccount") {
+    AccountId id = _model->index(ui.autoConnectAccount->currentIndex(), 0).data(CoreAccountModel::AccountIdRole).value<AccountId>();
+    s.setAutoConnectAccount(id);
+    return;
+  }
+  SettingsPage::saveAutoWidgetValue(widgetName, v);
+}
+
+// TODO: Qt 4.6 - replace by proper rowsMoved() semantics
+void CoreAccountSettingsPage::rowsAboutToBeRemoved(const QModelIndex &index, int start, int end) {
+  _lastAutoConnectId = _lastAccountId = 0;
+  if(index.isValid() || start != end)
+    return;
+
+  // the current index is removed, so remember it in case it's reinserted immediately afterwards
+  AccountId id = model()->index(start, 0).data(CoreAccountModel::AccountIdRole).value<AccountId>();
+  if(start == ui.accountView->currentIndex().row())
+    _lastAccountId = id;
+  if(start == ui.autoConnectAccount->currentIndex())
+    _lastAutoConnectId = id;
+}
+
+void CoreAccountSettingsPage::rowsInserted(const QModelIndex &index, int start, int end) {
+  if(index.isValid() || start != end)
+    return;
+
+  // check if the inserted index was just removed and select it in that case
+  AccountId id = model()->index(start, 0).data(CoreAccountModel::AccountIdRole).value<AccountId>();
+  if(id == _lastAccountId)
+    ui.accountView->setCurrentIndex(model()->index(start, 0));
+  if(id == _lastAutoConnectId)
+    ui.autoConnectAccount->setCurrentIndex(start);
+  _lastAccountId = _lastAutoConnectId = 0;
+}
+
+void CoreAccountSettingsPage::on_addAccountButton_clicked() {
+  CoreAccountEditDlg dlg(CoreAccount(), this);
+  if(dlg.exec() == QDialog::Accepted) {
+    AccountId id =_model->createOrUpdateAccount(dlg.account());
+    ui.accountView->setCurrentIndex(model()->accountIndex(id));
+    widgetHasChanged();
+  }
+}
+
+void CoreAccountSettingsPage::on_editAccountButton_clicked() {
+  QModelIndex idx = ui.accountView->selectionModel()->currentIndex();
+  if(!idx.isValid())
+    return;
+
+  CoreAccountEditDlg dlg(_model->account(idx), this);
+  if(dlg.exec() == QDialog::Accepted) {
+    AccountId id = _model->createOrUpdateAccount(dlg.account());
+    ui.accountView->setCurrentIndex(model()->accountIndex(id));
+    widgetHasChanged();
+  }
+}
+
+void CoreAccountSettingsPage::on_deleteAccountButton_clicked() {
+  if(!ui.accountView->selectionModel()->selectedIndexes().count())
+    return;
+  AccountId id = ui.accountView->selectionModel()->selectedIndexes().at(0).data(CoreAccountModel::AccountIdRole).value<AccountId>();
+  if(id.isValid()) {
+    model()->removeAccount(id);
+    widgetHasChanged();
+  }
+}
+
+void CoreAccountSettingsPage::setWidgetStates() {
+  bool selected = ui.accountView->selectionModel()->selectedIndexes().count();
+
+  ui.editAccountButton->setEnabled(selected);
+  ui.deleteAccountButton->setEnabled(selected);
+}
+
+void CoreAccountSettingsPage::widgetHasChanged() {
+  setChangedState(testHasChanged());
+  setWidgetStates();
+}
+
+bool CoreAccountSettingsPage::testHasChanged() {
+  if(!(*model() == *Client::coreAccountModel()))
+    return true;
+
+  return false;
+}
+
+/*****************************************************************************************
+ * CoreAccountEditDlg
+ *****************************************************************************************/
+CoreAccountEditDlg::CoreAccountEditDlg(const CoreAccount &acct, QWidget *parent)
+  : QDialog(parent)
+{
+  ui.setupUi(this);
+
+  _account = acct;
+
+  ui.hostName->setText(acct.hostName());
+  ui.port->setValue(acct.port());
+  ui.accountName->setText(acct.accountName());
+  ui.user->setText(acct.user());
+  ui.password->setText(acct.password());
+  ui.rememberPassword->setChecked(acct.storePassword());
+  ui.useProxy->setChecked(acct.useProxy());
+  ui.proxyHostName->setText(acct.proxyHostName());
+  ui.proxyPort->setValue(acct.proxyPort());
+  ui.proxyType->setCurrentIndex(acct.proxyType() == QNetworkProxy::Socks5Proxy ? 0 : 1);
+  ui.proxyUser->setText(acct.proxyUser());
+  ui.proxyPassword->setText(acct.proxyPassword());
+
+  if(acct.accountId().isValid())
+    setWindowTitle(tr("Edit Core Account"));
+  else
+    setWindowTitle(tr("Add Core Account"));
+}
+
+CoreAccount CoreAccountEditDlg::account() {
+  _account.setAccountName(ui.accountName->text().trimmed());
+  _account.setHostName(ui.hostName->text().trimmed());
+  _account.setPort(ui.port->value());
+  _account.setUser(ui.user->text().trimmed());
+  _account.setPassword(ui.password->text());
+  _account.setStorePassword(ui.rememberPassword->isChecked());
+  _account.setUseProxy(ui.useProxy->isChecked());
+  _account.setProxyHostName(ui.proxyHostName->text().trimmed());
+  _account.setProxyPort(ui.proxyPort->value());
+  _account.setProxyType(ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy);
+  _account.setProxyUser(ui.proxyUser->text().trimmed());
+  _account.setProxyPassword(ui.proxyPassword->text());
+  return _account;
+}
+
+void CoreAccountEditDlg::setWidgetStates() {
+  bool ok = !ui.accountName->text().trimmed().isEmpty()
+            && !ui.user->text().trimmed().isEmpty()
+            && !ui.hostName->text().isEmpty();
+  ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
+}
+
+void CoreAccountEditDlg::on_hostName_textChanged(const QString &text) {
+  Q_UNUSED(text);
+  setWidgetStates();
+}
+
+void CoreAccountEditDlg::on_accountName_textChanged(const QString &text) {
+  Q_UNUSED(text);
+  setWidgetStates();
+}
+
+void CoreAccountEditDlg::on_user_textChanged(const QString &text) {
+  Q_UNUSED(text)
+  setWidgetStates();
+}
diff --git a/src/qtui/settingspages/coreaccountsettingspage.h b/src/qtui/settingspages/coreaccountsettingspage.h
new file mode 100644 (file)
index 0000000..e552a0b
--- /dev/null
@@ -0,0 +1,95 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by the Quassel Project                             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef COREACCOUNTSETTINGSPAGE_H_
+#define COREACCOUNTSETTINGSPAGE_H_
+
+#include "settingspage.h"
+
+#include "coreaccount.h"
+
+#include "ui_coreaccounteditdlg.h"
+#include "ui_coreaccountsettingspage.h"
+
+class CoreAccountModel;
+
+class CoreAccountSettingsPage : public SettingsPage {
+  Q_OBJECT
+
+  public:
+    CoreAccountSettingsPage(QWidget *parent = 0);
+
+    virtual inline bool hasDefaults() const { return false; }
+
+  public slots:
+    void save();
+    void load();
+
+  private slots:
+    void on_addAccountButton_clicked();
+    void on_editAccountButton_clicked();
+    void on_deleteAccountButton_clicked();
+
+    void setWidgetStates();
+
+    void rowsAboutToBeRemoved(const QModelIndex &index, int start, int end);
+    void rowsInserted(const QModelIndex &index, int start, int end);
+
+  private:
+    Ui::CoreAccountSettingsPage ui;
+
+    CoreAccountModel *_model;
+    inline CoreAccountModel *model() const { return _model; }
+
+    AccountId _lastAccountId, _lastAutoConnectId;
+
+    virtual QVariant loadAutoWidgetValue(const QString &widgetName);
+    virtual void saveAutoWidgetValue(const QString &widgetName, const QVariant &value);
+
+    void widgetHasChanged();
+    bool testHasChanged();
+
+    inline QString settingsKey() const { return QString("CoreAccounts"); }
+};
+
+// ========================================
+//  CoreAccountEditDlg
+// ========================================
+class CoreAccountEditDlg : public QDialog {
+  Q_OBJECT
+
+public:
+  CoreAccountEditDlg(const CoreAccount &account, QWidget *parent = 0);
+
+  CoreAccount account();
+
+private slots:
+  void on_hostName_textChanged(const QString &);
+  void on_accountName_textChanged(const QString &);
+  void on_user_textChanged(const QString &);
+
+  void setWidgetStates();
+
+private:
+  Ui::CoreAccountEditDlg ui;
+  CoreAccount _account;
+};
+
+#endif
diff --git a/src/qtui/settingspages/coreaccountsettingspage.ui b/src/qtui/settingspages/coreaccountsettingspage.ui
new file mode 100644 (file)
index 0000000..94d45c0
--- /dev/null
@@ -0,0 +1,238 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CoreAccountSettingsPage</class>
+ <widget class="QWidget" name="CoreAccountSettingsPage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>388</width>
+    <height>464</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Connect to Quassel Core</string>
+  </property>
+  <property name="windowIcon">
+   <iconset>
+    <normaloff>:/16x16/actions/network-disconnect</normaloff>:/16x16/actions/network-disconnect</iconset>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Core Accounts</string>
+     </property>
+     <layout class="QHBoxLayout">
+      <item>
+       <widget class="QListView" name="accountView">
+        <property name="selectionBehavior">
+         <enum>QAbstractItemView::SelectRows</enum>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <layout class="QVBoxLayout">
+        <item>
+         <widget class="QPushButton" name="editAccountButton">
+          <property name="text">
+           <string>Edit...</string>
+          </property>
+          <property name="icon">
+           <iconset>
+            <normaloff>:/16x16/actions/oxygen/16x16/actions/document-properties.png</normaloff>:/16x16/actions/oxygen/16x16/actions/document-properties.png</iconset>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="addAccountButton">
+          <property name="text">
+           <string>Add...</string>
+          </property>
+          <property name="icon">
+           <iconset>
+            <normaloff>:/16x16/actions/oxygen/16x16/actions/list-add.png</normaloff>:/16x16/actions/oxygen/16x16/actions/list-add.png</iconset>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="deleteAccountButton">
+          <property name="text">
+           <string>Delete</string>
+          </property>
+          <property name="icon">
+           <iconset>
+            <normaloff>:/16x16/actions/oxygen/16x16/actions/list-remove.png</normaloff>:/16x16/actions/oxygen/16x16/actions/list-remove.png</iconset>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer>
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>20</width>
+            <height>40</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="autoConnectOnStartup">
+     <property name="text">
+      <string>Automatically connect on startup</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+     <property name="settingsKey" stdset="0">
+      <string notr="true">AutoConnectOnStartup</string>
+     </property>
+     <property name="defaultValue" stdset="0">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QWidget" name="widget" native="true">
+       <layout class="QVBoxLayout" name="verticalLayout">
+        <property name="margin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QRadioButton" name="autoConnectToLast">
+          <property name="text">
+           <string>Connect to last account used</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_3">
+          <item>
+           <widget class="QRadioButton" name="autoConnectToFixedAccount">
+            <property name="text">
+             <string>Always connect to</string>
+            </property>
+            <property name="settingsKey" stdset="0">
+             <string notr="true">AutoConnectToFixedAccount</string>
+            </property>
+            <property name="defaultValue" stdset="0">
+             <bool>false</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QComboBox" name="autoConnectAccount">
+            <property name="enabled">
+             <bool>false</bool>
+            </property>
+            <property name="settingsKey" stdset="0">
+             <string notr="true"/>
+            </property>
+            <property name="defaultValue" stdset="0">
+             <number>0</number>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>accountView</tabstop>
+  <tabstop>editAccountButton</tabstop>
+  <tabstop>addAccountButton</tabstop>
+  <tabstop>deleteAccountButton</tabstop>
+  <tabstop>autoConnectOnStartup</tabstop>
+  <tabstop>autoConnectToLast</tabstop>
+  <tabstop>autoConnectToFixedAccount</tabstop>
+  <tabstop>autoConnectAccount</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>autoConnectOnStartup</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>widget</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>94</x>
+     <y>390</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>391</x>
+     <y>450</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>autoConnectToFixedAccount</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>autoConnectAccount</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>154</x>
+     <y>445</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>256</x>
+     <y>449</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index d96bddc..62ab590 100644 (file)
@@ -1,11 +1,11 @@
 # Putting $FOO in SETTINGSPAGES automatically includes
 # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
 
 # Putting $FOO in SETTINGSPAGES automatically includes
 # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
 
-set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor general 
+set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor coreaccount general 
                   highlight identities ignorelist inputwidget itemview networks topicwidget)
 
 # Specify additional files (e.g. for subdialogs) here!
 set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp ignorelistmodel.cpp notificationssettingspage.cpp)
 set(SP_HEADERS aliasesmodel.h identityeditwidget.h ignorelistmodel.h notificationssettingspage.h previewbufferview.h)
                   highlight identities ignorelist inputwidget itemview networks topicwidget)
 
 # Specify additional files (e.g. for subdialogs) here!
 set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp ignorelistmodel.cpp notificationssettingspage.cpp)
 set(SP_HEADERS aliasesmodel.h identityeditwidget.h ignorelistmodel.h notificationssettingspage.h previewbufferview.h)
-set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui identityeditwidget.ui ignorelisteditdlg.ui saveidentitiesdlg.ui 
+set(SP_FORMS buffervieweditdlg.ui coreaccounteditdlg.ui createidentitydlg.ui identityeditwidget.ui ignorelisteditdlg.ui saveidentitiesdlg.ui 
              networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui)
              networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui)