From: Manuel Nickschas Date: Wed, 9 Jan 2008 19:11:30 +0000 (+0000) Subject: Finally! The new identities plus a nice shiny settingspage for editing them are done! X-Git-Tag: 0.2.0-alpha1~238 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=9a6a8478bdd8c7c5bb4ff1fa3de9510863d65a97 Finally! The new identities plus a nice shiny settingspage for editing them are done! The dialog should be fully functional, and you should be able to create/edit/save identities. However, they are not yet actually used (which is why we still have the old dialog as well)... Also I revamped the whole SettingsDlg stuff, it now notices when settingspages have changed and behaves accordingly, you can reset/reload settings and whatever else you'd expect from a fully functional configuration dialog... Furthermore, I did some general prettyfication, added some icons, tooltips, whatsthis-texts and so on. --- diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index 64f0c642..ffdd0ad1 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -29,6 +29,8 @@ src src/client src/client/buffer.cpp src/client/buffer.h +src/client/buffermodel.cpp +src/client/buffermodel.h src/client/client.cpp src/client/client.h src/client/client.pri @@ -180,6 +182,8 @@ src/qtui/settingspages/identitiessettingspage.cpp src/qtui/settingspages/identitiessettingspage.h src/qtui/settingspages/identitiessettingspage.ui src/qtui/settingspages/networkssettingspage.ui +src/qtui/settingspages/nickeditdlg.ui +src/qtui/settingspages/nickeditdlgnew.ui src/qtui/settingspages/saveidentitiesdlg.ui src/qtui/settingspages/servereditdlg.ui src/qtui/settingspages/settingspages.pri @@ -194,6 +198,7 @@ src/qtui/ui/channelwidget.ui src/qtui/ui/connectionpage.ui src/qtui/ui/coreconnectdlg.ui src/qtui/ui/coresettingspage.ui +src/qtui/ui/debugconsole.ui src/qtui/ui/identitiesdlg.ui src/qtui/ui/identitieseditdlg.ui src/qtui/ui/mainwin.ui diff --git a/src/common/main.cpp b/src/common/main.cpp index 97851699..b5fe32cf 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -18,13 +18,15 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "global.h" -#include "identity.h" -#include "settings.h" +#include #include #include #include +#include "global.h" +#include "identity.h" +#include "settings.h" + #if defined BUILD_CORE #include #include @@ -73,6 +75,8 @@ int main(int argc, char **argv) { QApplication app(argc, argv); #endif + qsrand(QDateTime::currentDateTime().toTime_t()); + // Set up i18n support QLocale locale = QLocale::system(); diff --git a/src/core/core.cpp b/src/core/core.cpp index 66d1d37b..7da0aee5 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -162,6 +162,7 @@ void Core::restoreState() { sess->restoreState(m["State"]); } } + qDebug() << "...done."; } } diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index bbe4a1f8..fda81561 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -18,8 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#define SPUTDEV - #include "coresession.h" #include "server.h" @@ -48,7 +46,7 @@ CoreSession::CoreSession(UserId uid, Storage *_storage, QObject *parent) CoreUserSettings s(user); sessionData = s.sessionData(); -#ifdef SPUTDEV + foreach(IdentityId id, s.identityIds()) { Identity *i = new Identity(s.identity(id), this); if(!i->isValid()) { @@ -70,7 +68,6 @@ CoreSession::CoreSession(UserId uid, Storage *_storage, QObject *parent) i.setIdentityName(tr("Default Identity")); createIdentity(i); } -#endif p->attachSlot(SIGNAL(requestNetworkStates()), this, SLOT(serverStateRequested())); p->attachSlot(SIGNAL(requestConnect(QString)), this, SLOT(connectToNetwork(QString))); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 47e44e53..dfef33ca 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -204,9 +204,8 @@ void MainWin::addBufferView(const QString &viewname, QAbstractItemModel *model, void MainWin::setupSettingsDlg() { settingsDlg->registerSettingsPage(new FontsSettingsPage(settingsDlg)); -#ifdef SPUTDEV settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg)); -#endif + } void MainWin::connectedToCore() { diff --git a/src/qtui/settingsdlg.cpp b/src/qtui/settingsdlg.cpp index 6c7d24a4..1e8a59b1 100644 --- a/src/qtui/settingsdlg.cpp +++ b/src/qtui/settingsdlg.cpp @@ -24,14 +24,26 @@ SettingsDlg::SettingsDlg(QWidget *parent) : QDialog(parent) { ui.setupUi(this); _currentPage = 0; - //ui.settingsFrame->setWidgetResizable(true); - //ui.settingsFrame->setWidget(ui.settingsStack); + //recommendedSize = layout()->minimumSize(); + + // make the scrollarea behave sanely + ui.settingsFrame->setWidgetResizable(true); + ui.settingsFrame->setWidget(ui.settingsStack); + + updateGeometry(); + ui.settingsTree->setRootIsDecorated(false); connect(ui.settingsTree, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelected())); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); } +/* +QSize SettingsDlg::sizeHint() const { + return recommendedSize; +} +*/ + SettingsPage *SettingsDlg::currentPage() const { return _currentPage; } @@ -39,6 +51,8 @@ SettingsPage *SettingsDlg::currentPage() const { void SettingsDlg::registerSettingsPage(SettingsPage *sp) { sp->setParent(ui.settingsStack); ui.settingsStack->addWidget(sp); + //recommendedSize = recommendedSize.expandedTo(sp->sizeHint()); + //updateGeometry(); connect(sp, SIGNAL(changed(bool)), this, SLOT(setButtonStates())); QTreeWidgetItem *cat; @@ -48,25 +62,42 @@ void SettingsDlg::registerSettingsPage(SettingsPage *sp) { cat->setExpanded(true); cat->setFlags(Qt::ItemIsEnabled); } else cat = cats[0]; - new QTreeWidgetItem(cat, QStringList(sp->title())); + QTreeWidgetItem *item = new QTreeWidgetItem(cat, QStringList(sp->title())); + treeItems[sp] = item; pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp; - updateGeometry(); // TESTING - selectPage(sp->category(), sp->title()); + //selectPage(sp->category(), sp->title()); } void SettingsDlg::selectPage(const QString &cat, const QString &title) { SettingsPage *sp = pages[QString("%1$%2").arg(cat, title)]; - Q_ASSERT(sp); // FIXME allow for invalid settings pages - ui.settingsStack->setCurrentWidget(sp); - _currentPage = sp; + if(!sp) { + _currentPage = 0; + ui.settingsStack->setCurrentIndex(0); + ui.settingsTree->setCurrentItem(0); + return; + } + if(sp != currentPage() && currentPage() != 0 && currentPage()->hasChanged()) { + int ret = QMessageBox::warning(this, tr("Save changes"), + tr("There are unsaved changes on the current configuration page. Would you like to apply your changes now?"), + QMessageBox::Discard|QMessageBox::Save|QMessageBox::Cancel, QMessageBox::Cancel); + if(ret == QMessageBox::Save) { + if(!applyChanges()) sp = currentPage(); + } else if(ret == QMessageBox::Discard) { + undoChanges(); + } else sp = currentPage(); + } + if(sp != currentPage()) { + ui.pageTitle->setText(sp->title()); + ui.settingsStack->setCurrentWidget(sp); + ui.settingsStack->setMinimumSize(sp->sizeHint()); // we don't want our page shrinked, use scrollbars instead... + _currentPage = sp; + } + ui.settingsTree->setCurrentItem(treeItems[sp]); setButtonStates(); } void SettingsDlg::itemSelected() { - // Check if we have changed anything... - // TODO - QList items = ui.settingsTree->selectedItems(); if(!items.count()) { return; @@ -76,7 +107,6 @@ void SettingsDlg::itemSelected() { QString cat = parent->text(0); QString title = items[0]->text(0); selectPage(cat, title); - ui.pageTitle->setText(title); } } @@ -85,6 +115,7 @@ void SettingsDlg::setButtonStates() { ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(sp && sp->hasChanged()); ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(sp && sp->hasChanged()); ui.buttonBox->button(QDialogButtonBox::Reset)->setEnabled(sp && sp->hasChanged()); + ui.buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(sp && sp->hasDefaults()); } void SettingsDlg::buttonClicked(QAbstractButton *button) { @@ -96,6 +127,7 @@ void SettingsDlg::buttonClicked(QAbstractButton *button) { applyChanges(); break; case QDialogButtonBox::Cancel: + undoChanges(); reject(); break; case QDialogButtonBox::Reset: @@ -118,13 +150,26 @@ bool SettingsDlg::applyChanges() { return false; } -// TODO add messagebox +void SettingsDlg::undoChanges() { + if(currentPage()) { + currentPage()->load(); + } +} + void SettingsDlg::reload() { - SettingsPage *page = qobject_cast(ui.settingsStack->currentWidget()); - if(page) page->load(); + if(!currentPage()) return; + int ret = QMessageBox::question(this, tr("Reload Settings"), tr("Do you like to reload the settings, undoing your changes on this page?"), + QMessageBox::Yes|QMessageBox::No, QMessageBox::No); + if(ret == QMessageBox::Yes) { + currentPage()->load(); + } } void SettingsDlg::loadDefaults() { - SettingsPage *page = qobject_cast(ui.settingsStack->currentWidget()); - if(page) page->defaults(); + if(!currentPage()) return; + int ret = QMessageBox::question(this, tr("Restore Defaults"), tr("Do you like to restore the default values for this page?"), + QMessageBox::RestoreDefaults|QMessageBox::Cancel, QMessageBox::Cancel); + if(ret == QMessageBox::Yes) { + currentPage()->defaults(); + } } diff --git a/src/qtui/settingsdlg.h b/src/qtui/settingsdlg.h index ca15811d..31be186d 100644 --- a/src/qtui/settingsdlg.h +++ b/src/qtui/settingsdlg.h @@ -35,6 +35,8 @@ class SettingsDlg : public QDialog { SettingsPage *currentPage() const; + //QSize sizeHint() const; + public slots: void selectPage(const QString &category, const QString &title); @@ -42,6 +44,7 @@ class SettingsDlg : public QDialog { void itemSelected(); void buttonClicked(QAbstractButton *); bool applyChanges(); + void undoChanges(); void reload(); void loadDefaults(); void setButtonStates(); @@ -51,6 +54,9 @@ class SettingsDlg : public QDialog { SettingsPage *_currentPage; QHash pages; + QHash treeItems; + + //QSize recommendedSize; }; /* diff --git a/src/qtui/settingspages/fontssettingspage.cpp b/src/qtui/settingspages/fontssettingspage.cpp index d64fdfc8..b82c72f5 100644 --- a/src/qtui/settingspages/fontssettingspage.cpp +++ b/src/qtui/settingspages/fontssettingspage.cpp @@ -47,18 +47,24 @@ FontsSettingsPage::FontsSettingsPage(QWidget *parent) connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *))); + connect(ui.customAppFonts, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkTopic, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkNickList, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkBufferView, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkNicks, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + connect(ui.checkTimestamp, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); + load(); } -bool FontsSettingsPage::hasChanged() const { - - return false; +bool FontsSettingsPage::hasDefaults() const { + return true; } void FontsSettingsPage::defaults() { load(Settings::Default); - + widgetHasChanged(); } void FontsSettingsPage::load() { @@ -68,24 +74,25 @@ void FontsSettingsPage::load() { void FontsSettingsPage::load(Settings::Mode mode) { QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None, mode); - setFont(ui.demoChatMessages, chatFormat.font()); + initLabel(ui.demoChatMessages, chatFormat.font()); QTextCharFormat nicksFormat = QtUi::style()->format(UiStyle::Sender, mode); if(nicksFormat.hasProperty(QTextFormat::FontFamily)) { - setFont(ui.demoNicks, nicksFormat.font()); + initLabel(ui.demoNicks, nicksFormat.font()); ui.checkNicks->setChecked(true); } else { - setFont(ui.demoNicks, chatFormat.font()); + initLabel(ui.demoNicks, chatFormat.font()); ui.checkNicks->setChecked(false); } QTextCharFormat timestampFormat = QtUi::style()->format(UiStyle::Timestamp, mode); if(timestampFormat.hasProperty(QTextFormat::FontFamily)) { - setFont(ui.demoTimestamp, timestampFormat.font()); + initLabel(ui.demoTimestamp, timestampFormat.font()); ui.checkTimestamp->setChecked(true); } else { - setFont(ui.demoTimestamp, chatFormat.font()); + initLabel(ui.demoTimestamp, chatFormat.font()); ui.checkTimestamp->setChecked(false); } + changeState(false); } void FontsSettingsPage::save() { @@ -107,10 +114,18 @@ void FontsSettingsPage::save() { changeState(false); } +void FontsSettingsPage::widgetHasChanged() { + if(!hasChanged()) changeState(true); +} + +void FontsSettingsPage::initLabel(QLabel *label, const QFont &font) { + setFont(label, font); +} + void FontsSettingsPage::setFont(QLabel *label, const QFont &font) { - QFontInfo fontInfo(font); label->setFont(font); - label->setText(QString("%1 %2").arg(fontInfo.family()).arg(fontInfo.pointSize())); + label->setText(QString("%1 %2").arg(font.family()).arg(font.pointSize())); + widgetHasChanged(); } void FontsSettingsPage::chooseFont(QWidget *widget) { diff --git a/src/qtui/settingspages/fontssettingspage.h b/src/qtui/settingspages/fontssettingspage.h index 7928cb8d..42b2f431 100644 --- a/src/qtui/settingspages/fontssettingspage.h +++ b/src/qtui/settingspages/fontssettingspage.h @@ -21,12 +21,15 @@ #ifndef _FONTSSETTINGSPAGE_H_ #define _FONTSSETTINGSPAGE_H_ +#include + #include "settings.h" #include "settingspage.h" #include "ui_fontssettingspage.h" class QSignalMapper; +class QLabel; class FontsSettingsPage : public SettingsPage { Q_OBJECT @@ -34,7 +37,7 @@ class FontsSettingsPage : public SettingsPage { public: FontsSettingsPage(QWidget *parent = 0); - bool hasChanged() const; + bool hasDefaults() const; public slots: void save(); @@ -43,9 +46,12 @@ class FontsSettingsPage : public SettingsPage { private slots: void load(Settings::Mode mode); + void initLabel(QLabel *label, const QFont &font); void setFont(QLabel *label, const QFont &font); void chooseFont(QWidget *label); + void widgetHasChanged(); + private: Ui::FontsSettingsPage ui; diff --git a/src/qtui/settingspages/fontssettingspage.ui b/src/qtui/settingspages/fontssettingspage.ui index d6abdec7..d76004f7 100644 --- a/src/qtui/settingspages/fontssettingspage.ui +++ b/src/qtui/settingspages/fontssettingspage.ui @@ -5,8 +5,8 @@ 0 0 - 524 - 400 + 475 + 366 @@ -14,360 +14,364 @@ - - - false - - - Custom Application Fonts - - - true - - - false - - - - - - - - General: - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - - Topic: - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - - Buffer Views: - - - true - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - - Nick List: - - - true - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - + + + + + false + + + Custom Application Fonts + + + true + + + false + + + + + + + + General: + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + + + + Topic: + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + + + + Buffer Views: + + + true + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + + + + Nick List: + + + true + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + - - - - - - - - Chat Widget - - - - - - - - General: - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - - Nicks: - - - true - - - - - - - Timestamp: - - - true - - + + + + + + Chat Widget + + + + + + + + General: + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Font + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Choose... + + + + + + + Nicks: + + + true + + + + + + + Timestamp: + + + true + + + + - - - - - - - - - true - - - - Some of these settings require a restart of the Quassel Client in order to take effect. We intend to fix this. - - - true - - + + + + + + + true + + + + Some of these settings require a restart of the Quassel Client in order to take effect. We intend to fix this. + + + true + + + + @@ -377,7 +381,7 @@ 20 - 41 + 40 diff --git a/src/qtui/settingspages/identitiessettingspage.cpp b/src/qtui/settingspages/identitiessettingspage.cpp index c9cb1f12..83b12066 100644 --- a/src/qtui/settingspages/identitiessettingspage.cpp +++ b/src/qtui/settingspages/identitiessettingspage.cpp @@ -30,6 +30,7 @@ IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent) ui.setupUi(this); setEnabled(false); // need a core connection! + setWidgetStates(); connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool))); connect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(clientIdentityCreated(IdentityId))); connect(Client::instance(), SIGNAL(identityRemoved(IdentityId)), this, SLOT(clientIdentityRemoved(IdentityId))); @@ -57,6 +58,26 @@ IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent) connect(ui.partReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); connect(ui.quitReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); + connect(ui.nicknameList, SIGNAL(itemSelectionChanged()), this, SLOT(setWidgetStates())); + + // we would need this if we enabled drag and drop in the nicklist... + //connect(ui.nicknameList, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(setWidgetStates())); + //connect(ui.nicknameList->model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(nicklistHasChanged())); + +} + +void IdentitiesSettingsPage::setWidgetStates() { + if(ui.nicknameList->selectedItems().count()) { + ui.renameNick->setEnabled(true); + ui.nickUp->setEnabled(ui.nicknameList->row(ui.nicknameList->selectedItems()[0]) > 0); + ui.nickDown->setEnabled(ui.nicknameList->row(ui.nicknameList->selectedItems()[0]) < ui.nicknameList->count()-1); + } else { + ui.renameNick->setDisabled(true); + ui.nickUp->setDisabled(true); + ui.nickDown->setDisabled(true); + } + ui.deleteNick->setEnabled(ui.nicknameList->count() > 1); + } void IdentitiesSettingsPage::coreConnectionStateChanged(bool state) { @@ -118,10 +139,6 @@ void IdentitiesSettingsPage::load() { changeState(false); } -void IdentitiesSettingsPage::defaults() { - // TODO implement bool hasDefaults() -} - void IdentitiesSettingsPage::widgetHasChanged() { bool changed = testHasChanged(); if(changed != hasChanged()) changeState(changed); @@ -165,7 +182,6 @@ bool IdentitiesSettingsPage::aboutToSave() { void IdentitiesSettingsPage::clientIdentityCreated(IdentityId id) { insertIdentity(new Identity(*Client::identity(id), this)); - Identity *i = identities[id]; connect(Client::identity(id), SIGNAL(updatedRemotely()), this, SLOT(clientIdentityUpdated())); } @@ -224,6 +240,7 @@ void IdentitiesSettingsPage::removeIdentity(Identity *id) { identities.remove(id->id()); ui.identityList->removeItem(ui.identityList->findData(id->id())); changedIdentities.removeAll(id->id()); + if(currentId == id->id()) currentId = 0; id->deleteLater(); widgetHasChanged(); } @@ -335,7 +352,7 @@ void IdentitiesSettingsPage::on_renameIdentity_clicked() { QString oldName = identities[currentId]->identityName(); bool ok = false; QString name = QInputDialog::getText(this, tr("Rename Identity"), - tr("Please enter a new name for the identity \"%1\":").arg(oldName), + tr("Please enter a new name for the identity \"%1\"!").arg(oldName), QLineEdit::Normal, oldName, &ok); if(ok && !name.isEmpty()) { renameIdentity(currentId, name); @@ -343,6 +360,61 @@ void IdentitiesSettingsPage::on_renameIdentity_clicked() { } } +void IdentitiesSettingsPage::on_addNick_clicked() { + QStringList existing; + for(int i = 0; i < ui.nicknameList->count(); i++) existing << ui.nicknameList->item(i)->text(); + NickEditDlgNew dlg(QString(), existing, this); + if(dlg.exec() == QDialog::Accepted) { + ui.nicknameList->addItem(dlg.nick()); + ui.nicknameList->setCurrentRow(ui.nicknameList->count()-1); + setWidgetStates(); + } +} + +void IdentitiesSettingsPage::on_deleteNick_clicked() { + // no confirmation, since a nickname is really nothing hard to recreate + if(ui.nicknameList->selectedItems().count()) { + delete ui.nicknameList->selectedItems()[0]; + ui.nicknameList->setCurrentRow(qMin(ui.nicknameList->currentRow()+1, ui.nicknameList->count()-1)); + setWidgetStates(); + widgetHasChanged(); + } +} + +void IdentitiesSettingsPage::on_renameNick_clicked() { + if(!ui.nicknameList->selectedItems().count()) return; + QString old = ui.nicknameList->selectedItems()[0]->text(); + QStringList existing; + for(int i = 0; i < ui.nicknameList->count(); i++) existing << ui.nicknameList->item(i)->text(); + NickEditDlgNew dlg(old, existing, this); + if(dlg.exec() == QDialog::Accepted) { + ui.nicknameList->selectedItems()[0]->setText(dlg.nick()); + } + +} + +void IdentitiesSettingsPage::on_nickUp_clicked() { + if(!ui.nicknameList->selectedItems().count()) return; + int row = ui.nicknameList->row(ui.nicknameList->selectedItems()[0]); + if(row > 0) { + ui.nicknameList->insertItem(row-1, ui.nicknameList->takeItem(row)); + ui.nicknameList->setCurrentRow(row-1); + setWidgetStates(); + widgetHasChanged(); + } +} + +void IdentitiesSettingsPage::on_nickDown_clicked() { + if(!ui.nicknameList->selectedItems().count()) return; + int row = ui.nicknameList->row(ui.nicknameList->selectedItems()[0]); + if(row < ui.nicknameList->count()-1) { + ui.nicknameList->insertItem(row+1, ui.nicknameList->takeItem(row)); + ui.nicknameList->setCurrentRow(row+1); + setWidgetStates(); + widgetHasChanged(); + } +} + /*****************************************************************************************/ CreateIdentityDlg::CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent) : QDialog(parent) { @@ -409,3 +481,34 @@ void SaveIdentitiesDlg::clientEvent() { ui.progressBar->setValue(++rcvevents); if(rcvevents >= numevents) accept(); } + +/*************************************************************************************************/ + +NickEditDlgNew::NickEditDlgNew(const QString &old, const QStringList &exist, QWidget *parent) + : QDialog(parent), oldNick(old), existing(exist) { + ui.setupUi(this); + + // define a regexp for valid nicknames + // TODO: add max nicklength according to ISUPPORT + QString letter = "A-Za-z"; + QString special = "\x5b-\x60\x7b-\x7d"; + QRegExp rx(QString("[%1%2][%1%2\\d-]*").arg(letter, special)); + ui.nickEdit->setValidator(new QRegExpValidator(rx, ui.nickEdit)); + if(old.isEmpty()) { + // new nick + setWindowTitle(tr("Add Nickname")); + on_nickEdit_textChanged(""); // disable ok button + } else ui.nickEdit->setText(old); +} + +QString NickEditDlgNew::nick() const { + return ui.nickEdit->text(); + +} + +void NickEditDlgNew::on_nickEdit_textChanged(const QString &text) { + ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty() || existing.contains(text)); +} + + + diff --git a/src/qtui/settingspages/identitiessettingspage.h b/src/qtui/settingspages/identitiessettingspage.h index 294d646e..b2c5021d 100644 --- a/src/qtui/settingspages/identitiessettingspage.h +++ b/src/qtui/settingspages/identitiessettingspage.h @@ -27,6 +27,7 @@ #include "ui_identitiessettingspage.h" #include "ui_createidentitydlg.h" #include "ui_saveidentitiesdlg.h" +#include "ui_nickeditdlgnew.h" class QAbstractItemModel; @@ -41,7 +42,6 @@ class IdentitiesSettingsPage : public SettingsPage { public slots: void save(); void load(); - void defaults(); private slots: void coreConnectionStateChanged(bool); @@ -55,7 +55,14 @@ class IdentitiesSettingsPage : public SettingsPage { void on_deleteIdentity_clicked(); void on_renameIdentity_clicked(); + void on_addNick_clicked(); + void on_deleteNick_clicked(); + void on_renameNick_clicked(); + void on_nickUp_clicked(); + void on_nickDown_clicked(); + void widgetHasChanged(); + void setWidgetStates(); private: Ui::IdentitiesSettingsPage ui; @@ -110,4 +117,23 @@ class SaveIdentitiesDlg : public QDialog { }; +class NickEditDlgNew : public QDialog { + Q_OBJECT + + public: + NickEditDlgNew(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0); + + QString nick() const; + + private slots: + void on_nickEdit_textChanged(const QString &); + + private: + Ui::NickEditDlgNew ui; + + QString oldNick; + QStringList existing; + +}; + #endif diff --git a/src/qtui/settingspages/identitiessettingspage.ui b/src/qtui/settingspages/identitiessettingspage.ui index 92f18b28..a5fd9d16 100644 --- a/src/qtui/settingspages/identitiessettingspage.ui +++ b/src/qtui/settingspages/identitiessettingspage.ui @@ -5,8 +5,8 @@ 0 0 - 431 - 398 + 495 + 417 @@ -14,558 +14,600 @@ - + - - - QComboBox::InsertAtBottom - - - true - - - - - - - ... - - - :/22x22/actions/oxygen/22x22/actions/edit-rename.png - - - - 22 - 22 - - - - - - - - Add... - - - :/22x22/actions/oxygen/22x22/actions/list-add-user.png - - - - 22 - 22 - - - - Qt::ToolButtonIconOnly - - + + + + + QComboBox::InsertAtBottom + + + true + + + + + + + Rename Identity + + + ... + + + :/22x22/actions/oxygen/22x22/actions/edit-rename.png + + + + 22 + 22 + + + + + + + + Add Identity + + + Add... + + + :/22x22/actions/oxygen/22x22/actions/list-add-user.png + + + + 22 + 22 + + + + Qt::ToolButtonIconOnly + + + + + + + Remove Identity + + + ... + + + :/22x22/actions/oxygen/22x22/actions/list-remove-user.png + + + + 22 + 22 + + + + + - - - ... - - - :/22x22/actions/oxygen/22x22/actions/list-remove-user.png - - - - 22 - 22 - + + + 0 - - - - - - - - 0 - - - - General - - - - + + + General + + - - - Real Name: - - + + + + + Real Name: + + + + + + + The "Real Name" is shown in /whois. + + + + - - - - - - - - Nicknames - - - - - - - 1 - 0 - - - - - - - - - - - 0 - 0 - - - - &Add... - - - :/16x16/actions/oxygen/16x16/actions/list-add.png - - - - 16 - 16 - - - - + + + Nicknames + + - + - - 0 + + 1 0 - - De&lete + + true - - :/16x16/actions/oxygen/16x16/actions/edit-delete.png + + false - - - - - - - 0 - 0 - + + QAbstractItemView::NoDragDrop - - Re&name... - - - :/16x16/actions/oxygen/16x16/actions/edit-rename.png + + QAbstractItemView::SelectRows - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - + - - - Qt::Horizontal + + + + 0 + 0 + - + + Add Nickname + + + &Add... + + + :/16x16/actions/oxygen/16x16/actions/list-add.png + + - 0 - 20 + 16 + 16 - + - + + + + 0 + 0 + + - Move upwards in list + Remove Nickname - ... + Remove - :/16x16/actions/oxygen/16x16/actions/go-up.png + :/16x16/actions/oxygen/16x16/actions/edit-delete.png - + + + + 0 + 0 + + - Move downwards in list + Rename Identity - ... + Re&name... - :/16x16/actions/oxygen/16x16/actions/go-down.png + :/16x16/actions/oxygen/16x16/actions/edit-rename.png + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + Move upwards in list + + + ... + + + :/16x16/actions/oxygen/16x16/actions/go-up.png + + + + + + + Move downwards in list + + + ... + + + :/16x16/actions/oxygen/16x16/actions/go-down.png + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + - Qt::Horizontal + Qt::Vertical - 0 - 20 + 124 + 76 - - - - Qt::Vertical - - - - 124 - 76 - - - - - - - - - - - - - A&way - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - false - - - - - Away Reason + + + + + A&way + + + + + + 0 - - - - - - false + + 0 - - - - - - Return Message + + 0 - - - - - - false + + 0 - - - - - - Away Nick + + 6 - + + 6 + + + + + false + + + + + + + Away Reason + + + + + + + false + + + + + + + Return Message + + + + + + + false + + + + + + + Away Nick + + + + - - - - - - Auto Away - - - true - - - false - - - - 6 - - - 8 - - - 8 - - - 8 - - - 8 - - - + + + + Auto Away + + + true + + + false + + 6 - 0 + 8 - 0 + 8 - 0 + 8 - 0 + 8 - - - Auto away after + + + 6 - - - - - - - - - minutes + + 0 - + + 0 + + + 0 + + + 0 + + + + + Auto away after + + + + + + + + + + minutes + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - Qt::Horizontal + + + 0 - - - 40 - 20 - + + 0 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - Return Message + + 0 - - - - - - Away Reason + + 0 - - - - - - - + + 6 + + + 6 + + + + + Return Message + + + + + + + Away Reason + + + + + + + + + + - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Advanced - - - - - - - - Ident: - - + + + Qt::Vertical + + + + 20 + 40 + + + - - - - - Messages - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - Part Reason: + + + + Advanced + + + + + + + + Ident: + + + + + + + The "ident" is part of your hostmask and, together with your host, uniquely identifies you within the IRC network. + + + + + + + + + Messages + + + + + + 0 - - - - - - - - - - - - Quit Reason: + + 0 - - - - - - - - - Kick Reason: + + 0 - + + 0 + + + 6 + + + 6 + + + + + Part Reason: + + + + + + + + + + + + + Quit Reason: + + + + + + + + + + Kick Reason: + + + + - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/qtui/settingspages/nickeditdlgnew.ui b/src/qtui/settingspages/nickeditdlgnew.ui new file mode 100644 index 00000000..c1b3be45 --- /dev/null +++ b/src/qtui/settingspages/nickeditdlgnew.ui @@ -0,0 +1,100 @@ + + NickEditDlgNew + + + + 0 + 0 + 285 + 93 + + + + Edit Nickname + + + + + + + + Please enter a valid nickname: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + A valid nickname may contain letters from the English alphabet, digits, and the special characters {, }, [, ], \, |, `, ^, _ and -. + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + + + Qt::Vertical + + + + 277 + 16 + + + + + + + + + + buttonBox + accepted() + NickEditDlgNew + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + NickEditDlgNew + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qtui/settingspages/settingspages.pri b/src/qtui/settingspages/settingspages.pri index 2e007c9d..e97d8cd5 100644 --- a/src/qtui/settingspages/settingspages.pri +++ b/src/qtui/settingspages/settingspages.pri @@ -1,7 +1,8 @@ +# Putting $FOO in SETTINGSPAGES automatically includes +# $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui SETTINGSPAGES = fonts identities -# Specify additional files here! - -SP_SRCS = +# Specify additional files (e.g. for subdialogs) here! +SP_SRCS = SP_HDRS = -SP_FRMS = createidentitydlg.ui saveidentitiesdlg.ui +SP_FRMS = createidentitydlg.ui saveidentitiesdlg.ui nickeditdlgnew.ui diff --git a/src/qtui/ui/mainwin.ui b/src/qtui/ui/mainwin.ui index 5d5e5adf..5b96bf55 100644 --- a/src/qtui/ui/mainwin.ui +++ b/src/qtui/ui/mainwin.ui @@ -46,7 +46,7 @@ 0 0 800 - 26 + 24 @@ -160,6 +160,9 @@ + + :/22x22/actions/oxygen/22x22/actions/application-exit.png + Quit... @@ -194,6 +197,9 @@ + + :/icons/quassel-icon.png + About Quassel IRC... @@ -222,6 +228,9 @@ false + + :/22x22/actions/oxygen/22x22/actions/network-disconnect.png + Disconnect from Core @@ -230,6 +239,9 @@ false + + :/22x22/actions/oxygen/22x22/actions/network-connect.png + Connect to Core... diff --git a/src/qtui/ui/nickeditdlg.ui b/src/qtui/ui/nickeditdlg.ui index fbd82ca0..8189f793 100644 --- a/src/qtui/ui/nickeditdlg.ui +++ b/src/qtui/ui/nickeditdlg.ui @@ -5,14 +5,12 @@ 0 0 - 307 - 96 + 309 + 113 - - 3 - 3 + 0 0 @@ -24,12 +22,21 @@ true - - 9 - 6 + + 9 + + + 9 + + + 9 + + + 9 + diff --git a/src/qtui/ui/settingsdlg.ui b/src/qtui/ui/settingsdlg.ui index 0dbb5e57..13f57a67 100644 --- a/src/qtui/ui/settingsdlg.ui +++ b/src/qtui/ui/settingsdlg.ui @@ -5,91 +5,103 @@ 0 0 - 742 - 502 + 780 + 580 - + Configure Quassel - - - Qt::Horizontal - - - - - 0 - 0 - - - - - 200 - 16777215 - - - - - Settings + + + + + Qt::Horizontal - - - - - - - - - 75 - true - - + + + + 0 + 0 + + + + + 200 + 16777215 + + + Settings - - - - - - Qt::Horizontal - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults - - + + + + + + + + + 75 + true + + + + Settings + + + + + + + Qt::Horizontal + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 16 + 16 + + + + 0 + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults + + + + diff --git a/src/qtui/ui/topicwidget.ui b/src/qtui/ui/topicwidget.ui index 53d88254..e1587b83 100644 --- a/src/qtui/ui/topicwidget.ui +++ b/src/qtui/ui/topicwidget.ui @@ -5,8 +5,8 @@ 0 0 - 568 - 28 + 559 + 30 @@ -48,13 +48,27 @@ + + false + ... + + :/22x22/actions/oxygen/22x22/actions/configure.png + + + + 22 + 22 + + - + + + diff --git a/src/uisupport/settingspage.cpp b/src/uisupport/settingspage.cpp index 8b8e423a..37ac416f 100644 --- a/src/uisupport/settingspage.cpp +++ b/src/uisupport/settingspage.cpp @@ -34,6 +34,14 @@ QString SettingsPage::title() const { return _title; } +bool SettingsPage::hasDefaults() const { + return false; +} + +void SettingsPage::defaults() { + +} + bool SettingsPage::hasChanged() const { return _changed; } diff --git a/src/uisupport/settingspage.h b/src/uisupport/settingspage.h index 2d73e823..247efb1f 100644 --- a/src/uisupport/settingspage.h +++ b/src/uisupport/settingspage.h @@ -32,6 +32,7 @@ class SettingsPage : public QWidget { virtual ~SettingsPage() {}; virtual QString category() const; virtual QString title() const; + virtual bool hasDefaults() const; bool hasChanged() const; @@ -44,7 +45,7 @@ class SettingsPage : public QWidget { public slots: virtual void save() = 0; virtual void load() = 0; - virtual void defaults() = 0; + virtual void defaults(); protected slots: //! Calling this slot is equivalent to calling changeState(true).