diff --git a/options.cpp b/options.cpp index fffba8515c..043ed40d0a 100644 --- a/options.cpp +++ b/options.cpp @@ -377,6 +377,33 @@ void Options::setOperationTitlebarDblClick(WindowOperation operationTitlebarDblC emit operationTitlebarDblClickChanged(); } +void Options::setOperationMaxButtonLeftClick(WindowOperation op) +{ + if (opMaxButtonLeftClick == op) { + return; + } + opMaxButtonLeftClick = op; + emit operationMaxButtonLeftClickChanged(); +} + +void Options::setOperationMaxButtonRightClick(WindowOperation op) +{ + if (opMaxButtonRightClick == op) { + return; + } + opMaxButtonRightClick = op; + emit operationMaxButtonRightClickChanged(); +} + +void Options::setOperationMaxButtonMiddleClick(WindowOperation op) +{ + if (opMaxButtonMiddleClick == op) { + return; + } + opMaxButtonMiddleClick = op; + emit operationMaxButtonMiddleClickChanged(); +} + void Options::setCommandActiveTitlebar1(MouseCommand commandActiveTitlebar1) { if (CmdActiveTitlebar1 == commandActiveTitlebar1) { @@ -820,9 +847,9 @@ void Options::loadConfig() // Electric borders KConfigGroup config(m_settings->config(), "Windows"); OpTitlebarDblClick = windowOperation(config.readEntry("TitlebarDoubleClickCommand", "Maximize"), true); - setOpMaxButtonLeftClick(windowOperation(config.readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true)); - setOpMaxButtonMiddleClick(windowOperation(config.readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true)); - setOpMaxButtonRightClick(windowOperation(config.readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true)); + setOperationMaxButtonLeftClick(windowOperation(config.readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true)); + setOperationMaxButtonMiddleClick(windowOperation(config.readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true)); + setOperationMaxButtonRightClick(windowOperation(config.readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true)); // Mouse bindings config = KConfigGroup(m_settings->config(), "MouseBindings"); @@ -1129,4 +1156,11 @@ double Options::animationTimeFactor() const return factors[ animationSpeed ]; } +KDecorationDefines::WindowOperation Options::operationMaxButtonClick(Qt::MouseButtons button) const +{ + return button == Qt::RightButton ? opMaxButtonRightClick : + button == Qt::MidButton ? opMaxButtonMiddleClick : + opMaxButtonLeftClick; +} + } // namespace diff --git a/options.h b/options.h index 2c27529862..b6248d10ee 100644 --- a/options.h +++ b/options.h @@ -118,6 +118,9 @@ class Options : public KDecorationOptions */ Q_PROPERTY(bool legacyFullscreenSupport READ isLegacyFullscreenSupport WRITE setLegacyFullscreenSupport NOTIFY legacyFullscreenSupportChanged) Q_PROPERTY(WindowOperation operationTitlebarDblClick READ operationTitlebarDblClick WRITE setOperationTitlebarDblClick NOTIFY operationTitlebarDblClickChanged) + Q_PROPERTY(WindowOperation operationMaxButtonLeftClick READ operationMaxButtonLeftClick WRITE setOperationMaxButtonLeftClick NOTIFY operationMaxButtonLeftClickChanged) + Q_PROPERTY(WindowOperation operationMaxButtonMiddleClick READ operationMaxButtonMiddleClick WRITE setOperationMaxButtonMiddleClick NOTIFY operationMaxButtonMiddleClickChanged) + Q_PROPERTY(WindowOperation operationMaxButtonRightClick READ operationMaxButtonRightClick WRITE setOperationMaxButtonRightClick NOTIFY operationMaxButtonRightClickChanged) Q_PROPERTY(MouseCommand commandActiveTitlebar1 READ commandActiveTitlebar1 WRITE setCommandActiveTitlebar1 NOTIFY commandActiveTitlebar1Changed) Q_PROPERTY(MouseCommand commandActiveTitlebar2 READ commandActiveTitlebar2 WRITE setCommandActiveTitlebar2 NOTIFY commandActiveTitlebar2Changed) Q_PROPERTY(MouseCommand commandActiveTitlebar3 READ commandActiveTitlebar3 WRITE setCommandActiveTitlebar3 NOTIFY commandActiveTitlebar3Changed) @@ -347,6 +350,17 @@ public: WindowOperation operationTitlebarDblClick() const { return OpTitlebarDblClick; } + WindowOperation operationMaxButtonLeftClick() const { + return opMaxButtonLeftClick; + } + WindowOperation operationMaxButtonRightClick() const { + return opMaxButtonRightClick; + } + WindowOperation operationMaxButtonMiddleClick() const { + return opMaxButtonMiddleClick; + } + WindowOperation operationMaxButtonClick(Qt::MouseButtons button) const; + enum MouseCommand { MouseRaise, MouseLower, MouseOperationsMenu, MouseToggleRaiseAndLower, @@ -570,6 +584,9 @@ public: void setFocusStealingPreventionLevel(int focusStealingPreventionLevel); void setLegacyFullscreenSupport(bool legacyFullscreenSupport); void setOperationTitlebarDblClick(WindowOperation operationTitlebarDblClick); + void setOperationMaxButtonLeftClick(WindowOperation op); + void setOperationMaxButtonRightClick(WindowOperation op); + void setOperationMaxButtonMiddleClick(WindowOperation op); void setCommandActiveTitlebar1(MouseCommand commandActiveTitlebar1); void setCommandActiveTitlebar2(MouseCommand commandActiveTitlebar2); void setCommandActiveTitlebar3(MouseCommand commandActiveTitlebar3); @@ -615,6 +632,15 @@ public: static WindowOperation defaultOperationTitlebarDblClick() { return MaximizeOp; } + static WindowOperation defaultOperationMaxButtonLeftClick() { + return MaximizeOp; + } + static WindowOperation defaultOperationMaxButtonRightClick() { + return HMaximizeOp; + } + static WindowOperation defaultOperationMaxButtonMiddleClick() { + return VMaximizeOp; + } static MouseCommand defaultCommandActiveTitlebar1() { return MouseRaise; } @@ -754,6 +780,9 @@ Q_SIGNALS: void focusStealingPreventionLevelChanged(); void legacyFullscreenSupportChanged(); void operationTitlebarDblClickChanged(); + void operationMaxButtonLeftClickChanged(); + void operationMaxButtonRightClickChanged(); + void operationMaxButtonMiddleClickChanged(); void commandActiveTitlebar1Changed(); void commandActiveTitlebar2Changed(); void commandActiveTitlebar3Changed(); @@ -846,6 +875,9 @@ private: OpenGLPlatformInterface m_glPlatformInterface; WindowOperation OpTitlebarDblClick; + WindowOperation opMaxButtonRightClick = defaultOperationMaxButtonRightClick(); + WindowOperation opMaxButtonMiddleClick = defaultOperationMaxButtonMiddleClick(); + WindowOperation opMaxButtonLeftClick = defaultOperationMaxButtonRightClick(); // mouse bindings MouseCommand CmdActiveTitlebar1;