diff --git a/kdecoration/config/oxygenexceptiondialog.h b/kdecoration/config/oxygenexceptiondialog.h index 8c1739ee..1870bacf 100644 --- a/kdecoration/config/oxygenexceptiondialog.h +++ b/kdecoration/config/oxygenexceptiondialog.h @@ -1,108 +1,106 @@ #ifndef oxygenexceptiondialog_h #define oxygenexceptiondialog_h ////////////////////////////////////////////////////////////////////////////// // oxygenexceptiondialog.h // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "ui_oxygenexceptiondialog.h" #include "oxygen.h" #include #include namespace Oxygen { class DetectDialog; //* oxygen exceptions list class ExceptionDialog: public QDialog { Q_OBJECT public: //* constructor explicit ExceptionDialog( QWidget* parent ); //* set exception void setException( InternalSettingsPtr ); //* save exception void save( void ); //* true if changed bool isChanged( void ) const { return m_changed; } Q_SIGNALS: //* emmited when changed void changed( bool ); - protected: - - //* set changed state - void setChanged( bool value ) - { - m_changed = value; - emit changed( value ); - } - private Q_SLOTS: //* check whether configuration is changed and emit appropriate signal if yes void updateChanged(); //* select window properties from grabbed pointers void selectWindowProperties( void ); //* read properties of selected window void readWindowProperties( bool ); private: + //* set changed state + void setChanged( bool value ) + { + m_changed = value; + emit changed( value ); + } + //* map mask and checkbox using CheckBoxMap=QMap< ExceptionMask, QCheckBox*>; Ui::OxygenExceptionDialog m_ui; //* map mask and checkbox CheckBoxMap m_checkboxes; //* internal exception InternalSettingsPtr m_exception; //* detection dialog DetectDialog* m_detectDialog = nullptr; //* changed state bool m_changed = false; }; } #endif diff --git a/kdecoration/oxygenbutton.h b/kdecoration/oxygenbutton.h index b929c78c..4b9407ff 100644 --- a/kdecoration/oxygenbutton.h +++ b/kdecoration/oxygenbutton.h @@ -1,179 +1,177 @@ #ifndef oxygenbutton_h #define oxygenbutton_h /* * Copyright 2006, 2007 Riccardo Iaconelli * Copyright 2006, 2007 Casper Boemann * Copyright 2009 Hugo Pereira Da Costa * Copyright 2015 David Edmundson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "oxygenanimation.h" #include "oxygen.h" #include "oxygendecohelper.h" #include "oxygendecoration.h" #include namespace Oxygen { class Button : public KDecoration2::DecorationButton { Q_OBJECT //* declare active state opacity Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity ) public: //* constructor explicit Button(QObject *parent, const QVariantList &args); //* button creation static Button *create(KDecoration2::DecorationButtonType type, KDecoration2::Decoration *decoration, QObject *parent); //* render void paint(QPainter *painter, const QRect &repaintRegion) override; //* flag enum Flag { FlagNone, FlagStandalone, FlagFirstInList, FlagLastInList }; //* flag void setFlag( Flag value ) { m_flag = value; } //* standalone buttons bool isStandAlone() const { return m_flag == FlagStandalone; } //* offset void setOffset( const QPointF& value ) { m_offset = value; } //* horizontal offset, for rendering void setHorizontalOffset( qreal value ) { m_offset.setX( value ); } //* vertical offset, for rendering void setVerticalOffset( qreal value ) { m_offset.setY( value ); } //* set icon size void setIconSize( const QSize& value ) { m_iconSize = value; } //*@name active state change animation //@{ void setOpacity( qreal value ) { if( m_opacity == value ) return; m_opacity = value; update(); } qreal opacity( void ) const { return m_opacity; } //@} - protected: + private Q_SLOTS: + + //* apply configuration changes + void reconfigure(); + + //* animation state + void updateAnimationState(bool); + + private: //* draw icon void drawIcon( QPainter* ); //*@name colors //@{ QColor foregroundColor( const QPalette& ) const; QColor foregroundColor( const QPalette& palette, bool active ) const; QColor backgroundColor( const QPalette& ) const; QColor backgroundColor( const QPalette& palette, bool active ) const; //@} //* true if animation is in progress bool isAnimated( void ) const { return m_animation->state() == QPropertyAnimation::Running; } //* true if button is active bool isActive( void ) const; //*@name button properties //@{ //* true if button if of menu type bool isMenuButton( void ) const { return type() == KDecoration2::DecorationButtonType::Menu || type() == KDecoration2::DecorationButtonType::ApplicationMenu; } //* true if button is of toggle type bool isToggleButton( void ) const { return type() == KDecoration2::DecorationButtonType::OnAllDesktops || type() == KDecoration2::DecorationButtonType::KeepAbove || type() == KDecoration2::DecorationButtonType::KeepBelow; } //* true if button if of close type bool isCloseButton( void ) const { return type() == KDecoration2::DecorationButtonType::Close; } //* true if button has decoration bool hasDecoration( void ) const { return !isMenuButton();} //@} - private Q_SLOTS: - - //* apply configuration changes - void reconfigure(); - - //* animation state - void updateAnimationState(bool); - - private: - //* private constructor explicit Button(KDecoration2::DecorationButtonType type, Decoration *decoration, QObject *parent); Flag m_flag = FlagNone; //* glow animation QPropertyAnimation* m_animation; //* vertical offset (for rendering) QPointF m_offset; //* icon size QSize m_iconSize; //* glow intensity qreal m_opacity; }; } //namespace #endif diff --git a/kdecoration/oxygenexceptionlist.h b/kdecoration/oxygenexceptionlist.h index e6d61acd..71faf5ae 100644 --- a/kdecoration/oxygenexceptionlist.h +++ b/kdecoration/oxygenexceptionlist.h @@ -1,79 +1,77 @@ #ifndef oxygenexceptionlist_h #define oxygenexceptionlist_h ////////////////////////////////////////////////////////////////////////////// // oxygenexceptionlist.h // window decoration exceptions // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygensettings.h" #include "oxygen.h" #include namespace Oxygen { //* oxygen exceptions list class ExceptionList { public: //* constructor from list explicit ExceptionList( const InternalSettingsList& exceptions = InternalSettingsList() ): _exceptions( exceptions ) {} //* exceptions const InternalSettingsList& get( void ) const { return _exceptions; } //* read from KConfig void readConfig( KSharedConfig::Ptr ); //* write to kconfig void writeConfig( KSharedConfig::Ptr ); - protected: + private: //* generate exception group name for given exception index static QString exceptionGroupName( int index ); //* read configuration static void readConfig( KCoreConfigSkeleton*, KConfig*, const QString& ); //* write configuration static void writeConfig( KCoreConfigSkeleton*, KConfig*, const QString& ); - private: - //* exceptions InternalSettingsList _exceptions; }; } #endif diff --git a/kstyle/animations/oxygenanimations.h b/kstyle/animations/oxygenanimations.h index e1a65ae7..439bc4b4 100644 --- a/kstyle/animations/oxygenanimations.h +++ b/kstyle/animations/oxygenanimations.h @@ -1,214 +1,214 @@ #ifndef oxygenanimations_h #define oxygenanimations_h ////////////////////////////////////////////////////////////////////////////// // oxygenanimations.h // container for all animation engines // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenbusyindicatorengine.h" #include "oxygendockseparatorengine.h" #include "oxygenheaderviewengine.h" #include "oxygenmdiwindowengine.h" #include "oxygenmenubarengine.h" #include "oxygenmenuengine.h" #include "oxygenprogressbarengine.h" #include "oxygenscrollbarengine.h" #include "oxygenspinboxengine.h" #include "oxygensplitterengine.h" #include "oxygentabbarengine.h" #include "oxygentoolbarengine.h" #include "oxygentoolboxengine.h" #include "oxygenwidgetstateengine.h" #include #include namespace Oxygen { //* stores engines class Animations: public QObject { Q_OBJECT public: //* constructor explicit Animations( QObject* ); //* register animations corresponding to given widget, depending on its type. void registerWidget( QWidget* widget ) const; - /*! unregister all animations associated to a widget */ + /** unregister all animations associated to a widget */ void unregisterWidget( QWidget* widget ) const; //* enable state engine WidgetStateEngine& widgetEnableStateEngine( void ) const { return *_widgetEnableStateEngine; } //* abstractButton engine WidgetStateEngine& widgetStateEngine( void ) const { return *_widgetStateEngine; } //* editable combobox arrow hover engine WidgetStateEngine& comboBoxEngine( void ) const { return *_comboBoxEngine; } //* Tool buttons arrow hover engine WidgetStateEngine& toolButtonEngine( void ) const { return *_toolButtonEngine; } //* item view engine WidgetStateEngine& inputWidgetEngine( void ) const { return *_inputWidgetEngine; } //* splitter engine SplitterEngine& splitterEngine( void ) const { return *_splitterEngine; } //* busy indicator BusyIndicatorEngine& busyIndicatorEngine( void ) const { return *_busyIndicatorEngine; } //* dock separators engine DockSeparatorEngine& dockSeparatorEngine( void ) const { return *_dockSeparatorEngine; } //* header view engine HeaderViewEngine& headerViewEngine( void ) const { return *_headerViewEngine; } //* progressbar engine ProgressBarEngine& progressBarEngine( void ) const { return *_progressBarEngine; } //* menubar engine MenuBarBaseEngine& menuBarEngine( void ) const { return *_menuBarEngine; } //* menu engine MenuBaseEngine& menuEngine( void ) const { return *_menuEngine; } //* scrollbar engine ScrollBarEngine& scrollBarEngine( void ) const { return *_scrollBarEngine; } //* spinbox engine SpinBoxEngine& spinBoxEngine( void ) const { return *_spinBoxEngine; } //* tabbar TabBarEngine& tabBarEngine( void ) const { return *_tabBarEngine; } //* toolbar ToolBarEngine& toolBarEngine( void ) const { return *_toolBarEngine; } //* toolbox ToolBoxEngine& toolBoxEngine( void ) const { return *_toolBoxEngine; } //* mdi windows MdiWindowEngine& mdiWindowEngine( void ) const { return *_mdiWindowEngine; } //* setup engines void setupEngines( void ); - protected Q_SLOTS: + private Q_SLOTS: //* enregister engine void unregisterEngine( QObject* ); private: //* register new engine void registerEngine( BaseEngine* engine ); //* busy indicator - BusyIndicatorEngine* _busyIndicatorEngine; + BusyIndicatorEngine* _busyIndicatorEngine = nullptr; //* dock separator handle hover effect - DockSeparatorEngine* _dockSeparatorEngine; + DockSeparatorEngine* _dockSeparatorEngine = nullptr; //* headerview hover effect - HeaderViewEngine* _headerViewEngine; + HeaderViewEngine* _headerViewEngine = nullptr; //* widget enable state engine - WidgetStateEngine* _widgetEnableStateEngine; + WidgetStateEngine* _widgetEnableStateEngine = nullptr; //* abstract button engine - WidgetStateEngine* _widgetStateEngine; + WidgetStateEngine* _widgetStateEngine = nullptr; //* editable combobox arrow hover effect - WidgetStateEngine* _comboBoxEngine; + WidgetStateEngine* _comboBoxEngine = nullptr; //* mennu toolbutton arrow hover effect - WidgetStateEngine* _toolButtonEngine; + WidgetStateEngine* _toolButtonEngine = nullptr; //* item view engine - WidgetStateEngine* _inputWidgetEngine; + WidgetStateEngine* _inputWidgetEngine = nullptr; //* QSplitter engine - SplitterEngine* _splitterEngine; + SplitterEngine* _splitterEngine = nullptr; //* progressbar engine - ProgressBarEngine* _progressBarEngine; + ProgressBarEngine* _progressBarEngine = nullptr; //* menubar engine - MenuBarBaseEngine* _menuBarEngine; + MenuBarBaseEngine* _menuBarEngine = nullptr; //* menu engine - MenuBaseEngine* _menuEngine; + MenuBaseEngine* _menuEngine = nullptr; //* scrollbar engine - ScrollBarEngine* _scrollBarEngine; + ScrollBarEngine* _scrollBarEngine = nullptr; //* spinbox engine - SpinBoxEngine* _spinBoxEngine; + SpinBoxEngine* _spinBoxEngine = nullptr; //* tabbar engine - TabBarEngine* _tabBarEngine; + TabBarEngine* _tabBarEngine = nullptr; //* toolbar engine - ToolBarEngine* _toolBarEngine; + ToolBarEngine* _toolBarEngine = nullptr; //* toolbar engine - ToolBoxEngine* _toolBoxEngine; + ToolBoxEngine* _toolBoxEngine = nullptr; //* mdi window - MdiWindowEngine* _mdiWindowEngine; + MdiWindowEngine* _mdiWindowEngine = nullptr; //* keep list of existing engines QList< BaseEngine::Pointer > _engines; }; } #endif diff --git a/kstyle/animations/oxygenmenubarengine.h b/kstyle/animations/oxygenmenubarengine.h index 33d542a9..dbf22e64 100644 --- a/kstyle/animations/oxygenmenubarengine.h +++ b/kstyle/animations/oxygenmenubarengine.h @@ -1,227 +1,227 @@ #ifndef oxygenmenubarengine_h #define oxygenmenubarengine_h ////////////////////////////////////////////////////////////////////////////// // oxygenmenubarengine.h // stores event filters and maps widgets to timelines for animations // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenbaseengine.h" #include "oxygendatamap.h" #include "oxygenmenubardata.h" namespace Oxygen { //* stores menubar hovered action and timeLine class MenuBarBaseEngine: public BaseEngine { Q_OBJECT public: //* constructor explicit MenuBarBaseEngine( QObject* parent ): BaseEngine( parent ) {} //* register menubar virtual bool registerWidget( QWidget* ) = 0; //* true if widget is animated virtual bool isAnimated( const QObject*, const QPoint& ) { return false; } //* animation opacity virtual qreal opacity( const QObject*, const QPoint& ) { return -1; } //* return 'hover' rect position when widget is animated virtual QRect currentRect( const QObject*, const QPoint& ) { return QRect(); } //* animated rect virtual QRect animatedRect( const QObject* ) { return QRect(); } //* timer virtual bool isTimerActive( const QObject* ) { return false; } //* enable state void setEnabled( bool ) override = 0; //* duration void setDuration( int ) override = 0; //* duration virtual void setFollowMouseDuration( int ) {} }; //* fading menubar animation class MenuBarEngineV1: public MenuBarBaseEngine { Q_OBJECT public: //* constructor explicit MenuBarEngineV1( QObject* parent ): MenuBarBaseEngine( parent ) {} //* constructor MenuBarEngineV1( QObject* parent, MenuBarBaseEngine* other ); //* register menubar bool registerWidget( QWidget* ) override; //* true if widget is animated bool isAnimated( const QObject* object, const QPoint& point ) override; //* animation opacity qreal opacity( const QObject* object, const QPoint& point ) override { return isAnimated( object, point ) ? _data.find( object ).data()->opacity( point ): AnimationData::OpacityInvalid; } //* return 'hover' rect position when widget is animated QRect currentRect( const QObject* object, const QPoint& point) override { return isAnimated( object, point ) ? _data.find( object ).data()->currentRect( point ): QRect(); } //* enable state void setEnabled( bool value ) override { BaseEngine::setEnabled( value ); _data.setEnabled( value ); } //* duration void setDuration( int duration ) override { BaseEngine::setDuration( duration ); _data.setDuration( duration ); } //* return list of registered widgets WidgetList registeredWidgets( void ) const override; protected Q_SLOTS: //* remove widget from map bool unregisterWidget( QObject* object ) override { return _data.unregisterWidget( object ); } private: //* data map DataMap _data; }; - //* follow-mouse menubar animation + //* follow-mouse menubar animation class MenuBarEngineV2: public MenuBarBaseEngine { Q_OBJECT public: //* constructor explicit MenuBarEngineV2( QObject* parent ): MenuBarBaseEngine( parent ) {} //* constructor MenuBarEngineV2( QObject* parent, MenuBarBaseEngine* other ); //* register menubar bool registerWidget( QWidget* ) override; //* true if widget is animated bool isAnimated( const QObject* object, const QPoint& point ) override; //* animation opacity qreal opacity( const QObject* object, const QPoint& point ) override { return isAnimated( object, point ) ? _data.find( object ).data()->opacity(): AnimationData::OpacityInvalid; } //* return 'hover' rect position when widget is animated QRect currentRect( const QObject*, const QPoint& ) override; //* return 'hover' rect position when widget is animated QRect animatedRect( const QObject* ) override; //* timer associated to the data bool isTimerActive( const QObject* ) override; //* enable state void setEnabled( bool value ) override { BaseEngine::setEnabled( value ); _data.setEnabled( value ); } //* duration void setDuration( int value ) override { BaseEngine::setDuration( value ); _data.setDuration( value ); } //* duration int followMouseDuration( void ) const { return _followMouseDuration; } //* duration void setFollowMouseDuration( int duration ) override { _followMouseDuration = duration; foreach( const DataMap::Value& value, _data ) { if( value ) value.data()->setFollowMouseDuration( duration ); } } //* return list of registered widgets WidgetList registeredWidgets( void ) const override; protected Q_SLOTS: //* remove widget from map bool unregisterWidget( QObject* object ) override { return _data.unregisterWidget( object ); } private: //* follow mouse animation duration int _followMouseDuration; //* data map DataMap _data; }; } #endif diff --git a/kstyle/animations/oxygenprogressbarengine.h b/kstyle/animations/oxygenprogressbarengine.h index ad662aa6..f1144f45 100644 --- a/kstyle/animations/oxygenprogressbarengine.h +++ b/kstyle/animations/oxygenprogressbarengine.h @@ -1,96 +1,94 @@ #ifndef oxygenprogressbarengine_h #define oxygenprogressbarengine_h ////////////////////////////////////////////////////////////////////////////// // oxygenprogressbarengine.h // handle progress bar animations // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenbaseengine.h" #include "oxygenprogressbardata.h" #include "oxygendatamap.h" #include namespace Oxygen { //* handles progress bar animations class ProgressBarEngine: public BaseEngine { Q_OBJECT public: //* constructor explicit ProgressBarEngine( QObject* object ): BaseEngine( object ) {} //* register progressbar bool registerWidget( QWidget* ); //* true if widget is animated bool isAnimated( const QObject* ); //* animation opacity int value( const QObject* object ) { return isAnimated( object ) ? data( object ).data()->value():0 ; } //* enable state void setEnabled( bool value ) override { BaseEngine::setEnabled( value ); _data.setEnabled( value ); } //* duration void setDuration( int value ) override { BaseEngine::setDuration( value ); _data.setDuration( value ); } public Q_SLOTS: //* remove widget from map bool unregisterWidget( QObject* object ) override { return _data.unregisterWidget( object ); } - protected: + private: //* returns data associated to widget DataMap::Value data( const QObject* ); - private: - //* map widgets to progressbar data DataMap _data; }; } #endif diff --git a/kstyle/animations/oxygenscrollbardata.h b/kstyle/animations/oxygenscrollbardata.h index 10a77cef..79411841 100644 --- a/kstyle/animations/oxygenscrollbardata.h +++ b/kstyle/animations/oxygenscrollbardata.h @@ -1,238 +1,238 @@ #ifndef oxygenscrollbar_data_h #define oxygenscrollbar_data_h ////////////////////////////////////////////////////////////////////////////// // oxygenscrollbardata.h // data container for QScrollBar animations // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenwidgetstatedata.h" #include namespace Oxygen { //* scrollbar data class ScrollBarData: public WidgetStateData { Q_OBJECT Q_PROPERTY( qreal addLineOpacity READ addLineOpacity WRITE setAddLineOpacity ) Q_PROPERTY( qreal subLineOpacity READ subLineOpacity WRITE setSubLineOpacity ) public: //* constructor ScrollBarData( QObject* parent, QWidget* target, int ); //* event filter bool eventFilter( QObject*, QEvent* ) override; using WidgetStateData::animation; using WidgetStateData::opacity; //* return animation for a given subcontrol const Animation::Pointer& animation( QStyle::SubControl ) const; //* return default opacity for a given subcontrol qreal opacity( QStyle::SubControl ) const; //* return default opacity for a given subcontrol bool isHovered( QStyle::SubControl control ) const { switch( control ) { case QStyle::SC_ScrollBarAddLine: return addLineArrowHovered(); case QStyle::SC_ScrollBarSubLine: return subLineArrowHovered(); default: return false; } } //* subControlRect QRect subControlRect( QStyle::SubControl control ) const { switch( control ) { case QStyle::SC_ScrollBarAddLine: return _addLineData._rect; case QStyle::SC_ScrollBarSubLine: return _subLineData._rect; default: return QRect(); } } //* subcontrol rect void setSubControlRect( QStyle::SubControl control, const QRect& rect ) { switch( control ) { case QStyle::SC_ScrollBarAddLine: _addLineData._rect = rect; break; case QStyle::SC_ScrollBarSubLine: _subLineData._rect = rect; break; default: break; } } //* duration void setDuration( int duration ) override { WidgetStateData::setDuration( duration ); addLineAnimation().data()->setDuration( duration ); subLineAnimation().data()->setDuration( duration ); } //* addLine opacity void setAddLineOpacity( qreal value ) { value = digitize( value ); if( _addLineData._opacity == value ) return; _addLineData._opacity = value; setDirty(); } //* addLine opacity qreal addLineOpacity( void ) const { return _addLineData._opacity; } //* subLine opacity void setSubLineOpacity( qreal value ) { value = digitize( value ); if( _subLineData._opacity == value ) return; _subLineData._opacity = value; setDirty(); } //* subLine opacity qreal subLineOpacity( void ) const { return _subLineData._opacity; } //* mouse position QPoint position( void ) const { return _position; } - protected Q_SLOTS: + private Q_SLOTS: //* clear addLineRect void clearAddLineRect( void ) { if( addLineAnimation().data()->direction() == Animation::Backward ) { _addLineData._rect = QRect(); } } //* clear subLineRect void clearSubLineRect( void ) { if( subLineAnimation().data()->direction() == Animation::Backward ) { _subLineData._rect = QRect(); } } private: //* hoverMoveEvent void hoverMoveEvent( QObject*, QEvent* ); //* hoverMoveEvent void hoverLeaveEvent( QObject*, QEvent* ); //*@name hover flags //@{ bool addLineArrowHovered( void ) const { return _addLineData._hovered; } void setAddLineArrowHovered( bool value ) { _addLineData._hovered = value; } bool subLineArrowHovered( void ) const { return _subLineData._hovered; } void setSubLineArrowHovered( bool value ) { _subLineData._hovered = value; } //@} //* update add line arrow void updateAddLineArrow( QStyle::SubControl ); //* update sub line arrow void updateSubLineArrow( QStyle::SubControl ); //*@name timelines //@{ const Animation::Pointer& addLineAnimation( void ) const { return _addLineData._animation; } const Animation::Pointer& subLineAnimation( void ) const { return _subLineData._animation; } //* stores arrow data class Data { public: //* constructor Data( void ): _hovered( false ), _opacity( AnimationData::OpacityInvalid ) {} //* true if hovered bool _hovered; //* animation Animation::Pointer _animation; //* opacity qreal _opacity; //* rect QRect _rect; }; //* add line data (down arrow) Data _addLineData; //* subtract line data (up arrow) Data _subLineData; //* mouse position QPoint _position; }; } #endif diff --git a/kstyle/animations/oxygentoolbardata.h b/kstyle/animations/oxygentoolbardata.h index ab8ef94b..ff26d194 100644 --- a/kstyle/animations/oxygentoolbardata.h +++ b/kstyle/animations/oxygentoolbardata.h @@ -1,217 +1,217 @@ #ifndef oxygentoolbar_data_h #define oxygentoolbar_data_h ////////////////////////////////////////////////////////////////////////////// // oxygentoolbardata.h // stores event filters and maps widgets to timelines for animations // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenanimationdata.h" #include namespace Oxygen { //* toolbar data class ToolBarData: public AnimationData { Q_OBJECT Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity ) Q_PROPERTY( qreal progress READ progress WRITE setProgress ) public: //* constructor ToolBarData( QObject* parent, QWidget* target, int duration ); //* event filter bool eventFilter( QObject*, QEvent* ) override; //* return animation associated to action at given position, if any const Animation::Pointer& animation( void ) const { return _animation; } //* return animation associated to action at given position, if any const Animation::Pointer& progressAnimation( void ) const { return _progressAnimation; } //* duration void setDuration( int duration ) override { animation().data()->setDuration( duration ); } //* duration void setFollowMouseDuration( int duration ) { progressAnimation().data()->setDuration( duration ); } //* return 'hover' rect position when widget is animated const QRect& animatedRect( void ) const { return _animatedRect; } //* current rect const QRect& currentRect( void ) const { return _currentRect; } //* timer const QBasicTimer& timer( void ) const { return _timer; } //* animation opacity qreal opacity( void ) const { return _opacity; } //* animation opacity void setOpacity( qreal value ) { value = digitize( value ); if( _opacity == value ) return; _opacity = value; setDirty(); } //* animation progress qreal progress( void ) const { return _progress; } //* animation progress void setProgress( qreal value ) { value = digitize( value ); if( _progress == value ) return; _progress = value; updateAnimatedRect(); } - protected Q_SLOTS: - - //* updated animated rect - void updateAnimatedRect( void ); - protected: //* timer event void timerEvent( QTimerEvent *) override; + private Q_SLOTS: + + //* updated animated rect + void updateAnimatedRect( void ); + private: //*@name current object handling //@{ //* object pointer - /*! there is no need to guard it because the object contents is never accessed */ + /** there is no need to guard it because the object contents is never accessed */ using ObjectPointer = const QObject*; //* current object const ObjectPointer& currentObject( void ) const { return _currentObject; } //* current object void setCurrentObject( const QObject* object ) { _currentObject = ObjectPointer( object ); } //* current object void clearCurrentObject( void ) { _currentObject = NULL; } //@} //*@name rect handling //@{ //* current rect void setCurrentRect( const QRect& rect ) { _currentRect = rect; } //* current rect void clearCurrentRect( void ) { _currentRect = QRect(); } //* previous rect const QRect& previousRect( void ) const { return _previousRect; } //* previous rect void setPreviousRect( const QRect& rect ) { _previousRect = rect; } //* previous rect void clearPreviousRect( void ) { _previousRect = QRect(); } //* animated rect void clearAnimatedRect( void ) { _animatedRect = QRect(); } //@} //* toolbar enterEvent void enterEvent( const QObject* ); //* toolbar enterEvent void leaveEvent( const QObject* ); //* toolbutton added void childAddedEvent( QObject* ); //* toolbutton enter event void childEnterEvent( const QObject* ); private: //* fade animation Animation::Pointer _animation; //* progress animation Animation::Pointer _progressAnimation; //* opacity - qreal _opacity; + qreal _opacity = 0; //* opacity - qreal _progress; + qreal _progress = 0; //* timer - /*! this allows to add some delay before starting leaveEvent animation */ + /** this allows to add some delay before starting leaveEvent animation */ QBasicTimer _timer; //* current object ObjectPointer _currentObject; //* current rect QRect _currentRect; //* previous rect QRect _previousRect; //* animated rect QRect _animatedRect; //* true if toolbar was entered at least once (this prevents some initialization glitches) - bool _entered; + bool _entered = false; }; } #endif diff --git a/kstyle/animations/oxygentoolboxengine.h b/kstyle/animations/oxygentoolboxengine.h index 42dd79a1..3702c5a3 100644 --- a/kstyle/animations/oxygentoolboxengine.h +++ b/kstyle/animations/oxygentoolboxengine.h @@ -1,106 +1,106 @@ #ifndef oxygentoolboxengine_h #define oxygentoolboxengine_h ////////////////////////////////////////////////////////////////////////////// // oxygentoolboxengine.h // QToolBox engine // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenbaseengine.h" #include "oxygendatamap.h" #include "oxygenwidgetstatedata.h" namespace Oxygen { //* QToolBox animation engine class ToolBoxEngine: public BaseEngine { Q_OBJECT public: //* constructor explicit ToolBoxEngine( QObject* parent ): BaseEngine( parent ) {} //* enability void setEnabled( bool value ) override { BaseEngine::setEnabled( value ); _data.setEnabled( value ); } //* duration void setDuration( int value ) override { BaseEngine::setDuration( value ); _data.setDuration( value ); } //* register widget bool registerWidget( QWidget* ); //* true if widget hover state is changed bool updateState( const QPaintDevice*, bool ); //* true if widget is animated bool isAnimated( const QPaintDevice* ); //* animation opacity qreal opacity( const QPaintDevice* object ) { return isAnimated( object ) ? data( object ).data()->opacity(): AnimationData::OpacityInvalid; } public Q_SLOTS: //* remove widget from map bool unregisterWidget( QObject* data ) override { if( !data ) return false; // reinterpret_cast is safe here since only the address is used to find // data in the map return _data.unregisterWidget( reinterpret_cast(data) ); } - protected: + private: //* returns data associated to widget PaintDeviceDataMap::Value data( const QPaintDevice* object ) { return _data.find( object ).data(); } private: //* map PaintDeviceDataMap _data; }; } #endif diff --git a/kstyle/config/oxygenanimationconfigwidget.h b/kstyle/config/oxygenanimationconfigwidget.h index 44367149..e2827f2f 100644 --- a/kstyle/config/oxygenanimationconfigwidget.h +++ b/kstyle/config/oxygenanimationconfigwidget.h @@ -1,77 +1,77 @@ #ifndef oxygenanimationconfigwidget_h #define oxygenanimationconfigwidget_h ////////////////////////////////////////////////////////////////////////////// // oxygenanimationconfigwidget.h // animation configuration item // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenbaseanimationconfigwidget.h" namespace Oxygen { class GenericAnimationConfigItem; class FollowMouseAnimationConfigItem; class AnimationConfigWidget: public BaseAnimationConfigWidget { Q_OBJECT public: //* constructor explicit AnimationConfigWidget( QWidget* = 0 ); public Q_SLOTS: //* read current configuration void load( void ) override; //* save current configuration void save( void ) override; protected Q_SLOTS: //* check whether configuration is changed and emit appropriate signal if yes void updateChanged() override; private: - GenericAnimationConfigItem* _genericAnimations; - GenericAnimationConfigItem* _progressBarAnimations; - GenericAnimationConfigItem* _progressBarBusyAnimations; - GenericAnimationConfigItem* _stackedWidgetAnimations; - GenericAnimationConfigItem* _labelAnimations; - GenericAnimationConfigItem* _lineEditAnimations; - GenericAnimationConfigItem* _comboBoxAnimations; - FollowMouseAnimationConfigItem* _toolBarAnimations; - FollowMouseAnimationConfigItem* _menuBarAnimations; - FollowMouseAnimationConfigItem* _menuAnimations; + GenericAnimationConfigItem* _genericAnimations = nullptr; + GenericAnimationConfigItem* _progressBarAnimations = nullptr; + GenericAnimationConfigItem* _progressBarBusyAnimations = nullptr; + GenericAnimationConfigItem* _stackedWidgetAnimations = nullptr; + GenericAnimationConfigItem* _labelAnimations = nullptr; + GenericAnimationConfigItem* _lineEditAnimations = nullptr; + GenericAnimationConfigItem* _comboBoxAnimations = nullptr; + FollowMouseAnimationConfigItem* _toolBarAnimations = nullptr; + FollowMouseAnimationConfigItem* _menuBarAnimations = nullptr; + FollowMouseAnimationConfigItem* _menuAnimations = nullptr; }; } #endif diff --git a/kstyle/config/oxygenstyleconfig.h b/kstyle/config/oxygenstyleconfig.h index aa3de1b3..50074837 100644 --- a/kstyle/config/oxygenstyleconfig.h +++ b/kstyle/config/oxygenstyleconfig.h @@ -1,89 +1,89 @@ #ifndef oxygenstyleconfig_h #define oxygenstyleconfig_h /* Copyright (c) 2010 Hugo Pereira Da Costa Copyright (C) 2003 Sandro Giessl based on the Keramik configuration dialog: Copyright (c) 2003 Maksim Orlovich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "ui_oxygenstyleconfig.h" namespace Oxygen { class StyleConfig: public QWidget, Ui::OxygenStyleConfig { Q_OBJECT public: //* constructor explicit StyleConfig(QWidget*); Q_SIGNALS: //* emmited whenever one option is changed. void changed(bool); public Q_SLOTS: //* load setup from config data void load( void ); //* save current state void save( void ); //* restore all default values void defaults( void ); //Everything below this is internal. //* reset to saved configuration void reset( void ); - protected Q_SLOTS: - - //* update layout - /** needed in expert mode to accommodate with animations config widget size changes */ - void updateLayout( void ); - //* update modified state when option is checked/unchecked void updateChanged( void ); protected: //* event processing bool event( QEvent* ) override; // menu mode from ui int menuMode( void ) const; // expander size from ui int triangularExpanderSize( void ) const; + private Q_SLOTS: + + //* update layout + /** needed in expert mode to accommodate with animations config widget size changes */ + void updateLayout( void ); + }; } #endif diff --git a/kstyle/debug/oxygenwidgetexplorer.h b/kstyle/debug/oxygenwidgetexplorer.h index 857d8a2e..28bb34b3 100644 --- a/kstyle/debug/oxygenwidgetexplorer.h +++ b/kstyle/debug/oxygenwidgetexplorer.h @@ -1,86 +1,84 @@ #ifndef oxygenwidgetexplorer_h #define oxygenwidgetexplorer_h ////////////////////////////////////////////////////////////////////////////// // oxygenwidgetexplorer.h // print widget's and parent's information on mouse click // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include namespace Oxygen { //* print widget's and parent's information on mouse click class WidgetExplorer: public QObject { Q_OBJECT public: //* constructor explicit WidgetExplorer( QObject* ); //* enable bool enabled( void ) const; //* enable void setEnabled( bool ); //* widget rects void setDrawWidgetRects( bool value ) { _drawWidgetRects = value; } //* event filter bool eventFilter( QObject*, QEvent* ) override; - protected: + private: //* event type QString eventType( const QEvent::Type& ) const; //* print widget information QString widgetInformation( const QWidget* ) const; - private: - //* enable state bool _enabled = false; //* widget rects bool _drawWidgetRects = false; //* map event types to string QMap _eventTypes; }; } #endif diff --git a/kstyle/demo/oxygenbuttondemowidget.h b/kstyle/demo/oxygenbuttondemowidget.h index e9416857..30b18851 100644 --- a/kstyle/demo/oxygenbuttondemowidget.h +++ b/kstyle/demo/oxygenbuttondemowidget.h @@ -1,80 +1,78 @@ #ifndef oxygenbuttondemowidget_h #define oxygenbuttondemowidget_h ////////////////////////////////////////////////////////////////////////////// // oxygenbuttondemowidget.h // oxygen buttons demo widget // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygendemowidget.h" #include "ui_oxygenbuttondemowidget.h" #include #include #include #include namespace Oxygen { class ButtonDemoWidget: public DemoWidget { Q_OBJECT public: //* constructor explicit ButtonDemoWidget( QWidget* = nullptr ); public Q_SLOTS: void benchmark( void ); - protected Q_SLOTS: + private Q_SLOTS: //* change text position in tool buttons void textPosition( int ); //* change tool button icon size void iconSize( int ); //* set buttons as flat void toggleFlat( bool ); - protected: + private: void installMenu( QPushButton* ); void installMenu( QToolButton* ); - private: - Ui_ButtonDemoWidget ui; QToolBar* _toolBar = nullptr; QList _pushButtons; QList _toolButtons; }; } #endif diff --git a/kstyle/demo/oxygenframedemowidget.h b/kstyle/demo/oxygenframedemowidget.h index 9d7fa5ee..1c977b68 100644 --- a/kstyle/demo/oxygenframedemowidget.h +++ b/kstyle/demo/oxygenframedemowidget.h @@ -1,81 +1,81 @@ #ifndef oxygenframedemowidget_h #define oxygenframedemowidget_h ////////////////////////////////////////////////////////////////////////////// // oxygenframedemowidget.h // oxygen frames demo widget // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include #include #include #include "oxygendemowidget.h" #include "ui_oxygenframedemowidget.h" namespace Oxygen { class FrameDemoWidget: public DemoWidget { Q_OBJECT public: //* constructor explicit FrameDemoWidget( QWidget* = 0 ); public Q_SLOTS: //* benchmarking void benchmark( void ); - protected Q_SLOTS: + private Q_SLOTS: //* groupbox void toggleFlatGroupBox( bool value ) { ui.groupBox->setFlat( value ); } //* frame style void toggleRaisedFrame( bool value ) { if( value ) ui.frame->setFrameStyle( QFrame::StyledPanel|QFrame::Raised ); } void togglePlainFrame( bool value ) { if( value ) ui.frame->setFrameStyle( QFrame::StyledPanel|QFrame::Plain ); } void toggleSunkenFrame( bool value ) { if( value ) ui.frame->setFrameStyle( QFrame::StyledPanel|QFrame::Sunken ); } //* layout direction void updateLayoutDirection( int ); private: Ui_FrameDemoWidget ui; }; } #endif diff --git a/kstyle/demo/oxygensliderdemowidget.h b/kstyle/demo/oxygensliderdemowidget.h index 187e89f8..1e10c333 100644 --- a/kstyle/demo/oxygensliderdemowidget.h +++ b/kstyle/demo/oxygensliderdemowidget.h @@ -1,111 +1,111 @@ #ifndef oxygensliderdemowidget_h #define oxygensliderdemowidget_h ////////////////////////////////////////////////////////////////////////////// // oxygensliderdemowidget.h // oxygen sliders demo widget // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include #include #include #include "oxygendemowidget.h" #include "ui_oxygensliderdemowidget.h" namespace Oxygen { class ProgressBar: public QObject { Q_OBJECT public: //* constructor ProgressBar( QObject*, QProgressBar*, QCheckBox* ); //* set value void setValue( int ); public Q_SLOTS: //* toggle invertex appearance void toggleInvertedAppearance( bool value ) { _progressBar->setInvertedAppearance( value ); } - protected Q_SLOTS: + private Q_SLOTS: //* toggle bussy state void toggleBusy( bool ); private: //* progressBar QProgressBar* _progressBar; //* checkbox QCheckBox* _checkBox; //* saved value int _value; }; class SliderDemoWidget: public DemoWidget { Q_OBJECT public: //* constructor explicit SliderDemoWidget( QWidget* = nullptr ); public Q_SLOTS: //* benchmark void benchmark( void ); private Q_SLOTS: void updateSliders( int ); void updateTickPosition( int ); private: bool _locked = false; Ui_SliderDemoWidget ui; //* progressbars ProgressBar* _horizontalProgressBar; ProgressBar* _verticalProgressBar; }; } #endif diff --git a/kstyle/demo/oxygentabdemowidget.h b/kstyle/demo/oxygentabdemowidget.h index bfea2811..a3a78c70 100644 --- a/kstyle/demo/oxygentabdemowidget.h +++ b/kstyle/demo/oxygentabdemowidget.h @@ -1,86 +1,86 @@ #ifndef oxygentabdemowidget_h #define oxygentabdemowidget_h ////////////////////////////////////////////////////////////////////////////// // oxygentabdemowidget.h // oxygen tabwidget demo widget // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include #include #include "ui_oxygentabdemowidget.h" #include "oxygendemowidget.h" namespace Oxygen { class TabDemoWidget: public DemoWidget { Q_OBJECT public: //* constructor explicit TabDemoWidget( QWidget* = nullptr ); public Q_SLOTS: //* benchmark void benchmark( void ); - protected Q_SLOTS: + private Q_SLOTS: //* show/hide corner buttons void toggleCornerWidgets( bool ); //* change document mode void toggleDocumentMode( bool ); //* show tab close buttons void toggleTabCloseButtons( bool ); // change tab position void changeTabPosition( int ); // change tab position void changeTextPosition( int ); private: //* ui Ui_TabDemoWidget ui; //* tabbar left button QToolButton* _left = nullptr; //* tabbar right button QToolButton* _right = nullptr; }; } #endif diff --git a/kstyle/oxygenblurhelper.h b/kstyle/oxygenblurhelper.h index 8553c581..d768999a 100644 --- a/kstyle/oxygenblurhelper.h +++ b/kstyle/oxygenblurhelper.h @@ -1,168 +1,168 @@ #ifndef oxygenblurhelper_h #define oxygenblurhelper_h ////////////////////////////////////////////////////////////////////////////// // oxygenblurhelper.h // handle regions passed to kwin for blurring // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Loosely inspired (and largely rewritten) from BeSpin style // Copyright (C) 2007 Thomas Luebking // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenstylehelper.h" #include "oxygen.h" #include #include #include #include #include #include #include #include #include #if OXYGEN_HAVE_X11 #include #endif namespace Oxygen { class BlurHelper: public QObject { Q_OBJECT public: //* constructor BlurHelper( QObject*, StyleHelper& ); //* enable state void setEnabled( bool value ) { _enabled = value; } //* enabled bool enabled( void ) const { return _enabled; } //* register widget void registerWidget( QWidget* ); //* register widget void unregisterWidget( QWidget* ); //* event filter bool eventFilter( QObject*, QEvent* ) override; protected: //* timer event - /*! used to perform delayed blur region update of pending widgets */ + /** used to perform delayed blur region update of pending widgets */ void timerEvent( QTimerEvent* event ) override { if( event->timerId() == _timer.timerId() ) { _timer.stop(); update(); } else QObject::timerEvent( event ); } private Q_SLOTS: //* wiget destroyed void widgetDestroyed( QObject* object ) { _widgets.remove( object ); } private: //* install event filter to object, in a unique way void addEventFilter( QObject* object ) { object->removeEventFilter( this ); object->installEventFilter( this ); } //* get list of blur-behind regions matching a given widget QRegion blurRegion( QWidget* ) const; //* trim blur region to remove unnecessary areas (recursive) void trimBlurRegion( QWidget*, QWidget*, QRegion& ) const; //* update blur region for all pending widgets void update( void ) { foreach( const WidgetPointer& widget, _pendingWidgets ) { if( widget ) update( widget.data() ); } _pendingWidgets.clear(); } //* update blur regions for given widget void update( QWidget* ) const; //* clear blur regions for given widget void clear( QWidget* ) const; //* returns true if a given widget is opaque bool isOpaque( const QWidget* widget ) const; //* true if widget is a transparent window - /*! some additional checks are performed to make sure stuff like plasma tooltips + /** some additional checks are performed to make sure stuff like plasma tooltips don't get their blur region overwritten */ bool isTransparent( const QWidget* widget ) const; //* helper StyleHelper& _helper; //* enability bool _enabled; //* list of widgets for which blur region must be updated using WidgetPointer = WeakPointer; using WidgetSet = QHash; WidgetSet _pendingWidgets; //* set of registered widgets QSet _widgets; //* delayed update timer QBasicTimer _timer; #if OXYGEN_HAVE_X11 //* blur atom xcb_atom_t _blurAtom; xcb_atom_t _opaqueAtom; #endif }; } #endif diff --git a/kstyle/oxygenframeshadow.h b/kstyle/oxygenframeshadow.h index 6f99536e..0a561f3a 100644 --- a/kstyle/oxygenframeshadow.h +++ b/kstyle/oxygenframeshadow.h @@ -1,271 +1,269 @@ #ifndef oxygenframeshadow_h #define oxygenframeshadow_h ////////////////////////////////////////////////////////////////////////////// // oxygenframeshadow.h // handle frames' shadows and rounded corners // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Largely inspired from skulpture widget style // Copyright (c) 2007-2009 Christoph Feck // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenaddeventfilter.h" #include "oxygenstylehelper.h" #include #include #include #include #include #include namespace Oxygen { //* shadow manager class FrameShadowFactory: public QObject { Q_OBJECT public: //* constructor explicit FrameShadowFactory( QObject* parent ): QObject( parent ) {} //* register widget bool registerWidget( QWidget*, StyleHelper& ); //* unregister void unregisterWidget( QWidget* ); //* true if widget is registered bool isRegistered( const QWidget* widget ) const { return _registeredWidgets.contains( widget ); } //* event filter bool eventFilter( QObject*, QEvent*) override; //* set contrast void setHasContrast( const QWidget* widget, bool ) const; //* update state void updateState( const QWidget*, bool focus, bool hover, qreal opacity, AnimationMode ) const; //* update shadows geometry void updateShadowsGeometry( const QObject*, QRect ) const; - protected: + private Q_SLOTS: + + //* triggered by object destruction + void widgetDestroyed( QObject* ); + + private: //* install shadows on given widget void installShadows( QWidget*, StyleHelper&, bool flat = false ); //* update shadows geometry void updateShadowsGeometry( QObject* ) const; //* remove shadows from widget void removeShadows( QWidget* ); //* raise shadows void raiseShadows( QObject* ) const; //* update shadows void update( QObject* ) const; //* install shadow on given side void installShadow( QWidget*, StyleHelper&, ShadowArea, bool flat = false ) const; - protected Q_SLOTS: - - //* triggered by object destruction - void widgetDestroyed( QObject* ); - - private: - //* needed to block ChildAdded events when creating shadows AddEventFilter _addEventFilter; //* set of registered widgets QSet _registeredWidgets; }; //* frame shadow /** this allows the shadow to be painted over the widgets viewport */ class FrameShadowBase: public QWidget { Q_OBJECT public: //* constructor explicit FrameShadowBase( ShadowArea area ): _area( area ) {} //* shadow area void setShadowArea(ShadowArea area) { _area = area; } //* shadow area const ShadowArea& shadowArea() const { return _area; } //* set contrast void setHasContrast( bool value ) { if( _contrast == value ) return; _contrast = value; } //* true if contrast pixel is enabled bool hasContrast( void ) const { return _contrast; } //* update geometry virtual void updateGeometry( void ) = 0; //* update geometry virtual void updateGeometry( QRect ) = 0; //* update state virtual void updateState( bool, bool, qreal, AnimationMode ) {} protected: //* initialization virtual void init(); //* return viewport associated to parent widget virtual QWidget* viewport( void ) const; //* parent margins /** offsets between update rect and parent widget rect. It is set via updateGeometry */ const QMargins& margins( void ) const { return _margins; } //* margins /** offsets between update rect and parent widget rect. It is set via updateGeometry */ void setMargins( const QMargins& margins ) { _margins = margins; } private: //* shadow area ShadowArea _area; //* margins /** offsets between update rect and parent widget rect. It is set via updateGeometry */ QMargins _margins; //* contrast pixel bool _contrast = false; }; //* frame shadow /** this allows the shadow to be painted over the widgets viewport */ class SunkenFrameShadow : public FrameShadowBase { Q_OBJECT public: //* constructor SunkenFrameShadow( ShadowArea area, StyleHelper& helper ): FrameShadowBase( area ), _helper( helper ) { init(); } //* update geometry /** nothing is done. Rect must be passed explicitly */ void updateGeometry( void ) override {} //* update geometry void updateGeometry( QRect ) override; //* update state void updateState( bool focus, bool hover, qreal opacity, AnimationMode ) override; protected: //* painting void paintEvent(QPaintEvent *) override; private: //* helper StyleHelper& _helper; //*@name widget state //@{ bool _hasFocus = false; bool _mouseOver = false; qreal _opacity = -1; AnimationMode _mode = AnimationNone; }; //* frame shadow /** this allows the shadow to be painted over the widgets viewport */ class FlatFrameShadow : public FrameShadowBase { Q_OBJECT public: //* constructor FlatFrameShadow( ShadowArea area, StyleHelper& helper ): FrameShadowBase( area ), _helper( helper ) { init(); } //* update geometry void updateGeometry( void ) override; //* update geometry void updateGeometry( QRect ) override; protected: //* painting void paintEvent(QPaintEvent *) override; private: //* helper StyleHelper& _helper; }; } #endif diff --git a/kstyle/oxygenmdiwindowshadow.h b/kstyle/oxygenmdiwindowshadow.h index e4e09eda..2770f0ce 100644 --- a/kstyle/oxygenmdiwindowshadow.h +++ b/kstyle/oxygenmdiwindowshadow.h @@ -1,175 +1,175 @@ #ifndef oxygenmdiwindowshadow_h #define oxygenmdiwindowshadow_h ////////////////////////////////////////////////////////////////////////////// // oxygenmdiwindowshadow.h // handle MDI windows' shadows // ------------------- // // Copyright (c) 2010 Hugo Pereira Da Costa // // Largely inspired from skulpture widget style // Copyright (c) 2007-2009 Christoph Feck // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include "oxygenstylehelper.h" #include "oxygentileset.h" namespace Oxygen { //* frame shadow - /*! this allows the shadow to be painted over the widgets viewport */ + /** this allows the shadow to be painted over the widgets viewport */ class MdiWindowShadow: public QWidget { Q_OBJECT public: //* shadow size (hard coded) enum { ShadowSize = 10 }; //* constructor explicit MdiWindowShadow( QWidget*, TileSet ); //* update geometry void updateGeometry( void ); //* update ZOrder void updateZOrder( void ); //* set associated window void setWidget( QWidget* value ) { _widget = value; } //* associated window QWidget* widget( void ) const { return _widget; } protected: //* painting void paintEvent(QPaintEvent *) override; private: //* associated widget QWidget* _widget = nullptr; //* tileset rect, used for painting QRect _shadowTilesRect; //* tileset used to draw shadow TileSet _shadowTiles; }; //* shadow manager class MdiWindowShadowFactory: public QObject { Q_OBJECT public: //* constructor MdiWindowShadowFactory( QObject*, StyleHelper& ); //* register widget bool registerWidget( QWidget* ); //* unregister void unregisterWidget( QWidget* ); //* true if widget is registered bool isRegistered( const QObject* widget ) const { return _registeredWidgets.contains( widget ); } //* event filter bool eventFilter( QObject*, QEvent*) override; private Q_SLOTS: //* triggered by object destruction void widgetDestroyed( QObject* ); private: //* find shadow matching a given object MdiWindowShadow* findShadow( QObject* ) const; //* install shadows on given widget void installShadow( QObject* ); //* remove shadows from widget void removeShadow( QObject* ); //* hide shadows void hideShadows( QObject* object ) const { if( MdiWindowShadow* windowShadow = findShadow( object ) ) { windowShadow->hide(); } } //* update ZOrder void updateShadowZOrder( QObject* object ) const { if( MdiWindowShadow* windowShadow = findShadow( object ) ) { if( !windowShadow->isVisible() ) windowShadow->show(); windowShadow->updateZOrder(); } } //* update shadows geometry void updateShadowGeometry( QObject* object ) const { if( MdiWindowShadow* windowShadow = findShadow( object ) ) { windowShadow->updateGeometry(); } } //* update shadows void update( QObject* object ) const { if( MdiWindowShadow* windowShadow = findShadow( object ) ) { windowShadow->update(); } } //* set of registered widgets QSet _registeredWidgets; //* tileset used to draw shadow TileSet _shadowTiles; }; } #endif diff --git a/kstyle/transitions/oxygenlabeldata.h b/kstyle/transitions/oxygenlabeldata.h index 2597521c..83cb22e2 100644 --- a/kstyle/transitions/oxygenlabeldata.h +++ b/kstyle/transitions/oxygenlabeldata.h @@ -1,114 +1,114 @@ #ifndef oxygenlabel_datah #define oxygenlabel_datah ////////////////////////////////////////////////////////////////////////////// // oxygenlabeldata.h // data container for QLabel transition // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygentransitiondata.h" #include #include #include namespace Oxygen { //* generic data class LabelData: public TransitionData { Q_OBJECT public: //* constructor LabelData( QObject*, QLabel*, int ); //* event filter bool eventFilter( QObject*, QEvent* ) override; //* returns true if animations are locked bool isLocked( void ) const { return _animationLockTimer.isActive(); } //* start lock animation timer void lockAnimations( void ) { _animationLockTimer.start( _lockTime, this ); } //* start lock animation timer void unlockAnimations( void ) { _animationLockTimer.stop(); } protected: //* timer event void timerEvent( QTimerEvent* ) override; protected Q_SLOTS: //* initialize animation bool initializeAnimation( void ) override; //* animate bool animate( void ) override; private Q_SLOTS: - + //* called when target is destroyed void targetDestroyed( void ); private: //* true if transparent bool transparent( void ) const { return transition() && transition().data()->testFlag( TransitionWidget::Transparent ); } private: //* lock time (milliseconds static const int _lockTime; //* timer used to disable animations when triggered too early QBasicTimer _animationLockTimer; //* needed to start animations out of parent paintEvent QBasicTimer _timer; //* target WeakPointer _target; //* old text QString _text; //* widget rect - /*! needed to properly handle QLabel geometry changes */ + /** needed to properly handle QLabel geometry changes */ QRect _widgetRect; }; } #endif diff --git a/kstyle/transitions/oxygenlineeditdata.h b/kstyle/transitions/oxygenlineeditdata.h index bb0c2ed5..0cd3b8d0 100644 --- a/kstyle/transitions/oxygenlineeditdata.h +++ b/kstyle/transitions/oxygenlineeditdata.h @@ -1,142 +1,142 @@ #ifndef oxygenlineedit_datah #define oxygenlineedit_datah ////////////////////////////////////////////////////////////////////////////// // oxygenlineeditdata.h // data container for QLineEdit transition // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygentransitiondata.h" #include #include #include namespace Oxygen { //* generic data class LineEditData: public TransitionData { Q_OBJECT public: //* constructor LineEditData( QObject*, QLineEdit*, int ); //* event filter bool eventFilter( QObject*, QEvent* ) override; //* returns true if animations are locked bool isLocked( void ) const { return _animationLockTimer.isActive(); } //* start lock animation timer void lockAnimations( void ) { _animationLockTimer.start( _lockTime, this ); } //* start lock animation timer void unlockAnimations( void ) { _animationLockTimer.stop(); } protected Q_SLOTS: //* initialize animation bool initializeAnimation( void ) override; //* animate bool animate( void ) override; protected: //* timer event void timerEvent( QTimerEvent* ) override; private Q_SLOTS: //* text edited void textEdited( void ); //* selection changed void selectionChanged( void ); //* text changed void textChanged( void ); //* called when target is destroyed void targetDestroyed( void ); private: - + //* target rect - /*! return rect corresponding to the area to be updated when animating */ + /** return rect corresponding to the area to be updated when animating */ QRect targetRect( void ) const { if( !_target ) return QRect(); QRect out( _target.data()->rect() ); if( _hasClearButton && _clearButtonRect.isValid() ) { out.setRight( _clearButtonRect.left() ); } return out; } //* check if target has clear button void checkClearButton( void ); //* lock time (milliseconds static const int _lockTime; //* timer used to disable animations when triggered too early QBasicTimer _animationLockTimer; //* needed to start animations out of parent paintEvent QBasicTimer _timer; //* target WeakPointer _target; //* true if target has clean button bool _hasClearButton; //* clear button rect QRect _clearButtonRect; //* true if text was manually edited - /*! needed to trigger animation only on programatically enabled text */ + /** needed to trigger animation only on programatically enabled text */ bool _edited; //* old text QString _text; //* widget rect - /*! needed to properly handle QLabel geometry changes */ + /** needed to properly handle QLabel geometry changes */ QRect _widgetRect; }; } #endif diff --git a/kstyle/transitions/oxygenstackedwidgetdata.h b/kstyle/transitions/oxygenstackedwidgetdata.h index a8f87d87..6dabbd9d 100644 --- a/kstyle/transitions/oxygenstackedwidgetdata.h +++ b/kstyle/transitions/oxygenstackedwidgetdata.h @@ -1,76 +1,76 @@ #ifndef oxygenstackedwidget_datah #define oxygenstackedwidget_datah ////////////////////////////////////////////////////////////////////////////// // oxygenstackedwidgetdata.h // data container for QStackedWidget transition // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygentransitiondata.h" #include namespace Oxygen { //* generic data class StackedWidgetData: public TransitionData { Q_OBJECT public: //* constructor StackedWidgetData( QObject*, QStackedWidget*, int ); protected Q_SLOTS: //* initialize animation bool initializeAnimation( void ) override; //* animate bool animate( void ) override; private Q_SLOTS: //* finish animation void finishAnimation( void ); //* called when target is destroyed void targetDestroyed( void ); private: //* target WeakPointer _target; //* current index - int _index; + int _index = 0; }; } #endif diff --git a/kstyle/transitions/oxygentransitionwidget.h b/kstyle/transitions/oxygentransitionwidget.h index e2c2fedc..c2e33321 100644 --- a/kstyle/transitions/oxygentransitionwidget.h +++ b/kstyle/transitions/oxygentransitionwidget.h @@ -1,232 +1,232 @@ #ifndef oxygentransitionwidget_h #define oxygentransitionwidget_h ////////////////////////////////////////////////////////////////////////////// // oxygentransitionwidget.h // stores event filters and maps widgets to transitions for transitions // ------------------- // // Copyright (c) 2009 Hugo Pereira Da Costa // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// #include "oxygenanimation.h" #include "oxygen.h" #include #include namespace Oxygen { //* temporary widget used to perform smooth transition between one widget state and another class TransitionWidget: public QWidget { Q_OBJECT //* declare opacity property Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity ) public: //* shortcut to painter using Pointer = WeakPointer; //* constructor TransitionWidget( QWidget* parent, int duration ); //*@name flags //@{ enum Flag { None = 0, GrabFromWindow = 1<<0, Transparent = 1<<1, PaintOnWidget = 1<<2 }; Q_DECLARE_FLAGS(Flags, Flag) void setFlags( Flags value ) { _flags = value; } void setFlag( Flag flag, bool value = true ) { if( value ) _flags |= flag; else _flags &= (~flag); } bool testFlag( Flag flag ) const { return _flags.testFlag( flag ); } //@} //* duration void setDuration( int duration ) { if( _animation ) { _animation.data()->setDuration( duration ); } } //* duration int duration( void ) const { return ( _animation ) ? _animation.data()->duration() : 0; } //* steps static void setSteps( int value ) { _steps = value; } //*@name opacity //@{ qreal opacity( void ) const { return _opacity; } void setOpacity( qreal value ) { value = digitize( value ); if( _opacity == value ) return; _opacity = value; update(); } //@} //@name pixmaps handling //@{ //* start void resetStartPixmap( void ) { setStartPixmap( QPixmap() ); } //* start void setStartPixmap( QPixmap pixmap ) { _startPixmap = pixmap; } //* start const QPixmap& startPixmap( void ) const { return _startPixmap; } //* end void resetEndPixmap( void ) { setEndPixmap( QPixmap() ); } //* end void setEndPixmap( QPixmap pixmap ) { _endPixmap = pixmap; _currentPixmap = pixmap; } //* start const QPixmap& endPixmap( void ) const { return _endPixmap; } //* current const QPixmap& currentPixmap( void ) const { return _currentPixmap; } //@} //* grap pixmap QPixmap grab( QWidget* = 0, QRect = QRect() ); //* true if animated bool isAnimated( void ) const { return _animation.data()->isRunning(); } //* end animation void endAnimation( void ) { if( _animation.data()->isRunning() ) _animation.data()->stop(); } //* animate transition void animate( void ) { if( _animation.data()->isRunning() ) _animation.data()->stop(); _animation.data()->start(); } //* true if paint is enabled static bool paintEnabled( void ); protected: //* generic event filter bool event( QEvent* ) override; //* paint event void paintEvent( QPaintEvent* ) override; private: //* grab widget background - /*! + /** Background is not rendered properly using QWidget::render. Use home-made grabber instead. This is directly inspired from bespin. Copyright (C) 2007 Thomas Luebking */ void grabBackground( QPixmap&, QWidget*, QRect& ) const; //* grab widget void grabWidget( QPixmap&, QWidget*, QRect& ) const; //* fade pixmap void fade( const QPixmap& source, QPixmap& target, qreal opacity, const QRect& ) const; //* apply step qreal digitize( const qreal& value ) const { if( _steps > 0 ) return std::floor( value*_steps )/_steps; else return value; } //* Flags Flags _flags = None; //* paint enabled static bool _paintEnabled; //* internal transition animation Animation::Pointer _animation; //* animation starting pixmap QPixmap _startPixmap; //* animation starting pixmap QPixmap _localStartPixmap; //* animation starting pixmap QPixmap _endPixmap; //* current pixmap QPixmap _currentPixmap; //* current state opacity qreal _opacity = 0; //* steps static int _steps; }; } #endif