X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fserverlist.cpp;h=8dbb4a1b3af292e4838995a99e734775fb244306;hp=b194c6060456ead0ef75cee40994d4c6081adb9d;hb=63db3c5de9d76c5abc55b0cba86f66d2aba7745d;hpb=a975272aca8f0deb25c395532b189141979304e5 diff --git a/gui/serverlist.cpp b/gui/serverlist.cpp index b194c606..8dbb4a1b 100644 --- a/gui/serverlist.cpp +++ b/gui/serverlist.cpp @@ -19,20 +19,18 @@ ***************************************************************************/ #include "serverlist.h" -#include "proxy.h" +#include "global.h" /* NOTE: This dialog holds not only the server list, but also the identities. * This makes perfect sense given the fact that connections are initiated from * this dialog, and that the dialog exists during the lifetime of the program. - * This data is also only used from within the GUI, which means it shouldn't be - * part of the global Quassel class (me thinks). */ ServerListDlg::ServerListDlg(QWidget *parent) : QDialog(parent) { ui.setupUi(this); QSettings settings; - settings.beginGroup("Network"); + settings.beginGroup("GUI"); ui.showOnStartup->setChecked(settings.value("ShowServerListOnStartup", true).toBool()); // create some default entries VarMap s1, s2, s3, s4; @@ -114,20 +112,14 @@ void ServerListDlg::storeNetworks() { } void ServerListDlg::loadIdentities() { - //QSettings s; - //s.beginGroup("Identities"); - //identities = s.value("Network/Identities").toMap(); - identities = GuiProxy::loadIdentities(); + identities = global->getData("Identities", VarMap()).toMap(); while(!identities.contains("Default")) { - identities = VarMap(); editIdentities(); } } void ServerListDlg::storeIdentities() { - //QSettings s; - //s.setValue("Network/Identities", identities); - GuiProxy::storeIdentities(identities); + global->putData("Identities", identities); } void ServerListDlg::editIdentities() { @@ -135,7 +127,7 @@ void ServerListDlg::editIdentities() { if(dlg.exec() == QDialog::Accepted) { identities = dlg.getIdentities(); QMap mapping = dlg.getNameMapping(); - // add mapping here + // add mapping here <-- well, I don't fucking know anymore what I meant by this back in 2005... // storeIdentities(); @@ -145,7 +137,7 @@ void ServerListDlg::editIdentities() { void ServerListDlg::on_showOnStartup_stateChanged(int) { QSettings s; - s.setValue("Network/ShowServerListOnStartup", ui.showOnStartup->isChecked()); + s.setValue("GUI/ShowServerListOnStartup", ui.showOnStartup->isChecked()); } /***************************************************************************/ @@ -175,6 +167,8 @@ VarMap NetworkEditDlg::createDefaultNetwork() { IdentitiesDlg::IdentitiesDlg(QWidget *parent, VarMap _identities) : QDialog(parent) { ui.setupUi(this); + connect(global, SIGNAL(dataUpdatedRemotely(QString)), this, SLOT(globalDataUpdated(QString))); + connect(ui.enableAutoAway, SIGNAL(stateChanged(int)), this, SLOT(autoAwayChecked())); identities = _identities; @@ -203,6 +197,17 @@ IdentitiesDlg::IdentitiesDlg(QWidget *parent, VarMap _identities) : QDialog(pare connect(ui.downNickButton, SIGNAL(clicked()), this, SLOT(downNick())); } +void IdentitiesDlg::globalDataUpdated(QString key) { + if(key == "Identities") { + if(QMessageBox::warning(this, tr("Data changed remotely!"), tr("Some other GUI client changed the identities data!
" + "Apply updated settings, losing all changes done locally?"), + QMessageBox::Apply|QMessageBox::Discard) == QMessageBox::Apply) { + identities = global->getData(key).toMap(); + updateWidgets(); + } + } +} + VarMap IdentitiesDlg::createDefaultIdentity() { VarMap id; id["RealName"] = "foo"; @@ -316,7 +321,8 @@ void IdentitiesDlg::autoAwayChecked() { } void IdentitiesDlg::nickSelectionChanged() { - int curidx = ui.nickList->currentRow(); + Q_ASSERT(ui.nickList->selectedItems().size() == 1); + int curidx = ui.nickList->row(ui.nickList->selectedItems()[0]); ui.editNickButton->setEnabled(curidx >= 0); ui.delNickButton->setEnabled(curidx >= 0); ui.upNickButton->setEnabled(curidx > 0); @@ -439,11 +445,11 @@ IdentitiesEditDlg::IdentitiesEditDlg(QWidget *parent, VarMap _identities, QMapcurrentRow(); + Q_ASSERT(ui.identList->selectedItems().size() == 1); + int idx = ui.identList->row(ui.identList->selectedItems()[0]); ui.duplicateButton->setEnabled(idx >= 0); ui.renameButton->setEnabled(idx > 0); ui.deleteButton->setEnabled(idx > 0); - } void IdentitiesEditDlg::addIdentity() { @@ -529,7 +535,7 @@ NickEditDlg::NickEditDlg(QWidget *parent, QString nick) : QDialog(parent) { } void NickEditDlg::textChanged(QString text) { - ui.okButton->setDisabled(text.isEmpty() || text == ""); + ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty() || text == ""); } QString NickEditDlg::getNick() { @@ -541,7 +547,7 @@ QString NickEditDlg::getNick() { RenameIdentityDlg::RenameIdentityDlg(QWidget *parent, QList _reserved, QString name) : QDialog(parent) { ui.setupUi(this); reserved = _reserved; - //ui.NickEditDlg->setWindowTitle(tr("Edit Identity Name")); // why does this not work? + setWindowTitle(tr("Edit Identity Name")); ui.label->setText(tr("Identity:")); ui.lineEdit->setText(name); connect(ui.lineEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); @@ -549,8 +555,8 @@ RenameIdentityDlg::RenameIdentityDlg(QWidget *parent, QList _reserved, } void RenameIdentityDlg::textChanged(QString text) { - if(text.length() == 0) { ui.okButton->setEnabled(0); return; } - ui.okButton->setDisabled(reserved.contains(text)); + if(text.length() == 0) { ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true); return; } + ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(reserved.contains(text)); } QString RenameIdentityDlg::getName() {