├── .clang-format ├── .github └── workflows │ └── build.yml ├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── LICENSE.GPL2 ├── LICENSE.LGPL2 ├── README.md ├── cmake └── FindXCB.cmake ├── data └── screenshots │ ├── widgets-adwaita-dark.png │ ├── widgets-adwaita.png │ ├── widgets-highcontrast.png │ └── widgets-highcontrastinverse.png └── src ├── CMakeLists.txt ├── demo ├── CMakeLists.txt ├── main.cpp ├── widgetfactory.cpp ├── widgetfactory.h └── widgetfactory.ui ├── lib ├── AdwaitaQtConfig.cmake.in ├── CMakeLists.txt ├── adwaita-qt.pc.cmake ├── adwaita.cpp ├── adwaita.h ├── adwaitaaddeventfilter.cpp ├── adwaitaaddeventfilter.h ├── adwaitacolors.cpp ├── adwaitacolors.h ├── adwaitacolors_p.h ├── adwaitadebug.h ├── adwaitamnemonics.cpp ├── adwaitamnemonics.h ├── adwaitaqt_export.h ├── adwaitarenderer.cpp ├── adwaitarenderer.h ├── adwaitasplitterproxy.cpp ├── adwaitasplitterproxy.h ├── adwaitawidgetexplorer.cpp ├── adwaitawidgetexplorer.h ├── adwaitawindowmanager.cpp ├── adwaitawindowmanager.h ├── animations │ ├── adwaitaanimation.cpp │ ├── adwaitaanimation.h │ ├── adwaitaanimationdata.cpp │ ├── adwaitaanimationdata.h │ ├── adwaitaanimations.cpp │ ├── adwaitaanimations.h │ ├── adwaitabaseengine.cpp │ ├── adwaitabaseengine.h │ ├── adwaitabusyindicatordata.cpp │ ├── adwaitabusyindicatordata.h │ ├── adwaitabusyindicatorengine.cpp │ ├── adwaitabusyindicatorengine.h │ ├── adwaitadatamap.h │ ├── adwaitadialdata.cpp │ ├── adwaitadialdata.h │ ├── adwaitadialengine.cpp │ ├── adwaitadialengine.h │ ├── adwaitaenabledata.cpp │ ├── adwaitaenabledata.h │ ├── adwaitagenericdata.cpp │ ├── adwaitagenericdata.h │ ├── adwaitaheaderviewdata.cpp │ ├── adwaitaheaderviewdata.h │ ├── adwaitaheaderviewengine.cpp │ ├── adwaitaheaderviewengine.h │ ├── adwaitascrollbardata.cpp │ ├── adwaitascrollbardata.h │ ├── adwaitascrollbarengine.cpp │ ├── adwaitascrollbarengine.h │ ├── adwaitaspinboxdata.cpp │ ├── adwaitaspinboxdata.h │ ├── adwaitaspinboxengine.cpp │ ├── adwaitaspinboxengine.h │ ├── adwaitastackedwidgetdata.cpp │ ├── adwaitastackedwidgetdata.h │ ├── adwaitastackedwidgetengine.cpp │ ├── adwaitastackedwidgetengine.h │ ├── adwaitatabbardata.cpp │ ├── adwaitatabbardata.h │ ├── adwaitatabbarengine.cpp │ ├── adwaitatabbarengine.h │ ├── adwaitatoolboxengine.cpp │ ├── adwaitatoolboxengine.h │ ├── adwaitatransitiondata.cpp │ ├── adwaitatransitiondata.h │ ├── adwaitatransitionwidget.cpp │ ├── adwaitatransitionwidget.h │ ├── adwaitawidgetstatedata.cpp │ ├── adwaitawidgetstatedata.h │ ├── adwaitawidgetstateengine.cpp │ └── adwaitawidgetstateengine.h ├── config-adwaita.h.cmake └── stylesheet │ ├── Adwaita-dark.scss │ ├── Adwaita-hc-dark.scss │ ├── Adwaita-hc.scss │ ├── Adwaita-light.scss │ ├── _colors-hc.scss │ ├── _colors.scss │ ├── _drawing.scss │ ├── processed │ ├── Adwaita-dark.css │ ├── Adwaita-hc-dark.css │ ├── Adwaita-hc.css │ └── Adwaita-light.css │ └── stylesheet.qrc.in └── style ├── CMakeLists.txt ├── adwaita.json ├── adwaita.themerc ├── adwaitahelper.cpp ├── adwaitahelper.h ├── adwaitastyle.cpp ├── adwaitastyle.h ├── adwaitastyleplugin.cpp └── adwaitastyleplugin.h /.clang-format: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT 2 | # 3 | # Copyright (C) 2019 Christoph Cullmann 4 | # Copyright (C) 2019 Gernot Gebhard 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included 15 | # in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # Style for C++ 26 | Language: Cpp 27 | 28 | # base is WebKit coding style: http://www.webkit.org/coding/coding-style.html 29 | # below are only things set that diverge from this style! 30 | BasedOnStyle: WebKit 31 | 32 | # enforce C++11 (e.g. for std::vector> 33 | Standard: Cpp11 34 | 35 | # 4 spaces indent 36 | TabWidth: 4 37 | 38 | # 3 * 80 wide lines 39 | ColumnLimit: 240 40 | 41 | # sort includes inside line separated groups 42 | SortIncludes: true 43 | 44 | # break before braces on function, namespace and class definitions. 45 | BreakBeforeBraces: Linux 46 | 47 | # CrlInstruction *a; 48 | PointerAlignment: Right 49 | 50 | # horizontally aligns arguments after an open bracket. 51 | AlignAfterOpenBracket: Align 52 | 53 | # align trailing comments 54 | AlignTrailingComments: true 55 | 56 | # don't move all parameters to new line 57 | AllowAllParametersOfDeclarationOnNextLine: false 58 | 59 | # no single line functions 60 | AllowShortFunctionsOnASingleLine: None 61 | 62 | # always break before you encounter multi line strings 63 | AlwaysBreakBeforeMultilineStrings: true 64 | 65 | # don't move arguments to own lines if they are not all on the same 66 | BinPackArguments: false 67 | 68 | # don't move parameters to own lines if they are not all on the same 69 | BinPackParameters: false 70 | 71 | # don't break binary ops 72 | BreakBeforeBinaryOperators: None 73 | 74 | # format C++11 braced lists like function calls 75 | Cpp11BracedListStyle: true 76 | 77 | # remove empty lines 78 | KeepEmptyLinesAtTheStartOfBlocks: false 79 | 80 | # no namespace indentation to keep indent level low 81 | NamespaceIndentation: None 82 | 83 | # we use template< without space. 84 | SpaceAfterTemplateKeyword: false 85 | 86 | # macros for which the opening brace stays attached. 87 | ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ] 88 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Automatic build 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | pull_request: 8 | branches: 9 | - '**' 10 | release: 11 | types: [ created ] 12 | env: 13 | BUILD_TYPE: Release 14 | 15 | jobs: 16 | Linux_Qt5: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Install dependencies 21 | run: | 22 | sudo apt update 23 | sudo apt install cmake make pkg-config libx11-dev xcb libx11-xcb-dev libxkbcommon-dev sassc 24 | 25 | - name: Install Qt 26 | uses: jurplel/install-qt-action@v2 27 | with: 28 | version: 5.15.2 29 | 30 | - name: Create Build Environment 31 | run: cmake -E make_directory ${{runner.workspace}}/build 32 | 33 | - name: Configure CMake 34 | shell: bash 35 | working-directory: ${{runner.workspace}}/build 36 | run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_EXAMPLE=true -DUSE_QT6=OFF 37 | 38 | - name: Build 39 | working-directory: ${{runner.workspace}}/build 40 | shell: bash 41 | run: make -j2 42 | 43 | Linux_Qt6: 44 | runs-on: ubuntu-latest 45 | steps: 46 | - uses: actions/checkout@v2 47 | - name: Install dependencies 48 | run: | 49 | sudo apt update 50 | sudo apt install cmake make pkg-config libx11-dev xcb libx11-xcb-dev libxkbcommon-dev sassc 51 | 52 | - name: Install Qt 53 | uses: jurplel/install-qt-action@v2 54 | with: 55 | version: 6.2.0 56 | 57 | - name: Create Build Environment 58 | run: cmake -E make_directory ${{runner.workspace}}/build 59 | 60 | - name: Configure CMake 61 | shell: bash 62 | working-directory: ${{runner.workspace}}/build 63 | run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_EXAMPLE=true -DUSE_QT6=ON 64 | 65 | - name: Build 66 | working-directory: ${{runner.workspace}}/build 67 | shell: bash 68 | run: make -j2 69 | 70 | Windows: 71 | runs-on: windows-latest 72 | steps: 73 | - uses: actions/checkout@v1 74 | with: 75 | fetch-depth: 1 76 | 77 | - name: Install Qt 78 | uses: jurplel/install-qt-action@v2 79 | with: 80 | cached: ${{ steps.cache-qt.outputs.cache-hit }} 81 | arch: 'win64_mingw81' 82 | version: '5.15.2' 83 | 84 | - name: Build 85 | shell: bash 86 | if: ${{ !steps.cache-qt.outputs.cache-hit }} 87 | run: | 88 | mkdir build 89 | cd build 90 | cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="$Qt5_Dir" -DBUILD_SHARED_LIBS=ON .. 91 | mingw32-make -j2 VERBOSE=1 92 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.kdev4 2 | build 3 | CMakeLists.txt.user* 4 | 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Cursors: 2 | Ken Vermette 3 | 4 | KStyle (original Breeze): 5 | Hugo Pereira Da Costa - Developer 6 | Andrew Lake - Designer 7 | 8 | KStyle (adwaita modifications) 9 | Martin Bříza 10 | Jan Grulich 11 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(Adwaita) 2 | 3 | cmake_minimum_required(VERSION 3.17) 4 | 5 | set(ADWAITAQT_VERSION_MAJOR 1) 6 | set(ADWAITAQT_VERSION "1.4.50") 7 | 8 | option(USE_QT6 "Use Qt6 instead of Qt5" OFF) 9 | 10 | if (USE_QT6) 11 | set(QT_MIN_VERSION "6.2.0") 12 | set(CMAKE_CXX_STANDARD 17) 13 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 14 | set(ADWAITAQT_SUFFIX "6") 15 | else() 16 | set(QT_MIN_VERSION "5.15.2") 17 | set(CMAKE_CXX_STANDARD 11) 18 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 19 | set(ADWAITAQT_SUFFIX "") 20 | endif() 21 | 22 | set(CMAKE_AUTOMOC ON) 23 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH}) 24 | 25 | include(GNUInstallDirs) 26 | 27 | if (USE_QT6) 28 | find_package(QT NAMES Qt6 COMPONENTS Core DBus Gui Widgets REQUIRED) 29 | else() 30 | find_package(QT NAMES Qt5 COMPONENTS Core DBus Gui Widgets REQUIRED) 31 | endif() 32 | 33 | find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS 34 | Core 35 | DBus 36 | Gui 37 | Widgets 38 | ) 39 | 40 | if (NOT APPLE AND NOT WIN32 AND NOT USE_QT6) 41 | find_package(XCB 1.10 COMPONENTS XCB) 42 | 43 | find_package(Qt${QT_VERSION_MAJOR}X11Extras ${QT_MIN_VERSION}) 44 | set(ADWAITA_HAVE_X11 ${XCB_FOUND} AND ${Qt5X11Extras_FOUND}) 45 | endif() 46 | 47 | if (NOT QT_PLUGINS_DIR) 48 | if (NOT USE_QT6) 49 | get_target_property(REAL_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} 50 | IMPORTED_LOCATION) 51 | execute_process(COMMAND "${REAL_QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS 52 | OUTPUT_VARIABLE QT_PLUGINS_DIR 53 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 54 | else() 55 | set(QT_PLUGINS_DIR ${QT6_INSTALL_PLUGINS}) 56 | endif() 57 | endif() 58 | 59 | add_subdirectory(src) 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | adwaita-qt 2 | ========== 3 | 4 | # Adwaita-qt project is unmaintained a no longer actively developed. 5 | 6 | A native style to bend Qt5/Qt6 applications to look like they belong into GNOME Shell. 7 | 8 | This style provides all four variants of GTK Adwaita theme: 9 | 10 | * Adwaita 11 | ![Widget Factory](data/screenshots/widgets-adwaita.png) 12 | 13 | * Adwaita-dark 14 | ![Widget Factory](data/screenshots/widgets-adwaita-dark.png) 15 | 16 | * HighContrast 17 | ![Widget Factory](data/screenshots/widgets-highcontrast.png) 18 | 19 | * HighContrastInverse 20 | ![Widget Factory](data/screenshots/widgets-highcontrastinverse.png) 21 | 22 | ## How to compile 23 | 24 | The project uses the standard CMake buildsystem. 25 | 26 | So for example, the whole compilation process could look like this: 27 | 28 | ``` 29 | mkdir build 30 | cd build 31 | cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr [-DUSE_QT6] .. 32 | make 33 | make install 34 | ``` 35 | 36 | ## Usage 37 | 38 | After install, you'll be able to either set the theme as your default via your DE's tools (like `systemsettings` or `qt-config`) or start your qt applications with the `-style adwaita` parameter. 39 | -------------------------------------------------------------------------------- /cmake/FindXCB.cmake: -------------------------------------------------------------------------------- 1 | # Try to find XCB on a Unix system 2 | # 3 | # This will define: 4 | # 5 | # XCB_FOUND - True if xcb is available 6 | # XCB_LIBRARIES - Link these to use xcb 7 | # XCB_INCLUDE_DIR - Include directory for xcb 8 | # XCB_DEFINITIONS - Compiler flags for using xcb 9 | # 10 | # In addition the following more fine grained variables will be defined: 11 | # 12 | # XCB_XCB_FOUND XCB_XCB_INCLUDE_DIR XCB_XCB_LIBRARIES 13 | # 14 | # Copyright (c) 2012 Fredrik Höglund 15 | # 16 | # Redistribution and use is allowed according to the terms of the BSD license. 17 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 18 | 19 | if (XCB_INCLUDE_DIR AND XCB_LIBRARIES) 20 | # In the cache already 21 | set(XCB_FIND_QUIETLY TRUE) 22 | endif (XCB_INCLUDE_DIR AND XCB_LIBRARIES) 23 | 24 | # Use pkg-config to get the directories and then use these values 25 | # in the FIND_PATH() and FIND_LIBRARY() calls 26 | find_package(PkgConfig) 27 | pkg_check_modules(PKG_XCB QUIET xcb) 28 | 29 | set(XCB_DEFINITIONS ${PKG_XCB_CFLAGS}) 30 | 31 | find_path(XCB_XCB_INCLUDE_DIR 32 | NAMES xcb/xcb.h 33 | HINTS ${PKG_XCB_INCLUDE_DIRS}) 34 | 35 | find_library(XCB_XCB_LIBRARIES 36 | NAMES xcb 37 | HINTS ${PKG_XCB_LIBRARY_DIRS}) 38 | 39 | set(XCB_INCLUDE_DIR ${XCB_XCB_INCLUDE_DIR}) 40 | 41 | set(XCB_LIBRARIES ${XCB_XCB_LIBRARIES}) 42 | 43 | list(REMOVE_DUPLICATES XCB_INCLUDE_DIR) 44 | 45 | include(FindPackageHandleStandardArgs) 46 | 47 | find_package_handle_standard_args(XCB 48 | FOUND_VAR 49 | XCB_FOUND 50 | REQUIRED_VARS 51 | XCB_LIBRARIES 52 | XCB_INCLUDE_DIR 53 | ) 54 | 55 | mark_as_advanced(XCB_INCLUDE_DIR XCB_LIBRARIES) 56 | -------------------------------------------------------------------------------- /data/screenshots/widgets-adwaita-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FedoraQt/adwaita-qt/0a774368916def5c9889de50f3323dec11de781e/data/screenshots/widgets-adwaita-dark.png -------------------------------------------------------------------------------- /data/screenshots/widgets-adwaita.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FedoraQt/adwaita-qt/0a774368916def5c9889de50f3323dec11de781e/data/screenshots/widgets-adwaita.png -------------------------------------------------------------------------------- /data/screenshots/widgets-highcontrast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FedoraQt/adwaita-qt/0a774368916def5c9889de50f3323dec11de781e/data/screenshots/widgets-highcontrast.png -------------------------------------------------------------------------------- /data/screenshots/widgets-highcontrastinverse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FedoraQt/adwaita-qt/0a774368916def5c9889de50f3323dec11de781e/data/screenshots/widgets-highcontrastinverse.png -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | option(BUILD_EXAMPLE "Build an example widget factory app" OFF) 2 | if (BUILD_EXAMPLE) 3 | add_subdirectory(demo) 4 | endif() 5 | 6 | add_subdirectory(lib) 7 | add_subdirectory(style) 8 | -------------------------------------------------------------------------------- /src/demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 3 | 4 | set(showcase_SRCS 5 | main.cpp 6 | widgetfactory.cpp 7 | ) 8 | 9 | set(showcase_UI 10 | widgetfactory.ui 11 | ) 12 | 13 | if (USE_QT6) 14 | qt6_wrap_ui(showcase_SRCS ${showcase_UI}) 15 | else() 16 | qt5_wrap_ui(showcase_SRCS ${showcase_UI}) 17 | endif() 18 | 19 | add_executable(showcase ${showcase_SRCS}) 20 | target_link_libraries(showcase Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets) 21 | -------------------------------------------------------------------------------- /src/demo/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Widget Showcase 3 | * Copyright (C) 2014-2018 Martin Bříza 4 | * Copyright (C) 2019 Jan Grulich 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | */ 21 | 22 | #include 23 | 24 | #include "widgetfactory.h" 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | QApplication app(argc, argv); 29 | WidgetFactory fact; 30 | fact.show(); 31 | return app.exec(); 32 | } 33 | -------------------------------------------------------------------------------- /src/demo/widgetfactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Widget Showcase 3 | * Copyright (C) 2014-2018 Martin Bříza 4 | * Copyright (C) 2019 Jan Grulich 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | * 20 | */ 21 | 22 | #ifndef WIDGETFACTORY_H 23 | #define WIDGETFACTORY_H 24 | 25 | #include 26 | 27 | class WidgetFactory : public QMainWindow 28 | { 29 | Q_OBJECT 30 | public: 31 | WidgetFactory(QWidget *parent = nullptr); 32 | ~WidgetFactory(); 33 | 34 | private: 35 | class Private; 36 | Private *d; 37 | }; 38 | 39 | #endif // WIDGETFACTORY_H 40 | -------------------------------------------------------------------------------- /src/lib/AdwaitaQtConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | find_dependency(Qt@QT_VERSION_MAJOR@Core @QT_MIN_VERSION@) 5 | find_dependency(Qt@QT_VERSION_MAJOR@Gui @QT_MIN_VERSION@) 6 | find_dependency(Qt@QT_VERSION_MAJOR@Widgets @QT_MIN_VERSION@) 7 | 8 | set(ADWAITAQT_LIBRARIES adwaitaqt@ADWAITAQT_SUFFIX@) 9 | set(ADWAITAQT_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@) 10 | include("${CMAKE_CURRENT_LIST_DIR}/AdwaitaQt@ADWAITAQT_SUFFIX@Targets.cmake") 11 | -------------------------------------------------------------------------------- /src/lib/adwaita-qt.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 3 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 4 | 5 | Name: adwaita-qt@ADWAITAQT_SUFFIX@ 6 | Description: Qt Adwaita Style 7 | Version: @ADWAITAQT_VERSION@ 8 | Requires: @PC_REQUIRES@ 9 | @PC_REQUIRES_PRIVATE@ 10 | 11 | Libs: -L${libdir} -ladwaitaqt@ADWAITAQT_SUFFIX@ 12 | Cflags: -I${includedir} 13 | Requires: Qt@QT_VERSION_MAJOR@Core Qt@QT_VERSION_MAJOR@Widgets 14 | -------------------------------------------------------------------------------- /src/lib/adwaitaaddeventfilter.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaaddeventfilter.h" 21 | -------------------------------------------------------------------------------- /src/lib/adwaitaaddeventfilter.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_ADD_EVENT_FILTER_H 21 | #define ADWAITA_ADD_EVENT_FILTER_H 22 | 23 | #include 24 | #include 25 | 26 | #include "adwaitaqt_export.h" 27 | 28 | namespace Adwaita 29 | { 30 | 31 | class ADWAITAQT_EXPORT AddEventFilter : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | //* constructor 36 | AddEventFilter() 37 | : QObject() 38 | { 39 | } 40 | 41 | //* destructor 42 | virtual ~AddEventFilter() 43 | { 44 | } 45 | 46 | //* event filter 47 | /** blocks all AddChild events */ 48 | virtual bool eventFilter(QObject *, QEvent *event) 49 | { 50 | return event->type() == QEvent::ChildAdded; 51 | } 52 | }; 53 | 54 | } // namespace Adwaita 55 | 56 | #endif // ADWAITA_ADD_EVENT_FILTER_H 57 | -------------------------------------------------------------------------------- /src/lib/adwaitacolors_p.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2019-2021 Jan Grulich * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_COLORS_P_H 21 | #define ADWAITA_COLORS_P_H 22 | 23 | #include "adwaita.h" 24 | 25 | #include 26 | 27 | class QColor; 28 | 29 | namespace Adwaita 30 | { 31 | 32 | class ColorsPrivate : public QObject 33 | { 34 | Q_OBJECT 35 | public: 36 | enum AdwaitaColor { 37 | invalid_color= 0, 38 | base_color, 39 | text_color, 40 | bg_color, 41 | fg_color, 42 | selected_fg_color, 43 | selected_bg_color, 44 | selected_borders_color, 45 | borders_color, 46 | alt_borders_color, 47 | borders_edge, 48 | link_color, 49 | link_visited_color, 50 | top_hilight, 51 | dark_fill, 52 | headerbar_bg_color, 53 | menu_color, 54 | menu_selected_color, 55 | scrollbar_bg_color, 56 | scrollbar_slider_color, 57 | scrollbar_slider_hover_color, 58 | scrollbar_slider_active_color, 59 | warning_color, 60 | error_color, 61 | success_color, 62 | destructive_color, 63 | osd_fg_color, 64 | osd_text_color, 65 | osd_bg_color, 66 | osd_insensitive_bg_color, 67 | osd_insensitive_fg_color, 68 | osd_borders_color, 69 | sidebar_bg_color, 70 | tooltip_borders_color, 71 | shadow_color, 72 | drop_target_color, 73 | insensitive_fg_color, 74 | insensitive_bg_color, 75 | insensitive_borders_color, 76 | backdrop_base_color, 77 | backdrop_text_color, 78 | backdrop_bg_color, 79 | backdrop_fg_color, 80 | backdrop_insensitive_color, 81 | backdrop_selected_fg_color, 82 | backdrop_borders_color, 83 | backdrop_dark_fill, 84 | suggested_bg_color, 85 | suggested_border_color, 86 | progress_bg_color, 87 | progress_border_color, 88 | checkradio_bg_color, 89 | checkradio_fg_color, 90 | checkradio_borders_color, 91 | switch_bg_color, 92 | switch_borders_color, 93 | focus_border_color, 94 | alt_focus_border_color 95 | }; 96 | Q_ENUM(AdwaitaColor); 97 | 98 | ColorsPrivate(); 99 | virtual ~ColorsPrivate(); 100 | 101 | QColor adwaitaColor(AdwaitaColor color, ColorVariant variant); 102 | QColor adwaitaWidgetColor(const QString &color, ColorVariant variant); 103 | static bool isDarkMode(); 104 | 105 | private: 106 | QHash > m_colors; 107 | QHash > m_widgetColors; 108 | }; 109 | 110 | } // namespace Adwaita 111 | 112 | #endif // ADWAITA_COLORS_P_H 113 | 114 | 115 | -------------------------------------------------------------------------------- /src/lib/adwaitadebug.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2019 Jan Grulich * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_DEBUG_H 21 | #define ADWAITA_DEBUG_H 22 | 23 | #include 24 | 25 | Q_DECLARE_LOGGING_CATEGORY(ADWAITA) 26 | 27 | #endif // ADWAITA_DEBUG_H 28 | -------------------------------------------------------------------------------- /src/lib/adwaitamnemonics.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitamnemonics.h" 21 | #include "adwaita.h" 22 | 23 | #include 24 | #include 25 | 26 | namespace Adwaita 27 | { 28 | 29 | //____________________________________________________ 30 | void Mnemonics::setMode(int mode) 31 | { 32 | switch (mode) { 33 | case Adwaita::MN_NEVER: 34 | qApp->removeEventFilter(this); 35 | setEnabled(false); 36 | break; 37 | case Adwaita::MN_ALWAYS: 38 | qApp->removeEventFilter(this); 39 | setEnabled(true); 40 | break; 41 | case Adwaita::MN_AUTO: 42 | qApp->removeEventFilter(this); 43 | qApp->installEventFilter(this); 44 | setEnabled(false); 45 | break; 46 | default: 47 | break; 48 | } 49 | 50 | return; 51 | } 52 | 53 | //____________________________________________________ 54 | bool Mnemonics::eventFilter(QObject *, QEvent *event) 55 | { 56 | switch (event->type()) { 57 | case QEvent::KeyPress: 58 | if (static_cast(event)->key() == Qt::Key_Alt) { 59 | setEnabled(true); 60 | } 61 | break; 62 | case QEvent::KeyRelease: 63 | if (static_cast(event)->key() == Qt::Key_Alt) { 64 | setEnabled(false); 65 | } 66 | break; 67 | case QEvent::ApplicationStateChange: 68 | setEnabled(false); 69 | break; 70 | default: 71 | break; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | //____________________________________________________ 78 | void Mnemonics::setEnabled(bool value) 79 | { 80 | if (_enabled == value) { 81 | return; 82 | } 83 | 84 | _enabled = value; 85 | 86 | // update all top level widgets 87 | foreach (QWidget *widget, qApp->topLevelWidgets()) { 88 | widget->update(); 89 | } 90 | } 91 | 92 | } // namespace Adwaita 93 | -------------------------------------------------------------------------------- /src/lib/adwaitamnemonics.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_MNEMONICS_H 21 | #define ADWAITA_MNEMONICS_H 22 | 23 | #include "adwaitaqt_export.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace Adwaita 30 | { 31 | class ADWAITAQT_EXPORT Mnemonics : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | //* constructor 36 | explicit Mnemonics(QObject *parent) 37 | : QObject(parent) 38 | , _enabled(true) 39 | { 40 | } 41 | 42 | //* destructor 43 | virtual ~Mnemonics() 44 | { 45 | } 46 | 47 | //* set mode 48 | void setMode(int); 49 | 50 | //* event filter 51 | virtual bool eventFilter(QObject *, QEvent *); 52 | 53 | //* true if mnemonics are enabled 54 | const bool &enabled() const 55 | { 56 | return _enabled; 57 | } 58 | 59 | //* alignment flag 60 | int textFlags() const 61 | { 62 | return _enabled ? Qt::TextShowMnemonic : Qt::TextHideMnemonic; 63 | } 64 | 65 | protected: 66 | //* set enable state 67 | void setEnabled(bool); 68 | 69 | private: 70 | //* enable state 71 | bool _enabled; 72 | }; 73 | 74 | } // namespace Adwaita 75 | 76 | #endif // ADWAITA_MNEMONICS_H 77 | -------------------------------------------------------------------------------- /src/lib/adwaitaqt_export.h: -------------------------------------------------------------------------------- 1 | #ifndef ADWAITAQT_EXPORT_H 2 | #define ADWAITAQT_EXPORT_H 3 | 4 | #if defined(_WIN32) 5 | # if defined (adwaitaqt6priv_EXPORTS) || defined (adwaitaqtpriv_EXPORTS) 6 | # define ADWAITAQT_EXPORT __declspec(dllexport) 7 | # else 8 | # define ADWAITAQT_EXPORT __declspec(dllimport) 9 | # endif 10 | #elif defined(__GNUC__) 11 | # define ADWAITAQT_EXPORT __attribute__((visibility("default"))) 12 | #else 13 | # define ADWAITAQT_EXPORT 14 | #endif 15 | 16 | #if defined(_WIN32) 17 | # if defined (adwaitaqt6_EXPORTS) || defined (adwaitaqt_EXPORTS) 18 | # define ADWAITAQT_MAIN_EXPORT __declspec(dllexport) 19 | # else 20 | # define ADWAITAQT_MAIN_EXPORT __declspec(dllimport) 21 | # endif 22 | #elif defined(__GNUC__) 23 | # define ADWAITAQT_MAIN_EXPORT __attribute__((visibility("default"))) 24 | #else 25 | # define ADWAITAQT_MAIN_EXPORT 26 | #endif 27 | 28 | #ifndef ADWAITAQT_NO_EXPORT 29 | # define ADWAITAQT_NO_EXPORT __attribute__((visibility("hidden"))) 30 | #endif 31 | 32 | #ifndef ADWAITAQT_DEPRECATED 33 | # define ADWAITAQT_DEPRECATED __attribute__ ((__deprecated__)) 34 | #endif 35 | 36 | #ifndef ADWAITAQT_DEPRECATED_EXPORT 37 | # define ADWAITAQT_DEPRECATED_EXPORT ADWAITAQT_EXPORT ADWAITAQT_DEPRECATED 38 | #endif 39 | 40 | #ifndef ADWAITAQT_DEPRECATED_NO_EXPORT 41 | # define ADWAITAQT_DEPRECATED_NO_EXPORT ADWAITAQT_NO_EXPORT ADWAITAQT_DEPRECATED 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/lib/adwaitarenderer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * Copyright (C) 2014-2018 Martin Bříza * 4 | * Copyright (C) 2019-2021 Jan Grulich * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, write to the * 18 | * Free Software Foundation, Inc., * 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 20 | *************************************************************************/ 21 | 22 | #ifndef ADWAITA_RENDERER_H 23 | #define ADWAITA_RENDERER_H 24 | 25 | #include "adwaita.h" 26 | #include "adwaitaqt_export.h" 27 | 28 | namespace Adwaita 29 | { 30 | 31 | class ADWAITAQT_MAIN_EXPORT Renderer 32 | { 33 | public: 34 | static void renderDebugFrame(const StyleOptions &options); 35 | 36 | static void renderFocusRect(const StyleOptions &options, Sides sides = SideNone); 37 | 38 | static void renderFocusLine(const StyleOptions &options); 39 | 40 | static void renderFrame(const StyleOptions &options); 41 | 42 | static void renderSquareFrame(const StyleOptions &options); 43 | 44 | static void renderFlatFrame(const StyleOptions &options); 45 | 46 | static void renderSidePanelFrame(const StyleOptions &options, Side side); 47 | 48 | static void renderMenuFrame(const StyleOptions &options, bool roundCorners = true); 49 | 50 | static void renderButtonFrame(const StyleOptions &options); 51 | 52 | static void renderCheckBoxFrame(const StyleOptions &options); 53 | 54 | static void renderFlatButtonFrame(const StyleOptions &options); 55 | 56 | static void renderFlatRoundedButtonFrame(const StyleOptions &options); 57 | 58 | static void renderToolButtonFrame(const StyleOptions &options); 59 | 60 | static void renderToolBoxFrame(const StyleOptions &options, int tabWidth); 61 | 62 | static void renderTabWidgetFrame(const StyleOptions &options, Corners corners); 63 | 64 | static void renderSelection(const StyleOptions &options); 65 | 66 | static void renderSeparator(const StyleOptions &options, bool vertical = false); 67 | 68 | static void renderCheckBoxBackground(const StyleOptions &options); 69 | 70 | static void renderCheckBox(const StyleOptions &options, const QColor &tickColor, qreal animation = -1); 71 | 72 | static void renderRadioButtonBackground(const StyleOptions &options); 73 | 74 | static void renderRadioButton(const StyleOptions &options, const QColor &tickColor, qreal animation = -1); 75 | 76 | static void renderSliderGroove(const StyleOptions &options); 77 | 78 | static void renderSliderHandle(const StyleOptions &options, Side ticks, qreal angle = 0.0); 79 | 80 | static void renderDialGroove(const StyleOptions &options); 81 | 82 | static void renderDialContents(const StyleOptions &options, qreal first, qreal second); 83 | 84 | static void renderProgressBarGroove(const StyleOptions &options); 85 | 86 | static void renderProgressBarContents(const StyleOptions &options); 87 | 88 | static void renderProgressBarBusyContents(const StyleOptions &options, bool horizontal, bool reverse, int progress); 89 | 90 | static void renderScrollBarGroove(const StyleOptions &options); 91 | 92 | static void renderScrollBarHandle(const StyleOptions &options); 93 | 94 | static void renderToolBarHandle(const StyleOptions &options); 95 | 96 | static void renderTabBarTab(const StyleOptions &options, const QColor &background, Corners corners, bool renderFrame); 97 | 98 | static void renderArrow(const StyleOptions &options, ArrowOrientation arrowOrientation); 99 | 100 | static void renderSign(const StyleOptions &options, bool orientation); 101 | 102 | static void renderDecorationButton(const StyleOptions &options, ButtonType buttonType); 103 | }; 104 | 105 | } // namespace Adwaita 106 | 107 | #endif // ADWAITA_RENDERER_H 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/lib/adwaitasplitterproxy.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_SPLITTER_PROXY_H 21 | #define ADWAITA_SPLITTER_PROXY_H 22 | 23 | #include "adwaita.h" 24 | #include "adwaitaaddeventfilter.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace Adwaita 35 | { 36 | class SplitterProxy; 37 | 38 | //* factory 39 | class ADWAITAQT_EXPORT SplitterFactory : public QObject 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | //* constructor 45 | explicit SplitterFactory(QObject *parent) 46 | : QObject(parent) 47 | , _enabled(false) 48 | { 49 | } 50 | 51 | //* destructor 52 | virtual ~SplitterFactory() 53 | { 54 | } 55 | 56 | //* enabled state 57 | void setEnabled(bool); 58 | 59 | //* register widget 60 | bool registerWidget(QWidget *); 61 | 62 | //* unregister widget 63 | void unregisterWidget(QWidget *); 64 | 65 | private: 66 | //* enabled state 67 | bool _enabled; 68 | 69 | //* needed to block ChildAdded events when creating proxy 70 | AddEventFilter _addEventFilter; 71 | 72 | //* pointer to SplitterProxy 73 | using SplitterProxyPointer = WeakPointer; 74 | 75 | //* registered widgets 76 | using WidgetMap = QMap; 77 | WidgetMap _widgets; 78 | }; 79 | 80 | //* splitter 'proxy' widget, with extended hit area 81 | class SplitterProxy : public QWidget 82 | { 83 | Q_OBJECT 84 | 85 | public: 86 | //* constructor 87 | explicit SplitterProxy(QWidget *, bool = false); 88 | 89 | //* destructor 90 | virtual ~SplitterProxy(); 91 | 92 | //* event filter 93 | virtual bool eventFilter(QObject *, QEvent *); 94 | 95 | //* enable state 96 | void setEnabled(bool); 97 | 98 | //* enable state 99 | bool enabled() const 100 | { 101 | return _enabled; 102 | } 103 | 104 | protected: 105 | //* event handler 106 | virtual bool event(QEvent *); 107 | 108 | protected: 109 | //* reset 'true' splitter widget 110 | void clearSplitter(); 111 | 112 | //* keep track of 'true' splitter widget 113 | void setSplitter(QWidget *); 114 | 115 | private: 116 | //* enabled state 117 | bool _enabled; 118 | 119 | //* splitter object 120 | WeakPointer _splitter; 121 | 122 | //* hook 123 | QPoint _hook; 124 | 125 | //* timer id 126 | int _timerId; 127 | }; 128 | 129 | } // namespace Adwaita 130 | 131 | #endif // ADWAITA_SPLITTER_PROXY_H 132 | -------------------------------------------------------------------------------- /src/lib/adwaitawidgetexplorer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_WIDGET_EXPLORER_H 21 | #define ADWAITA_WIDGET_EXPLORER_H 22 | 23 | #include "adwaitaqt_export.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace Adwaita 32 | { 33 | //* print widget's and parent's information on mouse click 34 | class ADWAITAQT_EXPORT WidgetExplorer : public QObject 35 | { 36 | Q_OBJECT 37 | public: 38 | //* constructor 39 | explicit WidgetExplorer(QObject *parent); 40 | 41 | //* enable 42 | bool enabled() const; 43 | 44 | //* enable 45 | void setEnabled(bool); 46 | 47 | //* widget rects 48 | void setDrawWidgetRects(bool value) 49 | { 50 | _drawWidgetRects = value; 51 | } 52 | 53 | //* event filter 54 | virtual bool eventFilter(QObject *object, QEvent *event); 55 | 56 | protected: 57 | //* event type 58 | QString eventType(const QEvent::Type &type) const; 59 | 60 | //* print widget information 61 | QString widgetInformation(const QWidget *widget) const; 62 | 63 | private: 64 | //* enable state 65 | bool _enabled; 66 | 67 | //* widget rects 68 | bool _drawWidgetRects; 69 | 70 | //* map event types to string 71 | QMap _eventTypes; 72 | }; 73 | 74 | } // namespace Adwaita 75 | 76 | #endif // ADWAITA_WIDGET_EXPLORER_H 77 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaanimation.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaanimation.h" 21 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaanimation.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_ANIMATION_H 21 | #define ADWAITA_ANIMATION_H 22 | 23 | #include "adwaita.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | #include 27 | #include 28 | 29 | namespace Adwaita 30 | { 31 | class ADWAITAQT_EXPORT Animation : public QPropertyAnimation 32 | { 33 | Q_OBJECT 34 | public: 35 | //* convenience 36 | using Pointer = WeakPointer; 37 | 38 | //* constructor 39 | Animation(int duration, QObject *parent) 40 | : QPropertyAnimation(parent) 41 | { 42 | setDuration(duration); 43 | } 44 | 45 | //* destructor 46 | virtual ~Animation() = default; 47 | 48 | //* true if running 49 | bool isRunning() const 50 | { 51 | return state() == Animation::Running; 52 | } 53 | 54 | //* restart 55 | void restart() 56 | { 57 | if (isRunning()) { 58 | stop(); 59 | } 60 | 61 | start(); 62 | } 63 | }; 64 | 65 | } // namespace Adwaita 66 | 67 | #endif // ADWAITA_ANIMATION_H 68 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaanimationdata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaanimationdata.h" 21 | 22 | namespace Adwaita 23 | { 24 | 25 | const qreal AnimationData::OpacityInvalid = -1; 26 | int AnimationData::_steps = 0; 27 | 28 | //_________________________________________________________________________________ 29 | void AnimationData::setupAnimation(const Animation::Pointer &animation, const QByteArray &property) 30 | { 31 | // setup animation 32 | animation.data()->setStartValue(0.0); 33 | animation.data()->setEndValue(1.0); 34 | animation.data()->setTargetObject(this); 35 | animation.data()->setPropertyName(property); 36 | } 37 | 38 | } // namespace Adwaita 39 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaanimationdata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_ANIMATION_DATA_H 21 | #define ADWAITA_ANIMATION_DATA_H 22 | 23 | #include "adwaitaanimation.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace Adwaita 33 | { 34 | //* base class 35 | class ADWAITAQT_EXPORT AnimationData : public QObject 36 | { 37 | Q_OBJECT 38 | public: 39 | //* constructor 40 | AnimationData(QObject *parent, QWidget *target) 41 | : QObject(parent) 42 | , _target(target) 43 | , _enabled(true) 44 | { 45 | Q_ASSERT(_target); 46 | } 47 | 48 | //* destructor 49 | virtual ~AnimationData() 50 | { 51 | } 52 | 53 | //* duration 54 | virtual void setDuration(int) = 0; 55 | 56 | //* steps 57 | static void setSteps(int value) 58 | { 59 | _steps = value; 60 | } 61 | 62 | //* enability 63 | virtual bool enabled() const 64 | { 65 | return _enabled; 66 | } 67 | 68 | //* enability 69 | virtual void setEnabled(bool value) 70 | { 71 | _enabled = value; 72 | } 73 | 74 | //* target 75 | const WeakPointer &target() const 76 | { 77 | return _target; 78 | } 79 | 80 | //* invalid opacity 81 | static const qreal OpacityInvalid; 82 | 83 | protected: 84 | //* setup animation 85 | virtual void setupAnimation(const Animation::Pointer &animation, const QByteArray &property); 86 | 87 | //* apply step 88 | virtual qreal digitize(const qreal &value) const 89 | { 90 | if (_steps > 0) { 91 | return std::floor(value * _steps) / _steps; 92 | } else { 93 | return value; 94 | } 95 | } 96 | 97 | //* trigger target update 98 | virtual void setDirty() const 99 | { 100 | if (_target) { 101 | _target.data()->update(); 102 | } 103 | } 104 | 105 | private: 106 | //* guarded target 107 | WeakPointer _target; 108 | 109 | //* enability 110 | bool _enabled; 111 | 112 | //* steps 113 | static int _steps; 114 | }; 115 | 116 | } // namespace Adwaita 117 | 118 | #endif // ADWAITA_ANIMATION_DATA_H 119 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitabaseengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitabaseengine.h" 21 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitabaseengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_BASE_ENGINE_H 21 | #define ADWAITA_BASE_ENGINE_H 22 | 23 | #include "adwaita.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | #include 27 | #include 28 | 29 | namespace Adwaita 30 | { 31 | //* base class for all animation engines 32 | /** it is used to store configuration values used by all animations stored in the engine */ 33 | class ADWAITAQT_EXPORT BaseEngine : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | using Pointer = WeakPointer; 38 | 39 | //* constructor 40 | explicit BaseEngine(QObject *parent) 41 | : QObject(parent) 42 | , _enabled(true) 43 | , _duration(200) 44 | { 45 | } 46 | 47 | //* destructor 48 | virtual ~BaseEngine() 49 | { 50 | } 51 | 52 | //* enability 53 | virtual void setEnabled(bool value) 54 | { 55 | _enabled = value; 56 | } 57 | 58 | //* enability 59 | virtual bool enabled() const 60 | { 61 | return _enabled; 62 | } 63 | 64 | //* duration 65 | virtual void setDuration(int value) 66 | { 67 | _duration = value; 68 | } 69 | 70 | //* duration 71 | virtual int duration() const 72 | { 73 | return _duration; 74 | } 75 | 76 | //* unregister widget 77 | virtual bool unregisterWidget(QObject *object) = 0; 78 | 79 | //* list of widgets 80 | using WidgetList = QSet; 81 | 82 | //* returns registered widgets 83 | virtual WidgetList registeredWidgets() const 84 | { 85 | return WidgetList(); 86 | } 87 | 88 | private: 89 | //* engine enability 90 | bool _enabled; 91 | 92 | //* animation duration 93 | int _duration; 94 | }; 95 | 96 | } // namespace Adwaita 97 | 98 | #endif // ADWAITA_BASE_ENGINE_H 99 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitabusyindicatordata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitabusyindicatordata.h" 21 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitabusyindicatordata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_BUSY_INDICATOR_DATA_ 21 | #define ADWAITA_BUSY_INDICATOR_DATA_ 22 | 23 | #include "adwaitaqt_export.h" 24 | 25 | #include 26 | 27 | namespace Adwaita 28 | { 29 | class ADWAITAQT_EXPORT BusyIndicatorData : public QObject 30 | { 31 | Q_OBJECT 32 | public: 33 | //* constructor 34 | explicit BusyIndicatorData(QObject *parent) 35 | : QObject(parent) 36 | , _animated(false) 37 | { 38 | } 39 | 40 | //* destructor 41 | virtual ~BusyIndicatorData() 42 | { 43 | } 44 | 45 | //*@name accessors 46 | //@{ 47 | 48 | //* animated 49 | bool isAnimated() const 50 | { 51 | return _animated; 52 | } 53 | 54 | //@} 55 | 56 | //*@name modifiers 57 | //@{ 58 | 59 | //* enabled 60 | void setEnabled(bool) 61 | { 62 | } 63 | 64 | //* enabled 65 | void setDuration(int) 66 | { 67 | } 68 | 69 | //* animated 70 | void setAnimated(bool value) 71 | { 72 | _animated = value; 73 | } 74 | 75 | //@} 76 | 77 | private: 78 | //* animated 79 | bool _animated; 80 | }; 81 | 82 | } // namespace Adwaita 83 | 84 | #endif // ADWAITA_BUSY_INDICATOR_DATA_ 85 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitabusyindicatorengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_BUSY_INDICATOR_ENGINE_H 21 | #define ADWAITA_BUSY_INDICATOR_ENGINE_H 22 | 23 | #include "adwaitaanimation.h" 24 | #include "adwaitabaseengine.h" 25 | #include "adwaitabusyindicatordata.h" 26 | #include "adwaitadatamap.h" 27 | #include "adwaitaqt_export.h" 28 | 29 | namespace Adwaita 30 | { 31 | //* handles progress bar animations 32 | class ADWAITAQT_EXPORT BusyIndicatorEngine : public BaseEngine 33 | { 34 | Q_OBJECT 35 | 36 | //* declare opacity property 37 | Q_PROPERTY(int value READ value WRITE setValue) 38 | 39 | public: 40 | //* constructor 41 | explicit BusyIndicatorEngine(QObject *); 42 | 43 | //* destructor 44 | virtual ~BusyIndicatorEngine() 45 | { 46 | } 47 | 48 | //*@name accessors 49 | //@{ 50 | 51 | //* true if widget is animated 52 | virtual bool isAnimated(const QObject *); 53 | 54 | //* value 55 | virtual int value() const 56 | { 57 | return _value; 58 | } 59 | 60 | //@} 61 | 62 | //*@name modifiers 63 | //@{ 64 | 65 | //* register progressbar 66 | virtual bool registerWidget(QObject *); 67 | 68 | //* duration 69 | virtual void setDuration(int); 70 | 71 | //* set object as animated 72 | virtual void setAnimated(const QObject *, bool); 73 | 74 | //* opacity 75 | virtual void setValue(int value); 76 | 77 | //@} 78 | 79 | public Q_SLOTS: 80 | 81 | //* remove widget from map 82 | virtual bool unregisterWidget(QObject *); 83 | 84 | protected: 85 | //* returns data associated to widget 86 | DataMap::Value data(const QObject *); 87 | 88 | private: 89 | //* map widgets to progressbar data 90 | DataMap _data; 91 | 92 | //* animation 93 | Animation::Pointer _animation; 94 | 95 | //* value 96 | int _value = 0; 97 | }; 98 | 99 | } // namespace Adwaita 100 | 101 | #endif // ADWAITA_BUSY_INDICATOR_ENGINE_H 102 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitadialdata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitadialdata.h" 21 | 22 | #include 23 | #include 24 | 25 | namespace Adwaita 26 | { 27 | 28 | //______________________________________________ 29 | DialData::DialData(QObject *parent, QWidget *target, int duration) 30 | : WidgetStateData(parent, target, duration) 31 | , _position(-1, -1) 32 | { 33 | target->installEventFilter(this); 34 | } 35 | 36 | //______________________________________________ 37 | bool DialData::eventFilter(QObject *object, QEvent *event) 38 | { 39 | if (object != target().data()) { 40 | return WidgetStateData::eventFilter(object, event); 41 | } 42 | 43 | // check event type 44 | switch (event->type()) { 45 | case QEvent::HoverEnter: 46 | case QEvent::HoverMove: 47 | hoverMoveEvent(object, event); 48 | break; 49 | case QEvent::HoverLeave: 50 | hoverLeaveEvent(object, event); 51 | break; 52 | default: 53 | break; 54 | } 55 | 56 | return WidgetStateData::eventFilter(object, event); 57 | } 58 | 59 | //______________________________________________ 60 | void DialData::hoverMoveEvent(QObject *object, QEvent *event) 61 | { 62 | // try cast object to dial 63 | QDial *scrollBar(qobject_cast(object)); 64 | if (!scrollBar || scrollBar->isSliderDown()) { 65 | return; 66 | } 67 | 68 | // cast event 69 | QHoverEvent *hoverEvent = static_cast(event); 70 | 71 | // store position 72 | #if QT_VERSION >= 0x060000 73 | _position = hoverEvent->position().toPoint(); 74 | #else 75 | _position = hoverEvent->pos(); 76 | #endif 77 | 78 | // trigger animation if position match handle rect 79 | updateState(_handleRect.contains(_position)); 80 | } 81 | 82 | //______________________________________________ 83 | void DialData::hoverLeaveEvent(QObject *, QEvent *) 84 | { 85 | // reset hover state 86 | updateState(false); 87 | 88 | // reset mouse position 89 | _position = QPoint(-1, -1); 90 | } 91 | 92 | } // namespace Adwaita 93 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitadialdata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_DIAL_DATA_H 21 | #define ADWAITA_DIAL_DATA_H 22 | 23 | #include "adwaitawidgetstatedata.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | namespace Adwaita 27 | { 28 | //* dial data 29 | class ADWAITAQT_EXPORT DialData : public WidgetStateData 30 | { 31 | Q_OBJECT 32 | public: 33 | //* constructor 34 | DialData(QObject *parent, QWidget *target, int); 35 | 36 | //* destructor 37 | virtual ~DialData() 38 | { 39 | } 40 | 41 | //* event filter 42 | virtual bool eventFilter(QObject *, QEvent *); 43 | 44 | //* subcontrol rect 45 | virtual void setHandleRect(const QRect &rect) 46 | { 47 | _handleRect = rect; 48 | } 49 | 50 | //* mouse position 51 | QPoint position() const 52 | { 53 | return _position; 54 | } 55 | 56 | protected: 57 | //* hoverMoveEvent 58 | virtual void hoverMoveEvent(QObject *, QEvent *); 59 | 60 | //* hoverMoveEvent 61 | virtual void hoverLeaveEvent(QObject *, QEvent *); 62 | 63 | private: 64 | //* rect 65 | QRect _handleRect; 66 | 67 | //* mouse position 68 | QPoint _position; 69 | }; 70 | 71 | } // namespace Adwaita 72 | 73 | #endif // ADWAITA_DIAL_DATA_H 74 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitadialengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitadialengine.h" 21 | 22 | #include 23 | 24 | namespace Adwaita 25 | { 26 | 27 | //____________________________________________________________ 28 | bool DialEngine::registerWidget(QWidget *widget, AnimationModes mode) 29 | { 30 | // check widget 31 | if (!widget) { 32 | return false; 33 | } 34 | 35 | // only handle hover and focus 36 | if (mode & AnimationHover && !dataMap(AnimationHover).contains(widget)) { 37 | dataMap(AnimationHover).insert(widget, new DialData(this, widget, duration()), enabled()); 38 | } 39 | if (mode & AnimationFocus && !dataMap(AnimationFocus).contains(widget)) { 40 | dataMap(AnimationFocus).insert(widget, new WidgetStateData(this, widget, duration()), enabled()); 41 | } 42 | 43 | // connect destruction signal 44 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection); 45 | 46 | return true; 47 | } 48 | 49 | } // namespace Adwaita 50 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitadialengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_DIAL_ENGINE_H 21 | #define ADWAITA_DIAL_ENGINE_H 22 | 23 | #include "adwaitadialdata.h" 24 | #include "adwaitawidgetstateengine.h" 25 | #include "adwaitaqt_export.h" 26 | 27 | namespace Adwaita 28 | { 29 | //* stores dial hovered action and timeLine 30 | class ADWAITAQT_EXPORT DialEngine : public WidgetStateEngine 31 | { 32 | Q_OBJECT 33 | public: 34 | //* constructor 35 | explicit DialEngine(QObject *parent) 36 | : WidgetStateEngine(parent) 37 | { 38 | } 39 | 40 | //* destructor 41 | virtual ~DialEngine() 42 | { 43 | } 44 | 45 | //* register dial 46 | virtual bool registerWidget(QWidget *, AnimationModes); 47 | 48 | //* control rect 49 | virtual void setHandleRect(const QObject *object, const QRect &rect) 50 | { 51 | if (DataMap::Value data = this->data(object, AnimationHover)) { 52 | static_cast(data.data())->setHandleRect(rect); 53 | } 54 | } 55 | 56 | //* mouse position 57 | virtual QPoint position(const QObject *object) 58 | { 59 | if (DataMap::Value data = this->data(object, AnimationHover)) { 60 | return static_cast(data.data())->position(); 61 | } else { 62 | return QPoint(-1, -1); 63 | } 64 | } 65 | }; 66 | 67 | } // namespace Adwaita 68 | 69 | #endif // ADWAITA_DIAL_ENGINE_H 70 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaenabledata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaenabledata.h" 21 | 22 | namespace Adwaita 23 | { 24 | 25 | //______________________________________________ 26 | bool EnableData::eventFilter(QObject *object, QEvent *event) 27 | { 28 | if (!enabled()) { 29 | return WidgetStateData::eventFilter(object, event); 30 | } 31 | 32 | // check event type 33 | switch (event->type()) { 34 | // enter event 35 | case QEvent::EnabledChange: { 36 | if (QWidget *widget = qobject_cast(object)) { 37 | updateState(widget->isEnabled()); 38 | } 39 | break; 40 | } 41 | default: 42 | break; 43 | } 44 | 45 | return WidgetStateData::eventFilter(object, event); 46 | } 47 | 48 | } // namespace Adwaita 49 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaenabledata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_ENABLE_DATA_H 21 | #define ADWAITA_ENABLE_DATA_H 22 | 23 | #include "adwaitawidgetstatedata.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | namespace Adwaita 27 | { 28 | //* Enable data 29 | class ADWAITAQT_EXPORT EnableData : public WidgetStateData 30 | { 31 | Q_OBJECT 32 | public: 33 | //* constructor 34 | EnableData(QObject *parent, QWidget *target, int duration, bool state = true) 35 | : WidgetStateData(parent, target, duration, state) 36 | { 37 | target->installEventFilter(this); 38 | } 39 | 40 | //* destructor 41 | virtual ~EnableData() 42 | { 43 | } 44 | 45 | //* event filter 46 | virtual bool eventFilter(QObject *, QEvent *); 47 | }; 48 | 49 | } // namespace Adwaita 50 | 51 | #endif // ADWAITA_ENABLE_DATA_H 52 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitagenericdata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitagenericdata.h" 21 | 22 | #include 23 | 24 | namespace Adwaita 25 | { 26 | 27 | //______________________________________________ 28 | GenericData::GenericData(QObject *parent, QWidget *target, int duration) 29 | : AnimationData(parent, target) 30 | , _animation(new Animation(duration, this)) 31 | , _opacity(0) 32 | { 33 | setupAnimation(_animation, "opacity"); 34 | } 35 | 36 | } // namespace Adwaita 37 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitagenericdata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_GENERIC_DATA_H 21 | #define ADWAITA_GENERIC_DATA_H 22 | 23 | #include "adwaitaanimation.h" 24 | #include "adwaitaanimationdata.h" 25 | #include "adwaitaqt_export.h" 26 | 27 | #include 28 | #include 29 | 30 | namespace Adwaita 31 | { 32 | //* generic data 33 | class ADWAITAQT_EXPORT GenericData : public AnimationData 34 | { 35 | Q_OBJECT 36 | 37 | //* declare opacity property 38 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) 39 | 40 | public: 41 | //* constructor 42 | GenericData(QObject *parent, QWidget *widget, int duration); 43 | 44 | //* destructor 45 | virtual ~GenericData() 46 | { 47 | } 48 | 49 | //* return animation object 50 | virtual const Animation::Pointer &animation() const 51 | { 52 | return _animation; 53 | } 54 | 55 | //* duration 56 | virtual void setDuration(int duration) 57 | { 58 | _animation.data()->setDuration(duration); 59 | } 60 | 61 | //* opacity 62 | virtual qreal opacity() const 63 | { 64 | return _opacity; 65 | } 66 | 67 | //* opacity 68 | virtual void setOpacity(qreal value) 69 | { 70 | value = digitize(value); 71 | if (_opacity == value) { 72 | return; 73 | } 74 | 75 | _opacity = value; 76 | setDirty(); 77 | } 78 | 79 | private: 80 | //* animation handling 81 | Animation::Pointer _animation; 82 | 83 | //* opacity variable 84 | qreal _opacity; 85 | }; 86 | 87 | } // namespace Adwaita 88 | 89 | #endif // ADWAITA_GENERIC_DATA_H 90 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaheaderviewdata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_HEADER_VIEW_DATA_H 21 | #define ADWAITA_HEADER_VIEW_DATA_H 22 | 23 | #include "adwaitaanimationdata.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | #include 27 | 28 | namespace Adwaita 29 | { 30 | //* headerviews 31 | class ADWAITAQT_EXPORT HeaderViewData : public AnimationData 32 | { 33 | Q_OBJECT 34 | 35 | //* declare opacity property 36 | Q_PROPERTY(qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity) 37 | Q_PROPERTY(qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity) 38 | public: 39 | //* constructor 40 | HeaderViewData(QObject *parent, QWidget *target, int duration); 41 | 42 | //* destructor 43 | virtual ~HeaderViewData() 44 | { 45 | } 46 | 47 | //* duration 48 | void setDuration(int duration) 49 | { 50 | currentIndexAnimation().data()->setDuration(duration); 51 | previousIndexAnimation().data()->setDuration(duration); 52 | } 53 | 54 | //* update state 55 | bool updateState(const QPoint &, bool); 56 | 57 | //*@name current index handling 58 | //@{ 59 | 60 | //* current opacity 61 | virtual qreal currentOpacity() const 62 | { 63 | return _current._opacity; 64 | } 65 | 66 | //* current opacity 67 | virtual void setCurrentOpacity(qreal value) 68 | { 69 | value = digitize(value); 70 | if (_current._opacity == value) { 71 | return; 72 | } 73 | 74 | _current._opacity = value; 75 | setDirty(); 76 | } 77 | 78 | //* current index 79 | virtual int currentIndex() const 80 | { 81 | return _current._index; 82 | } 83 | 84 | //* current index 85 | virtual void setCurrentIndex(int index) 86 | { 87 | _current._index = index; 88 | } 89 | 90 | //* current index animation 91 | virtual const Animation::Pointer ¤tIndexAnimation() const 92 | { 93 | return _current._animation; 94 | } 95 | 96 | //@} 97 | 98 | //*@name previous index handling 99 | //@{ 100 | 101 | //* previous opacity 102 | virtual qreal previousOpacity() const 103 | { 104 | return _previous._opacity; 105 | } 106 | 107 | //* previous opacity 108 | virtual void setPreviousOpacity(qreal value) 109 | { 110 | value = digitize(value); 111 | if (_previous._opacity == value) { 112 | return; 113 | } 114 | 115 | _previous._opacity = value; 116 | setDirty(); 117 | } 118 | 119 | //* previous index 120 | virtual int previousIndex() const 121 | { 122 | return _previous._index; 123 | } 124 | 125 | //* previous index 126 | virtual void setPreviousIndex(int index) 127 | { 128 | _previous._index = index; 129 | } 130 | 131 | //* previous index Animation 132 | virtual const Animation::Pointer &previousIndexAnimation() const 133 | { 134 | return _previous._animation; 135 | } 136 | 137 | //@} 138 | 139 | //* return Animation associated to action at given position, if any 140 | virtual Animation::Pointer animation(const QPoint &position) const; 141 | 142 | //* return opacity associated to action at given position, if any 143 | virtual qreal opacity(const QPoint &position) const; 144 | 145 | protected: 146 | //* dirty 147 | virtual void setDirty() const; 148 | 149 | private: 150 | //* container for needed animation data 151 | class Data 152 | { 153 | public: 154 | //* default constructor 155 | Data() 156 | : _opacity(0) 157 | , _index(-1) 158 | { 159 | } 160 | 161 | Animation::Pointer _animation; 162 | qreal _opacity; 163 | int _index; 164 | }; 165 | 166 | //* current tab animation data (for hover enter animations) 167 | Data _current; 168 | 169 | //* previous tab animations data (for hover leave animations) 170 | Data _previous; 171 | }; 172 | 173 | } // namespace Adwaita 174 | 175 | #endif // ADWAITA_HEADER_VIEW_DATA_H 176 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaheaderviewengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaheaderviewengine.h" 21 | 22 | #include 23 | 24 | namespace Adwaita 25 | { 26 | 27 | //____________________________________________________________ 28 | bool HeaderViewEngine::registerWidget(QWidget *widget) 29 | { 30 | if (!widget) { 31 | return false; 32 | } 33 | 34 | // create new data class 35 | if (!_data.contains(widget)) { 36 | _data.insert(widget, new HeaderViewData(this, widget, duration()), enabled()); 37 | } 38 | 39 | // connect destruction signal 40 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection); 41 | return true; 42 | } 43 | 44 | //____________________________________________________________ 45 | bool HeaderViewEngine::updateState(const QObject *object, const QPoint &position, bool value) 46 | { 47 | DataMap::Value data(_data.find(object)); 48 | return (data && data.data()->updateState(position, value)); 49 | } 50 | 51 | } // namespace Adwaita 52 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaheaderviewengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_HEADER_VIEW_ENGINE_H 21 | #define ADWAITA_HEADER_VIEW_ENGINE_H 22 | 23 | #include "adwaitabaseengine.h" 24 | #include "adwaitadatamap.h" 25 | #include "adwaitaheaderviewdata.h" 26 | #include "adwaitaqt_export.h" 27 | 28 | namespace Adwaita 29 | { 30 | //* stores headerview hovered action and timeLine 31 | class ADWAITAQT_EXPORT HeaderViewEngine : public BaseEngine 32 | { 33 | Q_OBJECT 34 | public: 35 | //* constructor 36 | explicit HeaderViewEngine(QObject *parent) 37 | : BaseEngine(parent) 38 | { 39 | } 40 | 41 | //* destructor 42 | virtual ~HeaderViewEngine() 43 | { 44 | } 45 | 46 | //* register headerview 47 | virtual bool registerWidget(QWidget *); 48 | 49 | //* true if widget hover state is changed 50 | virtual bool updateState(const QObject *, const QPoint &, bool); 51 | 52 | //* true if widget is animated 53 | virtual bool isAnimated(const QObject *object, const QPoint &point) 54 | { 55 | if (DataMap::Value data = _data.find(object)) { 56 | if (Animation::Pointer animation = data.data()->animation(point)) { 57 | return animation.data()->isRunning(); 58 | } 59 | } 60 | 61 | return false; 62 | } 63 | 64 | //* animation opacity 65 | virtual qreal opacity(const QObject *object, const QPoint &point) 66 | { 67 | return isAnimated(object, point) ? _data.find(object).data()->opacity(point) : AnimationData::OpacityInvalid; 68 | } 69 | 70 | //* enability 71 | virtual void setEnabled(bool value) 72 | { 73 | BaseEngine::setEnabled(value); 74 | _data.setEnabled(value); 75 | } 76 | 77 | //* duration 78 | virtual void setDuration(int value) 79 | { 80 | BaseEngine::setDuration(value); 81 | _data.setDuration(value); 82 | } 83 | 84 | public Q_SLOTS: 85 | 86 | //* remove widget from map 87 | virtual bool unregisterWidget(QObject *object) 88 | { 89 | return _data.unregisterWidget(object); 90 | } 91 | 92 | private: 93 | //* data map 94 | DataMap _data; 95 | }; 96 | 97 | } // namespace 98 | 99 | #endif // ADWAITA_HEADER_VIEW_ENGINE_H 100 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitascrollbarengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitascrollbarengine.h" 21 | 22 | #include 23 | 24 | namespace Adwaita 25 | { 26 | 27 | //____________________________________________________________ 28 | bool ScrollBarEngine::registerWidget(QWidget *widget, AnimationModes mode) 29 | { 30 | // check widget 31 | if (!widget) return false; 32 | 33 | // only handle hover and focus 34 | if (mode & AnimationHover && !dataMap(AnimationHover).contains(widget)) { 35 | dataMap(AnimationHover).insert(widget, new ScrollBarData(this, widget, duration()), enabled()); 36 | } 37 | if (mode & AnimationFocus && !dataMap(AnimationFocus).contains(widget)) { 38 | dataMap(AnimationFocus).insert(widget, new WidgetStateData(this, widget, duration()), enabled()); 39 | } 40 | 41 | // connect destruction signal 42 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection); 43 | 44 | return true; 45 | } 46 | 47 | //____________________________________________________________ 48 | bool ScrollBarEngine::isAnimated(const QObject *object, AnimationMode mode, QStyle::SubControl control) 49 | { 50 | if (mode == AnimationHover) { 51 | if (DataMap::Value data = this->data(object, AnimationHover)) { 52 | const ScrollBarData *scrollBarData(static_cast(data.data())); 53 | Animation::Pointer animation = scrollBarData->animation(control); 54 | return animation.data()->isRunning(); 55 | } else { 56 | return false; 57 | } 58 | } else if (control == QStyle::SC_ScrollBarSlider) { 59 | return WidgetStateEngine::isAnimated(object, mode); 60 | } else { 61 | return false; 62 | } 63 | } 64 | 65 | //____________________________________________________________ 66 | AnimationMode ScrollBarEngine::animationMode(const QObject *object, QStyle::SubControl control) 67 | { 68 | 69 | // enable state 70 | if (isAnimated(object, AnimationHover, control)) { 71 | return AnimationHover; 72 | } else if (isAnimated(object, AnimationFocus, control)) { 73 | return AnimationFocus; 74 | } else if (isAnimated(object, AnimationPressed, control)) { 75 | return AnimationPressed; 76 | } else { 77 | return AnimationNone; 78 | } 79 | } 80 | 81 | //____________________________________________________________ 82 | qreal ScrollBarEngine::opacity(const QObject *object, QStyle::SubControl control) 83 | { 84 | if (isAnimated(object, AnimationHover, control)) { 85 | return static_cast(data(object, AnimationHover).data())->opacity(control); 86 | } else if (control == QStyle::SC_ScrollBarSlider) { 87 | return WidgetStateEngine::buttonOpacity(object); 88 | } 89 | return AnimationData::OpacityInvalid; 90 | } 91 | 92 | } // namespace Adwaita 93 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitascrollbarengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_SCROLLBAR_ENGINE_H 21 | #define ADWAITA_SCROLLBAR_ENGINE_H 22 | 23 | #include "adwaitascrollbardata.h" 24 | #include "adwaitawidgetstateengine.h" 25 | #include "adwaitaqt_export.h" 26 | 27 | namespace Adwaita 28 | { 29 | //* stores scrollbar hovered action and timeLine 30 | class ADWAITAQT_EXPORT ScrollBarEngine : public WidgetStateEngine 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | //* constructor 36 | explicit ScrollBarEngine(QObject *parent) 37 | : WidgetStateEngine(parent) 38 | { 39 | } 40 | 41 | //* destructor 42 | virtual ~ScrollBarEngine() 43 | { 44 | } 45 | 46 | //* register scrollbar 47 | virtual bool registerWidget(QWidget *, AnimationModes); 48 | 49 | //*@name accessors 50 | //@{ 51 | 52 | using WidgetStateEngine::isAnimated; 53 | using WidgetStateEngine::opacity; 54 | 55 | //* true if widget is animated 56 | virtual bool isAnimated(const QObject *, AnimationMode, QStyle::SubControl control); 57 | 58 | //* true if widget is animated 59 | virtual AnimationMode animationMode(const QObject *object, QStyle::SubControl control); 60 | 61 | //* animation opacity 62 | virtual qreal opacity(const QObject *object, QStyle::SubControl control); 63 | 64 | //* return true if given subcontrol is hovered 65 | virtual bool isHovered(const QObject *object, QStyle::SubControl control) 66 | { 67 | if (DataMap::Value data = this->data(object, AnimationHover)) { 68 | return static_cast(data.data())->isHovered(control); 69 | } else { 70 | return false; 71 | } 72 | } 73 | 74 | //* control rect associated to object 75 | virtual QRect subControlRect(const QObject *object, QStyle::SubControl control) 76 | { 77 | if (DataMap::Value data = this->data(object, AnimationHover)) { 78 | return static_cast(data.data())->subControlRect(control); 79 | } else { 80 | return QRect(); 81 | } 82 | } 83 | 84 | //* mouse position 85 | virtual QPoint position(const QObject *object) 86 | { 87 | if (DataMap::Value data = this->data(object, AnimationHover)) { 88 | return static_cast(data.data())->position(); 89 | } else { 90 | return QPoint(-1, -1); 91 | } 92 | } 93 | 94 | //@} 95 | 96 | //*@name modifiers 97 | //@{ 98 | 99 | //* control rect 100 | virtual void setSubControlRect(const QObject *object, QStyle::SubControl control, const QRect &rect) 101 | { 102 | if (DataMap::Value data = this->data(object, AnimationHover)) { 103 | static_cast(data.data())->setSubControlRect(control, rect); 104 | } 105 | } 106 | 107 | //@} 108 | }; 109 | 110 | } // namespace Adwaita 111 | 112 | #endif // ADWAITA_SCROLLBAR_ENGINE_H 113 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaspinboxdata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaspinboxdata.h" 21 | 22 | namespace Adwaita 23 | { 24 | 25 | //________________________________________________ 26 | SpinBoxData::SpinBoxData(QObject *parent, QWidget *target, int duration) 27 | : AnimationData(parent, target) 28 | { 29 | _upArrowData._hoverAnimation = new Animation(duration, this); 30 | _downArrowData._hoverAnimation = new Animation(duration, this); 31 | _upArrowData._pressedAnimation = new Animation(duration, this); 32 | _downArrowData._pressedAnimation = new Animation(duration, this); 33 | setupAnimation(upArrowAnimation(), "upArrowOpacity"); 34 | setupAnimation(downArrowAnimation(), "downArrowOpacity"); 35 | setupAnimation(upArrowPressedAnimation(), "upArrowPressed"); 36 | setupAnimation(downArrowPressedAnimation(), "downArrowPressed"); 37 | } 38 | 39 | //______________________________________________ 40 | bool SpinBoxData::Data::updateState(bool value, bool pressed) 41 | { 42 | bool change = false; 43 | if (_hoverState != value) { 44 | _hoverState = value; 45 | _hoverAnimation.data()->setDirection((_hoverState) ? Animation::Forward : Animation::Backward); 46 | if (!_hoverAnimation.data()->isRunning()) { 47 | _hoverAnimation.data()->start(); 48 | } 49 | change = true; 50 | } 51 | 52 | if (_pressedState != pressed) { 53 | _pressedState = pressed; 54 | _pressedAnimation.data()->setDirection((_pressedState) ? Animation::Forward : Animation::Backward); 55 | if (!_pressedAnimation.data()->isRunning()) { 56 | _pressedAnimation.data()->start(); 57 | } 58 | change = true; 59 | } 60 | 61 | return change; 62 | } 63 | 64 | } // namespace Adwaita 65 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaspinboxengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitaspinboxengine.h" 21 | 22 | #include 23 | 24 | namespace Adwaita 25 | { 26 | 27 | //____________________________________________________________ 28 | bool SpinBoxEngine::registerWidget(QWidget *widget) 29 | { 30 | if (!widget) { 31 | return false; 32 | } 33 | 34 | // create new data class 35 | if (!_data.contains(widget)) { 36 | _data.insert(widget, new SpinBoxData(this, widget, duration()), enabled()); 37 | } 38 | 39 | // connect destruction signal 40 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection); 41 | return true; 42 | } 43 | 44 | } // namespace Adwaita 45 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitaspinboxengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_SPINBOX_ENGINE_H 21 | #define ADWAITA_SPINBOX_ENGINE_H 22 | 23 | #include "adwaitabaseengine.h" 24 | #include "adwaitadatamap.h" 25 | #include "adwaitaspinboxdata.h" 26 | #include "adwaitaqt_export.h" 27 | 28 | namespace Adwaita 29 | { 30 | //* handle spinbox arrows hover effect 31 | class ADWAITAQT_EXPORT SpinBoxEngine : public BaseEngine 32 | { 33 | Q_OBJECT 34 | public: 35 | //* constructor 36 | explicit SpinBoxEngine(QObject *parent) 37 | : BaseEngine(parent) 38 | { 39 | } 40 | 41 | //* destructor 42 | virtual ~SpinBoxEngine() 43 | { 44 | } 45 | 46 | //* register widget 47 | virtual bool registerWidget(QWidget *); 48 | 49 | //* state 50 | virtual bool updateState(const QObject *object, QStyle::SubControl subControl, bool value, bool pressed) 51 | { 52 | if (DataMap::Value data = _data.find(object)) { 53 | return data.data()->updateState(subControl, value, pressed); 54 | } else { 55 | return false; 56 | } 57 | } 58 | 59 | //* true if widget is animated 60 | virtual bool isAnimated(const QObject *object, QStyle::SubControl subControl) 61 | { 62 | if (DataMap::Value data = _data.find(object)) { 63 | return data.data()->isAnimated(subControl); 64 | } else { 65 | return false; 66 | } 67 | } 68 | 69 | //* animation opacity 70 | virtual qreal opacity(const QObject *object, QStyle::SubControl subControl) 71 | { 72 | if (DataMap::Value data = _data.find(object)) { 73 | return data.data()->opacity(subControl); 74 | } else { 75 | return AnimationData::OpacityInvalid; 76 | } 77 | } 78 | 79 | //* animation opacity 80 | virtual qreal pressed(const QObject *object, QStyle::SubControl subControl) 81 | { 82 | if (DataMap::Value data = _data.find(object)) { 83 | return data.data()->pressed(subControl); 84 | } else { 85 | return AnimationData::OpacityInvalid; 86 | } 87 | } 88 | 89 | //* enability 90 | virtual void setEnabled(bool value) 91 | { 92 | BaseEngine::setEnabled(value); 93 | _data.setEnabled(value); 94 | } 95 | 96 | //* duration 97 | virtual void setDuration(int value) 98 | { 99 | BaseEngine::setDuration(value); 100 | _data.setDuration(value); 101 | } 102 | 103 | public Q_SLOTS: 104 | 105 | //* remove widget from map 106 | virtual bool unregisterWidget(QObject *object) 107 | { 108 | return _data.unregisterWidget(object); 109 | } 110 | 111 | private: 112 | //* data map 113 | DataMap _data; 114 | }; 115 | 116 | } // namespace Adwaita 117 | 118 | #endif // ADWAITA_SPINBOX_ENGINE_H 119 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitastackedwidgetdata.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // adwaitastackedwidgetdata.cpp 3 | // data container for QStackedWidget transition 4 | // ------------------- 5 | // 6 | // Copyright (c) 2009 Hugo Pereira Da Costa 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to 10 | // deal in the Software without restriction, including without limitation the 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | // sell copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | // IN THE SOFTWARE. 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "adwaitastackedwidgetdata.h" 28 | 29 | namespace Adwaita 30 | { 31 | 32 | //______________________________________________________ 33 | StackedWidgetData::StackedWidgetData(QObject *parent, QStackedWidget *target, int duration) 34 | : TransitionData(parent, target, duration) 35 | , _target(target) 36 | , _index(target->currentIndex()) 37 | { 38 | // configure transition 39 | connect(_target.data(), SIGNAL(destroyed()), SLOT(targetDestroyed())); 40 | connect(_target.data(), SIGNAL(currentChanged(int)), SLOT(animate())); 41 | 42 | // disable focus 43 | transition().data()->setAttribute(Qt::WA_NoMousePropagation, true); 44 | transition().data()->setFlag(TransitionWidget::PaintOnWidget, true); 45 | 46 | setMaxRenderTime(50); 47 | } 48 | 49 | //___________________________________________________________________ 50 | bool StackedWidgetData::initializeAnimation() 51 | { 52 | // check enability 53 | if (!(_target && _target.data()->isVisible())) { 54 | return false; 55 | } 56 | 57 | // check index 58 | if (_target.data()->currentIndex() == _index) { 59 | return false; 60 | } 61 | 62 | // do not animate if either index or currentIndex is not valid 63 | // but update _index none the less 64 | if (_target.data()->currentIndex() < 0 || _index < 0) { 65 | _index = _target.data()->currentIndex(); 66 | return false; 67 | } 68 | 69 | // get old widget (matching _index) and initialize transition 70 | if (QWidget *widget = _target.data()->widget(_index)) { 71 | transition().data()->setOpacity(0); 72 | startClock(); 73 | transition().data()->setGeometry(widget->geometry()); 74 | transition().data()->setStartPixmap(transition().data()->grab(widget)); 75 | 76 | _index = _target.data()->currentIndex(); 77 | return !slow(); 78 | } else { 79 | _index = _target.data()->currentIndex(); 80 | return false; 81 | } 82 | } 83 | 84 | //___________________________________________________________________ 85 | bool StackedWidgetData::animate() 86 | { 87 | // check enability 88 | if (!enabled()) { 89 | return false; 90 | } 91 | 92 | // initialize animation 93 | if (!initializeAnimation()) { 94 | return false; 95 | } 96 | 97 | // show transition widget 98 | transition().data()->show(); 99 | transition().data()->raise(); 100 | transition().data()->animate(); 101 | return true; 102 | } 103 | 104 | //___________________________________________________________________ 105 | void StackedWidgetData::finishAnimation() 106 | { 107 | // disable updates on currentWidget 108 | if (_target && _target.data()->currentWidget()) { 109 | _target.data()->currentWidget()->setUpdatesEnabled(false); 110 | } 111 | 112 | // hide transition 113 | transition().data()->hide(); 114 | 115 | // reenable updates and repaint 116 | if (_target && _target.data()->currentWidget()) { 117 | _target.data()->currentWidget()->setUpdatesEnabled(true); 118 | _target.data()->currentWidget()->repaint(); 119 | } 120 | 121 | // invalidate start widget 122 | transition().data()->resetStartPixmap(); 123 | } 124 | 125 | //___________________________________________________________________ 126 | void StackedWidgetData::targetDestroyed() 127 | { 128 | setEnabled(false); 129 | _target.clear(); 130 | } 131 | 132 | } // namespace Adwaita 133 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitastackedwidgetdata.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // adwaitastackedwidgetdata.h 3 | // data container for QStackedWidget transition 4 | // ------------------- 5 | // 6 | // Copyright (c) 2009 Hugo Pereira Da Costa 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to 10 | // deal in the Software without restriction, including without limitation the 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | // sell copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | // IN THE SOFTWARE. 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef ADWAITA_STACKEDWIDGET_DATA_H 28 | #define ADWAITA_STACKEDWIDGET_DATA_H 29 | 30 | #include "adwaitatransitiondata.h" 31 | #include "adwaitaqt_export.h" 32 | 33 | #include 34 | 35 | namespace Adwaita 36 | { 37 | //! generic data 38 | class ADWAITAQT_EXPORT StackedWidgetData : public TransitionData 39 | { 40 | Q_OBJECT 41 | 42 | public: 43 | //! constructor 44 | StackedWidgetData(QObject *, QStackedWidget *, int); 45 | 46 | //! destructor 47 | virtual ~StackedWidgetData() 48 | { 49 | } 50 | 51 | protected Q_SLOTS: 52 | 53 | //! initialize animation 54 | virtual bool initializeAnimation(); 55 | 56 | //! animate 57 | virtual bool animate(); 58 | 59 | //! finish animation 60 | virtual void finishAnimation(); 61 | 62 | //! called when target is destroyed 63 | virtual void targetDestroyed(); 64 | 65 | private: 66 | //! target 67 | WeakPointer _target; 68 | 69 | //! current index 70 | int _index; 71 | }; 72 | 73 | } // namespace Adwaita 74 | 75 | #endif // ADWAITA_STACKEDWIDGET_DATA_H 76 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitastackedwidgetengine.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // adwaitastackedwidgetengine.cpp 3 | // stores event filters and maps widgets to animations 4 | // ------------------- 5 | // 6 | // Copyright (c) 2009 Hugo Pereira Da Costa 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to 10 | // deal in the Software without restriction, including without limitation the 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | // sell copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | // IN THE SOFTWARE. 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "adwaitastackedwidgetengine.h" 28 | 29 | namespace Adwaita 30 | { 31 | 32 | //____________________________________________________________ 33 | bool StackedWidgetEngine::registerWidget(QStackedWidget *widget) 34 | { 35 | if (!widget) { 36 | return false; 37 | } 38 | 39 | if (!_data.contains(widget)) { 40 | _data.insert(widget, new StackedWidgetData(this, widget, duration()), enabled()); 41 | } 42 | 43 | // connect destruction signal 44 | disconnect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *))); 45 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *))); 46 | 47 | return true; 48 | } 49 | 50 | } // namespace Adwaita 51 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitastackedwidgetengine.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // adwaitastackedwidgetengine.h 3 | // stores event filters and maps widgets to animations 4 | // ------------------- 5 | // 6 | // Copyright (c) 2009 Hugo Pereira Da Costa 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to 10 | // deal in the Software without restriction, including without limitation the 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | // sell copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | // IN THE SOFTWARE. 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef ADWAITA_STACKEDWIDGET_ENGINE_H 28 | #define ADWAITA_STACKEDWIDGET_ENGINE_H 29 | 30 | #include "adwaitabaseengine.h" 31 | #include "adwaitadatamap.h" 32 | #include "adwaitastackedwidgetdata.h" 33 | #include "adwaitaqt_export.h" 34 | 35 | namespace Adwaita 36 | { 37 | //! used for simple widgets 38 | class ADWAITAQT_EXPORT StackedWidgetEngine : public BaseEngine 39 | { 40 | Q_OBJECT 41 | public: 42 | //! constructor 43 | explicit StackedWidgetEngine(QObject *parent) 44 | : BaseEngine(parent) 45 | { 46 | } 47 | 48 | //! destructor 49 | virtual ~StackedWidgetEngine() 50 | { 51 | } 52 | 53 | //! register widget 54 | virtual bool registerWidget(QStackedWidget *); 55 | 56 | //! duration 57 | virtual void setEnabled(bool value) 58 | { 59 | BaseEngine::setEnabled(value); 60 | _data.setEnabled(value); 61 | } 62 | 63 | //! duration 64 | virtual void setDuration(int value) 65 | { 66 | BaseEngine::setDuration(value); 67 | _data.setDuration(value); 68 | } 69 | 70 | public Q_SLOTS: 71 | 72 | //! remove widget from map 73 | virtual bool unregisterWidget(QObject *object) 74 | { 75 | return _data.unregisterWidget(object); 76 | } 77 | 78 | private: 79 | //! maps 80 | DataMap _data; 81 | }; 82 | 83 | } // namespace Adwaita 84 | 85 | #endif // ADWAITA_STACKEDWIDGET_ENGINE_H 86 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatabbardata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_TABBAR_DATA_H 21 | #define ADWAITA_TABBAR_DATA_H 22 | 23 | #include "adwaitaanimationdata.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | #include 27 | 28 | namespace Adwaita 29 | { 30 | //* tabbars 31 | class ADWAITAQT_EXPORT TabBarData : public AnimationData 32 | { 33 | Q_OBJECT 34 | 35 | //* declare opacity property 36 | Q_PROPERTY(qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity) 37 | Q_PROPERTY(qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity) 38 | public: 39 | //* constructor 40 | TabBarData(QObject *parent, QWidget *target, int duration); 41 | 42 | //* destructor 43 | virtual ~TabBarData() 44 | { 45 | } 46 | 47 | //* duration 48 | void setDuration(int duration) 49 | { 50 | currentIndexAnimation().data()->setDuration(duration); 51 | previousIndexAnimation().data()->setDuration(duration); 52 | } 53 | 54 | //* update state 55 | bool updateState(const QPoint &, bool); 56 | 57 | //*@name current index handling 58 | //@{ 59 | 60 | //* current opacity 61 | virtual qreal currentOpacity() const 62 | { 63 | return _current._opacity; 64 | } 65 | 66 | //* current opacity 67 | virtual void setCurrentOpacity(qreal value) 68 | { 69 | if (_current._opacity == value) { 70 | return; 71 | } 72 | 73 | _current._opacity = value; 74 | setDirty(); 75 | } 76 | 77 | //* current index 78 | virtual int currentIndex() const 79 | { 80 | return _current._index; 81 | } 82 | 83 | //* current index 84 | virtual void setCurrentIndex(int index) 85 | { 86 | _current._index = index; 87 | } 88 | 89 | //* current index animation 90 | virtual const Animation::Pointer ¤tIndexAnimation() const 91 | { 92 | return _current._animation; 93 | } 94 | 95 | //@} 96 | 97 | //*@name previous index handling 98 | //@{ 99 | 100 | //* previous opacity 101 | virtual qreal previousOpacity() const 102 | { 103 | return _previous._opacity; 104 | } 105 | 106 | //* previous opacity 107 | virtual void setPreviousOpacity(qreal value) 108 | { 109 | if (_previous._opacity == value) { 110 | return; 111 | } 112 | 113 | _previous._opacity = value; 114 | setDirty(); 115 | } 116 | 117 | //* previous index 118 | virtual int previousIndex() const 119 | { 120 | return _previous._index; 121 | } 122 | 123 | //* previous index 124 | virtual void setPreviousIndex(int index) 125 | { 126 | _previous._index = index; 127 | } 128 | 129 | //* previous index Animation 130 | virtual const Animation::Pointer &previousIndexAnimation() const 131 | { 132 | return _previous._animation; 133 | } 134 | 135 | //@} 136 | 137 | //* return Animation associated to action at given position, if any 138 | virtual Animation::Pointer animation(const QPoint &position) const; 139 | 140 | //* return opacity associated to action at given position, if any 141 | virtual qreal opacity(const QPoint &position) const; 142 | 143 | private: 144 | //* container for needed animation data 145 | class Data 146 | { 147 | public: 148 | //* default constructor 149 | Data() 150 | : _opacity(0) 151 | , _index(-1) 152 | { 153 | } 154 | 155 | Animation::Pointer _animation; 156 | qreal _opacity; 157 | int _index; 158 | }; 159 | 160 | //* current tab animation data (for hover enter animations) 161 | Data _current; 162 | 163 | //* previous tab animations data (for hover leave animations) 164 | Data _previous; 165 | }; 166 | 167 | } // namespace Adwaita 168 | 169 | #endif // ADWAITA_TABBAR_DATA_H 170 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatabbarengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitatabbarengine.h" 21 | 22 | #include 23 | 24 | namespace Adwaita 25 | { 26 | 27 | //____________________________________________________________ 28 | bool TabBarEngine::registerWidget(QWidget *widget) 29 | { 30 | if (!widget) { 31 | return false; 32 | } 33 | 34 | // create new data class 35 | if (!_hoverData.contains(widget)) { 36 | _hoverData.insert(widget, new TabBarData(this, widget, duration()), enabled()); 37 | } 38 | 39 | if (!_focusData.contains(widget)) { 40 | _focusData.insert(widget, new TabBarData(this, widget, duration()), enabled()); 41 | } 42 | 43 | // connect destruction signal 44 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection); 45 | return true; 46 | } 47 | 48 | //____________________________________________________________ 49 | bool TabBarEngine::updateState(const QObject *object, const QPoint &position, AnimationMode mode, bool value) 50 | { 51 | DataMap::Value data(TabBarEngine::data(object, mode)); 52 | return (data && data.data()->updateState(position, value)); 53 | } 54 | 55 | //____________________________________________________________ 56 | bool TabBarEngine::isAnimated(const QObject *object, const QPoint &position, AnimationMode mode) 57 | { 58 | DataMap::Value data(TabBarEngine::data(object, mode)); 59 | return (data && data.data()->animation(position) && data.data()->animation(position).data()->isRunning()); 60 | } 61 | 62 | //____________________________________________________________ 63 | DataMap::Value TabBarEngine::data(const QObject *object, AnimationMode mode) 64 | { 65 | switch (mode) { 66 | case AnimationHover: 67 | return _hoverData.find(object).data(); 68 | case AnimationFocus: 69 | return _focusData.find(object).data(); 70 | default: 71 | return DataMap::Value(); 72 | } 73 | } 74 | 75 | } // namespace Adwaita 76 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatabbarengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_TABBAR_ENGINE_H 21 | #define ADWAITA_TABBAR_ENGINE_H 22 | 23 | #include "adwaita.h" 24 | #include "adwaitabaseengine.h" 25 | #include "adwaitadatamap.h" 26 | #include "adwaitatabbardata.h" 27 | #include "adwaitaqt_export.h" 28 | 29 | namespace Adwaita 30 | { 31 | //* stores tabbar hovered action and timeLine 32 | class ADWAITAQT_EXPORT TabBarEngine : public BaseEngine 33 | { 34 | Q_OBJECT 35 | public: 36 | //* constructor 37 | explicit TabBarEngine(QObject *parent) 38 | : BaseEngine(parent) 39 | { 40 | } 41 | 42 | //* destructor 43 | virtual ~TabBarEngine() 44 | { 45 | } 46 | 47 | //* register tabbar 48 | virtual bool registerWidget(QWidget *); 49 | 50 | //* true if widget hover state is changed 51 | virtual bool updateState(const QObject *, const QPoint &, AnimationMode, bool); 52 | 53 | //* true if widget is animated 54 | virtual bool isAnimated(const QObject *object, const QPoint &point, AnimationMode); 55 | 56 | //* animation opacity 57 | virtual qreal opacity(const QObject *object, const QPoint &point, AnimationMode mode) 58 | { 59 | return isAnimated(object, point, mode) ? data(object, mode).data()->opacity(point) : AnimationData::OpacityInvalid; 60 | } 61 | 62 | //* enability 63 | virtual void setEnabled(bool value) 64 | { 65 | BaseEngine::setEnabled(value); 66 | _hoverData.setEnabled(value); 67 | _focusData.setEnabled(value); 68 | } 69 | 70 | //* duration 71 | virtual void setDuration(int value) 72 | { 73 | BaseEngine::setDuration(value); 74 | _hoverData.setDuration(value); 75 | _focusData.setDuration(value); 76 | } 77 | 78 | public Q_SLOTS: 79 | 80 | //* remove widget from map 81 | virtual bool unregisterWidget(QObject *object) 82 | { 83 | if (!object) { 84 | return false; 85 | } 86 | 87 | bool found = false; 88 | if (_hoverData.unregisterWidget(object)) { 89 | found = true; 90 | } 91 | 92 | if (_focusData.unregisterWidget(object)) { 93 | found = true; 94 | } 95 | 96 | return found; 97 | } 98 | 99 | private: 100 | //* returns data associated to widget 101 | DataMap::Value data(const QObject *, AnimationMode); 102 | 103 | //* data map 104 | DataMap _hoverData; 105 | DataMap _focusData; 106 | }; 107 | 108 | } // namespace Adwaita 109 | 110 | #endif // ADWAITA_TABBAR_ENGINE_H 111 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatoolboxengine.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitatoolboxengine.h" 21 | 22 | namespace Adwaita 23 | { 24 | 25 | //____________________________________________________________ 26 | bool ToolBoxEngine::registerWidget(QWidget *widget) 27 | { 28 | if (!widget) { 29 | return false; 30 | } 31 | 32 | if (!_data.contains(widget)) { 33 | _data.insert(widget, new WidgetStateData(this, widget, duration()), enabled()); 34 | } 35 | 36 | // connect destruction signal 37 | connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection); 38 | return true; 39 | } 40 | 41 | //____________________________________________________________ 42 | bool ToolBoxEngine::updateState(const QPaintDevice *object, bool value) 43 | { 44 | PaintDeviceDataMap::Value data(ToolBoxEngine::data(object)); 45 | return (data && data.data()->updateState(value)); 46 | } 47 | 48 | //____________________________________________________________ 49 | bool ToolBoxEngine::isAnimated(const QPaintDevice *object) 50 | { 51 | PaintDeviceDataMap::Value data(ToolBoxEngine::data(object)); 52 | return (data && data.data()->animation() && data.data()->animation().data()->isRunning()); 53 | } 54 | 55 | } // namespace Adwaita 56 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatoolboxengine.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_TOOLBOX_ENGINE_H 21 | #define ADWAITA_TOOLBOX_ENGINE_H 22 | 23 | #include "adwaitabaseengine.h" 24 | #include "adwaitadatamap.h" 25 | #include "adwaitawidgetstatedata.h" 26 | #include "adwaitaqt_export.h" 27 | 28 | namespace Adwaita 29 | { 30 | //* QToolBox animation engine 31 | class ADWAITAQT_EXPORT ToolBoxEngine : public BaseEngine 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | //* constructor 37 | explicit ToolBoxEngine(QObject *parent) 38 | : BaseEngine(parent) 39 | { 40 | } 41 | 42 | //* destructor 43 | virtual ~ToolBoxEngine() 44 | { 45 | } 46 | 47 | //* enability 48 | virtual void setEnabled(bool value) 49 | { 50 | BaseEngine::setEnabled(value); 51 | _data.setEnabled(value); 52 | } 53 | 54 | //* duration 55 | virtual void setDuration(int value) 56 | { 57 | BaseEngine::setDuration(value); 58 | _data.setDuration(value); 59 | } 60 | 61 | //* register widget 62 | virtual bool registerWidget(QWidget *); 63 | 64 | //* true if widget hover state is changed 65 | virtual bool updateState(const QPaintDevice *, bool); 66 | 67 | //* true if widget is animated 68 | virtual bool isAnimated(const QPaintDevice *); 69 | 70 | //* animation opacity 71 | virtual qreal opacity(const QPaintDevice *object) 72 | { 73 | return isAnimated(object) ? data(object).data()->opacity() : AnimationData::OpacityInvalid; 74 | } 75 | 76 | public Q_SLOTS: 77 | 78 | //* remove widget from map 79 | virtual bool unregisterWidget(QObject *data) 80 | { 81 | if (!data) { 82 | return false; 83 | } 84 | 85 | // reinterpret_cast is safe here since only the address is used to find 86 | // data in the map 87 | return _data.unregisterWidget(reinterpret_cast(data)); 88 | } 89 | 90 | protected: 91 | //* returns data associated to widget 92 | PaintDeviceDataMap::Value data(const QPaintDevice *object) 93 | { 94 | return _data.find(object).data(); 95 | } 96 | 97 | private: 98 | //* map 99 | PaintDeviceDataMap _data; 100 | }; 101 | 102 | } // namespace Adwaita 103 | 104 | #endif // ADWAITA_TOOLBOX_ENGINE_H 105 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatransitiondata.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // adwaitatransitiondata.cpp 3 | // data container for generic transitions 4 | // ------------------- 5 | // 6 | // Copyright (c) 2009 Hugo Pereira Da Costa 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to 10 | // deal in the Software without restriction, including without limitation the 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | // sell copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | // IN THE SOFTWARE. 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "adwaitatransitiondata.h" 28 | 29 | namespace Adwaita 30 | { 31 | 32 | //_________________________________________________________________ 33 | TransitionData::TransitionData(QObject *parent, QWidget *target, int duration) 34 | : QObject(parent) 35 | , _transition(new TransitionWidget(target, duration)) 36 | { 37 | _transition.data()->hide(); 38 | } 39 | 40 | //_________________________________________________________________ 41 | TransitionData::~TransitionData() 42 | { 43 | if (_transition) { 44 | _transition.data()->deleteLater(); 45 | } 46 | } 47 | 48 | } // namespace Adwaita 49 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitatransitiondata.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // adwaitatransitiondata.h 3 | // data container for generic transitions 4 | // ------------------- 5 | // 6 | // Copyright (c) 2009 Hugo Pereira Da Costa 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to 10 | // deal in the Software without restriction, including without limitation the 11 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | // sell copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | // IN THE SOFTWARE. 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef ADWAITA_TRANSITION_DATA_H 28 | #define ADWAITA_TRANSITION_DATA_H 29 | 30 | #include "adwaitatransitionwidget.h" 31 | #include "adwaitaqt_export.h" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | namespace Adwaita 38 | { 39 | //* generic data 40 | class ADWAITAQT_EXPORT TransitionData : public QObject 41 | { 42 | Q_OBJECT 43 | public: 44 | //* constructor 45 | TransitionData(QObject *parent, QWidget *target, int); 46 | 47 | //* destructor 48 | virtual ~TransitionData(); 49 | 50 | //* enability 51 | virtual void setEnabled(bool value) 52 | { 53 | _enabled = value; 54 | } 55 | 56 | //* enability 57 | virtual bool enabled() const 58 | { 59 | return _enabled; 60 | } 61 | 62 | //* duration 63 | virtual void setDuration(int duration) 64 | { 65 | if (_transition) { 66 | _transition.data()->setDuration(duration); 67 | } 68 | } 69 | 70 | //* max render time 71 | void setMaxRenderTime(int value) 72 | { 73 | _maxRenderTime = value; 74 | } 75 | 76 | //* max renderTime 77 | const int &maxRenderTime() const 78 | { 79 | return _maxRenderTime; 80 | } 81 | 82 | //* start clock 83 | void startClock() 84 | { 85 | if (!_clock.isValid()) { 86 | _clock.start(); 87 | } else { 88 | _clock.restart(); 89 | } 90 | } 91 | 92 | //* check if rendering is two slow 93 | bool slow() const 94 | { 95 | return !(!_clock.isValid() || _clock.elapsed() <= maxRenderTime()); 96 | } 97 | 98 | protected Q_SLOTS: 99 | 100 | //* initialize animation 101 | virtual bool initializeAnimation() = 0; 102 | 103 | //* animate 104 | virtual bool animate() = 0; 105 | 106 | protected: 107 | //* returns true if one parent matches given class name 108 | inline bool hasParent(const QWidget *, const char *) const; 109 | 110 | //* transition widget 111 | virtual const TransitionWidget::Pointer &transition() const 112 | { 113 | return _transition; 114 | } 115 | 116 | //* used to avoid recursion when grabbing widgets 117 | void setRecursiveCheck(bool value) 118 | { 119 | _recursiveCheck = value; 120 | } 121 | 122 | //* used to avoid recursion when grabbing widgets 123 | bool recursiveCheck() const 124 | { 125 | return _recursiveCheck; 126 | } 127 | 128 | private: 129 | //* enability 130 | bool _enabled = true; 131 | 132 | //* used to avoid recursion when grabbing widgets 133 | bool _recursiveCheck = false; 134 | 135 | //* timer used to detect slow rendering 136 | QElapsedTimer _clock; 137 | 138 | //* max render time 139 | /*! used to detect slow rendering */ 140 | int _maxRenderTime = 200; 141 | 142 | //* animation handling 143 | TransitionWidget::Pointer _transition; 144 | }; 145 | 146 | //_____________________________________________________________________________________ 147 | bool TransitionData::hasParent(const QWidget *widget, const char *className) const 148 | { 149 | if (!widget) { 150 | return false; 151 | } 152 | 153 | for (QWidget *parent = widget->parentWidget(); parent; parent = parent->parentWidget()) { 154 | if (parent->inherits(className)) { 155 | return true; 156 | } 157 | } 158 | 159 | return false; 160 | } 161 | 162 | } // namespace Adwaita 163 | 164 | #endif // ADWAITA_TRANSITION_DATA_H 165 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitawidgetstatedata.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #include "adwaitawidgetstatedata.h" 21 | 22 | namespace Adwaita 23 | { 24 | 25 | //______________________________________________ 26 | bool WidgetStateData::updateState(bool value) 27 | { 28 | if (!_initialized) { 29 | _state = value; 30 | _initialized = true; 31 | return false; 32 | } else if (_state == value) { 33 | return false; 34 | } else { 35 | _state = value; 36 | animation().data()->setDirection(_state ? Animation::Forward : Animation::Backward); 37 | if (!animation().data()->isRunning()) { 38 | animation().data()->start(); 39 | } 40 | return true; 41 | } 42 | } 43 | 44 | } // namespace Adwaita 45 | -------------------------------------------------------------------------------- /src/lib/animations/adwaitawidgetstatedata.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 | *************************************************************************/ 19 | 20 | #ifndef ADWAITA_WIDGET_STATE_DATA_H 21 | #define ADWAITA_WIDGET_STATE_DATA_H 22 | 23 | #include "adwaitagenericdata.h" 24 | #include "adwaitaqt_export.h" 25 | 26 | namespace Adwaita 27 | { 28 | //* handle widget state (hover/focus/enable) changes 29 | class ADWAITAQT_EXPORT WidgetStateData : public GenericData 30 | { 31 | Q_OBJECT 32 | public: 33 | //* constructor 34 | WidgetStateData(QObject *parent, QWidget *target, int duration, bool state = false) 35 | : GenericData(parent, target, duration) 36 | , _initialized(false) 37 | , _state(state) 38 | { 39 | } 40 | 41 | //* destructor 42 | virtual ~WidgetStateData() 43 | { 44 | } 45 | 46 | /** 47 | returns true if hover has Changed 48 | and starts timer accordingly 49 | */ 50 | virtual bool updateState(bool value); 51 | 52 | private: 53 | bool _initialized; 54 | bool _state; 55 | }; 56 | 57 | } // namespace Adwaita 58 | 59 | #endif // ADWAITA_WIDGET_STATE_DATA_H 60 | -------------------------------------------------------------------------------- /src/lib/config-adwaita.h.cmake: -------------------------------------------------------------------------------- 1 | /* config-adwaita.h. Generated by cmake from config-adwaita.h.cmake */ 2 | 3 | /************************************************************************* 4 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, write to the * 18 | * Free Software Foundation, Inc., * 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 20 | *************************************************************************/ 21 | 22 | #ifndef config_adwaita_h 23 | #define config_adwaita_h 24 | 25 | /* Define to 1 if XCB libraries are found */ 26 | #cmakedefine01 ADWAITA_HAVE_X11 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/lib/stylesheet/Adwaita-dark.scss: -------------------------------------------------------------------------------- 1 | $variant: 'dark'; 2 | 3 | @import 'colors'; 4 | @import 'drawing'; 5 | 6 | @define-color base_color #{$base_color}; 7 | @define-color text_color #{$text_color}; 8 | @define-color bg_color #{$bg_color}; 9 | @define-color fg_color #{$fg_color}; 10 | 11 | @define-color selected_fg_color #{$selected_fg_color}; 12 | @define-color selected_bg_color #{$selected_bg_color}; 13 | @define-color selected_borders_color #{$selected_borders_color}; 14 | @define-color borders_color #{$borders_color}; 15 | @define-color alt_borders_color #{$alt_borders_color}; 16 | @define-color borders_edge #{$borders_edge}; 17 | @define-color link_color #{$link_color}; 18 | @define-color link_visited_color #{$link_visited_color}; 19 | @define-color top_hilight #{$top_hilight}; 20 | @define-color dark_fill #{$dark_fill}; 21 | @define-color headerbar_bg_color #{$headerbar_bg_color}; 22 | @define-color menu_color #{$menu_color}; 23 | @define-color menu_selected_color #{$menu_selected_color}; 24 | 25 | @define-color scrollbar_bg_color #{$scrollbar_bg_color}; 26 | @define-color scrollbar_slider_color #{$scrollbar_slider_color}; 27 | @define-color scrollbar_slider_hover_color #{$scrollbar_slider_hover_color}; 28 | @define-color scrollbar_slider_active_color #{$scrollbar_slider_active_color}; 29 | 30 | @define-color warning_color #{$warning_color}; 31 | @define-color error_color #{$error_color}; 32 | @define-color success_color #{$success_color}; 33 | @define-color destructive_color #{$destructive_color}; 34 | 35 | @define-color osd_fg_color #{$osd_fg_color}; 36 | @define-color osd_text_color #{$osd_text_color}; 37 | @define-color osd_bg_color #{$osd_bg_color}; 38 | @define-color osd_insensitive_bg_color #{$osd_insensitive_bg_color}; 39 | @define-color osd_insensitive_fg_color #{$osd_insensitive_fg_color}; 40 | @define-color osd_borders_color #{$osd_borders_color}; 41 | 42 | @define-color sidebar_bg_color #{$sidebar_bg_color}; 43 | 44 | @define-color tooltip_borders_color #{$tooltip_borders_color}; 45 | @define-color shadow_color #{$shadow_color}; 46 | 47 | @define-color drop_target_color #{$drop_target_color}; 48 | 49 | //insensitive state derived colors 50 | @define-color insensitive_fg_color #{$insensitive_fg_color}; 51 | @define-color insensitive_bg_color #{$insensitive_bg_color}; 52 | @define-color insensitive_borders_color #{$insensitive_borders_color}; 53 | 54 | //colors for the backdrop state, derived from the main colors. 55 | @define-color backdrop_base_color #{$backdrop_base_color}; 56 | @define-color backdrop_text_color #{$backdrop_text_color}; 57 | @define-color backdrop_bg_color #{$backdrop_bg_color}; 58 | @define-color backdrop_fg_color #{$backdrop_fg_color}; 59 | @define-color backdrop_insensitive_color #{$backdrop_insensitive_color}; 60 | @define-color backdrop_selected_fg_color #{$backdrop_selected_fg_color}; 61 | @define-color backdrop_borders_color #{$backdrop_borders_color}; 62 | @define-color backdrop_dark_fill #{$backdrop_dark_fill}; 63 | 64 | //special cased widget colors 65 | @define-color suggested_bg_color #{$suggested_bg_color}; 66 | @define-color suggested_border_color #{$suggested_border_color}; 67 | @define-color progress_bg_color #{$progress_bg_color}; 68 | @define-color progress_border_color #{$progress_border_color}; 69 | @define-color checkradio_bg_color #{$checkradio_bg_color}; 70 | @define-color checkradio_fg_color #{$checkradio_fg_color}; 71 | @define-color checkradio_borders_color #{$checkradio_borders_color}; 72 | @define-color switch_bg_color #{$switch_bg_color}; 73 | @define-color switch_borders_color #{$switch_borders_color}; 74 | @define-color focus_border_color #{$focus_border_color}; 75 | @define-color alt_focus_border_color #{$alt_focus_border_color}; 76 | @define-color dim_label_opacity #{$dim_label_opacity}; 77 | 78 | %button, 79 | button { 80 | @at-root %button_basic, & { 81 | @include button(normal); 82 | &:hover { @include button(hover); } 83 | &:checked { @include button(active); } 84 | &:checked:hover { @include button(checked-hover); } 85 | &:checked:active { @include button(checked-active); } 86 | &:backdrop { @include button(backdrop); } 87 | &:backdrop:active { @include button(backdrop-active); } 88 | &:backdrop:insensitive { @include button(backdrop-insensitive); } 89 | &:backdrop:insensitive:active { @include button(backdrop-insensitive-active); } 90 | &:disabled { @include button(insensitive); } 91 | &:disabled:active { @include button(insensitive-active); } 92 | } 93 | } 94 | 95 | checkradio { 96 | & { 97 | // for unchecked 98 | $_c: if($variant=='light', white, $bg_color); 99 | 100 | @each $state, $t in ("", "normal"), 101 | (":hover", "hover"), 102 | (":active", "active"), 103 | (":disabled", "insensitive") { 104 | &#{$state} { 105 | @include check($t, $_c); 106 | } 107 | } 108 | } 109 | 110 | & { 111 | // for checked 112 | @each $t in (':checked') { 113 | &#{$t} { 114 | @each $state, $t in ("", "normal"), 115 | (":hover", "hover"), 116 | (":active", "active"), 117 | (":disabled", "insensitive") { 118 | &#{$state} { 119 | @include check($t, $checkradio_bg_color, $checkradio_fg_color, $checked: true); 120 | } 121 | } 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/lib/stylesheet/Adwaita-hc-dark.scss: -------------------------------------------------------------------------------- 1 | $variant: 'dark'; 2 | 3 | @import 'colors'; 4 | @import 'colors-hc'; 5 | @import 'drawing'; 6 | 7 | @define-color base_color #{$base_color}; 8 | @define-color text_color #{$text_color}; 9 | @define-color bg_color #{$bg_color}; 10 | @define-color fg_color #{$fg_color}; 11 | 12 | @define-color selected_fg_color #{$selected_fg_color}; 13 | @define-color selected_bg_color #{$selected_bg_color}; 14 | @define-color selected_borders_color #{$selected_borders_color}; 15 | @define-color borders_color #{$borders_color}; 16 | @define-color alt_borders_color #{$alt_borders_color}; 17 | @define-color borders_edge #{$borders_edge}; 18 | @define-color link_color #{$link_color}; 19 | @define-color link_visited_color #{$link_visited_color}; 20 | @define-color top_hilight #{$top_hilight}; 21 | @define-color dark_fill #{$dark_fill}; 22 | @define-color headerbar_bg_color #{$headerbar_bg_color}; 23 | @define-color menu_color #{$menu_color}; 24 | @define-color menu_selected_color #{$menu_selected_color}; 25 | 26 | @define-color scrollbar_bg_color #{$scrollbar_bg_color}; 27 | @define-color scrollbar_slider_color #{$scrollbar_slider_color}; 28 | @define-color scrollbar_slider_hover_color #{$scrollbar_slider_hover_color}; 29 | @define-color scrollbar_slider_active_color #{$scrollbar_slider_active_color}; 30 | 31 | @define-color warning_color #{$warning_color}; 32 | @define-color error_color #{$error_color}; 33 | @define-color success_color #{$success_color}; 34 | @define-color destructive_color #{$destructive_color}; 35 | 36 | @define-color osd_fg_color #{$osd_fg_color}; 37 | @define-color osd_text_color #{$osd_text_color}; 38 | @define-color osd_bg_color #{$osd_bg_color}; 39 | @define-color osd_insensitive_bg_color #{$osd_insensitive_bg_color}; 40 | @define-color osd_insensitive_fg_color #{$osd_insensitive_fg_color}; 41 | @define-color osd_borders_color #{$osd_borders_color}; 42 | 43 | @define-color sidebar_bg_color #{$sidebar_bg_color}; 44 | 45 | @define-color tooltip_borders_color #{$tooltip_borders_color}; 46 | @define-color shadow_color #{$shadow_color}; 47 | 48 | @define-color drop_target_color #{$drop_target_color}; 49 | 50 | //insensitive state derived colors 51 | @define-color insensitive_fg_color #{$insensitive_fg_color}; 52 | @define-color insensitive_bg_color #{$insensitive_bg_color}; 53 | @define-color insensitive_borders_color #{$insensitive_borders_color}; 54 | 55 | //colors for the backdrop state, derived from the main colors. 56 | @define-color backdrop_base_color #{$backdrop_base_color}; 57 | @define-color backdrop_text_color #{$backdrop_text_color}; 58 | @define-color backdrop_bg_color #{$backdrop_bg_color}; 59 | @define-color backdrop_fg_color #{$backdrop_fg_color}; 60 | @define-color backdrop_insensitive_color #{$backdrop_insensitive_color}; 61 | @define-color backdrop_selected_fg_color #{$backdrop_selected_fg_color}; 62 | @define-color backdrop_borders_color #{$backdrop_borders_color}; 63 | @define-color backdrop_dark_fill #{$backdrop_dark_fill}; 64 | 65 | //special cased widget colors 66 | @define-color suggested_bg_color #{$suggested_bg_color}; 67 | @define-color suggested_border_color #{$suggested_border_color}; 68 | @define-color progress_bg_color #{$progress_bg_color}; 69 | @define-color progress_border_color #{$progress_border_color}; 70 | @define-color checkradio_bg_color #{$checkradio_bg_color}; 71 | @define-color checkradio_fg_color #{$checkradio_fg_color}; 72 | @define-color checkradio_borders_color #{$checkradio_borders_color}; 73 | @define-color switch_bg_color #{$switch_bg_color}; 74 | @define-color switch_borders_color #{$switch_borders_color}; 75 | @define-color focus_border_color #{$focus_border_color}; 76 | @define-color alt_focus_border_color #{$alt_focus_border_color}; 77 | @define-color dim_label_opacity #{$dim_label_opacity}; 78 | 79 | %button, 80 | button { 81 | @at-root %button_basic, & { 82 | @include button(normal); 83 | &:hover { @include button(hover); } 84 | &:checked { @include button(active); } 85 | &:checked:hover { @include button(checked-hover); } 86 | &:checked:active { @include button(checked-active); } 87 | &:backdrop { @include button(backdrop); } 88 | &:backdrop:active { @include button(backdrop-active); } 89 | &:backdrop:insensitive { @include button(backdrop-insensitive); } 90 | &:backdrop:insensitive:active { @include button(backdrop-insensitive-active); } 91 | &:disabled { @include button(insensitive); } 92 | &:disabled:active { @include button(insensitive-active); } 93 | } 94 | } 95 | 96 | checkradio { 97 | & { 98 | // for unchecked 99 | $_c: if($variant=='light', white, $bg_color); 100 | 101 | @each $state, $t in ("", "normal"), 102 | (":hover", "hover"), 103 | (":active", "active"), 104 | (":disabled", "insensitive") { 105 | &#{$state} { 106 | @include check($t, $_c); 107 | } 108 | } 109 | } 110 | 111 | & { 112 | // for checked 113 | @each $t in (':checked') { 114 | &#{$t} { 115 | @each $state, $t in ("", "normal"), 116 | (":hover", "hover"), 117 | (":active", "active"), 118 | (":disabled", "insensitive") { 119 | &#{$state} { 120 | @include check($t, $checkradio_bg_color, $checkradio_fg_color, $checked: true); 121 | } 122 | } 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/lib/stylesheet/Adwaita-hc.scss: -------------------------------------------------------------------------------- 1 | $variant: 'light'; 2 | 3 | @import 'colors'; 4 | @import 'colors-hc'; 5 | @import 'drawing'; 6 | 7 | @define-color base_color #{$base_color}; 8 | @define-color text_color #{$text_color}; 9 | @define-color bg_color #{$bg_color}; 10 | @define-color fg_color #{$fg_color}; 11 | 12 | @define-color selected_fg_color #{$selected_fg_color}; 13 | @define-color selected_bg_color #{$selected_bg_color}; 14 | @define-color selected_borders_color #{$selected_borders_color}; 15 | @define-color borders_color #{$borders_color}; 16 | @define-color alt_borders_color #{$alt_borders_color}; 17 | @define-color borders_edge #{$borders_edge}; 18 | @define-color link_color #{$link_color}; 19 | @define-color link_visited_color #{$link_visited_color}; 20 | @define-color top_hilight #{$top_hilight}; 21 | @define-color dark_fill #{$dark_fill}; 22 | @define-color headerbar_bg_color #{$headerbar_bg_color}; 23 | @define-color menu_color #{$menu_color}; 24 | @define-color menu_selected_color #{$menu_selected_color}; 25 | 26 | @define-color scrollbar_bg_color #{$scrollbar_bg_color}; 27 | @define-color scrollbar_slider_color #{$scrollbar_slider_color}; 28 | @define-color scrollbar_slider_hover_color #{$scrollbar_slider_hover_color}; 29 | @define-color scrollbar_slider_active_color #{$scrollbar_slider_active_color}; 30 | 31 | @define-color warning_color #{$warning_color}; 32 | @define-color error_color #{$error_color}; 33 | @define-color success_color #{$success_color}; 34 | @define-color destructive_color #{$destructive_color}; 35 | 36 | @define-color osd_fg_color #{$osd_fg_color}; 37 | @define-color osd_text_color #{$osd_text_color}; 38 | @define-color osd_bg_color #{$osd_bg_color}; 39 | @define-color osd_insensitive_bg_color #{$osd_insensitive_bg_color}; 40 | @define-color osd_insensitive_fg_color #{$osd_insensitive_fg_color}; 41 | @define-color osd_borders_color #{$osd_borders_color}; 42 | 43 | @define-color sidebar_bg_color #{$sidebar_bg_color}; 44 | 45 | @define-color tooltip_borders_color #{$tooltip_borders_color}; 46 | @define-color shadow_color #{$shadow_color}; 47 | 48 | @define-color drop_target_color #{$drop_target_color}; 49 | 50 | //insensitive state derived colors 51 | @define-color insensitive_fg_color #{$insensitive_fg_color}; 52 | @define-color insensitive_bg_color #{$insensitive_bg_color}; 53 | @define-color insensitive_borders_color #{$insensitive_borders_color}; 54 | 55 | //colors for the backdrop state, derived from the main colors. 56 | @define-color backdrop_base_color #{$backdrop_base_color}; 57 | @define-color backdrop_text_color #{$backdrop_text_color}; 58 | @define-color backdrop_bg_color #{$backdrop_bg_color}; 59 | @define-color backdrop_fg_color #{$backdrop_fg_color}; 60 | @define-color backdrop_insensitive_color #{$backdrop_insensitive_color}; 61 | @define-color backdrop_selected_fg_color #{$backdrop_selected_fg_color}; 62 | @define-color backdrop_borders_color #{$backdrop_borders_color}; 63 | @define-color backdrop_dark_fill #{$backdrop_dark_fill}; 64 | 65 | //special cased widget colors 66 | @define-color suggested_bg_color #{$suggested_bg_color}; 67 | @define-color suggested_border_color #{$suggested_border_color}; 68 | @define-color progress_bg_color #{$progress_bg_color}; 69 | @define-color progress_border_color #{$progress_border_color}; 70 | @define-color checkradio_bg_color #{$checkradio_bg_color}; 71 | @define-color checkradio_fg_color #{$checkradio_fg_color}; 72 | @define-color checkradio_borders_color #{$checkradio_borders_color}; 73 | @define-color switch_bg_color #{$switch_bg_color}; 74 | @define-color switch_borders_color #{$switch_borders_color}; 75 | @define-color focus_border_color #{$focus_border_color}; 76 | @define-color alt_focus_border_color #{$alt_focus_border_color}; 77 | @define-color dim_label_opacity #{$dim_label_opacity}; 78 | 79 | %button, 80 | button { 81 | @at-root %button_basic, & { 82 | @include button(normal); 83 | &:hover { @include button(hover); } 84 | &:checked { @include button(active); } 85 | &:checked:hover { @include button(checked-hover); } 86 | &:checked:active { @include button(checked-active); } 87 | &:backdrop { @include button(backdrop); } 88 | &:backdrop:active { @include button(backdrop-active); } 89 | &:backdrop:insensitive { @include button(backdrop-insensitive); } 90 | &:backdrop:insensitive:active { @include button(backdrop-insensitive-active); } 91 | &:disabled { @include button(insensitive); } 92 | &:disabled:active { @include button(insensitive-active); } 93 | } 94 | } 95 | 96 | checkradio { 97 | & { 98 | // for unchecked 99 | $_c: if($variant=='light', white, $bg_color); 100 | 101 | @each $state, $t in ("", "normal"), 102 | (":hover", "hover"), 103 | (":active", "active"), 104 | (":disabled", "insensitive") { 105 | &#{$state} { 106 | @include check($t, $_c); 107 | } 108 | } 109 | } 110 | 111 | & { 112 | // for checked 113 | @each $t in (':checked') { 114 | &#{$t} { 115 | @each $state, $t in ("", "normal"), 116 | (":hover", "hover"), 117 | (":active", "active"), 118 | (":disabled", "insensitive") { 119 | &#{$state} { 120 | @include check($t, $checkradio_bg_color, $checkradio_fg_color, $checked: true); 121 | } 122 | } 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/lib/stylesheet/Adwaita-light.scss: -------------------------------------------------------------------------------- 1 | $variant: 'light'; 2 | 3 | @import 'colors'; 4 | @import 'drawing'; 5 | 6 | @define-color base_color #{$base_color}; 7 | @define-color text_color #{$text_color}; 8 | @define-color bg_color #{$bg_color}; 9 | @define-color fg_color #{$fg_color}; 10 | 11 | @define-color selected_fg_color #{$selected_fg_color}; 12 | @define-color selected_bg_color #{$selected_bg_color}; 13 | @define-color selected_borders_color #{$selected_borders_color}; 14 | @define-color borders_color #{$borders_color}; 15 | @define-color alt_borders_color #{$alt_borders_color}; 16 | @define-color borders_edge #{$borders_edge}; 17 | @define-color link_color #{$link_color}; 18 | @define-color link_visited_color #{$link_visited_color}; 19 | @define-color top_hilight #{$top_hilight}; 20 | @define-color dark_fill #{$dark_fill}; 21 | @define-color headerbar_bg_color #{$headerbar_bg_color}; 22 | @define-color menu_color #{$menu_color}; 23 | @define-color menu_selected_color #{$menu_selected_color}; 24 | 25 | @define-color scrollbar_bg_color #{$scrollbar_bg_color}; 26 | @define-color scrollbar_slider_color #{$scrollbar_slider_color}; 27 | @define-color scrollbar_slider_hover_color #{$scrollbar_slider_hover_color}; 28 | @define-color scrollbar_slider_active_color #{$scrollbar_slider_active_color}; 29 | 30 | @define-color warning_color #{$warning_color}; 31 | @define-color error_color #{$error_color}; 32 | @define-color success_color #{$success_color}; 33 | @define-color destructive_color #{$destructive_color}; 34 | 35 | @define-color osd_fg_color #{$osd_fg_color}; 36 | @define-color osd_text_color #{$osd_text_color}; 37 | @define-color osd_bg_color #{$osd_bg_color}; 38 | @define-color osd_insensitive_bg_color #{$osd_insensitive_bg_color}; 39 | @define-color osd_insensitive_fg_color #{$osd_insensitive_fg_color}; 40 | @define-color osd_borders_color #{$osd_borders_color}; 41 | 42 | @define-color sidebar_bg_color #{$sidebar_bg_color}; 43 | 44 | @define-color tooltip_borders_color #{$tooltip_borders_color}; 45 | @define-color shadow_color #{$shadow_color}; 46 | 47 | @define-color drop_target_color #{$drop_target_color}; 48 | 49 | //insensitive state derived colors 50 | @define-color insensitive_fg_color #{$insensitive_fg_color}; 51 | @define-color insensitive_bg_color #{$insensitive_bg_color}; 52 | @define-color insensitive_borders_color #{$insensitive_borders_color}; 53 | 54 | //colors for the backdrop state, derived from the main colors. 55 | @define-color backdrop_base_color #{$backdrop_base_color}; 56 | @define-color backdrop_text_color #{$backdrop_text_color}; 57 | @define-color backdrop_bg_color #{$backdrop_bg_color}; 58 | @define-color backdrop_fg_color #{$backdrop_fg_color}; 59 | @define-color backdrop_insensitive_color #{$backdrop_insensitive_color}; 60 | @define-color backdrop_selected_fg_color #{$backdrop_selected_fg_color}; 61 | @define-color backdrop_borders_color #{$backdrop_borders_color}; 62 | @define-color backdrop_dark_fill #{$backdrop_dark_fill}; 63 | 64 | //special cased widget colors 65 | @define-color suggested_bg_color #{$suggested_bg_color}; 66 | @define-color suggested_border_color #{$suggested_border_color}; 67 | @define-color progress_bg_color #{$progress_bg_color}; 68 | @define-color progress_border_color #{$progress_border_color}; 69 | @define-color checkradio_bg_color #{$checkradio_bg_color}; 70 | @define-color checkradio_fg_color #{$checkradio_fg_color}; 71 | @define-color checkradio_borders_color #{$checkradio_borders_color}; 72 | @define-color switch_bg_color #{$switch_bg_color}; 73 | @define-color switch_borders_color #{$switch_borders_color}; 74 | @define-color focus_border_color #{$focus_border_color}; 75 | @define-color alt_focus_border_color #{$alt_focus_border_color}; 76 | @define-color dim_label_opacity #{$dim_label_opacity}; 77 | 78 | button { 79 | @at-root %button_basic, & { 80 | @include button(normal); 81 | &:hover { @include button(hover); } 82 | &:checked { @include button(active); } 83 | &:checked:hover { @include button(checked-hover); } 84 | &:checked:active { @include button(checked-active); } 85 | &:backdrop { @include button(backdrop); } 86 | &:backdrop:active { @include button(backdrop-active); } 87 | &:backdrop:insensitive { @include button(backdrop-insensitive); } 88 | &:backdrop:insensitive:active { @include button(backdrop-insensitive-active); } 89 | &:disabled { @include button(insensitive); } 90 | &:disabled:active { @include button(insensitive-active); } 91 | } 92 | } 93 | 94 | checkradio { 95 | & { 96 | // for unchecked 97 | $_c: if($variant=='light', white, $bg_color); 98 | 99 | @each $state, $t in ("", "normal"), 100 | (":hover", "hover"), 101 | (":active", "active"), 102 | (":disabled", "insensitive") { 103 | &#{$state} { 104 | @include check($t, $_c); 105 | } 106 | } 107 | } 108 | 109 | & { 110 | // for checked 111 | @each $t in (':checked') { 112 | &#{$t} { 113 | @each $state, $t in ("", "normal"), 114 | (":hover", "hover"), 115 | (":active", "active"), 116 | (":disabled", "insensitive") { 117 | &#{$state} { 118 | @include check($t, $checkradio_bg_color, $checkradio_fg_color, $checked: true); 119 | } 120 | } 121 | } 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/lib/stylesheet/_colors-hc.scss: -------------------------------------------------------------------------------- 1 | // High Contrast color overrides 2 | // When color definition differs for dark and light variant 3 | // it gets @if ed depending on $variant 4 | 5 | $fg_color: if($variant == 'light', darken($fg_color, 3%), lighten($fg_color, 2%)); 6 | $bg_color: if($variant == 'light', lighten($bg_color, 3%), darken($bg_color, 2%)); 7 | $selected_bg_color: darken($selected_bg_color,10%); 8 | $selected_borders_color: darken($selected_borders_color, 10%); 9 | $borders_color: if($variant == 'light', darken($borders_color, 30%), lighten($borders_color, 30%)); 10 | $alt_borders_color: if($variant == 'light', darken($alt_borders_color, 33%), lighten($alt_borders_color, 28%)); 11 | $menu_color: $base_color; 12 | $menu_selected_color: darken($bg_color,10%); 13 | 14 | //insensitive state derived colors 15 | $insensitive_fg_color: mix($fg_color, $bg_color, 50%); 16 | $insensitive_bg_color: mix($bg_color, $base_color, 60%); 17 | $insensitive_borders_color: mix($borders_color, $bg_color, 80%); 18 | 19 | //focus rings 20 | $focus_border_color: if($variant == 'light', transparentize($selected_bg_color, 0.2), transparentize(white, 0.4)); 21 | $alt_focus_border_color: if($variant == 'light', white, transparentize(white,0.4)); 22 | 23 | $dim_label_opacity: 0.9; 24 | 25 | $switch_borders_color: if($variant == 'light',darken($switch_bg_color,15%),lighten($switch_bg_color,15%)); 26 | -------------------------------------------------------------------------------- /src/lib/stylesheet/_colors.scss: -------------------------------------------------------------------------------- 1 | // When color definition differs for dark and light variant 2 | // it gets @if ed depending on $variant 3 | 4 | $base_color: if($variant == 'light', #ffffff, lighten(desaturate(#241f31, 100%), 2%)); 5 | $text_color: if($variant == 'light', black, white); 6 | $bg_color: if($variant == 'light', #f6f5f4, darken(desaturate(#3d3846, 100%), 4%)); 7 | $fg_color: if($variant == 'light', #2e3436, #eeeeec); 8 | 9 | $selected_fg_color: #ffffff; 10 | $selected_bg_color: if($variant == 'light', #3584e4, darken(#3584e4, 20%)); 11 | $selected_borders_color: if($variant== 'light', darken($selected_bg_color, 15%), darken($selected_bg_color, 30%)); 12 | $borders_color: if($variant == 'light', darken($bg_color, 18%), darken($bg_color, 10%)); 13 | $alt_borders_color: if($variant == 'light', darken($bg_color, 24%), darken($bg_color, 18%)); 14 | $borders_edge: if($variant == 'light', transparentize(white, 0.2), transparentize($fg_color, 0.93)); 15 | $link_color: if($variant == 'light', darken($selected_bg_color, 10%), lighten($selected_bg_color, 20%)); 16 | $link_visited_color: if($variant == 'light', darken($selected_bg_color, 20%), lighten($selected_bg_color, 10%)); 17 | $top_hilight: $borders_edge; 18 | $dark_fill: mix($borders_color, $bg_color, 50%); 19 | $headerbar_bg_color: if($variant == 'light', lighten($bg_color, 5%), darken($bg_color, 3%)); 20 | $menu_color: $base_color; 21 | $menu_selected_color: if($variant == 'light', darken($bg_color, 6%), darken($bg_color, 8%)); 22 | 23 | $scrollbar_bg_color: if($variant == 'light', mix($bg_color, $fg_color, 80%), mix($base_color, $bg_color, 50%)); 24 | $scrollbar_slider_color: mix($fg_color, $bg_color, 60%); 25 | $scrollbar_slider_hover_color: mix($fg_color, $bg_color, 80%); 26 | $scrollbar_slider_active_color: if($variant=='light', darken($selected_bg_color, 10%), lighten($selected_bg_color, 10%)); 27 | 28 | $warning_color: #f57900; 29 | $error_color: #cc0000; 30 | $success_color: if($variant == 'light', #33d17a, darken(#33d17a, 10%)); 31 | $destructive_color: if($variant == 'light', #e01b24, darken(#e01b24, 10%)); 32 | 33 | $osd_fg_color: #eeeeec; 34 | $osd_text_color: white; 35 | $osd_bg_color: if($variant == 'light', transparentize(darken(desaturate(#3d3846, 100%), 4%),0.3), transparentize(darken(desaturate(#3d3846, 100%), 10%),0.3)); 36 | $osd_insensitive_bg_color: transparentize(mix($osd_fg_color, opacify($osd_bg_color, 1), 10%), 0.5); 37 | $osd_insensitive_fg_color: mix($osd_fg_color, opacify($osd_bg_color, 1), 50%); 38 | $osd_borders_color: transparentize(black, 0.3); 39 | 40 | $sidebar_bg_color: mix($bg_color, $base_color, 50%); 41 | 42 | $tooltip_borders_color: transparentize(white, 0.9); 43 | $shadow_color: transparentize(black, 0.9); 44 | 45 | $drop_target_color: if($variant == 'light', #2ec27e, #26a269); 46 | 47 | //insensitive state derived colors 48 | $insensitive_fg_color: mix($fg_color, $bg_color, 50%); 49 | $insensitive_bg_color: mix($bg_color, $base_color, 60%); 50 | $insensitive_borders_color: mix($borders_color, $bg_color, 80%); 51 | 52 | //colors for the backdrop state, derived from the main colors. 53 | $backdrop_base_color: if($variant == 'light', darken($base_color, 1%), lighten($base_color, 1%)); 54 | $backdrop_text_color: mix($text_color, $backdrop_base_color, 80%); 55 | $backdrop_bg_color: $bg_color; 56 | $backdrop_fg_color: mix($fg_color, $backdrop_bg_color, 50%); 57 | $backdrop_insensitive_color: if($variant == 'light', darken($backdrop_bg_color, 15%), lighten($backdrop_bg_color, 15%)); 58 | $backdrop_selected_fg_color: if($variant == 'light', $backdrop_base_color, $backdrop_text_color); 59 | $backdrop_borders_color: mix($borders_color, $bg_color, 80%); 60 | $backdrop_dark_fill: mix($backdrop_borders_color, $backdrop_bg_color, 35%); 61 | 62 | //special cased widget colors 63 | $suggested_bg_color: $selected_bg_color; 64 | $suggested_border_color: $selected_borders_color; 65 | $progress_bg_color: $selected_bg_color; 66 | $progress_border_color: $selected_borders_color; 67 | $checkradio_bg_color: $selected_bg_color; 68 | $checkradio_fg_color: $selected_fg_color; 69 | $checkradio_borders_color: if($variant == 'light',darken($selected_bg_color,10%),darken($selected_bg_color,20%)); 70 | $switch_bg_color: $selected_bg_color; 71 | $switch_borders_color: if($variant == 'light',darken($switch_bg_color,15%),darken($switch_bg_color,30%)); 72 | $focus_border_color: if($variant == 'light', transparentize($selected_bg_color, 0.5), transparentize($selected_bg_color, 0.3)); 73 | $alt_focus_border_color: if($variant == 'light', transparentize(white, 0.2), transparentize(white,0.7)); 74 | $dim_label_opacity: 0.55; 75 | -------------------------------------------------------------------------------- /src/lib/stylesheet/processed/Adwaita-dark.css: -------------------------------------------------------------------------------- 1 | @define-color base_color #2d2d2d; 2 | @define-color text_color white; 3 | @define-color bg_color #353535; 4 | @define-color fg_color #eeeeec; 5 | @define-color selected_fg_color #ffffff; 6 | @define-color selected_bg_color #15539e; 7 | @define-color selected_borders_color #030c17; 8 | @define-color borders_color #1b1b1b; 9 | @define-color alt_borders_color #070707; 10 | @define-color borders_edge rgba(238, 238, 236, 0.07); 11 | @define-color link_color #3584e4; 12 | @define-color link_visited_color #1b6acb; 13 | @define-color top_hilight rgba(238, 238, 236, 0.07); 14 | @define-color dark_fill #282828; 15 | @define-color headerbar_bg_color #2d2d2d; 16 | @define-color menu_color #2d2d2d; 17 | @define-color menu_selected_color #202020; 18 | @define-color scrollbar_bg_color #313131; 19 | @define-color scrollbar_slider_color #a4a4a3; 20 | @define-color scrollbar_slider_hover_color #c9c9c7; 21 | @define-color scrollbar_slider_active_color #1b6acb; 22 | @define-color warning_color #f57900; 23 | @define-color error_color #cc0000; 24 | @define-color success_color #26ab62; 25 | @define-color destructive_color #b2161d; 26 | @define-color osd_fg_color #eeeeec; 27 | @define-color osd_text_color white; 28 | @define-color osd_bg_color rgba(38, 38, 38, 0.7); 29 | @define-color osd_insensitive_bg_color rgba(58, 58, 57, 0.5); 30 | @define-color osd_insensitive_fg_color #8a8a89; 31 | @define-color osd_borders_color rgba(0, 0, 0, 0.7); 32 | @define-color sidebar_bg_color #313131; 33 | @define-color tooltip_borders_color rgba(255, 255, 255, 0.1); 34 | @define-color shadow_color rgba(0, 0, 0, 0.1); 35 | @define-color drop_target_color #26a269; 36 | @define-color insensitive_fg_color #919190; 37 | @define-color insensitive_bg_color #323232; 38 | @define-color insensitive_borders_color #202020; 39 | @define-color backdrop_base_color #303030; 40 | @define-color backdrop_text_color #d6d6d6; 41 | @define-color backdrop_bg_color #353535; 42 | @define-color backdrop_fg_color #919190; 43 | @define-color backdrop_insensitive_color #5b5b5b; 44 | @define-color backdrop_selected_fg_color #d6d6d6; 45 | @define-color backdrop_borders_color #202020; 46 | @define-color backdrop_dark_fill #2e2e2e; 47 | @define-color suggested_bg_color #15539e; 48 | @define-color suggested_border_color #030c17; 49 | @define-color progress_bg_color #15539e; 50 | @define-color progress_border_color #030c17; 51 | @define-color checkradio_bg_color #15539e; 52 | @define-color checkradio_fg_color #ffffff; 53 | @define-color checkradio_borders_color #092444; 54 | @define-color switch_bg_color #15539e; 55 | @define-color switch_borders_color #030c17; 56 | @define-color focus_border_color rgba(21, 83, 158, 0.7); 57 | @define-color alt_focus_border_color rgba(255, 255, 255, 0.3); 58 | @define-color dim_label_opacity 0.55; 59 | button { color: #eeeeec; outline-color: rgba(21, 83, 158, 0.7); border-color: #1b1b1b; background-image: linear-gradient(to top, #373737 2px, #3a3a3a); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 60 | 61 | button:hover { color: #eeeeec; border-color: #1b1b1b; background-image: linear-gradient(to top, #303030 20%, #323232 90%); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 62 | 63 | button:checked { color: #eeeeec; border-color: #1b1b1b; background-image: image(#232323); box-shadow: none; } 64 | 65 | button:checked:hover { color: #eeeeec; border-color: #1b1b1b; background-image: image(#1b1b1b); box-shadow: none; } 66 | 67 | button:checked:active { color: #eeeeec; border-color: #1b1b1b; background-image: image(#161616); box-shadow: none; } 68 | 69 | button:backdrop { color: #919190; border-color: #202020; background-image: image(#353535); box-shadow: none; } 70 | 71 | button:backdrop:active { color: #919190; border-color: #202020; background-image: image(#2e2e2e); box-shadow: none; } 72 | 73 | button:backdrop:insensitive { color: #5b5b5b; border-color: #202020; background-image: image(#323232); box-shadow: none; } 74 | 75 | button:backdrop:insensitive:active { color: #5b5b5b; border-color: #202020; background-image: image(#2e2e2e); box-shadow: none; } 76 | 77 | button:disabled { color: #919190; border-color: #202020; background-image: image(#323232); } 78 | 79 | button:disabled:active { color: #919190; border-color: #202020; background-image: image(#292929); box-shadow: none; } 80 | 81 | checkradio { background-clip: padding-box; background-image: linear-gradient(to bottom, #424242 20%, #353535 90%); border-color: #070707; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 82 | 83 | checkradio:hover { background-image: linear-gradient(to bottom, #4c4c4c 10%, #3f3f3f 90%); } 84 | 85 | checkradio:active { box-shadow: inset 0 1px black; background-image: image(#282828); } 86 | 87 | checkradio:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 88 | 89 | checkradio:checked { background-clip: border-box; background-image: linear-gradient(to bottom, #185fb4 20%, #15539e 90%); border-color: #092444; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 90 | 91 | checkradio:checked:hover { background-image: linear-gradient(to bottom, #1b68c6 10%, #185cb0 90%); } 92 | 93 | checkradio:checked:active { box-shadow: inset 0 1px black; background-image: image(#124787); } 94 | 95 | checkradio:checked:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 96 | -------------------------------------------------------------------------------- /src/lib/stylesheet/processed/Adwaita-hc-dark.css: -------------------------------------------------------------------------------- 1 | @define-color base_color #2d2d2d; 2 | @define-color text_color white; 3 | @define-color bg_color #303030; 4 | @define-color fg_color #f3f3f1; 5 | @define-color selected_fg_color #ffffff; 6 | @define-color selected_bg_color #0f3b71; 7 | @define-color selected_borders_color black; 8 | @define-color borders_color #686868; 9 | @define-color alt_borders_color #4e4e4e; 10 | @define-color borders_edge rgba(238, 238, 236, 0.07); 11 | @define-color link_color #3584e4; 12 | @define-color link_visited_color #1b6acb; 13 | @define-color top_hilight rgba(238, 238, 236, 0.07); 14 | @define-color dark_fill #282828; 15 | @define-color headerbar_bg_color #2d2d2d; 16 | @define-color menu_color #2d2d2d; 17 | @define-color menu_selected_color #161616; 18 | @define-color scrollbar_bg_color #313131; 19 | @define-color scrollbar_slider_color #a4a4a3; 20 | @define-color scrollbar_slider_hover_color #c9c9c7; 21 | @define-color scrollbar_slider_active_color #1b6acb; 22 | @define-color warning_color #f57900; 23 | @define-color error_color #cc0000; 24 | @define-color success_color #26ab62; 25 | @define-color destructive_color #b2161d; 26 | @define-color osd_fg_color #eeeeec; 27 | @define-color osd_text_color white; 28 | @define-color osd_bg_color rgba(38, 38, 38, 0.7); 29 | @define-color osd_insensitive_bg_color rgba(58, 58, 57, 0.5); 30 | @define-color osd_insensitive_fg_color #8a8a89; 31 | @define-color osd_borders_color rgba(0, 0, 0, 0.7); 32 | @define-color sidebar_bg_color #313131; 33 | @define-color tooltip_borders_color rgba(255, 255, 255, 0.1); 34 | @define-color shadow_color rgba(0, 0, 0, 0.1); 35 | @define-color drop_target_color #26a269; 36 | @define-color insensitive_fg_color #919191; 37 | @define-color insensitive_bg_color #2f2f2f; 38 | @define-color insensitive_borders_color #5d5d5d; 39 | @define-color backdrop_base_color #303030; 40 | @define-color backdrop_text_color #d6d6d6; 41 | @define-color backdrop_bg_color #353535; 42 | @define-color backdrop_fg_color #919190; 43 | @define-color backdrop_insensitive_color #5b5b5b; 44 | @define-color backdrop_selected_fg_color #d6d6d6; 45 | @define-color backdrop_borders_color #202020; 46 | @define-color backdrop_dark_fill #2e2e2e; 47 | @define-color suggested_bg_color #15539e; 48 | @define-color suggested_border_color #030c17; 49 | @define-color progress_bg_color #15539e; 50 | @define-color progress_border_color #030c17; 51 | @define-color checkradio_bg_color #15539e; 52 | @define-color checkradio_fg_color #ffffff; 53 | @define-color checkradio_borders_color #092444; 54 | @define-color switch_bg_color #15539e; 55 | @define-color switch_borders_color #1f76e1; 56 | @define-color focus_border_color rgba(255, 255, 255, 0.6); 57 | @define-color alt_focus_border_color rgba(255, 255, 255, 0.6); 58 | @define-color dim_label_opacity 0.9; 59 | button { color: #f3f3f1; outline-color: rgba(255, 255, 255, 0.6); border-color: #686868; background-image: linear-gradient(to top, #323232 2px, #353535); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 60 | 61 | button:hover { color: #f3f3f1; border-color: #686868; background-image: linear-gradient(to top, #2b2b2b 20%, #2d2d2d 90%); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 62 | 63 | button:checked { color: #f3f3f1; border-color: #686868; background-image: image(#1e1e1e); box-shadow: none; } 64 | 65 | button:checked:hover { color: #f3f3f1; border-color: #686868; background-image: image(#161616); box-shadow: none; } 66 | 67 | button:checked:active { color: #f3f3f1; border-color: #686868; background-image: image(#111111); box-shadow: none; } 68 | 69 | button:backdrop { color: #919190; border-color: #202020; background-image: image(#353535); box-shadow: none; } 70 | 71 | button:backdrop:active { color: #919190; border-color: #202020; background-image: image(#2a2a2a); box-shadow: none; } 72 | 73 | button:backdrop:insensitive { color: #5b5b5b; border-color: #202020; background-image: image(#2f2f2f); box-shadow: none; } 74 | 75 | button:backdrop:insensitive:active { color: #5b5b5b; border-color: #202020; background-image: image(#2a2a2a); box-shadow: none; } 76 | 77 | button:disabled { color: #919191; border-color: #5d5d5d; background-image: image(#2f2f2f); } 78 | 79 | button:disabled:active { color: #919191; border-color: #5d5d5d; background-image: image(#252525); box-shadow: none; } 80 | 81 | checkradio { background-clip: padding-box; background-image: linear-gradient(to bottom, #3c3c3c 20%, #303030 90%); border-color: #4e4e4e; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 82 | 83 | checkradio:hover { background-image: linear-gradient(to bottom, #474747 10%, #3a3a3a 90%); } 84 | 85 | checkradio:active { box-shadow: inset 0 1px black; background-image: image(#232323); } 86 | 87 | checkradio:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 88 | 89 | checkradio:checked { background-clip: border-box; background-image: linear-gradient(to bottom, #185fb4 20%, #15539e 90%); border-color: #092444; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 90 | 91 | checkradio:checked:hover { background-image: linear-gradient(to bottom, #1b68c6 10%, #185cb0 90%); } 92 | 93 | checkradio:checked:active { box-shadow: inset 0 1px black; background-image: image(#124787); } 94 | 95 | checkradio:checked:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 96 | -------------------------------------------------------------------------------- /src/lib/stylesheet/processed/Adwaita-hc.css: -------------------------------------------------------------------------------- 1 | @define-color base_color #ffffff; 2 | @define-color text_color black; 3 | @define-color bg_color #fdfdfc; 4 | @define-color fg_color #272c2e; 5 | @define-color selected_fg_color #ffffff; 6 | @define-color selected_bg_color #1b6acb; 7 | @define-color selected_borders_color #124787; 8 | @define-color borders_color #877b6e; 9 | @define-color alt_borders_color #6e645a; 10 | @define-color borders_edge rgba(255, 255, 255, 0.8); 11 | @define-color link_color #1b6acb; 12 | @define-color link_visited_color #15539e; 13 | @define-color top_hilight rgba(255, 255, 255, 0.8); 14 | @define-color dark_fill #e1dedb; 15 | @define-color headerbar_bg_color white; 16 | @define-color menu_color #ffffff; 17 | @define-color menu_selected_color #e6e3e0; 18 | @define-color scrollbar_bg_color #cecece; 19 | @define-color scrollbar_slider_color #7e8182; 20 | @define-color scrollbar_slider_hover_color #565b5c; 21 | @define-color scrollbar_slider_active_color #1b6acb; 22 | @define-color warning_color #f57900; 23 | @define-color error_color #cc0000; 24 | @define-color success_color #33d17a; 25 | @define-color destructive_color #e01b24; 26 | @define-color osd_fg_color #eeeeec; 27 | @define-color osd_text_color white; 28 | @define-color osd_bg_color rgba(53, 53, 53, 0.7); 29 | @define-color osd_insensitive_bg_color rgba(71, 71, 71, 0.5); 30 | @define-color osd_insensitive_fg_color #919190; 31 | @define-color osd_borders_color rgba(0, 0, 0, 0.7); 32 | @define-color sidebar_bg_color #fbfafa; 33 | @define-color tooltip_borders_color rgba(255, 255, 255, 0.1); 34 | @define-color shadow_color rgba(0, 0, 0, 0.1); 35 | @define-color drop_target_color #2ec27e; 36 | @define-color insensitive_fg_color #929495; 37 | @define-color insensitive_bg_color #fefefd; 38 | @define-color insensitive_borders_color #9e958b; 39 | @define-color backdrop_base_color #fcfcfc; 40 | @define-color backdrop_text_color #323232; 41 | @define-color backdrop_bg_color #f6f5f4; 42 | @define-color backdrop_fg_color #929595; 43 | @define-color backdrop_insensitive_color #d4cfca; 44 | @define-color backdrop_selected_fg_color #fcfcfc; 45 | @define-color backdrop_borders_color #d5d0cc; 46 | @define-color backdrop_dark_fill #eae8e6; 47 | @define-color suggested_bg_color #3584e4; 48 | @define-color suggested_border_color #185fb4; 49 | @define-color progress_bg_color #3584e4; 50 | @define-color progress_border_color #185fb4; 51 | @define-color checkradio_bg_color #3584e4; 52 | @define-color checkradio_fg_color #ffffff; 53 | @define-color checkradio_borders_color #1b6acb; 54 | @define-color switch_bg_color #3584e4; 55 | @define-color switch_borders_color #185fb4; 56 | @define-color focus_border_color rgba(27, 106, 203, 0.8); 57 | @define-color alt_focus_border_color white; 58 | @define-color dim_label_opacity 0.9; 59 | button { color: #272c2e; outline-color: rgba(27, 106, 203, 0.8); border-color: #877b6e; background-image: linear-gradient(to top, #fafaf9 2px, white); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 60 | 61 | button:hover { color: #272c2e; border-color: #877b6e; background-image: linear-gradient(to top, #dad6d2, #edebe9 1px); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 62 | 63 | button:checked { color: #272c2e; border-color: #877b6e; background-image: image(#dfdbd8); box-shadow: none; } 64 | 65 | button:checked:hover { color: #272c2e; border-color: #877b6e; background-image: image(#d6d1cd); box-shadow: none; } 66 | 67 | button:checked:active { color: #272c2e; border-color: #877b6e; background-image: image(#cdc7c1); box-shadow: none; } 68 | 69 | button:backdrop { color: #929595; border-color: #d5d0cc; background-image: image(#f6f5f4); box-shadow: none; } 70 | 71 | button:backdrop:active { color: #929595; border-color: #d5d0cc; background-image: image(#ebebeb); box-shadow: none; } 72 | 73 | button:backdrop:insensitive { color: #d4cfca; border-color: #d5d0cc; background-image: image(#fefefd); box-shadow: none; } 74 | 75 | button:backdrop:insensitive:active { color: #d4cfca; border-color: #d5d0cc; background-image: image(#ebebeb); box-shadow: none; } 76 | 77 | button:disabled { color: #929495; border-color: #9e958b; background-image: image(#fefefd); } 78 | 79 | button:disabled:active { color: #929495; border-color: #9e958b; background-image: image(#ebebeb); box-shadow: none; } 80 | 81 | checkradio { background-clip: padding-box; background-image: linear-gradient(to bottom, white 20%, white 90%); border-color: #6e645a; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 82 | 83 | checkradio:hover { background-image: image(#f2f2f2); } 84 | 85 | checkradio:active { box-shadow: inset 0 1px rgba(0, 0, 0, 0.2); background-image: image(#d9d9d9); } 86 | 87 | checkradio:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 88 | 89 | checkradio:checked { background-clip: border-box; background-image: linear-gradient(to bottom, #4b92e7 20%, #3584e4 90%); border-color: #1b6acb; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 90 | 91 | checkradio:checked:hover { background-image: linear-gradient(to bottom, #5d9de9 10%, #478fe6 90%); } 92 | 93 | checkradio:checked:active { box-shadow: inset 0 1px rgba(0, 0, 0, 0.2); background-image: image(#1f76e1); } 94 | 95 | checkradio:checked:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 96 | -------------------------------------------------------------------------------- /src/lib/stylesheet/processed/Adwaita-light.css: -------------------------------------------------------------------------------- 1 | @define-color base_color #ffffff; 2 | @define-color text_color black; 3 | @define-color bg_color #f6f5f4; 4 | @define-color fg_color #2e3436; 5 | @define-color selected_fg_color #ffffff; 6 | @define-color selected_bg_color #3584e4; 7 | @define-color selected_borders_color #185fb4; 8 | @define-color borders_color #cdc7c2; 9 | @define-color alt_borders_color #bfb8b1; 10 | @define-color borders_edge rgba(255, 255, 255, 0.8); 11 | @define-color link_color #1b6acb; 12 | @define-color link_visited_color #15539e; 13 | @define-color top_hilight rgba(255, 255, 255, 0.8); 14 | @define-color dark_fill #e1dedb; 15 | @define-color headerbar_bg_color white; 16 | @define-color menu_color #ffffff; 17 | @define-color menu_selected_color #e8e6e3; 18 | @define-color scrollbar_bg_color #cecece; 19 | @define-color scrollbar_slider_color #7e8182; 20 | @define-color scrollbar_slider_hover_color #565b5c; 21 | @define-color scrollbar_slider_active_color #1b6acb; 22 | @define-color warning_color #f57900; 23 | @define-color error_color #cc0000; 24 | @define-color success_color #33d17a; 25 | @define-color destructive_color #e01b24; 26 | @define-color osd_fg_color #eeeeec; 27 | @define-color osd_text_color white; 28 | @define-color osd_bg_color rgba(53, 53, 53, 0.7); 29 | @define-color osd_insensitive_bg_color rgba(71, 71, 71, 0.5); 30 | @define-color osd_insensitive_fg_color #919190; 31 | @define-color osd_borders_color rgba(0, 0, 0, 0.7); 32 | @define-color sidebar_bg_color #fbfafa; 33 | @define-color tooltip_borders_color rgba(255, 255, 255, 0.1); 34 | @define-color shadow_color rgba(0, 0, 0, 0.1); 35 | @define-color drop_target_color #2ec27e; 36 | @define-color insensitive_fg_color #929595; 37 | @define-color insensitive_bg_color #faf9f8; 38 | @define-color insensitive_borders_color #d5d0cc; 39 | @define-color backdrop_base_color #fcfcfc; 40 | @define-color backdrop_text_color #323232; 41 | @define-color backdrop_bg_color #f6f5f4; 42 | @define-color backdrop_fg_color #929595; 43 | @define-color backdrop_insensitive_color #d4cfca; 44 | @define-color backdrop_selected_fg_color #fcfcfc; 45 | @define-color backdrop_borders_color #d5d0cc; 46 | @define-color backdrop_dark_fill #eae8e6; 47 | @define-color suggested_bg_color #3584e4; 48 | @define-color suggested_border_color #185fb4; 49 | @define-color progress_bg_color #3584e4; 50 | @define-color progress_border_color #185fb4; 51 | @define-color checkradio_bg_color #3584e4; 52 | @define-color checkradio_fg_color #ffffff; 53 | @define-color checkradio_borders_color #1b6acb; 54 | @define-color switch_bg_color #3584e4; 55 | @define-color switch_borders_color #185fb4; 56 | @define-color focus_border_color rgba(53, 132, 228, 0.5); 57 | @define-color alt_focus_border_color rgba(255, 255, 255, 0.8); 58 | @define-color dim_label_opacity 0.55; 59 | button { color: #2e3436; outline-color: rgba(53, 132, 228, 0.5); border-color: #cdc7c2; background-image: linear-gradient(to top, #f6f5f4 2px, #fbfafa); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 60 | 61 | button:hover { color: #2e3436; border-color: #cdc7c2; background-image: linear-gradient(to top, #d6d1cd, #e8e6e3 1px); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07); } 62 | 63 | button:checked { color: #2e3436; border-color: #cdc7c2; background-image: image(#dad6d2); box-shadow: none; } 64 | 65 | button:checked:hover { color: #2e3436; border-color: #cdc7c2; background-image: image(#d1ccc7); box-shadow: none; } 66 | 67 | button:checked:active { color: #2e3436; border-color: #cdc7c2; background-image: image(#c8c2bc); box-shadow: none; } 68 | 69 | button:backdrop { color: #929595; border-color: #d5d0cc; background-image: image(#f6f5f4); box-shadow: none; } 70 | 71 | button:backdrop:active { color: #929595; border-color: #d5d0cc; background-image: image(#e9e9e3); box-shadow: none; } 72 | 73 | button:backdrop:insensitive { color: #d4cfca; border-color: #d5d0cc; background-image: image(#faf9f8); box-shadow: none; } 74 | 75 | button:backdrop:insensitive:active { color: #d4cfca; border-color: #d5d0cc; background-image: image(#e9e9e3); box-shadow: none; } 76 | 77 | button:disabled { color: #929595; border-color: #d5d0cc; background-image: image(#faf9f8); } 78 | 79 | button:disabled:active { color: #929595; border-color: #d5d0cc; background-image: image(#e9e9e3); box-shadow: none; } 80 | 81 | checkradio { background-clip: padding-box; background-image: linear-gradient(to bottom, white 20%, white 90%); border-color: #bfb8b1; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 82 | 83 | checkradio:hover { background-image: image(#f2f2f2); } 84 | 85 | checkradio:active { box-shadow: inset 0 1px rgba(0, 0, 0, 0.2); background-image: image(#d9d9d9); } 86 | 87 | checkradio:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 88 | 89 | checkradio:checked { background-clip: border-box; background-image: linear-gradient(to bottom, #4b92e7 20%, #3584e4 90%); border-color: #1b6acb; box-shadow: 0 1px rgba(0, 0, 0, 0.05); color: #ffffff; } 90 | 91 | checkradio:checked:hover { background-image: linear-gradient(to bottom, #5d9de9 10%, #478fe6 90%); } 92 | 93 | checkradio:checked:active { box-shadow: inset 0 1px rgba(0, 0, 0, 0.2); background-image: image(#1f76e1); } 94 | 95 | checkradio:checked:disabled { box-shadow: none; color: rgba(255, 255, 255, 0.7); } 96 | -------------------------------------------------------------------------------- /src/lib/stylesheet/stylesheet.qrc.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | @STYLESHEET_PATH@/Adwaita-light.css 4 | @STYLESHEET_PATH@/Adwaita-dark.css 5 | @STYLESHEET_PATH@/Adwaita-hc.css 6 | @STYLESHEET_PATH@/Adwaita-hc-dark.css 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/style/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories( 3 | ${CMAKE_BINARY_DIR}/src/lib # for adwaita-config.h 4 | ${CMAKE_SOURCE_DIR}/src/lib 5 | ${CMAKE_CURRENT_SOURCE_DIR} 6 | ) 7 | 8 | set(Adwaita_SRCS 9 | adwaitahelper.cpp 10 | adwaitastyle.cpp 11 | adwaitastyleplugin.cpp 12 | ) 13 | 14 | add_definitions(-DQT_PLUGIN) 15 | 16 | if (MSVC) 17 | add_definitions(-D_USE_MATH_DEFINES) # Needed for M_PI on MSVC 18 | endif() 19 | 20 | set(LIBRARY_NAME "adwaita-qt") 21 | 22 | add_library(${LIBRARY_NAME} MODULE ${Adwaita_SRCS}) 23 | target_link_libraries(${LIBRARY_NAME} 24 | adwaitaqt${ADWAITAQT_SUFFIX} 25 | adwaitaqt${ADWAITAQT_SUFFIX}priv 26 | Qt${QT_VERSION_MAJOR}::Core 27 | Qt${QT_VERSION_MAJOR}::DBus 28 | Qt${QT_VERSION_MAJOR}::Gui 29 | Qt${QT_VERSION_MAJOR}::Widgets 30 | ) 31 | 32 | if (ADWAITA_HAVE_X11) 33 | target_link_libraries(${LIBRARY_NAME} ${XCB_LIBRARIES} Qt${QT_VERSION_MAJOR}::X11Extras) 34 | endif() 35 | 36 | if (NOT APPLE AND NOT WIN32) 37 | set_target_properties(${LIBRARY_NAME} PROPERTIES 38 | LINK_FLAGS "-Wl,--no-undefined" 39 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 40 | OUTPUT_NAME "adwaita" 41 | PREFIX "") 42 | endif() 43 | 44 | install(TARGETS ${LIBRARY_NAME} DESTINATION "${QT_PLUGINS_DIR}/styles") 45 | -------------------------------------------------------------------------------- /src/style/adwaita.json: -------------------------------------------------------------------------------- 1 | { "Keys": [ "Adwaita", "Adwaita-Dark", "Adwaita-HighContrast", "Adwaita-HighContrastInverse", "HighContrast", "HighContrastInverse" ] } 2 | -------------------------------------------------------------------------------- /src/style/adwaita.themerc: -------------------------------------------------------------------------------- 1 | [Misc] 2 | Name=Adwaita 3 | Comment=Qt widget style for GNOME 4 | [KDE] 5 | WidgetStyle=Adwaita 6 | -------------------------------------------------------------------------------- /src/style/adwaitahelper.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 3 | * Copyright (C) 2014-2018 Martin Bříza * 4 | * Copyright (C) 2019-2021 Jan Grulich * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, write to the * 18 | * Free Software Foundation, Inc., * 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 20 | *************************************************************************/ 21 | 22 | #ifndef ADWAITA_HELPER_H 23 | #define ADWAITA_HELPER_H 24 | 25 | #include "adwaita.h" 26 | #include "config-adwaita.h" 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | #if ADWAITA_HAVE_X11 35 | #include 36 | #include 37 | #endif 38 | 39 | namespace Adwaita 40 | { 41 | /* 42 | * Adwaita style helper class. 43 | * contains utility functions used at multiple places in both adwaita style and adwaita window decoration 44 | */ 45 | class Helper 46 | { 47 | public: 48 | explicit Helper(); 49 | 50 | virtual ~Helper() = default; 51 | 52 | static bool isWindowActive(const QWidget *widget); 53 | 54 | // true if style was compiled for and is running on X11 55 | static bool isX11(); 56 | 57 | // true if running on platform Wayland 58 | static bool isWayland(); 59 | 60 | // returns true if compositing is active 61 | bool compositingActive() const; 62 | 63 | // returns true if a given widget supports alpha channel 64 | bool hasAlphaChannel(const QWidget *widget ) const; 65 | 66 | // return dpi-aware pixmap of given size 67 | virtual QPixmap highDpiPixmap(const QSize &size) const 68 | { 69 | return highDpiPixmap(size.width(), size.height()); 70 | } 71 | 72 | // return dpi-aware pixmap of given size 73 | virtual QPixmap highDpiPixmap(int width) const 74 | { 75 | return highDpiPixmap(width, width); 76 | } 77 | 78 | // return dpi-aware pixmap of given size 79 | virtual QPixmap highDpiPixmap(int width, int height) const; 80 | 81 | // return device pixel ratio for a given pixmap 82 | virtual qreal devicePixelRatio(const QPixmap &pixmap) const; 83 | 84 | #if ADWAITA_HAVE_X11 85 | // get xcb connection 86 | static xcb_connection_t *connection(); 87 | 88 | // create xcb atom 89 | xcb_atom_t createAtom(const QString &name) const; 90 | 91 | #endif 92 | 93 | void setVariant(QWidget *widget, const QByteArray &variant); 94 | 95 | protected: 96 | // initialize 97 | void init(void); 98 | 99 | private: 100 | #if ADWAITA_HAVE_X11 101 | // atom used for compositing manager 102 | xcb_atom_t _compositingManagerAtom; 103 | #endif 104 | }; 105 | 106 | } 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/style/adwaitastyleplugin.cpp: -------------------------------------------------------------------------------- 1 | 2 | /************************************************************************* 3 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify * 6 | * it under the terms of the GNU General Public License as published by * 7 | * the Free Software Foundation; either version 2 of the License, or * 8 | * (at your option) any later version. * 9 | * * 10 | * This program is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 | * GNU General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program; if not, write to the * 17 | * Free Software Foundation, Inc., * 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 19 | *************************************************************************/ 20 | 21 | #include "adwaitastyleplugin.h" 22 | #include "adwaitastyle.h" 23 | #include "adwaita.h" 24 | 25 | #include 26 | 27 | namespace Adwaita 28 | { 29 | 30 | QStyle *StylePlugin::create(const QString &key) 31 | { 32 | if (key.toLower() == QStringLiteral("adwaita")) { 33 | return new Style(Adwaita::Adwaita); 34 | } 35 | 36 | if (key.toLower() == QStringLiteral("adwaita-dark")) { 37 | return new Style(Adwaita::AdwaitaDark); 38 | } 39 | 40 | if (key.toLower() == QStringLiteral("adwaita-highcontrast") || 41 | key.toLower() == QStringLiteral("highcontrast")) { 42 | return new Style(Adwaita::AdwaitaHighcontrast); 43 | } 44 | 45 | if (key.toLower() == QStringLiteral("adwaita-highcontrastinverse") || 46 | key.toLower() == QStringLiteral("highcontrastinverse")) { 47 | return new Style(Adwaita::AdwaitaHighcontrastInverse); 48 | } 49 | 50 | return nullptr; 51 | } 52 | 53 | StylePlugin::~StylePlugin() 54 | { 55 | } 56 | 57 | QStringList StylePlugin::keys() const 58 | { 59 | return QStringList() << QStringLiteral("Adwaita") << QStringLiteral("Adwaita-Dark") << QStringLiteral("Adwaita-Light") 60 | << QStringLiteral("Adwaita-HighContrast") << QStringLiteral("Adwaita-HighContrastInverse"); 61 | } 62 | 63 | } // namespace Adwaita 64 | -------------------------------------------------------------------------------- /src/style/adwaitastyleplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef ADWAITA_STYLE_PLUGIN_H 2 | #define ADWAITA_STYLE_PLUGIN_H 3 | 4 | /************************************************************************* 5 | * Copyright (C) 2014 by Hugo Pereira Da Costa * 6 | * * 7 | * This program is free software; you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation; either version 2 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * This program is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with this program; if not, write to the * 19 | * Free Software Foundation, Inc., * 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 21 | *************************************************************************/ 22 | 23 | #include 24 | 25 | namespace Adwaita 26 | { 27 | 28 | class StylePlugin : public QStylePlugin 29 | { 30 | Q_OBJECT 31 | 32 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "adwaita.json") 33 | public: 34 | 35 | //* constructor 36 | explicit StylePlugin(QObject *parent = 0): 37 | QStylePlugin(parent) 38 | {} 39 | 40 | //* destructor 41 | ~StylePlugin(); 42 | 43 | //* returns list of valid keys 44 | QStringList keys() const; 45 | 46 | //* create style 47 | QStyle *create(const QString &key); 48 | }; 49 | 50 | } // namespace Adwaita 51 | 52 | #endif // ADWAITA_STYLE_PLUGIN_H 53 | --------------------------------------------------------------------------------