From 5b3d50afc4372e918022ced3ff3adc46854cbd80 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 8 Jul 2015 15:17:49 +0200 Subject: [PATCH] + use icon of style sheet for task header + fix size issue with task panel + enable QSint task panel --- src/Gui/Application.cpp | 6 ++ src/Gui/QSint/actionpanel/freecadscheme.cpp | 80 ++++++++++----------- src/Gui/QSint/actionpanel/freecadscheme.h | 6 +- src/Gui/TaskView/TaskView.cpp | 3 +- src/Gui/TaskView/TaskView.h | 2 +- 5 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 49f58e869..517fa97f9 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -85,6 +85,8 @@ #include "View3DPy.h" #include "DlgOnlineHelpImp.h" #include "SpaceballEvent.h" +#include "Control.h" +#include "TaskView/TaskView.h" #include "SplitView3DInventor.h" #include "View3DInventor.h" @@ -1792,6 +1794,10 @@ void Application::runApplication(void) mdi->setBackground(QBrush(Qt::NoBrush)); QTextStream str(&f); qApp->setStyleSheet(str.readAll()); + + Gui::TaskView::TaskView* taskPanel = Control().taskPanel(); + if (taskPanel) + taskPanel->clearActionStyle(); } } diff --git a/src/Gui/QSint/actionpanel/freecadscheme.cpp b/src/Gui/QSint/actionpanel/freecadscheme.cpp index d39d9d0a5..25a6722a1 100644 --- a/src/Gui/QSint/actionpanel/freecadscheme.cpp +++ b/src/Gui/QSint/actionpanel/freecadscheme.cpp @@ -34,7 +34,7 @@ namespace QSint { -const char* ActionPaneFreeCAD = +const char* ActionPanelFreeCAD = "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));" @@ -98,7 +98,7 @@ FreeCADPanelScheme::FreeCADPanelScheme() : ActionPanelScheme() #if defined(Q_OS_WIN32) ActionPanelScheme* panelStyle = WinXPPanelScheme2::defaultScheme(); - actionStyle = QString(ActionPaneFreeCAD); + actionStyle = QString(ActionPanelFreeCAD); #elif defined(Q_OS_MAC) ActionPanelScheme* panelStyle = MacPanelScheme::defaultScheme(); @@ -123,19 +123,46 @@ FreeCADPanelScheme::FreeCADPanelScheme() : ActionPanelScheme() groupFoldDelay = panelStyle->groupFoldDelay; groupFoldEffect = panelStyle->groupFoldEffect; groupFoldThaw = panelStyle->groupFoldThaw; + + + builtinFold = headerButtonFold; + builtinFoldOver = headerButtonFoldOver; + builtinUnfold = headerButtonUnfold; + builtinUnfoldOver = headerButtonUnfoldOver; } void FreeCADPanelScheme::clearActionStyle() { + headerButtonFold = QPixmap(); + headerButtonFoldOver = QPixmap(); + headerButtonUnfold = QPixmap(); + headerButtonUnfoldOver = QPixmap(); + actionStyle.clear(); } void FreeCADPanelScheme::restoreActionStyle() { + headerButtonFold = builtinFold; + headerButtonFoldOver = builtinFoldOver; + headerButtonUnfold = builtinUnfold; + headerButtonUnfoldOver = builtinUnfoldOver; + actionStyle = builtinScheme; } -QPixmap FreeCADPanelScheme::drawFoldIcon(const QPalette& p) const +/*! + \code + QPalette p = QApplication::palette(); + QPalette p2 = p; + p2.setColor(QPalette::Highlight,p2.color(QPalette::Highlight).lighter()); + headerButtonFold = drawFoldIcon(p, true); + headerButtonFoldOver = drawFoldIcon(p2, true); + headerButtonUnfold = drawFoldIcon(p, false); + headerButtonUnfoldOver = drawFoldIcon(p2, false); + \endcode + */ +QPixmap FreeCADPanelScheme::drawFoldIcon(const QPalette& p, bool fold) const { QImage img(17,17,QImage::Format_ARGB32_Premultiplied); img.fill(0x00000000); @@ -155,48 +182,13 @@ QPixmap FreeCADPanelScheme::drawFoldIcon(const QPalette& p) const painter.drawLine(QLine(8,8,11,11)); painter.drawLine(QLine(9,8,10,11)); painter.end(); + + if (!fold) { + QTransform mat; + mat.rotate(180.0); + img = img.transformed(mat); + } 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 index dc0ba4fe8..0df9275f1 100644 --- a/src/Gui/QSint/actionpanel/freecadscheme.h +++ b/src/Gui/QSint/actionpanel/freecadscheme.h @@ -46,8 +46,12 @@ public: void restoreActionStyle(); private: - QPixmap drawFoldIcon(const QPalette& p) const; + QPixmap drawFoldIcon(const QPalette& p, bool fold) const; QString builtinScheme; + QPixmap builtinFold; + QPixmap builtinFoldOver; + QPixmap builtinUnfold; + QPixmap builtinUnfoldOver; }; diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index da7048019..a914e8990 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -26,6 +26,7 @@ #ifndef _PreComp_ # include # include +# include # include # include #endif @@ -321,7 +322,7 @@ TaskView::TaskView(QWidget *parent) taskPanel->setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); #else taskPanel = new QSint::ActionPanel(this); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(taskPanel->sizePolicy().hasHeightForWidth()); diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index dbc5fe4d6..d7355366e 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -24,7 +24,7 @@ #ifndef GUI_TASKVIEW_TASKVIEW_H #define GUI_TASKVIEW_TASKVIEW_H -//#define QSINT_ACTIONPANEL +#define QSINT_ACTIONPANEL #include #include