/***************************************************************************
- * Copyright (C) 2005-2016 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#include <QIcon>
+#include "settingsdlg.h"
+
#include <QMessageBox>
#include <QPushButton>
-#include "settingsdlg.h"
-
#include "client.h"
+#include "icon.h"
SettingsDlg::SettingsDlg(QWidget *parent)
: QDialog(parent),
- _currentPage(0)
+ _currentPage(nullptr)
{
ui.setupUi(this);
setModal(true);
setAttribute(Qt::WA_DeleteOnClose, true);
- setWindowIcon(QIcon::fromTheme("configure"));
+ setWindowIcon(icon::get("configure"));
updateGeometry();
connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), SLOT(coreConnectionStateChanged()));
setButtonStates();
-
- // Some settings panes can take a good bit of space. To avoid squashing the settings tree, try
- // to resize the dialog. If needed, it can always be resized by the user to take less space.
- //
- // Only try to resize if the sizes are valid. This shouldn't happen.. but better to be safe.
- // See http://www.qtcentre.org/threads/3427-invalid-sizeHint()
- if (ui.settingsTree->sizeHint().isValid() && ui.settingsTree->size().isValid()) {
- // Find out how much width would make the settings tree happy
- int wantedExtraWidth = ui.settingsTree->sizeHint().width()
- - ui.settingsTree->size().width();
- // If more space is needed, try to resize to allow for it. Qt should keep the dialog within
- // the bounds of the screen.
- if (wantedExtraWidth > 0) {
- this->resize(this->width() + wantedExtraWidth, this->height());
- }
- }
}
item = new QTreeWidgetItem(cat, QStringList(sp->title()));
item->setData(0, SettingsPageRole, QVariant::fromValue<QObject *>(sp));
- ui.settingsTree->setMinimumWidth(ui.settingsTree->header()->sectionSizeHint(0) + 5);
pageIsLoaded[sp] = false;
if (!ui.settingsTree->selectedItems().count())
ui.settingsTree->setCurrentItem(item);
void SettingsDlg::selectPage(SettingsPage *sp)
{
if (!sp) {
- _currentPage = 0;
+ _currentPage = nullptr;
ui.settingsStack->setCurrentIndex(0);
ui.pageTitle->setText(tr("Settings"));
return;
pageIsLoaded[sp] = true;
}
- if (sp != currentPage() && currentPage() != 0 && currentPage()->hasChanged()) {
+ if (sp != currentPage() && currentPage() != nullptr && 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);
void SettingsDlg::itemSelected()
{
QList<QTreeWidgetItem *> items = ui.settingsTree->selectedItems();
- SettingsPage *sp = 0;
+ SettingsPage *sp = nullptr;
if (!items.isEmpty()) {
sp = qobject_cast<SettingsPage *>(items[0]->data(0, SettingsPageRole).value<QObject *>());
}