From b7385374527f32f3f5ee51539008e15e08d58d5f Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 7 Jul 2015 11:45:57 +0200 Subject: [PATCH] + add QSint scheme for FreeCAD --- src/Gui/CMakeLists.txt | 2 + src/Gui/QSint/actionpanel/freecadscheme.cpp | 202 ++++++++++++++++++++ src/Gui/QSint/actionpanel/freecadscheme.h | 56 ++++++ 3 files changed, 260 insertions(+) create mode 100644 src/Gui/QSint/actionpanel/freecadscheme.cpp create mode 100644 src/Gui/QSint/actionpanel/freecadscheme.h diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 8daaec790..9d80a312b 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -688,6 +688,8 @@ SET(qsintActionPanel_SRCS QSint/actionpanel/winvistapanelscheme.h QSint/actionpanel/winxppanelscheme.cpp QSint/actionpanel/winxppanelscheme.h + QSint/actionpanel/freecadscheme.cpp + QSint/actionpanel/freecadscheme.h ) SOURCE_GROUP("Widget\\QSintActionPanel" FILES ${qsintActionPanel_SRCS}) set(qsint_MOC_HDRS diff --git a/src/Gui/QSint/actionpanel/freecadscheme.cpp b/src/Gui/QSint/actionpanel/freecadscheme.cpp new file mode 100644 index 000000000..d39d9d0a5 --- /dev/null +++ b/src/Gui/QSint/actionpanel/freecadscheme.cpp @@ -0,0 +1,202 @@ +/*************************************************************************** + * Copyright (c) 2015 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "freecadscheme.h" +#include "macpanelscheme.h" +#include "winxppanelscheme.h" +#include "winvistapanelscheme.h" +#include +#include +#include + + +namespace QSint +{ + + +const char* ActionPaneFreeCAD = + + "QFrame[class='panel'] {" + "background-color:qlineargradient(x1:1, y1:0.3, x2:1, y2:0, stop:0 rgb(51,51,101), stop:1 rgb(171,171,193));" + "}" + + "QSint--ActionGroup QFrame[class='header'] {" + "border: 1px solid #ffffff;" + "border-top-left-radius: 4px;" + "border-top-right-radius: 4px;" + "background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffffff, stop: 1 #c6d3f7);" + "}" + + "QSint--ActionGroup QToolButton[class='header'] {" + "text-align: left;" + "color: #215dc6;" + "background-color: transparent;" + "border: 1px solid transparent;" + "font-weight: bold;" + "}" + + "QSint--ActionGroup QToolButton[class='header']:hover {" + "color: #428eff;" + "}" + + "QSint--ActionGroup QFrame[class='content'] {" + "background-color: #d6dff7;" + "border: 1px solid #ffffff;" + "}" + + "QSint--ActionGroup QFrame[class='content'][header='true'] {" + "border-top: none;" + "}" + + "QSint--ActionGroup QToolButton[class='action'] {" + "background-color: transparent;" + "border: 1px solid transparent;" + "color: #215dc6;" + "text-align: left;" + "}" + + "QSint--ActionGroup QToolButton[class='action']:!enabled {" + "color: #999999;" + "}" + + "QSint--ActionGroup QToolButton[class='action']:hover {" + "color: #428eff;" + "}" + + "QSint--ActionGroup QToolButton[class='action']:focus {" + "border: 1px dotted black;" + "}" + + "QSint--ActionGroup QToolButton[class='action']:on {" + "background-color: #ddeeff;" + "color: #006600;" + "}" + ; + +FreeCADPanelScheme::FreeCADPanelScheme() : ActionPanelScheme() +{ +#if defined(Q_OS_WIN32) + ActionPanelScheme* panelStyle = WinXPPanelScheme2::defaultScheme(); + + actionStyle = QString(ActionPaneFreeCAD); +#elif defined(Q_OS_MAC) + ActionPanelScheme* panelStyle = MacPanelScheme::defaultScheme(); + + actionStyle = panelStyle->actionStyle; +#else + ActionPanelScheme* panelStyle = ActionPanelScheme::defaultScheme(); + + actionStyle = panelStyle->actionStyle; +#endif + + builtinScheme = actionStyle; + + headerSize = panelStyle->headerSize; + headerAnimation = panelStyle->headerAnimation; + headerButtonFold = panelStyle->headerButtonFold; + headerButtonFoldOver = panelStyle->headerButtonFoldOver; + headerButtonUnfold = panelStyle->headerButtonUnfold; + headerButtonUnfoldOver = panelStyle->headerButtonUnfoldOver; + headerButtonSize = panelStyle->headerButtonSize; + + groupFoldSteps = panelStyle->groupFoldSteps; + groupFoldDelay = panelStyle->groupFoldDelay; + groupFoldEffect = panelStyle->groupFoldEffect; + groupFoldThaw = panelStyle->groupFoldThaw; +} + +void FreeCADPanelScheme::clearActionStyle() +{ + actionStyle.clear(); +} + +void FreeCADPanelScheme::restoreActionStyle() +{ + actionStyle = builtinScheme; +} + +QPixmap FreeCADPanelScheme::drawFoldIcon(const QPalette& p) const +{ + QImage img(17,17,QImage::Format_ARGB32_Premultiplied); + img.fill(0x00000000); + QPainter painter; + painter.begin(&img); + painter.setBrush(p.window()); + painter.drawEllipse(2,2,13,13); + painter.setPen(p.color(QPalette::Base)); + painter.drawEllipse(2,2,13,13); + painter.setPen(p.color(QPalette::Highlight)); + painter.drawLine(QLine(5,7,8,4)); + painter.drawLine(QLine(6,7,8,5)); + painter.drawLine(QLine(8,4,11,7)); + painter.drawLine(QLine(8,5,10,7)); + painter.drawLine(QLine(5,11,8,8)); + painter.drawLine(QLine(6,11,8,9)); + painter.drawLine(QLine(8,8,11,11)); + painter.drawLine(QLine(9,8,10,11)); + painter.end(); + return QPixmap::fromImage(img); +} + +} +#if 0 +iisFreeCADTaskPanelScheme::iisFreeCADTaskPanelScheme(QObject *parent) + : iisTaskPanelScheme(parent) +{ +#ifdef Q_OS_WIN32 +#else + QPalette p = QApplication::palette(); + QLinearGradient panelBackgroundGrd(0,0, 0,300); + panelBackgroundGrd.setColorAt(1, p.color(QPalette::Dark)); + panelBackgroundGrd.setColorAt(0, p.color(QPalette::Midlight)); + panelBackground = panelBackgroundGrd; + + QLinearGradient headerBackgroundGrd(0,0,0,100); + headerBackgroundGrd.setColorAt(0, p.color(QPalette::Highlight)); + headerBackgroundGrd.setColorAt(1, p.color(QPalette::Highlight).lighter()); + headerBackground = headerBackgroundGrd; + + headerLabelScheme.text = p.color(QPalette::HighlightedText); + headerLabelScheme.textOver = p.color(QPalette::BrightText); + headerLabelScheme.iconSize = 22; + + headerButtonSize = QSize(17,17); + QPalette p2 = p; + p2.setColor(QPalette::Highlight,p2.color(QPalette::Highlight).lighter()); + QPixmap px1 = drawFoldIcon(p); + QPixmap px2 = drawFoldIcon(p2); + headerButtonFold = px1; + headerButtonFoldOver = px2; + QTransform mat; + mat.rotate(180.0); + headerButtonUnfold = px1.transformed(mat); + headerButtonUnfoldOver = px2.transformed(mat); + + groupBackground = p.window(); + groupBorder = p.color(QPalette::Window); + + taskLabelScheme.text = p.color(QPalette::Text); + taskLabelScheme.textOver = p.color(QPalette::Highlight); +#endif +} +#endif diff --git a/src/Gui/QSint/actionpanel/freecadscheme.h b/src/Gui/QSint/actionpanel/freecadscheme.h new file mode 100644 index 000000000..dc0ba4fe8 --- /dev/null +++ b/src/Gui/QSint/actionpanel/freecadscheme.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (c) 2015 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef FREECADTASKPANELSCHEME_H +#define FREECADTASKPANELSCHEME_H + +#include "actionpanelscheme.h" + + +namespace QSint +{ + + +class QSINT_EXPORT FreeCADPanelScheme : public ActionPanelScheme +{ +public: + explicit FreeCADPanelScheme(); + + static ActionPanelScheme* defaultScheme() + { + static FreeCADPanelScheme scheme; + return &scheme; + } + + void clearActionStyle(); + void restoreActionStyle(); + +private: + QPixmap drawFoldIcon(const QPalette& p) const; + QString builtinScheme; +}; + + +} + +#endif // IISFREECADTASKPANELSCHEME_H