This time it's just a thin wrapper around the settingspage, so it doesn't suck.
}
bool CoreConnection::connectToCore(AccountId accId) {
+ if(isConnected())
+ return false;
+
CoreAccountSettings s;
if(!accId.isValid()) {
chatviewsettings.cpp
columnhandleitem.cpp
coreconfigwizard.cpp
+ coreconnectdlg.cpp
coreconnectionstatuswidget.cpp
coreinfodlg.cpp
debugbufferviewoverlay.cpp
chatviewsearchcontroller.h
columnhandleitem.h
coreconfigwizard.h
+ coreconnectdlg.h
coreconnectionstatuswidget.h
coreinfodlg.h
debugbufferviewoverlay.h
--- /dev/null
+/***************************************************************************
+ * 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 <QDialogButtonBox>
+#include <QVBoxLayout>
+
+#include "coreconnectdlg.h"
+
+#include "iconloader.h"
+#include "clientsettings.h"
+#include "coreaccountsettingspage.h"
+
+CoreConnectDlg::CoreConnectDlg(QWidget *parent) : QDialog(parent) {
+ _settingsPage = new CoreAccountSettingsPage(this);
+ _settingsPage->setStandAlone(true);
+ _settingsPage->load();
+
+ CoreAccountSettings s;
+ AccountId lastAccount = s.lastAccount();
+ if(lastAccount.isValid())
+ _settingsPage->setSelectedAccount(lastAccount);
+
+ setWindowTitle(tr("Connect to Core"));
+ setWindowIcon(SmallIcon("network-disconnect"));
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(_settingsPage);
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+ buttonBox->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ layout->addWidget(buttonBox);
+
+ connect(_settingsPage, SIGNAL(connectToCore(AccountId)), SLOT(accept()));
+ connect(buttonBox, SIGNAL(accepted()), SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), SLOT(reject()));
+}
+
+AccountId CoreConnectDlg::selectedAccount() const {
+ return _settingsPage->selectedAccount();
+}
+
+void CoreConnectDlg::accept() {
+ _settingsPage->save();
+ QDialog::accept();
+}
--- /dev/null
+/***************************************************************************
+ * 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 CORECONNECTDLG_H
+#define CORECONNECTDLG_H_
+
+#include <QDialog>
+
+#include "coreaccount.h"
+
+class CoreAccountSettingsPage;
+
+class CoreConnectDlg : public QDialog {
+ Q_OBJECT
+
+public:
+ CoreConnectDlg(QWidget *parent = 0);
+ AccountId selectedAccount() const;
+
+ void accept();
+
+private:
+ CoreAccountSettingsPage *_settingsPage;
+};
+
+#endif
#include "clientbufferviewconfig.h"
#include "clientbufferviewmanager.h"
#include "clientignorelistmanager.h"
+#include "coreconnectdlg.h"
#include "coreconnection.h"
#include "coreconnectionstatuswidget.h"
#include "coreinfodlg.h"
// restore locked state of docks
QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool());
- if(Quassel::runMode() != Quassel::Monolithic) {
- //showCoreConnectionDlg(true); // autoconnect if appropriate
- } else {
- startInternalCore();
+ CoreConnection *conn = Client::coreConnection();
+ if(!conn->connectToCore()) {
+ // No autoconnect selected (or no accounts)
+ showCoreConnectionDlg();
}
- Client::coreConnection()->start();
}
MainWin::~MainWin() {
}
+void MainWin::showCoreConnectionDlg() {
+ CoreConnectDlg dlg(this);
+ if(dlg.exec() == QDialog::Accepted) {
+ AccountId accId = dlg.selectedAccount();
+ if(accId.isValid())
+ Client::coreConnection()->connectToCore(accId);
+ }
+}
+
void MainWin::showChannelList(NetworkId netId) {
ChannelListDlg *channelListDlg = new ChannelListDlg();
void showAboutDlg();
void showChannelList(NetworkId netId = NetworkId());
void startInternalCore();
+ void showCoreConnectionDlg();
void showCoreInfoDlg();
void showAwayLog();
void showSettingsDlg();
CoreAccountSettingsPage::CoreAccountSettingsPage(QWidget *parent)
: SettingsPage(tr("Misc"), tr("Core Accounts"), parent),
_lastAccountId(0),
-_lastAutoConnectId(0)
+_lastAutoConnectId(0),
+_standalone(false)
{
ui.setupUi(this);
initAutoWidgets();
setWidgetStates();
}
+void CoreAccountSettingsPage::setStandAlone(bool standalone) {
+ _standalone = standalone;
+}
+
void CoreAccountSettingsPage::load() {
_model->update(Client::coreAccountModel());
_lastAccountId = _lastAutoConnectId = 0;
}
+AccountId CoreAccountSettingsPage::selectedAccount() const {
+ QModelIndex index = ui.accountView->currentIndex();
+ if(!index.isValid())
+ return 0;
+ return index.data(CoreAccountModel::AccountIdRole).value<AccountId>();
+}
+
+void CoreAccountSettingsPage::setSelectedAccount(AccountId accId) {
+ QModelIndex index = model()->accountIndex(accId);
+ if(index.isValid())
+ ui.accountView->setCurrentIndex(index);
+}
+
void CoreAccountSettingsPage::on_addAccountButton_clicked() {
CoreAccountEditDlg dlg(CoreAccount(), this);
if(dlg.exec() == QDialog::Accepted) {
if(!idx.isValid())
return;
- CoreAccountEditDlg dlg(_model->account(idx), this);
+ editAccount(idx);
+}
+
+void CoreAccountSettingsPage::editAccount(const QModelIndex &index) {
+ if(!index.isValid())
+ return;
+
+ CoreAccountEditDlg dlg(_model->account(index), this);
if(dlg.exec() == QDialog::Accepted) {
AccountId id = _model->createOrUpdateAccount(dlg.account());
ui.accountView->setCurrentIndex(model()->accountIndex(id));
}
}
+void CoreAccountSettingsPage::on_accountView_doubleClicked(const QModelIndex &index) {
+ if(!index.isValid())
+ return;
+
+ if(isStandAlone())
+ emit connectToCore(index.data(CoreAccountModel::AccountIdRole).value<AccountId>());
+ else
+ editAccount(index);
+}
+
void CoreAccountSettingsPage::setWidgetStates() {
bool selected = ui.accountView->selectionModel()->selectedIndexes().count();
public:
CoreAccountSettingsPage(QWidget *parent = 0);
- virtual inline bool hasDefaults() const { return false; }
+ inline bool hasDefaults() const { return false; }
+ inline bool isStandAlone() const { return _standalone; }
+
+ AccountId selectedAccount() const;
public slots:
void save();
void load();
+ void setSelectedAccount(AccountId accId);
+ void setStandAlone(bool);
+
+signals:
+ void connectToCore(AccountId accId);
+
private slots:
void on_addAccountButton_clicked();
void on_editAccountButton_clicked();
void on_deleteAccountButton_clicked();
+ void on_accountView_doubleClicked(const QModelIndex &index);
void setWidgetStates();
inline CoreAccountModel *model() const { return _model; }
AccountId _lastAccountId, _lastAutoConnectId;
+ bool _standalone;
virtual QVariant loadAutoWidgetValue(const QString &widgetName);
virtual void saveAutoWidgetValue(const QString &widgetName, const QVariant &value);
+ void editAccount(const QModelIndex &);
+
void widgetHasChanged();
bool testHasChanged();