diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 351cfc2..507eb86 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -106,7 +106,7 @@ macro(qad_project NAME _MODULES _LIBS) endif() endmacro() -set(DIRS utils widgets application blockview graphic sql_table touch_widgets) +set(DIRS utils widgets application blockview graphic sql_table touch_widgets styles) foreach(D ${DIRS}) list(APPEND QT_MULTILIB_LIST qad_${D}) endforeach(D) diff --git a/qad/styles/CMakeLists.txt b/qad/styles/CMakeLists.txt new file mode 100644 index 0000000..7d5c85d --- /dev/null +++ b/qad/styles/CMakeLists.txt @@ -0,0 +1,2 @@ +qad_project(styles "Gui;Widgets" "") + diff --git a/qad/styles/DarkStyle.cpp b/qad/styles/DarkStyle.cpp new file mode 100644 index 0000000..8b31bf7 --- /dev/null +++ b/qad/styles/DarkStyle.cpp @@ -0,0 +1,73 @@ +/* +############################################################################### +# # +# The MIT License # +# # +# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) # +# >> https://github.com/Jorgen-VikingGod # +# # +# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle # +# # +############################################################################### +*/ + +#include "DarkStyle.h" + +DarkStyle::DarkStyle() : DarkStyle(styleBase()) {} + +DarkStyle::DarkStyle(QStyle *style) : QProxyStyle(style) {} + +QStyle *DarkStyle::styleBase(QStyle *style) const { + static QStyle *base = + !style ? QStyleFactory::create(QStringLiteral("Fusion")) : style; + return base; +} + +QStyle *DarkStyle::baseStyle() const { return styleBase(); } + +void DarkStyle::polish(QPalette &palette) { + // modify palette to dark + palette.setColor(QPalette::Window, QColor(53, 53, 53)); + palette.setColor(QPalette::WindowText, Qt::white); + palette.setColor(QPalette::Disabled, QPalette::WindowText, + QColor(127, 127, 127)); + palette.setColor(QPalette::Base, QColor(42, 42, 42)); + palette.setColor(QPalette::AlternateBase, QColor(66, 66, 66)); + palette.setColor(QPalette::ToolTipBase, Qt::white); + palette.setColor(QPalette::ToolTipText, QColor(53, 53, 53)); + palette.setColor(QPalette::Text, Qt::white); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127)); + palette.setColor(QPalette::Dark, QColor(35, 35, 35)); + palette.setColor(QPalette::Shadow, QColor(20, 20, 20)); + palette.setColor(QPalette::Button, QColor(53, 53, 53)); + palette.setColor(QPalette::ButtonText, Qt::white); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, + QColor(127, 127, 127)); + palette.setColor(QPalette::BrightText, Qt::red); + palette.setColor(QPalette::Link, QColor(42, 130, 218)); + palette.setColor(QPalette::Highlight, QColor(42, 130, 218)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80)); + palette.setColor(QPalette::HighlightedText, Qt::white); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, + QColor(127, 127, 127)); +} + +void DarkStyle::polish(QApplication *app) { + if (!app) return; + + // increase font size for better reading, + // setPointSize was reduced from +2 because when applied this way in Qt5, the + // font is larger than intended for some reason + QFont defaultFont = QApplication::font(); + defaultFont.setPointSize(defaultFont.pointSize() + 1); + app->setFont(defaultFont); + + // loadstylesheet + QFile qfDarkstyle(QStringLiteral(":/darkstyle/darkstyle.qss")); + if (qfDarkstyle.open(QIODevice::ReadOnly | QIODevice::Text)) { + // set stylesheet + QString qsStylesheet = QString::fromLatin1(qfDarkstyle.readAll()); + app->setStyleSheet(qsStylesheet); + qfDarkstyle.close(); + } +} diff --git a/qad/styles/DarkStyle.h b/qad/styles/DarkStyle.h new file mode 100644 index 0000000..51afac1 --- /dev/null +++ b/qad/styles/DarkStyle.h @@ -0,0 +1,39 @@ +/* +############################################################################### +# # +# The MIT License # +# # +# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) # +# >> https://github.com/Jorgen-VikingGod # +# # +# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle # +# # +############################################################################### +*/ + +#ifndef DARKSTYLE_HPP +#define DARKSTYLE_HPP + +#include +#include +#include +#include +#include + +class DarkStyle : public QProxyStyle { + Q_OBJECT + + public: + DarkStyle(); + explicit DarkStyle(QStyle *style); + + QStyle *baseStyle() const; + + void polish(QPalette &palette) override; + void polish(QApplication *app) override; + + private: + QStyle *styleBase(QStyle *style = Q_NULLPTR) const; +}; + +#endif // DARKSTYLE_HPP diff --git a/qad/styles/darkstyle.qrc b/qad/styles/darkstyle.qrc new file mode 100644 index 0000000..1bcbdf7 --- /dev/null +++ b/qad/styles/darkstyle.qrc @@ -0,0 +1,28 @@ + + + darkstyle/darkstyle.qss + darkstyle/icon_close.png + darkstyle/icon_restore.png + darkstyle/icon_undock.png + darkstyle/icon_branch_closed.png + darkstyle/icon_branch_end.png + darkstyle/icon_branch_more.png + darkstyle/icon_branch_open.png + darkstyle/icon_vline.png + darkstyle/icon_checkbox_checked.png + darkstyle/icon_checkbox_indeterminate.png + darkstyle/icon_checkbox_unchecked.png + darkstyle/icon_checkbox_checked_pressed.png + darkstyle/icon_checkbox_indeterminate_pressed.png + darkstyle/icon_checkbox_unchecked_pressed.png + darkstyle/icon_checkbox_checked_disabled.png + darkstyle/icon_checkbox_indeterminate_disabled.png + darkstyle/icon_checkbox_unchecked_disabled.png + darkstyle/icon_radiobutton_checked.png + darkstyle/icon_radiobutton_unchecked.png + darkstyle/icon_radiobutton_checked_pressed.png + darkstyle/icon_radiobutton_unchecked_pressed.png + darkstyle/icon_radiobutton_checked_disabled.png + darkstyle/icon_radiobutton_unchecked_disabled.png + + diff --git a/qad/styles/darkstyle/darkstyle.qss b/qad/styles/darkstyle/darkstyle.qss new file mode 100644 index 0000000..3141b86 --- /dev/null +++ b/qad/styles/darkstyle/darkstyle.qss @@ -0,0 +1,343 @@ +QToolTip{ + color:#ffffff; + background-color:palette(base); + border:1px solid palette(highlight); + border-radius:4px; +} +QStatusBar{ + background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + color:palette(mid); +} +QMenuBar{ + background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border-bottom:2px solid rgba(25,25,25,75); +} +QMenuBar::item{ + spacing:2px; + padding:3px 4px; + background:transparent; +} +QMenuBar::item:selected{ + background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(106,106,106,255),stop:1 rgba(106,106,106,75)); + border-left:1px solid rgba(106,106,106,127); + border-right:1px solid rgba(106,106,106,127); +} +QMenuBar::item:pressed{ + background-color:palette(highlight); + border-left:1px solid rgba(25,25,25,127); + border-right:1px solid rgba(25,25,25,127); +} +QMenu{ + background-color:palette(window); + border:1px solid palette(shadow); +} +QMenu::item{ + padding:3px 25px 3px 25px; + border:1px solid transparent; +} +QMenu::item:disabled{ + background-color:rgba(35,35,35,127); + color:palette(disabled); +} +QMenu::item:selected{ + border-color:rgba(147,191,236,127); + background:palette(highlight); +} +QMenu::icon:checked{ + background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border:1px solid palette(highlight); + border-radius:2px; +} +QMenu::separator{ + height:1px; + background:palette(alternate-base); + margin-left:5px; + margin-right:5px; +} +QMenu::indicator{ + width:18px; + height:18px; +} +QMenu::indicator:non-exclusive:checked{ + image:url(:/darkstyle/icon_checkbox_checked.png); + padding-left:2px; +} +QMenu::indicator:non-exclusive:unchecked{ + image:url(:/darkstyle/icon_checkbox_unchecked.png); + padding-left:2px; +} +QMenu::indicator:exclusive:checked{ + image:url(:/darkstyle/icon_radiobutton_checked.png); + padding-left:2px; +} +QMenu::indicator:exclusive:unchecked{ + image:url(:/darkstyle/icon_radiobutton_unchecked.png); + padding-left:2px; +} +QToolBar::top{ + background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border-bottom:3px solid qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); +} +QToolBar::bottom{ + background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border-top:3px solid qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); +} +QToolBar::left{ + background-color:qlineargradient(x1:0,y1:0,x2:1,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border-right:3px solid qlineargradient(x1:0,y1:0,x2:1,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); +} +QToolBar::right{ + background-color:qlineargradient(x1:1,y1:0,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border-left:3px solid qlineargradient(x1:1,y1:0,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); +} +QMainWindow::separator{ + width:6px; + height:5px; + padding:2px; +} +QSplitter::handle:horizontal{ + width:10px; +} +QSplitter::handle:vertical{ + height:10px; +} +QMainWindow::separator:hover,QSplitter::handle:hover{ + background:palette(highlight); +} +QDockWidget::title{ + padding:4px; + background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border:1px solid rgba(25,25,25,75); + border-bottom:2px solid rgba(25,25,25,75); +} +QDockWidget{ + titlebar-close-icon:url(:/darkstyle/icon_close.png); + titlebar-normal-icon:url(:/darkstyle/icon_restore.png); +} +QDockWidget::close-button,QDockWidget::float-button{ + subcontrol-position:top right; + subcontrol-origin:margin; + position:absolute; + top:3px; + bottom:0px; + width:20px; + height:20px; +} +QDockWidget::close-button{ + right:3px; +} +QDockWidget::float-button{ + right:25px; +} +QGroupBox{ + background-color:rgba(66,66,66,50%); + margin-top:27px; + border:1px solid rgba(25,25,25,127); + border-radius:4px; +} +QGroupBox::title{ + subcontrol-origin:margin; + subcontrol-position:left top; + padding:4px 6px; + margin-left:3px; + background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border:1px solid rgba(25,25,25,75); + border-bottom:2px solid rgb(127,127,127); + border-top-left-radius:4px; + border-top-right-radius:4px; +} +QTabWidget::pane{ + background-color:rgba(66,66,66,50%); + border-top:1px solid rgba(25,25,25,50%); +} +QTabWidget::tab-bar{ + left:3px; + top:1px; +} +QTabBar{ + background-color:transparent; + qproperty-drawBase:0; + border-bottom:1px solid rgba(25,25,25,50%); +} +QTabBar::tab{ + padding:4px 6px; + background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border:1px solid rgba(25,25,25,75); + border-top-left-radius:4px; + border-top-right-radius:4px; +} +QTabBar::tab:selected,QTabBar::tab:hover{ + background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(53,53,53,127),stop:1 rgba(66,66,66,50%)); + border-bottom-color:rgba(66,66,66,75%); +} +QTabBar::tab:selected{ + border-bottom:2px solid palette(highlight); +} +QTabBar::tab::selected:disabled{ + border-bottom:2px solid rgb(127,127,127); +} +QTabBar::tab:!selected{ + margin-top:2px; +} +QCheckBox::indicator{ + width:18px; + height:18px; +} +QCheckBox::indicator:checked,QTreeView::indicator:checked,QTableView::indicator:checked,QGroupBox::indicator:checked{ + image:url(:/darkstyle/icon_checkbox_checked.png); +} +QCheckBox::indicator:checked:pressed,QTreeView::indicator:checked:pressed,QTableView::indicator:checked:pressed,QGroupBox::indicator:checked:pressed{ + image:url(:/darkstyle/icon_checkbox_checked_pressed.png); +} +QCheckBox::indicator:checked:disabled,QTreeView::indicator:checked:disabled,QTableView::indicator:checked:disabled,QGroupBox::indicator:checked:disabled{ + image:url(:/darkstyle/icon_checkbox_checked_disabled.png); +} +QCheckBox::indicator:unchecked,QTreeView::indicator:unchecked,QTableView::indicator:unchecked,QGroupBox::indicator:unchecked{ + image:url(:/darkstyle/icon_checkbox_unchecked.png); +} +QCheckBox::indicator:unchecked:pressed,QTreeView::indicator:unchecked:pressed,QTableView::indicator:unchecked:pressed,QGroupBox::indicator:unchecked:pressed{ + image:url(:/darkstyle/icon_checkbox_unchecked_pressed.png); +} +QCheckBox::indicator:unchecked:disabled,QTreeView::indicator:unchecked:disabled,QTableView::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled{ + image:url(:/darkstyle/icon_checkbox_unchecked_disabled.png); +} +QCheckBox::indicator:indeterminate,QTreeView::indicator:indeterminate,QTableView::indicator:indeterminate,QGroupBox::indicator:indeterminate{ + image:url(:/darkstyle/icon_checkbox_indeterminate.png); +} +QCheckBox::indicator:indeterminate:pressed,QTreeView::indicator:indeterminate:pressed,QTableView::indicator:indeterminate:pressed,QGroupBox::indicator:indeterminate:pressed{ + image:url(:/darkstyle/icon_checkbox_indeterminate_pressed.png); +} +QCheckBox::indicator:indeterminate:disabled,QTreeView::indicator:indeterminate:disabled,QTableView::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled{ + image:url(:/darkstyle/icon_checkbox_indeterminate_disabled.png); +} +QRadioButton::indicator{ + width:18px; + height:18px; +} +QRadioButton::indicator:checked{ + image:url(:/darkstyle/icon_radiobutton_checked.png); +} +QRadioButton::indicator:checked:pressed{ + image:url(:/darkstyle/icon_radiobutton_checked_pressed.png); +} +QRadioButton::indicator:checked:disabled{ + image:url(:/darkstyle/icon_radiobutton_checked_disabled.png); +} +QRadioButton::indicator:unchecked{ + image:url(:/darkstyle/icon_radiobutton_unchecked.png); +} +QRadioButton::indicator:unchecked:pressed{ + image:url(:/darkstyle/icon_radiobutton_unchecked_pressed.png); +} +QRadioButton::indicator:unchecked:disabled{ + image:url(:/darkstyle/icon_radiobutton_unchecked_disabled.png); +} +QTreeView, QTableView{ + alternate-background-color:palette(window); + background:palette(base); +} +QTreeView QHeaderView::section, QTableView QHeaderView::section{ + background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75)); + border-style:none; + border-bottom:1px solid palette(dark); + padding-left:5px; + padding-right:5px; +} +QTreeView::item:selected:disabled, QTableView::item:selected:disabled{ + background:rgb(80,80,80); +} +QTreeView::branch{ + background-color:palette(base); +} +QTreeView::branch:has-siblings:!adjoins-item{ + border-image:url(:/darkstyle/icon_vline.png) 0; +} +QTreeView::branch:has-siblings:adjoins-item{ + border-image:url(:/darkstyle/icon_branch_more.png) 0; +} +QTreeView::branch:!has-children:!has-siblings:adjoins-item{ + border-image:url(:/darkstyle/icon_branch_end.png) 0; +} +QTreeView::branch:has-children:!has-siblings:closed, +QTreeView::branch:closed:has-children:has-siblings{ + border-image:none; + image:url(:/darkstyle/icon_branch_closed.png); +} +QTreeView::branch:open:has-children:!has-siblings, +QTreeView::branch:open:has-children:has-siblings{ + border-image:none; + image:url(:/darkstyle/icon_branch_open.png); +} +QScrollBar:vertical{ + background:palette(base); + border-top-right-radius:2px; + border-bottom-right-radius:2px; + width:16px; + margin:0px; +} +QScrollBar::handle:vertical{ + background-color:palette(alternate-base); + border-radius:2px; + min-height:20px; + margin:2px 4px 2px 4px; +} +QScrollBar::handle:vertical:hover{ + background-color:palette(highlight); +} +QScrollBar::add-line:vertical{ + background:none; + height:0px; + subcontrol-position:right; + subcontrol-origin:margin; +} +QScrollBar::sub-line:vertical{ + background:none; + height:0px; + subcontrol-position:left; + subcontrol-origin:margin; +} +QScrollBar:horizontal{ + background:palette(base); + height:16px; + margin:0px; +} +QScrollBar::handle:horizontal{ + background-color:palette(alternate-base); + border-radius:2px; + min-width:20px; + margin:4px 2px 4px 2px; +} +QScrollBar::handle:horizontal:hover{ + background-color:palette(highlight); +} +QScrollBar::add-line:horizontal{ + background:none; + width:0px; + subcontrol-position:bottom; + subcontrol-origin:margin; +} +QScrollBar::sub-line:horizontal{ + background:none; + width:0px; + subcontrol-position:top; + subcontrol-origin:margin; +} +QSlider::handle:horizontal{ + border-radius:4px; + border:1px solid rgba(25,25,25,255); + background-color:palette(alternate-base); + min-height:20px; + margin:0 -4px; +} +QSlider::handle:horizontal:hover{ + background:palette(highlight); +} +QSlider::add-page:horizontal{ + background:palette(base); +} +QSlider::sub-page:horizontal{ + background:palette(highlight); +} +QSlider::sub-page:horizontal:disabled{ + background:rgb(80,80,80); +} diff --git a/qad/styles/darkstyle/icon_branch_closed.png b/qad/styles/darkstyle/icon_branch_closed.png new file mode 100644 index 0000000..fa785cc Binary files /dev/null and b/qad/styles/darkstyle/icon_branch_closed.png differ diff --git a/qad/styles/darkstyle/icon_branch_end.png b/qad/styles/darkstyle/icon_branch_end.png new file mode 100644 index 0000000..d90a04c Binary files /dev/null and b/qad/styles/darkstyle/icon_branch_end.png differ diff --git a/qad/styles/darkstyle/icon_branch_more.png b/qad/styles/darkstyle/icon_branch_more.png new file mode 100644 index 0000000..bdbe4ed Binary files /dev/null and b/qad/styles/darkstyle/icon_branch_more.png differ diff --git a/qad/styles/darkstyle/icon_branch_open.png b/qad/styles/darkstyle/icon_branch_open.png new file mode 100644 index 0000000..9dd05d6 Binary files /dev/null and b/qad/styles/darkstyle/icon_branch_open.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_checked.png b/qad/styles/darkstyle/icon_checkbox_checked.png new file mode 100644 index 0000000..fa22907 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_checked.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_checked_disabled.png b/qad/styles/darkstyle/icon_checkbox_checked_disabled.png new file mode 100644 index 0000000..441d0d9 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_checked_disabled.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_checked_pressed.png b/qad/styles/darkstyle/icon_checkbox_checked_pressed.png new file mode 100644 index 0000000..7b508c8 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_checked_pressed.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_indeterminate.png b/qad/styles/darkstyle/icon_checkbox_indeterminate.png new file mode 100644 index 0000000..87ebf23 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_indeterminate.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_indeterminate_disabled.png b/qad/styles/darkstyle/icon_checkbox_indeterminate_disabled.png new file mode 100644 index 0000000..ee7d112 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_indeterminate_disabled.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_indeterminate_pressed.png b/qad/styles/darkstyle/icon_checkbox_indeterminate_pressed.png new file mode 100644 index 0000000..562c482 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_indeterminate_pressed.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_unchecked.png b/qad/styles/darkstyle/icon_checkbox_unchecked.png new file mode 100644 index 0000000..c3c14dd Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_unchecked.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_unchecked_disabled.png b/qad/styles/darkstyle/icon_checkbox_unchecked_disabled.png new file mode 100644 index 0000000..3ac26d8 Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_unchecked_disabled.png differ diff --git a/qad/styles/darkstyle/icon_checkbox_unchecked_pressed.png b/qad/styles/darkstyle/icon_checkbox_unchecked_pressed.png new file mode 100644 index 0000000..c24130c Binary files /dev/null and b/qad/styles/darkstyle/icon_checkbox_unchecked_pressed.png differ diff --git a/qad/styles/darkstyle/icon_close.png b/qad/styles/darkstyle/icon_close.png new file mode 100644 index 0000000..ece7c28 Binary files /dev/null and b/qad/styles/darkstyle/icon_close.png differ diff --git a/qad/styles/darkstyle/icon_radiobutton_checked.png b/qad/styles/darkstyle/icon_radiobutton_checked.png new file mode 100644 index 0000000..f747f49 Binary files /dev/null and b/qad/styles/darkstyle/icon_radiobutton_checked.png differ diff --git a/qad/styles/darkstyle/icon_radiobutton_checked_disabled.png b/qad/styles/darkstyle/icon_radiobutton_checked_disabled.png new file mode 100644 index 0000000..fa554cb Binary files /dev/null and b/qad/styles/darkstyle/icon_radiobutton_checked_disabled.png differ diff --git a/qad/styles/darkstyle/icon_radiobutton_checked_pressed.png b/qad/styles/darkstyle/icon_radiobutton_checked_pressed.png new file mode 100644 index 0000000..7b4bb11 Binary files /dev/null and b/qad/styles/darkstyle/icon_radiobutton_checked_pressed.png differ diff --git a/qad/styles/darkstyle/icon_radiobutton_unchecked.png b/qad/styles/darkstyle/icon_radiobutton_unchecked.png new file mode 100644 index 0000000..e74f040 Binary files /dev/null and b/qad/styles/darkstyle/icon_radiobutton_unchecked.png differ diff --git a/qad/styles/darkstyle/icon_radiobutton_unchecked_disabled.png b/qad/styles/darkstyle/icon_radiobutton_unchecked_disabled.png new file mode 100644 index 0000000..87d1846 Binary files /dev/null and b/qad/styles/darkstyle/icon_radiobutton_unchecked_disabled.png differ diff --git a/qad/styles/darkstyle/icon_radiobutton_unchecked_pressed.png b/qad/styles/darkstyle/icon_radiobutton_unchecked_pressed.png new file mode 100644 index 0000000..8f4d548 Binary files /dev/null and b/qad/styles/darkstyle/icon_radiobutton_unchecked_pressed.png differ diff --git a/qad/styles/darkstyle/icon_restore.png b/qad/styles/darkstyle/icon_restore.png new file mode 100644 index 0000000..be29650 Binary files /dev/null and b/qad/styles/darkstyle/icon_restore.png differ diff --git a/qad/styles/darkstyle/icon_undock.png b/qad/styles/darkstyle/icon_undock.png new file mode 100644 index 0000000..25e317e Binary files /dev/null and b/qad/styles/darkstyle/icon_undock.png differ diff --git a/qad/styles/darkstyle/icon_vline.png b/qad/styles/darkstyle/icon_vline.png new file mode 100644 index 0000000..14228c8 Binary files /dev/null and b/qad/styles/darkstyle/icon_vline.png differ diff --git a/qad/styles/ladybugs.qrc b/qad/styles/ladybugs.qrc new file mode 100644 index 0000000..edd616f --- /dev/null +++ b/qad/styles/ladybugs.qrc @@ -0,0 +1,11 @@ + + + ladybugs/dots.png + ladybugs/ladybugs-vector.png + ladybugs/dots2.png + ladybugs/dots_light.png + ladybugs/ladybugs-light.png + ladybugs/korov.png + ladybugs/dots_dark.png + + diff --git a/qad/styles/ladybugs/Dot-Backgrounds.jpg b/qad/styles/ladybugs/Dot-Backgrounds.jpg new file mode 100644 index 0000000..dc93859 Binary files /dev/null and b/qad/styles/ladybugs/Dot-Backgrounds.jpg differ diff --git a/qad/styles/ladybugs/bozhi-korov.jpg b/qad/styles/ladybugs/bozhi-korov.jpg new file mode 100644 index 0000000..3d25789 Binary files /dev/null and b/qad/styles/ladybugs/bozhi-korov.jpg differ diff --git a/qad/styles/ladybugs/dots.png b/qad/styles/ladybugs/dots.png new file mode 100644 index 0000000..bf107b3 Binary files /dev/null and b/qad/styles/ladybugs/dots.png differ diff --git a/qad/styles/ladybugs/dots2.png b/qad/styles/ladybugs/dots2.png new file mode 100644 index 0000000..af8c963 Binary files /dev/null and b/qad/styles/ladybugs/dots2.png differ diff --git a/qad/styles/ladybugs/dots_dark.png b/qad/styles/ladybugs/dots_dark.png new file mode 100644 index 0000000..04dcbd6 Binary files /dev/null and b/qad/styles/ladybugs/dots_dark.png differ diff --git a/qad/styles/ladybugs/dots_light.png b/qad/styles/ladybugs/dots_light.png new file mode 100644 index 0000000..25eb43a Binary files /dev/null and b/qad/styles/ladybugs/dots_light.png differ diff --git a/qad/styles/ladybugs/korov.png b/qad/styles/ladybugs/korov.png new file mode 100644 index 0000000..754987a Binary files /dev/null and b/qad/styles/ladybugs/korov.png differ diff --git a/qad/styles/ladybugs/ladybugs-light.png b/qad/styles/ladybugs/ladybugs-light.png new file mode 100644 index 0000000..5c99dda Binary files /dev/null and b/qad/styles/ladybugs/ladybugs-light.png differ diff --git a/qad/styles/ladybugs/ladybugs-vector.jpg b/qad/styles/ladybugs/ladybugs-vector.jpg new file mode 100644 index 0000000..e5cdb79 Binary files /dev/null and b/qad/styles/ladybugs/ladybugs-vector.jpg differ diff --git a/qad/styles/ladybugs/ladybugs-vector.png b/qad/styles/ladybugs/ladybugs-vector.png new file mode 100644 index 0000000..03f1e7e Binary files /dev/null and b/qad/styles/ladybugs/ladybugs-vector.png differ diff --git a/qad/styles/ladybugs/woodbackground.png b/qad/styles/ladybugs/woodbackground.png new file mode 100644 index 0000000..8be3366 Binary files /dev/null and b/qad/styles/ladybugs/woodbackground.png differ diff --git a/qad/styles/ladybugs/woodbutton.png b/qad/styles/ladybugs/woodbutton.png new file mode 100644 index 0000000..adb59ef Binary files /dev/null and b/qad/styles/ladybugs/woodbutton.png differ diff --git a/qad/styles/ladybugsstyle.cpp b/qad/styles/ladybugsstyle.cpp new file mode 100644 index 0000000..cdc471e --- /dev/null +++ b/qad/styles/ladybugsstyle.cpp @@ -0,0 +1,238 @@ +#include +#include "ladybugsstyle.h" + + +LadybugsStyle::LadybugsStyle() : QProxyStyle(QStyleFactory::create("fusion")) { +} + + +void LadybugsStyle::polish(QPalette &palette) { + QColor beige(252, 160, 160); + QColor brown(236, 80, 80); + QColor slightlyOpaqueBlack(0, 0, 0, 63); + + QPixmap backgroundImage(":/ladybugs/korov.png"); + QPixmap buttonImage(":/ladybugs/dots_dark.png"); + QPixmap baseImage(":/ladybugs/ladybugs-light.png"); +// QTransform transform; +// transform.rotate(90); + QPixmap midImage = buttonImage;//.transformed(transform); + + QPainter painter; + painter.begin(&midImage); + painter.setPen(Qt::NoPen); + painter.fillRect(midImage.rect(), slightlyOpaqueBlack); + painter.end(); + palette = QPalette(beige); + +// palette.setBrush(QPalette::BrightText, Qt::white); +// palette.setBrush(QPalette::WindowText, Qt::cyan); +// palette.setBrush(QPalette::Text, Qt::white); + palette.setBrush(QPalette::ButtonText, Qt::green); +// palette.setBrush(QPalette::Base, brown); + palette.setBrush(QPalette::Highlight, Qt::darkGreen); + setTexture(palette, QPalette::Button, buttonImage); + setTexture(palette, QPalette::Mid, midImage); + setTexture(palette, QPalette::Window, backgroundImage); + setTexture(palette, QPalette::Base, baseImage); + + QBrush brush = palette.background(); + brush.setColor(brush.color().dark()); + +// palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); +// palette.setBrush(QPalette::Disabled, QPalette::Text, brush); + palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); +// palette.setBrush(QPalette::Disabled, QPalette::Base, brush); + palette.setBrush(QPalette::Disabled, QPalette::Button, brush); + palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); +} + + +void LadybugsStyle::polish(QWidget *widget) { + if (qobject_cast(widget) + || qobject_cast(widget)) + widget->setAttribute(Qt::WA_Hover, true); +} + + +void LadybugsStyle::unpolish(QWidget *widget) { + if (qobject_cast(widget) + || qobject_cast(widget)) + widget->setAttribute(Qt::WA_Hover, false); +} + + +int LadybugsStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { + switch (metric) { + case PM_ComboBoxFrameWidth: + return 8; + case PM_ScrollBarExtent: + return QProxyStyle::pixelMetric(metric, option, widget) + 4; + default: + return QProxyStyle::pixelMetric(metric, option, widget); + } +} + + +int LadybugsStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { + switch (hint) { + case SH_DitherDisabledText: + return int(false); + case SH_EtchDisabledText: + return int(true); + default: + return QProxyStyle::styleHint(hint, option, widget, returnData); + } +} + + +void LadybugsStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { + switch (element) { + case PE_PanelButtonCommand: + { + int delta = (option->state & State_MouseOver) ? 64 : 0; + QColor slightlyOpaqueBlack(0, 0, 0, 63); + QColor semiTransparentWhite(255, 255, 255, 127 + delta); + QColor semiTransparentBlack(0, 0, 0, 127 - delta); + + int x, y, width, height; + option->rect.getRect(&x, &y, &width, &height); + + QPainterPath roundRect = roundRectPath(option->rect); + int radius = qMin(width, height) / 2; + + QBrush brush; + bool darker; + + const QStyleOptionButton *buttonOption = + qstyleoption_cast(option); + if (buttonOption + && (buttonOption->features & QStyleOptionButton::Flat)) { + brush = option->palette.background(); + darker = (option->state & (State_Sunken | State_On)); + } else { + if (option->state & (State_Sunken | State_On)) { + brush = option->palette.mid(); + darker = !(option->state & State_Sunken); + } else { + brush = option->palette.button(); + darker = false; + } + } + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->fillPath(roundRect, brush); + if (darker) + painter->fillPath(roundRect, slightlyOpaqueBlack); + + int penWidth; + if (radius < 10) + penWidth = 3; + else if (radius < 20) + penWidth = 5; + else + penWidth = 7; + + QPen topPen(semiTransparentWhite, penWidth); + QPen bottomPen(semiTransparentBlack, penWidth); + + if (option->state & (State_Sunken | State_On)) + qSwap(topPen, bottomPen); + + int x1 = x; + int x2 = x + radius; + int x3 = x + width - radius; + int x4 = x + width; + + if (option->direction == Qt::RightToLeft) { + qSwap(x1, x4); + qSwap(x2, x3); + } + + QPolygon topHalf; + topHalf << QPoint(x1, y) + << QPoint(x4, y) + << QPoint(x3, y + radius) + << QPoint(x2, y + height - radius) + << QPoint(x1, y + height); + + painter->setClipPath(roundRect); + painter->setClipRegion(topHalf, Qt::IntersectClip); + painter->setPen(topPen); + painter->drawPath(roundRect); + + QPolygon bottomHalf = topHalf; + bottomHalf[0] = QPoint(x4, y + height); + + painter->setClipPath(roundRect); + painter->setClipRegion(bottomHalf, Qt::IntersectClip); + painter->setPen(bottomPen); + painter->drawPath(roundRect); + + painter->setPen(option->palette.foreground().color()); + painter->setClipping(false); + painter->drawPath(roundRect); + + painter->restore(); + } + break; + default: + QProxyStyle::drawPrimitive(element, option, painter, widget); + } +} + + +void LadybugsStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { + switch (element) { + case CE_PushButtonLabel: + { + QStyleOptionButton myButtonOption; + const QStyleOptionButton *buttonOption = + qstyleoption_cast(option); + if (buttonOption) { + myButtonOption = *buttonOption; + if (myButtonOption.palette.currentColorGroup() + != QPalette::Disabled) { + if (myButtonOption.state & (State_Sunken | State_On)) { + myButtonOption.palette.setBrush(QPalette::ButtonText, + myButtonOption.palette.brightText()); + } + } + } + QProxyStyle::drawControl(element, &myButtonOption, painter, widget); + } + break; + default: + QProxyStyle::drawControl(element, option, painter, widget); + } +} + + +void LadybugsStyle::setTexture(QPalette &palette, QPalette::ColorRole role, const QPixmap &pixmap) { + for (int i = 0; i < QPalette::NColorGroups; ++i) { + QColor color = palette.brush(QPalette::ColorGroup(i), role).color(); + palette.setBrush(QPalette::ColorGroup(i), role, QBrush(color, pixmap)); + } +} + + +QPainterPath LadybugsStyle::roundRectPath(const QRect &rect) { + int radius = qMin(rect.width(), rect.height()) / 2; + int diam = 2 * radius; + + int x1, y1, x2, y2; + rect.getCoords(&x1, &y1, &x2, &y2); + + QPainterPath path; + path.moveTo(x2, y1 + radius); + path.arcTo(QRect(x2 - diam, y1, diam, diam), 0.0, +90.0); + path.lineTo(x1 + radius, y1); + path.arcTo(QRect(x1, y1, diam, diam), 90.0, +90.0); + path.lineTo(x1, y2 - radius); + path.arcTo(QRect(x1, y2 - diam, diam, diam), 180.0, +90.0); + path.lineTo(x1 + radius, y2); + path.arcTo(QRect(x2 - diam, y2 - diam, diam, diam), 270.0, +90.0); + path.closeSubpath(); + return path; +} diff --git a/qad/styles/ladybugsstyle.h b/qad/styles/ladybugsstyle.h new file mode 100644 index 0000000..ae7efaf --- /dev/null +++ b/qad/styles/ladybugsstyle.h @@ -0,0 +1,33 @@ +#ifndef LADYBUGSSTYLE_H +#define LADYBUGSSTYLE_H + +#include +#include + +class QPainterPath; + +class LadybugsStyle : public QProxyStyle +{ + Q_OBJECT +public: + LadybugsStyle(); + + void polish(QPalette &palette) override; + void polish(QWidget *widget) override; + void unpolish(QWidget *widget) override; + int pixelMetric(PixelMetric metric, const QStyleOption *option, + const QWidget *widget) const override; + int styleHint(StyleHint hint, const QStyleOption *option, + const QWidget *widget, QStyleHintReturn *returnData) const override; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const override; + void drawControl(ControlElement control, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const override; + +private: + static void setTexture(QPalette &palette, QPalette::ColorRole role, + const QPixmap &pixmap); + static QPainterPath roundRectPath(const QRect &rect); +}; + +#endif //LADYBUGSSTYLE_H diff --git a/qad/styles/norwegianwoodstyle.cpp b/qad/styles/norwegianwoodstyle.cpp new file mode 100644 index 0000000..cc641e0 --- /dev/null +++ b/qad/styles/norwegianwoodstyle.cpp @@ -0,0 +1,345 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "norwegianwoodstyle.h" + +NorwegianWoodStyle::NorwegianWoodStyle() : + QProxyStyle(QStyleFactory::create("windows")) +{ +} + +//! [0] +void NorwegianWoodStyle::polish(QPalette &palette) +{ + QColor brown(212, 140, 95); + QColor beige(236, 182, 120); + QColor slightlyOpaqueBlack(0, 0, 0, 63); + + QPixmap backgroundImage(":/norwegianwoodstyle/woodbackground.png"); + QPixmap buttonImage(":/norwegianwoodstyle/woodbutton.png"); + QPixmap midImage = buttonImage; + + QPainter painter; + painter.begin(&midImage); + painter.setPen(Qt::NoPen); + painter.fillRect(midImage.rect(), slightlyOpaqueBlack); + painter.end(); +//! [0] + +//! [1] + palette = QPalette(brown); + + palette.setBrush(QPalette::BrightText, Qt::white); + palette.setBrush(QPalette::Base, beige); + palette.setBrush(QPalette::Highlight, Qt::darkGreen); + setTexture(palette, QPalette::Button, buttonImage); + setTexture(palette, QPalette::Mid, midImage); + setTexture(palette, QPalette::Window, backgroundImage); + + QBrush brush = palette.background(); + brush.setColor(brush.color().dark()); + + palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); + palette.setBrush(QPalette::Disabled, QPalette::Text, brush); + palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); + palette.setBrush(QPalette::Disabled, QPalette::Base, brush); + palette.setBrush(QPalette::Disabled, QPalette::Button, brush); + palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); +} +//! [1] + +//! [3] +void NorwegianWoodStyle::polish(QWidget *widget) +//! [3] //! [4] +{ + if (qobject_cast(widget) + || qobject_cast(widget)) + widget->setAttribute(Qt::WA_Hover, true); +} +//! [4] + +//! [5] +void NorwegianWoodStyle::unpolish(QWidget *widget) +//! [5] //! [6] +{ + if (qobject_cast(widget) + || qobject_cast(widget)) + widget->setAttribute(Qt::WA_Hover, false); +} +//! [6] + +//! [7] +int NorwegianWoodStyle::pixelMetric(PixelMetric metric, +//! [7] //! [8] + const QStyleOption *option, + const QWidget *widget) const +{ + switch (metric) { + case PM_ComboBoxFrameWidth: + return 8; + case PM_ScrollBarExtent: + return QProxyStyle::pixelMetric(metric, option, widget) + 4; + default: + return QProxyStyle::pixelMetric(metric, option, widget); + } +} +//! [8] + +//! [9] +int NorwegianWoodStyle::styleHint(StyleHint hint, const QStyleOption *option, +//! [9] //! [10] + const QWidget *widget, + QStyleHintReturn *returnData) const +{ + switch (hint) { + case SH_DitherDisabledText: + return int(false); + case SH_EtchDisabledText: + return int(true); + default: + return QProxyStyle::styleHint(hint, option, widget, returnData); + } +} +//! [10] + +//! [11] +void NorwegianWoodStyle::drawPrimitive(PrimitiveElement element, +//! [11] //! [12] + const QStyleOption *option, + QPainter *painter, + const QWidget *widget) const +{ + switch (element) { + case PE_PanelButtonCommand: + { + int delta = (option->state & State_MouseOver) ? 64 : 0; + QColor slightlyOpaqueBlack(0, 0, 0, 63); + QColor semiTransparentWhite(255, 255, 255, 127 + delta); + QColor semiTransparentBlack(0, 0, 0, 127 - delta); + + int x, y, width, height; + option->rect.getRect(&x, &y, &width, &height); +//! [12] + +//! [13] + QPainterPath roundRect = roundRectPath(option->rect); +//! [13] //! [14] + int radius = qMin(width, height) / 2; +//! [14] + +//! [15] + QBrush brush; +//! [15] //! [16] + bool darker; + + const QStyleOptionButton *buttonOption = + qstyleoption_cast(option); + if (buttonOption + && (buttonOption->features & QStyleOptionButton::Flat)) { + brush = option->palette.background(); + darker = (option->state & (State_Sunken | State_On)); + } else { + if (option->state & (State_Sunken | State_On)) { + brush = option->palette.mid(); + darker = !(option->state & State_Sunken); + } else { + brush = option->palette.button(); + darker = false; +//! [16] //! [17] + } +//! [17] //! [18] + } +//! [18] + +//! [19] + painter->save(); +//! [19] //! [20] + painter->setRenderHint(QPainter::Antialiasing, true); +//! [20] //! [21] + painter->fillPath(roundRect, brush); +//! [21] //! [22] + if (darker) +//! [22] //! [23] + painter->fillPath(roundRect, slightlyOpaqueBlack); +//! [23] + +//! [24] + int penWidth; +//! [24] //! [25] + if (radius < 10) + penWidth = 3; + else if (radius < 20) + penWidth = 5; + else + penWidth = 7; + + QPen topPen(semiTransparentWhite, penWidth); + QPen bottomPen(semiTransparentBlack, penWidth); + + if (option->state & (State_Sunken | State_On)) + qSwap(topPen, bottomPen); +//! [25] + +//! [26] + int x1 = x; + int x2 = x + radius; + int x3 = x + width - radius; + int x4 = x + width; + + if (option->direction == Qt::RightToLeft) { + qSwap(x1, x4); + qSwap(x2, x3); + } + + QPolygon topHalf; + topHalf << QPoint(x1, y) + << QPoint(x4, y) + << QPoint(x3, y + radius) + << QPoint(x2, y + height - radius) + << QPoint(x1, y + height); + + painter->setClipPath(roundRect); + painter->setClipRegion(topHalf, Qt::IntersectClip); + painter->setPen(topPen); + painter->drawPath(roundRect); +//! [26] //! [32] + + QPolygon bottomHalf = topHalf; + bottomHalf[0] = QPoint(x4, y + height); + + painter->setClipPath(roundRect); + painter->setClipRegion(bottomHalf, Qt::IntersectClip); + painter->setPen(bottomPen); + painter->drawPath(roundRect); + + painter->setPen(option->palette.foreground().color()); + painter->setClipping(false); + painter->drawPath(roundRect); + + painter->restore(); + } + break; +//! [32] //! [33] + default: +//! [33] //! [34] + QProxyStyle::drawPrimitive(element, option, painter, widget); + } +} +//! [34] + +//! [35] +void NorwegianWoodStyle::drawControl(ControlElement element, +//! [35] //! [36] + const QStyleOption *option, + QPainter *painter, + const QWidget *widget) const +{ + switch (element) { + case CE_PushButtonLabel: + { + QStyleOptionButton myButtonOption; + const QStyleOptionButton *buttonOption = + qstyleoption_cast(option); + if (buttonOption) { + myButtonOption = *buttonOption; + if (myButtonOption.palette.currentColorGroup() + != QPalette::Disabled) { + if (myButtonOption.state & (State_Sunken | State_On)) { + myButtonOption.palette.setBrush(QPalette::ButtonText, + myButtonOption.palette.brightText()); + } + } + } + QProxyStyle::drawControl(element, &myButtonOption, painter, widget); + } + break; + default: + QProxyStyle::drawControl(element, option, painter, widget); + } +} +//! [36] + +//! [37] +void NorwegianWoodStyle::setTexture(QPalette &palette, QPalette::ColorRole role, +//! [37] //! [38] + const QPixmap &pixmap) +{ + for (int i = 0; i < QPalette::NColorGroups; ++i) { + QColor color = palette.brush(QPalette::ColorGroup(i), role).color(); + palette.setBrush(QPalette::ColorGroup(i), role, QBrush(color, pixmap)); + } +} +//! [38] + +//! [39] +QPainterPath NorwegianWoodStyle::roundRectPath(const QRect &rect) +//! [39] //! [40] +{ + int radius = qMin(rect.width(), rect.height()) / 2; + int diam = 2 * radius; + + int x1, y1, x2, y2; + rect.getCoords(&x1, &y1, &x2, &y2); + + QPainterPath path; + path.moveTo(x2, y1 + radius); + path.arcTo(QRect(x2 - diam, y1, diam, diam), 0.0, +90.0); + path.lineTo(x1 + radius, y1); + path.arcTo(QRect(x1, y1, diam, diam), 90.0, +90.0); + path.lineTo(x1, y2 - radius); + path.arcTo(QRect(x1, y2 - diam, diam, diam), 180.0, +90.0); + path.lineTo(x1 + radius, y2); + path.arcTo(QRect(x2 - diam, y2 - diam, diam, diam), 270.0, +90.0); + path.closeSubpath(); + return path; +} +//! [40] diff --git a/qad/styles/norwegianwoodstyle.h b/qad/styles/norwegianwoodstyle.h new file mode 100644 index 0000000..9eed913 --- /dev/null +++ b/qad/styles/norwegianwoodstyle.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef NORWEGIANWOODSTYLE_H +#define NORWEGIANWOODSTYLE_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QPainterPath; +QT_END_NAMESPACE + +//! [0] +class NorwegianWoodStyle : public QProxyStyle +{ + Q_OBJECT + +public: + NorwegianWoodStyle(); + + void polish(QPalette &palette) override; + void polish(QWidget *widget) override; + void unpolish(QWidget *widget) override; + int pixelMetric(PixelMetric metric, const QStyleOption *option, + const QWidget *widget) const override; + int styleHint(StyleHint hint, const QStyleOption *option, + const QWidget *widget, QStyleHintReturn *returnData) const override; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const override; + void drawControl(ControlElement control, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const override; + +private: + static void setTexture(QPalette &palette, QPalette::ColorRole role, + const QPixmap &pixmap); + static QPainterPath roundRectPath(const QRect &rect); +}; +//! [0] + +#endif diff --git a/qad/styles/norwegianwoodstyle.qrc b/qad/styles/norwegianwoodstyle.qrc new file mode 100644 index 0000000..8f988d2 --- /dev/null +++ b/qad/styles/norwegianwoodstyle.qrc @@ -0,0 +1,6 @@ + + + norwegianwoodstyle/woodbutton.png + norwegianwoodstyle/woodbackground.png + + diff --git a/qad/styles/norwegianwoodstyle/woodbackground.png b/qad/styles/norwegianwoodstyle/woodbackground.png new file mode 100644 index 0000000..8be3366 Binary files /dev/null and b/qad/styles/norwegianwoodstyle/woodbackground.png differ diff --git a/qad/styles/norwegianwoodstyle/woodbutton.png b/qad/styles/norwegianwoodstyle/woodbutton.png new file mode 100644 index 0000000..adb59ef Binary files /dev/null and b/qad/styles/norwegianwoodstyle/woodbutton.png differ diff --git a/qad/styles/window_icons/icon_window_close.png b/qad/styles/window_icons/icon_window_close.png new file mode 100644 index 0000000..ece7c28 Binary files /dev/null and b/qad/styles/window_icons/icon_window_close.png differ diff --git a/qad/styles/window_icons/icon_window_maximize.png b/qad/styles/window_icons/icon_window_maximize.png new file mode 100644 index 0000000..53ae289 Binary files /dev/null and b/qad/styles/window_icons/icon_window_maximize.png differ diff --git a/qad/styles/window_icons/icon_window_minimize.png b/qad/styles/window_icons/icon_window_minimize.png new file mode 100644 index 0000000..29bceed Binary files /dev/null and b/qad/styles/window_icons/icon_window_minimize.png differ diff --git a/qad/styles/window_icons/icon_window_restore.png b/qad/styles/window_icons/icon_window_restore.png new file mode 100644 index 0000000..be29650 Binary files /dev/null and b/qad/styles/window_icons/icon_window_restore.png differ