From: Chris Le Sueur Date: Wed, 15 May 2013 22:44:26 +0000 (+0100) Subject: Add a setting to hide inactive networks in buffer views X-Git-Tag: 0.10-beta1~10 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=57533dc61da3c52529653623cdf0a26657a908ea Add a setting to hide inactive networks in buffer views --- diff --git a/src/common/bufferviewconfig.cpp b/src/common/bufferviewconfig.cpp index c295b70b..2b6f3409 100644 --- a/src/common/bufferviewconfig.cpp +++ b/src/common/bufferviewconfig.cpp @@ -29,6 +29,7 @@ BufferViewConfig::BufferViewConfig(int bufferViewId, QObject *parent) _addNewBuffersAutomatically(true), _sortAlphabetically(true), _hideInactiveBuffers(false), + _hideInactiveNetworks(false), _disableDecoration(false), _allowedBufferTypes(BufferInfo::StatusBuffer | BufferInfo::ChannelBuffer | BufferInfo::QueryBuffer | BufferInfo::GroupBuffer), _minimumActivity(0) @@ -133,6 +134,16 @@ void BufferViewConfig::setHideInactiveBuffers(bool hideInactiveBuffers) emit configChanged(); } +void BufferViewConfig::setHideInactiveNetworks(bool hideInactiveNetworks) +{ + if (_hideInactiveNetworks == hideInactiveNetworks) + return; + + _hideInactiveNetworks = hideInactiveNetworks; + SYNC(ARG(hideInactiveNetworks)) + emit configChanged(); +} + QVariantList BufferViewConfig::initBufferList() const { diff --git a/src/common/bufferviewconfig.h b/src/common/bufferviewconfig.h index f380d5b2..ecf92ebf 100644 --- a/src/common/bufferviewconfig.h +++ b/src/common/bufferviewconfig.h @@ -35,6 +35,7 @@ class BufferViewConfig : public SyncableObject Q_PROPERTY(bool addNewBuffersAutomatically READ addNewBuffersAutomatically WRITE setAddNewBuffersAutomatically) Q_PROPERTY(bool sortAlphabetically READ sortAlphabetically WRITE setSortAlphabetically) Q_PROPERTY(bool hideInactiveBuffers READ hideInactiveBuffers WRITE setHideInactiveBuffers) + Q_PROPERTY(bool hideInactiveNetworks READ hideInactiveNetworks WRITE setHideInactiveNetworks) Q_PROPERTY(bool disableDecoration READ disableDecoration WRITE setDisableDecoration) Q_PROPERTY(int allowedBufferTypes READ allowedBufferTypes WRITE setAllowedBufferTypes) Q_PROPERTY(int minimumActivity READ minimumActivity WRITE setMinimumActivity) @@ -72,6 +73,9 @@ public slots: inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; } void setHideInactiveBuffers(bool hideInactiveBuffers); + inline bool hideInactiveNetworks() const { return _hideInactiveNetworks; } + void setHideInactiveNetworks(bool hideInactiveNetworks); + virtual inline void requestSetBufferViewName(const QString &bufferViewName) { REQUEST(ARG(bufferViewName)) } const QList &bufferList() const { return _buffers; } @@ -127,6 +131,7 @@ private: bool _addNewBuffersAutomatically; bool _sortAlphabetically; bool _hideInactiveBuffers; + bool _hideInactiveNetworks; bool _disableDecoration; int _allowedBufferTypes; int _minimumActivity; diff --git a/src/qtui/settingspages/bufferviewsettingspage.cpp b/src/qtui/settingspages/bufferviewsettingspage.cpp index 043445ba..245dd10b 100644 --- a/src/qtui/settingspages/bufferviewsettingspage.cpp +++ b/src/qtui/settingspages/bufferviewsettingspage.cpp @@ -60,6 +60,7 @@ BufferViewSettingsPage::BufferViewSettingsPage(QWidget *parent) connect(ui.addNewBuffersAutomatically, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.sortAlphabetically, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.hideInactiveBuffers, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.hideInactiveNetworks, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.networkSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged())); connect(ui.minimumActivitySelector, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged())); @@ -435,6 +436,7 @@ void BufferViewSettingsPage::loadConfig(BufferViewConfig *config) ui.addNewBuffersAutomatically->setChecked(config->addNewBuffersAutomatically()); ui.sortAlphabetically->setChecked(config->sortAlphabetically()); ui.hideInactiveBuffers->setChecked(config->hideInactiveBuffers()); + ui.hideInactiveNetworks->setChecked(config->hideInactiveNetworks()); int networkIndex = 0; for (int i = 0; i < ui.networkSelector->count(); i++) { @@ -476,6 +478,7 @@ void BufferViewSettingsPage::saveConfig(BufferViewConfig *config) config->setAddNewBuffersAutomatically(ui.addNewBuffersAutomatically->isChecked()); config->setSortAlphabetically(ui.sortAlphabetically->isChecked()); config->setHideInactiveBuffers(ui.hideInactiveBuffers->isChecked()); + config->setHideInactiveNetworks(ui.hideInactiveNetworks->isChecked()); config->setNetworkId(ui.networkSelector->itemData(ui.networkSelector->currentIndex()).value()); int minimumActivity = 0; diff --git a/src/qtui/settingspages/bufferviewsettingspage.ui b/src/qtui/settingspages/bufferviewsettingspage.ui index 6ec07d6a..30b09078 100644 --- a/src/qtui/settingspages/bufferviewsettingspage.ui +++ b/src/qtui/settingspages/bufferviewsettingspage.ui @@ -136,6 +136,13 @@ In this mode no separate status buffer is displayed. + + + + Hide inactive networks + + + diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 0850a502..2720fd11 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -377,6 +377,10 @@ bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) cons if (!config()) return true; + if (config()->hideInactiveNetworks() && !(sourceModel()->data(source_index, NetworkModel::ItemActiveRole).toBool())) { + return false; + } + if (!config()->networkId().isValid()) { return true; }