refactor: qsint style should be minimum plus mods
This commit is contained in:
@@ -28,12 +28,10 @@
|
||||
#include <QPalette>
|
||||
#include <QHash>
|
||||
|
||||
|
||||
namespace QSint
|
||||
{
|
||||
|
||||
const char* MinimumActionPanelFreeCAD =
|
||||
|
||||
const QString SystemPanelScheme::minimumStyle = QString::fromLatin1(
|
||||
"QSint--ActionGroup QToolButton[class='header'] {"
|
||||
"text-align: left;"
|
||||
"background-color: transparent;"
|
||||
@@ -50,16 +48,15 @@ const char* MinimumActionPanelFreeCAD =
|
||||
"QSint--ActionGroup QToolButton[class='action']:hover {"
|
||||
"text-decoration: underline;"
|
||||
"}"
|
||||
;
|
||||
);
|
||||
|
||||
FreeCADPanelScheme::FreeCADPanelScheme() : ActionPanelScheme()
|
||||
FreeCADPanelScheme::FreeCADPanelScheme()
|
||||
: ActionPanelScheme()
|
||||
{
|
||||
ActionPanelScheme* panelStyle = SystemPanelScheme::defaultScheme();
|
||||
|
||||
actionStyle = panelStyle->actionStyle;
|
||||
|
||||
builtinScheme = actionStyle;
|
||||
minimumStyle = QString(MinimumActionPanelFreeCAD);
|
||||
|
||||
headerSize = panelStyle->headerSize;
|
||||
headerAnimation = panelStyle->headerAnimation;
|
||||
@@ -74,7 +71,6 @@ FreeCADPanelScheme::FreeCADPanelScheme() : ActionPanelScheme()
|
||||
groupFoldEffect = panelStyle->groupFoldEffect;
|
||||
groupFoldThaw = panelStyle->groupFoldThaw;
|
||||
|
||||
|
||||
builtinFold = headerButtonFold;
|
||||
builtinFoldOver = headerButtonFoldOver;
|
||||
builtinUnfold = headerButtonUnfold;
|
||||
@@ -88,7 +84,7 @@ void FreeCADPanelScheme::clearActionStyle()
|
||||
headerButtonUnfold = QPixmap();
|
||||
headerButtonUnfoldOver = QPixmap();
|
||||
|
||||
actionStyle = minimumStyle;
|
||||
actionStyle = SystemPanelScheme::minimumStyle;
|
||||
}
|
||||
|
||||
void FreeCADPanelScheme::restoreActionStyle()
|
||||
@@ -101,8 +97,6 @@ void FreeCADPanelScheme::restoreActionStyle()
|
||||
actionStyle = builtinScheme;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
||||
SystemPanelScheme::SystemPanelScheme()
|
||||
{
|
||||
headerSize = 25;
|
||||
@@ -114,16 +108,17 @@ SystemPanelScheme::SystemPanelScheme()
|
||||
headerButtonFoldOver = drawFoldIcon(p, true, true);
|
||||
headerButtonUnfold = drawFoldIcon(p, false, false);
|
||||
headerButtonUnfoldOver = drawFoldIcon(p, false, true);
|
||||
headerButtonSize = QSize(17,17);
|
||||
headerButtonSize = QSize(17, 17);
|
||||
|
||||
groupFoldSteps = 20;
|
||||
groupFoldDelay = 15;
|
||||
groupFoldEffect = NoFolding;
|
||||
groupFoldThaw = true;
|
||||
|
||||
actionStyle = systemStyle(QApplication::palette());
|
||||
actionStyle = systemStyle(p);
|
||||
}
|
||||
|
||||
// Draws fold/unfold icons based on the palette
|
||||
QPixmap SystemPanelScheme::drawFoldIcon(const QPalette& palette, bool fold, bool hover) const
|
||||
{
|
||||
QSize bSize = headerButtonSize;
|
||||
@@ -131,7 +126,6 @@ QPixmap SystemPanelScheme::drawFoldIcon(const QPalette& palette, bool fold, bool
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&img);
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
qreal penWidth = bSize.width() / 14.0;
|
||||
@@ -150,23 +144,21 @@ QPixmap SystemPanelScheme::drawFoldIcon(const QPalette& palette, bool fold, bool
|
||||
|
||||
QPolygon chevron;
|
||||
if (fold) {
|
||||
// Upward
|
||||
// Upward chevron
|
||||
chevron << QPoint(lef_X, top_Y)
|
||||
<< QPoint(mid_X, bot_Y)
|
||||
<< QPoint(rig_X, top_Y);
|
||||
} else {
|
||||
// Downward
|
||||
// Downward chevron
|
||||
chevron << QPoint(lef_X, bot_Y)
|
||||
<< QPoint(mid_X, top_Y)
|
||||
<< QPoint(rig_X, bot_Y);
|
||||
}
|
||||
|
||||
painter.drawPolyline(chevron);
|
||||
painter.end();
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
|
||||
QString SystemPanelScheme::systemStyle(const QPalette& p) const
|
||||
{
|
||||
QHash<QString, QString> replacements;
|
||||
@@ -191,22 +183,20 @@ QString SystemPanelScheme::systemStyle(const QPalette& p) const
|
||||
replacements.insert(QStringLiteral("groupBackground"),
|
||||
p.color(QPalette::Button).name());
|
||||
|
||||
QString style = QStringLiteral(
|
||||
QString style = minimumStyle;
|
||||
|
||||
style += QStringLiteral(
|
||||
"QFrame[class='panel'] {"
|
||||
"background-color: {panelBackground};"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QFrame[class='header'] {"
|
||||
"border: 1px solid transparent;"
|
||||
"border: 1px solid {headerBackground};"
|
||||
"background-color: {headerBackground};"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QToolButton[class='header'] {"
|
||||
"text-align: left;"
|
||||
"color: {headerLabelText};"
|
||||
"background-color: transparent;"
|
||||
"border: 1px solid transparent;"
|
||||
"font-weight: bold;"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QToolButton[class='header']:hover {"
|
||||
@@ -222,20 +212,10 @@ QString SystemPanelScheme::systemStyle(const QPalette& p) const
|
||||
"border-top: none;"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QToolButton[class='action'] {"
|
||||
"background-color: transparent;"
|
||||
"border: 1px solid transparent;"
|
||||
"text-align: left;"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QToolButton[class='action']:!enabled {"
|
||||
"color: {disabledActionText};"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QToolButton[class='action']:hover {"
|
||||
"text-decoration: underline;"
|
||||
"}"
|
||||
|
||||
"QSint--ActionGroup QToolButton[class='action']:focus {"
|
||||
"color: {actionSelectedText};"
|
||||
"border: 1px dotted {actionSelectedBorder};"
|
||||
@@ -254,4 +234,4 @@ QString SystemPanelScheme::systemStyle(const QPalette& p) const
|
||||
return style;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace QSint
|
||||
|
||||
@@ -20,56 +20,98 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FREECADTASKPANELSCHEME_H
|
||||
#define FREECADTASKPANELSCHEME_H
|
||||
|
||||
#include "actionpanelscheme.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
#include <QPalette>
|
||||
|
||||
namespace QSint
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @class FreeCADPanelScheme
|
||||
* @brief A specialized panel scheme for FreeCAD task panels.
|
||||
*/
|
||||
class QSINT_EXPORT FreeCADPanelScheme : public ActionPanelScheme
|
||||
{
|
||||
public:
|
||||
explicit FreeCADPanelScheme();
|
||||
|
||||
/**
|
||||
* @brief Provides the default scheme for FreeCAD panels.
|
||||
* @return A pointer to the default FreeCADPanelScheme instance.
|
||||
*/
|
||||
static ActionPanelScheme* defaultScheme()
|
||||
{
|
||||
static FreeCADPanelScheme scheme;
|
||||
return &scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clears the custom action style, resetting to a minimal style.
|
||||
*/
|
||||
void clearActionStyle();
|
||||
|
||||
/**
|
||||
* @brief Restores the original action style.
|
||||
*/
|
||||
void restoreActionStyle();
|
||||
|
||||
private:
|
||||
QString builtinScheme;
|
||||
QString minimumStyle;
|
||||
QPixmap builtinFold;
|
||||
QPixmap builtinFoldOver;
|
||||
QPixmap builtinUnfold;
|
||||
QPixmap builtinUnfoldOver;
|
||||
QString builtinScheme; ///< Backup of the original scheme style.
|
||||
QPixmap builtinFold; ///< Backup of the default fold icon.
|
||||
QPixmap builtinFoldOver; ///< Backup of the default hover fold icon.
|
||||
QPixmap builtinUnfold; ///< Backup of the default unfold icon.
|
||||
QPixmap builtinUnfoldOver; ///< Backup of the default hover unfold icon.
|
||||
};
|
||||
|
||||
/**
|
||||
* @class SystemPanelScheme
|
||||
* @brief A system-wide default panel scheme for action panels.
|
||||
*/
|
||||
class QSINT_EXPORT SystemPanelScheme : public ActionPanelScheme
|
||||
{
|
||||
public:
|
||||
explicit SystemPanelScheme();
|
||||
|
||||
/**
|
||||
* @brief Provides the default system panel scheme.
|
||||
* @return A pointer to the default SystemPanelScheme instance.
|
||||
*/
|
||||
static ActionPanelScheme* defaultScheme()
|
||||
{
|
||||
static SystemPanelScheme scheme;
|
||||
return &scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The minimal style definition shared across schemes.
|
||||
*/
|
||||
static const QString minimumStyle;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Draws a fold/unfold icon based on the palette.
|
||||
* @param p The palette to use for coloring the icon.
|
||||
* @param fold True for fold icon, false for unfold icon.
|
||||
* @param hover True for hover effect, false otherwise.
|
||||
* @return A QPixmap representing the icon.
|
||||
*/
|
||||
QPixmap drawFoldIcon(const QPalette& p, bool fold, bool hover) const;
|
||||
|
||||
/**
|
||||
* @brief Generates a custom system style based on the palette.
|
||||
* @param p The palette to use for generating the style.
|
||||
* @return A QString containing the generated style.
|
||||
*/
|
||||
QString systemStyle(const QPalette& p) const;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace QSint
|
||||
|
||||
#endif // FREECADTASKPANELSCHEME_H
|
||||
|
||||
#endif // IISFREECADTASKPANELSCHEME_H
|
||||
|
||||
Reference in New Issue
Block a user