fixes #542 - show identities and network settings on first start
authorMarcus Eggenberger <egs@quassel-irc.org>
Sun, 15 Feb 2009 17:01:08 +0000 (18:01 +0100)
committerMarcus Eggenberger <egs@quassel-irc.org>
Sun, 15 Feb 2009 17:01:08 +0000 (18:01 +0100)
12 files changed:
src/client/client.cpp
src/client/client.h
src/qtui/CMakeLists.txt
src/qtui/ircconnectionwizard.cpp [new file with mode: 0644]
src/qtui/ircconnectionwizard.h [new file with mode: 0644]
src/qtui/mainwin.cpp
src/qtui/settingspages/identityeditwidget.cpp
src/qtui/settingspages/identityeditwidget.h
src/qtui/settingspages/networkssettingspage.h
src/qtui/simplenetworkeditor.cpp [new file with mode: 0644]
src/qtui/simplenetworkeditor.h [new file with mode: 0644]
src/qtui/ui/simplenetworkeditor.ui [new file with mode: 0644]

index b0f68e4..bbca252 100644 (file)
@@ -301,9 +301,6 @@ void Client::setSyncedToCore() {
   connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
   connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView()));
 
-  createDefaultIdentity();
-  createDefaultNetworks();
-
   _syncedToCore = true;
   emit connected();
   emit coreConnectionStateChanged(true);
@@ -323,28 +320,6 @@ void Client::createDefaultBufferView() {
   }
 }
 
-void Client::createDefaultIdentity() {
-  if(_identities.isEmpty()) {
-    Identity identity;
-    identity.setToDefaults();
-    identity.setIdentityName(tr("Default Identity"));
-    createIdentity(identity);
-  }
-}
-
-void Client::createDefaultNetworks() {
-  if(_networks.isEmpty()) {
-    QStringList defaultNets = Network::presetNetworks(true);
-    foreach(QString net, defaultNets) {
-      NetworkInfo info = Network::networkInfoFromPreset(net);
-      if(info.networkName.isEmpty())
-        continue;
-      QStringList defaultChans = Network::presetDefaultChannels(net);
-      createNetwork(info, defaultChans);
-    }
-  }
-}
-
 void Client::disconnectFromCore() {
   if(!isConnected())
     return;
index 3679d65..c0e07d8 100644 (file)
@@ -185,8 +185,6 @@ private slots:
   void setSyncedToCore();
   void requestInitialBacklog();
   void createDefaultBufferView();
-  void createDefaultIdentity();
-  void createDefaultNetworks();
 
 private:
   Client(QObject *parent = 0);
index 3364c57..f70e465 100644 (file)
@@ -30,6 +30,7 @@ set(SOURCES
     debuglogwidget.cpp
     debugmessagemodelfilter.cpp
     inputwidget.cpp
+    ircconnectionwizard.cpp
     jumpkeyhandler.cpp
     mainpage.cpp
     mainwin.cpp
@@ -43,6 +44,7 @@ set(SOURCES
     sessionsettings.cpp
     settingsdlg.cpp
     settingspagedlg.cpp
+    simplenetworkeditor.cpp
     systemtray.cpp
     systraynotificationbackend.cpp
     taskbarnotificationbackend.cpp
@@ -74,6 +76,7 @@ set(MOC_HDRS
     debuglogwidget.h
     debugmessagemodelfilter.h
     inputwidget.h
+    ircconnectionwizard.h
     jumpkeyhandler.h
     mainpage.h
     mainwin.h
@@ -84,6 +87,7 @@ set(MOC_HDRS
     qtuimessageprocessor.h
     settingsdlg.h
     settingspagedlg.h
+    simplenetworkeditor.h
     systemtray.h
     systraynotificationbackend.h
     taskbarnotificationbackend.h
@@ -120,6 +124,7 @@ set(FORMS
     nicklistwidget.ui
     settingsdlg.ui
     settingspagedlg.ui
+    simplenetworkeditor.ui
     topicwidget.ui)
 
 if(HAVE_KDE)
diff --git a/src/qtui/ircconnectionwizard.cpp b/src/qtui/ircconnectionwizard.cpp
new file mode 100644 (file)
index 0000000..e952c86
--- /dev/null
@@ -0,0 +1,164 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 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 "ircconnectionwizard.h"
+
+#include "client.h"
+#include "identityeditwidget.h"
+#include "simplenetworkeditor.h"
+
+#include <QVBoxLayout>
+
+IrcConnectionWizard::IrcConnectionWizard(QWidget *parent, Qt::WindowFlags flags)
+  : QWizard(parent, flags),
+    _introductionPage(0),
+    _identityPage(0),
+    _networkPage(0)
+{
+
+  _introductionPage = createIntroductionPage(this);
+  _identityPage = new IdentityPage(this);
+  _networkPage = new NetworkPage(this);
+
+
+  addPage(_introductionPage);
+  addPage(_identityPage);
+  addPage(_networkPage);
+
+  setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+
+  setOptions(options() | (QWizard::WizardOptions)(QWizard::NoDefaultButton | QWizard::CancelButtonOnLeft));
+  setOption(QWizard::NoCancelButton, false);
+
+  connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SLOT(finishClicked()));
+  setButtonText(QWizard::FinishButton, tr("Save && Connect"));
+}
+
+QWizardPage *IrcConnectionWizard::createIntroductionPage(QWidget *parent) {
+  QWizardPage *page = new QWizardPage(parent);
+  page->setTitle(QObject::tr("Welcome to Quassel IRC"));
+
+  QLabel *label = new QLabel(QObject::tr("This Wizard will help you setting up your default identity and your irc network connection. "
+                                        "You can abort this wizard in any step, if you want to setup your identity and IRC connection in more detail."
+                                        "This can be done in the settings."), page);
+  label->setWordWrap(true);
+
+  QVBoxLayout *layout = new QVBoxLayout;
+  layout->addWidget(label);
+  page->setLayout(layout);
+  return page;
+}
+
+void IrcConnectionWizard::finishClicked() {
+  CertIdentity *identity = static_cast<IdentityPage *>(_identityPage)->identity();
+  if(identity->id().isValid()) {
+    Client::updateIdentity(identity->id(), identity->toVariantMap());
+    identityReady(identity->id());
+  } else {
+    connect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId)));
+    Client::createIdentity(*identity);
+  }
+}
+
+void IrcConnectionWizard::identityReady(IdentityId id) {
+  disconnect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId)));
+  NetworkPage *networkPage = static_cast<NetworkPage *>(_networkPage);
+  NetworkInfo networkInfo = networkPage->networkInfo();
+  QStringList channels = networkPage->channelList();
+  networkInfo.identity = id;
+  connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(networkReady(NetworkId)));
+  Client::createNetwork(networkInfo, channels);
+}
+
+void IrcConnectionWizard::networkReady(NetworkId id) {
+  disconnect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(networkReady(NetworkId)));
+  const Network *net = Client::network(id);
+  Q_ASSERT(net);
+  net->requestConnect();
+  deleteLater();
+}
+
+// ==============================
+//  Wizard Pages
+// ==============================
+
+// Identity Page
+IdentityPage::IdentityPage(QWidget *parent)
+  : QWizardPage(parent),
+    _identityEditWidget(new IdentityEditWidget(this)),
+    _identity(0)
+{
+  setTitle(tr("Setup Identity"));
+
+  if(Client::identityIds().isEmpty()) {
+    _identity = new CertIdentity(-1, this);
+    _identity->setToDefaults();
+    _identity->setIdentityName(tr("Default Identity"));
+  } else {
+    _identity = new CertIdentity(*Client::identity(Client::identityIds().first()), this);
+  }
+
+  _identityEditWidget->displayIdentity(_identity);
+  _identityEditWidget->showAdvanced(false);
+  QVBoxLayout *layout = new QVBoxLayout;
+  layout->addWidget(_identityEditWidget);
+  setLayout(layout);
+}
+
+CertIdentity *IdentityPage::identity() {
+  _identityEditWidget->saveToIdentity(_identity);
+  return _identity;
+}
+
+
+// Network Page
+NetworkPage::NetworkPage(QWidget *parent)
+  : QWizardPage(parent),
+    _networkEditor(new SimpleNetworkEditor(this))
+{
+
+  QStringList defaultNets = Network::presetNetworks(true);
+  if(!defaultNets.isEmpty()) {
+    NetworkInfo info = Network::networkInfoFromPreset(defaultNets[0]);
+    if(!info.networkName.isEmpty()) {
+      _networkInfo = info;
+      _channelList = Network::presetDefaultChannels(defaultNets[0]);
+    }
+  }
+
+  _networkEditor->displayNetworkInfo(_networkInfo);
+  _networkEditor->setDefaultChannels(_channelList);
+
+  setTitle(tr("Setup Network Connection"));
+
+  QVBoxLayout *layout = new QVBoxLayout;
+  layout->addWidget(_networkEditor);
+  setLayout(layout);
+}
+
+NetworkInfo NetworkPage::networkInfo() {
+  _networkEditor->saveToNetworkInfo(_networkInfo);
+  return _networkInfo;
+}
+
+QStringList NetworkPage::channelList() {
+  _channelList = _networkEditor->defaultChannels();
+  return _channelList;
+}
diff --git a/src/qtui/ircconnectionwizard.h b/src/qtui/ircconnectionwizard.h
new file mode 100644 (file)
index 0000000..aa65a03
--- /dev/null
@@ -0,0 +1,91 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 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 IRCCONNECTIONWIZARD_H
+#define IRCCONNECTIONWIZARD_H
+
+#include <QWizard>
+
+#include "types.h"
+
+class IrcConnectionWizard : public QWizard {
+  Q_OBJECT
+
+public:
+  IrcConnectionWizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+
+  static QWizardPage *createIntroductionPage(QWidget *parent = 0);
+
+private slots:
+  void finishClicked();
+  void identityReady(IdentityId id);
+  void networkReady(NetworkId id);
+
+private:
+  QWizardPage *_introductionPage;
+  QWizardPage *_identityPage;
+  QWizardPage *_networkPage;
+};
+
+
+// ==============================
+//  Wizard Pages
+// ==============================
+
+// Identity Page
+#include "clientidentity.h"
+
+class IdentityEditWidget;
+
+class IdentityPage : public QWizardPage {
+  Q_OBJECT
+
+public:
+  IdentityPage(QWidget *parent = 0);
+
+  CertIdentity *identity();
+
+private:
+  IdentityEditWidget *_identityEditWidget;
+  CertIdentity *_identity;
+};
+
+
+// Network Page
+#include "network.h"
+
+class SimpleNetworkEditor;
+
+class NetworkPage : public QWizardPage {
+  Q_OBJECT
+
+public:
+  NetworkPage(QWidget *parent = 0);
+
+  NetworkInfo networkInfo();
+  QStringList channelList();
+
+private:
+  SimpleNetworkEditor *_networkEditor;
+  NetworkInfo _networkInfo;
+  QStringList _channelList;
+};
+
+#endif //IRCCONNECTIONWIZARD_H
index df44431..655cdcd 100644 (file)
@@ -55,6 +55,7 @@
 #include "inputwidget.h"
 #include "inputline.h"
 #include "irclistmodel.h"
+#include "ircconnectionwizard.h"
 #include "jumpkeyhandler.h"
 #include "msgprocessorstatuswidget.h"
 #include "nicklistwidget.h"
@@ -606,6 +607,11 @@ void MainWin::setConnectedState() {
   coreLagLabel->setVisible(!Client::internalCore());
   updateIcon();
   systemTray()->setState(SystemTray::Active);
+
+  if(Client::networkIds().isEmpty()) {
+    IrcConnectionWizard *wizard = new IrcConnectionWizard(this, Qt::Sheet);
+    wizard->show();
+  }
 }
 
 void MainWin::loadLayout() {
index b652c7b..025196c 100644 (file)
@@ -209,6 +209,19 @@ void IdentityEditWidget::on_nickDown_clicked() {
   }
 }
 
+void IdentityEditWidget::showAdvanced(bool advanced) {
+  int idx = ui.tabWidget->indexOf(ui.advancedTab);
+  if(advanced) {
+    if(idx != -1)
+      return; // already added
+    ui.tabWidget->addTab(ui.advancedTab, tr("Advanced"));
+  } else {
+    if(idx == -1)
+      return; // already removed
+    ui.tabWidget->removeTab(idx);
+  }
+}
+
 #ifdef HAVE_SSL
 void IdentityEditWidget::setSslState(SslState state) {
   switch(state) {
index 2879c9f..6516c57 100644 (file)
@@ -48,6 +48,7 @@ public:
 
 public slots:
   void setSslState(SslState state);
+  void showAdvanced(bool advanced);
 
 protected:
 #ifdef HAVE_SSL
index 40d0276..bafc645 100644 (file)
 class NetworksSettingsPage : public SettingsPage {
   Q_OBJECT
 
-  public:
-    NetworksSettingsPage(QWidget *parent = 0);
+public:
+  NetworksSettingsPage(QWidget *parent = 0);
 
-    bool aboutToSave();
+  bool aboutToSave();
 
-  public slots:
-    void save();
-    void load();
+public slots:
+  void save();
+  void load();
 
-  private slots:
-    void widgetHasChanged();
-    void setWidgetStates();
-    void coreConnectionStateChanged(bool);
-    void networkConnectionStateChanged(Network::ConnectionState state);
-    void networkConnectionError(const QString &msg);
-
-    void displayNetwork(NetworkId);
-    void setItemState(NetworkId, QListWidgetItem *item = 0);
-
-    void clientNetworkAdded(NetworkId);
-    void clientNetworkRemoved(NetworkId);
-    void clientNetworkUpdated();
-
-    void clientIdentityAdded(IdentityId);
-    void clientIdentityRemoved(IdentityId);
-    void clientIdentityUpdated();
-
-    void on_networkList_itemSelectionChanged();
-    void on_addNetwork_clicked();
-    void on_deleteNetwork_clicked();
-    void on_renameNetwork_clicked();
-    void on_editIdentities_clicked();
-
-    // void on_connectNow_clicked();
-
-    void on_serverList_itemSelectionChanged();
-    void on_addServer_clicked();
-    void on_deleteServer_clicked();
-    void on_editServer_clicked();
-    void on_upServer_clicked();
-    void on_downServer_clicked();
+private slots:
+  void widgetHasChanged();
+  void setWidgetStates();
+  void coreConnectionStateChanged(bool);
+  void networkConnectionStateChanged(Network::ConnectionState state);
+  void networkConnectionError(const QString &msg);
+
+  void displayNetwork(NetworkId);
+  void setItemState(NetworkId, QListWidgetItem *item = 0);
+
+  void clientNetworkAdded(NetworkId);
+  void clientNetworkRemoved(NetworkId);
+  void clientNetworkUpdated();
+
+  void clientIdentityAdded(IdentityId);
+  void clientIdentityRemoved(IdentityId);
+  void clientIdentityUpdated();
+
+  void on_networkList_itemSelectionChanged();
+  void on_addNetwork_clicked();
+  void on_deleteNetwork_clicked();
+  void on_renameNetwork_clicked();
+  void on_editIdentities_clicked();
+
+  // void on_connectNow_clicked();
+
+  void on_serverList_itemSelectionChanged();
+  void on_addServer_clicked();
+  void on_deleteServer_clicked();
+  void on_editServer_clicked();
+  void on_upServer_clicked();
+  void on_downServer_clicked();
 
-  private:
-    Ui::NetworksSettingsPage ui;
+private:
+  Ui::NetworksSettingsPage ui;
 
-    NetworkId currentId;
-    QHash<NetworkId, NetworkInfo> networkInfos;
-    bool _ignoreWidgetChanges;
+  NetworkId currentId;
+  QHash<NetworkId, NetworkInfo> networkInfos;
+  bool _ignoreWidgetChanges;
 
-    QPixmap connectedIcon, connectingIcon, disconnectedIcon;
+  QPixmap connectedIcon, connectingIcon, disconnectedIcon;
 
-    void reset();
-    bool testHasChanged();
-    QListWidgetItem *insertNetwork(NetworkId);
-    QListWidgetItem *insertNetwork(const NetworkInfo &info);
-    QListWidgetItem *networkItem(NetworkId) const;
-    void saveToNetworkInfo(NetworkInfo &);
+  void reset();
+  bool testHasChanged();
+  QListWidgetItem *insertNetwork(NetworkId);
+  QListWidgetItem *insertNetwork(const NetworkInfo &info);
+  QListWidgetItem *networkItem(NetworkId) const;
+  void saveToNetworkInfo(NetworkInfo &);
 };
 
 
diff --git a/src/qtui/simplenetworkeditor.cpp b/src/qtui/simplenetworkeditor.cpp
new file mode 100644 (file)
index 0000000..a185e62
--- /dev/null
@@ -0,0 +1,133 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 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 "simplenetworkeditor.h"
+
+#include "iconloader.h"
+
+#include "networkssettingspage.h"
+
+SimpleNetworkEditor::SimpleNetworkEditor(QWidget *parent)
+  : QWidget(parent)
+{
+  ui.setupUi(this);
+
+  ui.addServer->setIcon(SmallIcon("list-add"));
+  ui.deleteServer->setIcon(SmallIcon("edit-delete"));
+  ui.editServer->setIcon(SmallIcon("configure"));
+  ui.upServer->setIcon(SmallIcon("go-up"));
+  ui.downServer->setIcon(SmallIcon("go-down"));
+
+  connect(ui.networkNameEdit, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged()));
+  connect(ui.channelList, SIGNAL(textChanged()), this, SIGNAL(widgetHasChanged()));
+}
+
+void SimpleNetworkEditor::setWidgetStates() {
+  if(ui.serverList->selectedItems().count()) {
+    ui.editServer->setEnabled(true);
+    ui.deleteServer->setEnabled(true);
+    ui.upServer->setEnabled(ui.serverList->currentRow() > 0);
+    ui.downServer->setEnabled(ui.serverList->currentRow() < ui.serverList->count() - 1);
+  } else {
+    ui.editServer->setEnabled(false);
+    ui.deleteServer->setEnabled(false);
+    ui.upServer->setEnabled(false);
+    ui.downServer->setEnabled(false);
+  }
+}
+
+void SimpleNetworkEditor::displayNetworkInfo(const NetworkInfo &networkInfo) {
+  _networkInfo = networkInfo;
+
+  ui.serverList->clear();
+  foreach(Network::Server server, _networkInfo.serverList) {
+    QListWidgetItem *item = new QListWidgetItem(QString("%1:%2").arg(server.host).arg(server.port));
+    if(server.useSsl)
+      item->setIcon(SmallIcon("document-encrypt"));
+    ui.serverList->addItem(item);
+  }
+
+  ui.networkNameEdit->setText(_networkInfo.networkName);
+  setWidgetStates();
+}
+
+void SimpleNetworkEditor::saveToNetworkInfo(NetworkInfo &networkInfo) {
+  _networkInfo.networkName = ui.networkNameEdit->text();
+  networkInfo = _networkInfo;
+}
+
+QStringList SimpleNetworkEditor::defaultChannels() const {
+  return ui.channelList->toPlainText().split("\n",  QString::SkipEmptyParts);
+}
+
+void SimpleNetworkEditor::setDefaultChannels(const QStringList &channels) {
+  ui.channelList->setPlainText(channels.join("\n"));
+}
+
+void SimpleNetworkEditor::on_serverList_itemSelectionChanged() {
+  setWidgetStates();
+}
+
+void SimpleNetworkEditor::on_addServer_clicked() {
+  ServerEditDlg dlg(Network::Server(), this);
+  if(dlg.exec() == QDialog::Accepted) {
+    _networkInfo.serverList.append(dlg.serverData());
+    displayNetworkInfo(_networkInfo);
+    ui.serverList->setCurrentRow(ui.serverList->count() - 1);
+    emit widgetHasChanged();
+  }
+}
+
+void SimpleNetworkEditor::on_editServer_clicked() {
+  int cur = ui.serverList->currentRow();
+  ServerEditDlg dlg(_networkInfo.serverList[cur], this);
+  if(dlg.exec() == QDialog::Accepted) {
+    _networkInfo.serverList[cur] = dlg.serverData();
+    displayNetworkInfo(_networkInfo);
+    ui.serverList->setCurrentRow(cur);
+    emit widgetHasChanged();
+  }
+}
+
+void SimpleNetworkEditor::on_deleteServer_clicked() {
+  int cur = ui.serverList->currentRow();
+  _networkInfo.serverList.removeAt(cur);
+  displayNetworkInfo(_networkInfo);
+  ui.serverList->setCurrentRow(qMin(cur, ui.serverList->count() - 1));
+  emit widgetHasChanged();
+}
+
+void SimpleNetworkEditor::on_upServer_clicked() {
+  int cur = ui.serverList->currentRow();
+  Network::Server server = _networkInfo.serverList.takeAt(cur);
+  _networkInfo.serverList.insert(cur - 1, server);
+  displayNetworkInfo(_networkInfo);
+  ui.serverList->setCurrentRow(cur - 1);
+  emit widgetHasChanged();
+}
+
+void SimpleNetworkEditor::on_downServer_clicked() {
+  int cur = ui.serverList->currentRow();
+  Network::Server server = _networkInfo.serverList.takeAt(cur);
+  _networkInfo.serverList.insert(cur + 1, server);
+  displayNetworkInfo(_networkInfo);
+  ui.serverList->setCurrentRow(cur + 1);
+  emit widgetHasChanged();
+}
diff --git a/src/qtui/simplenetworkeditor.h b/src/qtui/simplenetworkeditor.h
new file mode 100644 (file)
index 0000000..d413060
--- /dev/null
@@ -0,0 +1,60 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 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 SIMPLENETWORKEDITOR_H
+#define SIMPLENETWORKEDITOR_H
+
+#include "ui_simplenetworkeditor.h"
+
+#include "network.h"
+
+class SimpleNetworkEditor : public QWidget {
+  Q_OBJECT
+
+public:
+  SimpleNetworkEditor(QWidget *parent = 0);
+
+  void displayNetworkInfo(const NetworkInfo &networkInfo);
+  void saveToNetworkInfo(NetworkInfo &networkInfo);
+
+  QStringList defaultChannels() const;
+  void setDefaultChannels(const QStringList &channels);
+
+signals:
+  void widgetHasChanged();
+
+private slots:
+  // code duplication from settingspages/networkssettingspage.{h|cpp}
+  void on_serverList_itemSelectionChanged();
+  void on_addServer_clicked();
+  void on_deleteServer_clicked();
+  void on_editServer_clicked();
+  void on_upServer_clicked();
+  void on_downServer_clicked();
+
+  void setWidgetStates();
+
+private:
+  Ui::SimpleNetworkEditor ui;
+
+  NetworkInfo _networkInfo;
+};
+
+#endif //SIMPLENETWORKEDITOR_H
diff --git a/src/qtui/ui/simplenetworkeditor.ui b/src/qtui/ui/simplenetworkeditor.ui
new file mode 100644 (file)
index 0000000..2c4c62a
--- /dev/null
@@ -0,0 +1,262 @@
+<ui version="4.0" >
+ <class>SimpleNetworkEditor</class>
+ <widget class="QWidget" name="SimpleNetworkEditor" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>467</width>
+    <height>413</height>
+   </rect>
+  </property>
+  <property name="sizePolicy" >
+   <sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle" >
+   <string/>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2" >
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout" >
+     <item>
+      <widget class="QLabel" name="label" >
+       <property name="text" >
+        <string>Networkname:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="networkNameEdit" />
+     </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>
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Servers</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_2" >
+      <item>
+       <widget class="QListWidget" name="serverList" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+          <horstretch>1</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="maximumSize" >
+         <size>
+          <width>170</width>
+          <height>16777215</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <layout class="QVBoxLayout" name="_2" >
+        <item>
+         <widget class="QPushButton" name="editServer" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>&amp;Edit...</string>
+          </property>
+          <property name="icon" >
+           <iconset>
+            <normaloff>../settingspages</normaloff>../settingspages</iconset>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="addServer" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>&amp;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="deleteServer" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>De&amp;lete</string>
+          </property>
+          <property name="icon" >
+           <iconset>
+            <normaloff>:/16x16/actions/oxygen/16x16/actions/edit-delete.png</normaloff>:/16x16/actions/oxygen/16x16/actions/edit-delete.png</iconset>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="_3" >
+          <item>
+           <spacer>
+            <property name="orientation" >
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0" >
+             <size>
+              <width>0</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QToolButton" name="upServer" >
+            <property name="toolTip" >
+             <string>Move upwards in list</string>
+            </property>
+            <property name="text" >
+             <string>...</string>
+            </property>
+            <property name="icon" >
+             <iconset>
+              <normaloff>:/16x16/actions/oxygen/16x16/actions/go-up.png</normaloff>:/16x16/actions/oxygen/16x16/actions/go-up.png</iconset>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="downServer" >
+            <property name="toolTip" >
+             <string>Move downwards in list</string>
+            </property>
+            <property name="text" >
+             <string>...</string>
+            </property>
+            <property name="icon" >
+             <iconset>
+              <normaloff>:/16x16/actions/oxygen/16x16/actions/go-down.png</normaloff>:/16x16/actions/oxygen/16x16/actions/go-down.png</iconset>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer>
+            <property name="orientation" >
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0" >
+             <size>
+              <width>0</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </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="QGroupBox" name="groupBox_2" >
+     <property name="title" >
+      <string>Channels</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_3" >
+      <item>
+       <widget class="QTextEdit" name="channelList" >
+        <property name="maximumSize" >
+         <size>
+          <width>170</width>
+          <height>16777215</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <layout class="QVBoxLayout" name="verticalLayout" >
+        <item>
+         <widget class="QLabel" name="label_2" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize" >
+           <size>
+            <width>120</width>
+            <height>0</height>
+           </size>
+          </property>
+          <property name="text" >
+           <string>Enter a list of channels you want to join after the IRC connection has been established.</string>
+          </property>
+          <property name="wordWrap" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="verticalSpacer" >
+          <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>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>