├── screenshots ├── kde.png ├── lxqt.png ├── win7.png ├── screen.png ├── win10mercy.png └── logo │ ├── favicon.png │ ├── logotype-a.png │ ├── logotype-b.png │ ├── favicon.svg │ ├── logotype-a.svg │ └── logotype-b.svg ├── .gitignore ├── examples └── Test │ ├── icons │ ├── Scale.png │ ├── close.png │ ├── Flaps_mode.png │ ├── Move_mode.png │ ├── light_bulb.png │ ├── 48px-Printer.png │ ├── Help-browser.png │ ├── Select_mode.png │ ├── stupid_logo.png │ ├── 48px-AddTexture.png │ ├── 48px-Edit-redo.png │ ├── 48px-Edit-undo.png │ ├── 48px-Go-bottom.png │ ├── 48px-Polypaint.png │ ├── 48px-Document-new.png │ ├── 48px-View-refresh.png │ ├── 48px-Document-open.png │ ├── 48px-Document-save.png │ ├── 48px-Image-x-Remove.png │ ├── 48px-Image-x-generic.png │ ├── 48px-System-log-out.png │ ├── 48px-View-zoom-fit.png │ ├── 48px-Document-save-as.png │ ├── 48px-Antialias_Icon.svg.png │ ├── 48px-Preferences-system.png │ └── 48px-Package-x-generic.svg.png │ ├── main.cpp │ ├── mainwindow.h │ ├── CMakeLists.txt │ ├── res.qrc │ ├── mainwindow.ui │ ├── tabtoolbar.json │ └── mainwindow.cpp ├── src └── TabToolbar │ ├── StyleTemplate.qrc │ ├── ToolButtonStyle.h │ ├── CompactToolButton.h │ ├── CMakeLists.txt │ ├── StyleTemplate.qss │ ├── Page.cpp │ ├── SubGroup.cpp │ ├── Group.cpp │ ├── CompactToolButton.cpp │ ├── StyleTools.cpp │ ├── ToolButtonStyle.cpp │ ├── TabToolbar.cpp │ ├── Builder.cpp │ └── Styles.cpp ├── LICENSE ├── .appveyor.yml ├── .travis.yml ├── CMakeLists.txt ├── include └── TabToolbar │ ├── API.h │ ├── Page.h │ ├── Group.h │ ├── Builder.h │ ├── StyleTools.h │ ├── SubGroup.h │ ├── TabToolbar.h │ └── Styles.h ├── cmake-modules └── FindTabToolbar.cmake ├── README.md ├── COPYING.LESSER └── COPYING /screenshots/kde.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/kde.png -------------------------------------------------------------------------------- /screenshots/lxqt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/lxqt.png -------------------------------------------------------------------------------- /screenshots/win7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/win7.png -------------------------------------------------------------------------------- /screenshots/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/screen.png -------------------------------------------------------------------------------- /screenshots/win10mercy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/win10mercy.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /debug/* 2 | /release/* 3 | *.Debug 4 | *.Release 5 | Makefile 6 | .qmake.stash 7 | *.user 8 | ui*.h 9 | -------------------------------------------------------------------------------- /examples/Test/icons/Scale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/Scale.png -------------------------------------------------------------------------------- /examples/Test/icons/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/close.png -------------------------------------------------------------------------------- /screenshots/logo/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/logo/favicon.png -------------------------------------------------------------------------------- /screenshots/logo/logotype-a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/logo/logotype-a.png -------------------------------------------------------------------------------- /screenshots/logo/logotype-b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/screenshots/logo/logotype-b.png -------------------------------------------------------------------------------- /examples/Test/icons/Flaps_mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/Flaps_mode.png -------------------------------------------------------------------------------- /examples/Test/icons/Move_mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/Move_mode.png -------------------------------------------------------------------------------- /examples/Test/icons/light_bulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/light_bulb.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Printer.png -------------------------------------------------------------------------------- /examples/Test/icons/Help-browser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/Help-browser.png -------------------------------------------------------------------------------- /examples/Test/icons/Select_mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/Select_mode.png -------------------------------------------------------------------------------- /examples/Test/icons/stupid_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/stupid_logo.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-AddTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-AddTexture.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Edit-redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Edit-redo.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Edit-undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Edit-undo.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Go-bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Go-bottom.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Polypaint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Polypaint.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Document-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Document-new.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-View-refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-View-refresh.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Document-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Document-open.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Document-save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Document-save.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Image-x-Remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Image-x-Remove.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Image-x-generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Image-x-generic.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-System-log-out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-System-log-out.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-View-zoom-fit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-View-zoom-fit.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Document-save-as.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Document-save-as.png -------------------------------------------------------------------------------- /src/TabToolbar/StyleTemplate.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | StyleTemplate.qss 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/Test/icons/48px-Antialias_Icon.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Antialias_Icon.svg.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Preferences-system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Preferences-system.png -------------------------------------------------------------------------------- /examples/Test/icons/48px-Package-x-generic.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SeriousAlexej/TabToolbar/HEAD/examples/Test/icons/48px-Package-x-generic.svg.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | TabToolbar - Copyright (C) 2018 Oleksii Sierov 2 | 3 | This software uses LGPL v3.0 license. 4 | For more details see COPYING and COPYING.LESSER 5 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | image: Visual Studio 2015 4 | 5 | clone_folder: c:\projects\tt 6 | 7 | clone_depth: 1 8 | 9 | before_build: 10 | - set CMAKE_PREFIX_PATH=C:\Qt\5.13.2\msvc2015_64\ 11 | - cmake -G "Visual Studio 14 2015 Win64" -DTT_BUILD_EXAMPLES=TRUE 12 | 13 | build: 14 | parallel: true 15 | project: TabToolbar.sln 16 | verbosity: normal -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c++ 2 | 3 | sudo: required 4 | dist: trusty 5 | group: deprecated-2017Q4 6 | 7 | compiler: 8 | - gcc 9 | 10 | os: 11 | - linux 12 | 13 | before_install: 14 | - sudo add-apt-repository --yes ppa:beineri/opt-qt591-trusty 15 | - sudo apt-get update 16 | - sudo apt-get install qt59-meta-full 17 | 18 | before_script: 19 | - QT_ENV_SCRIPT=$(find /opt -name 'qt*-env.sh') 20 | - source $QT_ENV_SCRIPT 21 | 22 | script: 23 | - cmake -DCMAKE_BUILD_TYPE=Release -DTT_BUILD_EXAMPLES=TRUE && cmake --build . -------------------------------------------------------------------------------- /examples/Test/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include "mainwindow.h" 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | QApplication a(argc, argv); 24 | CMainWindow w; 25 | w.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | set(CMAKE_CXX_STANDARD 11) 3 | 4 | add_compile_options("$<$:/utf-8>") 5 | add_compile_options("$<$:/utf-8>") 6 | 7 | if(WIN32) 8 | set(INSTALL_MISC_DIR .) 9 | else() 10 | set(INSTALL_MISC_DIR share/TabToolbar) 11 | endif() 12 | 13 | project(TabToolbar) 14 | 15 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 16 | 17 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 18 | 19 | set(TT_BUILD_EXAMPLES FALSE CACHE BOOL "Build example projects") 20 | 21 | add_subdirectory(src/TabToolbar) 22 | 23 | if(TT_BUILD_EXAMPLES) 24 | add_subdirectory(examples/Test) 25 | endif() 26 | 27 | install(DIRECTORY include 28 | DESTINATION . 29 | COMPONENT devel 30 | FILES_MATCHING PATTERN "*.h") 31 | install(FILES LICENSE DESTINATION ${INSTALL_MISC_DIR}) 32 | install(FILES COPYING DESTINATION ${INSTALL_MISC_DIR}) 33 | install(FILES COPYING.LESSER DESTINATION ${INSTALL_MISC_DIR}) 34 | install(FILES cmake-modules/FindTabToolbar.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake-modules) 35 | -------------------------------------------------------------------------------- /examples/Test/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef MAINWINDOW_H 19 | #define MAINWINDOW_H 20 | 21 | #include 22 | 23 | namespace Ui { 24 | class MainWindow; 25 | } 26 | 27 | class TTBuilder; 28 | 29 | class CMainWindow : public QMainWindow 30 | { 31 | Q_OBJECT 32 | public: 33 | explicit CMainWindow(QWidget* parent = 0); 34 | ~CMainWindow(); 35 | 36 | private: 37 | 38 | Ui::MainWindow* ui; 39 | TTBuilder* ttb; 40 | }; 41 | 42 | #endif // MAINWINDOW_H 43 | -------------------------------------------------------------------------------- /include/TabToolbar/API.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_API_H 19 | #define TT_API_H 20 | 21 | #if defined(_WIN32) 22 | #ifdef _MSC_VER 23 | #pragma warning(disable: 4251) 24 | #endif 25 | 26 | #if defined(TT_BUILDING_DLL) 27 | #define TT_API __declspec(dllexport) 28 | #else 29 | #define TT_API __declspec(dllimport) 30 | #endif 31 | 32 | #elif defined(__GNUC__) 33 | 34 | #if defined(TT_BUILDING_DLL) 35 | #define TT_API __attribute__((visibility("default"))) 36 | #else 37 | #define TT_API 38 | #endif 39 | 40 | #endif 41 | 42 | #endif //TT_API_H 43 | -------------------------------------------------------------------------------- /examples/Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_AUTOMOC ON) 2 | set(CMAKE_AUTOUIC ON) 3 | set(CMAKE_AUTORCC ON) 4 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 5 | 6 | find_package(Qt5Core 5.3 REQUIRED) 7 | find_package(Qt5Gui 5.3 REQUIRED) 8 | find_package(Qt5Widgets 5.3 REQUIRED) 9 | 10 | set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/Test) 11 | 12 | set(SRC_LIST 13 | ${SRCROOT}/main.cpp 14 | ${SRCROOT}/mainwindow.cpp 15 | ${SRCROOT}/mainwindow.h 16 | ) 17 | 18 | set(UIS 19 | ${SRCROOT}/mainwindow.ui 20 | ) 21 | 22 | set(RES 23 | ${SRCROOT}/res.qrc 24 | ) 25 | 26 | add_executable(Test 27 | ${SRC_LIST} 28 | ${UIS} 29 | ${RES} 30 | ) 31 | 32 | target_link_libraries(Test 33 | TabToolbar 34 | Qt5::Core 35 | Qt5::Gui 36 | Qt5::Widgets 37 | ) 38 | 39 | set_target_properties(Test PROPERTIES DEBUG_POSTFIX d) 40 | set_target_properties(Test PROPERTIES FOLDER "Examples") 41 | 42 | install(TARGETS Test 43 | RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/Test COMPONENT examples 44 | BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/Test COMPONENT examples) 45 | 46 | install(FILES ${SRC_LIST} ${UIS} ${RES} 47 | DESTINATION ${INSTALL_MISC_DIR}/examples/Test 48 | COMPONENT examples) 49 | 50 | install(DIRECTORY "${CMAKE_SOURCE_DIR}/examples/Test/icons" 51 | DESTINATION ${INSTALL_MISC_DIR}/examples/Test 52 | COMPONENT examples) 53 | -------------------------------------------------------------------------------- /src/TabToolbar/ToolButtonStyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_TOOL_BUTTON_STYLE 19 | #define TT_TOOL_BUTTON_STYLE 20 | #include 21 | 22 | class QStyleOptionToolButton; 23 | 24 | namespace tt 25 | { 26 | 27 | //this class uses part of Qt's source code to align text and icon on ToolButton 28 | class TTToolButtonStyle : public QProxyStyle 29 | { 30 | public: 31 | void drawControl(ControlElement element, const QStyleOption* opt, QPainter* p, const QWidget* widget) const override; 32 | void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* opt, QPainter* p, const QWidget* widget) const override; 33 | }; 34 | 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /src/TabToolbar/CompactToolButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_COMPACT_TOOL_BUTTON_H 19 | #define TT_COMPACT_TOOL_BUTTON_H 20 | #include 21 | #include 22 | 23 | class QAction; 24 | class QMenu; 25 | class QToolButton; 26 | 27 | namespace tt 28 | { 29 | 30 | class CompactToolButton: public QFrame 31 | { 32 | Q_OBJECT 33 | public: 34 | CompactToolButton(QAction* action, QMenu* menu, QWidget* parent = nullptr); 35 | virtual ~CompactToolButton() = default; 36 | 37 | void SetHover(bool hover); 38 | 39 | private: 40 | QToolButton* upButton; 41 | QToolButton* downButton; 42 | QToolButton* overlay; 43 | }; 44 | 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /examples/Test/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/light_bulb.png 4 | icons/48px-AddTexture.png 5 | icons/48px-Antialias_Icon.svg.png 6 | icons/48px-Package-x-generic.svg.png 7 | icons/48px-Edit-redo.png 8 | icons/48px-Edit-undo.png 9 | icons/48px-System-log-out.png 10 | icons/Scale.png 11 | icons/48px-View-zoom-fit.png 12 | icons/Help-browser.png 13 | icons/Flaps_mode.png 14 | icons/48px-Printer.png 15 | icons/48px-Image-x-Remove.png 16 | icons/48px-Preferences-system.png 17 | icons/Move_mode.png 18 | icons/48px-View-refresh.png 19 | icons/48px-Go-bottom.png 20 | icons/stupid_logo.png 21 | icons/48px-Document-new.png 22 | icons/48px-Document-open.png 23 | icons/48px-Document-save-as.png 24 | icons/48px-Document-save.png 25 | icons/48px-Image-x-generic.png 26 | icons/48px-Polypaint.png 27 | icons/Select_mode.png 28 | icons/close.png 29 | 30 | 31 | tabtoolbar.json 32 | 33 | 34 | -------------------------------------------------------------------------------- /include/TabToolbar/Page.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_PAGE_H 19 | #define TT_PAGE_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class QHBoxLayout; 26 | 27 | namespace tt 28 | { 29 | class TabToolbar; 30 | class Group; 31 | 32 | class TT_API Page : public QWidget 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit Page(int index, const QString& pageName, QWidget* parent = nullptr); 37 | virtual ~Page() = default; 38 | 39 | Group* AddGroup(const QString& name); 40 | void hide(); 41 | void show(); 42 | 43 | signals: 44 | void Hiding(int index); 45 | void Showing(int index); 46 | 47 | private: 48 | const int myIndex; 49 | QHBoxLayout* innerLayout; 50 | QWidget* innerArea; 51 | }; 52 | 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /include/TabToolbar/Group.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_GROUP_H 19 | #define TT_GROUP_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class QAction; 29 | class QMenu; 30 | 31 | namespace tt 32 | { 33 | 34 | class TT_API Group : public QFrame 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit Group(const QString& name, QWidget* parent = nullptr); 39 | 40 | void AddAction(QToolButton::ToolButtonPopupMode type, QAction* action, QMenu* menu = nullptr); 41 | void AddSeparator(); 42 | SubGroup* AddSubGroup(SubGroup::Align align); 43 | void AddWidget(QWidget* widget); 44 | 45 | private: 46 | QFrame* CreateSeparator(); 47 | 48 | QHBoxLayout* innerLayout; 49 | }; 50 | 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /include/TabToolbar/Builder.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_BUILDER_H 19 | #define TT_BUILDER_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class QJsonObject; 30 | 31 | namespace tt 32 | { 33 | 34 | class TabToolbar; 35 | 36 | class TT_API Builder : public QObject 37 | { 38 | Q_OBJECT 39 | public: 40 | explicit Builder(QWidget* parent); 41 | 42 | TabToolbar* CreateTabToolbar(const QString& configPath); 43 | void SetCustomWidgetCreator(const QString& name, const std::function& creator); 44 | void SetCustomWidgetCreator(const QString& name, const std::function& creator); 45 | 46 | QWidget* operator[](const QString& widgetName) const; 47 | 48 | private: 49 | QMap guiWidgets; 50 | QMap> customWidgetCreators; 51 | }; 52 | 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /include/TabToolbar/StyleTools.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_STYLE_TOOLS_H 19 | #define TT_STYLE_TOOLS_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace tt 28 | { 29 | 30 | using TStyleCreator = std::function; 31 | 32 | TT_API void RegisterStyle(const QString& styleName, const TStyleCreator& creator); 33 | TT_API void UnregisterStyle(const QString& styleName); 34 | TT_API bool IsStyleRegistered(const QString& styleName); 35 | TT_API QString GetSheetForStyle(const StyleParams& style); 36 | TT_API QStringList GetRegisteredStyles(); 37 | TT_API std::unique_ptr CreateStyle(const QString& styleName); 38 | TT_API QString GetDefaultStyle(); 39 | 40 | float GetScaleFactor(const QWidget& widget); 41 | int GetPixelMetric(QStyle::PixelMetric metric); 42 | 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /screenshots/logo/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 20 | 21 | 22 | 24 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /include/TabToolbar/SubGroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_SUB_GROUP_H 19 | #define TT_SUB_GROUP_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class QAction; 32 | class QMenu; 33 | 34 | namespace tt 35 | { 36 | 37 | class TT_API SubGroup : public QFrame 38 | { 39 | Q_OBJECT 40 | public: 41 | enum class Align 42 | { 43 | Yes, 44 | No 45 | }; 46 | 47 | struct ActionParams 48 | { 49 | QToolButton::ToolButtonPopupMode type; 50 | QAction* action; 51 | QMenu* menu; 52 | }; 53 | 54 | SubGroup(Align align, QWidget* parent = nullptr); 55 | 56 | void AddAction(QToolButton::ToolButtonPopupMode type, QAction* action, QMenu* menu = nullptr); 57 | void AddHorizontalButtons(const std::vector& params); 58 | void AddWidget(QWidget* widget); 59 | 60 | private: 61 | QFrame* ConstructInnerFrame(int spacing); 62 | 63 | QVBoxLayout* innerLayout; 64 | }; 65 | 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /src/TabToolbar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTT_BUILDING_DLL) 2 | 3 | set(CMAKE_AUTOMOC ON) 4 | set(CMAKE_AUTORCC ON) 5 | 6 | find_package(Qt5Core 5.3 REQUIRED) 7 | find_package(Qt5Gui 5.3 REQUIRED) 8 | find_package(Qt5Widgets 5.3 REQUIRED) 9 | 10 | set(INCROOT ${PROJECT_SOURCE_DIR}/include/TabToolbar) 11 | set(SRCROOT ${PROJECT_SOURCE_DIR}/src/TabToolbar) 12 | 13 | set(SRC_LIST 14 | ${INCROOT}/API.h 15 | ${SRCROOT}/TabToolbar.cpp 16 | ${INCROOT}/TabToolbar.h 17 | ${SRCROOT}/Page.cpp 18 | ${INCROOT}/Page.h 19 | ${SRCROOT}/Builder.cpp 20 | ${INCROOT}/Builder.h 21 | ${SRCROOT}/CompactToolButton.cpp 22 | ${SRCROOT}/CompactToolButton.h 23 | ${SRCROOT}/Group.cpp 24 | ${INCROOT}/Group.h 25 | ${SRCROOT}/SubGroup.cpp 26 | ${INCROOT}/SubGroup.h 27 | ${SRCROOT}/StyleTools.cpp 28 | ${INCROOT}/StyleTools.h 29 | ${SRCROOT}/Styles.cpp 30 | ${INCROOT}/Styles.h 31 | ${SRCROOT}/ToolButtonStyle.cpp 32 | ${SRCROOT}/ToolButtonStyle.h 33 | ) 34 | source_group("" FILES ${SRC_LIST}) 35 | 36 | set(RESOURCES 37 | ${SRCROOT}/StyleTemplate.qrc 38 | ) 39 | source_group("resources" FILES ${RESOURCES}) 40 | 41 | add_library(TabToolbar SHARED ${SRC_LIST} ${RESOURCES}) 42 | 43 | target_link_libraries(TabToolbar 44 | Qt5::Core 45 | Qt5::Gui 46 | Qt5::Widgets 47 | ) 48 | 49 | if(WIN32) 50 | # include the major version number in Windows shared library names (but not import library names) 51 | set_target_properties(TabToolbar PROPERTIES DEBUG_POSTFIX "d") 52 | set_target_properties(TabToolbar PROPERTIES SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") 53 | else() 54 | set_target_properties(TabToolbar PROPERTIES DEBUG_POSTFIX "d") 55 | endif() 56 | if (WIN32 AND MINGW) 57 | # on Windows/gcc get rid of "lib" prefix for shared libraries, 58 | # and transform the ".dll.a" suffix into ".a" for import libraries 59 | set_target_properties(TabToolbar PROPERTIES PREFIX "") 60 | set_target_properties(TabToolbar PROPERTIES IMPORT_SUFFIX ".a") 61 | endif() 62 | 63 | install(TARGETS TabToolbar 64 | RUNTIME DESTINATION bin COMPONENT bin 65 | LIBRARY DESTINATION lib COMPONENT bin 66 | ARCHIVE DESTINATION lib COMPONENT devel 67 | FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin 68 | ) 69 | -------------------------------------------------------------------------------- /cmake-modules/FindTabToolbar.cmake: -------------------------------------------------------------------------------- 1 | set(TabToolbar_ROOT "" CACHE PATH "Path to TabToolbar root directory.") 2 | 3 | set(TabToolbar_FIND_DIRS 4 | ${TabToolbar_ROOT} 5 | $ENV{TabToolbar_ROOT} 6 | /usr/local 7 | /usr 8 | /opt/local 9 | /opt 10 | ) 11 | 12 | find_path(TabToolbar_INCLUDE_DIR 13 | TabToolbar/TabToolbar.h 14 | PATH_SUFFIXES include 15 | PATHS ${TabToolbar_FIND_DIRS} 16 | ) 17 | 18 | # release library 19 | find_library(TabToolbar_LIBRARY_RELEASE 20 | NAMES TabToolbar libTabToolbar 21 | PATH_SUFFIXES lib64 lib 22 | PATHS ${TabToolbar_FIND_DIRS}) 23 | 24 | # debug library 25 | find_library(TabToolbar_LIBRARY_DEBUG 26 | NAMES TabToolbard libTabToolbard 27 | PATH_SUFFIXES lib64 lib 28 | PATHS ${TabToolbar_FIND_DIRS}) 29 | 30 | if (TabToolbar_LIBRARY_DEBUG OR TabToolbar_LIBRARY_RELEASE) 31 | set(TabToolbar_FOUND TRUE) 32 | 33 | # if both are found, set TabToolbar_LIBRARY to contain both 34 | if (TabToolbar_LIBRARY_DEBUG AND TabToolbar_LIBRARY_RELEASE) 35 | set(TabToolbar_LIBRARY debug ${TabToolbar_LIBRARY_DEBUG} 36 | optimized ${TabToolbar_LIBRARY_RELEASE}) 37 | endif() 38 | 39 | # if only one debug/release variant is found, set the other to be equal to the found one 40 | if (TabToolbar_LIBRARY_DEBUG AND NOT TabToolbar_LIBRARY_RELEASE) 41 | # debug and not release 42 | set(TabToolbar_LIBRARY_RELEASE ${TabToolbar_LIBRARY_DEBUG}) 43 | set(TabToolbar_LIBRARY ${TabToolbar_LIBRARY_DEBUG}) 44 | endif() 45 | if (TabToolbar_LIBRARY_RELEASE AND NOT TabToolbar_LIBRARY_DEBUG) 46 | # release and not debug 47 | set(TabToolbar_LIBRARY_DEBUG ${TabToolbar_LIBRARY_RELEASE}) 48 | set(TabToolbar_LIBRARY ${TabToolbar_LIBRARY_RELEASE}) 49 | endif() 50 | else() 51 | set(TabToolbar_FOUND FALSE) 52 | endif() 53 | 54 | MARK_AS_ADVANCED(TabToolbar_LIBRARY 55 | TabToolbar_LIBRARY_RELEASE 56 | TabToolbar_LIBRARY_DEBUG 57 | ) 58 | 59 | if (TabToolbar_FOUND) 60 | if (NOT TabToolbar_FIND_QUIETLY) 61 | message(STATUS "Found TabToolbar library: ${TabToolbar_LIBRARY}") 62 | endif (NOT TabToolbar_FIND_QUIETLY) 63 | else (TabToolbar_FOUND) 64 | if (TabToolbar_FIND_REQUIRED) 65 | message(FATAL_ERROR "Could not find TabToolbar library") 66 | endif (TabToolbar_FIND_REQUIRED) 67 | endif (TabToolbar_FOUND) 68 | -------------------------------------------------------------------------------- /include/TabToolbar/TabToolbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TAB_TOOLBAR_H 19 | #define TAB_TOOLBAR_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | class QToolButton; 28 | class QFrame; 29 | class QMenu; 30 | 31 | namespace tt 32 | { 33 | class Page; 34 | class StyleParams; 35 | 36 | class TT_API TabToolbar : public QToolBar 37 | { 38 | Q_OBJECT 39 | public: 40 | explicit TabToolbar(QWidget* parent = nullptr, unsigned _groupMaxHeight = 75, unsigned _groupRowCount = 3); 41 | virtual ~TabToolbar(); 42 | 43 | void SetSpecialTabEnabled(bool enabled); 44 | Page* AddPage(const QString& pageName); 45 | QAction* HideAction(); 46 | void AddCornerAction(QAction* action); 47 | void SetStyle(const QString& styleName); 48 | QString GetStyle() const; 49 | unsigned RowCount() const; 50 | unsigned GroupMaxHeight() const; 51 | int CurrentTab() const; 52 | void SetCurrentTab(int index); 53 | 54 | signals: 55 | void Minimized(); 56 | void Maximized(); 57 | void SpecialTabClicked(); 58 | void StyleChanged(); 59 | 60 | private slots: 61 | void FocusChanged(QWidget* old, QWidget* now); 62 | void TabClicked(int index); 63 | void CurrentTabChanged(int index); 64 | void HideAt(int index = -1); 65 | void HideTab(int index); 66 | void ShowTab(int index); 67 | 68 | protected: 69 | bool event(QEvent* event) override; 70 | 71 | private: 72 | void AdjustVerticalSize(unsigned vSize); 73 | 74 | const unsigned groupRowCount; 75 | const unsigned groupMaxHeight; 76 | bool hasSpecialTab = false; 77 | int currentIndex = 0; 78 | unsigned maxHeight = QWIDGETSIZE_MAX; 79 | QFrame* cornerActions = nullptr; 80 | QAction* hideAction = nullptr; 81 | QToolButton* hideButton = nullptr; 82 | QAction* tabBarHandle = nullptr; 83 | QTabWidget* tabBar = nullptr; 84 | bool ignoreStyleEvent = false; 85 | bool isMinimized = false; 86 | bool isShown = true; 87 | QTimer tempShowTimer; 88 | std::unique_ptr style; 89 | 90 | friend class Page; 91 | }; 92 | 93 | TabToolbar* _FindTabToolbarParent(QWidget& startingWidget); 94 | 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /src/TabToolbar/StyleTemplate.qss: -------------------------------------------------------------------------------- 1 | QToolBar[TabToolbar="true"] { 2 | border: 0px; 3 | background-color: %ToolbarBackgroundColor%; 4 | padding: 0px; 5 | } 6 | 7 | QToolButton[TTHide="true"] { 8 | color: %HideArrowColor%; 9 | } 10 | 11 | QScrollArea { 12 | padding: 0px; 13 | } 14 | 15 | QWidget[TTPage="true"] { 16 | padding: 0px; 17 | background-color: %PaneColor%; 18 | border: 0px; 19 | border-top: 1px solid %BorderColor%; 20 | } 21 | 22 | QTabWidget[TTWidget="true"] { 23 | background-color: transparent; 24 | } 25 | 26 | QTabWidget[TTWidget="true"]::pane { 27 | border-radius: 0px; 28 | border: 0px; 29 | background-color: transparent; 30 | padding: 0px; 31 | top: 1px; 32 | border-bottom: 1px solid %BorderColor%; 33 | } 34 | 35 | QTabWidget[TTWidget="true"]::tab-bar { 36 | top: 2px; 37 | background-color: transparent; 38 | } 39 | 40 | QTabBar[TTTab="true"] { 41 | background-color: transparent; 42 | } 43 | 44 | QTabBar[TTTab="true"]::tab { 45 | margin-right: %TabSpacing%; 46 | font-family: "DejaVu Sans Condensed"; 47 | color: %TabFontColor%; 48 | background-color: transparent; 49 | border-top-left-radius: %TabBorderRadius%; 50 | border-top-right-radius: %TabBorderRadius%; 51 | min-width: 50px; 52 | min-height: 20px; 53 | } 54 | 55 | QTabBar[TTTab="true"][TTSpecial="true"]::tab::first { 56 | border-top-left-radius: 0px; 57 | color: %TabSpecialFontColor%; 58 | background-color: %TabSpecialColor%; 59 | border-top: 1px solid %TabSpecialBorderColor%; 60 | border-bottom: 1px solid %TabSpecialBorderColor%; 61 | border-left: 1px solid %TabSpecialBorderColorSide%; 62 | border-right: 1px solid %TabSpecialBorderColorSide%; 63 | } 64 | 65 | QTabBar[TTTab="true"][TTSpecial="true"]::tab::first::hover { 66 | padding-top: 2px; 67 | margin-bottom: 0px; 68 | border-top: 1px solid %TabSpecialHoverBorderColor%; 69 | border-bottom: 1px solid %TabSpecialHoverBorderColor%; 70 | border-left: 1px solid %TabSpecialHoverBorderColorSide%; 71 | border-right: 1px solid %TabSpecialHoverBorderColorSide%; 72 | background-color: %TabSpecialHoverColor%; 73 | } 74 | 75 | QTabBar[TTTab="true"]::tab::selected::enabled { 76 | padding-top: 1px; 77 | border-top: 1px solid %BorderColor%; 78 | border-left: 1px solid %BorderColor%; 79 | border-right: 1px solid %BorderColor%; 80 | border-bottom: 0px solid transparent; 81 | background-color: %TabSelectedColor%; 82 | } 83 | 84 | QTabBar[TTTab="true"]::tab::selected::!enabled, 85 | QTabBar[TTTab="true"]::tab::!selected::enabled{ 86 | padding-top: 2px; 87 | } 88 | 89 | QTabBar[TTTab="true"]::tab::hover::enabled { 90 | padding-bottom: 0px; 91 | border-top: 1px solid %TabHoverBorderColorTop%; 92 | border-left: 1px solid %TabHoverBorderColorSide%; 93 | border-right: 1px solid %TabHoverBorderColorSide%; 94 | } 95 | 96 | QTabBar[TTTab="true"]::tab::!selected::hover { 97 | padding-top: 2px; 98 | border-top: 1px solid %TabUnselectedHoverBorderColorTop%; 99 | border-left: 1px solid %TabUnselectedHoverBorderColorSide%; 100 | border-right: 1px solid %TabUnselectedHoverBorderColorSide%; 101 | border-bottom: 0px solid transparent; 102 | margin-bottom: 1px; 103 | background-color: %TabUnselectedColor%; 104 | } 105 | 106 | QFrame[TTSeparator="true"] { 107 | border: 1px solid transparent; 108 | border-right-color: %SeparatorColor%; 109 | } 110 | 111 | QLabel[TTGroupName="true"] { 112 | color: %GroupNameColor%; 113 | } 114 | 115 | QFrame[TTHorizontalFrame="true"] { 116 | border-radius: %HorizontalFrameBorderSize%; 117 | border: 1px solid %HorizontalFrameBorderColor%; 118 | background-color: %HorizontalFrameBackgroundColor%; 119 | } 120 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

6 | 7 |

8 | 9 | ------------- 10 | 11 | [![Build status](https://ci.appveyor.com/api/projects/status/03acxnds340jgnm1?svg=true)](https://ci.appveyor.com/project/SeriousAlexej/tabtoolbar) 12 | [![Build Status](https://travis-ci.org/SeriousAlexej/TabToolbar.svg?branch=master)](https://travis-ci.org/SeriousAlexej/TabToolbar) 13 | 14 | As stated above, **TabToolbar** is a small library, meant to be used with **Qt**, 15 | that provides a few classes for creating of tabbed toolbars. 16 | 17 | Features: 18 | - **Cross-platform** - TabToolbar depends only on **Qt** and requires a **C++11** compliant compiler to be built. 19 | - **Native look and feel** - TabToolbar has a few predefined styles, which use current OS's palette to generate the best looking style possible. Moreover styles can be created and changed dynamically at runtime! 20 | - **Configurable** - UI configuration can be set directly from code, or loaded from JSON file! This enables easy UI fine-tuning and customization. 21 | - **Customizable** - UI can contain any custom widget! If you use JSON configs, all you have to do is to tell TabToolbar, how to create them, and you are good to go! 22 | - **Non-exclusive** - TabToolbar can be easily combined with classic menu bars! Consider a CAD application, that uses TabToolbar and places it's most used actions in it, while combining it with menu bar, which contains other less-frequently used actions. 23 | 24 | Styles: 25 | ------------- 26 | 27 | TabToolbar comes with four predefined styles: 28 | - **Vienna** (default for Windows 7 OS) 29 | - **Threshold** (default for all Windows >= 8 OSes) 30 | - **Kool** (default for Unix-like systems) 31 | - **White Mercy** a simple white reskin of Threshold style 32 | 33 | All these styles use current OS palette and thus look great with any theme (light, dark, you name it). 34 | Each style can be used on any OS. 35 | 36 | Some examples: 37 | 38 |

39 | Vienna style on Windows 7: 40 |

41 |

42 | 43 |

44 |

45 | Kool style on Manjaro KDE with Breeze Dark theme: 46 | 47 |

48 |

49 | Threshold style on Manjaro LXQt with gtk2 theme: 50 | 51 |

52 |

53 | White Mercy style on Windows 10: 54 |

55 |

56 | 57 |

58 | 59 | Building 60 | ------------- 61 | 62 | TabToolbar uses **CMake** and depends on **Qt >= 5.3**. 63 | A simple example project of how to use TabToolbar is included, but is by default not included in build. 64 | 65 | Usage 66 | ------------- 67 | 68 | To link TabToolbar to your project, you can use provided `FindTabToolbar` cmake module, which defines `TabToolbar_LIBRARY` variable 69 | that you can feed to your `target_link_libraries` command. 70 | 71 | An example project is also included in **examples/Test** subdirectory, please refer to it if you have any troubles. 72 | 73 | License 74 | ------------- 75 | 76 | TabToolbar uses **LGPL** license either version **3** or any later version. 77 | 78 | TabToolbar logo generously provided by ![Tobaloidee](https://github.com/Tobaloidee) 79 | -------------------------------------------------------------------------------- /src/TabToolbar/Page.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | using namespace tt; 32 | 33 | namespace 34 | { 35 | class TTScroller : public QObject 36 | { 37 | public: 38 | TTScroller(QObject* parent) : QObject(parent) {} 39 | 40 | protected: 41 | bool eventFilter(QObject* watched, QEvent* event) override 42 | { 43 | if(event->type() == QEvent::Wheel) 44 | { 45 | QScrollArea* scroll = static_cast(watched); 46 | QWheelEvent* wheel = static_cast(event); 47 | QScrollBar* scrollbar = scroll->horizontalScrollBar(); 48 | scrollbar->setValue(scrollbar->value() - wheel->delta()/5); 49 | return true; 50 | } 51 | return QObject::eventFilter(watched, event); 52 | } 53 | }; 54 | } 55 | 56 | Page::Page(int index, const QString& pageName, QWidget* parent) 57 | : QWidget(parent), 58 | myIndex(index) 59 | { 60 | setObjectName(pageName); 61 | setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding); 62 | setContentsMargins(0, 0, 0, 0); 63 | QHBoxLayout* l = new QHBoxLayout(this); 64 | l->setContentsMargins(0, 0, 0, 0); 65 | l->setSpacing(0); 66 | setLayout(l); 67 | 68 | QScrollArea* scrollArea = new QScrollArea(this); 69 | scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 70 | scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 71 | scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); 72 | scrollArea->setFrameShape(QFrame::NoFrame); 73 | scrollArea->setFrameShadow(QFrame::Plain); 74 | scrollArea->setLineWidth(0); 75 | scrollArea->setWidgetResizable(true); 76 | scrollArea->installEventFilter(new TTScroller(scrollArea)); 77 | innerArea = new QWidget(); 78 | innerArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); 79 | innerArea->setProperty("TTPage", QVariant(true)); 80 | innerLayout = new QHBoxLayout(innerArea); 81 | innerLayout->setContentsMargins(0, 0, 0, 0); 82 | innerLayout->setSpacing(2); 83 | 84 | QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 85 | innerLayout->addItem(spacer); 86 | 87 | scrollArea->setWidget(innerArea); 88 | l->addWidget(scrollArea); 89 | } 90 | 91 | Group* Page::AddGroup(const QString& name) 92 | { 93 | Group* grp = new Group(name, innerArea); 94 | innerLayout->insertWidget(innerLayout->count()-1, grp); 95 | 96 | auto* parentTT = _FindTabToolbarParent(*this); 97 | if (!parentTT) 98 | throw std::runtime_error("Page should be constructed inside TabToolbar!"); 99 | 100 | parentTT->AdjustVerticalSize(grp->height()); 101 | return grp; 102 | } 103 | 104 | void Page::hide() 105 | { 106 | emit Hiding(myIndex); 107 | } 108 | 109 | void Page::show() 110 | { 111 | emit Showing(myIndex); 112 | } 113 | -------------------------------------------------------------------------------- /include/TabToolbar/Styles.h: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #ifndef TT_STYLES_H 19 | #define TT_STYLES_H 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace tt 28 | { 29 | 30 | struct TT_API Color 31 | { 32 | bool operator==(const Color& o) const { return o.coefficient == coefficient && o.value == value; } 33 | float coefficient; 34 | QColor value; 35 | }; 36 | class TT_API Colors 37 | { 38 | private: 39 | using TVectorType = std::vector; 40 | 41 | public: 42 | Colors() = default; 43 | Colors(const Qt::GlobalColor& c) 44 | : m_colors(TVectorType({{1.0f, c}})) {} 45 | Colors(const QColor& c) 46 | : m_colors(TVectorType({{1.0f, c}})) {} 47 | Colors(const std::initializer_list& c) 48 | : m_colors(TVectorType(c)) {} 49 | 50 | operator QColor () const 51 | { 52 | return m_colors.at(0).value; 53 | } 54 | bool operator != (const Colors& c) const 55 | { 56 | return m_colors != c.m_colors; 57 | } 58 | Color& operator [] (std::size_t i) 59 | { 60 | return m_colors[i]; 61 | } 62 | const Color& operator [] (std::size_t i) const 63 | { 64 | return m_colors[i]; 65 | } 66 | TVectorType::size_type size() const 67 | { 68 | return m_colors.size(); 69 | } 70 | TVectorType::iterator begin() 71 | { 72 | return m_colors.begin(); 73 | } 74 | TVectorType::iterator end() 75 | { 76 | return m_colors.end(); 77 | } 78 | TVectorType::const_iterator begin() const 79 | { 80 | return m_colors.cbegin(); 81 | } 82 | TVectorType::const_iterator end() const 83 | { 84 | return m_colors.cend(); 85 | } 86 | 87 | private: 88 | TVectorType m_colors; 89 | }; 90 | 91 | #define TT_PROPERTY(type, name)\ 92 | Q_PROPERTY(type name MEMBER name)\ 93 | type name 94 | class TT_API StyleParams : public QObject 95 | { 96 | Q_OBJECT 97 | public: 98 | virtual ~StyleParams() = default; 99 | 100 | TT_PROPERTY(tt::Colors, SeparatorColor); 101 | TT_PROPERTY(tt::Colors, TabSelectedColor); 102 | TT_PROPERTY(tt::Colors, TabUnselectedColor); 103 | TT_PROPERTY(tt::Colors, PaneColor); 104 | TT_PROPERTY(tt::Colors, TabHoverBorderColorSide); 105 | TT_PROPERTY(tt::Colors, TabUnselectedHoverBorderColorSide); 106 | TT_PROPERTY(tt::Colors, TabSpecialBorderColorSide); 107 | TT_PROPERTY(tt::Colors, TabSpecialHoverBorderColorSide); 108 | TT_PROPERTY(tt::Colors, TabSpecialHoverColor); 109 | TT_PROPERTY(tt::Colors, TabSpecialColor); 110 | TT_PROPERTY(tt::Colors, HorizontalFrameBackgroundColor); 111 | TT_PROPERTY(tt::Colors, HorizontalFrameBorderColor); 112 | TT_PROPERTY(int, HorizontalFrameBorderSize); 113 | TT_PROPERTY(tt::Colors, HideArrowColor); 114 | TT_PROPERTY(tt::Colors, TabUnselectedHoverBorderColorTop); 115 | TT_PROPERTY(tt::Colors, TabHoverBorderColorTop); 116 | TT_PROPERTY(tt::Colors, TabSpecialBorderColor); 117 | TT_PROPERTY(tt::Colors, TabSpecialHoverBorderColor); 118 | TT_PROPERTY(tt::Colors, TabSpecialFontColor); 119 | TT_PROPERTY(tt::Colors, TabFontColor); 120 | TT_PROPERTY(tt::Colors, ToolbarBackgroundColor); 121 | TT_PROPERTY(tt::Colors, BorderColor); 122 | TT_PROPERTY(tt::Colors, GroupNameColor); 123 | TT_PROPERTY(int, TabBorderRadius); 124 | TT_PROPERTY(int, TabSpacing); 125 | 126 | bool UseTemplateSheet; 127 | QString AdditionalStyleSheet; 128 | }; 129 | #undef TT_PROPERTY 130 | 131 | extern TT_API const QString g_styleKool; 132 | extern TT_API const QString g_styleVienna; 133 | extern TT_API const QString g_styleThreshold; 134 | 135 | } 136 | Q_DECLARE_METATYPE(tt::Colors) 137 | #endif 138 | -------------------------------------------------------------------------------- /src/TabToolbar/SubGroup.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace tt; 30 | 31 | SubGroup::SubGroup(Align align, QWidget* parent) : QFrame(parent) 32 | { 33 | setFrameShape(NoFrame); 34 | setLineWidth(0); 35 | setContentsMargins(0, 0, 0, 0); 36 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 37 | 38 | innerLayout = new QVBoxLayout(this); 39 | innerLayout->setMargin(0); 40 | innerLayout->setContentsMargins(0, 0, 0, 0); 41 | innerLayout->setSpacing(1); 42 | innerLayout->setDirection(QBoxLayout::TopToBottom); 43 | QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, (align == Align::Yes ? QSizePolicy::Expanding : QSizePolicy::Ignored)); 44 | innerLayout->addItem(spacer); 45 | setLayout(innerLayout); 46 | } 47 | 48 | void SubGroup::AddAction(QToolButton::ToolButtonPopupMode type, QAction* action, QMenu* menu) 49 | { 50 | const int iconSize = GetPixelMetric(QStyle::PM_SmallIconSize) * GetScaleFactor(*this); 51 | QFrame* frame = ConstructInnerFrame(0); 52 | 53 | QToolButton* btn = new QToolButton(this); 54 | btn->setProperty("TTInternal", QVariant(true)); 55 | btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); 56 | btn->setAutoRaise(true); 57 | btn->setDefaultAction(action); 58 | btn->setPopupMode(type); 59 | btn->setIconSize(QSize(iconSize, iconSize)); 60 | if(menu) 61 | btn->setMenu(menu); 62 | btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); 63 | 64 | frame->layout()->addWidget(btn); 65 | innerLayout->insertWidget(innerLayout->count()-1, frame); 66 | } 67 | 68 | void SubGroup::AddWidget(QWidget* widget) 69 | { 70 | QFrame* frame = ConstructInnerFrame(4); 71 | widget->setParent(frame); 72 | widget->setProperty("TTInternal", QVariant(true)); 73 | frame->layout()->addWidget(widget); 74 | innerLayout->insertWidget(innerLayout->count()-1, frame); 75 | } 76 | 77 | void SubGroup::AddHorizontalButtons(const std::vector& params) 78 | { 79 | const int iconSize = GetPixelMetric(QStyle::PM_SmallIconSize) * GetScaleFactor(*this); 80 | QFrame* frame = ConstructInnerFrame(0); 81 | frame->setProperty("TTHorizontalFrame", QVariant(true)); 82 | 83 | for(auto& param : params) 84 | { 85 | QToolButton* btn = new QToolButton(this); 86 | btn->setProperty("TTInternal", QVariant(true)); 87 | btn->setToolButtonStyle(Qt::ToolButtonIconOnly); 88 | btn->setAutoRaise(true); 89 | btn->setDefaultAction(param.action); 90 | btn->setPopupMode(param.type); 91 | btn->setIconSize(QSize(iconSize, iconSize)); 92 | if(param.menu) 93 | btn->setMenu(param.menu); 94 | btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 95 | frame->layout()->addWidget(btn); 96 | } 97 | 98 | innerLayout->insertWidget(innerLayout->count()-1, frame); 99 | } 100 | 101 | QFrame* SubGroup::ConstructInnerFrame(int spacing) 102 | { 103 | 104 | const auto* parentTT = _FindTabToolbarParent(*this); 105 | if (!parentTT) 106 | throw std::runtime_error("Group should be constructed inside TabToolbar!"); 107 | 108 | unsigned groupMaxHeight = parentTT->GroupMaxHeight(); 109 | unsigned rowCount = parentTT->RowCount(); 110 | 111 | QFrame* frame = new QFrame(this); 112 | frame->setFrameShape(QFrame::NoFrame); 113 | frame->setLineWidth(0); 114 | frame->setContentsMargins(0, 0, 0, 0); 115 | QSizePolicy policy(QSizePolicy::Maximum, QSizePolicy::Preferred); 116 | policy.setHorizontalStretch(0); 117 | policy.setVerticalStretch(1); 118 | frame->setSizePolicy(policy); 119 | frame->setMaximumHeight(groupMaxHeight / rowCount); 120 | QHBoxLayout* l = new QHBoxLayout(frame); 121 | l->setMargin(0); 122 | l->setContentsMargins(0, 0, 0, 0); 123 | l->setSpacing(spacing); 124 | l->setDirection(QBoxLayout::LeftToRight); 125 | frame->setLayout(l); 126 | QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); 127 | l->addItem(spacer); 128 | return frame; 129 | } 130 | -------------------------------------------------------------------------------- /screenshots/logo/logotype-a.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 14 | 19 | 20 | 24 | 28 | 29 | 34 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 54 | 56 | 57 | 58 | 60 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /examples/Test/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 810 10 | 511 11 | 12 | 13 | 14 | TabToolbar Test 15 | 16 | 17 | 18 | :/icons/icons/stupid_logo.png:/icons/icons/stupid_logo.png 19 | 20 | 21 | 22 | true 23 | 24 | 25 | 26 | 0 27 | 0 28 | 29 | 30 | 31 | 32 | 99999 33 | 99999 34 | 35 | 36 | 37 | 38 | 0 39 | 40 | 41 | 0 42 | 43 | 44 | 0 45 | 46 | 47 | 0 48 | 49 | 50 | 0 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | :/icons/icons/48px-Document-save-as.png:/icons/icons/48px-Document-save-as.png 66 | 67 | 68 | Save As 69 | 70 | 71 | 72 | 73 | 74 | :/icons/icons/48px-Document-open.png:/icons/icons/48px-Document-open.png 75 | 76 | 77 | Open 78 | 79 | 80 | 81 | 82 | 83 | :/icons/icons/48px-Document-save.png:/icons/icons/48px-Document-save.png 84 | 85 | 86 | Save 87 | 88 | 89 | 90 | 91 | 92 | :/icons/icons/Scale.png:/icons/icons/Scale.png 93 | 94 | 95 | Scale 96 | 97 | 98 | 99 | 100 | 101 | :/icons/icons/48px-Polypaint.png:/icons/icons/48px-Polypaint.png 102 | 103 | 104 | Polypaint 105 | 106 | 107 | 108 | 109 | 110 | :/icons/icons/48px-Preferences-system.png:/icons/icons/48px-Preferences-system.png 111 | 112 | 113 | Settings 114 | 115 | 116 | 117 | 118 | dummy 119 | 120 | 121 | 122 | 123 | 124 | :/icons/icons/48px-Edit-redo.png:/icons/icons/48px-Edit-redo.png 125 | 126 | 127 | redo 128 | 129 | 130 | 131 | 132 | true 133 | 134 | 135 | 136 | :/icons/icons/48px-Edit-undo.png:/icons/icons/48px-Edit-undo.png 137 | 138 | 139 | undo 140 | 141 | 142 | 143 | 144 | 145 | :/icons/icons/close.png:/icons/icons/close.png 146 | 147 | 148 | close 149 | 150 | 151 | 152 | 153 | 154 | :/icons/icons/Help-browser.png:/icons/icons/Help-browser.png 155 | 156 | 157 | Help 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /screenshots/logo/logotype-b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 14 | 19 | 20 | 24 | 28 | 29 | 34 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 54 | 56 | 57 | 59 | 60 | 61 | 64 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/TabToolbar/Group.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "CompactToolButton.h" 38 | #include "ToolButtonStyle.h" 39 | 40 | using namespace tt; 41 | 42 | Group::Group(const QString& name, QWidget* parent) : QFrame(parent) 43 | { 44 | setFrameShape(NoFrame); 45 | setLineWidth(0); 46 | setContentsMargins(0, 0, 0, 0); 47 | setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); 48 | 49 | QHBoxLayout* separatorLayout = new QHBoxLayout(this); 50 | separatorLayout->setMargin(0); 51 | separatorLayout->setContentsMargins(0, 0, 0, 0); 52 | separatorLayout->setSpacing(0); 53 | separatorLayout->setDirection(QBoxLayout::LeftToRight); 54 | setLayout(separatorLayout); 55 | 56 | QVBoxLayout* outerLayout = new QVBoxLayout(); 57 | outerLayout->setMargin(0); 58 | outerLayout->setContentsMargins(0, 0, 0, 0); 59 | outerLayout->setSpacing(0); 60 | outerLayout->setDirection(QBoxLayout::TopToBottom); 61 | separatorLayout->addLayout(outerLayout); 62 | separatorLayout->addWidget(CreateSeparator()); 63 | 64 | QFrame* innerFrame = new QFrame(this); 65 | innerFrame->setFrameShape(NoFrame); 66 | innerFrame->setLineWidth(0); 67 | innerFrame->setContentsMargins(0, 0, 0, 0); 68 | innerFrame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 69 | 70 | innerLayout = new QHBoxLayout(innerFrame); 71 | innerLayout->setMargin(0); 72 | innerLayout->setContentsMargins(2, 4, 2, 0); 73 | innerLayout->setSpacing(4); 74 | innerLayout->setDirection(QBoxLayout::LeftToRight); 75 | innerFrame->setLayout(innerLayout); 76 | 77 | outerLayout->addWidget(innerFrame); 78 | 79 | QLabel* groupName = new QLabel(name, this); 80 | groupName->setProperty("TTGroupName", QVariant(true)); 81 | groupName->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 82 | groupName->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 83 | groupName->adjustSize(); 84 | 85 | outerLayout->addWidget(groupName); 86 | 87 | const auto* parentTT = _FindTabToolbarParent(*this); 88 | if (!parentTT) 89 | throw std::runtime_error("Group should be constructed inside TabToolbar!"); 90 | 91 | unsigned groupMaxHeight = parentTT->GroupMaxHeight(); 92 | unsigned rowCount = parentTT->RowCount(); 93 | const unsigned height = groupMaxHeight + groupName->height() + rowCount - 1; 94 | setMinimumHeight(height); 95 | setMaximumHeight(height); 96 | } 97 | 98 | SubGroup* Group::AddSubGroup(SubGroup::Align align) 99 | { 100 | SubGroup* sgrp = new SubGroup(align, this); 101 | innerLayout->addWidget(sgrp); 102 | return sgrp; 103 | } 104 | 105 | QFrame* Group::CreateSeparator() 106 | { 107 | QFrame* separator = new QFrame(this); 108 | separator->setProperty("TTSeparator", QVariant(true)); 109 | separator->setAutoFillBackground(false); 110 | separator->setFrameShadow(QFrame::Plain); 111 | separator->setLineWidth(1); 112 | separator->setMidLineWidth(0); 113 | separator->setFrameShape(QFrame::VLine); 114 | return separator; 115 | } 116 | 117 | void Group::AddSeparator() 118 | { 119 | innerLayout->addWidget(CreateSeparator()); 120 | } 121 | 122 | void Group::AddAction(QToolButton::ToolButtonPopupMode type, QAction* action, QMenu* menu) 123 | { 124 | if(type == QToolButton::MenuButtonPopup) 125 | { 126 | innerLayout->addWidget(new CompactToolButton(action, menu, this)); 127 | } 128 | else 129 | { 130 | const int iconSize = GetPixelMetric(QStyle::PM_LargeIconSize) * GetScaleFactor(*this); 131 | QToolButton* btn = new QToolButton(this); 132 | btn->setProperty("TTInternal", QVariant(true)); 133 | btn->setAutoRaise(true); 134 | btn->setDefaultAction(action); 135 | btn->setIconSize(QSize(iconSize, iconSize)); 136 | btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 137 | btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 138 | btn->setPopupMode(type); 139 | btn->setStyle(new TTToolButtonStyle()); 140 | if(menu) 141 | btn->setMenu(menu); 142 | innerLayout->addWidget(btn); 143 | } 144 | } 145 | 146 | void Group::AddWidget(QWidget* widget) 147 | { 148 | widget->setParent(this); 149 | widget->setProperty("TTInternal", QVariant(true)); 150 | innerLayout->addWidget(widget); 151 | } 152 | -------------------------------------------------------------------------------- /src/TabToolbar/CompactToolButton.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "CompactToolButton.h" 33 | #include "ToolButtonStyle.h" 34 | 35 | namespace 36 | { 37 | class TTOverlayToolButton : public QToolButton 38 | { 39 | public: 40 | TTOverlayToolButton(QWidget* parent) : QToolButton(parent) 41 | { 42 | setAttribute(Qt::WA_NoSystemBackground); 43 | setAttribute(Qt::WA_TranslucentBackground); 44 | setAttribute(Qt::WA_TransparentForMouseEvents); 45 | parent->installEventFilter(this); 46 | lower(); 47 | } 48 | 49 | bool paint = false; 50 | 51 | protected: 52 | bool eventFilter(QObject* obj, QEvent* ev) override 53 | { 54 | if (obj == parent()) 55 | { 56 | if (ev->type() == QEvent::Resize) 57 | resize(static_cast(ev)->size()); 58 | else if (ev->type() == QEvent::ChildAdded) 59 | lower(); 60 | } 61 | return QWidget::eventFilter(obj, ev); 62 | } 63 | 64 | void paintEvent(QPaintEvent*) override 65 | { 66 | if(!paint) 67 | return; 68 | 69 | QStylePainter sp(this); 70 | QStyleOptionToolButton opt; 71 | initStyleOption(&opt); 72 | opt.state |= QStyle::State_MouseOver | QStyle::State_AutoRaise | QStyle::State_Raised; 73 | opt.activeSubControls |= QStyle::SC_ToolButton; 74 | sp.drawComplexControl(QStyle::CC_ToolButton, opt); 75 | } 76 | }; 77 | 78 | class TTHover : public QObject 79 | { 80 | public: 81 | TTHover(tt::CompactToolButton* parent, QToolButton* up, QToolButton* down) : 82 | QObject(parent), 83 | toolButton(parent), 84 | upButton(up), 85 | downButton(down) 86 | { 87 | } 88 | 89 | protected: 90 | bool eventFilter(QObject* watched, QEvent* event) override 91 | { 92 | if(event->type() == QEvent::HoverLeave) 93 | { 94 | toolButton->SetHover(false); 95 | } 96 | else if(event->type() == QEvent::HoverEnter) 97 | { 98 | if(watched == upButton || watched == downButton) 99 | toolButton->SetHover(upButton->isEnabled()); 100 | } 101 | if(watched == upButton) 102 | { 103 | if(event->type() == QEvent::Hide) 104 | downButton->hide(); 105 | else if(event->type() == QEvent::Show) 106 | downButton->show(); 107 | else if(event->type() == QEvent::EnabledChange) 108 | { 109 | downButton->setEnabled(upButton->isEnabled()); 110 | toolButton->SetHover(upButton->isEnabled() && upButton->underMouse()); 111 | } 112 | } 113 | return QObject::eventFilter(watched, event); 114 | } 115 | 116 | private: 117 | tt::CompactToolButton* toolButton; 118 | QToolButton* upButton; 119 | QToolButton* downButton; 120 | }; 121 | } 122 | 123 | namespace tt 124 | { 125 | 126 | CompactToolButton::CompactToolButton(QAction* action, QMenu* menu, QWidget* parent) : 127 | QFrame(parent) 128 | { 129 | overlay = new TTOverlayToolButton(this); 130 | 131 | const int iconSize = GetPixelMetric(QStyle::PM_LargeIconSize) * GetScaleFactor(*this); 132 | upButton = new QToolButton(this); 133 | upButton->setProperty("TTInternal", QVariant(true)); 134 | upButton->setAutoRaise(true); 135 | upButton->setDefaultAction(action); 136 | upButton->setIconSize(QSize(iconSize, iconSize)); 137 | upButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 138 | upButton->setStyle(new TTToolButtonStyle()); 139 | upButton->setMaximumHeight(iconSize + 5); 140 | 141 | QVBoxLayout* l = new QVBoxLayout(this); 142 | l->setMargin(0); 143 | l->setContentsMargins(0, 0, 0, 0); 144 | l->setSpacing(0); 145 | l->setDirection(QBoxLayout::TopToBottom); 146 | 147 | upButton->setToolButtonStyle(Qt::ToolButtonIconOnly); 148 | upButton->setPopupMode(QToolButton::DelayedPopup); 149 | l->addWidget(upButton); 150 | 151 | downButton = new QToolButton(this); 152 | downButton->setProperty("TTInternal", QVariant(true)); 153 | downButton->setAutoRaise(true); 154 | downButton->setToolButtonStyle(Qt::ToolButtonTextOnly); 155 | downButton->setPopupMode(QToolButton::InstantPopup); 156 | downButton->setMinimumHeight(25); 157 | downButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 158 | downButton->setText(action->text()); 159 | downButton->setToolTip(action->toolTip()); 160 | downButton->setStyle(new TTToolButtonStyle()); 161 | 162 | if(menu) 163 | { 164 | downButton->setMenu(menu); 165 | QObject::connect(menu, &QMenu::aboutToHide, this, [this]{ SetHover(false); }); 166 | } 167 | l->addWidget(downButton); 168 | setLayout(l); 169 | 170 | TTHover* hover = new TTHover(this, upButton, downButton); 171 | upButton->installEventFilter(hover); 172 | downButton->installEventFilter(hover); 173 | } 174 | 175 | void CompactToolButton::SetHover(bool hover) 176 | { 177 | static_cast(overlay)->paint = hover; 178 | update(); 179 | } 180 | 181 | } 182 | -------------------------------------------------------------------------------- /examples/Test/tabtoolbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "groupHeight":75, 3 | "groupRowCount":3, 4 | "specialTab":true, 5 | "cornerActions":[ 6 | "actionHelp" 7 | ], 8 | "menus":[ 9 | { 10 | "name":"dummyMenu", 11 | "actions":[ 12 | "actionDummy", 13 | "separator", 14 | "actionHelp" 15 | ] 16 | } 17 | ], 18 | "tabs":[ 19 | { 20 | "displayName":"File", 21 | "name":"File", 22 | "groups":[] 23 | }, 24 | { 25 | "displayName":"Edit", 26 | "name":"Edit", 27 | "groups":[ 28 | { 29 | "displayName":"Styles", 30 | "name":"Styles", 31 | "content":[ 32 | { 33 | "itemType":"subgroup", 34 | "aligned":true, 35 | "name":"stylesSubgroup1", 36 | "content":[ 37 | { 38 | "itemType":"pushButton", 39 | "name":"nativeStyleButton" 40 | }, 41 | { 42 | "itemType":"pushButton", 43 | "name":"defaultStyleButton" 44 | } 45 | ] 46 | } 47 | ] 48 | } 49 | ] 50 | }, 51 | { 52 | "displayName":"View", 53 | "name":"View", 54 | "groups":[ 55 | { 56 | "displayName":"Group 1", 57 | "name":"Group 1", 58 | "content":[ 59 | { 60 | "itemType":"action", 61 | "type":"delayedPopup", 62 | "name":"actionOpen" 63 | }, 64 | { "itemType":"separator" }, 65 | { 66 | "itemType":"action", 67 | "type":"delayedPopup", 68 | "name":"actionSave" 69 | }, 70 | { 71 | "itemType":"action", 72 | "type":"delayedPopup", 73 | "name":"actionSaveAs" 74 | } 75 | ] 76 | }, 77 | { 78 | "displayName":"Group 2", 79 | "name":"Group 2", 80 | "content":[ 81 | { 82 | "itemType":"action", 83 | "type":"instantPopup", 84 | "name":"actionPolypaint", 85 | "menu":"dummyMenu" 86 | }, 87 | { 88 | "itemType":"action", 89 | "type":"instantPopup", 90 | "name":"actionScale", 91 | "menu":"dummyMenu" 92 | }, 93 | { "itemType":"separator" }, 94 | { 95 | "itemType":"textEdit", 96 | "name":"customTextEdit" 97 | }, 98 | { 99 | "itemType":"subgroup", 100 | "name":"group2Subgroup", 101 | "aligned":true, 102 | "content":[ 103 | { 104 | "itemType":"action", 105 | "type":"delayedPopup", 106 | "name":"actionUndo" 107 | }, 108 | { 109 | "itemType":"action", 110 | "type":"delayedPopup", 111 | "name":"actionRedo" 112 | }, 113 | { 114 | "itemType":"action", 115 | "type":"instantPopup", 116 | "name":"actionClose", 117 | "menu":"dummyMenu" 118 | } 119 | ] 120 | } 121 | ] 122 | }, 123 | { 124 | "displayName":"Group 3", 125 | "name":"Group 3", 126 | "content":[ 127 | { 128 | "itemType":"action", 129 | "type":"menuButtonPopup", 130 | "name":"actionSettings", 131 | "menu":"dummyMenu" 132 | }, 133 | { 134 | "itemType":"subgroup", 135 | "name":"group3Subgroup1", 136 | "aligned":true, 137 | "content":[ 138 | { 139 | "itemType":"horizontalActions", 140 | "actions":[ 141 | { 142 | "type":"delayedPopup", 143 | "name":"actionSave" 144 | }, 145 | { 146 | "type":"instantPopup", 147 | "name":"actionPolypaint", 148 | "menu":"dummyMenu" 149 | }, 150 | { 151 | "type":"menuButtonPopup", 152 | "name":"actionSettings", 153 | "menu":"dummyMenu" 154 | } 155 | ] 156 | }, 157 | { 158 | "itemType":"horizontalActions", 159 | "actions":[ 160 | { 161 | "type":"delayedPopup", 162 | "name":"actionUndo" 163 | }, 164 | { 165 | "type":"delayedPopup", 166 | "name":"actionRedo" 167 | }, 168 | { 169 | "type":"instantPopup", 170 | "name":"actionClose", 171 | "menu":"dummyMenu" 172 | } 173 | ] 174 | }, 175 | { 176 | "itemType":"checkBox", 177 | "name":"customCheckBox" 178 | } 179 | ] 180 | }, 181 | { "itemType":"separator" }, 182 | { 183 | "itemType":"subgroup", 184 | "name":"group3Subgroup2", 185 | "aligned":false, 186 | "content":[ 187 | { 188 | "itemType":"pushButton", 189 | "name":"customEditButton" 190 | }, 191 | { 192 | "itemType":"action", 193 | "type":"delayedPopup", 194 | "name":"actionSaveAs" 195 | } 196 | ] 197 | } 198 | ] 199 | } 200 | ] 201 | }, 202 | { 203 | "displayName":"Help", 204 | "name":"Help", 205 | "groups":[ 206 | { 207 | "displayName":"", 208 | "name":"HelpGroup", 209 | "content":[ 210 | { 211 | "itemType":"action", 212 | "type":"delayedPopup", 213 | "name":"actionHelp" 214 | } 215 | ] 216 | } 217 | ] 218 | } 219 | ] 220 | } 221 | -------------------------------------------------------------------------------- /src/TabToolbar/StyleTools.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #if (QT_VERSION <= QT_VERSION_CHECK(5, 10, 0)) 29 | #include 30 | #endif 31 | #include 32 | #include 33 | #include 34 | 35 | namespace tt 36 | { 37 | 38 | static std::unique_ptr> styleMap; 39 | 40 | static QString GetStyleTemplate() 41 | { 42 | static QString styleTemplate; 43 | if(!styleTemplate.isEmpty()) 44 | return styleTemplate; 45 | 46 | QFile f(":/tt/StyleTemplate.qss"); 47 | f.open(QFile::ReadOnly); 48 | styleTemplate = f.readAll(); 49 | return styleTemplate; 50 | } 51 | 52 | static QString FormatColor(const QColor& col) 53 | { 54 | return QString("rgba(%1, %2, %3, %4)") 55 | .arg(col.red()) 56 | .arg(col.green()) 57 | .arg(col.blue()) 58 | .arg(col.alpha()); 59 | } 60 | 61 | static QString FormatColor(const Colors& colors) 62 | { 63 | const std::size_t sz = colors.size(); 64 | if(sz == 1) 65 | return FormatColor(colors[0].value); 66 | 67 | QString result = "qlineargradient(x1:0, y1:1, x2:0, y2:0"; 68 | for(const Color& col : colors) 69 | result += QString(", stop:") + QString::number(col.coefficient) + " " + FormatColor(col.value); 70 | result += ")"; 71 | 72 | return result; 73 | } 74 | 75 | static void FillStyle(QString& style, const StyleParams& params) 76 | { 77 | style.clear(); 78 | if(params.UseTemplateSheet) 79 | style = GetStyleTemplate(); 80 | style += params.AdditionalStyleSheet; 81 | 82 | int numProps = params.metaObject()->propertyCount(); 83 | for(int i=0; iproperty(i); 86 | if(QString(prop.name()) == "objectName") 87 | continue; 88 | if(prop.type() == QVariant::Bool) 89 | continue; 90 | const QString propStr = QString("%") + prop.name() + "%"; 91 | if(!style.contains(propStr)) 92 | continue; 93 | style.replace(propStr, "%1"); 94 | 95 | const QVariant property = params.property(prop.name()); 96 | switch(prop.type()) 97 | { 98 | case QVariant::String: 99 | style = style.arg(property.toString() + "px"); 100 | break; 101 | case QVariant::Int: 102 | style = style.arg(property.toInt()); 103 | break; 104 | case QVariant::UserType: 105 | { 106 | const Colors& colors = property.value(); 107 | if(colors.size() == 0) 108 | throw std::runtime_error("Some property has no colors!"); 109 | style = style.arg(FormatColor(colors)); 110 | break; 111 | } 112 | default: 113 | throw std::runtime_error("Unknown property type in style!"); 114 | } 115 | } 116 | } 117 | 118 | bool IsStyleRegistered(const QString& styleName) 119 | { 120 | return styleMap->contains(styleName); 121 | } 122 | 123 | std::unique_ptr CreateStyle(const QString& styleName) 124 | { 125 | auto creator = styleMap->find(styleName); 126 | if(creator == styleMap->end()) 127 | throw std::runtime_error(styleName.toStdString() + " - style is not registered!"); 128 | 129 | StyleParams* style = (*creator)(); 130 | style->setObjectName(styleName); 131 | return std::unique_ptr(style); 132 | } 133 | 134 | QString GetSheetForStyle(const StyleParams& style) 135 | { 136 | QString styleString; 137 | FillStyle(styleString, style); 138 | return styleString; 139 | } 140 | 141 | void RegisterStyle(const QString& styleName, const TStyleCreator& creator) 142 | { 143 | if(!styleMap) 144 | styleMap.reset(new QMap()); 145 | if(styleMap->contains(styleName)) 146 | throw std::runtime_error(styleName.toStdString() + " - style already registered!"); 147 | 148 | styleMap->insert(styleName, creator); 149 | } 150 | 151 | void UnregisterStyle(const QString& styleName) 152 | { 153 | styleMap->remove(styleName); 154 | } 155 | 156 | QStringList GetRegisteredStyles() 157 | { 158 | return styleMap->keys(); 159 | } 160 | 161 | QString GetDefaultStyle() 162 | { 163 | #if defined(Q_OS_UNIX) 164 | return g_styleKool; 165 | #elif defined(Q_OS_WIN) 166 | QString versionStr = QSysInfo::kernelVersion(); 167 | const int dotIndex = versionStr.indexOf('.'); 168 | if(dotIndex != -1) 169 | versionStr = versionStr.left(dotIndex + 2); 170 | versionStr.replace('.', '0'); 171 | bool ok = false; 172 | const double versionDouble = QLocale().toDouble(versionStr, &ok); 173 | if(!ok) 174 | return g_styleKool; 175 | if(versionDouble >= 602) 176 | return g_styleThreshold; 177 | return g_styleVienna; 178 | #endif 179 | } 180 | 181 | float GetScaleFactor(const QWidget& widget) 182 | { 183 | #if (QT_VERSION <= QT_VERSION_CHECK(5, 10, 0)) 184 | auto scrNumber = QApplication::desktop()->screenNumber(widget.mapToGlobal(QPoint(0,0))); 185 | auto screens = QGuiApplication::screens(); 186 | QScreen* scr = screens.at(scrNumber); 187 | #else 188 | QScreen* scr = QGuiApplication::screenAt(widget.mapToGlobal(QPoint(0,0))); 189 | #endif 190 | const float defaultDpi = 96.0f; 191 | return scr->logicalDotsPerInchY() / defaultDpi; 192 | } 193 | 194 | int GetPixelMetric(QStyle::PixelMetric metric) 195 | { 196 | switch(metric) 197 | { 198 | case QStyle::PM_SmallIconSize: 199 | return 16; 200 | case QStyle::PM_LargeIconSize: 201 | return 32; 202 | default: 203 | return QApplication::style()->pixelMetric(metric); 204 | } 205 | } 206 | 207 | }//namespace tt 208 | -------------------------------------------------------------------------------- /examples/Test/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "mainwindow.h" 28 | #include "ui_mainwindow.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | CMainWindow::CMainWindow(QWidget* parent) : 37 | QMainWindow(parent), 38 | ui(new Ui::MainWindow) 39 | { 40 | ui->setupUi(this); 41 | ui->statusBar->addPermanentWidget(new QLabel("Some fancy status.")); 42 | 43 | tt::Builder ttb(this); 44 | ttb.SetCustomWidgetCreator("textEdit", []() { return new QTextEdit(); }); 45 | ttb.SetCustomWidgetCreator("checkBox", []() { return new QCheckBox(); }); 46 | ttb.SetCustomWidgetCreator("pushButton", []() { return new QPushButton(); }); 47 | tt::TabToolbar* tabToolbar = ttb.CreateTabToolbar(":/tt/tabtoolbar.json"); 48 | addToolBar(Qt::TopToolBarArea, tabToolbar); 49 | 50 | ttb["customTextEdit"]->setMaximumWidth(100); 51 | 52 | ((QCheckBox*)ttb["customCheckBox"])->setText("Check 1"); 53 | QPushButton* btn = (QPushButton*)ttb["customEditButton"]; 54 | btn->setText("Edit"); 55 | static bool kek = true; 56 | tt::Page* editPage = (tt::Page*)ttb["Edit"]; 57 | QObject::connect(btn, &QPushButton::clicked, [editPage]() 58 | { 59 | if(kek) 60 | editPage->hide(); 61 | else 62 | editPage->show(); 63 | kek = !kek; 64 | }); 65 | 66 | QObject::connect(tabToolbar, &tt::TabToolbar::SpecialTabClicked, this, [this]() 67 | { 68 | QMessageBox::information(this, "Kek", "Cheburek"); 69 | }); 70 | 71 | //create buttons for each style 72 | tt::Group* stylesGroup = (tt::Group*)ttb["Styles"]; 73 | stylesGroup->AddSeparator(); 74 | QStringList styles = tt::GetRegisteredStyles(); 75 | for(int i=0; iSetStyle(styleName); }); 80 | stylesGroup->AddWidget(btn); 81 | } 82 | 83 | tt::RegisterStyle("NoStyle", []() 84 | { 85 | tt::StyleParams* params = new tt::StyleParams(); 86 | params->UseTemplateSheet = false; 87 | params->AdditionalStyleSheet = ""; 88 | return params; 89 | }); 90 | btn = (QPushButton*)ttb["nativeStyleButton"]; 91 | btn->setText("No Style"); 92 | QObject::connect(btn, &QPushButton::clicked, [tabToolbar]() { tabToolbar->SetStyle("NoStyle"); }); 93 | btn = (QPushButton*)ttb["defaultStyleButton"]; 94 | btn->setText("Default"); 95 | QObject::connect(btn, &QPushButton::clicked, [tabToolbar]() { tabToolbar->SetStyle(tt::GetDefaultStyle()); }); 96 | /* 97 | TabToolbar* tt = new TabToolbar(this, 75, 3); 98 | addToolBar(Qt::TopToolBarArea, tt); 99 | 100 | QMenu* menu = new QMenu(this); 101 | menu->setObjectName("dummyMenu"); 102 | menu->addActions({ui->actionDummy}); 103 | 104 | tt->AddPage("File"); 105 | static bool kek = true; 106 | TTPage* editPage = tt->AddPage("Edit"); 107 | 108 | TTPage* viewPage = tt->AddPage("View"); 109 | TTGroup* g1 = viewPage->AddGroup("Group 1"); 110 | TTGroup* g2 = viewPage->AddGroup("Group 2"); 111 | TTGroup* g3 = viewPage->AddGroup("Group 3"); 112 | g1->AddAction(QToolButton::DelayedPopup, ui->actionOpen); 113 | g1->AddSeparator(); 114 | g1->AddAction(QToolButton::DelayedPopup, ui->actionSave); 115 | g1->AddAction(QToolButton::DelayedPopup, ui->actionSaveAs); 116 | g2->AddAction(QToolButton::InstantPopup, ui->actionPolypaint, menu); 117 | g2->AddAction(QToolButton::InstantPopup, ui->actionScale, menu); 118 | g2->AddSeparator(); 119 | QTextEdit* te = new QTextEdit(); 120 | g2->AddWidget(te); 121 | te->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored); 122 | te->setMaximumWidth(100); 123 | TTSubGroup* g2s = g2->AddSubGroup(TTSubGroup::Align::Yes); 124 | g2s->AddAction(QToolButton::DelayedPopup, ui->actionUndo); 125 | g2s->AddAction(QToolButton::DelayedPopup, ui->actionRedo); 126 | g2s->AddAction(QToolButton::InstantPopup, ui->actionClose, menu); 127 | g3->AddAction(QToolButton::MenuButtonPopup, ui->actionSettings, menu); 128 | TTSubGroup* g3s = g3->AddSubGroup(TTSubGroup::Align::Yes); 129 | g3s->AddHorizontalButtons({{QToolButton::DelayedPopup, ui->actionSave}, 130 | {QToolButton::InstantPopup, ui->actionPolypaint, menu}, 131 | {QToolButton::MenuButtonPopup, ui->actionSettings, menu}}); 132 | 133 | g3s->AddHorizontalButtons({{QToolButton::DelayedPopup, ui->actionUndo}, 134 | {QToolButton::DelayedPopup, ui->actionRedo}, 135 | {QToolButton::InstantPopup, ui->actionClose, menu}}); 136 | QCheckBox* ch = new QCheckBox("Check 1"); 137 | g3s->AddWidget(ch); 138 | 139 | g3->AddSeparator(); 140 | TTSubGroup* g3ss = g3->AddSubGroup(TTSubGroup::Align::No); 141 | QPushButton* btn = new QPushButton("Edit"); 142 | g3ss->AddWidget(btn); 143 | g3ss->AddAction(QToolButton::DelayedPopup, ui->actionSaveAs); 144 | QObject::connect(btn, &QPushButton::clicked, [editPage]() 145 | { 146 | if(kek) 147 | editPage->hide(); 148 | else 149 | editPage->show(); 150 | kek = !kek; 151 | }); 152 | 153 | tt->AddPage("Help"); 154 | 155 | tt->SetSpecialTabEnabled(true); 156 | tt->AddCornerAction(ui->actionHelp); 157 | QObject::connect(tt, &TabToolbar::SpecialTabClicked, this, [this]() 158 | { 159 | QMessageBox::information(this, "Kek", "Cheburek"); 160 | }); 161 | */ 162 | } 163 | 164 | CMainWindow::~CMainWindow() 165 | { 166 | delete ui; 167 | } 168 | -------------------------------------------------------------------------------- /COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /src/TabToolbar/ToolButtonStyle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include "ToolButtonStyle.h" 21 | 22 | using namespace tt; 23 | 24 | //redefine text alignment 25 | void TTToolButtonStyle::drawControl(ControlElement element, const QStyleOption* opt, QPainter* p, const QWidget* widget) const 26 | { 27 | if(element == CE_ToolButtonLabel) 28 | { 29 | if (const QStyleOptionToolButton* toolbutton = static_cast(opt)) 30 | { 31 | QRect rect = toolbutton->rect; 32 | int shiftX = 0; 33 | int shiftY = 0; 34 | if (toolbutton->state & (State_Sunken | State_On)) { 35 | shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); 36 | shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); 37 | } 38 | // Arrow type always overrules and is always shown 39 | bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow; 40 | if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty()) 41 | || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) { 42 | int alignment = Qt::AlignTop | Qt::AlignHCenter | Qt::TextShowMnemonic; 43 | if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) 44 | alignment |= Qt::TextHideMnemonic; 45 | rect.translate(shiftX, shiftY); 46 | p->setFont(toolbutton->font); 47 | proxy()->drawItemText(p, rect, alignment, toolbutton->palette, 48 | opt->state & State_Enabled, toolbutton->text, 49 | QPalette::ButtonText); 50 | } else { 51 | QPixmap pm; 52 | QSize pmSize = toolbutton->iconSize; 53 | if (!toolbutton->icon.isNull()) { 54 | QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off; 55 | QIcon::Mode mode; 56 | if (!(toolbutton->state & State_Enabled)) 57 | mode = QIcon::Disabled; 58 | else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise)) 59 | mode = QIcon::Active; 60 | else 61 | mode = QIcon::Normal; 62 | pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize), 63 | mode, state); 64 | pmSize = pm.size(); 65 | } 66 | 67 | if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) { 68 | p->setFont(toolbutton->font); 69 | QRect pr = rect, 70 | tr = rect; 71 | int alignment = Qt::TextShowMnemonic; 72 | if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) 73 | alignment |= Qt::TextHideMnemonic; 74 | 75 | if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { 76 | pr.setHeight(pmSize.height() + 6); 77 | tr.adjust(0, pr.height() - 1, 0, -2); 78 | pr.translate(shiftX, shiftY); 79 | if (!hasArrow) 80 | proxy()->drawItemPixmap(p, pr, Qt::AlignTop | Qt::AlignHCenter, pm); 81 | alignment |= Qt::AlignTop | Qt::AlignHCenter; 82 | } else { 83 | pr.setWidth(pmSize.width() + 8); 84 | tr.adjust(pr.width(), 0, 0, 0); 85 | pr.translate(shiftX, shiftY); 86 | if (!hasArrow) 87 | proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignTop | Qt::AlignHCenter, pm); 88 | alignment |= Qt::AlignTop | Qt::AlignHCenter; 89 | } 90 | tr.translate(shiftX, shiftY); 91 | proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette, 92 | toolbutton->state & State_Enabled, toolbutton->text, 93 | QPalette::ButtonText); 94 | } else { 95 | rect.translate(shiftX, shiftY); 96 | if (!hasArrow) 97 | proxy()->drawItemPixmap(p, rect, Qt::AlignTop | Qt::AlignHCenter, pm); 98 | } 99 | } 100 | } 101 | return; 102 | } 103 | return QProxyStyle::drawControl(element, opt, p, widget); 104 | } 105 | 106 | //redefine arrow alignment 107 | void TTToolButtonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex* opt, QPainter* p, const QWidget* widget) const 108 | { 109 | if(cc == CC_ToolButton) 110 | { 111 | if (const QStyleOptionToolButton *toolbutton 112 | = qstyleoption_cast(opt)) { 113 | QRect button, menuarea; 114 | button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); 115 | menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); 116 | 117 | State bflags = toolbutton->state & ~State_Sunken; 118 | 119 | if (bflags & State_AutoRaise) { 120 | if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { 121 | bflags &= ~State_Raised; 122 | } 123 | } 124 | State mflags = bflags; 125 | if (toolbutton->state & State_Sunken) { 126 | if (toolbutton->activeSubControls & SC_ToolButton) 127 | bflags |= State_Sunken; 128 | mflags |= State_Sunken; 129 | } 130 | 131 | QStyleOption tool(0); 132 | tool.palette = toolbutton->palette; 133 | if (toolbutton->subControls & SC_ToolButton) { 134 | if (bflags & (State_Sunken | State_On | State_Raised)) { 135 | tool.rect = button; 136 | tool.state = bflags; 137 | proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 138 | } 139 | } 140 | 141 | if (toolbutton->state & State_HasFocus) { 142 | QStyleOptionFocusRect fr; 143 | fr.QStyleOption::operator=(*toolbutton); 144 | fr.rect.adjust(3, 3, -3, -3); 145 | if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) 146 | fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, 147 | toolbutton, widget), 0); 148 | proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); 149 | } 150 | QStyleOptionToolButton label = *toolbutton; 151 | label.state = bflags; 152 | int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); 153 | label.rect = button.adjusted(fw, fw, -fw, -fw); 154 | proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); 155 | 156 | if (toolbutton->subControls & SC_ToolButtonMenu) { 157 | tool.rect = menuarea; 158 | tool.state = mflags; 159 | if (mflags & (State_Sunken | State_On | State_Raised)) 160 | proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); 161 | proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); 162 | } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { 163 | int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); 164 | QRect ir = toolbutton->rect; 165 | QStyleOptionToolButton newBtn = *toolbutton; 166 | newBtn.rect = QRect(ir.center().x() + 1 - (mbi - 6)/2, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6); 167 | proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 168 | } 169 | } 170 | return; 171 | } 172 | return QProxyStyle::drawComplexControl(cc, opt, p, widget); 173 | } 174 | -------------------------------------------------------------------------------- /src/TabToolbar/TabToolbar.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | using namespace tt; 35 | 36 | TabToolbar::TabToolbar(QWidget* parent, unsigned _groupMaxHeight, unsigned _groupRowCount) : 37 | QToolBar(parent), 38 | groupRowCount(_groupRowCount), 39 | groupMaxHeight(_groupMaxHeight) 40 | { 41 | setObjectName("TabToolbar"); 42 | tempShowTimer.setSingleShot(true); 43 | tempShowTimer.setInterval(QApplication::doubleClickInterval()); 44 | 45 | setProperty("TabToolbar", QVariant(true)); 46 | layout()->setContentsMargins(0, 0, 0, 0); 47 | layout()->setMargin(0); 48 | layout()->setSpacing(0); 49 | setContentsMargins(0, 0, 0, 0); 50 | setFloatable(false); 51 | setMovable(false); 52 | setAllowedAreas(Qt::TopToolBarArea); 53 | tabBar = new QTabWidget(this); 54 | tabBar->setProperty("TTWidget", QVariant(true)); 55 | tabBar->tabBar()->setProperty("TTTab", QVariant(true)); 56 | tabBarHandle = addWidget(tabBar); 57 | tabBar->setUsesScrollButtons(true); 58 | 59 | cornerActions = new QFrame(this); 60 | cornerActions->setFrameShape(QFrame::NoFrame); 61 | cornerActions->setLineWidth(0); 62 | cornerActions->setContentsMargins(0, 0, 0, 0); 63 | cornerActions->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 64 | QHBoxLayout* cornerLayout = new QHBoxLayout(cornerActions); 65 | cornerLayout->setMargin(0); 66 | cornerLayout->setContentsMargins(0, 0, 0, 0); 67 | cornerLayout->setSpacing(0); 68 | cornerLayout->setDirection(QBoxLayout::LeftToRight); 69 | cornerActions->setLayout(cornerLayout); 70 | 71 | hideAction = new QAction(this); 72 | hideAction->setCheckable(true); 73 | hideAction->setText("▲"); 74 | hideButton = new QToolButton(tabBar); 75 | hideButton->setProperty("TTHide", QVariant(true)); 76 | hideButton->setToolButtonStyle(Qt::ToolButtonTextOnly); 77 | hideButton->setDefaultAction(hideAction); 78 | hideButton->setAutoRaise(true); 79 | hideButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 80 | QObject::connect(hideAction, &QAction::triggered, [this]() 81 | { 82 | tempShowTimer.start(); 83 | isMinimized = hideAction->isChecked(); 84 | hideAction->setText(isMinimized ? "▼" : "▲"); 85 | HideAt(tabBar->currentIndex()); 86 | if(isMinimized) 87 | emit Minimized(); 88 | else 89 | emit Maximized(); 90 | }); 91 | QObject::connect(tabBar, &QTabWidget::tabBarDoubleClicked, hideAction, &QAction::trigger); 92 | QObject::connect(tabBar, &QTabWidget::tabBarClicked, this, &TabToolbar::TabClicked); 93 | QObject::connect(tabBar, &QTabWidget::currentChanged, this, &TabToolbar::CurrentTabChanged); 94 | QObject::connect((QApplication*)QApplication::instance(), &QApplication::focusChanged, this, &TabToolbar::FocusChanged); 95 | cornerLayout->addWidget(hideButton); 96 | tabBar->setCornerWidget(cornerActions); 97 | 98 | SetStyle(GetDefaultStyle()); 99 | } 100 | 101 | TabToolbar::~TabToolbar() 102 | { 103 | } 104 | 105 | bool TabToolbar::event(QEvent* event) 106 | { 107 | if(event->type() == QEvent::StyleChange && !ignoreStyleEvent) 108 | QTimer::singleShot(0, this, [this]() 109 | { // on KDE new palette is not ready yet, wait 110 | const QString styleName = (style ? style->objectName() : GetDefaultStyle()); 111 | SetStyle(styleName); 112 | }); 113 | return QToolBar::event(event); 114 | } 115 | 116 | void TabToolbar::FocusChanged(QWidget* old, QWidget* now) 117 | { 118 | (void)old; 119 | if(now && now != this) 120 | { 121 | if(isMinimized && isShown) 122 | { 123 | QObject* parent = now; 124 | do 125 | { 126 | parent = parent->parent(); 127 | if(parent == this) 128 | return; 129 | } while(parent); 130 | 131 | HideAt(currentIndex); 132 | } 133 | } 134 | } 135 | 136 | unsigned TabToolbar::RowCount() const 137 | { 138 | return groupRowCount; 139 | } 140 | 141 | unsigned TabToolbar::GroupMaxHeight() const 142 | { 143 | return groupMaxHeight * GetScaleFactor(*this); 144 | } 145 | 146 | void TabToolbar::SetStyle(const QString& styleName) 147 | { 148 | ignoreStyleEvent = true; 149 | style.reset(CreateStyle(styleName).release()); 150 | setStyleSheet(GetSheetForStyle(*style)); 151 | ignoreStyleEvent = false; 152 | emit StyleChanged(); 153 | } 154 | 155 | QString TabToolbar::GetStyle() const 156 | { 157 | if(style) 158 | return style->objectName(); 159 | return ""; 160 | } 161 | 162 | void TabToolbar::AddCornerAction(QAction* action) 163 | { 164 | QToolButton* actionButton = new QToolButton(tabBar); 165 | actionButton->setProperty("TTInternal", QVariant(true)); 166 | actionButton->setToolButtonStyle(Qt::ToolButtonIconOnly); 167 | actionButton->setDefaultAction(action); 168 | actionButton->setAutoRaise(true); 169 | actionButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 170 | cornerActions->layout()->addWidget(actionButton); 171 | } 172 | 173 | void TabToolbar::SetSpecialTabEnabled(bool enabled) 174 | { 175 | hasSpecialTab = enabled; 176 | tabBar->tabBar()->setProperty("TTSpecial", QVariant(enabled)); 177 | if(enabled && tabBar->count() > 0) 178 | { 179 | tabBar->setCurrentIndex(1); 180 | } 181 | } 182 | 183 | QAction* TabToolbar::HideAction() 184 | { 185 | return hideAction; 186 | } 187 | 188 | void TabToolbar::TabClicked(int index) 189 | { 190 | if(tempShowTimer.isActive() || (index == 0 && hasSpecialTab)) 191 | return; 192 | 193 | if(isMinimized) 194 | { 195 | if(isShown && index != currentIndex) 196 | return; //dont hide tab bar if just switching tabs 197 | isMinimized = isShown; 198 | HideAt(index); 199 | isMinimized = true; 200 | } 201 | } 202 | 203 | void TabToolbar::CurrentTabChanged(int index) 204 | { 205 | QSignalBlocker blocker(tabBar); 206 | if(index == 0 && hasSpecialTab) 207 | { 208 | tabBar->setCurrentIndex(currentIndex); 209 | emit SpecialTabClicked(); 210 | } 211 | else 212 | { 213 | currentIndex = index; 214 | } 215 | } 216 | 217 | int TabToolbar::CurrentTab() const 218 | { 219 | return currentIndex; 220 | } 221 | 222 | void TabToolbar::SetCurrentTab(int index) 223 | { 224 | tabBar->setCurrentIndex(index); 225 | } 226 | 227 | void TabToolbar::HideAt(int index) 228 | { 229 | if(isMinimized) 230 | { 231 | const int minHeight = tabBar->tabBar()->height() + 2; 232 | tabBar->setMaximumHeight(minHeight); 233 | tabBar->setMinimumHeight(minHeight); 234 | setMaximumHeight(minHeight); 235 | setMinimumHeight(minHeight); 236 | isShown = false; 237 | } else { 238 | tabBar->setCurrentIndex(index); 239 | if(!isShown) 240 | { 241 | tabBar->setMaximumHeight(maxHeight); 242 | tabBar->setMinimumHeight(maxHeight); 243 | setMaximumHeight(maxHeight); 244 | setMinimumHeight(maxHeight); 245 | tabBar->adjustSize(); 246 | } 247 | setFocus(); 248 | isShown = true; 249 | } 250 | } 251 | 252 | void TabToolbar::HideTab(int index) 253 | { 254 | (void)index; 255 | Page* page = static_cast(sender()); 256 | QSignalBlocker blocker(page); 257 | for(int i=0; icount(); i++) 258 | { 259 | if(tabBar->widget(i) == page) 260 | { 261 | tabBar->removeTab(i); 262 | return; 263 | } 264 | } 265 | currentIndex = tabBar->currentIndex(); 266 | } 267 | 268 | void TabToolbar::AdjustVerticalSize(unsigned vSize) 269 | { 270 | QTimer::singleShot(0, this, [this, vSize]() 271 | { 272 | maxHeight = vSize + tabBar->tabBar()->height() + 6; 273 | setMaximumHeight(maxHeight); 274 | setMinimumHeight(maxHeight); 275 | }); 276 | } 277 | 278 | void TabToolbar::ShowTab(int index) 279 | { 280 | Page* page = static_cast(sender()); 281 | QSignalBlocker blocker(page); 282 | tabBar->insertTab(index, page, page->objectName()); 283 | currentIndex = tabBar->currentIndex(); 284 | } 285 | 286 | Page* TabToolbar::AddPage(const QString& pageName) 287 | { 288 | Page* page = new Page(tabBar->count(), pageName); 289 | QSignalBlocker blocker(page); 290 | QObject::connect(page, &Page::Hiding, this, &TabToolbar::HideTab); 291 | QObject::connect(page, &Page::Showing, this, &TabToolbar::ShowTab); 292 | tabBar->addTab(page, pageName); 293 | return page; 294 | } 295 | 296 | TabToolbar* tt::_FindTabToolbarParent(QWidget& startingWidget) 297 | { 298 | QObject* par = &startingWidget; 299 | do 300 | { 301 | par = par->parent(); 302 | if(auto* tt = dynamic_cast(par)) 303 | return tt; 304 | } while(par); 305 | 306 | return nullptr; 307 | } 308 | -------------------------------------------------------------------------------- /src/TabToolbar/Builder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace tt; 34 | 35 | Builder::Builder(QWidget* parent) : QObject(parent) 36 | { 37 | } 38 | 39 | QWidget* Builder::operator[](const QString& widgetName) const 40 | { 41 | return guiWidgets.value(widgetName, nullptr); 42 | } 43 | 44 | void Builder::SetCustomWidgetCreator(const QString& name, const std::function& creator) 45 | { 46 | customWidgetCreators[name] = [creator](const QJsonObject&) { return creator(); }; 47 | } 48 | 49 | void Builder::SetCustomWidgetCreator(const QString& name, const std::function& creator) 50 | { 51 | customWidgetCreators[name] = creator; 52 | } 53 | 54 | TabToolbar* Builder::CreateTabToolbar(const QString& configPath) 55 | { 56 | const QList& actions = parent()->findChildren(); 57 | const QList& menus = parent()->findChildren(); 58 | QMap actionsMap; 59 | QMap menusMap; 60 | for(QAction* action : actions) 61 | actionsMap.insert(action->objectName(), action); 62 | for(QMenu* menu : menus) 63 | menusMap.insert(menu->objectName(), menu); 64 | 65 | QFile configFile(configPath); 66 | configFile.open(QIODevice::ReadOnly); 67 | const QJsonDocument config(QJsonDocument::fromJson(configFile.readAll())); 68 | const QJsonObject root = config.object(); 69 | const int groupHeight = root["groupHeight"].toInt(); 70 | const int groupRowCount = root["groupRowCount"].toInt(); 71 | const bool hasSpecialTab = root["specialTab"].toBool(); 72 | TabToolbar* tt = new TabToolbar((QWidget*)parent(), groupHeight, groupRowCount); 73 | 74 | auto CreateCustomWidget = [this, tt](const QString& name, const QJsonObject& item) 75 | { 76 | if(!customWidgetCreators.contains(name)) 77 | throw std::logic_error(std::string("Unknown item type: ") + name.toStdString()); 78 | QWidget* w = customWidgetCreators[name](item); 79 | if(item.contains("name")) 80 | { 81 | w->setObjectName(item["name"].toString()); 82 | guiWidgets[w->objectName()] = w; 83 | } 84 | w->setParent(tt); 85 | return w; 86 | }; 87 | 88 | auto CreateActionParams = [this, &actionsMap, &menusMap](const QJsonObject& obj) 89 | { 90 | SubGroup::ActionParams params; 91 | const QString type = obj["type"].toString(); 92 | if(type == "delayedPopup") 93 | params.type = QToolButton::DelayedPopup; 94 | else if(type == "instantPopup") 95 | params.type = QToolButton::InstantPopup; 96 | else if(type == "menuButtonPopup") 97 | params.type = QToolButton::MenuButtonPopup; 98 | else 99 | throw std::logic_error(std::string("Unknown toolbutton popup mode: ") + type.toStdString()); 100 | 101 | params.action = actionsMap[obj["name"].toString()]; 102 | params.menu = nullptr; 103 | if(obj.contains("menu") && !obj["menu"].isNull()) 104 | params.menu = menusMap[obj["menu"].toString()]; 105 | return params; 106 | }; 107 | 108 | const QJsonArray cornerActions = root["cornerActions"].toArray(); 109 | for(int i=0; iAddCornerAction(actionsMap[cornerActions.at(i).toString()]); 111 | 112 | const QJsonArray menusList = root["menus"].toArray(); 113 | for(int i=0; isetObjectName(menuObject["name"].toString()); 118 | menusMap[menu->objectName()] = menu; 119 | guiWidgets[menu->objectName()] = menu; 120 | const QJsonArray menuActions = menuObject["actions"].toArray(); 121 | for(int j=0; jaddSeparator(); 126 | else 127 | menu->addActions({actionsMap[actionName]}); 128 | } 129 | } 130 | 131 | const QJsonArray tabs = root["tabs"].toArray(); 132 | for(int i=0; iAddPage(pageDisplayName); 138 | guiWidgets[pageName] = page; 139 | 140 | const QJsonArray groups = tab["groups"].toArray(); 141 | for(int j=0; jAddGroup(groupDisplayName); 147 | guiWidgets[groupName] = group; 148 | 149 | const QJsonArray content = groupObject["content"].toArray(); 150 | for(int k=0; k defaultTypes = {"action", "subgroup", "separator"}; 155 | const QString itemType = item["itemType"].toString(); 156 | int type = defaultTypes.indexOf(itemType); 157 | switch(type) 158 | { 159 | case 0: //action 160 | { 161 | SubGroup::ActionParams params = CreateActionParams(item); 162 | group->AddAction(params.type, params.action, params.menu); 163 | break; 164 | } 165 | case 1: //subgroup 166 | { 167 | SubGroup::Align align = SubGroup::Align::Yes; 168 | if(!item["aligned"].toBool()) 169 | align = SubGroup::Align::No; 170 | SubGroup* subGroup = group->AddSubGroup(align); 171 | const QString subGroupName = item["name"].toString(); 172 | subGroup->setObjectName(subGroupName); 173 | guiWidgets[subGroupName] = subGroup; 174 | 175 | const QJsonArray subGroupContent = item["content"].toArray(); 176 | for(int w=0; w defaultSgTypes = {"action", "horizontalActions"}; 181 | const QString sgItemType = sgItem["itemType"].toString(); 182 | int sgType = defaultSgTypes.indexOf(sgItemType); 183 | switch(sgType) 184 | { 185 | case 0: //action 186 | { 187 | SubGroup::ActionParams params = CreateActionParams(sgItem); 188 | subGroup->AddAction(params.type, params.action, params.menu); 189 | break; 190 | } 191 | case 1: //horizontalActions 192 | { 193 | std::vector horizActions; 194 | const QJsonArray horizActionsArray = sgItem["actions"].toArray(); 195 | for(int x=0; xAddHorizontalButtons(horizActions); 201 | break; 202 | } 203 | default: 204 | { 205 | QWidget* w = CreateCustomWidget(sgItemType, sgItem); 206 | subGroup->AddWidget(w); 207 | break; 208 | } 209 | } 210 | } 211 | break; 212 | } 213 | case 2: //separator 214 | group->AddSeparator(); 215 | break; 216 | default: //custom widget 217 | { 218 | QWidget* w = CreateCustomWidget(itemType, item); 219 | group->AddWidget(w); 220 | break; 221 | } 222 | } 223 | } 224 | } 225 | } 226 | 227 | tt->SetSpecialTabEnabled(hasSpecialTab); 228 | return tt; 229 | } 230 | -------------------------------------------------------------------------------- /src/TabToolbar/Styles.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TabToolbar - a small utility library for Qt, providing tabbed toolbars 3 | Copyright (C) 2018 Oleksii Sierov 4 | 5 | TabToolbar is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | TabToolbar 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 Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with TabToolbar. If not, see . 17 | */ 18 | #include 19 | #include 20 | 21 | using namespace tt; 22 | 23 | extern const QString tt::g_styleKool = "Kool"; 24 | extern const QString tt::g_styleVienna = "Vienna"; 25 | extern const QString tt::g_styleThreshold = "Threshold"; 26 | 27 | namespace 28 | { 29 | struct TPalette 30 | { 31 | TPalette() 32 | { 33 | const QPalette p; 34 | light = p.light().color(); 35 | midlight = p.midlight().color(); 36 | dark = p.dark().color(); 37 | window = p.window().color(); 38 | text = p.text().color(); 39 | highlight = p.highlight().color(); 40 | htext = p.highlightedText().color(); 41 | } 42 | 43 | QColor htext; 44 | QColor highlight; 45 | QColor light; 46 | QColor midlight; 47 | QColor dark; 48 | QColor window; 49 | QColor text; 50 | }; 51 | 52 | struct DefaultStylesRegistrar 53 | { 54 | DefaultStylesRegistrar() 55 | { 56 | auto clampColor = [](int v) 57 | { 58 | if(v < 0) 59 | return 0; 60 | if(v > 255) 61 | return 255; 62 | return v; 63 | }; 64 | auto lcomb = [clampColor](const QColor& c1, const QColor& c2, float f) 65 | { 66 | const float fi = 1.0f - f; 67 | return QColor(clampColor(c1.red() *f + c2.red() *fi), 68 | clampColor(c1.green()*f + c2.green()*fi), 69 | clampColor(c1.blue() *f + c2.blue() *fi), 70 | clampColor(c1.alpha()*f + c2.alpha()*fi)); 71 | }; 72 | auto dimmed = [lcomb](const QColor& c, float factor) 73 | { 74 | return lcomb(c, Qt::black, 1.0f-factor); 75 | }; 76 | auto coeff = [clampColor](const QColor& c, float cr, float cg, float cb) 77 | { 78 | return QColor(clampColor(c.red() * cr), clampColor(c.green() * cg), clampColor(c.blue() * cb)); 79 | }; 80 | auto add = [clampColor](const QColor& c1, const QColor& c2) 81 | { 82 | return QColor(clampColor(c1.red() + c2.red()), 83 | clampColor(c1.green() + c2.green()), 84 | clampColor(c1.blue() + c2.blue()), 85 | clampColor(c1.alpha() + c2.alpha())); 86 | }; 87 | auto toBase = [](const QColor& c) 88 | { 89 | const int minColor = std::min(std::min(c.red(), c.green()), c.blue()); 90 | return QColor(c.red() - minColor, 91 | c.green() - minColor, 92 | c.blue() - minColor); 93 | }; 94 | 95 | RegisterStyle(g_styleKool, [lcomb, dimmed]() 96 | { 97 | const TPalette p; 98 | StyleParams* params = new StyleParams(); 99 | 100 | params->UseTemplateSheet = true; 101 | params->AdditionalStyleSheet = ""; 102 | params->TabBorderRadius = 0; 103 | params->TabFontColor = p.text; 104 | params->ToolbarBackgroundColor = p.window; 105 | params->BorderColor = dimmed(p.light, 0.25f); 106 | params->GroupNameColor = lcomb(p.text, p.midlight, 0.4f); 107 | 108 | params->TabSpecialColor = {{0.0f, dimmed(p.highlight, 0.2f)}, 109 | {1.0f, p.highlight}}; 110 | 111 | params->TabSpecialHoverColor = {{0.0f, params->TabSpecialColor[1].value}, 112 | {1.0f, params->TabSpecialColor[0].value}}; 113 | 114 | params->TabSpecialHoverBorderColor = p.highlight; 115 | params->TabSpecialHoverBorderColorSide = params->TabSpecialHoverBorderColor; 116 | params->TabSpecialBorderColor = p.highlight; 117 | params->TabSpecialBorderColorSide = params->TabSpecialBorderColor; 118 | params->TabSpecialFontColor = p.htext; 119 | 120 | params->TabUnselectedHoverBorderColorTop = 121 | params->TabHoverBorderColorTop = p.highlight; 122 | 123 | params->TabUnselectedHoverBorderColorSide = 124 | params->TabHoverBorderColorSide = {{0.0f, params->BorderColor}, 125 | {0.1f, params->BorderColor}, 126 | {0.7f, params->TabHoverBorderColorTop}, 127 | {1.0f, params->TabHoverBorderColorTop}}; 128 | 129 | params->PaneColor = {{0.0f, dimmed(p.light, 0.1f)}, 130 | {0.7f, p.light}, 131 | {1.0f, p.light}}; 132 | 133 | params->TabSelectedColor = p.light; 134 | 135 | params->TabUnselectedColor = lcomb(params->ToolbarBackgroundColor, params->TabSelectedColor[0].value, 0.5f); 136 | 137 | params->SeparatorColor = {{0.0f, Qt::transparent}, 138 | {0.05f, Qt::transparent}, 139 | {0.1f, params->BorderColor}, 140 | {0.9f, params->BorderColor}, 141 | {0.95f, Qt::transparent}, 142 | {1.0f, Qt::transparent}}; 143 | 144 | params->HorizontalFrameBackgroundColor = params->PaneColor; 145 | for(auto& c : params->HorizontalFrameBackgroundColor) 146 | c.value.setAlpha(100); 147 | params->HorizontalFrameBorderColor = params->BorderColor; 148 | params->HorizontalFrameBorderSize = 2; 149 | params->TabSpacing = 3; 150 | 151 | params->HideArrowColor = lcomb(p.text, p.midlight, 0.4f); 152 | return params; 153 | }); 154 | 155 | RegisterStyle(g_styleVienna, [lcomb, dimmed, coeff, add, toBase]() 156 | { 157 | const TPalette p; 158 | const QColor vienna = (p.window.lightnessF() > 0.5f ? QColor(51, 153, 255) : QColor(25, 40, 70)); 159 | StyleParams* params = new StyleParams(); 160 | 161 | params->UseTemplateSheet = true; 162 | params->AdditionalStyleSheet = ""; 163 | params->TabBorderRadius = 2; 164 | params->TabFontColor = lcomb(p.text, vienna, 0.588f); 165 | params->ToolbarBackgroundColor = add(dimmed(p.window, 0.07f), toBase(dimmed(vienna, 0.892f))); 166 | const float dimmCoeff = (p.window.lightnessF() > 0.5f ? 0.225f : 0.5f); 167 | params->BorderColor = add(dimmed(p.window, dimmCoeff), toBase(dimmed(vienna, 0.838f))); 168 | params->GroupNameColor = lcomb(p.text, params->ToolbarBackgroundColor, 0.484f); 169 | 170 | params->PaneColor = {{0.0f, params->ToolbarBackgroundColor}, 171 | {0.5f, params->ToolbarBackgroundColor}, 172 | {0.75f, lcomb(params->ToolbarBackgroundColor, p.light, 0.5f)}, 173 | {1.0f, p.light}}; 174 | 175 | params->TabSpecialColor = {{0.0f, add(dimmed(p.window, 0.7125f), coeff(toBase(dimmed(p.highlight, 0.294f)), 1.0f, 1.29f, 1.0f))}, 176 | {0.6f, add(dimmed(p.window, 0.891f), coeff(toBase(dimmed(p.highlight, 0.46f)), 1.0f, 0.69f, 1.0f))}, 177 | {0.6001f, add(dimmed(p.window, 0.825f), coeff(toBase(dimmed(p.highlight, 0.362f)), 1.0f, 0.815f, 1.0f))}, 178 | {1.0f, add(dimmed(p.window, 0.7125f), coeff(toBase(dimmed(p.highlight, 0.416f)), 1.0f, 0.924f, 1.0f))}}; 179 | 180 | params->TabSpecialHoverColor = {{0.0f, coeff(params->TabSpecialColor[0].value, 2.17f, 1.48f, 1.197f)}, 181 | {0.6f, coeff(params->TabSpecialColor[1].value, 0.653f, 1.218f, 1.286f)}, 182 | {0.6001f, coeff(params->TabSpecialColor[2].value, 1.69f, 1.326f, 1.191f)}, 183 | {1.0f, coeff(params->TabSpecialColor[3].value, 1.768f, 1.44f, 1.255f)}}; 184 | 185 | params->TabSpecialHoverBorderColor = 186 | params->TabSpecialBorderColor = add(dimmed(p.window, 0.729f), coeff(toBase(dimmed(p.highlight, 0.392f)), 1.0f, 0.66f, 1.0f)); 187 | params->TabSpecialHoverBorderColorSide = 188 | params->TabSpecialBorderColorSide = params->TabSpecialBorderColor; 189 | params->TabSpecialFontColor = p.htext; 190 | 191 | params->TabUnselectedHoverBorderColorTop = 192 | params->TabHoverBorderColorTop = QColor(255, 183, 0); 193 | 194 | params->TabUnselectedHoverBorderColorSide = 195 | params->TabHoverBorderColorSide = {{0.0f, params->BorderColor}, 196 | {0.3f, QColor(255, 183, 0)}, 197 | {1.0f, QColor(255, 183, 0)}}; 198 | 199 | params->TabUnselectedColor = add(dimmed(p.window, 0.02f), toBase(dimmed(vienna, 0.9264f))); 200 | 201 | params->TabSelectedColor = p.light; 202 | 203 | params->SeparatorColor = {{0.0f, Qt::transparent}, 204 | {0.075f, Qt::transparent}, 205 | {0.0751f, add(dimmed(p.window, 0.3125f), toBase(dimmed(vienna, 0.789f)))}, 206 | {0.925f, add(dimmed(p.window, 0.3125f), toBase(dimmed(vienna, 0.789f)))}, 207 | {0.9251f, Qt::transparent}, 208 | {1.0f, Qt::transparent}}; 209 | 210 | params->HorizontalFrameBackgroundColor = 211 | {{0.0f, add(dimmed(p.window, 0.033f), coeff(toBase(dimmed(vienna, 0.9362f)), 1.0f, 1.38f, 1.0f))}, 212 | {0.6f, add(dimmed(p.window, 0.05f), coeff(toBase(dimmed(vienna, 0.8333f)), 1.0f, 0.588f, 1.0f))}, 213 | {0.6001f, add(p.window, coeff(toBase(dimmed(vienna, 0.9166f)), 1.0f, 0.82f, 1.0f))}, 214 | {1.0f, p.light}}; 215 | 216 | params->HorizontalFrameBorderColor = params->BorderColor; 217 | params->HorizontalFrameBorderSize = 2; 218 | params->TabSpacing = 4; 219 | 220 | params->HideArrowColor = lcomb(p.text, p.light, 0.62f); 221 | return params; 222 | }); 223 | 224 | RegisterStyle(g_styleThreshold, [lcomb, dimmed, coeff]() 225 | { 226 | const TPalette p; 227 | StyleParams* params = new StyleParams(); 228 | 229 | params->UseTemplateSheet = true; 230 | params->AdditionalStyleSheet = ""; 231 | params->TabBorderRadius = 0; 232 | params->TabFontColor = p.text; 233 | params->ToolbarBackgroundColor = p.light; 234 | const float paneDimmCoeff = (p.window.lightnessF() > 0.5f ? 0.03529f : 0.1f); 235 | params->PaneColor = dimmed(p.light, paneDimmCoeff); 236 | const float borderDimmCoeff = (p.window.lightnessF() > 0.5f ? 0.15f : 0.3f); 237 | params->BorderColor = dimmed(params->ToolbarBackgroundColor, borderDimmCoeff); 238 | params->GroupNameColor = lcomb(p.text, p.light, 0.43f); 239 | 240 | params->TabSpecialColor = coeff(p.highlight, 0.5f, 0.8f, 0.8f); 241 | params->TabSpecialHoverColor = coeff(p.highlight, 0.8f, 0.9f, 0.88f); 242 | params->TabSpecialHoverBorderColor = 243 | params->TabSpecialBorderColor = params->TabSpecialColor; 244 | params->TabSpecialHoverBorderColorSide = 245 | params->TabSpecialBorderColorSide = params->TabSpecialColor; 246 | params->TabSpecialFontColor = p.htext; 247 | 248 | params->TabUnselectedHoverBorderColorTop = dimmed(params->PaneColor, 0.04f); 249 | params->TabHoverBorderColorTop = params->BorderColor; 250 | params->TabUnselectedHoverBorderColorSide = params->TabUnselectedHoverBorderColorTop; 251 | 252 | params->TabHoverBorderColorSide = params->BorderColor; 253 | 254 | const float unselectedDimmCoeff = (p.window.lightnessF() > 0.5f ? 0.008f : 0.1f); 255 | params->TabUnselectedColor = dimmed(params->ToolbarBackgroundColor, unselectedDimmCoeff); 256 | 257 | params->TabSelectedColor = params->PaneColor; 258 | 259 | params->SeparatorColor = {{0.0f, Qt::transparent}, 260 | {0.05f, Qt::transparent}, 261 | {0.051f, params->BorderColor}, 262 | {0.95f, params->BorderColor}, 263 | {0.951f, Qt::transparent}, 264 | {1.0f, Qt::transparent}}; 265 | 266 | params->HorizontalFrameBackgroundColor = Qt::transparent; 267 | params->HorizontalFrameBorderColor = Qt::transparent; 268 | params->HorizontalFrameBorderSize = 0; 269 | params->TabSpacing = 2; 270 | 271 | params->HideArrowColor = lcomb(p.text, p.light, 0.62f); 272 | return params; 273 | }); 274 | 275 | RegisterStyle("White Mercy", [dimmed]() 276 | { 277 | StyleParams* params = CreateStyle(g_styleThreshold).release(); 278 | params->TabUnselectedColor = params->PaneColor; 279 | params->PaneColor = params->ToolbarBackgroundColor; 280 | params->TabSelectedColor = params->PaneColor; 281 | params->BorderColor = dimmed(params->BorderColor, 0.1f); 282 | params->TabHoverBorderColorTop = params->BorderColor; 283 | params->TabHoverBorderColorSide = params->BorderColor; 284 | params->SeparatorColor = {{0.0f, Qt::transparent}, 285 | {0.05f, Qt::transparent}, 286 | {0.051f, params->BorderColor}, 287 | {0.95f, params->BorderColor}, 288 | {0.951f, Qt::transparent}, 289 | {1.0f, Qt::transparent}}; 290 | return params; 291 | }); 292 | } 293 | }; 294 | 295 | static DefaultStylesRegistrar g; 296 | } 297 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------