├── .gitignore ├── LICENSE ├── README.md ├── screenshots └── 1.png ├── snap ├── gui │ └── icon.png └── snapcraft.yaml ├── snap_launcher ├── bin │ ├── colorpie │ ├── desktop-launch │ └── qt.conf └── colorpie.desktop └── src ├── ColorPie.pro ├── breeze.qrc ├── dark.qss ├── dark ├── branch_closed-on.svg ├── branch_closed.svg ├── branch_open-on.svg ├── branch_open.svg ├── checkbox_checked.svg ├── checkbox_checked_disabled.svg ├── checkbox_indeterminate.svg ├── checkbox_indeterminate_disabled.svg ├── checkbox_unchecked.svg ├── checkbox_unchecked_disabled.svg ├── close-hover.svg ├── close-pressed.svg ├── close.svg ├── down_arrow-hover.svg ├── down_arrow.svg ├── down_arrow_disabled.svg ├── hmovetoolbar.svg ├── hsepartoolbar.svg ├── left_arrow.svg ├── left_arrow_disabled.svg ├── radio_checked.svg ├── radio_checked_disabled.svg ├── radio_unchecked.svg ├── radio_unchecked_disabled.svg ├── right_arrow.svg ├── right_arrow_disabled.svg ├── sizegrip.svg ├── spinup_disabled.svg ├── stylesheet-branch-end.svg ├── stylesheet-branch-more.svg ├── stylesheet-vline.svg ├── transparent.svg ├── undock-hover.svg ├── undock.svg ├── up_arrow-hover.svg ├── up_arrow.svg ├── up_arrow_disabled.svg ├── vmovetoolbar.svg └── vsepartoolbars.svg ├── elidedlabel.cpp ├── elidedlabel.h ├── html ├── favicon.ico ├── icon-128.png ├── icon-64.png ├── index.js ├── jquery-3.5.1.min.js ├── jtm │ ├── jquery.tinymodal.css │ └── jquery.tinymodal.js ├── texture.png ├── toastr │ ├── toastr.min.css │ └── toastr.min.js ├── v2.html └── v2 │ ├── app.0f8e8639.js │ ├── app.9d39357a.css │ ├── bootstrap.min.css │ └── chunk-vendors.4a7ab7d0.js ├── icons ├── icon-128.png ├── icon-16.png ├── icon-256.png ├── icon-32.png ├── icon-512.png ├── icon-64.png ├── others │ ├── close-fill.png │ ├── delete-bin-5-line.png │ ├── error-warning-line.png │ ├── eye-line.png │ ├── file-copy-line.png │ ├── file-text-line.png │ ├── file-unknow-line.png │ ├── folder-open-line.png │ ├── information-line.png │ ├── link-unlink-m.png │ ├── links-line.png │ ├── paypal-line.png │ └── star-line.png └── resize.sh ├── lib ├── color_widgets.pri ├── include │ └── QtColorWidgets │ │ ├── AbstractWidgetList │ │ ├── BoundColorSelector │ │ ├── CMakeLists.txt │ │ ├── ColorDelegate │ │ ├── ColorDialog │ │ ├── ColorListWidget │ │ ├── ColorPreview │ │ ├── ColorSelector │ │ ├── ColorWheel │ │ ├── GradientEditor │ │ ├── GradientListModel │ │ ├── GradientSlider │ │ ├── HarmonyColorWheel │ │ ├── HueSlider │ │ ├── abstract_widget_list.hpp │ │ ├── bound_color_selector.hpp │ │ ├── color_2d_slider.hpp │ │ ├── color_delegate.hpp │ │ ├── color_dialog.hpp │ │ ├── color_line_edit.hpp │ │ ├── color_list_widget.hpp │ │ ├── color_names.hpp │ │ ├── color_palette.hpp │ │ ├── color_palette_model.hpp │ │ ├── color_palette_widget.hpp │ │ ├── color_preview.hpp │ │ ├── color_selector.hpp │ │ ├── color_utils.hpp │ │ ├── color_wheel.hpp │ │ ├── color_wheel_private.hpp │ │ ├── colorwidgets_global.hpp │ │ ├── gradient_delegate.hpp │ │ ├── gradient_editor.hpp │ │ ├── gradient_helper.hpp │ │ ├── gradient_list_model.hpp │ │ ├── gradient_slider.hpp │ │ ├── harmony_color_wheel.hpp │ │ ├── hue_slider.hpp │ │ └── swatch.hpp ├── resources │ └── QtColorWidgets │ │ ├── CMakeLists.txt │ │ ├── alphaback.png │ │ ├── arrow-down-s-line.png │ │ ├── arrow-up-s-line.png │ │ ├── color_widgets.qrc │ │ ├── delete-bin-7-line.png │ │ ├── drop-fill.png │ │ └── drop-line.png └── src │ └── QtColorWidgets │ ├── CMakeLists.txt │ ├── abstract_widget_list.cpp │ ├── bound_color_selector.cpp │ ├── color_2d_slider.cpp │ ├── color_delegate.cpp │ ├── color_dialog.cpp │ ├── color_dialog.ui │ ├── color_line_edit.cpp │ ├── color_list_widget.cpp │ ├── color_names.cpp │ ├── color_palette.cpp │ ├── color_palette_model.cpp │ ├── color_palette_widget.cpp │ ├── color_palette_widget.ui │ ├── color_preview.cpp │ ├── color_selector.cpp │ ├── color_utils.cpp │ ├── color_wheel.cpp │ ├── gradient_editor.cpp │ ├── gradient_list_model.cpp │ ├── gradient_slider.cpp │ ├── harmony_color_wheel.cpp │ ├── hue_slider.cpp │ └── swatch.cpp ├── light.qss ├── light ├── branch_closed-on.svg ├── branch_closed.svg ├── branch_open-on.svg ├── branch_open.svg ├── checkbox_checked-hover.svg ├── checkbox_checked.svg ├── checkbox_checked_disabled.svg ├── checkbox_indeterminate-hover.svg ├── checkbox_indeterminate.svg ├── checkbox_indeterminate_disabled.svg ├── checkbox_unchecked-hover.svg ├── checkbox_unchecked_disabled.svg ├── close-hover.svg ├── close-pressed.svg ├── close.svg ├── down_arrow-hover.svg ├── down_arrow.svg ├── down_arrow_disabled.svg ├── hmovetoolbar.svg ├── hsepartoolbar.svg ├── left_arrow.svg ├── left_arrow_disabled.svg ├── radio_checked-hover.svg ├── radio_checked.svg ├── radio_checked_disabled.svg ├── radio_unchecked-hover.svg ├── radio_unchecked_disabled.svg ├── right_arrow.svg ├── right_arrow_disabled.svg ├── sizegrip.svg ├── spinup_disabled.svg ├── stylesheet-branch-end.svg ├── stylesheet-branch-more.svg ├── stylesheet-vline.svg ├── transparent.svg ├── undock-hover.svg ├── undock.svg ├── up_arrow-hover.svg ├── up_arrow.svg ├── up_arrow_disabled.svg ├── vmovetoolbar.svg └── vsepartoolbars.svg ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── manager.cpp ├── manager.h ├── manager.ui ├── resources.qrc ├── supportedinputs.cpp ├── supportedinputs.h ├── supportedinputs.ui ├── utils.cpp └── utils.h /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.so.* 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | object_script.*.Release 15 | object_script.*.Debug 16 | *_plugin_import.cpp 17 | /.qmake.cache 18 | /.qmake.stash 19 | *.pro.user 20 | *.pro.user.* 21 | *.qbs.user 22 | *.qbs.user.* 23 | *.moc 24 | moc_*.cpp 25 | moc_*.h 26 | qrc_*.cpp 27 | ui_*.h 28 | *.qmlc 29 | *.jsc 30 | Makefile* 31 | *build-* 32 | *.qm 33 | *.prl 34 | 35 | # Qt unit tests 36 | target_wrapper.* 37 | 38 | # QtCreator 39 | *.autosave 40 | 41 | # QtCreator Qml 42 | *.qmlproject.user 43 | *.qmlproject.user.* 44 | 45 | # QtCreator CMake 46 | CMakeLists.txt.user* 47 | 48 | # QtCreator 4.8< compilation database 49 | compile_commands.json 50 | 51 | # QtCreator local machine specific files for imported projects 52 | *creator.user* 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Keshav Bhatt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorPie 2 | ColorPie is professional color management utility written in Qt 3 | 4 | ## Screenshot 5 | ![ColorPie Application for Linux Desktop](https://github.com/keshavbhatt/ColorPie/blob/main/screenshots/1.png?raw=true) 6 | 7 | More updates and features coming soon. 8 | -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/screenshots/1.png -------------------------------------------------------------------------------- /snap/gui/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/snap/gui/icon.png -------------------------------------------------------------------------------- /snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: colorpie 2 | version: '1' 3 | summary: Color Picker and Converter 4 | description: | 5 | ColorPie is professional color management utility written in Qt. 6 | 7 | grade: stable 8 | confinement: strict 9 | icon: snap/gui/icon.png 10 | base: core18 11 | 12 | architectures: 13 | - build-on: amd64 14 | run-on: amd64 15 | 16 | apps: 17 | colorpie: 18 | command: desktop-launch colorpie 19 | environment: 20 | DISABLE_WAYLAND: 1 21 | QT_QPA_PLATFORMTHEME: gtk3 22 | desktop: usr/share/applications/colorpie.desktop 23 | plugs: 24 | - browser-support 25 | - desktop 26 | - desktop-legacy 27 | - gsettings 28 | - home 29 | - opengl 30 | - removable-media 31 | - unity7 32 | - x11 33 | - mount-observe 34 | - network 35 | - network-control 36 | - network-observe 37 | - network-bind 38 | - wayland 39 | plugs: 40 | gtk-3-themes: 41 | interface: content 42 | target: $SNAP/data-dir/themes 43 | default-provider: gtk-common-themes 44 | icon-themes: 45 | interface: content 46 | target: $SNAP/data-dir/icons 47 | default-provider: gtk-common-themes 48 | sound-themes: 49 | interface: content 50 | target: $SNAP/data-dir/sounds 51 | default-provider: gtk-common-themes 52 | qt513: 53 | interface: content 54 | target: $SNAP/qt513 55 | default-provider: qt513 56 | 57 | parts: 58 | snap-launcher: 59 | plugin: dump 60 | source: snap_launcher/ 61 | override-build: | 62 | snapcraftctl build 63 | sed -i 's|Icon=.*|Icon=${SNAP}/meta/gui/icon.png|g' ${SNAPCRAFT_PART_SRC}/colorpie.desktop 64 | 65 | mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/ 66 | cp -rf ${SNAPCRAFT_PART_SRC}/colorpie.desktop ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/colorpie.desktop 67 | -------------------------------------------------------------------------------- /snap_launcher/bin/colorpie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/snap_launcher/bin/colorpie -------------------------------------------------------------------------------- /snap_launcher/bin/qt.conf: -------------------------------------------------------------------------------- 1 | [Paths] 2 | Prefix= ../qt513/usr/ 3 | Libraries= lib 4 | Plugins= plugins 5 | Imports= qml 6 | Translations= translations 7 | Qml2Imports= qml 8 | -------------------------------------------------------------------------------- /snap_launcher/colorpie.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | GenericName=ColorPie 4 | Name=ColorPie 5 | Type=Application 6 | Icon=${SNAP}/meta/gui/icon.png 7 | Keywords=Color Picker;converter;gcolor;color;colour 8 | Exec=colorpie %F 9 | Categories=Utility;Qt; 10 | Terminal=false 11 | Name[en_US]=ColorPie 12 | -------------------------------------------------------------------------------- /src/ColorPie.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2020-10-11T12:31:24 4 | # 5 | #------------------------------------------------- 6 | 7 | requires(qtHaveModule(httpserver)) 8 | 9 | QT += core gui webengine webenginewidgets xml httpserver 10 | 11 | CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT 12 | 13 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 14 | 15 | TARGET = colorpie 16 | TEMPLATE = app 17 | 18 | # The following define makes your compiler emit warnings if you use 19 | # any feature of Qt which has been marked as deprecated (the exact warnings 20 | # depend on your compiler). Please consult the documentation of the 21 | # deprecated API in order to know how to port your code away from it. 22 | DEFINES += QT_DEPRECATED_WARNINGS 23 | 24 | # You can also make your code fail to compile if you use deprecated APIs. 25 | # In order to do so, uncomment the following line. 26 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 27 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 28 | 29 | CONFIG += c++11 30 | 31 | include(lib/color_widgets.pri) 32 | 33 | SOURCES += \ 34 | elidedlabel.cpp \ 35 | main.cpp \ 36 | mainwindow.cpp \ 37 | manager.cpp \ 38 | supportedinputs.cpp \ 39 | utils.cpp 40 | 41 | HEADERS += \ 42 | elidedlabel.h \ 43 | mainwindow.h \ 44 | manager.h \ 45 | supportedinputs.h \ 46 | utils.h 47 | 48 | FORMS += \ 49 | mainwindow.ui \ 50 | manager.ui \ 51 | supportedinputs.ui 52 | 53 | # Default rules for deployment. 54 | qnx: target.path = /tmp/$${TARGET}/bin 55 | else: unix:!android: target.path = /opt/$${TARGET}/bin 56 | !isEmpty(target.path): INSTALLS += target 57 | 58 | RESOURCES += \ 59 | breeze.qrc \ 60 | resources.qrc 61 | -------------------------------------------------------------------------------- /src/breeze.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | light/hmovetoolbar.svg 4 | light/vmovetoolbar.svg 5 | light/hsepartoolbar.svg 6 | light/vsepartoolbars.svg 7 | light/stylesheet-branch-end.svg 8 | light/stylesheet-vline.svg 9 | light/stylesheet-branch-more.svg 10 | light/branch_closed.svg 11 | light/branch_closed-on.svg 12 | light/branch_open.svg 13 | light/branch_open-on.svg 14 | light/down_arrow.svg 15 | light/down_arrow_disabled.svg 16 | light/down_arrow-hover.svg 17 | light/left_arrow.svg 18 | light/left_arrow_disabled.svg 19 | light/right_arrow.svg 20 | light/right_arrow_disabled.svg 21 | light/up_arrow.svg 22 | light/up_arrow_disabled.svg 23 | light/up_arrow-hover.svg 24 | light/sizegrip.svg 25 | light/transparent.svg 26 | light/close.svg 27 | light/close-hover.svg 28 | light/close-pressed.svg 29 | light/undock.svg 30 | light/undock-hover.svg 31 | light/checkbox_checked-hover.svg 32 | light/checkbox_checked.svg 33 | light/checkbox_checked_disabled.svg 34 | light/checkbox_indeterminate.svg 35 | light/checkbox_indeterminate-hover.svg 36 | light/checkbox_indeterminate_disabled.svg 37 | light/checkbox_unchecked-hover.svg 38 | light/checkbox_unchecked_disabled.svg 39 | light/radio_checked-hover.svg 40 | light/radio_checked.svg 41 | light/radio_checked_disabled.svg 42 | light/radio_unchecked-hover.svg 43 | light/radio_unchecked_disabled.svg 44 | dark/hmovetoolbar.svg 45 | dark/vmovetoolbar.svg 46 | dark/hsepartoolbar.svg 47 | dark/vsepartoolbars.svg 48 | dark/stylesheet-branch-end.svg 49 | dark/stylesheet-vline.svg 50 | dark/stylesheet-branch-more.svg 51 | dark/branch_closed.svg 52 | dark/branch_closed-on.svg 53 | dark/branch_open.svg 54 | dark/branch_open-on.svg 55 | dark/down_arrow.svg 56 | dark/down_arrow_disabled.svg 57 | dark/down_arrow-hover.svg 58 | dark/left_arrow.svg 59 | dark/left_arrow_disabled.svg 60 | dark/right_arrow.svg 61 | dark/right_arrow_disabled.svg 62 | dark/up_arrow.svg 63 | dark/up_arrow_disabled.svg 64 | dark/up_arrow-hover.svg 65 | dark/sizegrip.svg 66 | dark/transparent.svg 67 | dark/close.svg 68 | dark/close-hover.svg 69 | dark/close-pressed.svg 70 | dark/undock.svg 71 | dark/undock-hover.svg 72 | dark/checkbox_checked.svg 73 | dark/checkbox_checked_disabled.svg 74 | dark/checkbox_indeterminate.svg 75 | dark/checkbox_indeterminate_disabled.svg 76 | dark/checkbox_unchecked.svg 77 | dark/checkbox_unchecked_disabled.svg 78 | dark/radio_checked.svg 79 | dark/radio_checked_disabled.svg 80 | dark/radio_unchecked.svg 81 | dark/radio_unchecked_disabled.svg 82 | light.qss 83 | dark.qss 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/dark/branch_closed-on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/branch_closed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/branch_open-on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/branch_open.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/checkbox_checked.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/checkbox_checked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/dark/checkbox_indeterminate.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/checkbox_indeterminate_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/dark/checkbox_unchecked.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/checkbox_unchecked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/dark/close-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/close-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/down_arrow-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/down_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/down_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/hmovetoolbar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/dark/hsepartoolbar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/left_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/left_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/radio_checked.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/radio_checked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/dark/radio_unchecked.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/radio_unchecked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/dark/right_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/right_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/sizegrip.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/spinup_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/stylesheet-branch-end.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/dark/stylesheet-branch-more.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/dark/stylesheet-vline.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/transparent.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/dark/undock-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/dark/undock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/up_arrow-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml -------------------------------------------------------------------------------- /src/dark/up_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/up_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/dark/vmovetoolbar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/dark/vsepartoolbars.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/elidedlabel.cpp: -------------------------------------------------------------------------------- 1 | #include "elidedlabel.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | ElidedLabel::ElidedLabel(QWidget* parent, Qt::WindowFlags f) 9 | : QLabel(parent, f), m_elide_mode(Qt::ElideRight) { 10 | setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); 11 | } 12 | 13 | ElidedLabel::ElidedLabel(const QString& txt, QWidget* parent, Qt::WindowFlags f) 14 | : QLabel(txt, parent, f), m_elide_mode(Qt::ElideRight) { 15 | setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); 16 | } 17 | 18 | ElidedLabel::ElidedLabel(const QString& txt, Qt::TextElideMode elideMode, QWidget* parent, Qt::WindowFlags f) 19 | : QLabel(txt, parent, f), m_elide_mode(elideMode) { 20 | setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); 21 | 22 | } 23 | 24 | void ElidedLabel::setText(const QString& txt) { 25 | QLabel::setText(txt); 26 | cacheElidedText(geometry().width()); 27 | setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); 28 | } 29 | 30 | 31 | void ElidedLabel::cacheElidedText(int w) { 32 | m_cached_elided_text = fontMetrics().elidedText(text(), m_elide_mode, w, (buddy() == nullptr)? 0 : Qt::TextShowMnemonic); 33 | } 34 | 35 | void ElidedLabel::resizeEvent(QResizeEvent* e) { 36 | QLabel::resizeEvent(e); 37 | cacheElidedText(e->size().width()); 38 | } 39 | 40 | void ElidedLabel::paintEvent(QPaintEvent* e) { 41 | if(m_elide_mode == Qt::ElideNone) { 42 | QLabel::paintEvent(e); 43 | } else { 44 | QPainter p(this); 45 | p.drawText(0, 0, geometry().width(), geometry().height(), 46 | QStyle::visualAlignment(text().isRightToLeft()? Qt::RightToLeft : Qt::LeftToRight, alignment()) | ((buddy() == nullptr)? 0 : Qt::TextShowMnemonic), 47 | m_cached_elided_text); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/elidedlabel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // A label that elides its text when not enough geometry is available to show all of the text. 9 | // Currently only capable of one-line. 10 | class ElidedLabel : public QLabel { 11 | Q_OBJECT 12 | 13 | private: 14 | Qt::TextElideMode m_elide_mode; 15 | QString m_cached_elided_text; 16 | 17 | 18 | public: 19 | ElidedLabel(QWidget* parent = NULL, Qt::WindowFlags f = 0); 20 | ElidedLabel(const QString& txt, QWidget* parent = NULL, Qt::WindowFlags f = 0); 21 | ElidedLabel(const QString& txt, Qt::TextElideMode elideMode = Qt::ElideRight, QWidget* parent = NULL, Qt::WindowFlags f = 0); 22 | 23 | public: 24 | // Set the elide mode used for displaying text. 25 | inline void setElideMode(Qt::TextElideMode elideMode) { 26 | m_elide_mode = elideMode; 27 | updateGeometry(); 28 | } 29 | 30 | // Get the elide mode currently used to display text. 31 | inline Qt::TextElideMode elideMode() const { 32 | return m_elide_mode; 33 | } 34 | 35 | 36 | 37 | public: // QLabel overrides 38 | void setText(const QString&); // note: not virtual so no polymorphism ... 39 | 40 | 41 | protected: // QLabel overrides 42 | virtual void paintEvent(QPaintEvent*) override; 43 | virtual void resizeEvent(QResizeEvent*) override; 44 | 45 | protected: 46 | // Cache the elided text so as to not recompute it every paint event 47 | void cacheElidedText(int w); 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /src/html/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/html/favicon.ico -------------------------------------------------------------------------------- /src/html/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/html/icon-128.png -------------------------------------------------------------------------------- /src/html/icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/html/icon-64.png -------------------------------------------------------------------------------- /src/html/index.js: -------------------------------------------------------------------------------- 1 | toastr.options = { 2 | "progressBar": true, 3 | "closeButton": true, 4 | "debug": false, 5 | "newestOnTop": false, 6 | "positionClass": "toast-bottom-right", 7 | "preventDuplicates": true, 8 | "onclick": null, 9 | "showDuration": "200", 10 | "hideDuration": "1000", 11 | "timeOut": "5000", 12 | "extendedTimeOut": "1000", 13 | "showEasing": "swing", 14 | "hideEasing": "linear", 15 | "showMethod": "fadeIn", 16 | "hideMethod": "fadeOut" 17 | } 18 | 19 | function definitionCopied(){ 20 | toastr["success"]("Definition copied to clipboard.", "Clipboard") 21 | } 22 | 23 | function about(){ 24 | $.tinyModal({ 25 | title: 'About', 26 | html: '#about' 27 | }); 28 | } 29 | 30 | 31 | function simulateMouseClick(targetNode) { 32 | function triggerMouseEvent(targetNode, eventType) { 33 | var clickEvent = document.createEvent('MouseEvents'); 34 | clickEvent.initEvent(eventType, true, true); 35 | targetNode.dispatchEvent(clickEvent); 36 | } 37 | ["mouseover", "mousedown", "mouseup", "click"].forEach(function(eventType) { 38 | triggerMouseEvent(targetNode, eventType); 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /src/html/jtm/jquery.tinymodal.css: -------------------------------------------------------------------------------- 1 | *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box} 2 | .tinymodal-overlay{position:fixed;width:100%;height:100%;top:0;left:0;z-index:9999;background: rgba(0, 0, 0, 0.47);} 3 | .tinymodal-window{position:absolute;width:400px;top:10%;left:50%;-webkit-box-shadow:0 0 6px rgba(0,0,0,0.3),0 6px 30px rgba(0,0,0,0.25);box-shadow:0 0 6px rgba(0,0,0,0.3),0 6px 30px rgba(0,0,0,0.25);} 4 | .tinymodal-title{position:relative;padding:6.666666666666668px 25px;font-size:100%;font-weight:bold;text-shadow:0 1px rgba(0,0,0,0.7);color:#fbfbfb; background: linear-gradient(to bottom, #712001 5%, #E05A09 100%);-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px;} 5 | .tinymodal-close{position:absolute;top:50%;right:.5em;margin-top:-.5em;font-size:150%;line-height:1;cursor:pointer} 6 | .tinymodal-content{padding:25px;background-image: url(../texture.png);background-color: #1a1a1a;} 7 | .tinymodal-content{max-height:420px;overflow-y:auto} 8 | .tinymodal-buttons{padding:1.6px; background: linear-gradient(to bottom, #712001 5%, #E05A09 100%);-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;} 9 | .tinymodal-buttons:before,.tinymodal-buttons:after{content:"";display:table} 10 | .tinymodal-buttons:after{clear:both} 11 | .tinymodal-buttons .inner{float:right} 12 | .tinymodal-buttons button{margin-left:.5em;padding:.6em 1.25em;border:0;line-height:1;color:#fbfbfb;font-weight:bold;text-shadow:0 1px rgba(0,0,0,0.7); background: linear-gradient(to bottom, #712001 5%, #74350F 100%);-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 1px rgba(255,255,255,0.45);box-shadow:inset 0 1px rgba(255,255,255,0.45)} 13 | -------------------------------------------------------------------------------- /src/html/jtm/jquery.tinymodal.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery Tiny Modal 3 | * @author: Cedric Ruiz 4 | * https://github.com/elclanrs/jquery.tiny.modal 5 | */ 6 | (function($) { 7 | 8 | var _defaults = { 9 | buttons: [], 10 | title: 'Alert', 11 | html: '

Alert

', 12 | Ok: $.noop, 13 | Cancel: $.noop, 14 | onOpen: $.noop, 15 | onClose: $.noop, 16 | clickOutside: true 17 | }; 18 | 19 | $.tinyModal = function(opts) { 20 | 21 | var o = $.extend({}, _defaults, opts), 22 | $overlay = $('
').hide(), 23 | $modal = $('
\ 24 |
'+ o.title +'
×
\ 25 |
\ 26 |
\ 27 |
').hide(), 28 | $el = $(o.html) 29 | $children = $el.children(); 30 | 31 | $modal.find('.tinymodal-content').append($children); 32 | 33 | if (o.buttons.length) { 34 | $modal.find('.inner').append(''); 35 | } 36 | 37 | function show() { 38 | $('body').width($('body').width()).css('overflow', 'hidden'); 39 | $overlay.fadeIn('fast', function() { 40 | $modal.fadeIn('fast', o.onOpen); 41 | }); 42 | $modal.css({ 43 | marginLeft: -($modal.width()/2) +'px', 44 | }); 45 | } 46 | 47 | function hide(callback) { 48 | $modal.fadeOut('fast', function() { 49 | $('body').css({ width: 'auto', overflow: 'auto' }); 50 | $overlay.fadeOut('fast'); 51 | if (typeof callback == 'function') callback(); 52 | $el.append($children); 53 | }); 54 | } 55 | 56 | $modal.find('.tinymodal-buttons button, .tinymodal-close').on('click', function(e) { 57 | var callback = $(this).text(); 58 | hide(o[callback]); 59 | }); 60 | 61 | $modal.find('.tinymodal-close').click(o.onClose); 62 | 63 | $tip = $modal.find('.tip'); 64 | $tip.on('click',function(e){ 65 | hide(); 66 | // $hash = $(this).attr('href'); 67 | // window.location.hash = $hash; 68 | // window.location.reload(); 69 | }); 70 | 71 | $modal.on('click', function(e){ e.stopPropagation(); }); 72 | 73 | if (o.clickOutside) $overlay.on('click', hide); 74 | 75 | $('body').prepend($overlay.append($modal)); 76 | show(); 77 | }; 78 | 79 | }(jQuery)); 80 | -------------------------------------------------------------------------------- /src/html/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/html/texture.png -------------------------------------------------------------------------------- /src/html/toastr/toastr.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Note that this is toastr v2.1.3, the "latest" version in url has no more maintenance, 3 | * please go to https://cdnjs.com/libraries/toastr.js and pick a certain version you want to use, 4 | * make sure you copy the url from the website since the url may change between versions. 5 | * */ 6 | !function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return g({type:O.error,iconClass:m().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=m()),v=e("#"+t.containerId),v.length?v:(n&&(v=d(t)),v)}function o(e,t,n){return g({type:O.info,iconClass:m().iconClasses.info,message:e,optionsOverride:n,title:t})}function s(e){C=e}function i(e,t,n){return g({type:O.success,iconClass:m().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return g({type:O.warning,iconClass:m().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e,t){var o=m();v||n(o),u(e,o,t)||l(o)}function c(t){var o=m();return v||n(o),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function l(t){for(var n=v.children(),o=n.length-1;o>=0;o--)u(e(n[o]),t)}function u(t,n,o){var s=!(!o||!o.force)&&o.force;return!(!t||!s&&0!==e(":focus",t).length)&&(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0)}function d(t){return v=e("
").attr("id",t.containerId).addClass(t.positionClass),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'',closeClass:"toast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"toast-progress",rtl:!1}}function f(e){C&&C(e)}function g(t){function o(e){return null==e&&(e=""),e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function s(){c(),u(),d(),p(),g(),C(),l(),i()}function i(){var e="";switch(t.iconClass){case"toast-success":case"toast-info":e="polite";break;default:e="assertive"}I.attr("aria-live",e)}function a(){E.closeOnHover&&I.hover(H,D),!E.onclick&&E.tapToDismiss&&I.click(b),E.closeButton&&j&&j.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),E.onCloseClick&&E.onCloseClick(e),b(!0)}),E.onclick&&I.click(function(e){E.onclick(e),b()})}function r(){I.hide(),I[E.showMethod]({duration:E.showDuration,easing:E.showEasing,complete:E.onShown}),E.timeOut>0&&(k=setTimeout(b,E.timeOut),F.maxHideTime=parseFloat(E.timeOut),F.hideEta=(new Date).getTime()+F.maxHideTime,E.progressBar&&(F.intervalId=setInterval(x,10)))}function c(){t.iconClass&&I.addClass(E.toastClass).addClass(y)}function l(){E.newestOnTop?v.prepend(I):v.append(I)}function u(){if(t.title){var e=t.title;E.escapeHtml&&(e=o(t.title)),M.append(e).addClass(E.titleClass),I.append(M)}}function d(){if(t.message){var e=t.message;E.escapeHtml&&(e=o(t.message)),B.append(e).addClass(E.messageClass),I.append(B)}}function p(){E.closeButton&&(j.addClass(E.closeClass).attr("role","button"),I.prepend(j))}function g(){E.progressBar&&(q.addClass(E.progressClass),I.prepend(q))}function C(){E.rtl&&I.addClass("rtl")}function O(e,t){if(e.preventDuplicates){if(t.message===w)return!0;w=t.message}return!1}function b(t){var n=t&&E.closeMethod!==!1?E.closeMethod:E.hideMethod,o=t&&E.closeDuration!==!1?E.closeDuration:E.hideDuration,s=t&&E.closeEasing!==!1?E.closeEasing:E.hideEasing;if(!e(":focus",I).length||t)return clearTimeout(F.intervalId),I[n]({duration:o,easing:s,complete:function(){h(I),clearTimeout(k),E.onHidden&&"hidden"!==P.state&&E.onHidden(),P.state="hidden",P.endTime=new Date,f(P)}})}function D(){(E.timeOut>0||E.extendedTimeOut>0)&&(k=setTimeout(b,E.extendedTimeOut),F.maxHideTime=parseFloat(E.extendedTimeOut),F.hideEta=(new Date).getTime()+F.maxHideTime)}function H(){clearTimeout(k),F.hideEta=0,I.stop(!0,!0)[E.showMethod]({duration:E.showDuration,easing:E.showEasing})}function x(){var e=(F.hideEta-(new Date).getTime())/F.maxHideTime*100;q.width(e+"%")}var E=m(),y=t.iconClass||E.iconClass;if("undefined"!=typeof t.optionsOverride&&(E=e.extend(E,t.optionsOverride),y=t.optionsOverride.iconClass||y),!O(E,t)){T++,v=n(E,!0);var k=null,I=e("
"),M=e("
"),B=e("
"),q=e("
"),j=e(E.closeHtml),F={intervalId:null,hideEta:null,maxHideTime:null},P={toastId:T,state:"visible",startTime:new Date,options:E,map:t};return s(),r(),a(),f(P),E.debug&&console&&console.log(P),I}}function m(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),w=void 0))}var v,C,w,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:c,error:t,getContainer:n,info:o,options:{},subscribe:s,success:i,version:"2.1.3",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)}); 7 | //# sourceMappingURL=toastr.js.map 8 | -------------------------------------------------------------------------------- /src/html/v2.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | -------------------------------------------------------------------------------- /src/html/v2/app.0f8e8639.js: -------------------------------------------------------------------------------- 1 | (function(t){function o(o){for(var r,s,l=o[0],a=o[1],c=o[2],p=0,f=[];p20},style:{"background-color":"#"+t.inputColor.hex6},attrs:{id:"color-line"}},[t.isFalse?t._e():e("p",[t._v("#"+t._s(t.inputColor.hex6))]),t.isFalse?e("h2",{attrs:{id:"list-detect"}},[t._v(" No color identified ")]):e("h2",[t._v(t._s(t.OuterColor["format"])+": "+t._s(t.OuterColor["color"]))])]),t._m(0),t._l(Object.keys(t.inputColor),(function(o){return e("div",{key:o,staticClass:"color-element",attrs:{id:"list-"+o}},[e("div",{staticClass:"input-group"},["html"==o?e("div",{staticClass:"color-line",class:{hidden:t.isFalse},style:{"background-color":t.OuterColor.htmlref}}):t._e(),e("div",{staticClass:"input-group mb-3 input-group-sm"},[e("span",{staticClass:"input-group-text"},[t._v(t._s(o))]),e("input",{staticClass:"form-control",attrs:{type:"text",id:o,autocomplete:"off"},domProps:{value:t.inputFormat(t.inputColor[o])},on:{keyup:function(o){return t.inputUpdate(o)}}})]),e("p","color"==o?[t._v(" dotColor = { sanitized:"+t._s(t.formatColor(t.OuterColor["color"]))+" , format:"+t._s(t.formatColor(t.OuterColor["format"]))+" } ")]:[t._v("dotColor."+t._s(o)+"="+t._s(t.formatColor(t.OuterColor[o])))])])])})),e("h1",[t._v(t._s(t.OuterColor.invert))])],2)},l=[function(){var t=this,o=t.$createElement,e=t._self._c||o;return e("div",{staticClass:"color-element color-title"},[e("h1",[t._v("[apptitle] "),e("a",{attrs:{href:""}},[e("span",{staticClass:"badge bg-danger badge-super"},[t._v("NPM")])])])])}],a=(e("4de4"),e("d3b7"),e("ac1f"),e("5319"),e("ddb0"),e("b85c")),c=e("53ca"),u=e("1e72"),p=e.n(u),f=e("c603"),d=e.n(f),h=new d.a("#00a"),v=(new p.a).keys,m={name:"colorTest",data:function(){return{inputColor:{hex6:"#00a",color:"#00a"},OuterColor:h,isFalse:!1}},methods:{formatColor:function(t){return!!t&&("string"===typeof t?'"'+t+'"':t)},inputFormat:function(t){return"object"===Object(c["a"])(t)?JSON.stringify(t).replace(/"|{|}|/g,"").replace(/,/g,", ").replace(/:/g,": "):t},updateColors:function(t){var o,e=Object(a["a"])(v);try{for(e.s();!(o=e.n()).done;){var r=o.value;this.inputColor[r]=h[r]}}catch(n){e.e(n)}finally{e.f()}"color"!==t&&(this.inputColor.color=t),document.title=this.OuterColor.sanitizedColor+" | "+this.OuterColor.format+ (this.OuterColor.format!="hex6"?" >> "+this.OuterColor.hex6:"")},falseUpdate:function(t){var o,e=Object(a["a"])(v.filter((function(o){return o!==t})));try{for(e.s();!(o=e.n()).done;){var r=o.value;this.inputColor[r]=""}}catch(n){e.e(n)}finally{e.f()}"color"!==t&&(this.inputColor.color=""),document.title="No color identified"},inputUpdate:function(t){var o=t.target.id,e=t.target.value;h[o]=e,h[o]?(this.updateColors(e),this.inputColor[o]=e,this.isFalse=!1):(this.falseUpdate(o),this.inputColor[o]=e,this.isFalse=!0)}},mounted:function(){this.updateColors(this.inputColor.color)}},b=m,C=(e("1077"),e("2877")),g=Object(C["a"])(b,s,l,!1,null,null,null),y=g.exports,_={name:"App",components:{colorView:y}},O=_,w=(e("034f"),Object(C["a"])(O,n,i,!1,null,null,null)),j=w.exports;r["a"].config.productionTip=!1,new r["a"]({render:function(t){return t(j)}}).$mount("#app")},"85ec":function(t,o,e){},c11e:function(t,o,e){}}); 2 | -------------------------------------------------------------------------------- /src/html/v2/app.9d39357a.css: -------------------------------------------------------------------------------- 1 | .color-element p{display:none !important;} .color-element:nth-child(2):not(:last-child){padding-top:0px !important;} #list-color{display:none !important} .color-element:not(:last-child){padding-top:10px ;padding-bottom: 0px !important;} .color-element h1{display:none !important;} .hidden{opacity:0}.badge-super{vertical-align:super;font-size:30%;transform:translateY(-10px)}#color-box{display:grid;padding-left:400px}@media screen and (max-width:800px){#color-box{padding-left:0}}.input-group{margin-bottom:0!important}.color-title{padding-top:50px;padding-bottom:50px}#color-line{min-height:200px;padding:50px;color:#000;position:fixed;left:0;top:0;bottom:0;width:400px;box-sizing:border-box}#color-line,#color-line h2{font-weight:bold}#color-line.light{color:#fff}#color-line p{margin-bottom:0}@media screen and (max-width:800px){#color-line{position:static;width:100%;margin-bottom:0px}}.color-false{background-color:#d3d3d3!important}.color-element{padding-left:10px;padding-right:10px}.color-element p{margin-top:5px;margin-bottom:5px;width:100%;text-align:right;opacity:.2}.color-element:hover p{opacity:1}.color-element.color-title p{text-align:left;opacity:1}#list-color{grid-row:2;padding-bottom:50px}@media screen and (max-width:800px){#list-color{grid-row:3}}#list-color .input-group{opacity:1}#list-color .input-group input,#list-color .input-group span{font-size:1.5rem;padding:.5rem 1rem}body{background-color:#eff0f1; margin:0} 2 | -------------------------------------------------------------------------------- /src/icons/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/icon-128.png -------------------------------------------------------------------------------- /src/icons/icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/icon-16.png -------------------------------------------------------------------------------- /src/icons/icon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/icon-256.png -------------------------------------------------------------------------------- /src/icons/icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/icon-32.png -------------------------------------------------------------------------------- /src/icons/icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/icon-512.png -------------------------------------------------------------------------------- /src/icons/icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/icon-64.png -------------------------------------------------------------------------------- /src/icons/others/close-fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/close-fill.png -------------------------------------------------------------------------------- /src/icons/others/delete-bin-5-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/delete-bin-5-line.png -------------------------------------------------------------------------------- /src/icons/others/error-warning-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/error-warning-line.png -------------------------------------------------------------------------------- /src/icons/others/eye-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/eye-line.png -------------------------------------------------------------------------------- /src/icons/others/file-copy-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/file-copy-line.png -------------------------------------------------------------------------------- /src/icons/others/file-text-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/file-text-line.png -------------------------------------------------------------------------------- /src/icons/others/file-unknow-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/file-unknow-line.png -------------------------------------------------------------------------------- /src/icons/others/folder-open-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/folder-open-line.png -------------------------------------------------------------------------------- /src/icons/others/information-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/information-line.png -------------------------------------------------------------------------------- /src/icons/others/link-unlink-m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/link-unlink-m.png -------------------------------------------------------------------------------- /src/icons/others/links-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/links-line.png -------------------------------------------------------------------------------- /src/icons/others/paypal-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/paypal-line.png -------------------------------------------------------------------------------- /src/icons/others/star-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/icons/others/star-line.png -------------------------------------------------------------------------------- /src/icons/resize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Edit the settings below: 4 | 5 | # Output sizes - 6 | # Please note the format: each size is wrapped with quotes, width and height are separated with space. 7 | output=("16 16" "32 32" "64 64" "128 128" "512 512" ) 8 | 9 | # If you frequently use the same source file (f.e. "~/Desktop/src.jpg"), 10 | # set it in "default_src" 11 | default_src=""; 12 | 13 | # If you frequently use the same destination 14 | # (f.e. "~/Desktop/Some_folder/%.jpg"), set it in "default_dst" 15 | # Destination must include "%", it will be replaced by output size, f.e. "800x600" 16 | default_dst="%.png"; 17 | 18 | # Add signature? 19 | default_sign='n' 20 | 21 | # If you frequently use the same signature file (f.e. "~/Desktop/sig.png"), 22 | # set it in "default_sig" 23 | default_sig=""; 24 | 25 | # Gravity is for cropping left/right edges for different proportions (center, east, west) 26 | default_gravity="center" 27 | 28 | # Output JPG quality: maximum is 100 (recommended) 29 | quality=100 30 | 31 | # ====== 32 | # Do not edit below. 33 | # ====== 34 | # Welcome to Smashing resizer! 35 | # Written by Vlad Gerasimov from http://www.vladstudio.com 36 | # 37 | # This script takes one "source" image and saves it in different sizes. 38 | # 39 | # Requires: 40 | # * imagemagick - http://www.imagemagick.org/ 41 | # * python - I'm sure your PC already has it! 42 | 43 | 44 | 45 | # Unfortunately, bash is awful at math operations. 46 | # We'll create a simple function that handles math for us. 47 | # Example: $(math 2 * 2) 48 | 49 | function math(){ 50 | echo $(python -c "from __future__ import division; print $@") 51 | } 52 | 53 | 54 | 55 | # To make our script short and nice, here is the "save()" function. 56 | # We'll use it to save each size. 57 | 58 | function save(){ 59 | 60 | # read target width and height from function parameters 61 | local dst_w=${1} 62 | local dst_h=${2} 63 | 64 | # calculate ratio 65 | local ratio=$(math $dst_w/$dst_h); 66 | 67 | # calculate "intermediate" width and height 68 | local inter_w=$(math "int(round($src_h*$ratio))") 69 | local inter_h=${src_h} 70 | 71 | # which size we're saving now 72 | #local size="${dst_w}x${dst_h}" 73 | local size="${dst_w}" 74 | echo "Saving ${size}..." 75 | 76 | #crop intermediate image (with target ratio) 77 | convert ${src} -gravity ${gravity} -crop ${inter_w}x${inter_h}+0+0 +repage temp.psd 78 | 79 | # apply signature 80 | if [ "${sign}" == "y" ]; then 81 | convert temp.psd ${sig} -gravity southeast -geometry ${sig_w}x${sig_h}+24+48 -composite temp.psd 82 | fi 83 | 84 | ## For best quality, I resize image 80%, sharpen 3 times, then repeat. 85 | 86 | # setup resize filter and unsharp parameters (calculated through trial and error) 87 | local arguments="-interpolate bicubic -filter Lagrange" 88 | local unsharp="-unsharp 0.4x0.4+0.4+0.008" 89 | 90 | # scale 80%, sharpen, repeat until less than 150% of target size 91 | local current_w=${dst_w} 92 | 93 | # pardon moi for such ugly while condition! 94 | while [ $(math "${current_w}/${dst_w} > 1.5") = "True" ]; do 95 | current_w=$(math ${current_w}\*0\.80) 96 | current_w=$(math "int(round(${current_w}))") 97 | arguments="${arguments} -resize 80% +repage ${unsharp} ${unsharp} ${unsharp} " 98 | done 99 | 100 | # final resize 101 | arguments="${arguments} -resize ${dst_w}x${dst_h}! +repage ${unsharp} ${unsharp} ${unsharp} -density 72x72 +repage" 102 | 103 | # final convert! resize, sharpen, save 104 | convert temp.psd ${arguments} -quality ${quality} ${dst/\%/${size}} 105 | 106 | } 107 | 108 | # Ask for source image, or use default value 109 | echo "Enter path to source image, or hit Enter to keep default value (${default_src}): " 110 | read src 111 | src=${src:-${default_src}} 112 | 113 | # ask for destination path, or use default value 114 | echo "Enter destination path, or hit Enter to keep default value (${default_dst})." 115 | echo "must include % symbol, it will be replaced by output size, f.e. '800x600'" 116 | read dst 117 | dst=${dst:-${default_dst}} 118 | 119 | # Ask for signature image, or use default value 120 | echo "Apply signature? (hit Enter for 'yes' or type 'n' for 'no') " 121 | read sign 122 | sign=${sign:-${default_sign}} 123 | 124 | # Ask for signature image, or use default value 125 | echo "Enter path to signature image, or hit Enter to keep default value (${default_sig}): " 126 | read sig 127 | sig=${sig:-${default_sig}} 128 | 129 | # ask for gravity, or use default value 130 | echo "Enter gravity for cropping left/right edges (center, east, west), or hit Enter to keep default value (${default_gravity}): " 131 | read gravity 132 | gravity=${gravity:-${default_gravity}} 133 | 134 | 135 | # detect source image width and height 136 | src_w=$(identify -format "%w" "${src}") 137 | src_h=$(identify -format "%h" "${src}") 138 | 139 | # detect signature width and height 140 | if [ "${sign}" == "y" ]; then 141 | sig_w=$(identify -format "%w" "${sig}") 142 | sig_h=$(identify -format "%h" "${sig}") 143 | fi 144 | 145 | # loop throught output sizes and save each size 146 | for i in "${output[@]}" 147 | do 148 | save ${i} 149 | done 150 | 151 | # Delete temporary file 152 | rm temp.psd 153 | 154 | # Done! 155 | echo "Done!" 156 | -------------------------------------------------------------------------------- /src/lib/color_widgets.pri: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013-2019 Mattia Basaglia 2 | # 3 | # 4 | # This software is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Lesser General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This software is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public License 15 | # along with Color Widgets. If not, see . 16 | 17 | CONFIG += c++11 18 | 19 | INCLUDEPATH += $$PWD/src $$PWD/include 20 | 21 | SOURCES += \ 22 | $$PWD/src/QtColorWidgets/abstract_widget_list.cpp \ 23 | $$PWD/src/QtColorWidgets/bound_color_selector.cpp \ 24 | $$PWD/src/QtColorWidgets/color_2d_slider.cpp \ 25 | $$PWD/src/QtColorWidgets/color_delegate.cpp \ 26 | $$PWD/src/QtColorWidgets/color_dialog.cpp \ 27 | $$PWD/src/QtColorWidgets/color_line_edit.cpp \ 28 | $$PWD/src/QtColorWidgets/color_list_widget.cpp \ 29 | $$PWD/src/QtColorWidgets/color_names.cpp \ 30 | $$PWD/src/QtColorWidgets/color_palette.cpp \ 31 | $$PWD/src/QtColorWidgets/color_palette_model.cpp \ 32 | $$PWD/src/QtColorWidgets/color_palette_widget.cpp \ 33 | $$PWD/src/QtColorWidgets/color_preview.cpp \ 34 | $$PWD/src/QtColorWidgets/color_selector.cpp \ 35 | $$PWD/src/QtColorWidgets/color_utils.cpp \ 36 | $$PWD/src/QtColorWidgets/color_wheel.cpp \ 37 | $$PWD/src/QtColorWidgets/gradient_editor.cpp \ 38 | $$PWD/src/QtColorWidgets/gradient_list_model.cpp \ 39 | $$PWD/src/QtColorWidgets/gradient_slider.cpp \ 40 | $$PWD/src/QtColorWidgets/harmony_color_wheel.cpp \ 41 | $$PWD/src/QtColorWidgets/hue_slider.cpp \ 42 | $$PWD/src/QtColorWidgets/swatch.cpp 43 | 44 | HEADERS += \ 45 | $$PWD/include/QtColorWidgets/abstract_widget_list.hpp \ 46 | $$PWD/include/QtColorWidgets/bound_color_selector.hpp \ 47 | $$PWD/include/QtColorWidgets/color_2d_slider.hpp \ 48 | $$PWD/include/QtColorWidgets/color_delegate.hpp \ 49 | $$PWD/include/QtColorWidgets/color_dialog.hpp \ 50 | $$PWD/include/QtColorWidgets/color_line_edit.hpp \ 51 | $$PWD/include/QtColorWidgets/color_list_widget.hpp \ 52 | $$PWD/include/QtColorWidgets/color_names.hpp \ 53 | $$PWD/include/QtColorWidgets/color_palette.hpp \ 54 | $$PWD/include/QtColorWidgets/color_palette_model.hpp \ 55 | $$PWD/include/QtColorWidgets/color_palette_widget.hpp \ 56 | $$PWD/include/QtColorWidgets/color_preview.hpp \ 57 | $$PWD/include/QtColorWidgets/color_selector.hpp \ 58 | $$PWD/include/QtColorWidgets/color_utils.hpp \ 59 | $$PWD/include/QtColorWidgets/color_wheel.hpp \ 60 | $$PWD/include/QtColorWidgets/color_wheel_private.hpp \ 61 | $$PWD/include/QtColorWidgets/colorwidgets_global.hpp \ 62 | $$PWD/include/QtColorWidgets/gradient_delegate.hpp \ 63 | $$PWD/include/QtColorWidgets/gradient_editor.hpp \ 64 | $$PWD/include/QtColorWidgets/gradient_helper.hpp \ 65 | $$PWD/include/QtColorWidgets/gradient_list_model.hpp \ 66 | $$PWD/include/QtColorWidgets/gradient_slider.hpp \ 67 | $$PWD/include/QtColorWidgets/harmony_color_wheel.hpp \ 68 | $$PWD/include/QtColorWidgets/hue_slider.hpp \ 69 | $$PWD/include/QtColorWidgets/swatch.hpp 70 | 71 | FORMS += \ 72 | $$PWD/src/QtColorWidgets/color_dialog.ui \ 73 | $$PWD/src/QtColorWidgets/color_palette_widget.ui 74 | 75 | RESOURCES += \ 76 | $$PWD/resources/QtColorWidgets/color_widgets.qrc 77 | 78 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/AbstractWidgetList: -------------------------------------------------------------------------------- 1 | #include "abstract_widget_list.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/BoundColorSelector: -------------------------------------------------------------------------------- 1 | #include "bound_color_selector.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (HEADERS 2 | abstract_widget_list.hpp 3 | bound_color_selector.hpp 4 | color_2d_slider.hpp 5 | color_delegate.hpp 6 | color_dialog.hpp 7 | color_line_edit.hpp 8 | color_list_widget.hpp 9 | color_names.hpp 10 | color_palette.hpp 11 | color_palette_model.hpp 12 | color_palette_widget.hpp 13 | color_preview.hpp 14 | color_selector.hpp 15 | color_wheel.hpp 16 | colorwidgets_global.hpp 17 | gradient_slider.hpp 18 | hue_slider.hpp 19 | swatch.hpp 20 | gradient_editor.hpp 21 | harmony_color_wheel.hpp 22 | gradient_list_model.hpp 23 | gradient_delegate.hpp 24 | ) 25 | 26 | file(RELATIVE_PATH 27 | PREFIX 28 | ${PROJECT_SOURCE_DIR} 29 | ${CMAKE_CURRENT_LIST_DIR}) 30 | 31 | 32 | foreach (HEADER IN LISTS HEADERS) 33 | target_sources (${TARGET_NAME} 34 | PRIVATE 35 | $ 36 | $) 37 | endforeach (HEADER IN HEADERS) 38 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/ColorDelegate: -------------------------------------------------------------------------------- 1 | #include "color_delegate.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/ColorDialog: -------------------------------------------------------------------------------- 1 | #include "color_dialog.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/ColorListWidget: -------------------------------------------------------------------------------- 1 | #include "color_list_widget.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/ColorPreview: -------------------------------------------------------------------------------- 1 | #include "color_preview.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/ColorSelector: -------------------------------------------------------------------------------- 1 | #include "color_selector.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/ColorWheel: -------------------------------------------------------------------------------- 1 | #include "color_wheel.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/GradientEditor: -------------------------------------------------------------------------------- 1 | #include "gradient_editor.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/GradientListModel: -------------------------------------------------------------------------------- 1 | #include "gradient_list_model.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/GradientSlider: -------------------------------------------------------------------------------- 1 | #include "gradient_slider.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/HarmonyColorWheel: -------------------------------------------------------------------------------- 1 | #include "harmony_color_wheel.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/HueSlider: -------------------------------------------------------------------------------- 1 | #include "hue_slider.hpp" 2 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/abstract_widget_list.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef ABSTRACT_WIDGET_LIST_HPP 23 | #define ABSTRACT_WIDGET_LIST_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | #include 29 | 30 | class QCP_EXPORT AbstractWidgetList : public QWidget 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit AbstractWidgetList(QWidget *parent = 0); 35 | ~AbstractWidgetList(); 36 | 37 | /** 38 | * \brief Get the number of items 39 | */ 40 | int count() const; 41 | 42 | /** 43 | * \brief Swap row a and row b 44 | */ 45 | virtual void swap(int a, int b) = 0; 46 | 47 | 48 | /// Whether the given row index is valid 49 | bool isValidRow(int i) const { return i >= 0 && i < count(); } 50 | 51 | void setRowHeight(int row, int height); 52 | 53 | 54 | public Q_SLOTS: 55 | /** 56 | * \brief Remove row i 57 | */ 58 | void remove(int i); 59 | 60 | /** 61 | * \brief append a default row 62 | */ 63 | virtual void append() = 0; 64 | 65 | Q_SIGNALS: 66 | void removed(int i); 67 | 68 | protected: 69 | 70 | /** 71 | * \brief Create a new row with the given widget 72 | * 73 | * Must be called by implementations of append() 74 | */ 75 | void appendWidget(QWidget* w); 76 | 77 | /** 78 | * \brief get the widget found at the given row 79 | */ 80 | QWidget* widget(int i); 81 | 82 | 83 | /** 84 | * \brief get the widget found at the given row 85 | */ 86 | template 87 | T* widget_cast(int i) { return qobject_cast(widget(i)); } 88 | 89 | /** 90 | * \brief clear all rows without emitting signals 91 | * 92 | * May be useful when implementation want to set all values at once 93 | */ 94 | void clear(); 95 | 96 | private Q_SLOTS: 97 | void remove_clicked(QWidget* w); 98 | void up_clicked(QWidget* w); 99 | void down_clicked(QWidget* w); 100 | 101 | private: 102 | class Private; 103 | Private * const p; 104 | 105 | QWidget* create_button(QWidget* data, QSignalMapper*mapper, 106 | QString icon_name, QString text, 107 | QString tooltip = QString()) const; 108 | }; 109 | 110 | #endif // ABSTRACT_WIDGET_LIST_HPP 111 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/bound_color_selector.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef BOUND_COLOR_SELECTOR_HPP 23 | #define BOUND_COLOR_SELECTOR_HPP 24 | 25 | #include "color_selector.hpp" 26 | 27 | namespace color_widgets { 28 | /** 29 | * \brief A color selector bound to a color reference 30 | * \todo Maybe this can be removed 31 | */ 32 | class QCP_EXPORT BoundColorSelector : public ColorSelector 33 | { 34 | Q_OBJECT 35 | private: 36 | QColor* ref; 37 | public: 38 | explicit BoundColorSelector(QColor* reference, QWidget *parent = 0); 39 | 40 | private Q_SLOTS: 41 | void update_reference(QColor); 42 | }; 43 | } // namespace color_widgets 44 | #endif // BOUND_COLOR_SELECTOR_HPP 45 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_2d_slider.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_COLOR_2D_SLIDER_HPP 23 | #define COLOR_WIDGETS_COLOR_2D_SLIDER_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | #include 27 | 28 | namespace color_widgets { 29 | 30 | /** 31 | * \brief A 2D slider that edits 2 color components 32 | */ 33 | class QCP_EXPORT Color2DSlider : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true STORED false ) 38 | Q_PROPERTY(qreal hue READ hue WRITE setHue DESIGNABLE false ) 39 | Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation DESIGNABLE false ) 40 | Q_PROPERTY(qreal value READ value WRITE setValue DESIGNABLE false ) 41 | /** 42 | * \brief Which color component is used on the x axis 43 | */ 44 | Q_PROPERTY(Component componentX READ componentX WRITE setComponentX NOTIFY componentXChanged) 45 | /** 46 | * \brief Which color component is used on the y axis 47 | */ 48 | Q_PROPERTY(Component componentY READ componentY WRITE setComponentY NOTIFY componentYChanged) 49 | 50 | 51 | public: 52 | enum Component { 53 | Hue, Saturation, Value 54 | }; 55 | Q_ENUMS(Component) 56 | 57 | explicit Color2DSlider(QWidget *parent = nullptr); 58 | ~Color2DSlider(); 59 | 60 | /// Get current color 61 | QColor color() const; 62 | 63 | QSize sizeHint() const Q_DECL_OVERRIDE; 64 | 65 | /// Get current hue in the range [0-1] 66 | qreal hue() const; 67 | 68 | /// Get current saturation in the range [0-1] 69 | qreal saturation() const; 70 | 71 | /// Get current value in the range [0-1] 72 | qreal value() const; 73 | 74 | Component componentX() const; 75 | Component componentY() const; 76 | 77 | public Q_SLOTS: 78 | 79 | /// Set current color 80 | void setColor(const QColor& c); 81 | 82 | /** 83 | * @param h Hue [0-1] 84 | */ 85 | void setHue(qreal h); 86 | 87 | /** 88 | * @param s Saturation [0-1] 89 | */ 90 | void setSaturation(qreal s); 91 | 92 | /** 93 | * @param v Value [0-1] 94 | */ 95 | void setValue(qreal v); 96 | 97 | void setComponentX(Component componentX); 98 | void setComponentY(Component componentY); 99 | 100 | Q_SIGNALS: 101 | /** 102 | * Emitted when the user selects a color or setColor is called 103 | */ 104 | void colorChanged(QColor); 105 | 106 | /** 107 | * Emitted when the user selects a color 108 | */ 109 | void colorSelected(QColor); 110 | 111 | void componentXChanged(Component componentX); 112 | void componentYChanged(Component componentY); 113 | 114 | protected: 115 | void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; 116 | void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE; 117 | void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE; 118 | void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE; 119 | void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE; 120 | 121 | private: 122 | class Private; 123 | Private * const p; 124 | }; 125 | 126 | } // namespace color_widgets 127 | 128 | #endif // COLOR_WIDGETS_COLOR_2D_SLIDER_HPP 129 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_delegate.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_DELEGATE_HPP 23 | #define COLOR_DELEGATE_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | 29 | namespace color_widgets { 30 | 31 | 32 | class QCP_EXPORT ReadOnlyColorDelegate : public QStyledItemDelegate 33 | { 34 | Q_OBJECT 35 | public: 36 | using QStyledItemDelegate::QStyledItemDelegate; 37 | 38 | void paint(QPainter *painter, const QStyleOptionViewItem &option, 39 | const QModelIndex &index) const Q_DECL_OVERRIDE; 40 | 41 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; 42 | }; 43 | 44 | /** 45 | Delegate to use a ColorSelector in a color list 46 | */ 47 | class QCP_EXPORT ColorDelegate : public ReadOnlyColorDelegate 48 | { 49 | Q_OBJECT 50 | public: 51 | using ReadOnlyColorDelegate::ReadOnlyColorDelegate; 52 | 53 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, 54 | const QModelIndex &index) const Q_DECL_OVERRIDE; 55 | 56 | void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE; 57 | 58 | void setModelData(QWidget *editor, QAbstractItemModel *model, 59 | const QModelIndex &index) const Q_DECL_OVERRIDE; 60 | 61 | void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, 62 | const QModelIndex &index) const Q_DECL_OVERRIDE; 63 | 64 | protected: 65 | bool eventFilter(QObject * watched, QEvent * event) Q_DECL_OVERRIDE; 66 | 67 | private slots: 68 | void close_editor(); 69 | void color_changed(); 70 | }; 71 | 72 | } // namespace color_widgets 73 | 74 | #endif // COLOR_DELEGATE_HPP 75 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_dialog.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_DIALOG_HPP 23 | #define COLOR_DIALOG_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | #include "color_preview.hpp" 27 | #include "color_wheel.hpp" 28 | 29 | #include 30 | 31 | class QAbstractButton; 32 | 33 | namespace color_widgets { 34 | 35 | class QCP_EXPORT ColorDialog : public QDialog 36 | { 37 | Q_OBJECT 38 | Q_ENUMS(ButtonMode) 39 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true) 40 | Q_PROPERTY(ColorWheel::ShapeEnum wheelShape READ wheelShape WRITE setWheelShape NOTIFY wheelShapeChanged) 41 | Q_PROPERTY(ColorWheel::ColorSpaceEnum colorSpace READ colorSpace WRITE setColorSpace NOTIFY colorSpaceChanged) 42 | Q_PROPERTY(bool wheelRotating READ wheelRotating WRITE setWheelRotating NOTIFY wheelRotatingChanged) 43 | /** 44 | * \brief whether the color alpha channel can be edited. 45 | * 46 | * If alpha is disabled, the selected color's alpha will always be 255. 47 | */ 48 | Q_PROPERTY(bool alphaEnabled READ alphaEnabled WRITE setAlphaEnabled NOTIFY alphaEnabledChanged) 49 | 50 | public: 51 | enum ButtonMode { 52 | OkCancel, 53 | OkApplyCancel, 54 | Close, 55 | NoButton 56 | }; 57 | 58 | explicit ColorDialog(QWidget *parent = 0, Qt::WindowFlags f = {}); 59 | 60 | ~ColorDialog(); 61 | 62 | /** 63 | * Get currently selected color 64 | */ 65 | QColor color() const; 66 | 67 | /** 68 | * Set the display mode for the color preview 69 | */ 70 | void setPreviewDisplayMode(ColorPreview::DisplayMode mode); 71 | 72 | /** 73 | * Get the color preview diplay mode 74 | */ 75 | ColorPreview::DisplayMode previewDisplayMode() const; 76 | 77 | bool alphaEnabled() const; 78 | 79 | /** 80 | * Select which dialog buttons to show 81 | * 82 | * There are three predefined modes: 83 | * OkCancel - this is useful when the dialog is modal and we just want to return a color 84 | * OkCancelApply - this is for non-modal dialogs 85 | * Close - for non-modal dialogs with direct color updates via colorChanged signal 86 | */ 87 | void setButtonMode(ButtonMode mode); 88 | ButtonMode buttonMode() const; 89 | 90 | QSize sizeHint() const; 91 | 92 | ColorWheel::ShapeEnum wheelShape() const; 93 | ColorWheel::ColorSpaceEnum colorSpace() const; 94 | bool wheelRotating() const; 95 | 96 | public Q_SLOTS: 97 | 98 | /** 99 | * Change color 100 | */ 101 | void setColor(const QColor &c); 102 | 103 | /** 104 | * Set the current color and show the dialog 105 | */ 106 | void showColor(const QColor &oldcolor); 107 | 108 | void setWheelShape(ColorWheel::ShapeEnum shape); 109 | void setColorSpace(ColorWheel::ColorSpaceEnum space); 110 | void setWheelRotating(bool rotating); 111 | 112 | /** 113 | * Set whether the color alpha channel can be edited. 114 | * If alpha is disabled, the selected color's alpha will always be 255. 115 | */ 116 | void setAlphaEnabled(bool a); 117 | 118 | Q_SIGNALS: 119 | /** 120 | * The current color was changed 121 | */ 122 | void colorChanged(QColor); 123 | 124 | /** 125 | * The user selected the new color by pressing Ok/Apply 126 | */ 127 | void colorSelected(QColor); 128 | 129 | void wheelShapeChanged(ColorWheel::ShapeEnum shape); 130 | void colorSpaceChanged(ColorWheel::ColorSpaceEnum space); 131 | void wheelRotatingChanged(bool rotating); 132 | 133 | void alphaEnabledChanged(bool alphaEnabled); 134 | 135 | private Q_SLOTS: 136 | /// Update all the Ui elements to match the selected color 137 | void setColorInternal(const QColor &color); 138 | /// Update from HSV sliders 139 | void set_hsv(); 140 | /// Update from RGB sliders 141 | void set_rgb(); 142 | /// Update from Alpha slider 143 | void set_alpha(); 144 | 145 | void on_edit_hex_colorChanged(const QColor& color); 146 | void on_edit_hex_colorEditingFinished(const QColor& color); 147 | 148 | void on_buttonBox_clicked(QAbstractButton*); 149 | 150 | protected: 151 | void dragEnterEvent(QDragEnterEvent *event); 152 | void dropEvent(QDropEvent * event); 153 | void mouseReleaseEvent(QMouseEvent *event); 154 | void mouseMoveEvent(QMouseEvent *event); 155 | 156 | private: 157 | class Private; 158 | Private * const p; 159 | }; 160 | 161 | } // namespace color_widgets 162 | 163 | #endif // COLOR_DIALOG_HPP 164 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_line_edit.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_COLOR_LINE_EDIT_HPP 23 | #define COLOR_WIDGETS_COLOR_LINE_EDIT_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | #include 27 | #include 28 | 29 | namespace color_widgets { 30 | 31 | /** 32 | * \brief A line edit used to define a color name 33 | * 34 | * Supported string formats: 35 | * * Short hex strings #f00 36 | * * Long hex strings #ff0000 37 | * * Color names red 38 | * * Function-like rgb(255,0,0) 39 | * 40 | * Additional string formats supported when showAlpha is true: 41 | * * Long hex strings #ff0000ff 42 | * * Function like rgba(255,0,0,255) 43 | */ 44 | class QCP_EXPORT ColorLineEdit : public QLineEdit 45 | { 46 | Q_OBJECT 47 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 48 | /** 49 | * \brief Whether the widget displays and edits the alpha channel 50 | */ 51 | Q_PROPERTY(bool showAlpha READ showAlpha WRITE setShowAlpha NOTIFY showAlphaChanged) 52 | /** 53 | * \brief If \b true, the background of the widget is changed to show the color 54 | */ 55 | Q_PROPERTY(bool previewColor READ previewColor WRITE setPreviewColor NOTIFY previewColorChanged) 56 | 57 | public: 58 | explicit ColorLineEdit(QWidget* parent = nullptr); 59 | ~ColorLineEdit(); 60 | 61 | QColor color() const; 62 | bool showAlpha() const; 63 | bool previewColor() const; 64 | 65 | public Q_SLOTS: 66 | void setColor(const QColor& color); 67 | void setShowAlpha(bool showAlpha); 68 | void setPreviewColor(bool previewColor); 69 | 70 | Q_SIGNALS: 71 | /** 72 | * \brief Emitted when the color is changed by any means 73 | */ 74 | void colorChanged(const QColor& color); 75 | /** 76 | * \brief Emitted when the user is typing a color but has not finished yet 77 | */ 78 | void colorEdited(const QColor& color); 79 | /** 80 | * \brief Emitted when the user finished to edit a string 81 | */ 82 | void colorEditingFinished(const QColor& color); 83 | 84 | void showAlphaChanged(bool showAlpha); 85 | void previewColorChanged(bool previewColor); 86 | 87 | protected: 88 | void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; 89 | void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE; 90 | void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; 91 | 92 | private: 93 | class Private; 94 | Private* p; 95 | }; 96 | 97 | } // namespace color_widgets 98 | #endif // COLOR_WIDGETS_COLOR_LINE_EDIT_HPP 99 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_list_widget.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_LIST_WIDGET_HPP 23 | #define COLOR_LIST_WIDGET_HPP 24 | 25 | #include "abstract_widget_list.hpp" 26 | #include "color_wheel.hpp" 27 | 28 | namespace color_widgets { 29 | 30 | class QCP_EXPORT ColorListWidget : public AbstractWidgetList 31 | { 32 | Q_OBJECT 33 | 34 | Q_PROPERTY(QList colors READ colors WRITE setColors NOTIFY colorsChanged ) 35 | Q_PROPERTY(ColorWheel::ShapeEnum wheelShape READ wheelShape WRITE setWheelShape NOTIFY wheelShapeChanged) 36 | Q_PROPERTY(ColorWheel::ColorSpaceEnum colorSpace READ colorSpace WRITE setColorSpace NOTIFY colorSpaceChanged) 37 | Q_PROPERTY(bool wheelRotating READ wheelRotating WRITE setWheelRotating NOTIFY wheelRotatingChanged) 38 | 39 | public: 40 | explicit ColorListWidget(QWidget *parent = 0); 41 | ~ColorListWidget(); 42 | 43 | QList colors() const; 44 | void setColors(const QList& colors); 45 | 46 | void swap(int a, int b); 47 | 48 | void append(); 49 | 50 | void setColor(const QColor& color); 51 | 52 | ColorWheel::ShapeEnum wheelShape() const; 53 | ColorWheel::ColorSpaceEnum colorSpace() const; 54 | bool wheelRotating() const; 55 | 56 | Q_SIGNALS: 57 | void colorsChanged(const QList&); 58 | void wheelShapeChanged(ColorWheel::ShapeEnum shape); 59 | void colorSpaceChanged(ColorWheel::ColorSpaceEnum space); 60 | void wheelRotatingChanged(bool rotating); 61 | 62 | public Q_SLOTS: 63 | void setWheelShape(ColorWheel::ShapeEnum shape); 64 | void setColorSpace(ColorWheel::ColorSpaceEnum space); 65 | void setWheelRotating(bool rotating); 66 | 67 | private Q_SLOTS: 68 | void emit_changed(); 69 | void handle_removed(int); 70 | void color_changed(int row); 71 | 72 | private: 73 | class Private; 74 | Private * const p; 75 | void append_widget(int col); 76 | }; 77 | 78 | } // namespace color_widgets 79 | 80 | #endif // COLOR_LIST_WIDGET_HPP 81 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_names.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_COLOR_NAMES_HPP 23 | #define COLOR_WIDGETS_COLOR_NAMES_HPP 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | namespace color_widgets { 31 | 32 | /** 33 | * \brief Convert a string into a color 34 | * 35 | * Supported string formats: 36 | * * Short hex strings #f00 37 | * * Long hex strings #ff0000 38 | * * Color names red 39 | * * Function-like rgb(255,0,0) 40 | * 41 | * Additional string formats supported only when \p alpha is true: 42 | * * Long hex strings #ff0000ff 43 | * * Function like rgba(255,0,0,255) 44 | */ 45 | QCP_EXPORT QColor colorFromString(const QString& string, bool alpha = true); 46 | 47 | /** 48 | * \brief Convert a color into a string 49 | * 50 | * Format: 51 | * * If the color has full alpha: #ff0000 52 | * * If alpha is true and the color has non-full alpha: #ff000088 53 | */ 54 | QCP_EXPORT QString stringFromColor(const QColor& color, bool alpha = true); 55 | 56 | } // namespace color_widgets 57 | #endif // COLOR_WIDGETS_COLOR_NAMES_HPP 58 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_palette_model.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_COLOR_PALETTE_MODEL_HPP 23 | #define COLOR_WIDGETS_COLOR_PALETTE_MODEL_HPP 24 | 25 | #include 26 | #include "color_palette.hpp" 27 | 28 | namespace color_widgets { 29 | 30 | class QCP_EXPORT ColorPaletteModel : public QAbstractListModel 31 | { 32 | Q_OBJECT 33 | /** 34 | * \brief List of directories to be scanned for palette files 35 | */ 36 | Q_PROPERTY(QStringList searchPaths READ searchPaths WRITE setSearchPaths NOTIFY searchPathsChanged) 37 | 38 | /** 39 | * \brief Default directory to be used when saving a palette 40 | */ 41 | Q_PROPERTY(QString savePath READ savePath WRITE setSavePath NOTIFY savePathChanged) 42 | 43 | /** 44 | * \brief Size of the icon used for the palette previews 45 | */ 46 | Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) 47 | 48 | 49 | public: 50 | ColorPaletteModel(); 51 | ~ColorPaletteModel(); 52 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 53 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 54 | bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()) Q_DECL_OVERRIDE; 55 | 56 | QString savePath() const; 57 | QStringList searchPaths() const; 58 | QSize iconSize() const; 59 | 60 | /** 61 | * \brief Number of palettes 62 | */ 63 | int count() const; 64 | 65 | /** 66 | * \brief Returns a reference to the first palette with the given name 67 | * \pre hasPalette(name) 68 | */ 69 | const ColorPalette& palette(const QString& name) const; 70 | 71 | /** 72 | * \brief Whether a palette with the given name exists in the model 73 | */ 74 | bool hasPalette(const QString& name) const; 75 | 76 | /** 77 | * \brief Get the palette at the given index (row) 78 | * \pre 0 <= index < count() 79 | */ 80 | const ColorPalette& palette(int index) const; 81 | 82 | /** 83 | * \brief Updates an existing palette 84 | * \param index Palette index 85 | * \param palette New palette 86 | * \param save Whether to save the palette to the filesystem 87 | * 88 | * Saving will try: (in this order) 89 | * * To overwrite the file pointed by the old palette 90 | * * To write to the new palette file name 91 | * * To create a file in the save path 92 | * If all of the above fail, the palette will be replaced interally 93 | * but not on the filesystem 94 | * 95 | * \returns \b true if the palette has been successfully updated (and saved) 96 | */ 97 | bool updatePalette(int index, const ColorPalette& palette, bool save = true); 98 | 99 | /** 100 | * \brief Remove a palette from the model and optionally from the filesystem 101 | * \returns \b true if the palette has been successfully removed 102 | */ 103 | bool removePalette(int index, bool remove_file = true); 104 | 105 | /** 106 | * \brief Remove a palette to the model and optionally to the filesystem 107 | * \returns \b true if the palette has been successfully added 108 | */ 109 | bool addPalette(const ColorPalette& palette, bool save = true); 110 | 111 | /** 112 | * \brief The index of the palette with the given file name 113 | * \returns -1 if none is found 114 | */ 115 | int indexFromFile(const QString& filename) const; 116 | 117 | public Q_SLOTS: 118 | void setSavePath(const QString& savePath); 119 | void setSearchPaths(const QStringList& searchPaths); 120 | void addSearchPath(const QString& path); 121 | void setIconSize(const QSize& iconSize); 122 | 123 | /** 124 | * \brief Load palettes files found in the search paths 125 | */ 126 | void load(); 127 | 128 | Q_SIGNALS: 129 | void savePathChanged(const QString& savePath); 130 | void searchPathsChanged(const QStringList& searchPaths); 131 | void iconSizeChanged(const QSize& iconSize); 132 | 133 | private: 134 | class Private; 135 | Private* p; 136 | }; 137 | 138 | } // namespace color_widgets 139 | 140 | #endif // COLOR_WIDGETS_COLOR_PALETTE_MODEL_HPP 141 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_preview.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * \copyright Copyright (C) 2014 Calle Laakkonen 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | #ifndef COLOR_PREVIEW_HPP 24 | #define COLOR_PREVIEW_HPP 25 | 26 | #include "colorwidgets_global.hpp" 27 | 28 | #include 29 | 30 | namespace color_widgets { 31 | 32 | /** 33 | * Simple widget that shows a preview of a color 34 | */ 35 | class QCP_EXPORT ColorPreview : public QWidget 36 | { 37 | Q_OBJECT 38 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true) 39 | Q_PROPERTY(QColor comparisonColor READ comparisonColor WRITE setComparisonColor NOTIFY comparisonColorChanged DESIGNABLE true) 40 | Q_PROPERTY(DisplayMode display_mode READ displayMode WRITE setDisplayMode NOTIFY displayModeChanged DESIGNABLE true) 41 | Q_PROPERTY(QBrush background READ background WRITE setBackground NOTIFY backgroundChanged DESIGNABLE true) 42 | Q_PROPERTY(bool drawFrame READ drawFrame WRITE setDrawFrame NOTIFY drawFrameChanged DESIGNABLE true) 43 | Q_ENUMS(DisplayMode) 44 | public: 45 | enum DisplayMode 46 | { 47 | NoAlpha, ///< Show current color with no transparency 48 | AllAlpha, ///< show current color with transparency 49 | SplitAlpha, ///< Show both solid and transparent side by side 50 | SplitColor, ///< Show current and comparison colors side by side 51 | SplitColorReverse, ///< Like Split color but swapped 52 | }; 53 | Q_ENUMS(DisplayMode) 54 | 55 | explicit ColorPreview(QWidget *parent = 0); 56 | ~ColorPreview(); 57 | 58 | /// Get the background visible under transparent colors 59 | QBrush background() const; 60 | 61 | /// Change the background visible under transparent colors 62 | void setBackground(const QBrush &bk); 63 | 64 | /// Get color display mode 65 | DisplayMode displayMode() const; 66 | 67 | /// Set how transparent colors are handled 68 | void setDisplayMode(DisplayMode dm); 69 | 70 | /// Get current color 71 | QColor color() const; 72 | 73 | /// Get the comparison color 74 | QColor comparisonColor() const; 75 | 76 | QSize sizeHint () const; 77 | 78 | void paint(QPainter &painter, QRect rect) const; 79 | 80 | /// Whether to draw a frame around the color 81 | bool drawFrame() const; 82 | void setDrawFrame(bool); 83 | 84 | public Q_SLOTS: 85 | /// Set current color 86 | void setColor(const QColor &c); 87 | 88 | /// Set the comparison color 89 | void setComparisonColor(const QColor &c); 90 | 91 | Q_SIGNALS: 92 | /// Emitted when the user clicks on the widget 93 | void clicked(); 94 | 95 | /// Emitted on setColor 96 | void colorChanged(QColor); 97 | 98 | void comparisonColorChanged(QColor); 99 | void displayModeChanged(DisplayMode); 100 | void backgroundChanged(const QBrush&); 101 | void drawFrameChanged(bool); 102 | protected: 103 | void paintEvent(QPaintEvent *); 104 | void resizeEvent(QResizeEvent *); 105 | void mouseReleaseEvent(QMouseEvent *ev); 106 | void mouseMoveEvent(QMouseEvent *ev); 107 | 108 | private: 109 | class Private; 110 | Private * const p; 111 | }; 112 | 113 | } // namespace color_widgets 114 | Q_DECLARE_METATYPE(color_widgets::ColorPreview::DisplayMode) 115 | 116 | #endif // COLOR_PREVIEW_HPP 117 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_selector.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_SELECTOR_HPP 23 | #define COLOR_SELECTOR_HPP 24 | 25 | #include "color_preview.hpp" 26 | #include "color_wheel.hpp" 27 | 28 | namespace color_widgets { 29 | 30 | /** 31 | * Color preview that opens a color dialog 32 | */ 33 | class QCP_EXPORT ColorSelector : public ColorPreview 34 | { 35 | Q_OBJECT 36 | Q_ENUMS(UpdateMode) 37 | Q_PROPERTY(UpdateMode updateMode READ updateMode WRITE setUpdateMode NOTIFY updateModeChanged) 38 | Q_PROPERTY(Qt::WindowModality dialogModality READ dialogModality WRITE setDialogModality NOTIFY dialogModalityChanged) 39 | Q_PROPERTY(ColorWheel::ShapeEnum wheelShape READ wheelShape WRITE setWheelShape NOTIFY wheelShapeChanged) 40 | Q_PROPERTY(ColorWheel::ColorSpaceEnum colorSpace READ colorSpace WRITE setColorSpace NOTIFY colorSpaceChanged) 41 | Q_PROPERTY(bool wheelRotating READ wheelRotating WRITE setWheelRotating NOTIFY wheelRotatingChanged) 42 | 43 | public: 44 | enum UpdateMode { 45 | Confirm, ///< Update color only after the dialog has been accepted 46 | Continuous ///< Update color as it's being modified in the dialog 47 | }; 48 | 49 | explicit ColorSelector(QWidget *parent = 0); 50 | ~ColorSelector(); 51 | 52 | void setUpdateMode(UpdateMode m); 53 | UpdateMode updateMode() const; 54 | 55 | Qt::WindowModality dialogModality() const; 56 | void setDialogModality(Qt::WindowModality m); 57 | 58 | ColorWheel::ShapeEnum wheelShape() const; 59 | ColorWheel::ColorSpaceEnum colorSpace() const; 60 | bool wheelRotating() const; 61 | 62 | Q_SIGNALS: 63 | void wheelShapeChanged(ColorWheel::ShapeEnum shape); 64 | void colorSpaceChanged(ColorWheel::ColorSpaceEnum space); 65 | void wheelRotatingChanged(bool rotating); 66 | void updateModeChanged(UpdateMode); 67 | void dialogModalityChanged(Qt::WindowModality); 68 | /// Emitted when a color is selected by the user 69 | void colorSelected(const QColor& c); 70 | 71 | public Q_SLOTS: 72 | void showDialog(); 73 | void setWheelShape(ColorWheel::ShapeEnum shape); 74 | void setColorSpace(ColorWheel::ColorSpaceEnum space); 75 | void setWheelRotating(bool rotating); 76 | 77 | private Q_SLOTS: 78 | void accept_dialog(); 79 | void reject_dialog(); 80 | void update_old_color(const QColor &c); 81 | 82 | protected: 83 | void dragEnterEvent(QDragEnterEvent *event); 84 | void dropEvent(QDropEvent * event); 85 | 86 | private: 87 | /// Connect/Disconnect colorChanged based on UpdateMode 88 | void connect_dialog(); 89 | 90 | /// Disconnect from dialog update 91 | void disconnect_dialog(); 92 | 93 | class Private; 94 | Private * const p; 95 | }; 96 | 97 | } // namespace color_widgets 98 | 99 | #endif // COLOR_SELECTOR_HPP 100 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/color_utils.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_UTILS_HPP 23 | #define COLOR_UTILS_HPP 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "QtColorWidgets/colorwidgets_global.hpp" 30 | 31 | namespace color_widgets { 32 | namespace utils { 33 | 34 | 35 | QCP_EXPORT inline qreal color_chromaF(const QColor& c) 36 | { 37 | qreal max = qMax(c.redF(), qMax(c.greenF(), c.blueF())); 38 | qreal min = qMin(c.redF(), qMin(c.greenF(), c.blueF())); 39 | return max - min; 40 | } 41 | 42 | QCP_EXPORT inline qreal color_lumaF(const QColor& c) 43 | { 44 | return 0.30 * c.redF() + 0.59 * c.greenF() + 0.11 * c.blueF(); 45 | } 46 | 47 | QCP_EXPORT QColor color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha = 1 ); 48 | 49 | QCP_EXPORT inline QColor rainbow_lch(qreal hue) 50 | { 51 | return color_from_lch(hue,1,1); 52 | } 53 | 54 | QCP_EXPORT inline QColor rainbow_hsv(qreal hue) 55 | { 56 | return QColor::fromHsvF(hue,1,1); 57 | } 58 | 59 | QCP_EXPORT inline qreal color_lightnessF(const QColor& c) 60 | { 61 | return ( qMax(c.redF(),qMax(c.greenF(),c.blueF())) + 62 | qMin(c.redF(),qMin(c.greenF(),c.blueF())) ) / 2; 63 | } 64 | 65 | QCP_EXPORT inline qreal color_HSL_saturationF(const QColor& col) 66 | { 67 | qreal c = color_chromaF(col); 68 | qreal l = color_lightnessF(col); 69 | if ( qFuzzyCompare(l+1,1) || qFuzzyCompare(l+1,2) ) 70 | return 0; 71 | return c / (1-qAbs(2*l-1)); 72 | } 73 | 74 | 75 | QCP_EXPORT QColor color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha = 1 ); 76 | 77 | QCP_EXPORT QColor get_screen_color(const QPoint &global_pos); 78 | 79 | } // namespace utils 80 | } // namespace color_widgets 81 | 82 | #endif // COLOR_UTILS_HPP 83 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/colorwidgets_global.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QT_COLOR_WIDGETS_GLOBAL_H 2 | #define QT_COLOR_WIDGETS_GLOBAL_H 3 | 4 | #include 5 | 6 | #if defined(QTCOLORWIDGETS_STATICALLY_LINKED) 7 | # define QCP_EXPORT 8 | #elif defined(QTCOLORWIDGETS_LIBRARY) 9 | # define QCP_EXPORT Q_DECL_EXPORT 10 | #else 11 | # define QCP_EXPORT Q_DECL_IMPORT 12 | #endif 13 | 14 | #endif // QT_COLOR_WIDGETS_GLOBAL_H 15 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/gradient_delegate.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | #ifndef COLOR_WIDGETS_GRADIENT_DELEGATE_HPP 24 | #define COLOR_WIDGETS_GRADIENT_DELEGATE_HPP 25 | 26 | 27 | #include 28 | #include 29 | 30 | #include "QtColorWidgets/gradient_editor.hpp" 31 | 32 | namespace color_widgets { 33 | 34 | /** 35 | * \brief Item delegate to edits gradients 36 | * 37 | * In order to make it work, return as edit data from the model a QBrush with a gradient 38 | */ 39 | class QCP_EXPORT GradientDelegate : public QStyledItemDelegate 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const Q_DECL_OVERRIDE 45 | { 46 | QVariant data = index.data(Qt::EditRole); 47 | if ( data.canConvert() ) 48 | { 49 | QBrush brush = data.value(); 50 | if ( brush.gradient() ) 51 | { 52 | GradientEditor* editor = new GradientEditor(parent); 53 | editor->setStops(brush.gradient()->stops()); 54 | return editor; 55 | } 56 | } 57 | 58 | return QStyledItemDelegate::createEditor(parent, option, index); 59 | } 60 | 61 | void setModelData(QWidget * widget, QAbstractItemModel * model, const QModelIndex & index) const Q_DECL_OVERRIDE 62 | { 63 | if ( GradientEditor* editor = qobject_cast(widget) ) 64 | model->setData(index, QBrush(editor->gradient()), Qt::EditRole); 65 | else 66 | QStyledItemDelegate::setModelData(widget, model, index); 67 | } 68 | 69 | void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const Q_DECL_OVERRIDE 70 | { 71 | QVariant display_data = index.data(Qt::DisplayRole); 72 | QVariant gradient_data = display_data.isValid() ? display_data : index.data(Qt::EditRole); 73 | if ( gradient_data.canConvert() ) 74 | { 75 | QBrush brush = gradient_data.value(); 76 | if ( brush.gradient() ) 77 | { 78 | QBrush background; 79 | background.setTexture(QPixmap(QStringLiteral(":/color_widgets/alphaback.png"))); 80 | painter->fillRect(option.rect, background); 81 | 82 | QLinearGradient g(option.rect.topLeft(), option.rect.topRight()); 83 | g.setStops(brush.gradient()->stops()); 84 | painter->fillRect(option.rect, g); 85 | 86 | if ( option.state & QStyle::State_Selected ) 87 | { 88 | int border = 2; 89 | painter->setBrush(Qt::transparent); 90 | painter->setPen(QPen(option.palette.highlight(), border)); 91 | painter->drawRect(option.rect.adjusted(border/2, border/2, -border/2, -border/2)); 92 | } 93 | return; 94 | } 95 | } 96 | 97 | QStyledItemDelegate::paint(painter, option, index); 98 | } 99 | }; 100 | 101 | } // namespace color_widgets 102 | 103 | #endif // COLOR_WIDGETS_GRADIENT_DELEGATE_HPP 104 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/gradient_editor.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file gradient_editor.hpp 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef GRADIENT_EDITOR_HPP 23 | #define GRADIENT_EDITOR_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | #include 29 | 30 | namespace color_widgets { 31 | 32 | class ColorDialog; 33 | 34 | /** 35 | * \brief A slider that moves on top of a gradient 36 | */ 37 | class QCP_EXPORT GradientEditor : public QWidget 38 | { 39 | Q_OBJECT 40 | Q_PROPERTY(QBrush background READ background WRITE setBackground NOTIFY backgroundChanged) 41 | Q_PROPERTY(QGradientStops stops READ stops WRITE setStops NOTIFY stopsChanged) 42 | Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient) 43 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) 44 | Q_PROPERTY(int selectedStop READ selectedStop WRITE setSelectedStop NOTIFY selectedStopChanged) 45 | Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) 46 | 47 | public: 48 | explicit GradientEditor(QWidget *parent = 0); 49 | explicit GradientEditor(Qt::Orientation orientation, QWidget *parent = 0); 50 | ~GradientEditor(); 51 | 52 | QSize sizeHint() const override; 53 | 54 | /// Get the background, it's visible for transparent gradient stops 55 | QBrush background() const; 56 | /// Set the background, it's visible for transparent gradient stops 57 | void setBackground(const QBrush &bg); 58 | 59 | /// Get the colors that make up the gradient 60 | QGradientStops stops() const; 61 | /// Set the colors that make up the gradient 62 | void setStops(const QGradientStops &colors); 63 | 64 | /// Get the gradient 65 | QLinearGradient gradient() const; 66 | /// Set the gradient 67 | void setGradient(const QLinearGradient &gradient); 68 | 69 | Qt::Orientation orientation() const; 70 | 71 | /** 72 | * \brief Dialog shown when double clicking a stop 73 | */ 74 | ColorDialog* dialog() const; 75 | 76 | /** 77 | * \brief Index of the currently selected gradient stop (or -1 if there is no selection) 78 | */ 79 | int selectedStop() const; 80 | 81 | /** 82 | * \brief Color of the selected stop 83 | */ 84 | QColor selectedColor() const; 85 | 86 | public Q_SLOTS: 87 | void setOrientation(Qt::Orientation); 88 | void setSelectedStop(int stop); 89 | void setSelectedColor(const QColor& color); 90 | void addStop(); 91 | void removeStop(); 92 | 93 | Q_SIGNALS: 94 | void backgroundChanged(const QBrush&); 95 | void stopsChanged(const QGradientStops&); 96 | void selectedStopChanged(int); 97 | 98 | protected: 99 | void paintEvent(QPaintEvent *ev) override; 100 | 101 | void mousePressEvent(QMouseEvent *ev) override; 102 | void mouseMoveEvent(QMouseEvent *ev) override; 103 | void mouseReleaseEvent(QMouseEvent *ev) override; 104 | void leaveEvent(QEvent * event) override; 105 | void mouseDoubleClickEvent(QMouseEvent *event) override; 106 | 107 | void dragEnterEvent(QDragEnterEvent *event) override; 108 | void dragMoveEvent(QDragMoveEvent* event) override; 109 | void dragLeaveEvent(QDragLeaveEvent *event) override; 110 | void dropEvent(QDropEvent* event) override; 111 | 112 | private Q_SLOTS: 113 | void dialogUpdate(const QColor& c); 114 | 115 | private: 116 | class Private; 117 | Private * const p; 118 | }; 119 | 120 | } // namespace color_widgets 121 | 122 | #endif // GRADIENT_EDITOR_HPP 123 | 124 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/gradient_helper.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef GRADIENT_HELPER_HPP 23 | #define GRADIENT_HELPER_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | 29 | namespace color_widgets { 30 | 31 | inline QColor blendColors(const QColor& a, const QColor& b, qreal ratio) 32 | { 33 | return QColor::fromRgbF( 34 | a.redF() * (1-ratio) + b.redF() * ratio, 35 | a.greenF() * (1-ratio) + b.greenF() * ratio, 36 | a.blueF() * (1-ratio) + b.blueF() * ratio, 37 | a.alphaF() * (1-ratio) + b.alphaF() * ratio 38 | ); 39 | } 40 | 41 | 42 | /** 43 | * \brief Get an insertion point in the gradient 44 | * \param gradient Gradient stops to look into (must be properly set up) 45 | * \param factor Value in [0, 1] to get the color for 46 | * \return A pair whose first element is the index to insert the new value at, and a GradientStop 47 | */ 48 | inline QPair Q_DECL_EXPORT gradientBlendedColorInsert(const QGradientStops& gradient, qreal factor) 49 | { 50 | if ( gradient.empty() ) 51 | return {0, {0, QColor()}}; 52 | 53 | if ( gradient.size() == 1 || factor <= 0 ) 54 | return {0, gradient.front()}; 55 | 56 | int i = 0; 57 | QGradientStop s1; 58 | for ( auto s2 : gradient ) 59 | { 60 | if ( factor < s2.first ) 61 | { 62 | qreal ratio = (factor - s1.first) / (s2.first - s1.first); 63 | return {i, {factor, blendColors(s1.second, s2.second, ratio)}}; 64 | } 65 | s1 = s2; 66 | ++i; 67 | } 68 | 69 | return {gradient.size(), gradient.back()}; 70 | } 71 | 72 | /** 73 | * \brief Returns a color in the gradient 74 | * \param gradient Gradient stops to look into (must be properly set up) 75 | * \param factor Value in [0, 1] to get the color for 76 | */ 77 | inline QColor Q_DECL_EXPORT gradientBlendedColor(const QGradientStops& gradient, qreal factor) 78 | { 79 | return gradientBlendedColorInsert(gradient, factor).second.second; 80 | } 81 | 82 | /** 83 | * \brief Returns a color in the gradient 84 | * \param gradient Gradient to look into 85 | * \param factor Value in [0, 1] to get the color for 86 | */ 87 | inline QColor Q_DECL_EXPORT gradientBlendedColor(const QGradient& gradient, qreal factor) 88 | { 89 | return gradientBlendedColor(gradient.stops(), factor); 90 | } 91 | 92 | } // namespace color_widgets 93 | 94 | 95 | 96 | 97 | #endif // GRADIENT_HELPER_HPP 98 | 99 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/gradient_list_model.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_GRADIENT_LIST_MODEL_HPP 23 | #define COLOR_WIDGETS_GRADIENT_LIST_MODEL_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace color_widgets { 32 | 33 | class QCP_EXPORT GradientListModel : public QAbstractListModel 34 | { 35 | Q_OBJECT 36 | 37 | /** 38 | * \brief Size of the icon used for the gradient previews 39 | */ 40 | Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) 41 | 42 | Q_PROPERTY(ItemEditMode editMode READ editMode WRITE setEditMode NOTIFY editModeChanged) 43 | 44 | public: 45 | enum ItemEditMode 46 | { 47 | EditNone = 0, 48 | EditName, 49 | EditGradient, 50 | }; 51 | 52 | Q_ENUM(ItemEditMode); 53 | 54 | GradientListModel(QObject *parent = nullptr); 55 | ~GradientListModel(); 56 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 57 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 58 | Qt::ItemFlags flags(const QModelIndex & index) const Q_DECL_OVERRIDE; 59 | bool setData(const QModelIndex & index, const QVariant & value, int role) Q_DECL_OVERRIDE; 60 | 61 | QSize iconSize() const; 62 | 63 | /** 64 | * \brief Number of gradients 65 | */ 66 | int count() const; 67 | 68 | /** 69 | * \brief Remove all gradients 70 | */ 71 | void clear(); 72 | 73 | /** 74 | * \brief Returns a reference to the first gradient with the given name 75 | * \pre hasGradient(name) 76 | */ 77 | const QLinearGradient& gradient(const QString& name) const; 78 | 79 | /** 80 | * \brief Returns a reference to the first gradient with the given name 81 | * \pre hasGradient(name) 82 | */ 83 | QGradientStops gradientStops(const QString& name) const; 84 | 85 | /** 86 | * \brief Whether a gradient with the given name exists in the model 87 | */ 88 | bool hasGradient(const QString& name) const; 89 | 90 | /** 91 | * \brief Get the gradient at the given index (row) 92 | * \pre 0 <= index < count() 93 | */ 94 | const QLinearGradient& gradient(int index) const; 95 | 96 | /** 97 | * \brief Get the gradient stops at the given index (row) 98 | * \pre 0 <= index < count() 99 | */ 100 | QGradientStops gradientStops(int index) const; 101 | 102 | /** 103 | * \brief Inserts or updates a gradient 104 | * \returns The index for the new gradient 105 | */ 106 | int setGradient(const QString& name, const QGradient& gradient); 107 | 108 | int setGradient(const QString& name, const QGradientStops& gradient); 109 | 110 | /** 111 | * \brief Updates the gradient at \p index 112 | */ 113 | bool setGradient(int index, const QGradient& gradient); 114 | 115 | bool setGradient(int index, const QGradientStops& gradient); 116 | 117 | /** 118 | * \brief Renames the gradient at \p index 119 | * \returns \b true on success 120 | */ 121 | bool rename(int index, const QString& new_name); 122 | 123 | /** 124 | * \brief Renames a gradient 125 | * \returns \b true on success 126 | */ 127 | bool rename(const QString& old_name, const QString& new_name); 128 | 129 | /** 130 | * \brief Remove a gradient from the model 131 | * \returns \b true if the gradient has been successfully removed 132 | */ 133 | bool removeGradient(const QString& name); 134 | 135 | 136 | bool removeGradient(int index); 137 | 138 | /** 139 | * \brief The index of the gradient with the given name 140 | * \returns -1 if none is found 141 | */ 142 | int indexFromName(const QString& name) const; 143 | 144 | /** 145 | * \brief Name of the gradient at index 146 | */ 147 | QString nameFromIndex(int index) const; 148 | 149 | ItemEditMode editMode() const; 150 | 151 | /** 152 | * \brief Brush for a gradient 153 | * \pre 0 <= \p index < count() 154 | */ 155 | QBrush gradientBrush(int index) const; 156 | 157 | public Q_SLOTS: 158 | void setIconSize(const QSize& iconSize); 159 | void setEditMode(ItemEditMode mode); 160 | 161 | Q_SIGNALS: 162 | void iconSizeChanged(const QSize& iconSize); 163 | void editModeChanged(ItemEditMode mode); 164 | 165 | private: 166 | class Private; 167 | std::unique_ptr d; 168 | }; 169 | 170 | } // namespace color_widgets 171 | 172 | #endif // COLOR_WIDGETS_GRADIENT_LIST_MODEL_HPP 173 | 174 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/gradient_slider.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file gradient_slider.hpp 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * \copyright Copyright (C) 2014 Calle Laakkonen 8 | * \copyright Copyright (C) 2017 caryoscelus 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program. If not, see . 22 | * 23 | */ 24 | #ifndef GRADIENT_SLIDER_HPP 25 | #define GRADIENT_SLIDER_HPP 26 | 27 | #include "colorwidgets_global.hpp" 28 | 29 | #include 30 | #include 31 | 32 | namespace color_widgets { 33 | 34 | /** 35 | * \brief A slider that moves on top of a gradient 36 | */ 37 | class QCP_EXPORT GradientSlider : public QSlider 38 | { 39 | Q_OBJECT 40 | Q_PROPERTY(QBrush background READ background WRITE setBackground NOTIFY backgroundChanged) 41 | Q_PROPERTY(QGradientStops colors READ colors WRITE setColors DESIGNABLE false) 42 | Q_PROPERTY(QColor firstColor READ firstColor WRITE setFirstColor STORED false) 43 | Q_PROPERTY(QColor lastColor READ lastColor WRITE setLastColor STORED false) 44 | Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient) 45 | 46 | public: 47 | explicit GradientSlider(QWidget *parent = 0); 48 | explicit GradientSlider(Qt::Orientation orientation, QWidget *parent = 0); 49 | ~GradientSlider(); 50 | 51 | /// Get the background, it's visible for transparent gradient stops 52 | QBrush background() const; 53 | /// Set the background, it's visible for transparent gradient stops 54 | void setBackground(const QBrush &bg); 55 | 56 | /// Get the colors that make up the gradient 57 | QGradientStops colors() const; 58 | /// Set the colors that make up the gradient 59 | void setColors(const QGradientStops &colors); 60 | 61 | /// Get the gradient 62 | QLinearGradient gradient() const; 63 | /// Set the gradient 64 | void setGradient(const QLinearGradient &gradient); 65 | 66 | /** 67 | * Overload: create an evenly distributed gradient of the given colors 68 | */ 69 | void setColors(const QVector &colors); 70 | 71 | /** 72 | * \brief Set the first color of the gradient 73 | * 74 | * If the gradient is currently empty it will create a stop with the given color 75 | */ 76 | void setFirstColor(const QColor &c); 77 | 78 | /** 79 | * \brief Set the last color of the gradient 80 | * 81 | * If the gradient is has less than two colors, 82 | * it will create a stop with the given color 83 | */ 84 | void setLastColor(const QColor &c); 85 | 86 | /** 87 | * \brief Get the first color 88 | * 89 | * \returns QColor() con empty gradient 90 | */ 91 | QColor firstColor() const; 92 | 93 | /** 94 | * \brief Get the last color 95 | * 96 | * \returns QColor() con empty gradient 97 | */ 98 | QColor lastColor() const; 99 | 100 | Q_SIGNALS: 101 | void backgroundChanged(const QBrush&); 102 | 103 | protected: 104 | void paintEvent(QPaintEvent *ev) override; 105 | 106 | void mousePressEvent(QMouseEvent *ev) override; 107 | void mouseMoveEvent(QMouseEvent *ev) override; 108 | void mouseReleaseEvent(QMouseEvent *ev) override; 109 | 110 | private: 111 | class Private; 112 | Private * const p; 113 | }; 114 | 115 | } // namespace color_widgets 116 | 117 | #endif // GRADIENT_SLIDER_HPP 118 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/harmony_color_wheel.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * \copyright Copyright (C) 2017 caryoscelus 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | #ifndef HARMONY_COLOR_WHEEL_HPP 24 | #define HARMONY_COLOR_WHEEL_HPP 25 | 26 | 27 | #include "color_wheel.hpp" 28 | 29 | namespace color_widgets { 30 | 31 | /** 32 | * \brief ColorWheel with color harmonies 33 | */ 34 | class QCP_EXPORT HarmonyColorWheel : public ColorWheel 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit HarmonyColorWheel(QWidget *parent = 0); 40 | ~HarmonyColorWheel(); 41 | 42 | /// Get all harmony colors (including main) 43 | QList harmonyColors() const; 44 | 45 | /// Get number of harmony colors (including main) 46 | unsigned int harmonyCount() const; 47 | 48 | /// Clear harmony color scheme 49 | void clearHarmonies(); 50 | 51 | /** 52 | * @brief Add harmony color 53 | * @param hue_diff Initial hue difference (in [0-1) range) 54 | * @param editable Whether this harmony should be editable 55 | * @returns Index of newly added harmony 56 | */ 57 | unsigned addHarmony(double hue_diff, bool editable); 58 | 59 | /** 60 | * @brief Add symmetric harmony color 61 | * @param relative_to Index of other harmony that should be symmetric relative to main hue 62 | * @returns Index of newly added harmony 63 | * Editability is inherited from symmetric editor 64 | */ 65 | unsigned addSymmetricHarmony(unsigned relative_to); 66 | 67 | /** 68 | * @brief Add opposite harmony color 69 | * @param relative_to Index of other harmony that should be opposite to this 70 | * @returns Index of newly added harmony 71 | * Editability is inherited from opposite editor 72 | */ 73 | unsigned addOppositeHarmony(unsigned relative_to); 74 | 75 | Q_SIGNALS: 76 | /** 77 | * Emitted when harmony settings or harmony colors are changed (including due to main hue change) 78 | */ 79 | void harmonyChanged(); 80 | 81 | protected: 82 | void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; 83 | void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; 84 | void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; 85 | void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; 86 | 87 | private: 88 | class Private; 89 | Private * p; 90 | }; 91 | 92 | } // namespace color_widgets 93 | 94 | #endif // COLOR_WHEEL_HPP 95 | 96 | -------------------------------------------------------------------------------- /src/lib/include/QtColorWidgets/hue_slider.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2014 Calle Laakkonen 7 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | #ifndef HUE_SLIDER_HPP 24 | #define HUE_SLIDER_HPP 25 | 26 | #include "gradient_slider.hpp" 27 | 28 | namespace color_widgets { 29 | 30 | /** 31 | * \brief A slider for selecting a hue value 32 | */ 33 | class QCP_EXPORT HueSlider : public GradientSlider 34 | { 35 | Q_OBJECT 36 | /** 37 | * \brief Saturation used in the rainbow gradient, as a [0-1] float 38 | */ 39 | Q_PROPERTY(qreal colorSaturation READ colorSaturation WRITE setColorSaturation NOTIFY colorSaturationChanged) 40 | /** 41 | * \brief Value used in the rainbow gradient, as a [0-1] float 42 | */ 43 | Q_PROPERTY(qreal colorValue READ colorValue WRITE setColorValue NOTIFY colorValueChanged) 44 | /** 45 | * \brief Alpha used in the rainbow gradient, as a [0-1] float 46 | */ 47 | Q_PROPERTY(qreal colorAlpha READ colorAlpha WRITE setColorAlpha NOTIFY colorAlphaChanged) 48 | 49 | /** 50 | * \brief Color with corresponding color* components 51 | */ 52 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 53 | 54 | /** 55 | * \brief Normalized Hue, as indicated from the slider 56 | */ 57 | Q_PROPERTY(qreal colorHue READ colorHue WRITE setColorHue NOTIFY colorHueChanged) 58 | 59 | 60 | public: 61 | explicit HueSlider(QWidget *parent = nullptr); 62 | explicit HueSlider(Qt::Orientation orientation, QWidget *parent = nullptr); 63 | ~HueSlider(); 64 | 65 | qreal colorSaturation() const; 66 | qreal colorValue() const; 67 | qreal colorAlpha() const; 68 | QColor color() const; 69 | qreal colorHue() const; 70 | 71 | public Q_SLOTS: 72 | void setColorValue(qreal value); 73 | void setColorSaturation(qreal value); 74 | void setColorAlpha(qreal alpha); 75 | void setColorHue(qreal colorHue); 76 | /** 77 | * \brief Set Hue Saturation and ColorValue, ignoring alpha 78 | */ 79 | void setColor(const QColor& color); 80 | /** 81 | * \brief Set Hue Saturation, ColorValue and Alpha 82 | */ 83 | void setFullColor(const QColor& color); 84 | 85 | Q_SIGNALS: 86 | void colorHueChanged(qreal colorHue); 87 | void colorChanged(QColor); 88 | void colorAlphaChanged(qreal v); 89 | void colorSaturationChanged(qreal v); 90 | void colorValueChanged(qreal v); 91 | 92 | private: 93 | class Private; 94 | Private * const p; 95 | }; 96 | 97 | } // namespace color_widgets 98 | 99 | #endif // HUE_SLIDER_HPP 100 | 101 | -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (SOURCES 2 | alphaback.png 3 | color_widgets.qrc 4 | ) 5 | 6 | file(RELATIVE_PATH 7 | PREFIX 8 | ${PROJECT_SOURCE_DIR} 9 | ${CMAKE_CURRENT_LIST_DIR}) 10 | 11 | 12 | foreach (SOURCE IN LISTS SOURCES) 13 | target_sources (${TARGET_NAME} 14 | PRIVATE 15 | $) 16 | endforeach (SOURCE IN SOURCES) 17 | -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/alphaback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/lib/resources/QtColorWidgets/alphaback.png -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/arrow-down-s-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/lib/resources/QtColorWidgets/arrow-down-s-line.png -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/arrow-up-s-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/lib/resources/QtColorWidgets/arrow-up-s-line.png -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/color_widgets.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | alphaback.png 4 | drop-fill.png 5 | drop-line.png 6 | delete-bin-7-line.png 7 | arrow-down-s-line.png 8 | arrow-up-s-line.png 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/delete-bin-7-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/lib/resources/QtColorWidgets/delete-bin-7-line.png -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/drop-fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/lib/resources/QtColorWidgets/drop-fill.png -------------------------------------------------------------------------------- /src/lib/resources/QtColorWidgets/drop-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keshavbhatt/ColorPie/aa5541b7ca91fec9ab67d5607038d58d3a372d61/src/lib/resources/QtColorWidgets/drop-line.png -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (SOURCES 2 | abstract_widget_list.cpp 3 | bound_color_selector.cpp 4 | color_2d_slider.cpp 5 | color_delegate.cpp 6 | color_dialog.cpp 7 | color_dialog.ui 8 | color_line_edit.cpp 9 | color_list_widget.cpp 10 | color_names.cpp 11 | color_palette.cpp 12 | color_palette_model.cpp 13 | color_palette_widget.cpp 14 | color_palette_widget.ui 15 | color_preview.cpp 16 | color_selector.cpp 17 | color_utils.cpp 18 | color_wheel.cpp 19 | gradient_slider.cpp 20 | hue_slider.cpp 21 | swatch.cpp 22 | gradient_editor.cpp 23 | harmony_color_wheel.cpp 24 | gradient_list_model.cpp 25 | ) 26 | 27 | file(RELATIVE_PATH 28 | PREFIX 29 | ${PROJECT_SOURCE_DIR} 30 | ${CMAKE_CURRENT_LIST_DIR}) 31 | 32 | 33 | foreach (SOURCE IN LISTS SOURCES) 34 | target_sources (${TARGET_NAME} 35 | PRIVATE 36 | $) 37 | endforeach (SOURCE IN SOURCES) 38 | -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/bound_color_selector.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #include "QtColorWidgets/bound_color_selector.hpp" 23 | 24 | namespace color_widgets { 25 | 26 | BoundColorSelector::BoundColorSelector(QColor* reference, QWidget *parent) : 27 | ColorSelector(parent), ref(reference) 28 | { 29 | setColor(*reference); 30 | connect(this,&ColorPreview::colorChanged,this, &BoundColorSelector::update_reference); 31 | } 32 | 33 | void BoundColorSelector::update_reference(QColor c) 34 | { 35 | *ref = c; 36 | } 37 | 38 | } // namespace color_widgets 39 | -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/color_list_widget.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #include "QtColorWidgets/color_list_widget.hpp" 23 | #include "QtColorWidgets/color_selector.hpp" 24 | 25 | namespace color_widgets { 26 | 27 | class ColorListWidget::Private 28 | { 29 | public: 30 | QColor currentColor; 31 | QList colors; 32 | QSignalMapper mapper; 33 | ColorWheel::ShapeEnum wheel_shape = ColorWheel::ShapeTriangle; 34 | ColorWheel::ColorSpaceEnum color_space = ColorWheel::ColorHSV; 35 | bool wheel_rotating = true; 36 | }; 37 | 38 | ColorListWidget::ColorListWidget(QWidget *parent) 39 | : AbstractWidgetList(parent), p(new Private) 40 | { 41 | connect(this, &AbstractWidgetList::removed, this, &ColorListWidget::handle_removed); 42 | connect(&p->mapper, SIGNAL(mapped(int)), SLOT(color_changed(int))); 43 | } 44 | 45 | ColorListWidget::~ColorListWidget() 46 | { 47 | delete p; 48 | } 49 | 50 | QList ColorListWidget::colors() const 51 | { 52 | return p->colors; 53 | } 54 | 55 | void ColorListWidget::setColor(const QColor &color) 56 | { 57 | p->currentColor = color; 58 | } 59 | 60 | void ColorListWidget::setColors(const QList &colors) 61 | { 62 | clear(); 63 | p->colors = colors; 64 | for(int i = 0;i < colors.size();i++ ) 65 | append_widget(i); 66 | Q_EMIT colorsChanged(colors); 67 | } 68 | 69 | void ColorListWidget::swap(int a, int b) 70 | { 71 | ColorSelector* sa = widget_cast(a); 72 | ColorSelector* sb = widget_cast(b); 73 | if ( sa && sb ) 74 | { 75 | QColor ca = sa->color(); 76 | sa->setColor(sb->color()); 77 | sb->setColor(ca); 78 | Q_EMIT colorsChanged(p->colors); 79 | } 80 | } 81 | 82 | void ColorListWidget::append() 83 | { 84 | p->colors.push_back(p->currentColor); 85 | append_widget(p->colors.size()-1); 86 | Q_EMIT colorsChanged(p->colors); 87 | } 88 | 89 | void ColorListWidget::emit_changed() 90 | { 91 | Q_EMIT colorsChanged(p->colors); 92 | } 93 | 94 | void ColorListWidget::handle_removed(int i) 95 | { 96 | p->colors.removeAt(i); 97 | Q_EMIT colorsChanged(p->colors); 98 | } 99 | 100 | void ColorListWidget::color_changed(int row) 101 | { 102 | ColorSelector *cs = widget_cast(row); 103 | if ( cs ) 104 | { 105 | p->colors[row] = cs->color(); 106 | Q_EMIT colorsChanged(p->colors); 107 | } 108 | } 109 | 110 | void ColorListWidget::append_widget(int col) 111 | { 112 | ColorSelector* cbs = new ColorSelector; 113 | cbs->setDisplayMode(ColorPreview::AllAlpha); 114 | cbs->setColor(p->colors[col]); 115 | //connect(cbs,SIGNAL(colorChanged(QColor)),SLOT(emit_changed())); 116 | p->mapper.setMapping(cbs,col); 117 | connect(cbs,SIGNAL(colorChanged(QColor)),&p->mapper,SLOT(map())); 118 | connect(this, &ColorListWidget::wheelRotatingChanged, cbs, &ColorSelector::setWheelRotating); 119 | connect(this, &ColorListWidget::wheelShapeChanged, cbs, &ColorSelector::setWheelShape); 120 | connect(this, &ColorListWidget::colorSpaceChanged, cbs, &ColorSelector::setColorSpace); 121 | appendWidget(cbs); 122 | //setRowHeight(count()-1,22); 123 | } 124 | 125 | void ColorListWidget::setWheelShape(ColorWheel::ShapeEnum shape) 126 | { 127 | Q_EMIT wheelShapeChanged(p->wheel_shape = shape); 128 | } 129 | 130 | ColorWheel::ShapeEnum ColorListWidget::wheelShape() const 131 | { 132 | return p->wheel_shape; 133 | } 134 | 135 | void ColorListWidget::setColorSpace(ColorWheel::ColorSpaceEnum space) 136 | { 137 | Q_EMIT colorSpaceChanged(p->color_space = space); 138 | } 139 | 140 | ColorWheel::ColorSpaceEnum ColorListWidget::colorSpace() const 141 | { 142 | return p->color_space; 143 | } 144 | 145 | void ColorListWidget::setWheelRotating(bool rotating) 146 | { 147 | Q_EMIT wheelRotatingChanged(p->wheel_rotating = rotating); 148 | } 149 | 150 | bool ColorListWidget::wheelRotating() const 151 | { 152 | return p->wheel_rotating; 153 | } 154 | 155 | } // namespace color_widgets 156 | -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/color_names.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #include "QtColorWidgets/color_names.hpp" 23 | #include 24 | 25 | static QRegularExpression regex_qcolor (QStringLiteral("^(?:(?:#[[:xdigit:]]{3})|(?:#[[:xdigit:]]{6})|(?:[[:alpha:]]+))$")); 26 | static QRegularExpression regex_func_rgb (QStringLiteral(R"(^rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)")); 27 | static QRegularExpression regex_hex_rgba (QStringLiteral("^#[[:xdigit:]]{8}$")); 28 | static QRegularExpression regex_func_rgba (QStringLiteral(R"(^rgba?\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)")); 29 | 30 | namespace color_widgets { 31 | 32 | 33 | QString stringFromColor(const QColor& color, bool alpha) 34 | { 35 | if ( !alpha || color.alpha() == 255 ) 36 | return color.name(); 37 | return color.name()+QStringLiteral("%1").arg(color.alpha(), 2, 16, QChar('0')); 38 | } 39 | 40 | QColor colorFromString(const QString& string, bool alpha) 41 | { 42 | QString xs = string.trimmed(); 43 | QRegularExpressionMatch match; 44 | 45 | match = regex_qcolor.match(xs); 46 | if ( match.hasMatch() ) 47 | { 48 | return QColor(xs); 49 | } 50 | 51 | match = regex_func_rgb.match(xs); 52 | if ( match.hasMatch() ) 53 | { 54 | return QColor( 55 | match.captured(1).toInt(), 56 | match.captured(2).toInt(), 57 | match.captured(3).toInt() 58 | ); 59 | } 60 | 61 | if ( alpha ) 62 | { 63 | match = regex_hex_rgba.match(xs); 64 | if ( match.hasMatch() ) 65 | { 66 | return QColor( 67 | xs.mid(1,2).toInt(nullptr,16), 68 | xs.mid(3,2).toInt(nullptr,16), 69 | xs.mid(5,2).toInt(nullptr,16), 70 | xs.mid(7,2).toInt(nullptr,16) 71 | ); 72 | } 73 | 74 | match = regex_func_rgba.match(xs); 75 | if ( match.hasMatch() ) 76 | { 77 | return QColor( 78 | match.captured(1).toInt(), 79 | match.captured(2).toInt(), 80 | match.captured(3).toInt(), 81 | match.captured(4).toInt() 82 | ); 83 | } 84 | } 85 | 86 | return QColor(); 87 | } 88 | 89 | } // namespace color_widgets 90 | -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/color_selector.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #include "QtColorWidgets/color_selector.hpp" 23 | #include "QtColorWidgets/color_dialog.hpp" 24 | #include 25 | #include 26 | #include 27 | 28 | namespace color_widgets { 29 | 30 | class ColorSelector::Private 31 | { 32 | public: 33 | UpdateMode update_mode; 34 | ColorDialog *dialog; 35 | QColor old_color; 36 | 37 | Private(QWidget *widget) : dialog(new ColorDialog(widget)) 38 | { 39 | dialog->setButtonMode(ColorDialog::OkCancel); 40 | } 41 | }; 42 | 43 | ColorSelector::ColorSelector(QWidget *parent) : 44 | ColorPreview(parent), p(new Private(this)) 45 | { 46 | setUpdateMode(Continuous); 47 | p->old_color = color(); 48 | 49 | connect(this,&ColorPreview::clicked,this,&ColorSelector::showDialog); 50 | connect(this,SIGNAL(colorChanged(QColor)),this,SLOT(update_old_color(QColor))); 51 | connect(p->dialog,&QDialog::rejected,this,&ColorSelector::reject_dialog); 52 | connect(p->dialog,&ColorDialog::colorSelected, this, &ColorSelector::accept_dialog); 53 | 54 | connect(p->dialog, &ColorDialog::wheelRotatingChanged, this, &ColorSelector::wheelRotatingChanged); 55 | connect(p->dialog, &ColorDialog::wheelShapeChanged, this, &ColorSelector::wheelShapeChanged); 56 | connect(p->dialog, &ColorDialog::colorSpaceChanged, this, &ColorSelector::colorSpaceChanged); 57 | 58 | setAcceptDrops(true); 59 | } 60 | 61 | ColorSelector::~ColorSelector() 62 | { 63 | delete p; 64 | } 65 | 66 | ColorSelector::UpdateMode ColorSelector::updateMode() const 67 | { 68 | return p->update_mode; 69 | } 70 | 71 | void ColorSelector::setUpdateMode(UpdateMode m) 72 | { 73 | p->update_mode = m; 74 | Q_EMIT updateModeChanged(m); 75 | } 76 | 77 | Qt::WindowModality ColorSelector::dialogModality() const 78 | { 79 | return p->dialog->windowModality(); 80 | } 81 | 82 | void ColorSelector::setDialogModality(Qt::WindowModality m) 83 | { 84 | p->dialog->setWindowModality(m); 85 | Q_EMIT dialogModalityChanged(m); 86 | } 87 | 88 | void ColorSelector::setWheelShape(ColorWheel::ShapeEnum shape) 89 | { 90 | p->dialog->setWheelShape(shape); 91 | } 92 | 93 | ColorWheel::ShapeEnum ColorSelector::wheelShape() const 94 | { 95 | return p->dialog->wheelShape(); 96 | } 97 | 98 | void ColorSelector::setColorSpace(ColorWheel::ColorSpaceEnum space) 99 | { 100 | p->dialog->setColorSpace(space); 101 | } 102 | 103 | ColorWheel::ColorSpaceEnum ColorSelector::colorSpace() const 104 | { 105 | return p->dialog->colorSpace(); 106 | } 107 | 108 | void ColorSelector::setWheelRotating(bool rotating) 109 | { 110 | p->dialog->setWheelRotating(rotating); 111 | } 112 | 113 | bool ColorSelector::wheelRotating() const 114 | { 115 | return p->dialog->wheelRotating(); 116 | } 117 | 118 | void ColorSelector::showDialog() 119 | { 120 | p->old_color = color(); 121 | p->dialog->setColor(color()); 122 | connect_dialog(); 123 | p->dialog->show(); 124 | } 125 | 126 | 127 | void ColorSelector::connect_dialog() 128 | { 129 | if (p->update_mode == Continuous) 130 | connect(p->dialog, SIGNAL(colorChanged(QColor)), this, SLOT(setColor(QColor)), Qt::UniqueConnection); 131 | else 132 | disconnect_dialog(); 133 | } 134 | 135 | void ColorSelector::disconnect_dialog() 136 | { 137 | disconnect(p->dialog, SIGNAL(colorChanged(QColor)), this, SLOT(setColor(QColor))); 138 | } 139 | 140 | void ColorSelector::accept_dialog() 141 | { 142 | setColor(p->dialog->color()); 143 | p->old_color = color(); 144 | Q_EMIT colorSelected(color()); 145 | } 146 | 147 | void ColorSelector::reject_dialog() 148 | { 149 | setColor(p->old_color); 150 | } 151 | 152 | void ColorSelector::update_old_color(const QColor &c) 153 | { 154 | if (!p->dialog->isVisible()) 155 | p->old_color = c; 156 | } 157 | 158 | void ColorSelector::dragEnterEvent(QDragEnterEvent *event) 159 | { 160 | if ( event->mimeData()->hasColor() || 161 | ( event->mimeData()->hasText() && QColor(event->mimeData()->text()).isValid() ) ) 162 | event->acceptProposedAction(); 163 | } 164 | 165 | 166 | void ColorSelector::dropEvent(QDropEvent *event) 167 | { 168 | if ( event->mimeData()->hasColor() ) 169 | { 170 | setColor(event->mimeData()->colorData().value()); 171 | event->accept(); 172 | } 173 | else if ( event->mimeData()->hasText() ) 174 | { 175 | QColor col(event->mimeData()->text()); 176 | if ( col.isValid() ) 177 | { 178 | setColor(col); 179 | event->accept(); 180 | } 181 | } 182 | } 183 | 184 | } // namespace color_widgets 185 | -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/color_utils.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #include "QtColorWidgets/color_utils.hpp" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | QColor color_widgets::utils::color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha ) 30 | { 31 | qreal h1 = hue*6; 32 | qreal x = chroma*(1-qAbs(std::fmod(h1,2)-1)); 33 | QColor col; 34 | if ( h1 >= 0 && h1 < 1 ) 35 | col = QColor::fromRgbF(chroma,x,0); 36 | else if ( h1 < 2 ) 37 | col = QColor::fromRgbF(x,chroma,0); 38 | else if ( h1 < 3 ) 39 | col = QColor::fromRgbF(0,chroma,x); 40 | else if ( h1 < 4 ) 41 | col = QColor::fromRgbF(0,x,chroma); 42 | else if ( h1 < 5 ) 43 | col = QColor::fromRgbF(x,0,chroma); 44 | else if ( h1 < 6 ) 45 | col = QColor::fromRgbF(chroma,0,x); 46 | 47 | qreal m = luma - color_lumaF(col); 48 | 49 | return QColor::fromRgbF( 50 | qBound(0.0,col.redF()+m,1.0), 51 | qBound(0.0,col.greenF()+m,1.0), 52 | qBound(0.0,col.blueF()+m,1.0), 53 | alpha); 54 | } 55 | 56 | QColor color_widgets::utils::color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha ) 57 | { 58 | qreal chroma = (1 - qAbs(2*lig-1))*sat; 59 | qreal h1 = hue*6; 60 | qreal x = chroma*(1-qAbs(std::fmod(h1,2)-1)); 61 | QColor col; 62 | if ( h1 >= 0 && h1 < 1 ) 63 | col = QColor::fromRgbF(chroma,x,0); 64 | else if ( h1 < 2 ) 65 | col = QColor::fromRgbF(x,chroma,0); 66 | else if ( h1 < 3 ) 67 | col = QColor::fromRgbF(0,chroma,x); 68 | else if ( h1 < 4 ) 69 | col = QColor::fromRgbF(0,x,chroma); 70 | else if ( h1 < 5 ) 71 | col = QColor::fromRgbF(x,0,chroma); 72 | else if ( h1 < 6 ) 73 | col = QColor::fromRgbF(chroma,0,x); 74 | 75 | qreal m = lig-chroma/2; 76 | 77 | return QColor::fromRgbF( 78 | qBound(0.0,col.redF()+m,1.0), 79 | qBound(0.0,col.greenF()+m,1.0), 80 | qBound(0.0,col.blueF()+m,1.0), 81 | alpha); 82 | } 83 | 84 | 85 | QColor color_widgets::utils::get_screen_color(const QPoint &global_pos) 86 | { 87 | QScreen *screen = QApplication::screenAt(global_pos); 88 | 89 | WId wid = QApplication::desktop()->winId(); 90 | QImage img = screen->grabWindow(wid, global_pos.x(), global_pos.y(), 1, 1).toImage(); 91 | 92 | return img.pixel(0,0); 93 | } 94 | -------------------------------------------------------------------------------- /src/lib/src/QtColorWidgets/hue_slider.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2014 Calle Laakkonen 7 | * \copyright Copyright (C) 2013-2020 Mattia Basaglia 8 | * \copyright Copyright (C) 2017 caryoscelus 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program. If not, see . 22 | * 23 | */ 24 | #include "QtColorWidgets/hue_slider.hpp" 25 | 26 | namespace color_widgets { 27 | 28 | class HueSlider::Private 29 | { 30 | private: 31 | HueSlider *w; 32 | 33 | public: 34 | qreal saturation = 1; 35 | qreal value = 1; 36 | qreal alpha = 1; 37 | 38 | Private(HueSlider *widget) 39 | : w(widget) 40 | { 41 | w->setRange(0, 359); 42 | connect(w, &QSlider::valueChanged, [this]{ 43 | Q_EMIT w->colorHueChanged(w->colorHue()); 44 | Q_EMIT w->colorChanged(w->color()); 45 | }); 46 | updateGradient(); 47 | } 48 | 49 | void updateGradient() 50 | { 51 | static const double n_colors = 6; 52 | QGradientStops colors; 53 | colors.reserve(n_colors+1); 54 | for ( int i = 0; i <= n_colors; ++i ) 55 | colors.append(QGradientStop(i/n_colors, QColor::fromHsvF(i/n_colors, saturation, value))); 56 | w->setColors(colors); 57 | } 58 | }; 59 | 60 | HueSlider::HueSlider(QWidget *parent) : 61 | GradientSlider(parent), p(new Private(this)) 62 | { 63 | } 64 | 65 | HueSlider::HueSlider(Qt::Orientation orientation, QWidget *parent) : 66 | GradientSlider(orientation, parent), p(new Private(this)) 67 | { 68 | } 69 | 70 | HueSlider::~HueSlider() 71 | { 72 | delete p; 73 | } 74 | 75 | qreal HueSlider::colorSaturation() const 76 | { 77 | return p->saturation; 78 | } 79 | 80 | void HueSlider::setColorSaturation(qreal s) 81 | { 82 | p->saturation = qBound(0.0, s, 1.0); 83 | p->updateGradient(); 84 | Q_EMIT colorSaturationChanged(s); 85 | } 86 | 87 | qreal HueSlider::colorValue() const 88 | { 89 | return p->value; 90 | } 91 | 92 | void HueSlider::setColorValue(qreal v) 93 | { 94 | p->value = qBound(0.0, v, 1.0); 95 | p->updateGradient(); 96 | Q_EMIT colorValueChanged(v); 97 | } 98 | 99 | qreal HueSlider::colorAlpha() const 100 | { 101 | return p->alpha; 102 | } 103 | 104 | void HueSlider::setColorAlpha(qreal alpha) 105 | { 106 | p->alpha = alpha; 107 | p->updateGradient(); 108 | Q_EMIT colorAlphaChanged(alpha); 109 | } 110 | 111 | QColor HueSlider::color() const 112 | { 113 | return QColor::fromHsvF(colorHue(), p->saturation, p->value, p->alpha); 114 | } 115 | 116 | void HueSlider::setColor(const QColor& color) 117 | { 118 | p->saturation = color.saturationF(); 119 | p->value = color.valueF(); 120 | p->updateGradient(); 121 | setColorHue(color.hueF()); 122 | Q_EMIT colorValueChanged(p->alpha); 123 | Q_EMIT colorSaturationChanged(p->alpha); 124 | } 125 | 126 | void HueSlider::setFullColor(const QColor& color) 127 | { 128 | p->alpha = color.alphaF(); 129 | setColor(color); 130 | Q_EMIT colorAlphaChanged(p->alpha); 131 | } 132 | 133 | qreal HueSlider::colorHue() const 134 | { 135 | if (maximum() == minimum()) 136 | return 0; 137 | auto hue = qreal(value() - minimum()) / (maximum() - minimum()); 138 | if (orientation() == Qt::Vertical) 139 | hue = 1 - hue; 140 | return hue; 141 | } 142 | 143 | void HueSlider::setColorHue(qreal colorHue) 144 | { 145 | // TODO: consider supporting invertedAppearance? 146 | if (orientation() == Qt::Vertical) 147 | colorHue = 1 - colorHue; 148 | setValue(minimum()+colorHue*(maximum()-minimum())); 149 | Q_EMIT colorHueChanged(colorHue); 150 | Q_EMIT colorChanged(color()); 151 | } 152 | 153 | } // namespace color_widgets 154 | -------------------------------------------------------------------------------- /src/light/branch_closed-on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/branch_closed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/branch_open-on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/branch_open.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/checkbox_checked-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/checkbox_checked.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/checkbox_checked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/checkbox_indeterminate-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/light/checkbox_indeterminate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/light/checkbox_indeterminate_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/light/checkbox_unchecked-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/light/checkbox_unchecked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/light/close-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/close-pressed.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/down_arrow-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/down_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/down_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/hmovetoolbar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/hsepartoolbar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/left_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/left_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/radio_checked-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/radio_checked.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/radio_checked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/radio_unchecked-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/light/radio_unchecked_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/light/right_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/right_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/sizegrip.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/spinup_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/stylesheet-branch-end.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/light/stylesheet-branch-more.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/light/stylesheet-vline.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/transparent.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/light/undock-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/light/undock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/up_arrow-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/up_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/up_arrow_disabled.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/light/vmovetoolbar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/light/vsepartoolbars.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | 11 | //NOTE: DISABLE Qt Quick Compiler in Project sttings if resources not loading in Release mode 12 | 13 | static inline QString host(const QHttpServerRequest &request) 14 | { 15 | return request.headers()[QStringLiteral("Host")].toString(); 16 | } 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | QApplication a(argc, argv); 21 | QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 22 | QApplication::setApplicationName("ColorPie"); 23 | QApplication::setOrganizationName("org.keshavnrj.ubuntu"); 24 | QCoreApplication::setApplicationVersion("1"); 25 | 26 | qputenv("QTWEBENGINE_CHROMIUM_FLAGS","--single-process"); 27 | #ifdef QT_DEBUG 28 | qputenv("QTWEBENGINE_CHROMIUM_FLAGS","--remote-debugging-port=9421"); 29 | #endif 30 | qputenv("QTWEBENGINE_CHROMIUM_FLAGS","--no-sandbox"); 31 | 32 | static const char ENV_VAR_QT_DEVICE_PIXEL_RATIO[] = "QT_DEVICE_PIXEL_RATIO"; 33 | if (!qEnvironmentVariableIsSet(ENV_VAR_QT_DEVICE_PIXEL_RATIO) 34 | && !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR") 35 | && !qEnvironmentVariableIsSet("QT_SCALE_FACTOR") 36 | && !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) { 37 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 38 | } 39 | 40 | QHttpServer httpServer; 41 | 42 | httpServer.route("/", [] (const QUrl &url) { 43 | if(url.isEmpty()){ 44 | return QHttpServerResponse::fromFile(QStringLiteral(":/html/%1").arg("v2.html")); 45 | }else{ 46 | //qDebug()<", [] (const QUrl &url) { 52 | //qDebug()< 5 | #include 6 | #include 7 | 8 | MainWindow::MainWindow(QWidget *parent,QString serverBase) : 9 | QMainWindow(parent), 10 | ui(new Ui::MainWindow) 11 | { 12 | ui->setupUi(this); 13 | initColor = QColor("#00a"); 14 | home = serverBase; 15 | this->setWindowIcon(QIcon(":/icons/icon-256.png")); 16 | this->setWindowTitle(qApp->applicationName()+" v"+qApp->applicationVersion()); 17 | 18 | connect(ui->webView,&QWebEngineView::loadFinished,[=](const bool loaded){ 19 | if(loaded && !app_init){ 20 | loadColor(initColor.name()); 21 | managerWidget->setFromHex6(initColor.name()); 22 | app_init = true; 23 | } 24 | }); 25 | 26 | QWebEngineProfile *weProfile = new QWebEngineProfile(QApplication::applicationName(),this); 27 | 28 | QWebEnginePage *webenginepage = new QWebEnginePage(weProfile, this); 29 | webenginepage->setBackgroundColor(QColor("#EFF0F1")); 30 | 31 | connect(webenginepage,&QWebEnginePage::titleChanged,[=](const QString titleStr){ 32 | this->setWindowTitle(QApplication::applicationName()+" | "+QString(titleStr)); 33 | QString hex6 = QString(titleStr).split(">>").last().simplified().trimmed(); 34 | QColor color("#"+hex6); 35 | if(color.isValid()) 36 | managerWidget->setFromHex6("#"+hex6); 37 | }); 38 | 39 | webenginepage->settings()->setAttribute(QWebEngineSettings::ShowScrollBars,false); 40 | 41 | //page should be set parent of profile to prevent 42 | //Release of profile requested but WebEnginePage still not deleted. Expect troubles ! 43 | weProfile->setParent(webenginepage); 44 | 45 | ui->webView->setPage(webenginepage); 46 | setStyle(":/light.qss"); 47 | 48 | ui->webView->setMinimumSize(500,500); 49 | 50 | managerWidget = new Manager(this); 51 | managerWidget->setMinimumSize(350,managerWidget->minimumSizeHint().height()); 52 | 53 | managerWidget->initialize(initColor); 54 | connect(managerWidget,&Manager::colorChanged,[=](QString colorName){ 55 | loadColor(colorName); 56 | }); 57 | 58 | QSplitter *split1 = new QSplitter; 59 | split1->setObjectName("split1"); 60 | split1->setOrientation(Qt::Horizontal); 61 | split1->addWidget(managerWidget); 62 | split1->addWidget(ui->webviewWidget); 63 | split1->setStretchFactor(0,2); 64 | split1->setStretchFactor(1,2); 65 | ui->centralWidget->layout()->addWidget(split1); 66 | if(settings.value("geometry").isValid()){ 67 | restoreGeometry(settings.value("geometry").toByteArray()); 68 | restoreState(settings.value("windowState").toByteArray()); 69 | } 70 | ui->webviewWidget->layout()->setContentsMargins(9,0,0,0); 71 | ui->webView->load(QUrl(serverBase)); 72 | } 73 | void MainWindow::loadColor(QString colorStr) 74 | { 75 | QString js = "document.getElementById('color').value = '"+colorStr+"';" 76 | "var event = new Event('keyup');" 77 | "document.getElementById('color').dispatchEvent(event);" 78 | "delete event;"; 79 | ui->webView->page()->runJavaScript(js); 80 | } 81 | 82 | void MainWindow::closeEvent(QCloseEvent *event) 83 | { 84 | settings.setValue("geometry",saveGeometry()); 85 | settings.setValue("windowState", saveState()); 86 | managerWidget->saveColors(); 87 | QMainWindow::closeEvent(event); 88 | } 89 | 90 | void MainWindow::setStyle(QString fname) 91 | { 92 | QFile styleSheet(fname); 93 | if (!styleSheet.open(QIODevice::ReadOnly)) { 94 | qWarning("Unable to open file"); 95 | return; } 96 | qApp->setStyleSheet(styleSheet.readAll()); 97 | styleSheet.close(); 98 | } 99 | 100 | MainWindow::~MainWindow() 101 | { 102 | delete ui; 103 | } 104 | 105 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include "manager.h" 16 | 17 | namespace Ui { 18 | class MainWindow; 19 | } 20 | 21 | class MainWindow : public QMainWindow 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit MainWindow(QWidget *parent = nullptr,QString serverBase=""); 27 | ~MainWindow(); 28 | 29 | protected slots: 30 | void closeEvent(QCloseEvent *event); 31 | private slots: 32 | void setStyle(QString fname); 33 | void loadColor(QString colorStr); 34 | private: 35 | Ui::MainWindow *ui; 36 | QString home; 37 | QSettings settings; 38 | bool app_init = false; 39 | Manager * managerWidget = nullptr; 40 | QColor initColor; 41 | 42 | }; 43 | 44 | #endif // MAINWINDOW_H 45 | -------------------------------------------------------------------------------- /src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 0 20 | 21 | 22 | 0 23 | 24 | 25 | 0 26 | 27 | 28 | 0 29 | 30 | 31 | 32 | 33 | 34 | 0 35 | 36 | 37 | 0 38 | 39 | 40 | 0 41 | 42 | 43 | 0 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | QWebEngineView 62 | QWidget 63 |
QtWebEngineWidgets/QWebEngineView
64 | 1 65 |
66 |
67 | 68 | 69 |
70 | -------------------------------------------------------------------------------- /src/manager.cpp: -------------------------------------------------------------------------------- 1 | #include "manager.h" 2 | #include "ui_manager.h" 3 | 4 | using namespace color_widgets; 5 | 6 | Manager::Manager(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Manager) 9 | { 10 | ui->setupUi(this); 11 | 12 | colorDialog = new ColorDialog(this); 13 | colorListWidget = new ColorListWidget(this); 14 | 15 | connect(colorListWidget,&ColorListWidget::colorsChanged,[=](const QList&colorList){ 16 | colorCollection = colorList; 17 | }); 18 | 19 | colorDialog->layout()->setContentsMargins(0,0,0,0); 20 | colorDialog->setButtonMode(ColorDialog::NoButton); 21 | colorDialog->setPreviewDisplayMode(ColorPreview::AllAlpha); 22 | 23 | //gridLayout modifications 24 | QGridLayout *gridLayout = colorDialog->findChild("gridLayout"); 25 | gridLayout->setContentsMargins(0,0,0,0); 26 | gridLayout->setSpacing(0); 27 | for (int i = 0; i < gridLayout->count(); ++i) { 28 | setLayoutVisible(gridLayout->itemAt(i),false); 29 | } 30 | 31 | connect(colorDialog,&ColorDialog::colorChanged,[=](const QColor color){ 32 | Q_EMIT colorChanged(color.name()); 33 | colorListWidget->setColor(color); 34 | }); 35 | 36 | ui->colorBoxLayout->addWidget(colorDialog); 37 | ui->savedColorsBoxLayout->addWidget(colorListWidget); 38 | 39 | loadColors(); 40 | } 41 | 42 | //helper 43 | void Manager::setLayoutVisible(QLayoutItem *item, bool visible) 44 | { 45 | if (auto widget = item->widget()) 46 | return widget->setVisible(visible); 47 | if (auto layout = item->layout()) 48 | for (int i = 0; i < layout->count(); ++i) 49 | setLayoutVisible(layout->itemAt(i), visible); 50 | } 51 | 52 | void Manager::setFromHex6(QString hex6) 53 | { 54 | colorDialog->blockSignals(true); 55 | colorDialog->setColor(QColor(hex6)); 56 | colorListWidget->setColor(QColor(hex6)); 57 | colorDialog->blockSignals(false); 58 | } 59 | 60 | void Manager::initialize(QColor color) 61 | { 62 | ui->colorControl->setText(color.name()); 63 | } 64 | 65 | Manager::~Manager() 66 | { 67 | delete ui; 68 | } 69 | 70 | void Manager::on_colorControl_textChanged(const QString &arg1) 71 | { 72 | Q_EMIT colorChanged(arg1); 73 | if(arg1.length()==7){ 74 | QColor color(arg1); 75 | if(color.isValid()){ 76 | colorDialog->setColor(color); 77 | } 78 | } 79 | } 80 | 81 | void Manager::on_supportedInputs_clicked() 82 | { 83 | SupportedInputs *sup = new SupportedInputs(this); 84 | sup->setWindowTitle(QApplication::applicationName()+" | "+"Supported Input"); 85 | sup->setAttribute(Qt::WA_DeleteOnClose); 86 | sup->show(); 87 | } 88 | 89 | void Manager::saveColors() 90 | { 91 | QJsonArray dataArray; 92 | foreach (auto color, colorCollection) { 93 | dataArray.append(QJsonValue(color.name())); 94 | } 95 | QJsonDocument doc(dataArray); 96 | QString filepath = utils::returnPath("savedColors")+QDir::separator()+"colors.json"; 97 | utils::saveJson(doc,filepath); 98 | } 99 | 100 | void Manager::loadColors() 101 | { 102 | QString filepath = utils::returnPath("savedColors")+QDir::separator()+"colors.json"; 103 | QJsonDocument doc = utils::loadJson(filepath); 104 | if(doc.isNull()==false){ 105 | QJsonArray dataArray = doc.array(); 106 | foreach (auto color, dataArray) { 107 | colorCollection.append(QColor(color.toString())); 108 | } 109 | } 110 | colorListWidget->setColors(colorCollection); 111 | } 112 | -------------------------------------------------------------------------------- /src/manager.h: -------------------------------------------------------------------------------- 1 | #ifndef MANAGER_H 2 | #define MANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "QtColorWidgets/color_line_edit.hpp" 15 | #include "QtColorWidgets/ColorPreview" 16 | #include "QtColorWidgets/ColorDialog" 17 | #include "QtColorWidgets/ColorListWidget" 18 | 19 | #include "utils.h" 20 | #include "supportedinputs.h" 21 | 22 | namespace Ui { 23 | class Manager; 24 | } 25 | 26 | class Manager : public QWidget 27 | { 28 | Q_OBJECT 29 | 30 | signals: 31 | void colorChanged(QString colorName); 32 | 33 | public: 34 | explicit Manager(QWidget *parent = nullptr); 35 | ~Manager(); 36 | 37 | public slots: 38 | void initialize(QColor color); 39 | void setFromHex6(QString hex6); 40 | void saveColors(); 41 | 42 | private slots: 43 | void on_colorControl_textChanged(const QString &arg1); 44 | 45 | void on_supportedInputs_clicked(); 46 | 47 | void setLayoutVisible(QLayoutItem *item, bool visible); 48 | void loadColors(); 49 | private: 50 | Ui::Manager *ui; 51 | 52 | 53 | color_widgets::ColorLineEdit *colorLineEdit = nullptr; 54 | color_widgets::ColorDialog * colorDialog = nullptr; 55 | color_widgets::ColorListWidget * colorListWidget = nullptr; 56 | 57 | QList colorCollection; 58 | QSettings settings; 59 | 60 | }; 61 | 62 | #endif // MANAGER_H 63 | -------------------------------------------------------------------------------- /src/manager.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Manager 4 | 5 | 6 | 7 | 0 8 | 0 9 | 449 10 | 363 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 0 25 | 280 26 | 27 | 28 | 29 | Color chooser 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Input color name or code 38 | 39 | 40 | 41 | 42 | 43 | 44 | Supported inputs 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Saved Colors 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/icon-16.png 4 | icons/icon-32.png 5 | icons/icon-64.png 6 | icons/icon-128.png 7 | icons/icon-512.png 8 | icons/others/close-fill.png 9 | icons/others/delete-bin-5-line.png 10 | icons/others/error-warning-line.png 11 | icons/others/eye-line.png 12 | icons/others/file-copy-line.png 13 | icons/others/file-text-line.png 14 | icons/others/file-unknow-line.png 15 | icons/others/folder-open-line.png 16 | icons/others/information-line.png 17 | icons/others/links-line.png 18 | icons/others/link-unlink-m.png 19 | icons/others/paypal-line.png 20 | icons/others/star-line.png 21 | html/jtm/jquery.tinymodal.css 22 | html/jtm/jquery.tinymodal.js 23 | html/toastr/toastr.min.css 24 | html/toastr/toastr.min.js 25 | html/favicon.ico 26 | html/icon-128.png 27 | html/icon-64.png 28 | html/index.js 29 | html/jquery-3.5.1.min.js 30 | html/texture.png 31 | html/v2/app.0f8e8639.js 32 | html/v2/app.9d39357a.css 33 | html/v2/bootstrap.min.css 34 | html/v2/chunk-vendors.4a7ab7d0.js 35 | html/v2.html 36 | icons/icon-256.png 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/supportedinputs.cpp: -------------------------------------------------------------------------------- 1 | #include "supportedinputs.h" 2 | #include "ui_supportedinputs.h" 3 | 4 | SupportedInputs::SupportedInputs(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::SupportedInputs) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | SupportedInputs::~SupportedInputs() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /src/supportedinputs.h: -------------------------------------------------------------------------------- 1 | #ifndef SUPPORTEDINPUTS_H 2 | #define SUPPORTEDINPUTS_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class SupportedInputs; 8 | } 9 | 10 | class SupportedInputs : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit SupportedInputs(QWidget *parent = nullptr); 16 | ~SupportedInputs(); 17 | 18 | private: 19 | Ui::SupportedInputs *ui; 20 | }; 21 | 22 | #endif // SUPPORTEDINPUTS_H 23 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | class utils : public QObject 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | utils(QObject* parent=0); 19 | virtual ~utils(); 20 | public slots: 21 | static bool splitString(const QString &str, int m, QStringList &list); 22 | static QString refreshCacheSize(const QString cache_dir); 23 | bool delete_cache(const QString cache_dir); 24 | static QString toCamelCase(const QString &s); 25 | static QString upperFirstChar(const QString &s); 26 | static QString generateRandomId(int length); 27 | static QString convertSectoDay(qint64 secs); 28 | static QString returnPath(QString pathname); 29 | static QString randomIpV6(); 30 | 31 | 32 | static QString EncodeXML ( const QString& encodeMe ){ 33 | 34 | QString temp; 35 | int length = encodeMe.size(); 36 | for (int index = 0; index < length; index++) 37 | { 38 | QChar character(encodeMe.at(index)); 39 | 40 | switch (character.unicode()) 41 | { 42 | case '&': 43 | temp += "&"; break; 44 | 45 | case '\'': 46 | temp += "'"; break; 47 | 48 | case '"': 49 | temp += """; break; 50 | 51 | case '<': 52 | temp += "<"; break; 53 | 54 | case '>': 55 | temp += ">"; break; 56 | 57 | default: 58 | temp += character; 59 | break; 60 | } 61 | } 62 | 63 | return temp; 64 | } 65 | 66 | static QString DecodeXML ( const QString& decodeMe ) { 67 | 68 | QString temp(decodeMe); 69 | 70 | temp.replace("&", "&"); 71 | temp.replace("'", "'"); 72 | temp.replace(""", "\""); 73 | temp.replace("<", "<"); 74 | temp.replace(">", ">"); 75 | 76 | return temp; 77 | } 78 | 79 | static QString htmlToPlainText(QString str); 80 | static QString removeNodeColor(QString input); 81 | static QString humanReadableSize(double bytes); 82 | static bool isMedia(QString filename); //both video or audio 83 | static bool isVideo(QString filename); 84 | static bool isAudio(QString filename); 85 | static bool isImage(QString filename); 86 | static QString cleanString(QString input); 87 | static QString genRand(int length); 88 | static void saveJson(QJsonDocument document, QString fileName); 89 | static QJsonDocument loadJson(QString fileName); 90 | 91 | 92 | 93 | private slots: 94 | //use refreshCacheSize 95 | static quint64 dir_size(const QString &directory); 96 | 97 | }; 98 | 99 | #endif // UTILS_H 100 | --------------------------------------------------------------------------------