Changeset View
Changeset View
Standalone View
Standalone View
decorations/settings.cpp
Show All 13 Lines | |||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "settings.h" | 20 | #include "settings.h" | ||
21 | // KWin | 21 | // KWin | ||
22 | #include "decorationbridge.h" | ||||
22 | #include "composite.h" | 23 | #include "composite.h" | ||
23 | #include "virtualdesktops.h" | 24 | #include "virtualdesktops.h" | ||
24 | #include "workspace.h" | 25 | #include "workspace.h" | ||
25 | #include "appmenu.h" | 26 | #include "appmenu.h" | ||
26 | 27 | | |||
27 | #include <config-kwin.h> | 28 | #include <config-kwin.h> | ||
28 | 29 | | |||
29 | #include <KDecoration2/DecorationSettings> | 30 | #include <KDecoration2/DecorationSettings> | ||
Show All 25 Lines | 44 | { | |||
55 | ); | 56 | ); | ||
56 | // prevent changes in Decoration due to Compositor being destroyed | 57 | // prevent changes in Decoration due to Compositor being destroyed | ||
57 | connect(Compositor::self(), &Compositor::aboutToDestroy, this, | 58 | connect(Compositor::self(), &Compositor::aboutToDestroy, this, | ||
58 | [this, c] { | 59 | [this, c] { | ||
59 | disconnect(c); | 60 | disconnect(c); | ||
60 | } | 61 | } | ||
61 | ); | 62 | ); | ||
62 | connect(Workspace::self(), &Workspace::configChanged, this, &SettingsImpl::readSettings); | 63 | connect(Workspace::self(), &Workspace::configChanged, this, &SettingsImpl::readSettings); | ||
64 | connect(DecorationBridge::self(), &DecorationBridge::metaDataLoaded, this, &SettingsImpl::readSettings); | ||||
63 | } | 65 | } | ||
64 | 66 | | |||
65 | SettingsImpl::~SettingsImpl() = default; | 67 | SettingsImpl::~SettingsImpl() = default; | ||
66 | 68 | | |||
67 | bool SettingsImpl::isAlphaChannelSupported() const | 69 | bool SettingsImpl::isAlphaChannelSupported() const | ||
68 | { | 70 | { | ||
69 | return Compositor::self()->compositing(); | 71 | return Compositor::self()->compositing(); | ||
70 | } | 72 | } | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 175 | if (right != m_rightButtons) { | |||
175 | emit decorationSettings()->decorationButtonsRightChanged(m_rightButtons); | 177 | emit decorationSettings()->decorationButtonsRightChanged(m_rightButtons); | ||
176 | } | 178 | } | ||
177 | ApplicationMenu::self()->setViewEnabled(left.contains(KDecoration2::DecorationButtonType::ApplicationMenu) || right.contains(KDecoration2::DecorationButtonType::ApplicationMenu)); | 179 | ApplicationMenu::self()->setViewEnabled(left.contains(KDecoration2::DecorationButtonType::ApplicationMenu) || right.contains(KDecoration2::DecorationButtonType::ApplicationMenu)); | ||
178 | const bool close = config.readEntry("CloseOnDoubleClickOnMenu", false); | 180 | const bool close = config.readEntry("CloseOnDoubleClickOnMenu", false); | ||
179 | if (close != m_closeDoubleClickMenu) { | 181 | if (close != m_closeDoubleClickMenu) { | ||
180 | m_closeDoubleClickMenu = close; | 182 | m_closeDoubleClickMenu = close; | ||
181 | emit decorationSettings()->closeOnDoubleClickOnMenuChanged(m_closeDoubleClickMenu); | 183 | emit decorationSettings()->closeOnDoubleClickOnMenuChanged(m_closeDoubleClickMenu); | ||
182 | } | 184 | } | ||
183 | const auto size = stringToSize(config.readEntry("BorderSize", QStringLiteral("Normal"))); | 185 | m_autoBorderSize = config.readEntry("BorderSizeAuto", true); | ||
186 | | ||||
187 | auto size = stringToSize(config.readEntry("BorderSize", QStringLiteral("Normal"))); | ||||
188 | if (m_autoBorderSize) { | ||||
189 | /* Falls back to Normal border size, if the plugin does not provide a valid recommendation. */ | ||||
zzag: For consistency sake, it has to be a single line comment. | |||||
190 | size = stringToSize(DecorationBridge::self()->recommendedBorderSize()); | ||||
191 | } | ||||
Can't it be const auto size = stringToSize(m_autoBorderSize ? DecorationBridge::self()->recommendedBorderSize() : config.readEntry("BorderSize", QStringLiteral("Normal"))); ? Also, I would replace auto with a concrete type. zzag: Can't it be
```lang=cpp
const auto size = stringToSize(m_autoBorderSize
? DecorationBridge… | |||||
More compact and const, but also more difficult to understand. I leave it like it is. romangg: More compact and const, but also more difficult to understand. I leave it like it is. | |||||
184 | if (size != m_borderSize) { | 192 | if (size != m_borderSize) { | ||
185 | m_borderSize = size; | 193 | m_borderSize = size; | ||
186 | emit decorationSettings()->borderSizeChanged(m_borderSize); | 194 | emit decorationSettings()->borderSizeChanged(m_borderSize); | ||
187 | } | 195 | } | ||
188 | const QFont font = QFontDatabase::systemFont(QFontDatabase::TitleFont); | 196 | const QFont font = QFontDatabase::systemFont(QFontDatabase::TitleFont); | ||
189 | if (font != m_font) { | 197 | if (font != m_font) { | ||
190 | m_font = font; | 198 | m_font = font; | ||
191 | emit decorationSettings()->fontChanged(m_font); | 199 | emit decorationSettings()->fontChanged(m_font); | ||
192 | } | 200 | } | ||
193 | 201 | | |||
194 | emit decorationSettings()->reconfigured(); | 202 | emit decorationSettings()->reconfigured(); | ||
195 | } | 203 | } | ||
196 | 204 | | |||
197 | } | 205 | } | ||
198 | } | 206 | } |
For consistency sake, it has to be a single line comment.