qt5-ukui-platformtheme/0000775000175000017500000000000013643027763014044 5ustar fengfengqt5-ukui-platformtheme/qt5-ukui.pro0000664000175000017500000000016113641116416016240 0ustar fengfengTEMPLATE = subdirs SUBDIRS += \ qt5-ukui-platformtheme \ ukui-styles \ libqt5-ukui-style \ test qt5-ukui-platformtheme/test/0000775000175000017500000000000013643026433015014 5ustar fengfengqt5-ukui-platformtheme/test/highlighted-icon-button/0000775000175000017500000000000013643026433021533 5ustar fengfengqt5-ukui-platformtheme/test/highlighted-icon-button/main.cpp0000664000175000017500000000170113641116416023161 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } qt5-ukui-platformtheme/test/highlighted-icon-button/mainwindow.cpp0000664000175000017500000000573613641116416024425 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include "ui_mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); ui->comboBox->setEnabled(false); menu = new QMenu(ui->pushButton); menu->addAction(QIcon::fromTheme("edit-find-symbolic"), "edit-find-symbolic"); menu->addAction(QIcon::fromTheme("edit-cut-symbolic"), "edit-cut-symbolic"); menu->addAction(QIcon::fromTheme("user-trash"), "user-trash"); menu->addAction(QIcon::fromTheme("open-menu-symbolic"), "open-menu-symbolic"); ui->pushButton->setMenu(menu); view = new QListWidget(this); view->resize(300, 200); view->move(100, 200); auto item = new QListWidgetItem(QIcon::fromTheme("window-close"), "window-close", view); item = new QListWidgetItem(QIcon::fromTheme("window-close-symbolic"), "window-close-symoblic", view); item = new QListWidgetItem(QIcon::fromTheme("user-trash"), "user-trash", view); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_checkBox_toggled(bool checked) { ui->pushButton->setProperty("useIconHighlightEffect", checked); ui->pushButton->update(); ui->toolButton->setProperty("useIconHighlightEffect", checked); ui->toolButton->update(); view->setProperty("useIconHighlightEffect", checked); view->viewport()->update(); menu->setProperty("useIconHighlightEffect", checked); ui->comboBox->setEnabled(checked); int mode = ui->comboBox->currentIndex(); ui->pushButton->setProperty("iconHighlightEffectMode", mode); ui->pushButton->update(); ui->toolButton->setProperty("iconHighlightEffectMode", mode); ui->toolButton->update(); view->setProperty("iconHighlightEffectMode", mode); view->viewport()->update(); menu->setProperty("iconHighlightEffectMode", mode); } void MainWindow::on_comboBox_currentIndexChanged(int index) { int mode = index; ui->pushButton->setProperty("iconHighlightEffectMode", mode); ui->pushButton->update(); ui->toolButton->setProperty("iconHighlightEffectMode", mode); ui->toolButton->update(); view->setProperty("iconHighlightEffectMode", mode); view->viewport()->update(); } qt5-ukui-platformtheme/test/highlighted-icon-button/mainwindow.h0000664000175000017500000000242313641116416024060 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class QListWidget; class QMenu; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_checkBox_toggled(bool checked); void on_comboBox_currentIndexChanged(int index); private: Ui::MainWindow *ui; QListWidget *view; QMenu *menu; }; #endif // MAINWINDOW_H qt5-ukui-platformtheme/test/highlighted-icon-button/mainwindow.ui0000664000175000017500000000467413641116416024260 0ustar fengfeng MainWindow 0 0 800 600 MainWindow 12 12 345 101 PushButton .. 36 36 use auto highlight icon ... .. 36 36 highlightOnly bothDefaultAndHighlight 0 0 800 36 qt5-ukui-platformtheme/test/highlighted-icon-button/highlighted-icon-button.pro0000664000175000017500000000174113641116416026776 0ustar fengfengQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui # Default rules for deployment. #qnx: target.path = /tmp/$${TARGET}/bin #else: unix:!android: target.path = /opt/$${TARGET}/bin #!isEmpty(target.path): INSTALLS += target qt5-ukui-platformtheme/test/system-settings/0000775000175000017500000000000013643026434020177 5ustar fengfengqt5-ukui-platformtheme/test/system-settings/main.cpp0000664000175000017500000000213413641116416021625 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); QFontDatabase db; //qDebug()<. * * Authors: Yue Lan * */ #include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include #include #include bool init_style = false; bool init_icon_theme = false; bool init_system_font = false; bool init_system_font_size = false; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QGSettings settings("org.ukui.style", "/org/ukui/style/"); auto currentStyle = settings.get("styleName").toString(); auto currentIconTheme = settings.get("iconThemeName").toString(); auto styles = QStyleFactory::keys(); styles.removeOne("ukui"); QStringListModel *style_model = new QStringListModel(styles, this); ui->comboBox->setModel(style_model); ui->comboBox->setCurrentText(currentStyle); QDir iconThemePaths = QDir("/usr/share/icons"); auto iconThemes = iconThemePaths.entryList(QDir::Dirs); QStringListModel *icon_theme_model = new QStringListModel(iconThemes, this); ui->comboBox_2->setModel(icon_theme_model); ui->comboBox_2->setCurrentText(currentIconTheme); QFontDatabase db; QStringListModel *fonts_model = new QStringListModel(db.families(), this); ui->comboBox_3->setModel(fonts_model); ui->comboBox_3->setCurrentText(settings.get("systemFont").toString()); ui->spinBox->setValue(settings.get("systemFontSize").toInt()); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_comboBox_currentIndexChanged(const QString &arg1) { if (!init_style) { init_style = true; return; } //change style QGSettings settings("org.ukui.style", "/org/ukui/style/"); settings.set("styleName", arg1); } void MainWindow::on_comboBox_2_currentIndexChanged(const QString &arg1) { if (!init_icon_theme) { init_icon_theme = true; return; } //change icon theme QGSettings settings("org.ukui.style", "/org/ukui/style/"); settings.set("iconThemeName", arg1); } void MainWindow::on_horizontalSlider_valueChanged(int value) { QGSettings settings("org.ukui.style", "/org/ukui/style/"); settings.set("menuTransparency", value); } void MainWindow::on_comboBox_3_currentTextChanged(const QString &arg1) { if (!init_system_font) { init_system_font = true; return; } bool enableMenuSettings = true; if (arg1 != "ukui-white" || arg1 != "ukui-black") { enableMenuSettings = false; } ui->horizontalSlider->setEnabled(enableMenuSettings); QGSettings settings("org.ukui.style", "/org/ukui/style/"); settings.set("systemFont", arg1); } void MainWindow::on_spinBox_valueChanged(int arg1) { if (!init_system_font_size) { init_system_font_size = true; return; } QGSettings settings("org.ukui.style", "/org/ukui/style/"); settings.set("systemFontSize", arg1); } qt5-ukui-platformtheme/test/system-settings/mainwindow.h0000664000175000017500000000256413641116416022531 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_comboBox_currentIndexChanged(const QString &arg1); void on_comboBox_2_currentIndexChanged(const QString &arg1); void on_horizontalSlider_valueChanged(int value); void on_comboBox_3_currentTextChanged(const QString &arg1); void on_spinBox_valueChanged(int arg1); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H qt5-ukui-platformtheme/test/system-settings/system-settings.pro0000664000175000017500000000235013641116416024101 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-01-03T20:37:30 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = system-settings TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 link_pkgconfig PKGCONFIG += gsettings-qt SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui # Default rules for deployment. #qnx: target.path = /tmp/$${TARGET}/bin #else: unix:!android: target.path = /opt/$${TARGET}/bin #!isEmpty(target.path): INSTALLS += target qt5-ukui-platformtheme/test/system-settings/mainwindow.ui0000664000175000017500000000462513641116416022717 0ustar fengfeng MainWindow 0 0 400 344 MainWindow style icon menu opacity Qt::Horizontal font 11 0 0 400 29 TopToolBarArea false qt5-ukui-platformtheme/test/mps-style-application/0000775000175000017500000000000013643026433021252 5ustar fengfengqt5-ukui-platformtheme/test/mps-style-application/main.cpp0000664000175000017500000000200713641116416022700 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include #include "internal-styles/mps-style.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setStyle(new MPSStyle); MainWindow w; w.show(); return a.exec(); } qt5-ukui-platformtheme/test/mps-style-application/mainwindow.cpp0000664000175000017500000000176013641116416024135 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } qt5-ukui-platformtheme/test/mps-style-application/mainwindow.h0000664000175000017500000000207613641116416023603 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H qt5-ukui-platformtheme/test/mps-style-application/mainwindow.ui0000664000175000017500000000515613641116416023773 0ustar fengfeng MainWindow 0 0 400 300 MainWindow 50 20 337 200 PushButton ... RadioButton QDialogButtonBox::Cancel|QDialogButtonBox::Ok Qt::Horizontal 24 0 0 400 37 TopToolBarArea false qt5-ukui-platformtheme/test/mps-style-application/mps-style-application.pro0000664000175000017500000000245513641116416026237 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-02-11T15:20:45 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = mps-style-application TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += plugin c++11 link_pkgconfig PKGCONFIG += gsettings-qt include(../../libqt5-ukui-style/libqt5-ukui-style.pri) SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui # Default rules for deployment. #qnx: target.path = /tmp/$${TARGET}/bin #else: unix:!android: target.path = /opt/$${TARGET}/bin #!isEmpty(target.path): INSTALLS += target qt5-ukui-platformtheme/test/tabwidget/0000775000175000017500000000000013643026434016767 5ustar fengfengqt5-ukui-platformtheme/test/tabwidget/main.cpp0000664000175000017500000000213213641116416020413 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "widget.h" #include /// make a QTabWidget have a slide animation. /// This is integrated in ukui style by default. /// \see /// Qt5UKUIStyle, UKUI::TabWidget::DefaultSlideAnimator. int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } qt5-ukui-platformtheme/test/tabwidget/widget.h0000664000175000017500000000171713641116416020427 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QTabWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); }; #endif // WIDGET_H qt5-ukui-platformtheme/test/tabwidget/widget.cpp0000664000175000017500000000305113641116416020753 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "widget.h" #include #include #include #include #include #include Widget::Widget(QWidget *parent) : QTabWidget(parent) { auto v1 = new QListView(this); v1->setViewMode(QListView::IconMode); auto m1 = new QFileSystemModel(v1); v1->setModel(m1); m1->setRootPath("/"); v1->setRootIndex(m1->index("/")); addTab(v1, "view1"); auto v2 = new QTreeView; v2->setModel(m1); v2->setRootIndex(m1->index("/")); addTab(v2, "view2"); addTab(new QPushButton("test1", this), "test1"); addTab(new QLabel("test2", this), "test2"); addTab(new QPushButton("test3", this), "test3"); addTab(new QLabel("test4", this), "test4"); } Widget::~Widget() { } qt5-ukui-platformtheme/test/tabwidget/tabwidget.pro0000664000175000017500000000221713641116416021463 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-01-09T11:25:46 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = tabwidget TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 SOURCES += \ main.cpp \ widget.cpp HEADERS += \ widget.h # Default rules for deployment. #qnx: target.path = /tmp/$${TARGET}/bin #else: unix:!android: target.path = /opt/$${TARGET}/bin #!isEmpty(target.path): INSTALLS += target qt5-ukui-platformtheme/test/test.pro0000664000175000017500000000022113641116416016507 0ustar fengfengTEMPLATE = subdirs SUBDIRS += \ highlighted-icon-button \ region-blur \ system-settings \ tabwidget \ mps-style-application qt5-ukui-platformtheme/test/region-blur/0000775000175000017500000000000013643026433017241 5ustar fengfengqt5-ukui-platformtheme/test/region-blur/main.cpp0000664000175000017500000000222613641116416020672 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setStyle("ukui"); MainWindow w; w.setWindowTitle("blur tool bar region"); w.show(); QMainWindow w2; w2.setWindowTitle("whole window blur"); w2.setAttribute(Qt::WA_TranslucentBackground); w2.show(); return a.exec(); } qt5-ukui-platformtheme/test/region-blur/region-blur.pro0000664000175000017500000000223113641116416022205 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-01-03T10:58:54 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = region-blur TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h # Default rules for deployment. #qnx: target.path = /tmp/$${TARGET}/bin #else: unix:!android: target.path = /opt/$${TARGET}/bin #!isEmpty(target.path): INSTALLS += target qt5-ukui-platformtheme/test/region-blur/mainwindow.cpp0000664000175000017500000000327313641116416022125 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setAttribute(Qt::WA_TranslucentBackground); m_tool_bar = new QToolBar(this); m_tool_bar->addAction("test1"); m_tool_bar->addAction("test2"); m_tool_bar->addAction("test3"); m_tool_bar->addAction("test4"); addToolBar(m_tool_bar); m_list_view = new QListWidget(this); m_list_view->setAttribute(Qt::WA_TranslucentBackground); m_list_view->setAttribute(Qt::WA_Hover); m_list_view->setStyleSheet("background: transparent"); m_list_view->addItem("test1"); m_list_view->addItem("test2"); m_list_view->addItem("test3"); m_list_view->addItem("test4"); setCentralWidget(m_list_view); } MainWindow::~MainWindow() { } void MainWindow::resizeEvent(QResizeEvent *e) { QMainWindow::resizeEvent(e); m_blur_region = m_tool_bar->rect(); } qt5-ukui-platformtheme/test/region-blur/mainwindow.h0000664000175000017500000000262313641116416021570 0ustar fengfeng/* * Qt5-UKUI * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include class QListWidget; class QToolBar; class MainWindow : public QMainWindow { Q_OBJECT Q_PROPERTY(QRegion blurRegion READ blurRegion WRITE setBlurRegion MEMBER m_region) public: MainWindow(QWidget *parent = 0); ~MainWindow(); const QRegion blurRegion() {return m_blur_region;} void setBlurRegion(const QRegion ®ion) {m_blur_region = region;} protected: void resizeEvent(QResizeEvent *e); private: QListWidget *m_list_view; QToolBar *m_tool_bar; QRegion m_blur_region = QRegion(); }; #endif // MAINWINDOW_H qt5-ukui-platformtheme/COPYING0000664000175000017500000001674413641116416015103 0ustar fengfeng GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. qt5-ukui-platformtheme/ukui-styles/0000775000175000017500000000000013643026434016334 5ustar fengfengqt5-ukui-platformtheme/ukui-styles/ukui-styles.pro0000664000175000017500000000010613641116416021347 0ustar fengfengTEMPLATE = subdirs SUBDIRS += \ proxy-style \ qt5-style-ukui qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/0000775000175000017500000000000013643027460021156 5ustar fengfengqt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/tab-widget-animation-helper.cpp0000664000175000017500000000304513641116416027143 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "tab-widget-animation-helper.h" #include "tabwidget/ukui-tabwidget-default-slide-animator.h" TabWidgetAnimationHelper::TabWidgetAnimationHelper(QObject *parent) : AnimationHelper(parent) { } bool TabWidgetAnimationHelper::registerWidget(QWidget *w) { auto animator = new UKUI::TabWidget::DefaultSlideAnimator; if (!animator->bindWidget(w)) return false; m_animators->insert(w, animator); return true; } bool TabWidgetAnimationHelper::unregisterWidget(QWidget *w) { auto animator = m_animators->value(w); if (animator) { animator->unboundWidget(); } m_animators->remove(w); return true; } AnimatorIface *TabWidgetAnimationHelper::animator(const QWidget *w) { return m_animators->value(w); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/button-animation-helper.cpp0000664000175000017500000000322013641116416026422 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "button-animation-helper.h" #include "animations/button-animator.h" #include ButtonAnimationHelper::ButtonAnimationHelper(QObject *parent) : AnimationHelper(parent) { } bool ButtonAnimationHelper::registerWidget(QWidget *w) { auto animator = new UKUI::Button::ButtonAnimator; bool result = animator->bindWidget(w); if (!result) { animator->deleteLater(); } else { m_animators->insert(w, animator); } return result; } bool ButtonAnimationHelper::unregisterWidget(QWidget *w) { auto animator= m_animators->value(w); bool result = false; if (animator) { result = animator->unboundWidget(); delete animator; } m_animators->remove(w); return result; } AnimatorIface *ButtonAnimationHelper::animator(const QWidget *w) { return m_animators->value(w); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-ukui-style-plugin.h0000664000175000017500000000241313641116416025443 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef QT5UKUISTYLEPLUGIN_H #define QT5UKUISTYLEPLUGIN_H #include class Qt5UKUIStylePlugin : public QStylePlugin { Q_OBJECT #if QT_VERSION >= 0x050000 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "qt5-style-ukui.json") #endif // QT_VERSION >= 0x050000 public: Qt5UKUIStylePlugin(QObject *parent = 0); QStyle *create(const QString &key) override; const QStringList blackList(); }; #endif // QT5UKUISTYLEPLUGIN_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-ukui-style-helper.cpp0000664000175000017500000001032513643027460025762 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "qt5-ukui-style-helper.h" #include "ukui-style-settings.h" #include #include #include #include #include extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); void drawComboxPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); auto palette = option->palette; bool enable = option->state.testFlag(QStyle::State_Enabled); bool hover = option->state.testFlag(QStyle::State_MouseOver); if (enable) { if (hover) { painter->setBrush(palette.brush(QPalette::Normal, QPalette::Highlight)); } else { painter->setBrush(palette.brush(QPalette::Normal, QPalette::Base)); } } else { painter->setBrush(palette.brush(QPalette::Disabled, QPalette::Base)); } // painter->setFont(QColor(252,255,0)); painter->drawRoundedRect(option->rect.adjusted(+1,+1,-1,-1),4,4); painter->restore(); } void drawMenuPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) { //qDebug()<<"draw menu frame"<styleObject<palette; painter->save(); painter->setRenderHint(QPainter::Antialiasing); QPainterPath rectPath; rectPath.addRoundedRect(option->rect.adjusted(+5,+5,-5,-5), 6, 6); // Draw a black floor QPixmap pixmap(option->rect.size()); pixmap.fill(Qt::transparent); QPainter pixmapPainter(&pixmap); pixmapPainter.setRenderHint(QPainter::Antialiasing); pixmapPainter.setPen(Qt::transparent); pixmapPainter.setBrush(Qt::black); pixmapPainter.drawPath(rectPath); pixmapPainter.end(); // Blur the black background QImage img = pixmap.toImage(); qt_blurImage(img, 6, false, false); // Dig out the center part pixmap = QPixmap::fromImage(img); QPainter pixmapPainter2(&pixmap); pixmapPainter2.setRenderHint(QPainter::Antialiasing); pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); pixmapPainter2.setPen(Qt::transparent); pixmapPainter2.setBrush(Qt::transparent); pixmapPainter2.drawPath(rectPath); // Shadow rendering painter->drawPixmap(option->rect, pixmap, pixmap.rect()); //That's when I started drawing the frame floor QStyleOption opt = *option; auto color = opt.palette.color(QPalette::Base); if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; //qDebug()<setPen(Qt::transparent); painter->setBrush(color); QPainterPath path; auto region = widget->mask(); if (region.isEmpty()) { path.addRoundedRect(opt.rect.adjusted(+5,+5,-5,-5), 6, 6); } else { path.addRegion(region); } //painter->drawPolygon(path.toFillPolygon().toPolygon()); painter->drawPath(path); painter->restore(); return; } const QRegion getRoundedRectRegion(const QRect &rect, qreal radius_x, qreal radius_y) { QPainterPath path; path.addRoundedRect(rect, radius_x, radius_y); return path.toFillPolygon().toPolygon(); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/box-animation-helper.cpp0000664000175000017500000000316713641116416025711 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "box-animation-helper.h" #include "animations/box-animator.h" #include BoxAnimationHelper::BoxAnimationHelper(QObject *parent) : AnimationHelper(parent) { } bool BoxAnimationHelper::registerWidget(QWidget *w) { auto animator = new UKUI::Box::BoxAnimator; bool result = animator->bindWidget(w); if (!result) { animator->deleteLater(); } else { m_animators->insert(w, animator); } return result; } bool BoxAnimationHelper::unregisterWidget(QWidget *w) { auto animator= m_animators->value(w); bool result = false; if (animator) { result = animator->unboundWidget(); delete animator; } m_animators->remove(w); return result; } AnimatorIface *BoxAnimationHelper::animator(const QWidget *w) { return m_animators->value(w); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/animations/0000775000175000017500000000000013643026465023324 5ustar fengfengqt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/animations/button-animator.cpp0000664000175000017500000001233613643026465027160 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "button-animator.h" #include #include using namespace UKUI::Button; ButtonAnimator::ButtonAnimator(QObject *parent) : QParallelAnimationGroup (parent) { m_mouseover = new QVariantAnimation(this); m_mouseover->setStartValue(0.0); m_mouseover->setEndValue(1.0); m_mouseover->setDuration(100); m_mouseover->setEasingCurve(QEasingCurve::OutCubic); addAnimation(m_mouseover); m_sunken = new QVariantAnimation(this); m_sunken->setStartValue(0.0); m_sunken->setEndValue(1.0); m_sunken->setDuration(75); m_sunken->setEasingCurve(QEasingCurve::InCubic); addAnimation(m_sunken); } bool ButtonAnimator::bindWidget(QWidget *w) { if (qobject_cast(w)) { if (w->property("doNotAnimate").toBool()) return false; m_widget = w; return true; } else if(qobject_cast(w)) { if(w->property("doNotAnimate").toBool()) return false; m_widget = w; return true; } return false; } bool ButtonAnimator::unboundWidget() { this->stop(); this->setDirection(QAbstractAnimation::Forward); if (m_widget) { this->setParent(nullptr); return true; } return false; } QVariant ButtonAnimator::value(const QString &property) { if(property == "MouseOver") return m_mouseover->currentValue(); else if(property == "SunKen") return m_sunken->currentValue(); else return QVariant(); } bool ButtonAnimator::isRunning(const QString &property) { if(property == "MouseOver") return m_mouseover->state() == Running; else if(property == "SunKen") return m_sunken->state() == Running; else return this->state() == Running; } bool ButtonAnimator::setAnimatorStartValue(const QString &property, const QVariant &value) { if(property == "MouseOver") { m_mouseover->setStartValue(value); return true; } else if(property == "SunKen") { m_sunken->setStartValue(value); return true; } else { return false; } } bool ButtonAnimator::setAnimatorEndValue(const QString &property, const QVariant &value) { if(property == "MouseOver") { m_mouseover->setEndValue(value); return true; } else if(property == "SunKen") { m_sunken->setEndValue(value); return true; } else { return false; } } bool ButtonAnimator::setAnimatorDuration(const QString &property, int duration) { if(property == "MouseOver") { m_mouseover->setDuration(duration); return true; } else if(property == "SunKen") { m_sunken->setDuration(duration); return true; } else { return false; } } void ButtonAnimator::setAnimatorDirectionForward(const QString &property, bool forward) { auto d = forward? QAbstractAnimation::Forward: QAbstractAnimation::Backward; if(property == "MouseOver") m_mouseover->setDirection(d); else if(property == "SunKen") m_sunken->setDirection(d); else return; } void ButtonAnimator::startAnimator(const QString &property) { if(property == "MouseOver") m_mouseover->start(); else if(property == "SunKen") m_sunken->start(); else this->start(); } void ButtonAnimator::stopAnimator(const QString &property) { if(property == "MouseOver") { m_mouseover->stop(); m_mouseover->setCurrentTime(0); } else if(property == "SunKen") { m_sunken->stop(); m_sunken->setCurrentTime(0); } else { this->stop(); this->setCurrentTime(0); } } int ButtonAnimator::currentAnimatorTime(const QString &property) { if(property == "MouseOver") return m_mouseover->currentTime(); else if(property == "SunKen") return m_sunken->currentTime(); else return this->currentTime(); } int ButtonAnimator::totalAnimationDuration(const QString &property) { if(property == "MouseOver") return m_mouseover->duration(); else if(property == "SunKen") return m_sunken->duration(); else return this->duration(); } QVariant ButtonAnimator::endValue(const QString &property) { if(property == "MouseOver") return m_mouseover->endValue(); else if(property == "SunKen") return m_sunken->endValue(); else return this->endValue(); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/animations/box-animator.cpp0000664000175000017500000001136313641116416026426 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "box-animator.h" #include using namespace UKUI::Box; BoxAnimator::BoxAnimator(QObject *parent) : QParallelAnimationGroup (parent) { m_mouseover = new QVariantAnimation(this); m_mouseover->setStartValue(0.0); m_mouseover->setEndValue(1.0); m_mouseover->setDuration(100); m_mouseover->setEasingCurve(QEasingCurve::OutCubic); addAnimation(m_mouseover); m_sunken = new QVariantAnimation(this); m_sunken->setStartValue(0.0); m_sunken->setEndValue(1.0); m_sunken->setDuration(75); m_sunken->setEasingCurve(QEasingCurve::InCubic); addAnimation(m_sunken); } bool BoxAnimator::bindWidget(QWidget *w) { if (qobject_cast(w)) { if (w->property("doNotAnimate").toBool()) return false; m_widget = w; return true; } return false; } bool BoxAnimator::unboundWidget() { this->stop(); this->setDirection(QAbstractAnimation::Forward); if (m_widget) { this->setParent(nullptr); return true; } return false; } QVariant BoxAnimator::value(const QString &property) { if(property == "MouseOver") return m_mouseover->currentValue(); else if(property == "SunKen") return m_sunken->currentValue(); else return QVariant(); } bool BoxAnimator::isRunning(const QString &property) { if(property == "MouseOver") return m_mouseover->state() == Running; else if(property == "SunKen") return m_sunken->state() == Running; else return this->state() == Running; } bool BoxAnimator::setAnimatorStartValue(const QString &property, const QVariant &value) { if(property == "MouseOver") { m_mouseover->setStartValue(value); return true; } else if(property == "SunKen") { m_sunken->setStartValue(value); return true; } else { return false; } } bool BoxAnimator::setAnimatorEndValue(const QString &property, const QVariant &value) { if(property == "MouseOver") { m_mouseover->setEndValue(value); return true; } else if(property == "SunKen") { m_sunken->setEndValue(value); return true; } else { return false; } } bool BoxAnimator::setAnimatorDuration(const QString &property, int duration) { if(property == "MouseOver") { m_mouseover->setDuration(duration); return true; } else if(property == "SunKen") { m_sunken->setDuration(duration); return true; } else { return false; } } void BoxAnimator::setAnimatorDirectionForward(const QString &property, bool forward) { auto d = forward? QAbstractAnimation::Forward: QAbstractAnimation::Backward; if(property == "MouseOver") m_mouseover->setDirection(d); else if(property == "SunKen") m_sunken->setDirection(d); else return; } void BoxAnimator::startAnimator(const QString &property) { if(property == "MouseOver") m_mouseover->start(); else if(property == "SunKen") m_sunken->start(); else this->start(); } void BoxAnimator::stopAnimator(const QString &property) { if(property == "MouseOver") { m_mouseover->stop(); m_mouseover->setCurrentTime(0); } else if(property == "SunKen") { m_sunken->stop(); m_sunken->setCurrentTime(0); } else { this->stop(); this->setCurrentTime(0); } } int BoxAnimator::currentAnimatorTime(const QString &property) { if(property == "MouseOver") return m_mouseover->currentTime(); else if(property == "SunKen") return m_sunken->currentTime(); else return this->currentTime(); } int BoxAnimator::totalAnimationDuration(const QString &property) { if(property == "MouseOver") return m_mouseover->duration(); else if(property == "SunKen") return m_sunken->duration(); else return this->duration(); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/animations/animations.pri0000664000175000017500000000024313641116416026173 0ustar fengfengINCLUDEPATH += $$PWD HEADERS += \ $$PWD/box-animator.h \ $$PWD/button-animator.h SOURCES += \ $$PWD/box-animator.cpp \ $$PWD/button-animator.cpp qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/animations/button-animator.h0000664000175000017500000000416513641116416026620 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef BUTTONANIMATOR_H #define BUTTONANIMATOR_H #include #include #include #include "animator-iface.h" namespace UKUI { namespace Button { class ButtonAnimator : public QParallelAnimationGroup, public AnimatorIface { Q_OBJECT public: explicit ButtonAnimator(QObject *parent = nullptr); bool bindWidget(QWidget *w); bool unboundWidget(); QWidget *boundedWidget() {return m_widget;} QVariant value(const QString &property); bool setAnimatorStartValue(const QString &property, const QVariant &value); bool setAnimatorEndValue(const QString &property, const QVariant &value); bool setAnimatorDuration(const QString &property, int duration); void setAnimatorDirectionForward(const QString &property = nullptr, bool forward = true); bool isRunning(const QString &property = nullptr); void startAnimator(const QString &property = nullptr); void stopAnimator(const QString &property = nullptr); int currentAnimatorTime(const QString &property = nullptr); int totalAnimationDuration(const QString &property = nullptr); QVariant endValue(const QString &property = nullptr); signals: private: QWidget* m_widget = nullptr; QVariantAnimation *m_mouseover; QVariantAnimation *m_sunken; }; } } #endif // BUTTONANIMATOR_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/animations/box-animator.h0000664000175000017500000000404513641116416026072 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef BOXANIMATOR_H #define BOXANIMATOR_H #include #include #include #include "animator-iface.h" namespace UKUI { namespace Box { class BoxAnimator : public QParallelAnimationGroup, public AnimatorIface { Q_OBJECT public: explicit BoxAnimator(QObject *parent = nullptr); bool bindWidget(QWidget *w); bool unboundWidget(); QWidget *boundedWidget() {return m_widget;} QVariant value(const QString &property); bool setAnimatorStartValue(const QString &property, const QVariant &value); bool setAnimatorEndValue(const QString &property, const QVariant &value); bool setAnimatorDuration(const QString &property, int duration); void setAnimatorDirectionForward(const QString &property = nullptr, bool forward = true); bool isRunning(const QString &property = nullptr); void startAnimator(const QString &property = nullptr); void stopAnimator(const QString &property = nullptr); int currentAnimatorTime(const QString &property = nullptr); int totalAnimationDuration(const QString &property = nullptr); signals: private: QWidget* m_widget = nullptr; QVariantAnimation *m_mouseover; QVariantAnimation *m_sunken; }; } } #endif // BOXANIMATOR_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-ukui-style-plugin.cpp0000664000175000017500000000334313641116416026001 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "qt5-ukui-style-plugin.h" #include "qt5-ukui-style.h" #include #include "black-list.h" #include #include Qt5UKUIStylePlugin::Qt5UKUIStylePlugin(QObject *parent) : QStylePlugin(parent) { } QStyle *Qt5UKUIStylePlugin::create(const QString &key) { if (blackList().contains(qAppName())) return new QFusionStyle; //FIXME: bool dark = false; bool useDefault = false; if (key == "ukui-black" || key == "ukui-dark") { qDebug()<<"use ukui-black"; dark = true; } else if (key == "ukui-white" || key == "ukui-light") { qDebug()<<"use ukui-white"; } else { useDefault = true; } return new Qt5UKUIStyle(dark, useDefault); } const QStringList Qt5UKUIStylePlugin::blackList() { return blackAppList(); } #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2(qt5-style-ukui, Qt5UKUIStylePlugin) #endif // QT_VERSION < 0x050000 qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-ukui-style-helper.h0000664000175000017500000000227313641116416025430 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef QT5UKUISTYLEHELPER_H #define QT5UKUISTYLEHELPER_H #include "qt5-ukui-style.h" void drawComboxPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget); void drawMenuPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget); const QRegion getRoundedRectRegion(const QRect &rect, qreal radius_x, qreal radius_y); #endif // QT5UKUISTYLEHELPER_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-style-ukui.pro0000664000175000017500000000315213643027460024523 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-01-03T19:31:51 # #------------------------------------------------- QT += widgets widgets-private TARGET = qt5-style-ukui TEMPLATE = lib CONFIG += plugin c++11 link_pkgconfig PKGCONFIG += gsettings-qt include(../../libqt5-ukui-style/libqt5-ukui-style.pri) include(animations/animations.pri) # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_NO_DEBUG_OUTPUT # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ box-animation-helper.cpp \ button-animation-helper.cpp \ qt5-ukui-style-plugin.cpp \ qt5-ukui-style.cpp \ tab-widget-animation-helper.cpp \ scrollbar-animation-helper.cpp \ qt5-ukui-style-helper.cpp HEADERS += \ box-animation-helper.h \ button-animation-helper.h \ qt5-ukui-style-plugin.h \ qt5-ukui-style.h \ tab-widget-animation-helper.h \ scrollbar-animation-helper.h \ qt5-ukui-style-helper.h DISTFILES += qt5-style-ukui.json unix { target.path = $$[QT_INSTALL_PLUGINS]/styles INSTALLS += target } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/button-animation-helper.h0000664000175000017500000000242513641116416026075 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef BUTTONANIMATIONHELPER_H #define BUTTONANIMATIONHELPER_H #include #include "animation-helper.h" #include "animator-iface.h" #include "button-animator.h" class ButtonAnimationHelper: public AnimationHelper { Q_OBJECT public: ButtonAnimationHelper(QObject *parent = nullptr); bool registerWidget(QWidget *w); bool unregisterWidget(QWidget *w); AnimatorIface *animator(const QWidget *w); signals: public slots: }; #endif // BUTTONANIMATIONHELPER_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/box-animation-helper.h0000664000175000017500000000240413641116416025347 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef BOXANIMATIONHELPER_H #define BOXANIMATIONHELPER_H #include #include "animation-helper.h" #include "animator-iface.h" #include "box-animator.h" class BoxAnimationHelper : public AnimationHelper { Q_OBJECT public: BoxAnimationHelper(QObject *parent = nullptr); bool registerWidget(QWidget *w); bool unregisterWidget(QWidget *w); AnimatorIface *animator(const QWidget *w); signals: public slots: }; #endif // BOXANIMATIONHELPER_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-ukui-style.h0000664000175000017500000000777213641116416024164 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef QT5UKUISTYLE_H #define QT5UKUISTYLE_H #include #include class TabWidgetAnimationHelper; class ScrollBarAnimationHelper; class ButtonAnimationHelper; class BoxAnimationHelper; class QStyleOptionViewItem; /*! * \brief The Qt5UKUIStyle class * \details * This class provide the default ukui style in UKUI desktop enviroment. */ class Qt5UKUIStyle : public QFusionStyle { Q_OBJECT public: explicit Qt5UKUIStyle(bool dark = false, bool useDefault = true); const QStringList specialList() const; bool shouldBeTransparent(const QWidget *w) const; //debuger bool eventFilter(QObject *obj, QEvent *e); int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const; void polish(QWidget *widget); void unpolish(QWidget *widget); void polish(QPalette& palette) ; QPalette standardPalette() const; void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const; void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const; QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget = nullptr) const; void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const; protected: void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const; QRect scrollBarSubControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget = nullptr) const; void realSetWindowSurfaceFormatAlpha(const QWidget *widget) const; void realSetMenuTypeToMenu(const QWidget *widget) const; void drawComBoxIndicator(SubControl which, const QStyleOptionComplex *option,QPainter *painter) const; QRect centerRect(const QRect &rect, int width, int height) const; private: TabWidgetAnimationHelper *m_tab_animation_helper; ScrollBarAnimationHelper *m_scrollbar_animation_helper; ButtonAnimationHelper* m_button_animation_helper; BoxAnimationHelper* m_combobox_animation_helper; bool m_use_dark_palette = false; bool m_is_default_style = true; }; #endif // QT5UKUISTYLE_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/tab-widget-animation-helper.h0000664000175000017500000000233513641116416026611 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef TABWIDGETANIMATIONHELPER_H #define TABWIDGETANIMATIONHELPER_H #include #include "animation-helper.h" class TabWidgetAnimationHelper : public AnimationHelper { Q_OBJECT public: explicit TabWidgetAnimationHelper(QObject *parent = nullptr); bool registerWidget(QWidget *w); bool unregisterWidget(QWidget *w); AnimatorIface *animator(const QWidget *w); }; #endif // TABWIDGETANIMATIONHELPER_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/scrollbar-animation-helper.h0000664000175000017500000000236513641116416026550 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef SCROLLBARANIMATIONHELPER_H #define SCROLLBARANIMATIONHELPER_H #include #include "animation-helper.h" class ScrollBarAnimationHelper : public AnimationHelper { Q_OBJECT public: explicit ScrollBarAnimationHelper(QObject *parent = nullptr); bool registerWidget(QWidget *w); bool unregisterWidget(QWidget *w); AnimatorIface *animator(const QWidget *w); signals: public slots: }; #endif // SCROLLBARANIMATIONHELPER_H qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-ukui-style.cpp0000664000175000017500000042752213643027460024520 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "qt5-ukui-style.h" #include "qt5-ukui-style-helper.h" #include "ukui-style-settings.h" #include "ukui-tabwidget-default-slide-animator.h" #include #include #include #include #include "tab-widget-animation-helper.h" #include "scrollbar-animation-helper.h" #include "button-animation-helper.h" #include "button-animator.h" #include "box-animation-helper.h" #include "animator-iface.h" #include "animation-helper.h" #include "highlight-effect.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); //---copy from qcommonstyle #include #include static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr) { if (lastVisibleLine) *lastVisibleLine = -1; qreal height = 0; qreal widthUsed = 0; textLayout.beginLayout(); int i = 0; while (true) { QTextLine line = textLayout.createLine(); if (!line.isValid()) break; line.setLineWidth(lineWidth); line.setPosition(QPointF(0, height)); height += line.height(); widthUsed = qMax(widthUsed, line.naturalTextWidth()); // we assume that the height of the next line is the same as the current one if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) { const QTextLine nextLine = textLayout.createLine(); *lastVisibleLine = nextLine.isValid() ? i : -1; break; } ++i; } textLayout.endLayout(); return QSizeF(widthUsed, height); } QString calculateElidedText(const QString &text, const QTextOption &textOption, const QFont &font, const QRect &textRect, const Qt::Alignment valign, Qt::TextElideMode textElideMode, int flags, bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) { QTextLayout textLayout(text, font); textLayout.setTextOption(textOption); // In AlignVCenter mode when more than one line is displayed and the height only allows // some of the lines it makes no sense to display those. From a users perspective it makes // more sense to see the start of the text instead something inbetween. const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter); int lastVisibleLine = -1; viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine); const QRectF boundingRect = textLayout.boundingRect(); // don't care about LTR/RTL here, only need the height const QRect layoutRect = QStyle::alignedRect(Qt::LayoutDirectionAuto, valign, boundingRect.size().toSize(), textRect); if (paintStartPosition) *paintStartPosition = QPointF(textRect.x(), layoutRect.top()); QString ret; qreal height = 0; const int lineCount = textLayout.lineCount(); for (int i = 0; i < lineCount; ++i) { const QTextLine line = textLayout.lineAt(i); height += line.height(); // above visible rect if (height + layoutRect.top() <= textRect.top()) { if (paintStartPosition) paintStartPosition->ry() += line.height(); continue; } const int start = line.textStart(); const int length = line.textLength(); const bool drawElided = line.naturalTextWidth() > textRect.width(); bool elideLastVisibleLine = lastVisibleLine == i; if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) { const QTextLine nextLine = textLayout.lineAt(i + 1); const int nextHeight = height + nextLine.height() / 2; // elide when less than the next half line is visible if (nextHeight + layoutRect.top() > textRect.height() + textRect.top()) elideLastVisibleLine = true; } QString text = textLayout.text().mid(start, length); if (drawElided || elideLastVisibleLine) { if (elideLastVisibleLine) { if (text.endsWith(QChar::LineSeparator)) text.chop(1); text += QChar(0x2026); } const QStackTextEngine engine(text, font); ret += engine.elidedText(textElideMode, textRect.width(), flags); // no newline for the last line (last visible or real) // sometimes drawElided is true but no eliding is done so the text ends // with QChar::LineSeparator - don't add another one. This happened with // arabic text in the testcase for QTBUG-72805 if (i < lineCount - 1 && !ret.endsWith(QChar::LineSeparator)) ret += QChar::LineSeparator; } else { ret += text; } // below visible text, can stop if ((height + layoutRect.top() >= textRect.bottom()) || (lastVisibleLine >= 0 && lastVisibleLine == i)) break; } return ret; } QString toolButtonElideText(const QStyleOptionToolButton *option, const QRect &textRect, int flags) { if (option->fontMetrics.horizontalAdvance(option->text) <= textRect.width()) return option->text; QString text = option->text; text.replace('\n', QChar::LineSeparator); QTextOption textOption; textOption.setWrapMode(QTextOption::ManualWrap); textOption.setTextDirection(option->direction); return calculateElidedText(text, textOption, option->font, textRect, Qt::AlignTop, Qt::ElideMiddle, flags, false, nullptr); } static QWindow *qt_getWindow(const QWidget *widget) { return widget ? widget->window()->windowHandle() : 0; } static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton, const QRect &rect, QPainter *painter, const QWidget *widget = 0) { QStyle::PrimitiveElement pe; switch (toolbutton->arrowType) { case Qt::LeftArrow: pe = QStyle::PE_IndicatorArrowLeft; break; case Qt::RightArrow: pe = QStyle::PE_IndicatorArrowRight; break; case Qt::UpArrow: pe = QStyle::PE_IndicatorArrowUp; break; case Qt::DownArrow: pe = QStyle::PE_IndicatorArrowDown; break; default: return; } QStyleOption arrowOpt = *toolbutton; arrowOpt.rect = rect; style->drawPrimitive(pe, &arrowOpt, painter, widget); } void Qt5UKUIStyle::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const { const QWidget *widget = option->widget; const int textMargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1; QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding const bool wrapText = option->features & QStyleOptionViewItem::WrapText; QTextOption textOption; textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap); textOption.setTextDirection(option->direction); textOption.setAlignment(QStyle::visualAlignment(option->direction, option->displayAlignment)); QPointF paintPosition; const QString newText = calculateElidedText(option->text, textOption, option->font, textRect, option->displayAlignment, option->textElideMode, 0, true, &paintPosition); QTextLayout textLayout(newText, option->font); textLayout.setTextOption(textOption); viewItemTextLayout(textLayout, textRect.width()); textLayout.draw(p, paintPosition); } //---copy from qcommonstyle Qt5UKUIStyle::Qt5UKUIStyle(bool dark, bool useDefault) : QFusionStyle () { m_is_default_style = useDefault; m_use_dark_palette = dark; m_tab_animation_helper = new TabWidgetAnimationHelper(this); m_scrollbar_animation_helper = new ScrollBarAnimationHelper(this); m_button_animation_helper = new ButtonAnimationHelper(this); m_combobox_animation_helper = new BoxAnimationHelper(this); } const QStringList Qt5UKUIStyle::specialList() const { //use dark palette in default style. QStringList l; l<<"ukui-menu"; l<<"ukui-panel"; l<<"ukui-sidebar"; return l; } bool Qt5UKUIStyle::shouldBeTransparent(const QWidget *w) const { bool should = false; if (w->inherits("QComboBoxPrivateContainer")) return true; if (w->inherits("QTipLabel")) return true; return should; } bool Qt5UKUIStyle::eventFilter(QObject *obj, QEvent *e) { /*! \bug There is a bug when use fusion as base style when in qt5 assistant's HelperView. ScrollBar will not draw with our overrided function correctly, and then it will trigger QEvent::StyleAnimationUpdate. by some how it will let HelperView be hidden. I eat this event to aviod this bug, but the scrollbar in HelperView still display with old fusion style, and the animation will be ineffective. I don't know why HelperView didn't use our function drawing scrollbar but fusion, that makes me stranged. */ if (e->type() == QEvent::StyleAnimationUpdate) { return true; } return false; } /* * Note there are some widgets can not be set as transparent one in polish. * Because it has been created as a rgb window. * * To reslove this problem, we have to let attribute be setted more ahead. * Some styleHint() methods are called in the early creation of a widget. * So we can real set them as alpha widgets. */ int Qt5UKUIStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { realSetWindowSurfaceFormatAlpha(widget); realSetMenuTypeToMenu(widget); switch (hint) { case SH_ScrollBar_Transient: return true; case SH_ItemView_ShowDecorationSelected: return true; case SH_DialogButtonBox_ButtonsHaveIcons: return int(true); case SH_DialogButtons_DefaultButton: return int(true); case SH_UnderlineShortcut: return true; case SH_ComboBox_Popup: return false; default: break; } return QFusionStyle::styleHint(hint, option, widget, returnData); } void Qt5UKUIStyle::polish(QPalette &palette){ palette = standardPalette(); return QFusionStyle::polish(palette); } QPalette Qt5UKUIStyle::standardPalette() const { auto palette = QFusionStyle::standardPalette(); //ukui-light QColor window_bg(231,231,231), window_no_bg(233,233,233), base_bg(255,255,255), base_no_bg(248, 248, 248), font_bg(0,0,0), font_br_bg(255,255,255), font_di_bg(191,191,191), button_bg(217,217,217), button_ac_bg(107,142,235), button_di_bg(233,233,233), highlight_bg(61,107,229), tip_bg(248,248,248), tip_font(22,22,22), alternateBase(248,248,248); if (m_use_dark_palette || (m_is_default_style && specialList().contains(qAppName()))) { //ukui-dark window_bg.setRgb(45,46,50); window_no_bg.setRgb(48,46,50); base_bg.setRgb(31,32,34); base_no_bg.setRgb(28,28,30); font_bg.setRgb(255,255,255); font_bg.setAlphaF(0.9); font_br_bg.setRgb(255,255,255); font_br_bg.setAlphaF(0.9); font_di_bg.setRgb(255,255,255); font_di_bg.setAlphaF(0.1); button_bg.setRgb(61,61,65); button_ac_bg.setRgb(48,48,51); button_di_bg.setRgb(48,48,51); highlight_bg.setRgb(61,107,229); tip_bg.setRgb(61,61,65); tip_font.setRgb(232,232,232); alternateBase.setRgb(36,35,40); } palette.setBrush(QPalette::Window,window_bg); palette.setBrush(QPalette::Active,QPalette::Window,window_bg); palette.setBrush(QPalette::Inactive,QPalette::Window,window_no_bg); palette.setBrush(QPalette::Disabled,QPalette::Window,window_no_bg); palette.setBrush(QPalette::WindowText,font_bg); palette.setBrush(QPalette::Active,QPalette::WindowText,font_bg); palette.setBrush(QPalette::Inactive,QPalette::WindowText,font_bg); palette.setBrush(QPalette::Disabled,QPalette::WindowText,font_di_bg); palette.setBrush(QPalette::Base,base_bg); palette.setBrush(QPalette::Active,QPalette::Base,base_bg); palette.setBrush(QPalette::Inactive,QPalette::Base,base_no_bg); palette.setBrush(QPalette::Disabled,QPalette::Base,base_no_bg); palette.setBrush(QPalette::Text,font_bg); palette.setBrush(QPalette::Active,QPalette::Text,font_bg); palette.setBrush(QPalette::Disabled,QPalette::Text,font_di_bg); //Cursor placeholder palette.setBrush(QPalette::PlaceholderText,font_di_bg); palette.setBrush(QPalette::ToolTipBase,tip_bg); palette.setBrush(QPalette::ToolTipText,tip_font); palette.setBrush(QPalette::Highlight,highlight_bg); palette.setBrush(QPalette::Active,QPalette::Highlight,highlight_bg); palette.setBrush(QPalette::HighlightedText,font_br_bg); palette.setBrush(QPalette::BrightText,font_br_bg); palette.setBrush(QPalette::Active,QPalette::BrightText,font_br_bg); palette.setBrush(QPalette::Inactive,QPalette::BrightText,font_br_bg); palette.setBrush(QPalette::Disabled,QPalette::BrightText,font_di_bg); palette.setBrush(QPalette::Button,button_bg); palette.setBrush(QPalette::Active,QPalette::Button,button_bg); palette.setBrush(QPalette::Inactive,QPalette::Button,button_bg); palette.setBrush(QPalette::Disabled,QPalette::Button,button_di_bg); palette.setBrush(QPalette::ButtonText,font_bg); palette.setBrush(QPalette::Inactive,QPalette::ButtonText,font_bg); palette.setBrush(QPalette::Disabled,QPalette::ButtonText,font_di_bg); palette.setBrush(QPalette::AlternateBase,alternateBase); palette.setBrush(QPalette::Inactive,QPalette::AlternateBase,alternateBase); palette.setBrush(QPalette::Disabled,QPalette::AlternateBase,button_di_bg); return palette; } void Qt5UKUIStyle::polish(QWidget *widget) { QFusionStyle::polish(widget); if (auto menu = qobject_cast(widget)) { //widget->setAttribute(Qt::WA_TranslucentBackground); HighLightEffect::setMenuIconHighlightEffect(menu); //QRegion mask = getRoundedRectRegion(widget->rect(), 10, 10); //widget->setMask(mask); //do not polish widget with proxy style. return; //qDebug()<mask(); } if (qobject_cast(widget)) { //FIXME: unpolish, extensiable. m_tab_animation_helper->registerWidget(widget); } if (qobject_cast(widget)) { widget->setAttribute(Qt::WA_Hover); m_scrollbar_animation_helper->registerWidget(widget); } if (auto v = qobject_cast(widget)) { v->viewport()->setAttribute(Qt::WA_Hover); } if(qobject_cast(widget)) { m_button_animation_helper->registerWidget(widget); } if(qobject_cast(widget)) { m_button_animation_helper->registerWidget(widget); } if(qobject_cast(widget)) { m_combobox_animation_helper->registerWidget(widget); } widget->installEventFilter(this); } void Qt5UKUIStyle::unpolish(QWidget *widget) { widget->removeEventFilter(this); if (qobject_cast(widget)) { widget->setAttribute(Qt::WA_TranslucentBackground, false); //widget->setMask(QRegion()); return; } if (qobject_cast(widget)) { m_tab_animation_helper->unregisterWidget(widget); } if (qobject_cast(widget)) { widget->setAttribute(Qt::WA_Hover, false); m_scrollbar_animation_helper->unregisterWidget(widget); } if (auto v = qobject_cast(widget)) { v->viewport()->setAttribute(Qt::WA_Hover); } if(qobject_cast(widget)) { m_button_animation_helper->unregisterWidget(widget); } if(qobject_cast(widget)) { m_button_animation_helper->unregisterWidget(widget); } if(qobject_cast(widget)) { m_combobox_animation_helper->unregisterWidget(widget); } QFusionStyle::unpolish(widget); } void Qt5UKUIStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { //qDebug()<<"draw PE"<isEnabled()) { return drawMenuPrimitive(option, painter, widget); } return QFusionStyle::drawPrimitive(element, option, painter, widget); } case PE_FrameFocusRect: { if (qobject_cast(widget)) return; break; } case PE_IndicatorBranch: { if (qobject_cast(widget)) { bool isHover = (option->state & State_MouseOver) && (option->state & ~State_Selected); bool isSelected = option->state & State_Selected; bool enable = option->state & State_Enabled; QColor color = option->palette.color(enable? QPalette::Active: QPalette::Disabled, QPalette::Highlight); QColor color2 = option->palette.color(enable? QPalette::Active: QPalette::Disabled, QPalette::HighlightedText); if (isSelected) { painter->fillRect(option->rect, color); auto vopt = qstyleoption_cast(option); QStyleOptionViewItem tmp = *vopt; tmp.palette.setColor(tmp.palette.currentColorGroup(), QPalette::Highlight, color2); QFusionStyle::drawPrimitive(PE_IndicatorBranch, &tmp, painter, widget); return; } else if (isHover) { color.setAlphaF(0.5); painter->fillRect(option->rect, color); } break; } } case PE_PanelItemViewItem: { bool isIconView = false; auto opt = qstyleoption_cast(option); if (!opt) return; if (opt) { isIconView = (opt->decorationPosition & QStyleOptionViewItem::Top); } bool isHover = (option->state & State_MouseOver) && (option->state & ~State_Selected); bool isSelected = option->state & State_Selected; bool enable = option->state & State_Enabled; QColor color = option->palette.color(enable? QPalette::Active: QPalette::Disabled, QPalette::Highlight); color.setAlpha(0); if (isHover) { color.setAlpha(127); } if (isSelected) { color.setAlpha(255); } if (!isIconView) painter->fillRect(option->rect, color); else { painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::transparent); painter->setBrush(color); painter->drawRoundedRect(option->rect, 6, 6); painter->restore(); } return; } case PE_Frame:{ painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(QPen(option->palette.color(QPalette::Normal, QPalette::Dark), 1)); painter->setBrush(Qt::NoBrush); painter->drawRoundedRect(option->rect,6,6); painter->restore(); return; } case PE_IndicatorHeaderArrow: //Here is the arrow drawing of the table box if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setBrush(Qt::NoBrush); if(option->state & State_Enabled){ painter->setPen(QPen(option->palette.foreground().color(), 1.1)); if (option->state & State_MouseOver) { painter->setPen(QPen(option->palette.color(QPalette::Highlight), 1.1)); } } else { painter->setPen(QPen(option->palette.color(QPalette::Text), 1.1)); } QPolygon points(4); //Add 8 to center vertically int x = option->rect.x()+8; int y = option->rect.y()+8; int w = 8; int h = 4; x += (option->rect.width() - w) / 2; y += (option->rect.height() - h) / 2; if (header->sortIndicator & QStyleOptionHeader::SortUp) { points[0] = QPoint(x, y); points[1] = QPoint(x + w / 2, y + h); points[2] = QPoint(x + w / 2, y + h); points[3] = QPoint(x + w, y); } else if (header->sortIndicator & QStyleOptionHeader::SortDown) { points[0] = QPoint(x, y + h); points[1] = QPoint(x + w / 2, y); points[2] = QPoint(x + w / 2, y); points[3] = QPoint(x + w, y + h); } painter->drawLine(points[0], points[1] ); painter->drawLine(points[2], points[3] ); painter->restore(); return; } case PE_PanelButtonCommand://UKUI PushButton style { if(const QStyleOptionButton *button = qstyleoption_cast(option)) { auto animator = m_button_animation_helper->animator(widget); if(animator == nullptr) return QFusionStyle::drawPrimitive(PE_PanelButtonCommand,option,painter,widget); if(!(button->state & State_Enabled)) { animator->stopAnimator("SunKen"); animator->stopAnimator("MouseOver"); painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Disabled,QPalette::Button)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); return; } if(!(button->state & State_AutoRaise)) { painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Button)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); } if((button->state & (State_Sunken | State_On)) || animator->isRunning("SunKen") || animator->value("SunKen") == 1.0) { double opacity = animator->value("SunKen").toDouble(); if(button->state & (State_Sunken | State_On)) { if(opacity == 0.0) { animator->setAnimatorDirectionForward("SunKen",true); animator->startAnimator("SunKen"); } } else { if(opacity == 1.0) { animator->setAnimatorDirectionForward("SunKen",false); animator->startAnimator("SunKen"); } } if (animator->isRunning("SunKen")) { const_cast(widget)->update(); } painter->save(); auto color = button->palette.color(QPalette::Highlight).lighter(125); painter->setBrush(color); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(button->rect,4,4); painter->restore(); painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(button->palette.color(QPalette::Highlight)); painter->setOpacity(opacity); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(button->rect,4,4); painter->restore(); return; } if(button->state & State_MouseOver || animator->isRunning("MouseOver") || animator->currentAnimatorTime("MouseOver") == animator->totalAnimationDuration("MouseOver")) { double opacity = animator->value("MouseOver").toDouble(); if(button->state & State_MouseOver) { animator->setAnimatorDirectionForward("MouseOver",true); if(opacity == 0.0) { animator->startAnimator("MouseOver"); } } else { animator->setAnimatorDirectionForward("MouseOver",false); if(opacity == 1.0) { animator->startAnimator("MouseOver"); } } if (animator->isRunning("MouseOver")) { const_cast(widget)->update(); } painter->save(); painter->setOpacity(opacity); auto color = button->palette.color(QPalette::Highlight).lighter(125); painter->setBrush(color); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(button->rect,4,4); painter->restore(); return; } return; } break; } // painter->save(); // painter->setRenderHint(QPainter::Antialiasing,true); // /*! // * \todo // * It is selected by default and not done first,because it conflicts with the normal button. // */ // // if(option->state & State_HasFocus){ // // painter->setPen(option->palette.color(QPalette::Disabled,QPalette::Button)); // // painter->setBrush(option->palette.color(QPalette::Highlight)); // // } // // else { // painter->setPen(Qt::NoPen); // painter->setBrush(option->palette.color(QPalette::Button)); // // } // if (option->state & State_MouseOver) { // if (option->state & State_Sunken) { // painter->setPen(Qt::NoPen); // painter->setBrush(option->palette.color(QPalette::Highlight)); // } else { // painter->setPen(Qt::NoPen); // painter->setBrush(option->palette.color(QPalette::Highlight)); // } // } // painter->drawRoundedRect(option->rect,4,4); // painter->restore(); // /*! // * \todo // * Judge whether it is OK or other buttons // */ // return; // } case PE_PanelTipLabel://UKUI Tip style: Open ground glass { if (widget->isEnabled()) { QStyleOption opt = *option; painter->save(); painter->setRenderHint(QPainter::Antialiasing); QPainterPath rectPath; rectPath.addRoundedRect(option->rect.adjusted(+3,+3,-3,-3), 4, 4); // Draw a black floor QPixmap pixmap(option->rect.size()); pixmap.fill(Qt::transparent); QPainter pixmapPainter(&pixmap); pixmapPainter.setRenderHint(QPainter::Antialiasing); pixmapPainter.setPen(Qt::transparent); pixmapPainter.setBrush(Qt::black); pixmapPainter.drawPath(rectPath); pixmapPainter.end(); // Blur the black background QImage img = pixmap.toImage(); qt_blurImage(img, 4, false, false); // Dig out the center part pixmap = QPixmap::fromImage(img); QPainter pixmapPainter2(&pixmap); pixmapPainter2.setRenderHint(QPainter::Antialiasing); pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); pixmapPainter2.setPen(Qt::transparent); pixmapPainter2.setBrush(Qt::transparent); pixmapPainter2.drawPath(rectPath); // Shadow rendering painter->drawPixmap(option->rect, pixmap, pixmap.rect()); //This is the beginning of drawing the bottom of the prompt box auto color = opt.palette.color(QPalette::ToolTipBase); if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; color.setAlphaF(opacity); } opt.palette.setColor(QPalette::ToolTipBase, color); painter->setRenderHint(QPainter::Antialiasing); QPen pen(opt.palette.toolTipBase().color().darker(150), 1); pen.setCapStyle(Qt::RoundCap); pen.setJoinStyle(Qt::RoundJoin); painter->setPen(Qt::transparent); painter->setBrush(color); QPainterPath path; auto region = widget->mask(); if (region.isEmpty()) { path.addRoundedRect(opt.rect.adjusted(+3,+3,-3,-3), 4, 4); } else { path.addRegion(region); } painter->drawPath(path); painter->restore(); return; } return QFusionStyle::drawPrimitive(element, option, painter, widget); } case PE_FrameStatusBar://UKUI Status style { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Dark)); painter->drawRect(option->rect); painter->restore(); return; } case PE_IndicatorButtonDropDown: //UKUI IndicatorButton style { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(Qt::NoPen); if(widget->isEnabled()){ if (option->state & State_MouseOver) { painter->setBrush(option->palette.color(QPalette::Highlight)); painter->drawRoundedRect(option->rect.left()-4,option->rect.y(),option->rect.width()+4,option->rect.height(),4,4); } } painter->restore(); return; } case PE_PanelButtonTool://UKUI ToolBar item style { /* * When the control does not require animation,please use the code annotated below */ // AnimatorIface* animator = new AnimatorIface(); // auto button_animator = m_button_animation_helper->animator(widget); // if(!(animator = button_animator)) // { // animator->setAnimatorDuration("SunKen",1); // animator->setAnimatorDuration("MouseOver",1); // animator->setAnimatorStartValue("SunKen",1); // animator->setAnimatorStartValue("MouseOver",1); // } auto animator = m_button_animation_helper->animator(widget); if(animator == nullptr) return QFusionStyle::drawPrimitive(PE_PanelButtonTool,option,painter,widget); if(!(option->state & State_Enabled)) { animator->stopAnimator("SunKen"); animator->stopAnimator("MouseOver"); painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Disabled,QPalette::Button)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); return; } if(!(option->state & State_AutoRaise)) { painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Button)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); } if(option->state & (State_Sunken | State_On) || animator->isRunning("SunKen") || animator->currentAnimatorTime("SunKen") == animator->totalAnimationDuration("SunKen")) { double opacity = animator->value("SunKen").toDouble(); if(option->state & (State_Sunken | State_On)) { if(opacity == 0.0) { animator->setAnimatorDirectionForward("SunKen",true); animator->startAnimator("SunKen"); } } else { if(animator->currentAnimatorTime("SunKen") == animator->totalAnimationDuration("SunKen")) { animator->setAnimatorDirectionForward("SunKen",false); animator->startAnimator("SunKen"); } } if (animator->isRunning("SunKen")) { const_cast(widget)->update(); } painter->save(); auto color = option->palette.color(QPalette::Highlight).lighter(125); painter->setBrush(color); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Highlight)); painter->setOpacity(opacity); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); return; } if(option->state & State_MouseOver || animator->isRunning("MouseOver") || animator->currentAnimatorTime("MouseOver") == animator->totalAnimationDuration("MouseOver")) { double opacity = animator->value("MouseOver").toDouble(); if(option->state & State_MouseOver) { animator->setAnimatorDirectionForward("MouseOver",true); if(opacity == 0.0) { animator->startAnimator("MouseOver"); } } else { animator->setAnimatorDirectionForward("MouseOver",false); if(opacity == 1.0) { animator->startAnimator("MouseOver"); } } if (animator->isRunning("MouseOver")) { const_cast(widget)->update(); } painter->save(); painter->setOpacity(opacity); auto color = option->palette.color(QPalette::Highlight).lighter(125); painter->setBrush(color); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); return; } return; } //Show this section when there are too many tabs case PE_IndicatorTabTear: { /* * To Do * Adjust to auto width instead of displaying this block */ return; } break; //This is rare. It's a line under the item case PE_FrameTabBarBase: if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast(option)) { painter->save(); painter->setPen(option->palette.base().color()); switch (tbb->shape) { case QTabBar::RoundedNorth: { QRegion region(tbb->rect); region -= tbb->selectedTabRect; painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight()); //No more second line // painter->setClipRegion(region); // painter->setPen(option->palette.base().color()); // painter->drawLine(tbb->rect.topLeft() + QPoint(0, 1), tbb->rect.topRight() + QPoint(0, 1)); } break; case QTabBar::RoundedWest: painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom()); break; case QTabBar::RoundedSouth: painter->drawLine(tbb->rect.left(), tbb->rect.bottom(), tbb->rect.right(), tbb->rect.bottom()); break; case QTabBar::RoundedEast: painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight()); break; case QTabBar::TriangularNorth: case QTabBar::TriangularEast: case QTabBar::TriangularWest: case QTabBar::TriangularSouth: //painter->restore(); QFusionStyle::drawPrimitive(element, option, painter, widget); return; } painter->restore(); return; } //This is the content box style in the table control case PE_FrameTabWidget: { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Base)); //painter->drawRect(option->rect.x()+2, //option->rect.y(),option->rect.width()/2,option->rect.height()/2); //painter->drawRoundedRect(option->rect.x()+5, //option->rect.y(),option->rect.width()-4,option->rect.height(),5,5); painter->drawRoundedRect(option->rect.adjusted(+2,+0,-2,+0),5,5); /*if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast(option)) { QColor borderColor = option->palette.color(QPalette::Light); QRect rect = option->rect.adjusted(0, 0, -1, -1); // Shadow outline if (twf->shape != QTabBar::RoundedSouth) { rect.adjust(0, 0, 0, -1); QColor alphaShadow(Qt::Window); alphaShadow.setAlpha(15); painter->setPen(alphaShadow); painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->setPen(borderColor); }*/ // outline // painter->setPen( option->palette.color(QPalette::Light)); //painter->drawRect(rect); // Inner frame highlight //painter->setPen( QColor(244,0,77)); //painter->drawRect(rect.adjusted(1, 1, -1, -1)); // } painter->restore(); return; } break ; case PE_FrameGroupBox: //UKUI GroupBox style: { /* * Remove the style of the bounding box according to the design */ //painter->save(); //painter->setRenderHint(QPainter::Antialiasing,true); //painter->setPen(option->palette.color(QPalette::Base)); //painter->setBrush(option->palette.color(QPalette::Base)); //painter->drawRoundedRect(option->rect,4,4); //painter->restore(); return; } case PE_PanelLineEdit://UKUI Text edit style { // Conflict with qspinbox and so on, The widget text cannot use this style if (widget) { if (widget->parentWidget()) if (widget->parentWidget()->inherits("QDoubleSpinBox")|widget->parentWidget()->inherits("QSpinBox")|widget->parentWidget()->inherits("QComboBox")) { return; } } painter->save(); if (const QStyleOptionFrame *panel = qstyleoption_cast(option)) { painter->setRenderHint(QPainter::Antialiasing,true); //Setpen is set to avoid a bug that collides with a white background painter->setPen(option->palette.color(QPalette::Window)); painter->setBrush(option->palette.color(QPalette::Base)); // if (panel->lineWidth > 0) // proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget); if (widget->isEnabled()) { if (option->state &State_MouseOver) { painter->setBrush(option->palette.button().color().lighter()); } if(option->state &State_HasFocus) { painter->setPen(option->palette.color(QPalette::Highlight)); painter->setBrush(option->palette.color(QPalette::Base)); } } painter->drawRoundedRect(panel->rect,4,4); } painter->restore(); return; } case PE_IndicatorCheckBox: { //UKUI CheckBox style if (const QStyleOptionButton *checkbox = qstyleoption_cast(option)) { painter->save(); painter->translate(0.5, 0.5); painter->setRenderHint(QPainter::Antialiasing,true); QColor selectpen=option->palette.color(QPalette::Mid); QColor selectbg; QColor selectmark; if (option->state&State_Enabled){ selectbg=option->palette.color(QPalette::Highlight); selectmark=option->palette.color(QPalette::HighlightedText); } else{ selectbg=option->palette.button().color(); selectmark=option->palette.color(QPalette::Mid); } const int maxFactor = 120; QColor tmp = option->palette.base().color(); tmp.setRed((tmp.red() * 85) / maxFactor + (option->palette.foreground().color().red() * (maxFactor - 85)) / maxFactor); tmp.setGreen((tmp.green() * 85) / maxFactor + (option->palette.foreground().color().green() * (maxFactor - 85)) / maxFactor); tmp.setBlue((tmp.blue() * 85) / maxFactor + (option->palette.foreground().color().blue() * (maxFactor - 85)) / maxFactor); painter->setPen(tmp); painter->setBrush(Qt::NoBrush); if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) painter->setPen(option->palette.color(QPalette::Highlight)); painter->drawRoundedRect(option->rect,3,3); painter->restore(); // if (option->state & State_MouseOver) // painter->setBrush(option->palette.color(QPalette::Highlight)); if (option->state & State_NoChange){//Non optional status selectpen=tmp; selectbg=Qt::NoBrush; selectmark=tmp; } else if (option->state & State_On) { painter->save(); painter->translate(0.5, 0.5); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(selectpen); painter->setBrush(selectbg); if(option->state & State_MouseOver){ painter->setPen(option->palette.midlight().color()); painter->setBrush( option->palette.highlight().color().lighter()); } else if (option->state & State_Sunken) { painter->setBrush( option->palette.highlight().color().darker()); } painter->drawRoundedRect(option->rect,3,3); painter->restore(); // Draw checkmark painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(QPen(selectmark,1.1)); const qreal checkMarkPadding = 1 + option->rect.width() * 0.13; // at least one pixel padding QPainterPath path; const qreal rectHeight = option->rect.height(); // assuming height equals width path.moveTo(checkMarkPadding + rectHeight * 0.11, rectHeight * 0.47); path.lineTo(rectHeight * 0.5, rectHeight - checkMarkPadding); path.lineTo(rectHeight - checkMarkPadding, checkMarkPadding); painter->drawPath(path.translated(option->rect.topLeft())); painter->restore(); } } return; } case PE_IndicatorArrowUp: case PE_IndicatorArrowDown: case PE_IndicatorArrowRight: case PE_IndicatorArrowLeft: { if (option->rect.width() <= 1 || option->rect.height() <= 1) break; QRect r = option->rect; int size = qMin(r.height(), r.width()); QPixmap pixmap; QString key; int width = option->rect.width(); int height = option->rect.height(); int state = option->state; int direction = element; while (width > 0) { char a = width % 10 + 48; key.insert(0,&a); width /= 10; } while (height > 0) { char a = height % 10 + 48; key.insert(0,&a); height /= 10; } while (state > 0) { char a = state % 10 + 48; key.insert(0,&a); state /= 10; } while (direction > 0) { char a = direction % 10 + 48; key.insert(0,&a); direction /= 10; } qreal pixelRatio = painter->device()->devicePixelRatioF(); int border = qRound(pixelRatio*(size/4)); int sqsize = qRound(pixelRatio*(2*(size/2))); if(size > 16) { border = pixelRatio*4; sqsize = pixelRatio*16; } if (!QPixmapCache::find(key, pixmap)) { QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied); image.fill(0); QPainter imagePainter(&image); int sx = 0; int sy = (sqsize/2 - border)/2; QLineF lines[2]; switch (element) { case PE_IndicatorArrowUp: lines[0] = QLine(border, sqsize/2, sqsize/2, border); lines[1] = QLine(sqsize/2, border, sqsize - border, sqsize/2); break; case PE_IndicatorArrowDown: lines[0] = QLine(border, border, sqsize/2, sqsize/2); lines[1] = QLine(sqsize/2, sqsize/2, sqsize - border, border); break; case PE_IndicatorArrowRight: lines[0] = QLine(border, border, sqsize/2, sqsize/2); lines[1] = QLine(sqsize/2, sqsize/2, border, sqsize - border); sx = (sqsize/2 - border)/2; sy = 0; break; case PE_IndicatorArrowLeft: lines[0] = QLine(sqsize/2, border, border, sqsize/2); lines[1] = QLine(border, sqsize/2, sqsize/2, sqsize - border); sx = (sqsize/2 - border)/2; sy = 0; break; default: break; } imagePainter.translate(sx , sy); imagePainter.setPen(Qt::NoPen); imagePainter.setPen(QPen(option->palette.foreground().color(), 1.1)); if (option->state & (State_MouseOver|State_Sunken)) { imagePainter.setPen(QPen(option->palette.color(QPalette::Light), 1.1)); } imagePainter.setBrush(Qt::NoBrush); imagePainter.setRenderHint(QPainter::Qt4CompatiblePainting); imagePainter.setRenderHint(QPainter::Antialiasing); if (!(option->state & State_Enabled)) { imagePainter.translate(1, 1); imagePainter.setPen(QPen(option->palette.foreground().color(), 1.3)); imagePainter.setBrush(Qt::NoBrush); imagePainter.drawLines(lines,2); // imagePainter.translate(-1, -1); // imagePainter.setBrush(option->palette.mid().color()); // imagePainter.setPen(option->palette.mid().color()); } else { imagePainter.drawLines(lines,2); } imagePainter.end(); pixmap = QPixmap::fromImage(image); pixmap.setDevicePixelRatio(pixelRatio); QPixmapCache::insert(key, pixmap); } int xOffset = r.x() + (r.width() - sqsize)/2; int yOffset = r.y() + (r.height() - sqsize)/2; painter->drawPixmap(xOffset, yOffset, pixmap); return; } case PE_IndicatorRadioButton:{ auto radiobutton = qstyleoption_cast(option); if (option->state & State_None){//Non optional status painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setBrush(option->palette.color(QPalette::Disabled,QPalette::Button)); painter->setPen(option->palette.color(QPalette::Disabled,QPalette::Mid)); painter->drawEllipse(option->rect.x()+1,option->rect.y(), 16.0, 16.0); painter->restore(); } else if (option->state & State_Off) { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setBrush(option->palette.color(QPalette::Button)); painter->setPen(option->palette.color(QPalette::Mid)); if (option->state & State_Sunken) { painter->setBrush(option->palette.color(QPalette::Highlight)); painter->setPen(QPen(option->palette.color(QPalette::Dark), 1)); }else if (option->state & State_MouseOver){ painter->setBrush(option->palette.color(QPalette::Highlight)); painter->setPen(QPen(option->palette.color(QPalette::Dark), 1)); } painter->drawEllipse(option->rect.x()+1,option->rect.y(), 16.0, 16.0); painter->restore(); } else if (option->state & State_On) { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setBrush(option->palette.color(QPalette::Highlight)); painter->setPen(QPen(option->palette.color(QPalette::Dark), 1)); if (option->state & State_Sunken) { painter->setBrush(option->palette.color(QPalette::Highlight)); painter->setPen(QPen(option->palette.color(QPalette::Dark), 1)); }else if(option->state & State_MouseOver){ painter->setBrush(option->palette.color(QPalette::Highlight)); painter->setPen(QPen(option->palette.color(QPalette::Dark), 1)); } painter->drawEllipse(option->rect.x()+1,option->rect.y(), 16.0, 16.0); painter->restore(); painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(option->palette.color(QPalette::HighlightedText)); painter->setBrush(option->palette.color(QPalette::HighlightedText)); painter->drawEllipse(option->rect.x()+6, option->rect.y()+5, 6.0, 6.0); painter->restore(); } return; } default: break; } return QFusionStyle::drawPrimitive(element, option, painter, widget); } void Qt5UKUIStyle::drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { case CC_ScrollBar: { const QStyleOptionSlider opt = *qstyleoption_cast(option); QStyleOption tmp = opt; //auto animatorObj = widget->findChild("ukui_scrollbar_default_interaction_animator"); auto animator = m_scrollbar_animation_helper->animator(widget); bool enable = option->state.testFlag(QStyle::State_Enabled); bool mouse_over = option->state.testFlag(QStyle::State_MouseOver); bool is_horizontal = option->state.testFlag(QStyle::State_Horizontal); if (!animator) { return QFusionStyle::drawComplexControl(control, option, painter, widget); } animator->setAnimatorDirectionForward("bg_opacity", mouse_over); animator->setAnimatorDirectionForward("groove_width", mouse_over); if (enable) { if (mouse_over) { if (!animator->isRunning("groove_width") && animator->currentAnimatorTime("groove_width") < animator->totalAnimationDuration("groove_width")) { animator->startAnimator("bg_opacity"); animator->startAnimator("groove_width"); } } else { if (!animator->isRunning("groove_width") && animator->currentAnimatorTime("groove_width") > 0) { animator->startAnimator("groove_width"); animator->startAnimator("bg_opacity"); } } } if (animator->isRunning("groove_width")) { const_cast(widget)->update(); } painter->save(); painter->setPen(Qt::transparent); painter->setBrush(tmp.palette.windowText()); auto percent = animator->value("groove_width").toInt()*1.0/12; painter->setOpacity(0.1*percent); auto grooveRect = option->rect; auto currentWidth = animator->value("groove_width").toInt(); if (is_horizontal) { grooveRect.setY(qMax(grooveRect.height() - currentWidth*2, 0)); } else { grooveRect.setX(qMax(grooveRect.width() - currentWidth*2, 0)); } if (widget->property("drawScrollBarGroove").isValid()) { if (!widget->property("drawScrollBarGroove").toBool()) { painter->restore(); return QCommonStyle::drawComplexControl(control, option, painter, widget); } } painter->drawRect(grooveRect); painter->restore(); return QCommonStyle::drawComplexControl(control, option, painter, widget); } case CC_ComboBox: { if(const QStyleOptionComboBox* combobox = qstyleoption_cast(option)) { auto animator = m_combobox_animation_helper->animator(widget); if(animator == nullptr) return QFusionStyle::drawComplexControl(CC_ComboBox,option,painter,widget); if(!(option->state & State_Enabled)) { animator->stopAnimator("SunKen"); animator->stopAnimator("MouseOver"); painter->save(); painter->setPen(QPen(option->palette.color(QPalette::Disabled,QPalette::Button),1,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); painter->setBrush(option->palette.color(QPalette::Disabled,QPalette::Button)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(option->rect,4,4); painter->restore(); return; } QRectF rect=subControlRect(CC_ComboBox,option,SC_ComboBoxFrame); painter->save(); painter->setPen(QPen(option->palette.color(QPalette::Button),1,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); painter->setBrush(option->palette.color(QPalette::Button)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(rect,4,4); painter->restore(); drawComBoxIndicator(SC_ComboBoxArrow,option,painter); //rect.adjust(1, 1, -1, -1); if((combobox->state & (State_Sunken | State_On)) || animator->isRunning("SunKen") || animator->currentAnimatorTime("SunKen") == animator->totalAnimationDuration("SunKen")) { double opacity = animator->value("SunKen").toDouble(); if(combobox->state & (State_Sunken | State_On)) { if(opacity == 0.0) { animator->setAnimatorDirectionForward("SunKen",true); animator->startAnimator("SunKen"); } } else { if(animator->currentAnimatorTime("SunKen") == animator->totalAnimationDuration("SunKen")) { animator->setAnimatorDirectionForward("SunKen",false); animator->startAnimator("SunKen"); } } if (animator->isRunning("SunKen")) { const_cast(widget)->update(); } //rect.adjust(1.4, 1.4, -1.4, -1.4); painter->save(); auto color = combobox->palette.color(QPalette::Highlight).lighter(125); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(color,1,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(rect,4,4); painter->restore(); painter->save(); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(combobox->palette.color(QPalette::Highlight),1,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); painter->setRenderHint(QPainter::Antialiasing,true); painter->drawRoundedRect(rect,4,4); painter->restore(); return; } if(combobox->state & State_MouseOver || animator->isRunning("MouseOver") || (animator->currentAnimatorTime("MouseOver") == animator->totalAnimationDuration("MouseOver"))) { double opacity = animator->value("MouseOver").toDouble(); if(combobox->state & State_MouseOver) { animator->setAnimatorDirectionForward("MouseOver",true); if(opacity == 0.0) { animator->startAnimator("MouseOver"); } } else { animator->setAnimatorDirectionForward("MouseOver",false); if(animator->currentAnimatorTime("MouseOver") == animator->totalAnimationDuration("MouseOver")) { animator->startAnimator("MouseOver"); } } if (animator->isRunning("MouseOver")) { const_cast(widget)->update(); } painter->save(); auto color = combobox->palette.color(QPalette::Highlight).lighter(125); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(color,1.0,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin)); painter->setRenderHint(QPainter::Antialiasing,true); painter->setOpacity(opacity); painter->drawRoundedRect(rect,4,4); painter->restore(); return; } return; } } // QRect rect=subControlRect(CC_ComboBox,option,SC_ComboBoxFrame); // rect.adjust(+1,+1,-1,-1); // painter->save(); // painter->setPen(option->palette.color(QPalette::Button)); // painter->setBrush(option->palette.color(QPalette::Button)); // painter->setRenderHint(QPainter::Antialiasing,true); // if (widget->isEnabled()) { // if (option->state & State_MouseOver) { // if (option->state & State_Sunken) { // painter->setPen(option->palette.color(QPalette::Highlight)); // } else { // painter->setPen(option->palette.color(QPalette::Highlight)); // } // } // if (option->state & State_On) { // painter->setPen(option->palette.color(QPalette::Highlight)); // } // } // painter->drawRoundedRect(rect,4,4); // painter->restore(); // drawComBoxIndicator(SC_ComboBoxArrow,option,painter); // return; // } case CC_SpinBox: { const QStyleOptionSpinBox *pb=qstyleoption_cast(option); QRectF r1=subControlRect(control,option,QStyle::SC_SpinBoxUp,widget); QRectF r2=subControlRect(control,option,QStyle::SC_SpinBoxDown,widget); // QRect r3=subControlRect(control,option,QStyle::SC_SpinBoxEditField,widget); painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(QPen(option->palette.color(QPalette::Button),1)); painter->setBrush(option->palette.color(QPalette::Button)); if (widget->isEnabled()) { if(pb->state&QStyle::State_HasFocus){ painter->setPen(QPen(option->palette.color(QPalette::Highlight),1)); } if(pb->state&State_MouseOver){ painter->setPen(option->palette.color(QPalette::Highlight)); } } painter->drawRoundedRect(option->rect,4,4); painter->restore(); /* * There's no PE_IndicatorSpinUp and PE_IndicatorSpinDown here, and it's drawn directly. */ painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setBrush(Qt::NoBrush); if(option->state & State_Enabled){ painter->setPen(QPen(option->palette.foreground().color(), 1.1)); if (option->state & State_MouseOver) { painter->restore(); painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(option->palette.color(QPalette::Highlight), 1.1)); } } else { painter->setPen(QPen(option->palette.color(QPalette::Text), 1.1)); } painter->fillRect(int(r1.x())-2, int(r1.y()), int(r1.width()), int(r1.height()+r2.height()),Qt::NoBrush); int w = 8; int h = 4; QPolygon points(4); int x = int(r1.x())+2; int y = int(r1.y())+2; points[0] = QPoint(x, y + h); points[1] = QPoint(x + w / 2, y); points[2] = QPoint(x + w / 2, y); points[3] = QPoint(x + w, y + h); painter->drawLine(points[0], points[1] ); painter->drawLine(points[2], points[3] ); int x2 = int(r2.x())+2; int y2 = int(r2.y())+2; points[0] = QPoint(x2, y2); points[1] = QPoint(x2 + w / 2, y2 + h); points[2] = QPoint(x2 + w / 2, y2 + h); points[3] = QPoint(x2 + w, y2); painter->drawLine(points[0], points[1] ); painter->drawLine(points[2], points[3] ); painter->restore(); return ; } case CC_Slider : if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { //Size and location of each rectangle used QRectF rect = option->rect; QRectF rectHandle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); QRectF rectSliderTickmarks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); QRect rectGroove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); QPen pen; //Drawing chute (line) if (option->subControls & SC_SliderGroove) { pen.setStyle(Qt::CustomDashLine); QVector dashes; //qreal space = 1.3; qreal space = 0; dashes << 0.1 << space; // dashes << -0.1 << space; pen.setDashPattern(dashes); pen.setWidthF(3); pen.setColor(option->palette.highlight().color().lighter()); painter->setPen(pen); painter->setRenderHint(QPainter::Antialiasing); if (slider->orientation == Qt::Horizontal) { painter->drawLine(QPointF(rectGroove.left(), rectHandle.center().y()), QPointF(rectHandle.left(), rectHandle.center().y())); pen.setColor(option->palette.color(QPalette::Button)); painter->setPen(pen); painter->drawLine(QPointF(rectGroove.right(), rectHandle.center().y()), QPointF(rectHandle.right(), rectHandle.center().y())); } else { painter->drawLine(QPointF(rectGroove.center().x(), rectGroove.bottom()), QPointF(rectGroove.center().x(), rectHandle.bottom())); pen.setColor(option->palette.color(QPalette::Button)); painter->setPen(pen); painter->drawLine(QPointF(rectGroove.center().x(), rectGroove.top()), QPointF(rectGroove.center().x(), rectHandle.top())); } } //Painting slider if (option->subControls & SC_SliderHandle) { pen.setStyle(Qt::SolidLine); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Highlight)); painter->drawEllipse(rectHandle); } //Drawing scale if ((option->subControls & SC_SliderTickmarks) && slider->tickInterval) { painter->setPen(option->palette.foreground().color()); int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; //int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, w); //int ticks = slider->tickPosition; int v = slider->minimum; int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); while (v <= slider->maximum + 1) { const int v_ = qMin(v, slider->maximum); int pos = sliderPositionFromValue(slider->minimum, slider->maximum, v_, available) + len / 2; if (slider->orientation == Qt::Horizontal) { if (slider->tickPosition == QSlider::TicksBothSides) { painter->drawLine(pos, int(rect.top()), pos, int(rectHandle.top())); painter->drawLine(pos, int(rect.bottom()), pos, int(rectHandle.bottom())); } else { painter->drawLine(pos, int(rectSliderTickmarks.top()), pos, int(rectSliderTickmarks.bottom())); } } else { if (slider->tickPosition == QSlider::TicksBothSides) { painter->drawLine(int(rect.left()), pos, int(rectHandle.left()), pos); painter->drawLine(int(rect.right()), pos, int(rectHandle.right()), pos); } else { painter->drawLine(int(rectSliderTickmarks.left()), pos, int(rectSliderTickmarks.right()), pos); } } // in the case where maximum is max int int nextInterval = v + interval; if (nextInterval < v) break; v = nextInterval; } } return; } case CC_ToolButton: { if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast(option)) { QRect button, menuarea; button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget); menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); State bflags = toolbutton->state & ~State_Sunken; if (bflags & State_AutoRaise) { if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { bflags &= ~State_Raised; } } State mflags = bflags; if (toolbutton->state & State_Sunken) { if (toolbutton->activeSubControls & SC_ToolButton) bflags |= State_Sunken; mflags |= State_Sunken; } QStyleOption tool = *toolbutton; tool.state = bflags; if(mflags & (State_Sunken | State_MouseOver)) { tool.state = mflags; } tool.rect = button; if(toolbutton->subControls & SC_ToolButtonMenu) { tool.rect.adjust(0,0,menuarea.width(),0); } proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); if (toolbutton->state & State_HasFocus) { QStyleOptionFocusRect fr; fr.QStyleOption::operator=(*toolbutton); fr.rect.adjust(3, 3, -3, -3); if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, toolbutton, widget), 0); proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); } QStyleOptionToolButton label = *toolbutton; label.state = bflags; int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); label.rect = button.adjusted(fw, fw, -fw, -fw); proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); } /* ToolButton has Menu and popupmode is DelayedPopup. If you want to show the arrow, please remove the comment below */ // else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { // int mbi = qMin(button.width(),button.height())/5; // QRect ir = toolbutton->rect; // QStyleOptionToolButton newBtn = *toolbutton; // newBtn.rect = QRect(ir.right() - mbi -1, ir.y() + ir.height() - mbi -1, mbi, mbi); // newBtn.rect = visualRect(toolbutton->direction, button, newBtn.rect); // Qt5UKUIStyle::drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); // } } break; } case CC_GroupBox: //UKUI GroupBox style { painter->save(); if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { // Draw frame QRect textRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); //新加 QRect groupContents = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxContents, widget); if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { QStyleOptionFrame frame; frame.QStyleOption::operator=(*groupBox); frame.features = groupBox->features; frame.lineWidth = groupBox->lineWidth; frame.midLineWidth = groupBox->midLineWidth; frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); } // Draw title if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { // groupBox->textColor gets the incorrect palette here painter->setPen(QPen(option->palette.windowText(), 1)); int alignment = int(groupBox->textAlignment); if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) alignment |= Qt::TextHideMnemonic; proxy()->drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignLeft | alignment, groupBox->palette, groupBox->state & State_Enabled, groupBox->text, QPalette::NoRole); if (groupBox->state & State_HasFocus) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*groupBox); fropt.rect = textRect.adjusted(-2, -1, 2, 1); proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.color(QPalette::Base)); painter->drawRoundedRect(groupContents,4,4); painter->restore(); } // Draw checkbox if (groupBox->subControls & SC_GroupBoxCheckBox) { QStyleOptionButton box; box.QStyleOption::operator=(*groupBox); box.rect = checkBoxRect; proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); } } painter->restore(); return; break; } default: return QFusionStyle::drawComplexControl(control, option, painter, widget); } } void Qt5UKUIStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { switch (element) { case CE_ItemViewItem: { auto p = painter; auto opt = option; if (const QStyleOptionViewItem *vopt = qstyleoption_cast(opt)) { p->save(); p->setClipRect(opt->rect); QRect checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget); QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget); QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget); // draw the background proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p, widget); // draw the check mark if (vopt->features & QStyleOptionViewItem::HasCheckIndicator) { QStyleOptionViewItem option(*vopt); option.rect = checkRect; option.state = option.state & ~QStyle::State_HasFocus; switch (vopt->checkState) { case Qt::Unchecked: option.state |= QStyle::State_Off; break; case Qt::PartiallyChecked: option.state |= QStyle::State_NoChange; break; case Qt::Checked: option.state |= QStyle::State_On; break; } proxy()->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget); } // draw the icon QIcon::Mode mode = QIcon::Normal; if (!(vopt->state & QStyle::State_Enabled)) mode = QIcon::Disabled; else if (vopt->state & QStyle::State_Selected) mode = QIcon::Selected; QIcon::State state = vopt->state & QStyle::State_Open ? QIcon::On : QIcon::Off; //vopt->icon.paint(p, iconRect, vopt->decorationAlignment, mode, state); auto pixmap = vopt->icon.pixmap(vopt->decorationSize, mode, state); auto target = pixmap; if (widget) { if (widget->property("useIconHighlightEffect").isValid()) { bool needHandel = widget->property("useIconHighlightEffect").toBool(); if (needHandel) { HighLightEffect::EffectMode mode = HighLightEffect::HighlightOnly; if (widget->property("iconHighlightEffectMode").isValid()) { auto var = widget->property("iconHighlightEffectMode"); mode = qvariant_cast(var); target = HighLightEffect::generatePixmap(pixmap, vopt, widget, false, mode); } else { target = HighLightEffect::generatePixmap(pixmap, vopt, widget, false); } } } } QFusionStyle::drawItemPixmap(painter, iconRect, vopt->decorationAlignment, target); // draw the text if (!vopt->text.isEmpty()) { QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) cg = QPalette::Inactive; if (vopt->state & QStyle::State_Selected) { p->setPen(vopt->palette.color(cg, QPalette::HighlightedText)); } else { p->setPen(vopt->palette.color(cg, QPalette::Text)); } if (vopt->state & QStyle::State_Editing) { p->setPen(vopt->palette.color(cg, QPalette::Text)); p->drawRect(textRect.adjusted(0, 0, -1, -1)); } viewItemDrawText(p, vopt, textRect); } // draw the focus rect /* if (vopt->state & QStyle::State_HasFocus) { QStyleOptionFocusRect o; o.QStyleOption::operator=(*vopt); o.rect = proxy()->subElementRect(SE_ItemViewItemFocusRect, vopt, widget); o.state |= QStyle::State_KeyboardFocusChange; o.state |= QStyle::State_Item; QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled; o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected) ? QPalette::Highlight : QPalette::Window); proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, p, widget); } */ p->restore(); } break; } case CE_ProgressBarGroove:{ const QStyleOptionProgressBar *bar = qstyleoption_cast(option); if (!bar) return; painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->setPen(Qt::NoPen); painter->setBrush(option->palette.button()); int adjustMarignx2 = qMin(option->rect.width(), option->rect.height()) - 16; bool needAdjustBarWidth = adjustMarignx2 > 0; bool vertical = (bar->orientation == Qt::Vertical); auto progressBarGroveRect = option->rect; if (!vertical) { if (needAdjustBarWidth) { progressBarGroveRect.adjust(0, adjustMarignx2/2, 0, -adjustMarignx2/2); } } else { if (needAdjustBarWidth) { progressBarGroveRect.adjust(adjustMarignx2/2, 0, -adjustMarignx2/2, 0); } } painter->drawRoundedRect(progressBarGroveRect, 4, 4); painter->restore(); return; } case CE_ProgressBarContents:{ painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { //Judgment status painter->setPen(Qt::NoPen); bool vertical = false; bool inverted = false; bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); bool complete = bar->progress == bar->maximum; // Get extra style options if version 2 vertical = (bar->orientation == Qt::Vertical); inverted = bar->invertedAppearance; // If the orientation is vertical, we use a transform to rotate // the progress bar 90 degrees clockwise. This way we can use the // same rendering code for both orientations. int maxWidth = vertical? option->rect.height(): option->rect.width(); const auto progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); const auto progressSteps = qint64(progress) - bar->minimum; const auto progressBarWidth = progressSteps * maxWidth / totalSteps; int width = indeterminate ? maxWidth : progressBarWidth; QRect progressBar; painter->setPen(Qt::NoPen); int adjustMarignx2 = qMin(option->rect.width(), option->rect.height()) - 16; bool needAdjustBarWidth = adjustMarignx2 > 0; //Positioning progressBar = option->rect; if (!indeterminate) { if (!inverted) { if (!vertical) { //progressBar.setRect(option->rect.left()-1, option->rect.top(), width-3,option->rect.height()-7); progressBar.setRight(width); if (needAdjustBarWidth) { progressBar.adjust(0, adjustMarignx2/2, 0, -adjustMarignx2/2); } } else { progressBar.setTop(maxWidth - width); if (needAdjustBarWidth) { progressBar.adjust(adjustMarignx2/2, 0, -adjustMarignx2/2, 0); } } } else { if (!vertical) { progressBar = option->rect; progressBar.setLeft(maxWidth - width); if (needAdjustBarWidth) { progressBar.adjust(0, adjustMarignx2/2, 0, -adjustMarignx2/2); } } else { progressBar = option->rect; progressBar.setBottom(width); if (needAdjustBarWidth) { progressBar.adjust(adjustMarignx2/2, 0, -adjustMarignx2/2, 0); } } } } //Brush color if (!indeterminate && width > 0) { painter->save(); if (!vertical) { painter->setPen(Qt::NoPen); QColor startcolor = option->palette.highlight().color(); QColor endcolor = option->palette.highlight().color().darker(200); QLinearGradient linearGradient(QPoint(option->rect.bottomRight().x(), option->rect.bottomRight().y()), QPoint(option->rect.bottomLeft().x(), option->rect.bottomLeft().y())); linearGradient.setColorAt(1,startcolor); linearGradient.setColorAt(0,endcolor); painter->setBrush(QBrush(linearGradient)); // painter->setBrush(option->palette.highlight().color()); if (!complete && !indeterminate) painter->setClipRect(progressBar.adjusted(0, 0, 0, 0)); painter->drawRoundedRect(progressBar, 4, 4); } else { painter->setPen(Qt::NoPen); QColor startcolor = option->palette.highlight().color(); QColor endcolor = option->palette.highlight().color().darker(200); QLinearGradient linearGradient(QPoint(option->rect.topLeft()), QPoint(option->rect.bottomLeft())); linearGradient.setColorAt(0,startcolor); linearGradient.setColorAt(1,endcolor); painter->setBrush(QBrush(linearGradient)); if (!complete && !indeterminate) painter->setClipRect(progressBar.adjusted(0, 0, 0, 0)); painter->drawRoundedRect(progressBar, 4, 4); } painter->restore(); } else { //FIXME: implement waiting animation. //painter->fillRect(option->rect, Qt::red); } } painter->restore(); return; } case CE_ProgressBarLabel:{ return; } case CE_ScrollBarSlider: { //qDebug()<<"draw slider"; //auto animatorObj = widget->findChild("ukui_scrollbar_default_interaction_animator"); auto animator = m_scrollbar_animation_helper->animator(widget); if (!animator) { return QFusionStyle::drawControl(element, option, painter, widget); } bool enable = option->state.testFlag(QStyle::State_Enabled); bool mouse_over = option->state.testFlag(QStyle::State_MouseOver); bool is_horizontal = option->state.testFlag(QStyle::State_Horizontal); bool is_sunken = option->state.testFlag(QStyle::State_Sunken); //draw slider if (!enable) { painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::transparent); painter->setBrush(option->palette.windowText()); painter->setOpacity(0.2); auto sliderRect = option->rect; if (is_horizontal) { sliderRect.translate(0, sliderRect.height() - 3); sliderRect.setHeight(2); } else { sliderRect.translate(sliderRect.width() - 3, 0); sliderRect.setWidth(2); } painter->drawRoundedRect(sliderRect, 1, 1); painter->restore(); } else { auto sliderWidth = 0; if (is_horizontal) { sliderWidth = qMin(animator->value("groove_width").toInt() + 4, option->rect.height()); } else { sliderWidth = qMin(animator->value("groove_width").toInt() + 4, option->rect.width()); } animator->setAnimatorDirectionForward("slider_opacity", mouse_over); if (mouse_over) { if (!animator->isRunning("slider_opacity") && animator->currentAnimatorTime("slider_opacity") == 0) { animator->startAnimator("slider_opacity"); } } else { animator->setAnimatorDirectionForward("additional_opacity", false); // if (animator->currentAnimatorTime("slider_opacity") > 0) // animator->startAnimator("additional_opacity"); if (!animator->isRunning("slider_opacity") && animator->currentAnimatorTime("slider_opacity") > 0) { animator->startAnimator("slider_opacity"); } } //sunken additional opacity if (is_sunken) { if (animator->currentAnimatorTime("additional_opacity") == 0) { animator->setAnimatorDirectionForward("additional_opacity", is_sunken); animator->startAnimator("additional_opacity"); //qDebug()<<"start is_sunken"; } } else { if (animator->currentAnimatorTime("additional_opacity") > 0) { animator->setAnimatorDirectionForward("additional_opacity", is_sunken); animator->startAnimator("additional_opacity"); //qDebug()<<"start not_is_sunken"; } } if (animator->isRunning("additional_opacity") || animator->isRunning("slider_opacity")) { const_cast(widget)->update(); //qDebug()<<"sunken"<value("additional_opacity").toDouble(); } //draw slider painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::transparent); painter->setBrush(option->palette.windowText()); double slider_opacity = animator->value("slider_opacity").toDouble(); double additional_opacity = animator->value("additional_opacity").toDouble(); painter->setOpacity(slider_opacity + additional_opacity); auto sliderRect = option->rect; if (is_horizontal) { sliderRect.setY(sliderRect.height() - sliderWidth); } else { sliderRect.setX(sliderRect.width() - sliderWidth); } if (sliderWidth > 4) { if (is_horizontal) { sliderRect.adjust(0, 1, 0, -1); } else { sliderRect.adjust(1, 0, -1, 0); } } else { // if (is_horizontal) { // sliderRect.adjust(0, -1, 0, -1); // } else { // sliderRect.adjust(-1, 0, -1, 0); // } } int rectMin = qMin(sliderRect.width(), sliderRect.height()); painter->drawRoundedRect(sliderRect, rectMin/2, rectMin/2); painter->restore(); } return; } case CE_ScrollBarAddLine: { //auto animatorObj = widget->findChild("ukui_scrollbar_default_interaction_animator"); auto animator = m_scrollbar_animation_helper->animator(widget); if (!animator) { return QFusionStyle::drawControl(element, option, painter, widget); } painter->save(); auto percent = animator->value("groove_width").toInt()*1.0/12; painter->setOpacity(percent); //QFusionStyle::drawControl(element, option, painter, widget); QIcon icon; if (option->state.testFlag(State_Horizontal)) { icon = QIcon::fromTheme("pan-end-symbolic"); } else { icon = QIcon::fromTheme("pan-down-symbolic"); } icon.paint(painter, option->rect, Qt::AlignCenter); painter->restore(); return; } case CE_ScrollBarSubLine: { //auto animatorObj = widget->findChild("ukui_scrollbar_default_interaction_animator"); auto animator = m_scrollbar_animation_helper->animator(widget); if (!animator) { return QFusionStyle::drawControl(element, option, painter, widget); } painter->save(); auto percent = animator->value("groove_width").toInt()*1.0/12; painter->setOpacity(percent); //QFusionStyle::drawControl(element, option, painter, widget); QIcon icon; if (option->state.testFlag(State_Horizontal)) { icon = QIcon::fromTheme("pan-start-symbolic"); } else { icon = QIcon::fromTheme("pan-up-symbolic"); } icon.paint(painter, option->rect, Qt::AlignCenter); painter->restore(); return; } case CE_PushButtonLabel: { const QStyleOptionButton *button = qstyleoption_cast(option); QRect textRect = button->rect; //这是是否要绘制"&P" as P(带下划线) uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; if (!proxy()->styleHint(SH_UnderlineShortcut, button, widget)) tf |= Qt::TextHideMnemonic; if (!button->icon.isNull()) { //Center both icon and text QRect iconRect; QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && button->state & State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (button->state & State_On) state = QIcon::On; QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); int labelWidth = pixmap.width(); int labelHeight = pixmap.height(); int iconSpacing = 4;//4 is currently hardcoded in QPushButton::sizeHint() int textWidth =button->fontMetrics.boundingRect(option->rect, int(tf), button->text).width(); if (!button->text.isEmpty()) labelWidth += (textWidth + iconSpacing); iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, textRect.y() + (textRect.height() - labelHeight) / 2, pixmap.width(), pixmap.height()); iconRect = visualRect(button->direction, textRect, iconRect); tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead if (button->direction == Qt::RightToLeft) textRect.setRight(iconRect.left() - iconSpacing); else textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); if (button->state & (State_On | State_Sunken)) iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, option, widget), proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); } else { tf |= Qt::AlignHCenter; } if (button->state & (State_On | State_Sunken)) textRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, option, widget), proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); if (button->features & QStyleOptionButton::HasMenu) { int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget); if (button->direction == Qt::LeftToRight) textRect = textRect.adjusted(0, 0, -indicatorSize, 0); else textRect = textRect.adjusted(indicatorSize, 0, 0, 0); } //You can also write static colors directly //proxy()->drawItemText(painter, textRect, tf, button->palette, (button->state & State_Enabled),button->text, QPalette::HighlightedText); //The following are text dynamic colors painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); if(option->state & State_HasFocus){ painter->setPen(option->palette.color(QPalette::HighlightedText)); } else { painter->setPen(option->palette.color(QPalette::ButtonText)); } if (option->state & State_MouseOver) { if (option->state & State_Sunken) { painter->setPen(option->palette.color(QPalette::HighlightedText)); } else { painter->setPen(option->palette.color(QPalette::HighlightedText)); } } //painter->drawText(option->rect,pushbutton->text, QTextOption(Qt::AlignCenter)); proxy()->drawItemText(painter, textRect, int(tf), button->palette, (button->state & State_Enabled),button->text); painter->restore(); return; } case CE_ToolButtonLabel: { if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast(option)) { QRect rect = toolbutton->rect; int shiftX = 0; int shiftY = 0; if (toolbutton->state & (State_Sunken | State_On)) { shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); } // Arrow type always overrules and is always shown bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow; if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty()) || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) { int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; if (!proxy()->styleHint(SH_UnderlineShortcut, option, widget)) alignment |= Qt::TextHideMnemonic; rect.translate(shiftX, shiftY); painter->setFont(toolbutton->font); proxy()->drawItemText(painter, rect, alignment, toolbutton->palette, option->state & State_Enabled, toolbutton->text, QPalette::ButtonText); } else { QPixmap pm; QSize pmSize = toolbutton->iconSize; if (!toolbutton->icon.isNull()) { QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off; QIcon::Mode mode; if (!(toolbutton->state & State_Enabled)) mode = QIcon::Disabled; else if ((option->state & State_MouseOver) && (option->state & State_AutoRaise)) mode = QIcon::Active; else mode = QIcon::Normal; pm = toolbutton->icon.pixmap(qt_getWindow(widget), toolbutton->rect.size().boundedTo(toolbutton->iconSize), mode, state); pmSize = pm.size() / pm.devicePixelRatio(); } if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) { painter->setFont(toolbutton->font); QRect pr = rect, tr = rect; int alignment = Qt::TextShowMnemonic; if (!proxy()->styleHint(SH_UnderlineShortcut, option, widget)) alignment |= Qt::TextHideMnemonic; if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { pr.setHeight(pmSize.height() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint() tr.adjust(0, pr.height() - 1, 0, -1); pr.translate(shiftX, shiftY); if (!hasArrow) { proxy()->drawItemPixmap(painter, pr, Qt::AlignCenter, pm); } else { drawArrow(proxy(), toolbutton, pr, painter, widget); } alignment |= Qt::AlignCenter; } else { pr.setWidth(pmSize.width() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint() tr.adjust(pr.width(), 0, 0, 0); pr.translate(shiftX, shiftY); if (!hasArrow) { proxy()->drawItemPixmap(painter, QStyle::visualRect(option->direction, rect, pr), Qt::AlignCenter, pm); } else { drawArrow(proxy(), toolbutton, pr, painter, widget); } alignment |= Qt::AlignLeft | Qt::AlignVCenter; } tr.translate(shiftX, shiftY); const QString text = toolButtonElideText(toolbutton, tr, alignment); proxy()->drawItemText(painter, QStyle::visualRect(option->direction, rect, tr), alignment, toolbutton->palette, toolbutton->state & State_Enabled, text, QPalette::ButtonText); } else { rect.translate(shiftX, shiftY); if (hasArrow) { drawArrow(proxy(), toolbutton, rect, painter, widget); } else { proxy()->drawItemPixmap(painter, rect, Qt::AlignCenter, pm); } } } } return; } //Draw TabBar and every item style case CE_TabBarTab: if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { proxy()->drawControl(CE_TabBarTabShape, tab, painter, widget); proxy()->drawControl(CE_TabBarTabLabel, tab, painter, widget); return; } break; case CE_TabBarTabShape: { QRect rect = option->rect; int state = option->state; QColor outline =option->palette.window().color(); QColor highlightedOutline =option->palette.window().color(); QColor tabFrameColor =option->palette.window().color(); painter->save(); if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { bool rtlHorTabs = (tab->direction == Qt::RightToLeft && (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedSouth)); bool selected = tab->state & State_Selected; bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End) || (rtlHorTabs && tab->position == QStyleOptionTab::Beginning)); bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; int tabOverlap = pixelMetric(PM_TabBarTabOverlap, option, widget); rect = option->rect.adjusted(0, 0, (onlyOne || lastTab) ? 0 : tabOverlap, 0); QRect r2(rect); int x1 = r2.left(); int x2 = r2.right(); int y1 = r2.top(); int y2 = r2.bottom(); //painter->setPen(d->innerContrastLine()); painter->setPen( Qt::NoPen); QTransform rotMatrix; bool flip = false; //painter->setPen(shadow); painter->setPen( Qt::NoPen); switch (tab->shape) { case QTabBar::RoundedNorth: break; case QTabBar::RoundedSouth: rotMatrix.rotate(180); rotMatrix.translate(0, -rect.height() + 1); rotMatrix.scale(-1, 1); painter->setTransform(rotMatrix, true); break; case QTabBar::RoundedWest: rotMatrix.rotate(180 + 90); rotMatrix.scale(-1, 1); flip = true; painter->setTransform(rotMatrix, true); break; case QTabBar::RoundedEast: rotMatrix.rotate(90); rotMatrix.translate(0, - rect.width() + 1); flip = true; painter->setTransform(rotMatrix, true); break; default: painter->restore(); QCommonStyle::drawControl(element, tab, painter, widget); return; } if (flip) { QRect tmp = rect; rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width()); int temp = x1; x1 = y1; y1 = temp; temp = x2; x2 = y2; y2 = temp; } painter->setRenderHint(QPainter::Antialiasing, true); painter->translate(0.5, 0.5); /* * The following colors are the check box background * colors of the outer box tab or the small pop-up box tab */ QColor tabFrameColor = tab->features & QStyleOptionTab::HasFrame ? option->palette.base().color() : option->palette.base().color(); QLinearGradient fillGradient(rect.topLeft(), rect.bottomLeft()); QLinearGradient outlineGradient(rect.topLeft(), rect.bottomLeft()); QPen outlinePen = Qt::NoPen; if (selected) { fillGradient.setColorAt(0, tabFrameColor.lighter(104)); fillGradient.setColorAt(1, tabFrameColor); outlineGradient.setColorAt(1, outline); outlinePen = Qt::NoPen; } else { fillGradient.setColorAt(0, option->palette.window().color()); fillGradient.setColorAt(0.85,option->palette.window().color()); fillGradient.setColorAt(1, option->palette.window().color()); } //No special height handling when selected //QRect drawRect = rect.adjusted(0, selected ? 0 : 2, 0, 3); QRect drawRect = rect.adjusted(0, 0, 0, 3); painter->setPen( Qt::NoPen); painter->save(); painter->setClipRect(rect.adjusted(+1, -1, +0, selected ? -2 : -3)); painter->setBrush(fillGradient); painter->drawRoundedRect(drawRect.adjusted(+1, 0, +0, -1), 4.0, 4.0); painter->restore(); if (selected) { painter->save(); painter->setBrush(option->palette.window().color()); painter->drawRoundedRect(QRect(option->rect.right()-5,option->rect.y(),20,option->rect.height()-3),6,6); painter->drawRect(option->rect.right()-15,option->rect.y()-3,20,32); if(option->rect.left()-15>0){ painter->drawRoundedRect(QRect(option->rect.left()-13,option->rect.y(),20,option->rect.height()-3),6,6); painter->drawRect(option->rect.left()-10,option->rect.y()-1,25,10); } else{ painter->drawRect(option->rect.x()+2,option->rect.y()-3,20,32); painter->restore(); painter->save(); painter->setBrush(option->palette.base().color()); painter->drawRoundedRect(QRect(option->rect.x()+2,option->rect.y()-1,20,36),6,6); } painter->restore(); painter->save(); painter->setBrush(option->palette.base().color()); painter->drawRoundedRect(option->rect.adjusted(+7,-1,-6,-5),6,6); painter->restore(); } } painter->restore(); return; }break; case CE_ComboBoxLabel: { auto comboBoxOption = qstyleoption_cast(option); painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); painter->setPen(option->palette.color(QPalette::ButtonText)); if (option->state & State_Selected) { if (option->state & State_Sunken) { painter->setPen(option->palette.color(QPalette::ButtonText)); } else { painter->setPen(option->palette.color(QPalette::ButtonText)); } } painter->drawText(option->rect.adjusted(+4,+0,+0,+0), comboBoxOption->currentText, QTextOption(Qt::AlignVCenter)); painter->restore(); return; } case CE_RadioButtonLabel: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter); if (!proxy()->styleHint(SH_UnderlineShortcut, btn, widget)) alignment |= Qt::TextHideMnemonic; QPixmap pix; QRect textRect = btn->rect; if (!btn->icon.isNull()) { pix = btn->icon.pixmap(widget ? widget->window()->windowHandle() : 0, btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled); proxy()->drawItemPixmap(painter, btn->rect, alignment, pix); if (btn->direction == Qt::RightToLeft) textRect.setRight(textRect.right() - btn->iconSize.width() - 4); else textRect.setLeft(textRect.left() + btn->iconSize.width() + 4); } if (!btn->text.isEmpty()){ proxy()->drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic, btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText); } return; } break; case CE_RadioButton: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { bool isRadio = (element == CE_RadioButton); QStyleOptionButton subopt = *btn; subopt.rect = subElementRect( SE_RadioButtonIndicator, btn, widget); proxy()->drawPrimitive(PE_IndicatorRadioButton ,&subopt, painter, widget); subopt.rect = subElementRect( SE_RadioButtonContents, btn, widget); proxy()->drawControl( CE_RadioButtonLabel , &subopt, painter, widget); if (btn->state & State_HasFocus) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*btn); fropt.rect = subElementRect(SE_RadioButtonFocusRect, btn, widget); proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } return; } break; //Draw table header style case CE_HeaderSection: { painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->fillRect(option->rect, option->palette.alternateBase().color()); painter->restore(); return; }break; case CE_SizeGrip: { /* * Style is not required here, as required by design */ return; }break; //Drawing of single menu item of menu bar case CE_MenuBarItem: { painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(option)) { QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect.adjusted(0, 1, 0, -3); painter->fillRect(option->rect, option->palette.window()); uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip| Qt::TextSingleLine; if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); if (!pix.isNull()) proxy()->drawItemPixmap(painter,mbi->rect, alignment, pix); else proxy()->drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, QPalette::ButtonText); bool act = mbi->state & State_Selected && mbi->state & State_Sunken | mbi->state & State_HasFocus; bool dis = !(mbi->state & State_Enabled); QRect r = option->rect; //when hover、click and other state, begin to draw style if (act) { painter->setBrush(option->palette.highlight().color()); painter->setPen(Qt::NoPen); painter->drawRoundedRect(r.adjusted(0, 0, -1, -1),4,4); QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!QFusionStyle::styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole); } else { } } painter->restore(); return; break; } //Draw submenu style case CE_MenuItem: { painter->save(); painter->setRenderHint(QPainter::Antialiasing); // Draws one item in a popup menu. if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { // QColor highlightOutline = highlightedOutline; QColor highlightOutline = option->palette.highlight().color(); QColor highlight = option->palette.highlight().color(); if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { int w = 0; // const int margin = QStyleHelper::dpiScaled(5); const int margin =5; if (!menuItem->text.isEmpty()) { painter->setFont(menuItem->font); proxy()->drawItemText(painter, menuItem->rect.adjusted(margin, 0, -margin, 0), Qt::AlignLeft | Qt::AlignVCenter, menuItem->palette, menuItem->state & State_Enabled, menuItem->text, QPalette::Text); w = menuItem->fontMetrics.horizontalAdvance(menuItem->text) + margin; } // painter->setPen(shadow.lighter(106)); painter->setPen(option->palette.color(QPalette::Disabled,QPalette::WindowText)); painter->setOpacity(0.9); bool reverse = menuItem->direction == Qt::RightToLeft; painter->drawLine(menuItem->rect.left() + margin + (reverse ? 0 : w), menuItem->rect.center().y(), menuItem->rect.right() - margin - (reverse ? w : 0), menuItem->rect.center().y()); painter->restore(); break; } bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; if (selected) { QRect r = option->rect; painter->setBrush(highlightOutline); painter->setPen(Qt::NoPen); painter->drawRoundedRect(r.adjusted(2, 0.5, -2, -0.5),4,4); } bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; bool checked = menuItem->checked; bool sunken = menuItem->state & State_Sunken; bool enabled = menuItem->state & State_Enabled; bool ignoreCheckMark = false; // const int checkColHOffset = windowsItemHMargin + windowsItemFrame - 1; // int checkcol = qMax(menuItem->rect.height() * 0.79,qMax(menuItem->maxIconWidth, dpiScaled(21))); // icon checkbox's highlight column width const int checkColHOffset = 5; int checkcol = qMax(menuItem->rect.height() * 0.79,qMax(menuItem->maxIconWidth, 21)); if (qobject_cast(widget) ||(option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool())) ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate if (!ignoreCheckMark) { // Check, using qreal and QRectF to avoid error accumulation //const qreal boxMargin = dpiScaled(3.5); const qreal boxMargin = 3.5; const qreal boxWidth = checkcol - 2 * boxMargin; QRectF checkRectF(option->rect.left() + boxMargin + checkColHOffset, option->rect.center().y() - boxWidth/2 + 1, boxWidth, boxWidth); QRect checkRect = checkRectF.toRect(); checkRect.setWidth(checkRect.height()); // avoid .toRect() round error results in non-perfect square checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); if (checkable) { if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) { // Radio button if (checked || sunken) { painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); QPalette::ColorRole textRole = !enabled ? QPalette::Text: selected ? QPalette::HighlightedText : QPalette::ButtonText; painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole)); const int adjustment = checkRect.height() * 0.3; painter->drawEllipse(checkRect.adjusted(adjustment, adjustment, -adjustment, -adjustment)); } } else { // Check box if (menuItem->icon.isNull()) { QStyleOptionButton box; box.QStyleOption::operator=(*option); box.rect = checkRect; if (checked) box.state |= State_On; proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); } } } } else { //ignore checkmark if (menuItem->icon.isNull()) checkcol = 0; else checkcol = menuItem->maxIconWidth; } // Text and icon, ripped from windows style bool dis = !(menuItem->state & State_Enabled); bool act = menuItem->state & State_Selected; const QStyleOption *opt = option; const QStyleOptionMenuItem *menuitem = menuItem; QPainter *p = painter; QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + checkColHOffset, menuitem->rect.y(), checkcol, menuitem->rect.height())); if (!menuItem->icon.isNull()) { QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; if (act && !dis) mode = QIcon::Active; QPixmap pixmap; int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); QSize iconSize(smallIconSize, smallIconSize); if (const QComboBox *combo = qobject_cast(widget)) iconSize = combo->iconSize(); if (checked) pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); else pixmap = menuItem->icon.pixmap(iconSize, mode); const int pixw = pixmap.width() / pixmap.devicePixelRatio(); const int pixh = pixmap.height() / pixmap.devicePixelRatio(); QRect pmr(0, 0, pixw, pixh); pmr.moveCenter(vCheckRect.center()); painter->setPen(menuItem->palette.text().color()); if (!ignoreCheckMark && checkable && checked) { QStyleOption opt = *option; if (act) { // QColor activeColor = mergedColors(option->palette.background().color(), // option->palette.highlight().color()); QColor activeColor =option->palette.background().color(); opt.palette.setBrush(QPalette::Button, activeColor); } opt.state |= State_Sunken; opt.rect = vCheckRect; proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); } //FIXME: add highlight effect support. QPixmap target = HighLightEffect::generatePixmap(pixmap, menuItem, widget); painter->drawPixmap(pmr.topLeft(), target); } if (selected) { painter->setPen(menuItem->palette.highlightedText().color()); } else { painter->setPen(menuItem->palette.text().color()); } int x, y, w, h; menuitem->rect.getRect(&x, &y, &w, &h); int tab = menuitem->tabWidth; QColor discol; if (dis) { discol = menuitem->palette.text().color(); p->setPen(discol); } //int xm = checkColHOffset + checkcol + windowsItemHMargin; int xm = checkColHOffset + checkcol + 5; int xpos = menuitem->rect.x() + xm; // QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); QRect textRect(xpos, y + 5, w - xm - 5 - tab + 1, h - 2 * 5); QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); QStringRef s(&menuitem->text); if (!s.isEmpty()) { // draw text p->save(); int t = s.indexOf(QLatin1Char('\t')); int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!QFusionStyle::styleHint(SH_UnderlineShortcut, menuitem, widget)) text_flags |= Qt::TextHideMnemonic; text_flags |= Qt::AlignLeft; if (t >= 0) { QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); const QString textToDraw = s.mid(t + 1).toString(); if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw); p->setPen(discol); } p->drawText(vShortcutRect, text_flags, textToDraw); s = s.left(t); } QFont font = menuitem->font; // font may not have any "hard" flags set. We override // the point size so that when it is resolved against the device, this font will win. // This is mainly to handle cases where someone sets the font on the window // and then the combo inherits it and passes it onward. At that point the resolve mask // is very, very weak. This makes it stonger. font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF()); if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); p->setFont(font); const QString textToDraw = s.left(t).toString(); if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw); p->setPen(discol); } p->drawText(vTextRect, text_flags, textToDraw); p->restore(); } // Arrow if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow int dim = (menuItem->rect.height() - 4) / 2; PrimitiveElement arrow; arrow = option->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim; QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim)); QStyleOptionMenuItem newMI = *menuItem; newMI.rect = vSubMenuRect; newMI.state = !enabled ? State_None : State_Enabled; if (selected) newMI.palette.setColor(QPalette::Foreground, newMI.palette.highlightedText().color()); proxy()->drawPrimitive(arrow, &newMI, painter, widget); } } painter->restore(); return; } // Draw UKUI ToolBoxTab Style case CE_ToolBoxTab: if (const QStyleOptionToolBox *tb = qstyleoption_cast(option)) { proxy()->drawControl(CE_ToolBoxTabShape, tb, painter, widget); proxy()->drawControl(CE_ToolBoxTabLabel, tb, painter, widget); return; } break; case CE_ToolBoxTabShape: if (const QStyleOptionToolBox *tb = qstyleoption_cast(option)) { painter->save(); painter->setPen(Qt::NoPen); if(widget->isEnabled()){ painter->setBrush(tb->palette.button().color()); if(option->state & State_MouseOver) { painter->setBrush(tb->palette.button().color().darker(110)); if(option->state & State_Sunken) painter->setBrush(tb->palette.button().color().darker(110)); } } else { painter->setBrush(tb->palette.color(QPalette::Disabled,QPalette::Button)); } if (tb->direction != Qt::RightToLeft|tb->direction != Qt::RightToLeft) { painter->drawRoundedRect(option->rect,4,4); } painter->restore(); return; } break; case CE_ToolBoxTabLabel: if (const QStyleOptionToolBox *tb = qstyleoption_cast(option)) { bool enabled = tb->state & State_Enabled; bool selected = tb->state & State_Selected; int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget); QPixmap pm = tb->icon.pixmap(widget ? widget->window()->windowHandle() : 0, QSize(iconExtent, iconExtent),enabled ? QIcon::Normal : QIcon::Disabled); QRect cr = subElementRect(QStyle::SE_ToolBoxTabContents, tb, widget); QRect tr, ir; int ih = 0; if (pm.isNull()) { tr = cr; tr.adjust(4, 0, -8, 0); } else { int iw = pm.width() / pm.devicePixelRatio() + 4; ih = pm.height()/ pm.devicePixelRatio(); ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih); tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height()); } if (selected && proxy()->styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb, widget)) { QFont f(painter->font()); f.setBold(true); painter->setFont(f); } QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width()); if (ih) painter->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm); int alignment = Qt::AlignCenter | Qt::AlignVCenter | Qt::TextShowMnemonic; if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, tb, widget)) alignment |= Qt::TextHideMnemonic; // painter->drawText(option->rect,tb->text, QTextOption(Qt::AlignCenter)); proxy()->drawItemText(painter, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText); if (!txt.isEmpty() && option->state & State_HasFocus) { QStyleOptionFocusRect opt; opt.rect = tr; opt.palette = tb->palette; opt.state = QStyle::State_None; proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, painter, widget); } return; } break; default: return QFusionStyle::drawControl(element, option, painter, widget); } } int Qt5UKUIStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { switch (metric) { case PM_ScrollBarExtent: { return 10; } case PM_ScrollView_ScrollBarOverlap: { return -10; } case PM_SliderThickness:{ return 40; } case PM_SliderLength:{ return 20; } case PM_MenuHMargin:{ return 5; } case PM_MenuVMargin:{ return 10; } case PM_IndicatorWidth:{ return 16; } case PM_IndicatorHeight:{ return 16; } case PM_SubMenuOverlap:return -2; case PM_ButtonMargin:return 9; case PM_DefaultFrameWidth:return 2; case PM_TabBarTabVSpace:return 20; case PM_TabBarTabHSpace:return 40; case PM_HeaderMargin:return 9; case PM_MenuBarItemSpacing:return 16; case PM_MenuBarVMargin:return 4; case PM_ProgressBarChunkWidth: return 0; case PM_ToolBarItemSpacing:return 4; case PM_MenuButtonIndicator: if (const QStyleOptionToolButton *tb = qstyleoption_cast(option)) { if(tb->subControls & SC_ToolButtonMenu) return 16; } return 12; default: break; } return QFusionStyle::pixelMetric(metric, option, widget); } QRect Qt5UKUIStyle::subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget) const { switch (control) { case CC_ScrollBar: { auto rect = QFusionStyle::subControlRect(control, option, subControl, widget); if (subControl == SC_ScrollBarSlider) { rect.adjust(1, 1, -1, -1); if (option->state.testFlag(QStyle::State_Horizontal)) { rect.adjust(1, 0, -1, 0); } else { rect.adjust(0, 1, 0, -1); } return rect; } return rect; return scrollBarSubControlRect(control, option, subControl, widget); } case CC_Slider: switch( subControl ) { case SC_SliderHandle: { QRect handleRect( QFusionStyle::subControlRect( CC_Slider, option, subControl, widget ) ); handleRect = centerRect( handleRect, PM_SliderThickness+9, PM_SliderControlThickness+8); return handleRect; } default:return QFusionStyle::subControlRect(control, option, subControl, widget); } case QStyle::CC_ToolButton: if (const QStyleOptionToolButton *tb = qstyleoption_cast(option)) { QRect rect = tb->rect; qreal width=rect.width(); qreal mbi = pixelMetric(PM_MenuButtonIndicator, tb, widget); qreal js = width - mbi - tb->iconSize.width(); if(js > 1) { mbi = qRound(js/2 + mbi); } if(width < 40) { mbi = 10; } else if(width < 30) { mbi = 8; } if(mbi > 24) mbi = 24; switch (subControl) { case SC_ToolButton: if ((tb->features & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) == QStyleOptionToolButton::MenuButtonPopup) { rect.adjust(0, 0, -mbi, 0); } return rect; case SC_ToolButtonMenu: if ((tb->features & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) == QStyleOptionToolButton::MenuButtonPopup) { rect.adjust(rect.width() -mbi, 0, 0, 0); } return rect; default: break; } } default: break; } return QFusionStyle::subControlRect(control, option, subControl, widget); } void Qt5UKUIStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const { qreal scale = pixmap.devicePixelRatio(); QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect); QRect inter = aligned.intersected(rect); QPixmap target = pixmap; auto device = painter->device(); auto widget = dynamic_cast(device); if (widget) { if (HighLightEffect::isWidgetIconUseHighlightEffect(widget)) { QStyleOption opt; opt.initFrom(widget); if (auto button = qobject_cast(widget)) { opt.state.setFlag(QStyle::State_Sunken, button->isDown()); } target = HighLightEffect::generatePixmap(pixmap, &opt, widget); } } painter->drawPixmap(inter.x(), inter.y(), target, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width() * scale, inter.height() *scale); } // This fuction is copied from fusion style. // The only different is it not hide add/sub line rect // when style hint SH_ScrollBar_Transient is true. QRect Qt5UKUIStyle::scrollBarSubControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget) const { QRect ret; if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(option)) { const QRect scrollBarRect = scrollbar->rect; int sbextent = 0; sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget); int maxlen = ((scrollbar->orientation == Qt::Horizontal) ? scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2); int sliderlen; // calculate slider length if (scrollbar->maximum != scrollbar->minimum) { uint range = scrollbar->maximum - scrollbar->minimum; sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep); int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget); if (sliderlen < slidermin || range > INT_MAX / 2) sliderlen = slidermin; if (sliderlen > maxlen) sliderlen = maxlen; } else { sliderlen = maxlen; } int sliderstart = sbextent + sliderPositionFromValue(scrollbar->minimum, scrollbar->maximum, scrollbar->sliderPosition, maxlen - sliderlen, scrollbar->upsideDown); switch (subControl) { case SC_ScrollBarSubLine: // top/left button if (scrollbar->orientation == Qt::Horizontal) { int buttonWidth = qMin(scrollBarRect.width() / 2, sbextent); ret.setRect(0, 0, buttonWidth, scrollBarRect.height()); } else { int buttonHeight = qMin(scrollBarRect.height() / 2, sbextent); ret.setRect(0, 0, scrollBarRect.width(), buttonHeight); } break; case SC_ScrollBarAddLine: // bottom/right button if (scrollbar->orientation == Qt::Horizontal) { int buttonWidth = qMin(scrollBarRect.width()/2, sbextent); ret.setRect(scrollBarRect.width() - buttonWidth, 0, buttonWidth, scrollBarRect.height()); } else { int buttonHeight = qMin(scrollBarRect.height()/2, sbextent); ret.setRect(0, scrollBarRect.height() - buttonHeight, scrollBarRect.width(), buttonHeight); } break; case SC_ScrollBarSubPage: // between top/left button and slider if (scrollbar->orientation == Qt::Horizontal) ret.setRect(sbextent, 0, sliderstart - sbextent, scrollBarRect.height()); else ret.setRect(0, sbextent, scrollBarRect.width(), sliderstart - sbextent); break; case SC_ScrollBarAddPage: // between bottom/right button and slider if (scrollbar->orientation == Qt::Horizontal) ret.setRect(sliderstart + sliderlen, 0, maxlen - sliderstart - sliderlen + sbextent, scrollBarRect.height()); else ret.setRect(0, sliderstart + sliderlen, scrollBarRect.width(), maxlen - sliderstart - sliderlen + sbextent); break; case SC_ScrollBarGroove: if (scrollbar->orientation == Qt::Horizontal) ret.setRect(sbextent, 0, scrollBarRect.width() - sbextent * 2, scrollBarRect.height()); else ret.setRect(0, sbextent, scrollBarRect.width(), scrollBarRect.height() - sbextent * 2); break; case SC_ScrollBarSlider: if (scrollbar->orientation == Qt::Horizontal) ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); else ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); break; default: break; } ret = visualRect(scrollbar->direction, scrollBarRect, ret); } return ret; } void Qt5UKUIStyle::realSetWindowSurfaceFormatAlpha(const QWidget *widget) const { if (!widget) return; if (widget->testAttribute(Qt::WA_WState_Created)) return; if (auto menu = qobject_cast(widget)) { const_cast(widget)->setAttribute(Qt::WA_TranslucentBackground); } if (shouldBeTransparent(widget)) const_cast(widget)->setAttribute(Qt::WA_TranslucentBackground); } void Qt5UKUIStyle::realSetMenuTypeToMenu(const QWidget *widget) const { if (auto menu = qobject_cast(widget)) { if (!qobject_cast(widget) || widget->testAttribute(Qt::WA_X11NetWmWindowTypeMenu) || !widget->windowHandle()) return; int wmWindowType = 0; if (widget->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu)) wmWindowType |= QXcbWindowFunctions::DropDownMenu; if (widget->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu)) wmWindowType |= QXcbWindowFunctions::PopupMenu; if (wmWindowType == 0) return; QXcbWindowFunctions::setWmWindowType(widget->windowHandle(), static_cast(wmWindowType)); } } void Qt5UKUIStyle::drawComBoxIndicator(SubControl which, const QStyleOptionComplex *option, QPainter *painter) const { PrimitiveElement arrow=PE_IndicatorArrowDown; QRect buttonRect=option->rect.adjusted(+0,+0,-1,-1); buttonRect.translate(buttonRect.width()/2,0); buttonRect.setWidth((buttonRect.width()+1)/2); QStyleOption buttonOpt(*option); painter->save(); painter->setClipRect(buttonRect,Qt::IntersectClip); if(!(option->activeSubControls&which)) buttonOpt.state&=~(State_MouseOver|State_On|State_Sunken); QStyleOption arrowOpt(buttonOpt); arrowOpt.rect=subControlRect(CC_ComboBox,option,which).adjusted(+0,+0,-0,+0); if(arrowOpt.rect.isValid()) proxy()->drawPrimitive(arrow,&arrowOpt,painter); painter->restore(); } QRect Qt5UKUIStyle::centerRect(const QRect &rect, int width, int height) const { return QRect(rect.left() + (rect.width() - width)/2, rect.top() + (rect.height() - height)/2, width, height); } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/qt5-style-ukui.json0000664000175000017500000000007713641116416024675 0ustar fengfeng{ "Keys" : [ "ukui-default", "ukui-light", "ukui-dark" ] } qt5-ukui-platformtheme/ukui-styles/qt5-style-ukui/scrollbar-animation-helper.cpp0000664000175000017500000000352113641116416027076 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "scrollbar-animation-helper.h" #include "animations/scrollbar/ukui-scrollbar-default-interaction-animator.h" #include ScrollBarAnimationHelper::ScrollBarAnimationHelper(QObject *parent) : AnimationHelper(parent) { } bool ScrollBarAnimationHelper::registerWidget(QWidget *w) { auto animator = new UKUI::ScrollBar::DefaultInteractionAnimator; bool result = animator->bindWidget(w); if (!result) { animator->deleteLater(); } else { m_animators->insert(w, animator); } return result; } bool ScrollBarAnimationHelper::unregisterWidget(QWidget *w) { auto animator = w->findChild("ukui_scrollbar_default_interaction_animator", Qt::FindDirectChildrenOnly); bool result = false; if (animator) { result = animator->unboundWidget(); animator->deleteLater(); } m_animators->remove(w); return result; } AnimatorIface *ScrollBarAnimationHelper::animator(const QWidget *w) { return m_animators->value(w); } qt5-ukui-platformtheme/ukui-styles/proxy-style/0000775000175000017500000000000013643027460020653 5ustar fengfengqt5-ukui-platformtheme/ukui-styles/proxy-style/proxy-style.pro0000664000175000017500000000262213641116416023714 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-01-02T08:39:47 # #------------------------------------------------- QT += widgets KWindowSystem x11extras TARGET = ukui-proxy-style TEMPLATE = lib CONFIG += plugin c++11 link_pkgconfig PKGCONFIG += gsettings-qt include(../../libqt5-ukui-style/settings/settings.pri) DEFINES += PROXYSTYLE_LIBRARY # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_NO_DEBUG_OUTPUT # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ proxy-style.cpp \ proxy-style-plugin.cpp \ blur-helper.cpp \ window-manager.cpp HEADERS += \ proxy-style.h \ proxy-style_global.h \ proxy-style-plugin.h \ blur-helper.h \ window-manager.h unix { target.path = $$[QT_INSTALL_PLUGINS]/styles INSTALLS += target } DISTFILES += \ ukui-style.json qt5-ukui-platformtheme/ukui-styles/proxy-style/window-manager.cpp0000664000175000017500000001215113641116416024274 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "window-manager.h" #include #include #include #include #include #include #include WindowManager::WindowManager(QObject *parent) : QObject(parent) { m_timer.setTimerType(Qt::PreciseTimer); m_timer.setInterval(100); m_timer.setSingleShot(true); m_start_point = QPoint(0, 0); qApp->installEventFilter(new AppEventFilter(this)); } void WindowManager::registerWidget(QWidget *w) { w->removeEventFilter(this); w->installEventFilter(this); } void WindowManager::unregisterWidget(QWidget *w) { w->removeEventFilter(this); } bool WindowManager::eventFilter(QObject *obj, QEvent *e) { //qDebug()<type(); switch (e->type()) { case QEvent::MouseButtonPress: { QMouseEvent *event = static_cast(e); if (event->button() == Qt::LeftButton) { // If the cursor is not normal arrow cursor, // we should consider there is another excepted operation // which current widget hope do. So we won't trigger // the window move event. QWidget *w = qobject_cast(obj); if (w->cursor().shape() != Qt::CursorShape::ArrowCursor) return false; buttonPresseEvent(obj, event); return false; } return false; } case QEvent::MouseMove: { if (m_is_dragging) { if (m_current_obj != obj) return false; if (m_timer.isActive()) { return false; } else { if (QWidget::mouseGrabber()) return false; QMouseEvent *event = static_cast(e); //move request mouseMoveEvent(obj, event); return true; } } return false; } case QEvent::MouseButtonRelease: { QMouseEvent *event = static_cast(e); mouseReleaseEvent(obj, event); return false; } case QEvent::Move: { if (m_current_obj && m_is_dragging) { //qDebug()<<"drag end"; endDrag(); } else { //qDebug()<<"move"; } return false; } default: return false; } } void WindowManager::buttonPresseEvent(QObject *obj, QMouseEvent *e) { //qDebug()<<"mouse press event"; endDrag(); QWidget *w = qobject_cast(obj); //NOTE: We have to skip the border for resize event. auto pos = w->mapFromGlobal(e->globalPos()); if (!w->rect().adjusted(10, 10, -10, -10).contains(pos)) { //qDebug()<<"skip move event"; return; } m_is_dragging = true; m_current_obj = obj; m_start_point = e->pos(); m_timer.start(); } void WindowManager::mouseMoveEvent(QObject *obj, QMouseEvent *e) { if (!m_is_dragging) return; //qDebug()<<"move"; QWidget *w = qobject_cast(obj); const QPoint native = e->globalPos(); auto connection = QX11Info::connection(); xcb_ungrab_pointer(connection, XCB_TIME_CURRENT_TIME); NETRootInfo(connection, NET::WMMoveResize).moveResizeRequest(w->winId(), native.x(), native.y(), NET::Move); m_start_point = e->pos(); m_timer.start(); } void WindowManager::mouseReleaseEvent(QObject *obj, QMouseEvent *e) { endDrag(); } void WindowManager::endDrag() { m_is_dragging = false; m_current_obj = nullptr; m_start_point = QPoint(0, 0); m_timer.stop(); } // AppEventFilter AppEventFilter::AppEventFilter(WindowManager *parent) : QObject(parent) { m_wm = parent; } bool AppEventFilter::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::MouseButtonRelease) { m_wm->m_is_dragging = false; m_wm->m_current_obj = nullptr; m_wm->m_timer.stop(); m_wm->m_start_point = QPoint(); } // if (m_wm->m_is_dragging && m_wm->m_current_obj && (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseMove)) { // QMouseEvent mouseEvent(QEvent::MouseButtonRelease, // m_wm->m_start_point, // Qt::LeftButton, // Qt::LeftButton, // Qt::NoModifier); // qApp->sendEvent(m_wm->m_current_obj, &mouseEvent); // } return false; } qt5-ukui-platformtheme/ukui-styles/proxy-style/proxy-style.h0000664000175000017500000000506713641116416023351 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef PROXYSTYLE_H #define PROXYSTYLE_H #include "proxy-style_global.h" #include class BlurHelper; class WindowManager; class ApplicationStyleSettings; namespace UKUI { /*! * \brief The ProxyStyle class * \details * ProxyStyle is direct UKUI platform theme style for provide style-management * in ukui platform. * * ProxyStyle is not a completed style, and it must be created completedly form another * QStyle (exclude itself), such as fusion, oxygen, etc. * * UKUI style provide a global blur effect for qt windows, but it does not mean all window * will be blurred. In fact, you should make your application window be transparent first. * If you do not want your transparent window be blurred, you should add your class to exception, * which cached in gsettings org.ukui.style blur-exception-classes. */ class PROXYSTYLESHARED_EXPORT ProxyStyle : public QProxyStyle { Q_OBJECT public: explicit ProxyStyle(const QString &key); virtual ~ProxyStyle() {} //debuger bool eventFilter(QObject *obj, QEvent *e); int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const; void polish(QWidget *widget); void unpolish(QWidget *widget); void polish(QPalette &pal); void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; private: BlurHelper *m_blur_helper; WindowManager *m_window_manager; ApplicationStyleSettings *m_app_style_settings; bool m_use_custom_highlight_color = false; QColor m_custom_highlight_color; }; } #endif // PROXYSTYLE_H qt5-ukui-platformtheme/ukui-styles/proxy-style/blur-helper.h0000664000175000017500000000302513643027460023245 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef BLURHELPER_H #define BLURHELPER_H #include #include class BlurHelper : public QObject { Q_OBJECT public: explicit BlurHelper(QObject *parent = nullptr); bool eventFilter(QObject *obj, QEvent *e); void registerWidget(QWidget *widget); void unregisterWidget(QWidget *widget); bool isApplicationInBlackList(); const QStringList blackList(); bool shouldSkip(QWidget *w); signals: public slots: void onBlurEnableChanged(bool enable); void onWidgetDestroyed(QWidget *widget); void delayUpdate(QWidget *w, bool updateBlurRegionOnly = false); private: QList m_blur_widgets; QList m_update_list; QTimer m_timer; }; #endif // BLURHELPER_H qt5-ukui-platformtheme/ukui-styles/proxy-style/proxy-style-plugin.cpp0000664000175000017500000001217013641116416025171 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "proxy-style-plugin.h" #include "proxy-style.h" #include "ukui-style-settings.h" #include "application-style-settings.h" #include "black-list.h" #include #include #include using namespace UKUI; ProxyStylePlugin::ProxyStylePlugin() { if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { auto settings = UKUIStyleSettings::globalInstance(); connect(settings, &UKUIStyleSettings::changed, this, [=](const QString &key){ auto appStyleSettings = ApplicationStyleSettings::getInstance(); if (appStyleSettings->currentStyleStretagy() != ApplicationStyleSettings::Default) return; if (key == "styleName") { qDebug()<<"style name changed"; //We should not swich a application theme which use internal style. if (QApplication::style()->inherits("InternalStyle")) return; auto styleName = settings->get("styleName").toString(); if (styleName == "ukui") { styleName = "ukui-default"; } if (styleName == "ukui-white") { styleName = "ukui-default"; } if (styleName == "ukui-black") { styleName = "ukui-dark"; } bool isStyleValid = false; for (auto key : QStyleFactory::keys()) { if (key.toLower() == styleName.toLower()) { isStyleValid = true; } } if (!isStyleValid) { styleName = "fusion"; } if (!blackList().contains(qAppName())) QApplication::setStyle(new ProxyStyle(styleName)); QPalette palette = QApplication::palette(); /*! \todo implemet palette switch. */ switch (appStyleSettings->currentColorStretagy()) { case ApplicationStyleSettings::System: { break; } case ApplicationStyleSettings::Bright: { break; } case ApplicationStyleSettings::Dark: { break; } default: break; } QApplication::setPalette(palette); } if (key == "systemPalette") { onSystemPaletteChanged(); } if (key == "useSystemPalette") { onSystemPaletteChanged(); } }); } } QStyle *ProxyStylePlugin::create(const QString &key) { if (blackList().contains(qAppName())) return new QProxyStyle("fusion"); qDebug()<<"create"<get("styleName").toString(); if (m_current_style_name == "ukui-white") { m_current_style_name = "ukui-default"; } if (m_current_style_name == "ukui-black") { m_current_style_name = "ukui-dark"; } for (auto styleName : QStyleFactory::keys()) { if (styleName.toLower() == m_current_style_name.toLower()) { return new ProxyStyle(styleName); } } } qDebug()<<"ukui create proxy style"; return new ProxyStyle(nullptr); } qDebug()<<"ukui create proxy style: null"; return new ProxyStyle(nullptr); } const QStringList ProxyStylePlugin::blackList() { return blackAppList(); } void ProxyStylePlugin::onSystemPaletteChanged() { bool useSystemPalette = UKUIStyleSettings::globalInstance()->get("useSystemPalette").toBool(); if (useSystemPalette) { auto data = UKUIStyleSettings::globalInstance()->get("systemPalette"); if (data.isNull()) return; auto palette = qvariant_cast(data); QApplication::setPalette(palette); } else { auto palette = QApplication::style()->standardPalette(); QApplication::setPalette(palette); } } qt5-ukui-platformtheme/ukui-styles/proxy-style/proxy-style-plugin.h0000664000175000017500000000244613641116416024643 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef PROXYSTYLEPLUGIN_H #define PROXYSTYLEPLUGIN_H #include namespace UKUI { class ProxyStylePlugin : public QStylePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QStyleFactoryInterface_iid FILE "ukui-style.json") public: ProxyStylePlugin(); QStyle *create(const QString &key) override; const QStringList blackList(); protected: void onSystemPaletteChanged(); signals: public slots: private: QString m_current_style_name; }; } #endif // PROXYSTYLEPLUGIN_H qt5-ukui-platformtheme/ukui-styles/proxy-style/proxy-style.cpp0000664000175000017500000001517513643027460023707 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "proxy-style.h" #include #include "blur-helper.h" #include "window-manager.h" #include "application-style-settings.h" #include "ukui-style-settings.h" #include #include #include #include #include #include using namespace UKUI; ProxyStyle::ProxyStyle(const QString &key) : QProxyStyle (key == nullptr? "fusion": key) { auto settings = UKUIStyleSettings::globalInstance(); m_use_custom_highlight_color = settings->get("useCustomHighlightColor").toBool(); m_custom_highlight_color = QColor(settings->get("customHighlightColor").toString()); connect(settings, &QGSettings::changed, this, [=](const QString &key){ if (key == "useCustomHighlightColor") { m_use_custom_highlight_color = settings->get("useCustomHighlightColor").toBool(); } if (key == "customHighlightColor") { m_custom_highlight_color = QColor(settings->get("customHighlightColor").toString()); } if (m_use_custom_highlight_color) { //qApp->setStyle(new ProxyStyle(key)); auto pal = QApplication::palette(); pal.setColor(QPalette::Active, QPalette::Highlight, m_custom_highlight_color); pal.setColor(QPalette::Inactive, QPalette::Highlight, m_custom_highlight_color); pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::transparent); qApp->setPalette(pal); qApp->paletteChanged(pal); } else { auto pal = qApp->style()->standardPalette(); qApp->setPalette(pal); qApp->paletteChanged(pal); } }); m_blur_helper = new BlurHelper(this); m_window_manager = new WindowManager(this); m_app_style_settings = ApplicationStyleSettings::getInstance(); connect(m_app_style_settings, &ApplicationStyleSettings::colorStretageChanged, [=](const ApplicationStyleSettings::ColorStretagy &stretagy){ /*! \todo implemet palette switch. */ switch (stretagy) { case ApplicationStyleSettings::System: { break; } case ApplicationStyleSettings::Bright: { break; } case ApplicationStyleSettings::Dark: { break; } default: break; } }); } bool ProxyStyle::eventFilter(QObject *obj, QEvent *e) { // if (e->type() == QEvent::Hide) { // qDebug()<metaObject()->className()<type()<<"=========\n\n\n"; // } else { // qDebug()<metaObject()->className()<type(); // } return false; } int ProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { //FIXME: switch (hint) { case QStyle::SH_Menu_Scrollable: { return 1; } default: return QProxyStyle::styleHint(hint, option, widget, returnData); } } void ProxyStyle::polish(QWidget *widget) { //return QProxyStyle::polish(widget); QProxyStyle::polish(widget); //FIXME: if(!widget) return; if (auto label = qobject_cast(widget)) { if (auto p = label->parent()) { //trying fix QWizardPage's title problems if (QString(p->metaObject()->className()) == "QWidget") { auto font = QApplication::font(); font.setPixelSize(font.pixelSize()); label->setFont(font); } } } //qDebug()<<"\n\n\n============widget mask"<metaObject()->className()<mask(); /*! \todo register transparent widget to blurhelper with better way. for now it will let some transparent widget show in error. i have to avoid them by limitting widget's class name, but that is no my expected. */ if (widget->testAttribute(Qt::WA_TranslucentBackground) && widget->isTopLevel()) { //FIXME: m_blur_helper->registerWidget(widget); /* if (QString(widget->metaObject()->className())=="QMenu" || widget->inherits("Peony::DirectoryViewMenu") || widget->inherits("Peony::DesktopMenu")) { m_blur_helper->registerWidget(widget); } */ } //qDebug()<metaObject()->className(); //add exception. if (widget->isWindow()) { auto var = widget->property("useStyleWindowManager"); if (var.isNull()) { m_window_manager->registerWidget(widget); } else { if (var.toBool()) { m_window_manager->registerWidget(widget); } } } widget->installEventFilter(this); } void ProxyStyle::unpolish(QWidget *widget) { //return QProxyStyle::unpolish(widget); widget->removeEventFilter(this); //FIXME: if (widget->testAttribute(Qt::WA_TranslucentBackground) && widget->isTopLevel()) { m_blur_helper->unregisterWidget(widget); } if (widget->isWindow()) { auto var = widget->property("useStyleWindowManager"); if (var.isNull()) { m_window_manager->unregisterWidget(widget); } else { if (var.toBool()) { m_window_manager->unregisterWidget(widget); } } } QProxyStyle::unpolish(widget); } void ProxyStyle::polish(QPalette &pal) { QProxyStyle::polish(pal); if (m_use_custom_highlight_color) { pal.setColor(QPalette::Active, QPalette::Highlight, m_custom_highlight_color); pal.setColor(QPalette::Inactive, QPalette::Highlight, m_custom_highlight_color); pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::transparent); } } void ProxyStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { return QProxyStyle::drawPrimitive(element, option, painter, widget); } qt5-ukui-platformtheme/ukui-styles/proxy-style/window-manager.h0000664000175000017500000000422013641116416023737 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef WINDOWMANAGER_H #define WINDOWMANAGER_H #include #include #include class QMouseEvent; class AppEventFilter; /*! * \brief The WindowManager class * \details * This class is use to help window management. * There are some qt's windows, such as frameless window, could not * move and move resize by it self. Through registering widget to window * manager, we can let them movable and can be maximum/half-maximum like * other normal window. */ class WindowManager : public QObject { friend class AppEventFilter; Q_OBJECT public: explicit WindowManager(QObject *parent = nullptr); void registerWidget(QWidget *w); void unregisterWidget(QWidget *w); bool eventFilter(QObject *obj, QEvent *e); void buttonPresseEvent(QObject *obj, QMouseEvent *e); void mouseMoveEvent(QObject *obj, QMouseEvent *e); void mouseReleaseEvent(QObject *obj, QMouseEvent *e); protected: void endDrag(); private: QObject *m_current_obj = nullptr; bool m_is_dragging = false; QTimer m_timer; QPoint m_start_point; }; class AppEventFilter : public QObject { friend class WindowManager; Q_OBJECT private: explicit AppEventFilter(WindowManager *parent); ~AppEventFilter() {} bool eventFilter(QObject *obj, QEvent *e); WindowManager *m_wm = nullptr; }; #endif // WINDOWMANAGER_H qt5-ukui-platformtheme/ukui-styles/proxy-style/ukui-style.json0000664000175000017500000000003313641116416023653 0ustar fengfeng{ "Keys": [ "ukui" ] } qt5-ukui-platformtheme/ukui-styles/proxy-style/blur-helper.cpp0000664000175000017500000001670213643027460023606 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "blur-helper.h" #include "ukui-style-settings.h" #include #include #include #include #include #include #include "black-list.h" #include #include BlurHelper::BlurHelper(QObject *parent) : QObject(parent) { if (QGSettings::isSchemaInstalled("org.ukui.style")) { auto settings = UKUIStyleSettings::globalInstance(); connect(settings, &QGSettings::changed, this, [=](const QString &key){ if (key == "enabled-global-blur") { bool enable = settings->get("enable-global-blur").toBool(); this->onBlurEnableChanged(enable); } }); } m_timer.setSingleShot(true); m_timer.setInterval(100); } bool BlurHelper::eventFilter(QObject *obj, QEvent *e) { QWidget* widget = qobject_cast(obj); if (widget->winId() <= 0) return false; //FIXME: //qDebug()<type()<type()) { case QEvent::UpdateRequest: { //QWidget* widget = qobject_cast(obj); delayUpdate(widget, true); break; } case QEvent::LayoutRequest: { //QWidget* widget = qobject_cast(obj); delayUpdate(widget); break; } case QEvent::Hide: { //QWidget* widget = qobject_cast(obj); KWindowEffects::enableBlurBehind(widget->winId(), false); } default: break; } return false; } /*! * \brief BlurHelper::registerWidget * \param widget * \note * * we can't blur a widget before it shown, because some times * there might be problems about window painting. * this usually happend on a widget which has graphics effect. * * to avoid them, never try get winid and do a blur for that case. */ void BlurHelper::registerWidget(QWidget *widget) { if (shouldSkip(widget)) return; if (isApplicationInBlackList()) return; if (widget->property("doNotBlur").toBool()) return; if (!m_blur_widgets.contains(widget)) { m_blur_widgets<mask().isEmpty()) { // KWindowEffects::enableBlurBehind(widget->winId(), true, widget->mask()); // } else { // KWindowEffects::enableBlurBehind(widget->winId(), true); // } connect(widget, &QWidget::destroyed, this, [=](){ this->onWidgetDestroyed(widget); }); } widget->removeEventFilter(this); widget->installEventFilter(this); if (!widget->mask().isEmpty()) { widget->update(widget->mask()); } else { widget->update(); } } void BlurHelper::unregisterWidget(QWidget *widget) { if (shouldSkip(widget)) return; if (isApplicationInBlackList()) return; if (widget->property("doNotBlur").toBool()) return; m_blur_widgets.removeOne(widget); widget->removeEventFilter(this); KWindowEffects::enableBlurBehind(widget->winId(), false); } bool BlurHelper::isApplicationInBlackList() { return blackList().contains(qAppName()); } const QStringList BlurHelper::blackList() { return blackAppListWithBlurHelper(); } bool BlurHelper::shouldSkip(QWidget *w) { bool skip = false; if (w->inherits("QComboBoxPrivateContainer")) return true; // if (w->inherits("QTipLabel")) // return true; return skip; } void BlurHelper::onBlurEnableChanged(bool enable) { for (auto widget : m_blur_widgets) { if (!widget) continue; if (widget->winId() <= 0) continue; KWindowEffects::enableBlurBehind(widget->winId(), enable); if (widget->isVisible()) widget->update(); } } void BlurHelper::onWidgetDestroyed(QWidget *widget) { unregisterWidget(widget); } void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) { if (w->winId() <= 0) return; m_update_list.append(w); if (!m_timer.isActive()) { for (auto widget : m_update_list) { // cast to widget and check //KWindowEffects::enableBlurBehind(widget->winId(), false); if (!widget) continue; if (widget->winId() <= 0) continue; bool hasMask = false; if (widget->mask().isNull()) hasMask = true; QVariant regionValue = widget->property("blurRegion"); QRegion region = qvariant_cast(regionValue); if (widget->inherits("QMenu")) { QPainterPath path; path.addRoundedRect(widget->rect().adjusted(+5,+5,-5,-5), 6, 6); KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); if (!updateBlurRegionOnly) widget->update(); break; } if (widget->inherits("QTipLabel")) { QPainterPath path; path.addRoundedRect(widget->rect().adjusted(+3,+3,-3,-3),4, 4); KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); if (!updateBlurRegionOnly) widget->update(); break; } if (!hasMask && region.isEmpty()) break; //qDebug()<metaObject()->className()<geometry()<mask(); if (!region.isEmpty()) { //qDebug()<<"blur region"<winId(), true, region); if (!updateBlurRegionOnly) widget->update(); } else { //qDebug()<mask(); KWindowEffects::enableBlurBehind(widget->winId(), true, widget->mask()); if (!updateBlurRegionOnly) widget->update(widget->mask()); } //NOTE: we can not setAttribute Qt::WA_TranslucentBackground here, //because the window is about to be shown. //widget->setAttribute(Qt::WA_TranslucentBackground); //KWindowEffects::enableBlurBehind(widget->winId(), true); //widget->update(); } m_update_list.clear(); } else { m_timer.start(); } } qt5-ukui-platformtheme/ukui-styles/proxy-style/proxy-style_global.h0000664000175000017500000000205713641116416024665 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef PROXYSTYLE_GLOBAL_H #define PROXYSTYLE_GLOBAL_H #include #if defined(PROXYSTYLE_LIBRARY) # define PROXYSTYLESHARED_EXPORT Q_DECL_EXPORT #else # define PROXYSTYLESHARED_EXPORT Q_DECL_IMPORT #endif #endif // PROXYSTYLE_GLOBAL_H qt5-ukui-platformtheme/CONTRIBUTING_zh_CN.md0000664000175000017500000000737213641116416017357 0ustar fengfeng# 贡献指南 ## 写给使用者 UKUI的使用者都是此项目的用户,因为它影响了所有UKUI上的Qt应用,我们能从一个标准qt应用的按钮圆角弧度,菜单透明度,动画以及毛玻璃特效等方面看到它对控件样式带来的影响。 我们希望用户能够指出我们在应用和主题风格设计上的不统一处,以及视觉上的不足与问题,这些都有助于我们对项目进行有针对性的提升。 当然,UKUI主题框架不可能接管所有应用的控件风格与绘制,一个应用可能希望保持自己的主题,或者针对现有主题的不足进行改进。对于用户来说,可能很难分辨一个控件是否是属于UKUI主题框架内的标准控件,而只能够发现风格上的不同。 无论如何,如果你找到了视觉上的问题,你都可以向我们提交issue,可以在相应的应用项目中,也可以在这里。 ## 写给开发者 如果你对Qt5 QPA PlatformTheme以及QStyle比较熟悉,那么你应该能够很快的了解这个项目,并且知道如何参与其中。和其它platform theme,如qt5-gtk2-platformtheme、qt5ct、KDE等项目一样,我们希望通过提供平台插件和主题风格插件来构建我们自己的桌面环境主题,这样做将意味着不光是我们自己开发的应用,其它开发这开发的Qt应用也将会在我们的桌面环境中具有UKUI的风格。 这种做法将从根本上解决Qt开发者不得不花费大量时间去调整自己应用的样式以达到接近UKUI设计风格的问题。我们希望开发者花费更多时间在业务逻辑和功能实现上,并且还能够保证应用在其它平台上(如KDE)也能够具有风格的统一性。 为了实现这一目标,我需要开发者们的理解和支持。开发者首先需要知道如何以标准的方式进行应用的开发,然后还需要掌握如何在标准之上针对需求进行合理的调优。通过自己体验这样的流程,你将明白它的长远意义。 现在,我几乎将我全部的精力投入到这个项目的开发中去了,然而它的推进仍然十分缓慢。我一个人很难在短时间内解决所有的问题,所以希望有志愿者能够帮助我。我简单的列出了一些问题: ### Platform Theme层面 和其它platform theme一样,我们希望在UKUI中提供其它platform theme所提供的特性。 - 平台对话框,比如文件选择对话框 - 平台配置,比如字体配置 - 平台扩展,比如全局菜单 当然,Gtk应用的主题风格与Qt应用的风格主题也是一个比较棘手的问题,我们需要考虑怎样合理的统一它们。 ### Style层面 一个好看的主题往往是极其复杂的,比如breeze和oxygen。要构建我们自己的主题,我们需要花费大量的时间在UI设计和细节优化上。作为一名开发者,我们需要做的是将设计稿的内容转化成代码,这大致可以分为2个部分: - 控件的样式绘制与调优,比如按钮菜单的圆角弧度,调色板中的颜色等 - 动画与控件的结合,比如标签页的滑动切换,按钮的悬浮与渐变效果等 你首先得了解QStyle和主题插件的相关流程,它们是怎么绘制一个控件,怎么让控件具有动画效果的。 ### 动画框架层 动画框架一般来说基于Qt的Animation框架,它的目标是: - 让widgets和视图元素具有动画效果,并且让状态的改版更加的平滑和炫酷 需要注意的是动画框架是相对独立的,然而它对主题的影响还是非常之大。 ## 积极的交流 如果你对参与项目感兴趣,我也乐意尽力帮助你熟悉这个项目。你可以以提交issue的方式作为开始,也可以通过邮件与我交流。 Yue Lan, qt5-ukui-platformtheme/libqt5-ukui-style/0000775000175000017500000000000013643026475017354 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/libqt5-ukui-style_global.h0000664000175000017500000000211513641116416024346 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef LIBQT5UKUISTYLE_GLOBAL_H #define LIBQT5UKUISTYLE_GLOBAL_H #include #if defined(LIBQT5UKUISTYLE_LIBRARY) # define LIBQT5UKUISTYLESHARED_EXPORT Q_DECL_EXPORT #else # define LIBQT5UKUISTYLESHARED_EXPORT Q_DECL_IMPORT #endif #endif // LIBQT5UKUISTYLE_GLOBAL_H qt5-ukui-platformtheme/libqt5-ukui-style/development-files/0000775000175000017500000000000013641116416022767 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/development-files/qt5-ukui.pc0000664000175000017500000000046313641116416025002 0ustar fengfengName: libqt5-ukui-style Description: UKUI style API for secondary development. Home Page: https://github.com/ukui/qt5-ukui-platformtheme Requires: Qt5Widgets >= 5.12.1 glib-2.0 gio-2.0 gsettings-qt Version: 1.0.0 Libs: -L/usr/lib -L/usr/lib/x86_64-linux-gnu -lqt5-ukui-style Cflags: -I/usr/include/qt5-ukui qt5-ukui-platformtheme/libqt5-ukui-style/animations/0000775000175000017500000000000013641116416021507 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/animations/scrollbar/0000775000175000017500000000000013641116416023472 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/animations/scrollbar/scrollbar.pri0000664000175000017500000000021513641116416026167 0ustar fengfengHEADERS += \ $$PWD/ukui-scrollbar-default-interaction-animator.h SOURCES += \ $$PWD/ukui-scrollbar-default-interaction-animator.cpp ././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootqt5-ukui-platformtheme/libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-animator.cppqt5-ukui-platformtheme/libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-ani0000664000175000017500000002065413641116416033066 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "ukui-scrollbar-default-interaction-animator.h" #include #include #include using namespace UKUI::ScrollBar; DefaultInteractionAnimator::DefaultInteractionAnimator(QObject *parent) : QParallelAnimationGroup (parent) { m_bg_opacity = new QVariantAnimation(this); m_bg_opacity->setStartValue(0.0); m_bg_opacity->setEndValue(0.1); m_bg_opacity->setDuration(250); addAnimation(m_bg_opacity); m_groove_width = new QVariantAnimation(this); m_groove_width->setStartValue(0); m_groove_width->setEndValue(10); m_bg_opacity->setDuration(150); addAnimation(m_groove_width); m_slider_opacity = new QVariantAnimation(this); m_slider_opacity->setStartValue(0.2); m_slider_opacity->setEndValue(0.35); m_bg_opacity->setDuration(250); addAnimation(m_slider_opacity); m_sunken_silder_additional_opacity = new QVariantAnimation(this); m_sunken_silder_additional_opacity->setStartValue(double(0)); m_sunken_silder_additional_opacity->setEndValue(0.15); m_sunken_silder_additional_opacity->setDuration(150); addAnimation(m_sunken_silder_additional_opacity); setObjectName("ukui_scrollbar_default_interaction_animator"); } /*! * \brief DefaultInteractionAnimator::bindWidget * \param w * \return * * \details * QObject has a feature that parent object can use findChild() method * getting a specific named child. * * I use QObject::setObjectName() set my animator and bind to a scroll bar. * So that i could not cache a hash or map to manage animators. * * \bug * Cause I use named QObject child to cache the animator for a scrollbar, * However there are some troubles for my unexcepted. * * For example, qt5 assistant's main view can not find child correctly. * I don't know if animator bind with child was been removed at some times. */ bool DefaultInteractionAnimator::bindWidget(QWidget *w) { //qDebug()<objectName()<topLevelWidget()->metaObject()->className(); if (qobject_cast(w)) { if (w->property("doNotAnimate").toBool()) return false; m_widget = w; return true; } return false; } bool DefaultInteractionAnimator::unboundWidget() { this->stop(); this->setDirection(QAbstractAnimation::Forward); if (m_widget) { this->setParent(nullptr); return true; } return false; } QVariant DefaultInteractionAnimator::value(const QString &property) { if (property == "bg_opacity") { return m_bg_opacity->currentValue(); } else if (property == "groove_width") { return m_groove_width->currentValue(); } else if (property == "slider_opacity") { return m_slider_opacity->currentValue(); } else if (property == "additional_opacity") { return m_sunken_silder_additional_opacity->currentValue(); } else { return QVariant(); } } bool DefaultInteractionAnimator::setAnimatorStartValue(const QString &property, const QVariant &value) { if (property == "bg_opacity") { m_bg_opacity->setStartValue(value); return true; } else if (property == "groove_width") { m_groove_width->setStartValue(value); return true; } else if (property == "slider_opacity") { m_slider_opacity->setStartValue(value); return true; } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->setStartValue(value); return true; } else { return false; } } bool DefaultInteractionAnimator::setAnimatorEndValue(const QString &property, const QVariant &value) { if (property == "bg_opacity") { m_bg_opacity->setEndValue(value); return true; } else if (property == "groove_width") { m_groove_width->setEndValue(value); return true; } else if (property == "slider_opacity") { m_slider_opacity->setEndValue(value); return true; } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->setEndValue(value); return true; } else { return false; } } bool DefaultInteractionAnimator::setAnimatorDuration(const QString &property, int duration) { if (property == "bg_opacity") { m_bg_opacity->setDuration(duration); return true; } else if (property == "groove_width") { m_groove_width->setDuration(duration); return true; } else if (property == "slider_opacity") { m_groove_width->setDuration(duration); return true; } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->setDuration(duration); return true; } else { return false; } } void DefaultInteractionAnimator::setAnimatorDirectionForward(const QString &property, bool forward) { auto d = forward? QAbstractAnimation::Forward: QAbstractAnimation::Backward; if (property == "bg_opacity") { m_bg_opacity->setDirection(d); } else if (property == "groove_width") { m_groove_width->setDirection(d); } else if (property == "slider_opacity") { m_slider_opacity->setDirection(d); } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->setDirection(d); } else { return; } } bool DefaultInteractionAnimator::isRunning(const QString &property) { if (property == "bg_opacity") { return m_bg_opacity->state() == Running; } else if (property == "groove_width") { return m_groove_width->state() == Running; } else if (property == "slider_opacity") { return m_slider_opacity->state() == Running; } else if (property == "additional_opacity") { return m_sunken_silder_additional_opacity->state() == Running; } else { return this->state() == Running; } } void DefaultInteractionAnimator::startAnimator(const QString &property) { if (property == "bg_opacity") { m_bg_opacity->start(); } else if (property == "groove_width") { m_groove_width->start(); } else if (property == "slider_opacity") { m_slider_opacity->start(); } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->start(); } else { this->start(); } } void DefaultInteractionAnimator::stopAnimator(const QString &property) { if (property == "bg_opacity") { m_bg_opacity->stop(); } else if (property == "groove_width") { m_groove_width->stop(); } else if (property == "slider_opacity") { m_slider_opacity->stop(); } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->stop(); } else { this->stop(); } } int DefaultInteractionAnimator::currentAnimatorTime(const QString &property) { if (property == "bg_opacity") { return m_bg_opacity->currentTime(); } else if (property == "groove_width") { return m_groove_width->currentTime(); } else if (property == "slider_opacity") { return m_slider_opacity->currentTime(); } else if (property == "additional_opacity") { return m_sunken_silder_additional_opacity->currentTime(); } else { return this->currentTime(); } } int DefaultInteractionAnimator::totalAnimationDuration(const QString &property) { if (property == "bg_opacity") { return m_bg_opacity->duration(); } else if (property == "groove_width") { return m_groove_width->duration(); } else if (property == "slider_opacity") { return m_slider_opacity->duration(); } else if (property == "additional_opacity") { return m_sunken_silder_additional_opacity->duration(); } else { return this->duration(); } } ././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootrootqt5-ukui-platformtheme/libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-animator.hqt5-ukui-platformtheme/libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-ani0000664000175000017500000000434313641116416033063 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef UKUISCROLLBARDEFAULTINTERACTIONANIMATOR_H #define UKUISCROLLBARDEFAULTINTERACTIONANIMATOR_H #include #include "animator-iface.h" class QVariantAnimation; namespace UKUI { namespace ScrollBar { class DefaultInteractionAnimator : public QParallelAnimationGroup, public AnimatorIface { Q_OBJECT public: explicit DefaultInteractionAnimator(QObject *parent = nullptr); bool bindWidget(QWidget *w); bool unboundWidget(); QWidget *boundedWidget() {return m_widget;} QVariant value(const QString &property); bool isRunning(const QString &property = nullptr); bool setAnimatorStartValue(const QString &property, const QVariant &value); bool setAnimatorEndValue(const QString &property, const QVariant &value); bool setAnimatorDuration(const QString &property, int duration); void setAnimatorDirectionForward(const QString &property = nullptr, bool forward = true); void startAnimator(const QString &property = nullptr); void stopAnimator(const QString &property = nullptr); int currentAnimatorTime(const QString &property = nullptr); int totalAnimationDuration(const QString &property); private: QWidget *m_widget = nullptr; QVariantAnimation *m_bg_opacity; QVariantAnimation *m_groove_width; QVariantAnimation *m_slider_opacity; QVariantAnimation *m_sunken_silder_additional_opacity; }; } } #endif // UKUISCROLLBARDEFAULTINTERACTIONANIMATOR_H qt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/0000775000175000017500000000000013641116416023461 5ustar fengfeng././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.hqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.0000664000175000017500000000662213641116416032745 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef UKUITABWIDGETDEFAULTSLIDEANIMATOR_H #define UKUITABWIDGETDEFAULTSLIDEANIMATOR_H #include #include #include #include "ukui-tabwidget-animator-iface.h" #include namespace UKUI { namespace TabWidget { /*! * \brief The DefaultSlideAnimator class * \details * This class is an implement of UKUITabWidgetAnimatorIface. */ class DefaultSlideAnimator : public QVariantAnimation, public UKUITabWidgetAnimatorIface { Q_OBJECT public: explicit DefaultSlideAnimator(QObject *parent = nullptr); bool bindTabWidget(QTabWidget *w); bool unboundTabWidget(); QWidget *boundedWidget() {return m_bound_widget;} bool eventFilter(QObject *obj, QEvent *e); protected: void watchSubPage(QWidget *w); bool filterTabWidget(QObject *obj, QEvent *e); bool filterStackedWidget(QObject *obj, QEvent *e); bool filterSubPage(QObject *obj, QEvent *e); bool filterTmpPage(QObject *obj, QEvent *e); void clearPixmap(); private: QTabWidget *m_bound_widget = nullptr; QStackedWidget *m_stack = nullptr; QList m_children; QPixmap m_previous_pixmap; QPixmap m_next_pixmap; /*! * \brief m_tmp_page * \note * insert a tmp tab page into tab widget directly is dangerous, * because a custom tab widget's page may be desgined different * with normal tab page, such as peony-qt's directory view. * In that case, it might lead program crashed when * application call a custom page but get a tmp page. * * for those reasons, i use a temporary widgets bound to the * stacked widget with qt's parent&child mechanism. * It can float on the top layer or hide on the lower layer of stack, * but it does not belong to the elements in the stack (no index), * which can avoid the above problems. * * However, this way might be incompatible with other animations. * Because it uses a new widget for painting, not relate with orignal * page. Another conflict is the oxygen's fade animation might force * raise current tab page when it finished. That might cause a incompleted * slide animation if slide duration is longer than fade's. */ QWidget *m_tmp_page = nullptr; /*! * \brief m_tab_resizing * \details * If a went to a resize event, the animation should handle * widget's relayout after resized. * This bool varient is used to help judege if animator's pixmaps * and template widget' states should be updated. */ bool m_tab_resizing = false; }; } } #endif // UKUITABWIDGETDEFAULTSLIDEANIMATOR_H ././@LongLink0000644000000000000000000000016000000000000011600 Lustar rootrootqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-factory.cppqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-0000664000175000017500000000222313641116416032735 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "ukui-tabwidget-default-slide-animator-factory.h" #include "ukui-tabwidget-default-slide-animator.h" using namespace UKUI::TabWidget; DefaultSlideAnimatorFactory::DefaultSlideAnimatorFactory(QObject *parent) : QObject(parent) { } UKUITabWidgetAnimatorIface *DefaultSlideAnimatorFactory::createAnimator() { return new DefaultSlideAnimator; } qt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-animator-plugin-iface.h0000664000175000017500000000424013641116416032730 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef UKUITABWIDGETANIMATORPLUGINIFACE_H #define UKUITABWIDGETANIMATORPLUGINIFACE_H #include #include "animator-plugin-iface.h" #include "ukui-tabwidget-animator-iface.h" #define UKUITabWidgetAnimatorPluginInterface_iid "org.ukui.style.animatons.TabWidgetPluginInterface" /*! * \brief The UKUITabWidgetAnimatorPluginIface class * \details * This class is used to create a tabwidget animator instace. * * UKUI Animation's frameworks is desgined to be extensiable. * And this interface is an entry of plugin. * * \see UKUITabWidgetAnimatorIface */ class UKUITabWidgetAnimatorPluginIface : public UKUIAnimatorPluginIface { public: virtual ~UKUITabWidgetAnimatorPluginIface() {} /*! * \brief key * \return * A key word of plugin, such as "slide". */ virtual const QString key() = 0; /*! * \brief description * \return * A description for animator. For example, "Animator for do a horizon slide * for tab widget." */ virtual const QString description() = 0; /*! * \brief createAnimator * \return * an animator instance, for example a UKUI::TabWidget::DefaultSlideAnimator. */ virtual UKUITabWidgetAnimatorIface *createAnimator() = 0; }; Q_DECLARE_INTERFACE(UKUITabWidgetAnimatorPluginIface, UKUITabWidgetAnimatorPluginInterface_iid) #endif // UKUITABWIDGETANIMATORPLUGINIFACE_H ././@LongLink0000644000000000000000000000015000000000000011577 Lustar rootrootqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.cppqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.0000664000175000017500000002002213641116416032733 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "ukui-tabwidget-default-slide-animator.h" #include #include #include #include #include #include #include using namespace UKUI::TabWidget; /*! * \brief DefaultSlideAnimator::DefaultSlideAnimator * \param parent * \details * This class define a slide animator for tab widget sliding animation. * Animator based on QVariantAnimation, paint on a tmp widgets when running. * The content of widget is based on animation's current value and 2 pixmap * grabbed at appropriate times. * * \note * Once an animator have bound a tab widget, it have to unbound current widget at first. * Then it can bind another tab widget again. */ DefaultSlideAnimator::DefaultSlideAnimator(QObject *parent) : QVariantAnimation (parent) { setDuration(150); setStartValue(0.0); setEndValue(1.0); } /*! * \brief DefaultSlideAnimator::bindTabWidget * \param w A QTabWidget instance, most passed in QStyle::polish(). * \return result if Tab widget be bound \c true for binding successed. * \details * When do a tab widget binding, animator will create a tmp child page for tab widget's * stack widget. Then it will watched their event waiting for preparing and doing a animation. */ bool DefaultSlideAnimator::bindTabWidget(QTabWidget *w) { if (w) { m_bound_widget = w; //watch tab widget w->installEventFilter(this); m_tmp_page = new QWidget; //watch tmp page; m_tmp_page->installEventFilter(this); for (auto child : w->children()) { if (child->objectName() == "qt_tabwidget_stackedwidget") { auto stack = qobject_cast(child); m_stack = stack; //watch stack widget m_tmp_page->setParent(m_stack); m_stack->installEventFilter(this); break; } } for (int i = 0; i < w->count(); i++) { //watch sub page watchSubPage(w->widget(i)); } connect(w, &QTabWidget::currentChanged, this, [=](int index){ qDebug()<currentIndex(); qDebug()<currentWidget()) { m_next_pixmap = m_bound_widget->currentWidget()->grab(); m_tmp_page->raise(); m_tmp_page->show(); } }); return true; } return false; } bool DefaultSlideAnimator::unboundTabWidget() { clearPixmap(); if (m_bound_widget) { disconnect(m_bound_widget, &QTabWidget::currentChanged, this, nullptr); for (auto w : m_bound_widget->children()) { w->removeEventFilter(this); } m_tmp_page->removeEventFilter(this); m_tmp_page->deleteLater(); m_tmp_page = nullptr; m_bound_widget = nullptr; this->deleteLater(); return true; } return false; } bool DefaultSlideAnimator::eventFilter(QObject *obj, QEvent *e) { if (obj == m_tmp_page) { return filterTmpPage(obj, e); } if (obj == m_stack) { return filterStackedWidget(obj, e); } if (obj == m_bound_widget) { return filterTabWidget(obj, e); } return filterSubPage(obj, e); } void DefaultSlideAnimator::watchSubPage(QWidget *w) { w->installEventFilter(this); } bool DefaultSlideAnimator::filterTabWidget(QObject *obj, QEvent *e) { if (e->type() == QEvent::Close) { this->unboundTabWidget(); } return false; } bool DefaultSlideAnimator::filterStackedWidget(QObject *obj, QEvent *e) { switch (e->type()) { case QEvent::ChildAdded: case QEvent::ChildRemoved: { qDebug()<<"added/removed"<objectName() == "qt_tabwidget_stackedwidget") { QChildEvent *ce = static_cast(e); if (!ce->child()->isWidgetType()) return false; if (ce->added()) { ce->child()->installEventFilter(this); } else { ce->child()->removeEventFilter(this); } } return false; } case QEvent::Resize: //qDebug()<<"resize"; m_tab_resizing = true; return false; case QEvent::LayoutRequest: { /// there a 2 case we need excute these codes. /// 1. when stacked widget created and shown, it first do resize, then do a layout request. /// 2. after stacked widget resize. /// /// This event is very suitable for the above two situations, /// both in terms of efficiency and trigger time. if (m_tab_resizing) { qDebug()<<"ok"; m_tmp_page->resize(m_stack->size()); if (m_bound_widget->currentWidget()) m_previous_pixmap = m_bound_widget->currentWidget()->grab(); } m_tab_resizing = false; return false; } default: break; } return false; } bool DefaultSlideAnimator::filterSubPage(QObject *obj, QEvent *e) { switch (e->type()) { case QEvent::Show: { this->start(); return false; } case QEvent::Hide: { if (!m_next_pixmap.isNull()) m_previous_pixmap = m_next_pixmap; this->stop(); return false; } case QEvent::Resize: { this->stop(); return false; } default: return false; } } bool DefaultSlideAnimator::filterTmpPage(QObject *obj, QEvent *e) { switch (e->type()) { case QEvent::Show: { return false; } case QEvent::Paint: { QWidget *w = qobject_cast(obj); if (this->state() == QAbstractAnimation::Running) { QPainter p(w); auto value = this->currentValue().toDouble(); p.setRenderHints(QPainter::Antialiasing); //do a horizon slide. auto prevSrcRect = QRectF(m_previous_pixmap.rect()); auto prevTargetRect = QRectF(m_previous_pixmap.rect()); prevSrcRect.setX(m_previous_pixmap.width()*value); prevSrcRect.setWidth(m_previous_pixmap.width() * (1 - value)); prevTargetRect.setX(0); prevTargetRect.setWidth(m_previous_pixmap.width() * (1 - value)); p.drawPixmap(prevTargetRect, m_previous_pixmap, prevSrcRect); auto nextSrcRect = QRectF(m_next_pixmap.rect()); auto nextTargetRect = QRectF(m_next_pixmap.rect()); nextSrcRect.setWidth(m_next_pixmap.width() * value); nextTargetRect.setX(m_next_pixmap.width() * (1 - value)); nextTargetRect.setWidth(m_next_pixmap.width() * value); p.drawPixmap(nextTargetRect, m_next_pixmap, nextSrcRect); //continue paint until animate finished. w->raise(); w->show(); w->update(); //eat event so that widget will not paint default items and override //our custom pixmap. return true; } qDebug()<<"hide"; m_tmp_page->hide(); m_stack->stackUnder(m_tmp_page); m_previous_pixmap = m_next_pixmap; return false; } default: return false; } } void DefaultSlideAnimator::clearPixmap() { m_previous_pixmap = QPixmap(); m_next_pixmap = QPixmap(); } qt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/tabwidget.pri0000664000175000017500000000061113641116416026145 0ustar fengfengINCLUDEPATH += $$PWD HEADERS += \ $$PWD/ukui-tabwidget-animator-iface.h \ $$PWD/ukui-tabwidget-animator-plugin-iface.h \ $$PWD/ukui-tabwidget-default-slide-animator-factory.h \ $$PWD/ukui-tabwidget-default-slide-animator.h SOURCES += \ $$PWD/ukui-tabwidget-default-slide-animator-factory.cpp \ $$PWD/ukui-tabwidget-default-slide-animator.cpp INCLUDEPATH += $$PWD/.. ././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-factory.hqt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-0000664000175000017500000000406613641116416032744 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef UKUITABWIDGETDEFAULTSLIDEANIMATORFACTORY_H #define UKUITABWIDGETDEFAULTSLIDEANIMATORFACTORY_H #include #include "ukui-tabwidget-animator-plugin-iface.h" namespace UKUI { namespace TabWidget { /*! * \brief The DefaultSlideAnimatorFactory class * \details * This class is an internal plugin. It provides a default tabwidget * switch animation for QTabWidget and its drived class. * * \note * Note that it used in ukui-style, but you can also use its api in other * desktop environment. */ class DefaultSlideAnimatorFactory : public QObject, public UKUITabWidgetAnimatorPluginIface { Q_OBJECT public: explicit DefaultSlideAnimatorFactory(QObject *parent = nullptr); const QString id() {return tr("Default Slide");} const QString brief() {return tr("Let tab widget switch with a slide animation.");} const QString key() {return "tab_slide";} const QString description() {return brief();} AnimatorPluginType pluginType() {return TabWidget;} const QString inhertKey() {return "QTabWidget";} const QStringList excludeKeys() {return QStringList()<<"Peony::DirectoryWidget";} bool isParallel() {return false;} UKUITabWidgetAnimatorIface *createAnimator(); }; } } #endif // UKUITABWIDGETDEFAULTSLIDEANIMATORFACTORY_H qt5-ukui-platformtheme/libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-animator-iface.h0000664000175000017500000000443713641116416031444 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef UKUITABWIDGETANIMATORIFACE_H #define UKUITABWIDGETANIMATORIFACE_H #include #include "animator-iface.h" /*! * \brief The UKUITabWidgetAnimatorIface class * \details * This class define the interface for doing a QTabWidget's animation. * a tabwidget animator should bind only one tabwidget with bindTabWidget(), * and can be unbounded with unboundTabWidget(). * * Animator is created by AnimatorPlugin, which is another interface's implement * of UKUI style animation's frameworks. * * \see UKUITabWidgetAnimatorPluginIface */ class UKUITabWidgetAnimatorIface : public AnimatorIface { public: virtual ~UKUITabWidgetAnimatorIface() {} virtual bool bindWidget(QWidget *w) { return bindTabWidget(qobject_cast(w)); } virtual bool unboundWidget() { return unboundTabWidget(); } /*! * \brief bindTabWidget * \param w widget should be bound. * \return true if successed. * \details * this method is used for binding a animator instance for a tab widget. * You have to implement this function in your own implement class. */ virtual bool bindTabWidget(QTabWidget *w) = 0; /*! * \brief unboundTabWidget * \return true if successed. * \details * this method is used to unbound the animator instance and tab widget. * You have to implement this function in your own implement class. */ virtual bool unboundTabWidget() = 0; }; #endif // UKUITABWIDGETANIMATORIFACE_H qt5-ukui-platformtheme/libqt5-ukui-style/animations/animator-iface.h0000664000175000017500000000377613641116416024554 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef ANIMATORIFACE_H #define ANIMATORIFACE_H #include "animator-plugin-iface.h" #include class QWidget; class AnimatorIface { public: virtual ~AnimatorIface() {} virtual bool bindWidget(QWidget *w) {return false;} virtual bool unboundWidget() {return false;} virtual QWidget *boundedWidget() {return nullptr;} virtual QVariant value(const QString &property) {return QVariant();} virtual bool setAnimatorStartValue(const QString &property, const QVariant &value) {return false;} virtual bool setAnimatorEndValue(const QString &property, const QVariant &value) {return false;} virtual bool setAnimatorDuration(const QString &property, int duration) {return false;} virtual void setAnimatorDirectionForward(const QString &property = nullptr, bool forward = true) {} virtual bool isRunning(const QString &property = nullptr) {return false;} virtual void startAnimator(const QString &property = nullptr) {} virtual void stopAnimator(const QString &property = nullptr) {} virtual int currentAnimatorTime(const QString &property = nullptr) {return 0;} virtual int totalAnimationDuration(const QString &property = nullptr) {return 0;} }; #endif // ANIMATORIFACE_H qt5-ukui-platformtheme/libqt5-ukui-style/animations/animation-helper.cpp0000664000175000017500000000222413641116416025447 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "animation-helper.h" #include #include "animator-iface.h" AnimationHelper::AnimationHelper(QObject *parent) : QObject(parent) { m_animators = new QHash(); } AnimationHelper::~AnimationHelper() { // for (auto animator : *m_animators) { // delete animator; // } delete m_animators; } qt5-ukui-platformtheme/libqt5-ukui-style/animations/animations.pri0000664000175000017500000000041113641116416024361 0ustar fengfengINCLUDEPATH += $$PWD INCLUDEPATH += $$PWD/.. include(tabwidget/tabwidget.pri) include(scrollbar/scrollbar.pri) HEADERS += \ $$PWD/animator-plugin-iface.h \ $$PWD/animator-iface.h \ $$PWD/animation-helper.h SOURCES += \ $$PWD/animation-helper.cpp qt5-ukui-platformtheme/libqt5-ukui-style/animations/animator-plugin-iface.h0000664000175000017500000000566013641116416026042 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef ANIMATORPLUGINIFACE_H #define ANIMATORPLUGINIFACE_H #include class UKUIAnimatorPluginIface { public: enum AnimatorPluginType { TabWidget, StackedWidget, PushButton, ItemView, ScrollBar, MenuBar, Menu, Other }; virtual ~UKUIAnimatorPluginIface() {} /*! * \brief id * \return unique plugin's id. * \details * You have to define a unique id for your animator plugin. */ virtual const QString id() = 0; /*! * \brief brief * \return a brief of animator. */ virtual const QString brief() = 0; /*! * \brief pluginType * \return animator type for indicating what kinds of widget to bind with. */ virtual AnimatorPluginType pluginType() = 0; /*! * \brief inhertKey * \return * \details * When a style polish a widget, ukui animation frameworks will bind the animator * to the widget. This value is the keyword for judgeing if the widget should be bound * with animator. For example, return this value with "QWidget", then all the widgets * will be bound. */ virtual const QString inhertKey() = 0; /*! * \brief excludeKeys * \return * \details * In contrast to inhertKey(), this list is a "blacklist" of * widgets should not be bound with the animator. */ virtual const QStringList excludeKeys() = 0; /*! * \brief isParallel * \return * \details * Indicate if the animator which plugin created is compatible with other * animators. * * \note * This variable has no practical effect, * but we hope that the animations acting on the same control * can be parallelized, although it is difficult to achieve. * * If you note the animator is not parallelized, other animator * might be invalid. For example, the default tabwidget slide animator * will hijack the paint event of current tabwidget's tab. This might * let other animator can not do a paint in current tab. */ virtual bool isParallel() = 0; }; #endif // ANIMATORPLUGINIFACE_H qt5-ukui-platformtheme/libqt5-ukui-style/animations/animation-helper.h0000664000175000017500000000265413641116416025123 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef ANIMATIONHELPER_H #define ANIMATIONHELPER_H #include class QWidget; class AnimatorIface; class AnimationHelper : public QObject { Q_OBJECT public: explicit AnimationHelper(QObject *parent = nullptr); virtual ~AnimationHelper(); signals: public slots: virtual bool registerWidget(QWidget *) {return false;} virtual bool unregisterWidget(QWidget *) {return false;} protected: /*! * \brief m_animators * \deprecated * You should not use this member in newly-written code. */ QHash *m_animators = nullptr; }; #endif // ANIMATIONHELPER_H qt5-ukui-platformtheme/libqt5-ukui-style/black-list.h0000664000175000017500000000076313643026475021560 0ustar fengfeng#ifndef BLACKLIST_H #define BLACKLIST_H #include static const QStringList blackAppList() { QStringList l; l<<"ukui-control-center"; l<<"kylin-burner"; l<<"assistant"; return l; } static const QStringList blackAppListWithBlurHelper(){ QStringList l; l<<"youker-assistant"; l<<"kylin-assistant"; l<<"kylin-video"; l<<"ukui-control-center"; l<<"ubuntu-kylin-software-center.py"; l<<"kylin-burner"; return l; } #endif // BLACKLIST_H qt5-ukui-platformtheme/libqt5-ukui-style/settings/0000775000175000017500000000000013641116416021205 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/settings/org.ukui.style.gschema.xml0000664000175000017500000000633013641116416026241 0ustar fengfeng "ukui-default" Current Qt Style Set default style for UKUI desktop environment. "ukui-icon-theme-default" Icon Theme for Qt Applications. Icon Theme for Qt Applications. "Noto Sans CJK SC" System Font for Qt Applications. System Font for Qt Applications. 11 System Font Size for Qt Applications. System Font Size for Qt Applications. Use point size. true Enable Window Blur Effects. Globally enable or disable the window blur effects for transparent window. Setting it to "false" will disable the effects. 72 Menu's transparency. The default transparency of menu. 72 Peony::SideBar's transparency. The default transparency of the peony side bar. "[]" a list of QWidget based classes do not blur. Example: [QWidget, QWidget1, QWidget2] false Use system palette. Globally enable or disable system palette provided by ukui platform. "" System Palette Set default system palette for UKUI desktop environment. false Use custom highlight color. Globally enable or disable custom highlight color. "#3D6BE5" Custom highlight color Set custom highlight color for UKUI desktop environment. qt5-ukui-platformtheme/libqt5-ukui-style/settings/application-style-settings.h0000664000175000017500000000566213641116416026666 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef APPLICATIONSTYLESETTINGS_H #define APPLICATIONSTYLESETTINGS_H #include #include #include class QStyle; /*! * \brief The ApplicationStyleSettings class * \details * This class is used to decide the style switch stretagies for independent application. * For example, you can choose the color scheme switch stretagy of an application, hold * the color in light or dark, or follow the system's palette. * * \note * This API is unstable, if possible, do not use it. */ class ApplicationStyleSettings : public QSettings { Q_OBJECT public: enum ColorStretagy { System, Bright, Dark, Other }; Q_ENUM(ColorStretagy) enum StyleStretagy { Default, Custom }; Q_ENUM(StyleStretagy) static ApplicationStyleSettings *getInstance(); ColorStretagy currentColorStretagy() {return m_color_stretagy;} StyleStretagy currentStyleStretagy() {return m_style_stretagy;} const QString currentCustomStyleName(); void setColor(const QPalette::ColorRole &role, const QColor &color, const QPalette::ColorGroup &group = QPalette::Active); const QColor getColor(const QPalette::ColorRole &role, const QPalette::ColorGroup &group = QPalette::Active); QPalette getCustomPalette() {return m_custom_palette;} signals: void colorStretageChanged(const ColorStretagy &stretagy); void styleStretageChanged(const StyleStretagy &stretagy); public slots: void setColorStretagy(ColorStretagy stretagy); void setStyleStretagy(StyleStretagy stretagy); void setCustomStyle(const QString &style); protected: void refreshData(bool forceSync = false); void readPalleteSettings(); private: explicit ApplicationStyleSettings(QObject *parent = nullptr); ~ApplicationStyleSettings() {} ColorStretagy m_color_stretagy; StyleStretagy m_style_stretagy; QString m_current_custom_style_name; QMetaEnum m_color_role_enum = QMetaEnum::fromType(); QMetaEnum m_color_group_enum = QMetaEnum::fromType(); QPalette m_custom_palette; }; #endif // APPLICATIONSTYLESETTINGS_H qt5-ukui-platformtheme/libqt5-ukui-style/settings/ukui-style-settings.h0000664000175000017500000000257413641116416025337 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef UKUISTYLESETTINGS_H #define UKUISTYLESETTINGS_H #include "libqt5-ukui-style_global.h" #include /*! * \brief The UKUIStyleSettings class * \details * To distingust with other gsettings, I derived this class form QGSettings. * It just represent the specific gsettings "org.ukui.style", and * there is no api difference from UKUIStyleSettings to QGSettings. */ class LIBQT5UKUISTYLESHARED_EXPORT UKUIStyleSettings : public QGSettings { Q_OBJECT public: UKUIStyleSettings(); static UKUIStyleSettings *globalInstance(); }; #endif // UKUISTYLESETTINGS_H qt5-ukui-platformtheme/libqt5-ukui-style/settings/application-style-settings.cpp0000664000175000017500000001326313641116416027215 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "application-style-settings.h" #include #include #include #include #include static ApplicationStyleSettings *global_instance = nullptr; ApplicationStyleSettings *ApplicationStyleSettings::getInstance() { if (!global_instance) global_instance = new ApplicationStyleSettings; return global_instance; } const QString ApplicationStyleSettings::currentCustomStyleName() { if (m_style_stretagy == Default) return nullptr; return m_current_custom_style_name; } void ApplicationStyleSettings::setColor(const QPalette::ColorRole &role, const QColor &color, const QPalette::ColorGroup &group) { beginGroup(m_color_group_enum.key(group)); setValue(m_color_role_enum.key(role), color); endGroup(); QtConcurrent::run([=](){ this->sync(); }); auto palette = QApplication::palette(); palette.setColor(group, role, color); QApplication::setPalette(palette); qApp->paletteChanged(palette); } const QColor ApplicationStyleSettings::getColor(const QPalette::ColorRole &role, const QPalette::ColorGroup &group) { beginGroup(m_color_role_enum.key(group)); auto data = value(m_color_role_enum.key(role)); QColor color = qvariant_cast(data); endGroup(); if (color.isValid()) return color; return QApplication::palette().color(group, role); } void ApplicationStyleSettings::setColorStretagy(ApplicationStyleSettings::ColorStretagy stretagy) { if (m_color_stretagy != stretagy) { m_color_stretagy = stretagy; setValue("color-stretagy", stretagy); Q_EMIT colorStretageChanged(stretagy); QtConcurrent::run([=](){ this->sync(); }); } } void ApplicationStyleSettings::setStyleStretagy(ApplicationStyleSettings::StyleStretagy stretagy) { if (m_style_stretagy != stretagy) { m_style_stretagy = stretagy; setValue("style-stretagy", stretagy); Q_EMIT styleStretageChanged(stretagy); QtConcurrent::run([=](){ this->sync(); }); } } void ApplicationStyleSettings::setCustomStyle(const QString &style) { m_current_custom_style_name = style; QApplication::setStyle(style); } void ApplicationStyleSettings::refreshData(bool forceSync) { sync(); m_custom_palette = QApplication::palette(); auto color_stretagy = qvariant_cast(value("color-stretagy")); if (color_stretagy != m_color_stretagy) { m_color_stretagy = color_stretagy; Q_EMIT colorStretageChanged(m_color_stretagy); } auto style_stretagy = qvariant_cast(value("style-stretagy")); if (style_stretagy != m_style_stretagy) { m_style_stretagy = style_stretagy; Q_EMIT styleStretageChanged(m_style_stretagy); } auto current_custom_style_name = value("custom-style").toString(); if (m_current_custom_style_name != current_custom_style_name) { m_current_custom_style_name = current_custom_style_name; QApplication::setStyle(m_current_custom_style_name); } readPalleteSettings(); if (forceSync) { QtConcurrent::run([=](){ this->sync(); }); } } void ApplicationStyleSettings::readPalleteSettings() { for (int i = 0; i < m_color_group_enum.keyCount(); i++) { beginGroup(m_color_group_enum.key(i)); for (int j = 0; j < m_color_role_enum.keyCount(); j++) { auto data = value(m_color_role_enum.key(j)); if (data.isValid()) { m_custom_palette.setColor(QPalette::ColorGroup(i), QPalette::ColorRole(j), qvariant_cast(data)); } } } } ApplicationStyleSettings::ApplicationStyleSettings(QObject *parent) : QSettings(parent) { /*! \todo make settings together into an ini file. */ // QString configFileName = QApplication::organizationDomain() + "." + QApplication::organizationName() + "." + QApplication::applicationName(); // QString configDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + "ukui"; // QString configPath = configDir + "/" + configFileName; // setPath(QSettings::IniFormat, QSettings::UserScope, configPath); // setDefaultFormat(QSettings::IniFormat); setDefaultFormat(QSettings::IniFormat); setAtomicSyncRequired(true); m_color_stretagy = qvariant_cast(value("color-stretagy")); m_style_stretagy = qvariant_cast(value("style-stretagy")); m_current_custom_style_name = value("custom-style").toString(); m_custom_palette = QApplication::palette(); readPalleteSettings(); QFileSystemWatcher *watcher = new QFileSystemWatcher(this); watcher->addPath(fileName()); connect(watcher, &QFileSystemWatcher::fileChanged, [=](){ refreshData(); }); } qt5-ukui-platformtheme/libqt5-ukui-style/settings/settings.pri0000664000175000017500000000040113641116416023554 0ustar fengfengHEADERS += $$PWD/libqt5-ukui-style_global.h \ $$PWD/ukui-style-settings.h \ $$PWD/application-style-settings.h SOURCES += $$PWD/ukui-style-settings.cpp \ $$PWD/application-style-settings.cpp INCLUDEPATH += $$PWD/.. INCLUDEPATH += $$PWD qt5-ukui-platformtheme/libqt5-ukui-style/settings/ukui-style-settings.cpp0000664000175000017500000000221613641116416025663 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "ukui-style-settings.h" static UKUIStyleSettings *global_instance = nullptr; UKUIStyleSettings::UKUIStyleSettings() : QGSettings ("org.ukui.style", "/org/ukui/style/") { } UKUIStyleSettings *UKUIStyleSettings::globalInstance() { if (!global_instance){ global_instance = new UKUIStyleSettings; } return global_instance; } qt5-ukui-platformtheme/libqt5-ukui-style/internal-styles/0000775000175000017500000000000013641116416022502 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/internal-styles/mps-style.cpp0000664000175000017500000001143413641116416025146 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "mps-style.h" MPSStyle::MPSStyle(bool dark) : InternalStyle ("fusion") { } void MPSStyle::drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { //FIXME: QProxyStyle::drawComplexControl(control, option, painter, widget); } void MPSStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { //FIXME: QProxyStyle::drawControl(element, option, painter, widget); } void MPSStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const { //FIXME: QProxyStyle::drawItemPixmap(painter, rectangle, alignment, pixmap); } void MPSStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const { //FIXME: QProxyStyle::drawItemText(painter, rectangle, alignment, palette, enabled, text, textRole); } void MPSStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { //FIXME: QProxyStyle::drawPrimitive(element, option, painter, widget); } QPixmap MPSStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const { //FIXME: return QProxyStyle::generatedIconPixmap(iconMode, pixmap, option); } QStyle::SubControl MPSStyle::hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget) const { //FIXME: return QProxyStyle::hitTestComplexControl(control, option, position, widget); } QRect MPSStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const { //FIXME: return QProxyStyle::itemPixmapRect(rectangle, alignment, pixmap); } QRect MPSStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const { //FIXME: return QProxyStyle::itemTextRect(metrics, rectangle, alignment, enabled, text); } int MPSStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { //FIXME: return QProxyStyle::pixelMetric(metric, option, widget); } void MPSStyle::polish(QWidget *widget) { //FIXME: QProxyStyle::polish(widget); } void MPSStyle::polish(QApplication *application) { //FIXME: QProxyStyle::polish(application); } void MPSStyle::polish(QPalette &palette) { //FIXME: QProxyStyle::polish(palette); } void MPSStyle::unpolish(QWidget *widget) { //FIXME: QProxyStyle::unpolish(widget); } void MPSStyle::unpolish(QApplication *application) { //FIXME: QProxyStyle::unpolish(application); } QSize MPSStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const { //FIXME: return QProxyStyle::sizeFromContents(type, option, contentsSize, widget); } QIcon MPSStyle::standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const { //FIXME: return QProxyStyle::standardIcon(standardIcon, option, widget); } QPalette MPSStyle::standardPalette() const { //FIXME: return QProxyStyle::standardPalette(); } int MPSStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { //FIXME: return QProxyStyle::styleHint(hint, option, widget, returnData); } QRect MPSStyle::subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget) const { //FIXME: return QProxyStyle::subControlRect(control, option, subControl, widget); } QRect MPSStyle::subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const { //FIXME: return QProxyStyle::subElementRect(element, option, widget); } qt5-ukui-platformtheme/libqt5-ukui-style/internal-styles/mps-style.h0000664000175000017500000001030313641116416024605 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef MPSSTYLE_H #define MPSSTYLE_H #include "internal-style.h" /*! * \brief The MPSStyle class * \details * M(enu)P(anel)S(idebar)Style is an internal style shared in several * UKUI desktop applications, such as UKUI Menu, UKUI Panel and UKUI Sidebar, etc. * * Usually, applications use the styles which have been installed as qstyle plugin in * UKUI desktop environment, such as ukui-white and ukui-black. However one style may * be not enough for UKUI3.0 desgin. The menu, panel and sidebar desgin is Noticeably * different from the common style which we used in peony or other qt's applications. * To integrate the unique style into the theme, I came up the idea of internal styles, * and combine them with current platform theme's frameworks. So it will Looks like a * whole style. * * \see InternalStyle */ class MPSStyle : public InternalStyle { Q_OBJECT public: explicit MPSStyle(bool dark = true); void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const; void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; void drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const; void drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const; void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const; QStyle::SubControl hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget = nullptr) const; QRect itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const; QRect itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const; //virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget); int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const; void polish(QWidget *widget); void polish(QApplication *application); void polish(QPalette &palette); void unpolish(QWidget *widget); void unpolish(QApplication *application); QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const; QIcon standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; QPalette standardPalette() const; int styleHint(QStyle::StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const; QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget = nullptr) const; QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget = nullptr) const; }; #endif // MPSSTYLE_H qt5-ukui-platformtheme/libqt5-ukui-style/internal-styles/internal-styles.pri0000664000175000017500000000026513641116416026356 0ustar fengfengINCLUDEPATH += $$PWD INCLUDEPATH += $$PWD/.. SOURCES += $$PWD/internal-style.cpp \ $$PWD/mps-style.cpp HEADERS += $$PWD/internal-style.h \ $$PWD/mps-style.h qt5-ukui-platformtheme/libqt5-ukui-style/internal-styles/internal-style.h0000664000175000017500000000331213641116416025624 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef INTERNALSTYLE_H #define INTERNALSTYLE_H #include /*! * \brief The InternalStyle class * \details * This class is a interface type class. It is desgined as an extension of UKUI theme * frameworks. Applications which use internal style means that there will be no effect * when system theme switched, for example, from fusion to ukui-white. * But an internal style usually should response the palette settings changed for * keeping the unity as a desktop environment theme's extensions. * * The typical example which implement the internal style is MPSStyle. */ class InternalStyle : public QProxyStyle { Q_OBJECT public: explicit InternalStyle(QStyle *parentStyle = nullptr); explicit InternalStyle(const QString parentStyleName); signals: void useSystemStylePolicyChanged(bool use); public slots: virtual void setUseSystemStyle(bool use); }; #endif // INTERNALSTYLE_H qt5-ukui-platformtheme/libqt5-ukui-style/internal-styles/internal-style.cpp0000664000175000017500000000214013641116416026155 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "internal-style.h" InternalStyle::InternalStyle(QStyle *parentStyle) : QProxyStyle (parentStyle) { } InternalStyle::InternalStyle(const QString parentStyleName) : QProxyStyle(parentStyleName) { } void InternalStyle::setUseSystemStyle(bool use) { Q_EMIT useSystemStylePolicyChanged(use); } qt5-ukui-platformtheme/libqt5-ukui-style/libqt5-ukui-style.pro0000664000175000017500000000257113641116416023405 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2020-01-02T12:00:35 # #------------------------------------------------- QT += widgets concurrent TARGET = qt5-ukui-style TEMPLATE = lib DEFINES += LIBQT5UKUISTYLE_LIBRARY # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_NO_DEBUG_OUTPUT # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 include(libqt5-ukui-style.pri) CONFIG += c++11 link_pkgconfig PKGCONFIG += gsettings-qt DISTFILES += \ org.ukui.style.gschema.xml unix { target.path = $$[QT_INSTALL_LIBS] INSTALLS += target gschema.path = /usr/share/glib-2.0/schemas gschema.files += $$PWD/settings/org.ukui.style.gschema.xml INSTALLS += gschema pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig pkgconfig.files += development-files/qt5-ukui.pc INSTALLS += pkgconfig } qt5-ukui-platformtheme/libqt5-ukui-style/libqt5-ukui-style.pri0000664000175000017500000000035013641116416023370 0ustar fengfengINCLUDEPATH += $$PWD HEADERS += $$PWD/libqt5-ukui-style_global.h \ $$PWD/black-list.h include(animations/animations.pri) include(settings/settings.pri) include(internal-styles/internal-styles.pri) include(effects/effects.pri) qt5-ukui-platformtheme/libqt5-ukui-style/effects/0000775000175000017500000000000013643027460020766 5ustar fengfengqt5-ukui-platformtheme/libqt5-ukui-style/effects/highlight-effect.h0000664000175000017500000000454113641116416024342 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef HIGHLIGHTEFFECT_H #define HIGHLIGHTEFFECT_H #include #include class QAbstractItemView; class QAbstractButton; class QMenu; class HighLightEffect : public QObject { Q_OBJECT public: enum EffectMode { HighlightOnly, BothDefaultAndHighlit }; Q_ENUM(EffectMode) /*! * \brief setSkipEffect * \param w * \param skip * \details * in ukui-style, some widget such as menu will be set use highlight * icon effect automaticlly, * but we might not want to compose a special pure color image. * This function is use to skip the effect. */ static void setSkipEffect(QWidget *w, bool skip = true); static bool isPixmapPureColor(const QPixmap &pixmap); static bool setMenuIconHighlightEffect(QMenu *menu, bool set = true, EffectMode mode = HighlightOnly); static bool setViewItemIconHighlightEffect(QAbstractItemView *view, bool set = true, EffectMode mode = HighlightOnly); static bool setButtonIconHighlightEffect(QAbstractButton *button, bool set = true, EffectMode mode = HighlightOnly); static bool isWidgetIconUseHighlightEffect(const QWidget *w); static QPixmap generatePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget = nullptr, bool force = false, EffectMode mode = HighlightOnly); private: explicit HighLightEffect(QObject *parent = nullptr); }; #endif // HIGHLIGHTEFFECT_H qt5-ukui-platformtheme/libqt5-ukui-style/effects/effects.pri0000664000175000017500000000020513641116416023114 0ustar fengfengINCLUDEPATH += $$PWD INCLUDEPATH += $$PWD/.. HEADERS += \ $$PWD/highlight-effect.h SOURCES += \ $$PWD/highlight-effect.cpp qt5-ukui-platformtheme/libqt5-ukui-style/effects/highlight-effect.cpp0000664000175000017500000002010713643027460024673 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include "highlight-effect.h" #include #include #include #include #include #include #include #include #define TORLERANCE 32 void HighLightEffect::setSkipEffect(QWidget *w, bool skip) { w->setProperty("skipHighlightIconEffect", skip); } bool HighLightEffect::isPixmapPureColor(const QPixmap &pixmap) { QImage img = pixmap.toImage(); bool init = false; int red = 0; int green = 0; int blue = 0; bool isPure = true; bool isFullyPure = true; for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() != 0) { if (!init) { red = color.red(); green = color.green(); blue = color.blue(); init = true; } else { color.setAlpha(255); int r = color.red(); int g = color.green(); int b = color.blue(); int dr = qAbs(r - red); int dg = qAbs(g - green); int db = qAbs(b - blue); bool same = dr < TORLERANCE && dg < TORLERANCE && db < TORLERANCE; if (isFullyPure) { if (dr > 0 || dg > 0 || db > 0) { isFullyPure = false; } } if (!same) { return false; } } } } } return isPure; } bool HighLightEffect::setMenuIconHighlightEffect(QMenu *menu, bool set, HighLightEffect::EffectMode mode) { if (!menu) return false; menu->setProperty("useIconHighlightEffect", set); menu->setProperty("iconHighlightEffectMode", mode); return true; } bool HighLightEffect::setViewItemIconHighlightEffect(QAbstractItemView *view, bool set, HighLightEffect::EffectMode mode) { if (!view) return false; view->viewport()->setProperty("useIconHighlightEffect", set); view->viewport()->setProperty("iconHighlightEffectMode", mode); return true; } bool HighLightEffect::setButtonIconHighlightEffect(QAbstractButton *button, bool set, EffectMode mode) { if (!button) return false; button->setProperty("useIconHighlightEffect", set); button->setProperty("iconHighlightEffectMode", mode); return true; } bool HighLightEffect::isWidgetIconUseHighlightEffect(const QWidget *w) { if (w) { return w->property("useIconHighlightEffect").toBool(); } return false; } QPixmap HighLightEffect::generatePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget, bool force, EffectMode mode) { if (pixmap.isNull()) return pixmap; if (widget) { if (widget->property("skipHighlightIconEffect").isValid()) { bool skipEffect = widget->property("skipHighlightIconEffect").toBool(); if (skipEffect) return pixmap; } } if (force) { if (!isPixmapPureColor(pixmap)) return pixmap; QPixmap target = pixmap; QPainter p(&target); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setCompositionMode(QPainter::CompositionMode_SourceIn); if (option->state & QStyle::State_MouseOver || option->state & QStyle::State_Selected || option->state & QStyle::State_On || option->state & QStyle::State_Sunken) { p.fillRect(target.rect(), option->palette.highlightedText()); } else { if (mode == BothDefaultAndHighlit) p.fillRect(target.rect(), option->palette.shadow()); } //p.end(); return target; } if (!isPixmapPureColor(pixmap)) return pixmap; if (widget) { if (isWidgetIconUseHighlightEffect(widget)) { if (widget->property("iconHighlightEffectMode").isValid()) { mode = qvariant_cast(widget->property("iconHighlightEffectMode")); } bool isEnable = option->state.testFlag(QStyle::State_Enabled); bool overOrDown = option->state.testFlag(QStyle::State_MouseOver) || option->state.testFlag(QStyle::State_Sunken) || option->state.testFlag(QStyle::State_On) || option->state.testFlag(QStyle::State_Selected); if (auto button = qobject_cast(widget)) { if (button->isDown() || button->isChecked()) { overOrDown = true; } } if (qobject_cast(widget)) { if (!option->state.testFlag(QStyle::State_Selected)) overOrDown = false; } if (isEnable && overOrDown) { QPixmap target = pixmap; QPainter p(&target); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(target.rect(), option->palette.highlightedText()); //p.end(); return target; } else { if (mode == BothDefaultAndHighlit) { QPixmap target = pixmap; QPainter p(&target); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(target.rect(), option->palette.shadow()); //p.end(); return target; } } } } else { bool isEnable = option->state.testFlag(QStyle::State_Enabled); bool overOrDown = option->state.testFlag(QStyle::State_MouseOver) || option->state.testFlag(QStyle::State_Sunken) || option->state.testFlag(QStyle::State_Selected) || option->state.testFlag(QStyle::State_On); if (isEnable && overOrDown) { QPixmap target = pixmap; QPainter p(&target); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(target.rect(), option->palette.highlightedText()); //p.end(); return target; } else { if (mode == BothDefaultAndHighlit) { QPixmap target = pixmap; QPainter p(&target); p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(target.rect(), option->palette.shadow()); //p.end(); return target; } } } return pixmap; } HighLightEffect::HighLightEffect(QObject *parent) : QObject(parent) { } qt5-ukui-platformtheme/README.md0000664000175000017500000000315413641116416015316 0ustar fengfeng# qt5-ukui-platformtheme The UKUI platform theme for qt5 QPA. ## Document See [doxygen/README.md](doxygen/README.md). ## Description In the early development of the UKUI 3.0, we used qt5-gtk2-platformtheme to ensure the unity of the UKUI desktop style. However, it has many limitations for our new desgin. This project is intend to provide a common resolution of desktop application development with qt5 in UKUI3.0. We hope provide a platform theme to unify and beautify all qt applications according to the design of UKUI3.0, not only our own applications. We are also committed to building our applications that can adapt to different styles. This project is first step to archive those objectives. qt5-ukui-platformtheme's route brings us closer to the upstream communities. It is not a division, but a desire for fusion and individuality in a compatible way. ## Build and Test ### Build Depends (reference debian/contorl) - pkg-config - qt5-default - qtbase5-private-dev - libkf5windowsystem-dev - libgsettings-qt-dev - libglib2.0-dev ### Testing To test the project, you should first install it into system and make sure that the current qpa platform is ukui. You can export the QT_QPA_PLATFORMTHEME in terminal. > export QT_QPA_PLATFORMTHEME=ukui One more important job, > sudo glib-compile-schemas /usr/share/glib-2.0/schemas That will let the gsettings used by qt5-ukui-platformtheme worked. Then you can run the test in project, or run any qt5 program for testing with ukui platformtheme. ### ToDoList - menu blur - custom palette - style switch/management - Change style's details through configuration file - animations qt5-ukui-platformtheme/qt5-ukui-platformtheme/0000775000175000017500000000000013643026433020366 5ustar fengfengqt5-ukui-platformtheme/qt5-ukui-platformtheme/main.cpp0000664000175000017500000000267313641116416022025 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include #include "qt5-ukui-platform-theme.h" #include #define UKUI_PLATFORMTHEME QT_BEGIN_NAMESPACE class Qt5UKUIPlatformThemePlugin : public QPlatformThemePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "ukui.json") public: virtual QPlatformTheme *create(const QString &key, const QStringList ¶ms) { qDebug()<<"platform ukui"<. * * Authors: Yue Lan * */ #ifndef QT5UKUIPLATFORMTHEME_H #define QT5UKUIPLATFORMTHEME_H #include "qt5-ukui-platformtheme_global.h" #include #include #include #if !defined(QT_NO_DBUS) && defined(QT_DBUS_LIB) #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) && !defined(QT_NO_SYSTEMTRAYICON) #define DBUS_TRAY #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)) #define GLOBAL_MENU #endif #endif class QPalette; #ifdef DBUS_TRAY class QPlatformSystemTrayIcon; #endif #ifdef GLOBAL_MENU class QPlatformMenuBar; #endif /*! * \brief The Qt5UKUIPlatformTheme class * \details * In UKUI desktop environment, we have our own platform to manage the qt applications' style. * This class is used to take over the theme and preferences of those applications. * The platform theme will effect globally. */ class QT5UKUIPLATFORMTHEMESHARED_EXPORT Qt5UKUIPlatformTheme : public QObject, public QPlatformTheme { Q_OBJECT public: Qt5UKUIPlatformTheme(const QStringList &args); ~Qt5UKUIPlatformTheme(); virtual const QPalette *palette(Palette type = SystemPalette) const; virtual const QFont *font(Font type = SystemFont) const; virtual QVariant themeHint(ThemeHint hint) const; #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) virtual bool usePlatformNativeDialog(DialogType type) const; virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) virtual QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = 0) const; #endif #ifdef GLOBAL_MENU virtual QPlatformMenuBar* createPlatformMenuBar() const; #endif #ifdef DBUS_TRAY virtual QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const; #endif private: QFont m_system_font; QFont m_fixed_font; }; #endif // QT5UKUIPLATFORMTHEME_H qt5-ukui-platformtheme/qt5-ukui-platformtheme/qt5-ukui-platformtheme.pro0000664000175000017500000000250313641116416025440 0ustar fengfeng#------------------------------------------------- # # Project created by QtCreator 2019-12-31T14:19:01 # #------------------------------------------------- QT += widgets dbus gui-private TARGET = qt5-ukui-platformtheme TEMPLATE = lib CONFIG += plugin CONFIG += c++11 link_pkgconfig PKGCONFIG += gsettings-qt include(../libqt5-ukui-style/libqt5-ukui-style.pri) DEFINES += QT5UKUIPLATFORMTHEME_LIBRARY # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_NO_DEBUG_OUTPUT # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ qt5-ukui-platform-theme.cpp \ main.cpp HEADERS += \ qt5-ukui-platform-theme.h \ qt5-ukui-platformtheme_global.h unix { target.path = $$[QT_INSTALL_PLUGINS]/platformthemes INSTALLS += target } DISTFILES += \ ukui.json qt5-ukui-platformtheme/qt5-ukui-platformtheme/ukui.json0000664000175000017500000000003313641116416022231 0ustar fengfeng{ "Keys": [ "ukui" ] } qt5-ukui-platformtheme/qt5-ukui-platformtheme/qt5-ukui-platformtheme_global.h0000664000175000017500000000215313641116416026410 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #ifndef QT5UKUIPLATFORMTHEME_GLOBAL_H #define QT5UKUIPLATFORMTHEME_GLOBAL_H #include #if defined(QT5UKUIPLATFORMTHEME_LIBRARY) # define QT5UKUIPLATFORMTHEMESHARED_EXPORT Q_DECL_EXPORT #else # define QT5UKUIPLATFORMTHEMESHARED_EXPORT Q_DECL_IMPORT #endif #endif // QT5UKUIPLATFORMTHEME_GLOBAL_H qt5-ukui-platformtheme/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp0000664000175000017500000001362613641116416025507 0ustar fengfeng/* * Qt5-UKUI's Library * * Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Yue Lan * */ #include #include #include "qt5-ukui-platform-theme.h" #include "ukui-style-settings.h" #include #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #include #include #endif #include #include #include Qt5UKUIPlatformTheme::Qt5UKUIPlatformTheme(const QStringList &args) { //FIXME: Q_UNUSED(args) if (QGSettings::isSchemaInstalled("org.ukui.style")) { auto settings = UKUIStyleSettings::globalInstance(); //set font auto fontName = settings->get("systemFont").toString(); auto fontSize = settings->get("systemFontSize").toInt(); m_system_font.setFamily(fontName); m_system_font.setPointSize(fontSize); m_fixed_font.setFamily(fontName); m_fixed_font.setPointSize(fontSize*1.2); /*! * \bug * if we set app font, qwizard title's font will * become very small. I handle the wizard title * in ProxyStyle::polish(). */ QApplication::setFont(m_system_font); //QIcon::setThemeName(settings->get("icon-theme-name").toString()); connect(settings, &QGSettings::changed, this, [=](const QString &key){ qDebug()<get("icon-theme-name").toString()); // update all widgets for repaint new themed icons. for (auto widget : QApplication::allWidgets()) { widget->update(); } } if (key == "systemFont") { QString font = settings->get("system-font").toString(); QFontDatabase db; if (db.families().contains(font)) { QFont oldFont = QApplication::font(); m_system_font.setFamily(font); m_fixed_font.setFamily(font); oldFont.setFamily(font); QApplication::setFont(oldFont); for (auto w : QApplication::allWidgets()) { w->setFont(font); } } } if (key == "systemFontSize") { int fontSize = settings->get("system-font-size").toInt(); QFontDatabase db; if (fontSize > 0) { QFont oldFont = QApplication::font(); m_system_font.setPointSize(fontSize); m_fixed_font.setPointSize(fontSize*1.2); oldFont.setPointSize(fontSize); QApplication::setFont(oldFont); for (auto w : QApplication::allWidgets()) { w->setFont(m_system_font); } } } }); } } Qt5UKUIPlatformTheme::~Qt5UKUIPlatformTheme() { } const QPalette *Qt5UKUIPlatformTheme::palette(Palette type) const { //FIXME: return QPlatformTheme::palette(type); } const QFont *Qt5UKUIPlatformTheme::font(Font type) const { //FIXME: if (type == FixedFont) return &m_fixed_font; return &m_system_font; switch (type) { case SystemFont: return &m_system_font; case TitleBarFont: case FixedFont: case GroupBoxTitleFont: return &m_fixed_font; default: return &m_system_font; } return QPlatformTheme::font(type); } QVariant Qt5UKUIPlatformTheme::themeHint(ThemeHint hint) const { //FIXME: //qDebug()<<"theme hint"<get("icon-theme-name"); } return "hicolor"; } case QPlatformTheme::SystemIconFallbackThemeName: return "ukui-icon-theme-default"; case QPlatformTheme::IconThemeSearchPaths: //FIXME: return QStringList()<<"/usr/share/icons"; default: break; } return QPlatformTheme::themeHint(hint); } #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) bool Qt5UKUIPlatformTheme::usePlatformNativeDialog(DialogType type) const { //FIXME: return false; } QPlatformDialogHelper *Qt5UKUIPlatformTheme::createPlatformDialogHelper(DialogType type) const { return QPlatformTheme::createPlatformDialogHelper(type); } #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QIcon Qt5UKUIPlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const { //FIXME: return QPlatformTheme::fileIcon(fileInfo, iconOptions); } #endif #ifdef GLOBAL_MENU QPlatformMenuBar *Qt5UKUIPlatformTheme::createPlatformMenuBar() const { return QPlatformTheme::createPlatformMenuBar(); } #endif #ifdef DBUS_TRAY QPlatformSystemTrayIcon *Qt5UKUIPlatformTheme::createPlatformSystemTrayIcon() const { return QPlatformTheme::createPlatformSystemTrayIcon(); } #endif qt5-ukui-platformtheme/doxygen/0000775000175000017500000000000013641116416015511 5ustar fengfengqt5-ukui-platformtheme/doxygen/Doxyfile.in0000664000175000017500000032407313641116416017635 0ustar fengfeng# Doxyfile 1.8.13 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv # built into libc) for the transcoding. See http://www.gnu.org/software/libiconv # for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = "Qt5 UKUI" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = out # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = YES # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = YES # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = YES # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = YES # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, Javascript, # C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: # FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: # Fortran. In the later case the parser tries to guess whether the code is fixed # or free formatted code, this is the default for Fortran type files), VHDL. For # instance to make doxygen treat .inc files as Fortran files (default is PHP), # and .f files as C (default is Fortran), use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. # Minimum value: 0, maximum value: 99, default value: 0. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 0 # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # (class|struct|union) declarations. If set to NO, these declarations will be # included in the documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. # The default value is: NO. WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. # The default value is: NO. WARN_AS_ERROR = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = ../ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.idl \ *.ddl \ *.odl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.cs \ *.d \ *.php \ *.php4 \ *.php5 \ *.phtml \ *.inc \ *.m \ *.markdown \ *.md \ *.mm \ *.dox \ *.py \ *.pyw \ *.f90 \ *.f95 \ *.f03 \ *.f08 \ *.f \ *.for \ *.tcl \ *.vhd \ *.vhdl \ *.ucf \ *.qsf # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = ../test # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # function all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see http://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the config file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse-libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # http://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: http://developer.apple.com/tools/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # http://www.mathjax.org) which uses client side Javascript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from http://www.mathjax.org before deployment. # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /