git-svn-id: svn://db.shs.com.ru/libs@549 a8b55f48-bf90-11e4-a774-851b48703e85
@@ -106,7 +106,7 @@ macro(qad_project NAME _MODULES _LIBS)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(DIRS utils widgets application blockview graphic sql_table touch_widgets styles)
|
||||
set(DIRS utils widgets application blockview graphic sql_table touch_widgets)
|
||||
foreach(D ${DIRS})
|
||||
list(APPEND QT_MULTILIB_LIST qad_${D})
|
||||
endforeach(D)
|
||||
|
||||
@@ -23,7 +23,7 @@ else()
|
||||
get_filename_component(QAD_INCLUDES ${QAD_H_INCLUDE} PATH)
|
||||
endif()
|
||||
set(_SEARCH_DIR ${MINGW_LIB} /usr/lib /usr/local/lib $ENV{SMSDK_DIR}/lib)
|
||||
set(_QAD_LIBS utils widgets application blockview graphic sql_table touch_widgets styles)
|
||||
set(_QAD_LIBS utils widgets application blockview graphic sql_table touch_widgets)
|
||||
if(LIBPROJECT)
|
||||
set(QAD_INCLUDES)
|
||||
endif()
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
qad_project(styles "Gui;Widgets" "")
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# 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();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# 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 <QApplication>
|
||||
#include <QFile>
|
||||
#include <QFont>
|
||||
#include <QProxyStyle>
|
||||
#include <QStyleFactory>
|
||||
|
||||
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
|
||||
@@ -1,28 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>darkstyle/darkstyle.qss</file>
|
||||
<file>darkstyle/icon_close.png</file>
|
||||
<file>darkstyle/icon_restore.png</file>
|
||||
<file>darkstyle/icon_undock.png</file>
|
||||
<file>darkstyle/icon_branch_closed.png</file>
|
||||
<file>darkstyle/icon_branch_end.png</file>
|
||||
<file>darkstyle/icon_branch_more.png</file>
|
||||
<file>darkstyle/icon_branch_open.png</file>
|
||||
<file>darkstyle/icon_vline.png</file>
|
||||
<file>darkstyle/icon_checkbox_checked.png</file>
|
||||
<file>darkstyle/icon_checkbox_indeterminate.png</file>
|
||||
<file>darkstyle/icon_checkbox_unchecked.png</file>
|
||||
<file>darkstyle/icon_checkbox_checked_pressed.png</file>
|
||||
<file>darkstyle/icon_checkbox_indeterminate_pressed.png</file>
|
||||
<file>darkstyle/icon_checkbox_unchecked_pressed.png</file>
|
||||
<file>darkstyle/icon_checkbox_checked_disabled.png</file>
|
||||
<file>darkstyle/icon_checkbox_indeterminate_disabled.png</file>
|
||||
<file>darkstyle/icon_checkbox_unchecked_disabled.png</file>
|
||||
<file>darkstyle/icon_radiobutton_checked.png</file>
|
||||
<file>darkstyle/icon_radiobutton_unchecked.png</file>
|
||||
<file>darkstyle/icon_radiobutton_checked_pressed.png</file>
|
||||
<file>darkstyle/icon_radiobutton_unchecked_pressed.png</file>
|
||||
<file>darkstyle/icon_radiobutton_checked_disabled.png</file>
|
||||
<file>darkstyle/icon_radiobutton_unchecked_disabled.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,343 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 358 B |
|
Before Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 313 B |
|
Before Width: | Height: | Size: 176 B |
|
Before Width: | Height: | Size: 373 B |
|
Before Width: | Height: | Size: 373 B |
|
Before Width: | Height: | Size: 121 B |
|
Before Width: | Height: | Size: 286 B |
|
Before Width: | Height: | Size: 286 B |
|
Before Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 238 B |
|
Before Width: | Height: | Size: 238 B |
|
Before Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 370 B |
|
Before Width: | Height: | Size: 617 B |
|
Before Width: | Height: | Size: 616 B |
|
Before Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 538 B |
|
Before Width: | Height: | Size: 537 B |
|
Before Width: | Height: | Size: 404 B |
|
Before Width: | Height: | Size: 424 B |
|
Before Width: | Height: | Size: 303 B |
@@ -1,11 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>ladybugs/dots.png</file>
|
||||
<file>ladybugs/ladybugs-vector.png</file>
|
||||
<file>ladybugs/dots2.png</file>
|
||||
<file>ladybugs/dots_light.png</file>
|
||||
<file>ladybugs/ladybugs-light.png</file>
|
||||
<file>ladybugs/korov.png</file>
|
||||
<file>ladybugs/dots_dark.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 995 KiB |
|
Before Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 209 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
@@ -1,238 +0,0 @@
|
||||
#include <QtWidgets>
|
||||
#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<QPushButton *>(widget)
|
||||
|| qobject_cast<QComboBox *>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, true);
|
||||
}
|
||||
|
||||
|
||||
void LadybugsStyle::unpolish(QWidget *widget) {
|
||||
if (qobject_cast<QPushButton *>(widget)
|
||||
|| qobject_cast<QComboBox *>(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<const QStyleOptionButton *>(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<const QStyleOptionButton *>(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;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef LADYBUGSSTYLE_H
|
||||
#define LADYBUGSSTYLE_H
|
||||
|
||||
#include <QProxyStyle>
|
||||
#include <QPalette>
|
||||
|
||||
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
|
||||
@@ -1,345 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtWidgets>
|
||||
|
||||
#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<QPushButton *>(widget)
|
||||
|| qobject_cast<QComboBox *>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, true);
|
||||
}
|
||||
//! [4]
|
||||
|
||||
//! [5]
|
||||
void NorwegianWoodStyle::unpolish(QWidget *widget)
|
||||
//! [5] //! [6]
|
||||
{
|
||||
if (qobject_cast<QPushButton *>(widget)
|
||||
|| qobject_cast<QComboBox *>(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<const QStyleOptionButton *>(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<const QStyleOptionButton *>(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]
|
||||
@@ -1,88 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QProxyStyle>
|
||||
#include <QPalette>
|
||||
|
||||
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
|
||||
@@ -1,6 +0,0 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>norwegianwoodstyle/woodbutton.png</file>
|
||||
<file>norwegianwoodstyle/woodbackground.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 404 B |