Merge pull request #19649 from alfrix/taskpanel_improvements

refactor(Gui): improve the taskpanel
This commit is contained in:
Chris Hennes
2025-03-10 16:51:09 +00:00
committed by GitHub
50 changed files with 776 additions and 2049 deletions
-11
View File
@@ -449,7 +449,6 @@ set(Gui_RES_SRCS
Icons/resource.qrc
Language/translation.qrc
${FreeCAD_TR_QRC}
QSint/actionpanel/schemes.qrc
)
qt_add_resources(Gui_QRC_SRCS ${Gui_RES_SRCS})
@@ -862,20 +861,10 @@ SET(qsintActionPanel_SRCS
QSint/actionpanel/actionpanel.h
QSint/actionpanel/actionpanelscheme.cpp
QSint/actionpanel/actionpanelscheme.h
QSint/actionpanel/androidpanelscheme.cpp
QSint/actionpanel/androidpanelscheme.h
QSint/actionpanel/macpanelscheme.cpp
QSint/actionpanel/macpanelscheme.h
QSint/actionpanel/taskgroup_p.cpp
QSint/actionpanel/taskgroup_p.h
QSint/actionpanel/taskheader_p.cpp
QSint/actionpanel/taskheader_p.h
QSint/actionpanel/winvistapanelscheme.cpp
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
+32 -96
View File
@@ -9,94 +9,35 @@
#include <QVariant>
namespace QSint
{
const char* ActionBoxStyle =
"QSint--ActionBox {"
"background-color: white;"
"border: 1px solid white;"
"border-radius: 3px;"
"text-align: left;"
"}"
"QSint--ActionBox:hover {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);"
"border: 1px solid #DAF2FC;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='header'] {"
"text-align: left;"
"font: 14px;"
"color: #006600;"
"background-color: transparent;"
"border: none;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='header']:hover {"
"color: #00cc00;"
"text-decoration: underline;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='action'] {"
"background-color: transparent;"
"border: none;"
"color: #0033ff;"
"text-align: left;"
"font: 11px;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='action']:!enabled {"
"color: #999999;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='action']:hover {"
"color: #0099ff;"
"text-decoration: underline;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
ActionBox::ActionBox(QWidget *parent) :
QFrame(parent)
ActionBox::ActionBox(QWidget *parent)
: QFrame(parent)
{
init();
}
ActionBox::ActionBox(const QString & headerText, QWidget *parent) :
QFrame(parent)
ActionBox::ActionBox(const QString & headerText, QWidget *parent)
: QFrame(parent)
{
init();
headerLabel->setText(headerText);
init(headerText);
}
ActionBox::ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent) :
QFrame(parent)
ActionBox::ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent)
: QFrame(parent)
{
init();
headerLabel->setText(headerText);
init(headerText);
setIcon(icon);
}
void ActionBox::init()
void ActionBox::init(const QString &headerText)
{
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
setStyleSheet(QString(ActionBoxStyle));
auto *mainLayout = new QHBoxLayout(this);
QHBoxLayout *mainLayout = new QHBoxLayout(this);
QVBoxLayout *iconLayout = new QVBoxLayout();
auto *iconLayout = new QVBoxLayout();
mainLayout->addLayout(iconLayout);
iconLabel = new QLabel(this);
@@ -106,7 +47,7 @@ void ActionBox::init()
dataLayout = new QVBoxLayout();
mainLayout->addLayout(dataLayout);
headerLabel = createItem("");
headerLabel = createItem(headerText);
headerLabel->setProperty("class", "header");
}
@@ -118,22 +59,14 @@ void ActionBox::setIcon(const QPixmap & icon)
QPixmap ActionBox::icon() const
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
return iconLabel->pixmap(Qt::ReturnByValue);
#else
QPixmap p;
const QPixmap* ptr = iconLabel->pixmap();
if (ptr)
p = *ptr;
return p;
#endif
}
ActionLabel* ActionBox::createItem(QAction * action, QLayout * l)
{
if (!action)
if (!action) {
return nullptr;
}
ActionLabel *act = createItem("", l);
act->setDefaultAction(action);
return act;
@@ -143,15 +76,15 @@ QList<ActionLabel*> ActionBox::createItems(QList<QAction*> actions)
{
QList<ActionLabel*> list;
if (actions.isEmpty())
if (actions.isEmpty()) {
return list;
}
QLayout *l = createHBoxLayout();
Q_FOREACH (QAction *action, actions) {
ActionLabel *act = createItem(action, l);
if (act)
for (QAction *action : actions) {
if (auto *act = createItem(action, l)) {
list.append(act);
}
}
return list;
@@ -162,10 +95,10 @@ ActionLabel* ActionBox::createItem(const QString & text, QLayout * l)
ActionLabel *act = new ActionLabel(this);
act->setText(text);
act->setProperty("class", "action");
act->setStyleSheet("");
if (l)
if (l) {
l->addWidget(act);
}
else {
QHBoxLayout *hbl = new QHBoxLayout();
hbl->addWidget(act);
@@ -187,11 +120,14 @@ QSpacerItem* ActionBox::createSpacer(QLayout * l)
{
QSpacerItem * spacer;
if (l) // add horizontal spacer
if (l) {
// add horizontal spacer
l->addItem(spacer = new QSpacerItem(1,0,QSizePolicy::MinimumExpanding,QSizePolicy::Ignored));
else // add vertical spacer
}
else {
// add vertical spacer
dataLayout->addItem(spacer = new QSpacerItem(0,1,QSizePolicy::Ignored,QSizePolicy::MinimumExpanding));
}
return spacer;
}
@@ -215,13 +151,14 @@ void ActionBox::addLayout(QLayout * l)
void ActionBox::addWidget(QWidget * w, QLayout * l)
{
if (!w)
if (!w) {
return;
}
w->setParent(this);
if (l)
if (l) {
l->addWidget(w);
}
else {
QHBoxLayout *hbl = new QHBoxLayout();
hbl->addWidget(w);
@@ -235,5 +172,4 @@ QSize ActionBox::minimumSizeHint() const
return {150,65};
}
} // namespace
+100 -199
View File
@@ -16,149 +16,13 @@
namespace QSint
{
/**
\brief Class representing a panel of actions similar to Windows Vista/7 control panel items.
\since 0.2
\image html ActionBox.png An example of ActionBox
ActionBox normally consists of an icon, clickable header and a list of actions.
Every action can have own icon as well, provide tooltips and status tips,
be clickable and checkable etc. i.e. behave like a normal ActionLabel.
ActionBox objects are easily customizable via CSS technology - you can get
different look just by writing corresponding style sheet.
<b>Usage of ActionBox in the application</b>
1. Create ActionBox using constructor (or in Designer as Promoted Objects).
Icon and header text can be passed to the constructor as well. For example:
\code
ActionBox *box1 = new ActionBox(":/icons/box1icon.png", "Header Text", this);
\endcode
2. ActionBox header itself is a clickable item (based on ActionLabel), so you
can retrieve it and use, for example, to connect with a slot:
\code
connect(box1->header(), SIGNAL(clicked()), this, SLOT(header1clicked()));
\endcode
3. To create an action, use one of createItem() functions. For example:
\code
ActionLabel *action1 = box1->createItem(":/icons/action1icon.png", "Action1 Text");
connect(action1, SIGNAL(clicked()), this, SLOT(action1clicked()));
ActionLabel *action2 = box1->createItem(":/icons/action2icon.png", "Action2 Text");
connect(action2, SIGNAL(clicked()), this, SLOT(action2clicked()));
\endcode
createItem() also allows one to create an ActionLabel from already existing QAction:
\code
QAction myAction3(":/icons/action3icon.png", "Action3 Text");
connect(myAction3, SIGNAL(clicked()), this, SLOT(action3clicked()));
ActionLabel *action3 = box1->createItem(myAction3);
\endcode
4. By default, actions are arranged vertically, one per row. In order
to have more than one actions in a row, first add horizontal layout item
using createHBoxLayout() function, and then pass it to the createItem() to
create actions.
\code
// create horizontal layout
QLayout *hbl1 = box1->createHBoxLayout();
// create actions using this layout
ActionLabel *action3 = box1->createItem(":/icons/action3icon.png", "1st action in row", hbl1);
ActionLabel *action4 = box1->createItem("2nd action in row", hbl1);
\endcode
5. Sometimes you would like to have a spacer between the items. Use createSpacer()
function to insert an empty space into default or specified layout.
\code
// create a spacer after two actions added before
box1->createSpacer(hbl1);
// create another action which will be preceded by the empty space (i.e. right-aligned)
ActionLabel *action5 = box1->createItem("3rd action in row", hbl1);
\endcode
6. You can insert arbitrary layout items and widgets into ActionBox using
addLayout() and addWidgets() functions. Please note that ownership of these items
transferred to ActionBox, so you must not delete them manually.
<b>Customization of ActionBox via CSS</b>
ActionBox items can be easily customized using CSS mechanism. Just create a new
style and apply it to the ActionBox with setStyleSheet().
See the following example of the complete ActionBox customization. Note that
\a QSint--ActionBox is used as a main class name. Headers are ActionLabels with
property \a class='header'. Actions are ActionLabels with
property \a class='action'.
\code
// define a string representing CSS style
const char* ActionBoxNewStyle =
// customization of ActionBox
"QSint--ActionBox {"
"background-color: white;"
"border: 1px solid white;"
"border-radius: 3px;"
"text-align: left;"
"}"
"QSint--ActionBox:hover {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);"
"border: 1px solid #DAF2FC;"
"}"
// customization of ActionBox's header
"QSint--ActionBox QSint--ActionLabel[class='header'] {"
"text-align: left;"
"font: 14px;"
"color: #006600;"
"background-color: transparent;"
"border: none;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='header']:hover {"
"color: #00cc00;"
"text-decoration: underline;"
"}"
// customization of ActionBox's actions
"QSint--ActionBox QSint--ActionLabel[class='action'] {"
"background-color: transparent;"
"border: none;"
"color: #0033ff;"
"text-align: left;"
"font: 11px;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='action']:hover {"
"color: #0099ff;"
"text-decoration: underline;"
"}"
"QSint--ActionBox QSint--ActionLabel[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
// apply the style
box1->setStyleSheet(ActionBoxNewStyle);
\endcode
*/
* @brief A panel of actions, similar to Windows Vista/7 control panel items.
*
* An ActionBox displays an icon, a clickable header, and a list of actions.
* Actions can have icons, tooltips, status tips, and support click/check functionality
* (similar to ActionLabel). Customizable via CSS.
*/
class QSINT_EXPORT ActionBox : public QFrame
{
Q_OBJECT
@@ -167,92 +31,129 @@ class QSINT_EXPORT ActionBox : public QFrame
Q_PROPERTY(ActionLabel header READ header) // clazy:exclude=qproperty-without-notify
public:
/** Constructor.
*/
/**
* @brief Constructs an ActionBox.
* @param parent The parent widget.
*/
explicit ActionBox(QWidget *parent = nullptr);
/** Constructor.
*/
explicit ActionBox(const QString & headerText, QWidget *parent = nullptr);
/** Constructor.
*/
/**
* @brief Constructs an ActionBox with a header text.
* @param headerText The header text.
* @param parent The parent widget.
*/
ActionBox(const QString & headerText, QWidget *parent = nullptr);
/**
* @brief Constructs an ActionBox with an icon and header text.
* @param icon The icon.
* @param headerText The header text.
* @param parent The parent widget.
*/
explicit ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent = nullptr);
/** Sets icon of the ActionBox to \a icon.
*/
/**
* @brief Sets the ActionBox icon.
* @param icon The icon.
*/
void setIcon(const QPixmap & icon);
/** Returns icon of the ActionBox.
*/
QPixmap icon() const;// { return iconLabel->pixmap(); }
/** Returns header item of the ActionBox.
*/
/**
* @brief Returns the ActionBox icon.
* @return The icon.
*/
QPixmap icon() const;
/**
* @brief Returns the header label.
* @return The header label.
*/
inline ActionLabel* header() const { return headerLabel; }
/** Creates action item from the \a action and returns it.
By default, action is added to the default vertical layout, i.e. subsequent
calls of this function will create several actions arranged vertically,
one below another.
You can add action to the specified layout passing it as \a l parameter.
This allows one to do custom actions arrangements, i.e. horizontal etc.
\since 0.2
*/
/**
* @brief Creates and adds an action from a QAction.
* @param action The QAction.
* @param l Optional layout to add the action to. Defaults to the
* ActionBox's default vertical layout.
* @return The created ActionLabel.
*/
ActionLabel* createItem(QAction * action, QLayout * l = nullptr);
/** Creates action items from the \a actions list and returns the list of action items.
\since 0.2
*/
QList<ActionLabel*> createItems(QList<QAction*> actions);
/**
* @brief Creates and adds multiple actions from a list of QActions.
* @param actions The list of QActions.
* @return The list of created ActionLabels.
*/
QList<ActionLabel*> createItems(const QList<QAction*> actions);
/** Adds an action with \a text to the ActionBox and returns action item.
*/
/**
* @brief Creates and adds an action with text.
* @param text The action text.
* @param l Optional layout to add the action to.
* @return The created ActionLabel.
*/
ActionLabel* createItem(const QString & text = QString(), QLayout * l = nullptr);
/** Adds an action with \a icon and \a text to the ActionBox and returns action item.
This function acts just like previous one. See the description above.
*/
/**
* @brief Creates and adds an action with an icon and text.
* @param icon The action icon.
* @param text The action text.
* @param l Optional layout to add the action to.
* @return The created ActionLabel.
*/
ActionLabel* createItem(const QPixmap & icon, const QString & text, QLayout * l = nullptr);
/** Adds a spacer and returns spacer item.
By default, a spacer is added to the default vertical layout.
You can add a spacer to the specified layout passing it as \a l parameter.
*/
/**
* @brief Creates and adds a spacer.
* @param l Optional layout to add the spacer to. Defaults to the
* ActionBox's default vertical layout.
* @return The created spacer item.
*/
QSpacerItem* createSpacer(QLayout * l = nullptr);
/** Creates empty horizontal layout.
Use this function to arrange action items into a row.
*/
/**
* @brief Creates a horizontal layout.
* @return The created layout.
*/
QLayout* createHBoxLayout();
/** Returns default layout used for actions (typically it's QVBoxLayout).
*/
/**
* @brief Returns the default layout used for actions.
* @return The default layout.
*/
inline QLayout* itemLayout() const { return dataLayout; }
/** Adds layout \a l to the default layout.
*/
/**
* @brief Adds a layout.
* @param l The layout to add.
*/
void addLayout(QLayout * l);
/** Adds widget \a w to the layout.
By default, widget is added to the default vertical layout.
You can add widget to the specified layout passing it as \a l parameter.
*/
/**
* @brief Adds a widget.
* @param w The widget to add.
* @param l Optional layout to add the widget to. Defaults to the
* ActionBox's default vertical layout.
*/
void addWidget(QWidget * w, QLayout * l = nullptr);
/**
* @brief Returns the recommended minimum size.
* @return The minimum size hint.
*/
QSize minimumSizeHint() const override;
protected:
void init();
/**
* @brief Initializes the ActionBox.
* @param headerText The initial header text.
*/
void init(const QString &headerText = QString());
QVBoxLayout *dataLayout;
QLabel *iconLabel;
ActionLabel *headerLabel;
QVBoxLayout *dataLayout; ///< Default layout for actions/widgets.
QLabel *iconLabel; ///< Label for the ActionBox icon.
ActionLabel *headerLabel; ///< Label for the header.
};
} // namespace
#endif // ACTIONBOX_H
+99 -133
View File
@@ -4,82 +4,72 @@
* License: LGPL *
* *
***************************************************************************/
#include "actiongroup.h"
#include "taskheader_p.h"
#include "taskgroup_p.h"
#include <QPainter>
#include <QVBoxLayout>
#include <QTimer>
namespace QSint
{
ActionGroup::ActionGroup(QWidget *parent)
: QWidget(parent)
: QWidget(parent),
myHeader(new TaskHeader(QPixmap(), "", false, this))
{
myHeader = new TaskHeader(QPixmap(), "", false, this);
myHeader->setVisible(false);
init(false);
}
ActionGroup::ActionGroup(const QString &title, bool expandable, QWidget *parent)
: QWidget(parent)
: QWidget(parent),
myHeader(new TaskHeader(QPixmap(), title, expandable, this))
{
myHeader = new TaskHeader(QPixmap(), title, expandable, this);
init(true);
}
ActionGroup::ActionGroup(const QPixmap &icon, const QString &title, bool expandable, QWidget *parent)
: QWidget(parent)
: QWidget(parent),
myHeader(new TaskHeader(icon, title, expandable, this))
{
myHeader = new TaskHeader(icon, title, expandable, this);
init(true);
}
void ActionGroup::init(bool header)
ActionGroup::~ActionGroup() = default;
void ActionGroup::init(bool hasHeader)
{
m_foldStep = 0;
m_foldStep = 0;
myScheme = ActionPanelScheme::defaultScheme();
myScheme = ActionPanelScheme::defaultScheme();
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
QVBoxLayout *vbl = new QVBoxLayout();
vbl->setContentsMargins(0, 0, 0, 0);
vbl->setSpacing(0);
setLayout(vbl);
layout->addWidget(myHeader);
vbl->addWidget(myHeader);
myGroup = new TaskGroup(this, hasHeader);
layout->addWidget(myGroup);
myGroup = new TaskGroup(this, header);
vbl->addWidget(myGroup);
myDummy = new QWidget(this);
layout->addWidget(myDummy);
myDummy->hide();
myDummy = new QWidget(this);
vbl->addWidget(myDummy);
myDummy->hide();
connect(myHeader, &TaskHeader::activated, this, &ActionGroup::showHide);
}
void ActionGroup::setScheme(ActionPanelScheme *pointer)
{
myScheme = pointer;
myHeader->setScheme(pointer);
myGroup->setScheme(pointer);
update();
connect(myHeader, &TaskHeader::activated, this, &ActionGroup::showHide);
}
QBoxLayout* ActionGroup::groupLayout()
{
return myGroup->groupLayout();
return myGroup->groupLayout();
}
ActionLabel* ActionGroup::addAction(QAction *action, bool addToLayout, bool addStretch)
{
if (!action)
return nullptr;
if (!action) return nullptr;
ActionLabel* label = new ActionLabel(action, this);
auto *label = new ActionLabel(action, this);
myGroup->addActionLabel(label, addToLayout, addStretch);
return label;
@@ -87,11 +77,9 @@ ActionLabel* ActionGroup::addAction(QAction *action, bool addToLayout, bool addS
ActionLabel* ActionGroup::addActionLabel(ActionLabel *label, bool addToLayout, bool addStretch)
{
if (!label)
return nullptr;
if (!label) return nullptr;
myGroup->addActionLabel(label, addToLayout, addStretch);
return label;
}
@@ -102,122 +90,102 @@ bool ActionGroup::addWidget(QWidget *widget, bool addToLayout, bool addStretch)
void ActionGroup::showHide()
{
if (m_foldStep)
return;
if (m_foldStep || !myHeader->expandable()) return;
if (!myHeader->expandable())
return;
if (myGroup->isVisible())
{
m_foldPixmap = myGroup->transparentRender();
m_tempHeight = m_fullHeight = myGroup->height();
m_foldDelta = m_fullHeight / myScheme->groupFoldSteps;
m_foldStep = myScheme->groupFoldSteps;
m_foldDirection = -1;
if (myGroup->isVisible())
{
m_foldPixmap = myGroup->transparentRender();
// m_foldPixmap = QPixmap::grabWidget(myGroup, myGroup->rect());
myGroup->hide();
myDummy->setFixedSize(myGroup->size());
m_tempHeight = m_fullHeight = myGroup->height();
m_foldDelta = m_fullHeight / myScheme->groupFoldSteps;
m_foldStep = myScheme->groupFoldSteps;
m_foldDirection = -1;
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processHide);
}
else
{
m_foldStep = myScheme->groupFoldSteps;
m_foldDirection = 1;
m_tempHeight = 0;
myGroup->hide();
myDummy->setFixedSize(myGroup->size());
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processShow);
}
myDummy->show();
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processHide);
}
else
{
m_foldStep = myScheme->groupFoldSteps;
m_foldDirection = 1;
m_tempHeight = 0;
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processShow);
}
myDummy->show();
}
void ActionGroup::processHide()
{
if (!--m_foldStep) {
myDummy->setFixedHeight(0);
myDummy->hide();
myHeader->setFold(false);
setFixedHeight(myHeader->height());
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
return;
}
if (--m_foldStep == 0)
{
myDummy->hide();
myHeader->setFold(false);
setFixedHeight(myHeader->height());
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
return;
}
setUpdatesEnabled(false);
m_tempHeight -= m_foldDelta;
myDummy->setFixedHeight(m_tempHeight);
setFixedHeight(myDummy->height() + myHeader->height());
m_tempHeight -= m_foldDelta;
myDummy->setFixedHeight(m_tempHeight);
setFixedHeight(myDummy->height()+myHeader->height());
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processHide);
setUpdatesEnabled(true);
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processHide);
}
void ActionGroup::processShow()
{
if (!--m_foldStep) {
myDummy->hide();
m_foldPixmap = QPixmap();
myGroup->show();
myHeader->setFold(true);
setFixedHeight(m_fullHeight+myHeader->height());
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setMaximumHeight(QWIDGETSIZE_MAX);
setMinimumHeight(0);
return;
}
if (--m_foldStep == 0)
{
myDummy->hide();
m_foldPixmap = QPixmap();
myGroup->show();
myHeader->setFold(true);
setFixedHeight(m_fullHeight + myHeader->height());
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setMaximumHeight(QWIDGETSIZE_MAX);
return;
}
setUpdatesEnabled(false);
m_tempHeight += m_foldDelta;
myDummy->setFixedHeight(m_tempHeight);
setFixedHeight(myDummy->height() + myHeader->height());
m_tempHeight += m_foldDelta;
myDummy->setFixedHeight(m_tempHeight);
setFixedHeight(myDummy->height()+myHeader->height());
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processShow);
setUpdatesEnabled(true);
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processShow);
}
void ActionGroup::paintEvent ( QPaintEvent * event )
void ActionGroup::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter p(this);
Q_UNUSED(event);
QPainter p(this);
if (myDummy->isVisible()) {
if (myScheme->groupFoldThaw) {
if (m_foldDirection < 0)
p.setOpacity((double)m_foldStep / myScheme->groupFoldSteps);
else
p.setOpacity((double)(myScheme->groupFoldSteps-m_foldStep) / myScheme->groupFoldSteps);
if (!myDummy->isVisible()) {
return;
}
if (myScheme->groupFoldThaw)
{
double opacity = (m_foldDirection < 0)
? static_cast<double>(m_foldStep) / myScheme->groupFoldSteps
: static_cast<double>(myScheme->groupFoldSteps - m_foldStep) / myScheme->groupFoldSteps;
p.setOpacity(opacity);
}
switch (myScheme->groupFoldEffect)
{
case ActionPanelScheme::ShrunkFolding:
p.drawPixmap(myDummy->pos(), m_foldPixmap.scaled(myDummy->size()) );
break;
case ActionPanelScheme::SlideFolding:
p.drawPixmap(myDummy->pos(), m_foldPixmap,
QRect(0, m_foldPixmap.height()-myDummy->height(),
m_foldPixmap.width(), myDummy->width()
) );
break;
default:
p.drawPixmap(myDummy->pos(), m_foldPixmap);
case ActionPanelScheme::ShrunkFolding:
p.drawPixmap(myDummy->pos(), m_foldPixmap.scaled(myDummy->size()));
break;
case ActionPanelScheme::SlideFolding:
p.drawPixmap(myDummy->pos(), m_foldPixmap,
QRect(0, m_foldPixmap.height() - myDummy->height(),
m_foldPixmap.width(), myDummy->width()));
break;
default:
p.drawPixmap(myDummy->pos(), m_foldPixmap);
}
return;
}
}
bool ActionGroup::isExpandable() const
{
return myHeader->expandable();
@@ -243,21 +211,19 @@ QString ActionGroup::headerText() const
return myHeader->myTitle->text();
}
void ActionGroup::setHeaderText(const QString & headerText)
void ActionGroup::setHeaderText(const QString &headerText)
{
myHeader->myTitle->setText(headerText);
}
void ActionGroup::setHeaderIcon(const QPixmap& icon)
void ActionGroup::setHeaderIcon(const QPixmap &icon)
{
myHeader->myTitle->setIcon(icon);
}
QSize ActionGroup::minimumSizeHint() const
{
return {200,65};
return {200, 65};
}
}
} // namespace
+133 -111
View File
@@ -8,169 +8,191 @@
#ifndef ACTIONGROUP_H
#define ACTIONGROUP_H
#include <QWidget>
#include <QBoxLayout>
#include <QTimer>
#include <QWidget>
#include "qsint_global.h"
namespace QSint
{
class ActionLabel;
class ActionPanelScheme;
class TaskHeader;
class TaskGroup;
/**
\brief Class representing a single group of actions similar to Windows XP task panels.
\since 0.2
\image html ActionGroup.png An example of ActionGroup
ActionGroup consists from optional header and set of actions represented by ActionLabel.
It can contain arbitrary widgets as well.
*/
* @brief A collapsible group widget for organizing actions.
*
* An ActionGroup can have a header and contains actions (ActionLabels) or other widgets.
*/
class QSINT_EXPORT ActionGroup : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool expandable READ isExpandable WRITE setExpandable) // clazy:exclude=qproperty-without-notify
Q_PROPERTY(bool header READ hasHeader WRITE setHeader) // clazy:exclude=qproperty-without-notify
Q_PROPERTY(QString headerText READ headerText WRITE setHeaderText) // clazy:exclude=qproperty-without-notify
Q_PROPERTY(bool expandable READ isExpandable WRITE setExpandable NOTIFY expandableChanged)
Q_PROPERTY(bool header READ hasHeader WRITE setHeader NOTIFY headerChanged)
Q_PROPERTY(QString headerText READ headerText WRITE setHeaderText NOTIFY headerTextChanged)
Q_SIGNALS:
void expandableChanged();
void headerChanged();
void headerTextChanged();
public:
/** Constructor. Creates ActionGroup without header.
*/
/**
* @brief Constructs an ActionGroup.
* @param parent The parent widget.
*/
explicit ActionGroup(QWidget *parent = nullptr);
/** Constructor. Creates ActionGroup with header's
text set to \a title, but with no icon.
/**
* @brief Constructs an ActionGroup with a title.
* @param title The title of the group's header.
* @param expandable If `true` (default), the group can be expanded/collapsed.
* @param parent The parent widget.
*/
explicit ActionGroup(const QString& title, bool expandable = true, QWidget *parent = nullptr);
If \a expandable set to \a true (default), the group can be expanded/collapsed by the user.
*/
explicit ActionGroup(const QString& title,
bool expandable = true,
QWidget *parent = nullptr);
/**
* @brief Constructs an ActionGroup with an icon and title.
* @param icon The icon for the group's header.
* @param title The title of the group's header.
* @param expandable If `true` (default), the group can be expanded/collapsed.
* @param parent The parent widget.
*/
explicit ActionGroup(const QPixmap& icon, const QString& title, bool expandable = true, QWidget *parent = nullptr);
/** Constructor. Creates ActionGroup with header's
text set to \a title and icon set to \a icon.
/**
* @brief Destroys the ActionGroup.
*/
~ActionGroup() override;
If \a expandable set to \a true (default), the group can be expanded/collapsed by the user.
*/
explicit ActionGroup(const QPixmap& icon,
const QString& title,
bool expandable = true,
QWidget *parent = nullptr);
/** Creates action item from the \a action and returns it.
If \a addToLayout is set to \a true (default),
the action is added to the default vertical layout, i.e. subsequent
calls of this function will create several ActionLabels arranged vertically,
one below another.
Set \a addToLayout to \a false if you want to add the action to the specified layout manually.
This allows one to do custom actions arrangements, i.e. horizontal etc.
If \a addStretch is set to \a true (default),
ActionLabel will be automatically aligned to the left side of the ActionGroup.
Set \a addStretch to \a false if you want ActionLabel to occupy all the horizontal space.
*/
/**
* @brief Creates and adds an action.
* @param action The QAction to add.
* @param addToLayout If `true` (default), adds the action to the group's layout.
* @param addStretch If `true` (default), aligns the ActionLabel to the left.
* @return The newly created ActionLabel.
*/
ActionLabel* addAction(QAction *action, bool addToLayout = true, bool addStretch = true);
/** Adds \a label to the group.
\sa addAction() for the description.
*/
/**
* @brief Adds an existing ActionLabel.
* @param label The ActionLabel to add.
* @param addToLayout If `true` (default), adds the label to the group's layout.
* @param addStretch If `true` (default), aligns the ActionLabel to the left.
* @return The added ActionLabel.
*/
ActionLabel* addActionLabel(ActionLabel *label, bool addToLayout = true, bool addStretch = true);
/** Adds \a widget to the group. Returns \a true if it has been added successfully.
\sa addAction() for the description.
*/
/**
* @brief Adds a widget to the group.
* @param widget The widget to add.
* @param addToLayout If `true` (default), adds the widget to the group's layout.
* @param addStretch If `true` (default), aligns the widget to the left.
* @return `true` if added successfully.
*/
bool addWidget(QWidget *widget, bool addToLayout = true, bool addStretch = true);
/** Returns group's layout (QVBoxLayout by default).
*/
/**
* @brief Returns the group's layout.
* @return The group's layout (QVBoxLayout by default).
*/
QBoxLayout* groupLayout();
/** Sets the scheme of the panel and all the child groups to \a scheme.
By default, ActionPanelScheme::defaultScheme() is used.
*/
void setScheme(ActionPanelScheme *pointer);
/** Returns \a true if the group is expandable.
\sa setExpandable().
*/
/**
* @brief Checks if the group is expandable.
* @return `true` if the group is expandable, `false` otherwise.
*/
bool isExpandable() const;
/** Returns \a true if the group has header.
/**
* @brief Sets whether the group is expandable.
* @param expandable If `true`, the group can be expanded/collapsed.
*/
void setExpandable(bool expandable);
\sa setHeader().
*/
/**
* @brief Checks if the group has a header.
* @return `true` if the group has a header, `false` otherwise.
*/
bool hasHeader() const;
/** Returns text of the header.
Only valid if the group has header (see hasHeader()).
/**
* @brief Sets whether the group has a header.
* @param enable If `true`, the group will have a header.
*/
void setHeader(bool enable);
\sa setHeaderText().
*/
/**
* @brief Returns the header text.
* @return The header text.
*/
QString headerText() const;
/**
* @brief Sets the header text.
* @param text The header text.
*/
void setHeaderText(const QString &text);
/**
* @brief Sets the header icon.
* @param icon The header icon.
*/
void setHeaderIcon(const QPixmap &icon);
/**
* @brief Returns the recommended minimum size for the group.
* @return The minimum size hint.
*/
QSize minimumSizeHint() const override;
public Q_SLOTS:
/** Expands/collapses the group.
Only valid if the group has header (see hasHeader()).
*/
/**
* @brief Shows or hides the group's contents.
*/
void showHide();
/** Makes the group expandable if \a expandable is set to \a true.
\sa isExpandable().
*/
void setExpandable(bool expandable = true);
/** Enables/disables group's header according to \a enable.
\sa hasHeader().
*/
void setHeader(bool enable = true);
/** Sets text of the header to \a title.
Only valid if the group has header (see hasHeader()).
\sa headerText().
*/
void setHeaderText(const QString & title);
void setHeaderIcon(const QPixmap& icon);
protected Q_SLOTS:
/**
* @brief Handles hiding the group's contents.
*/
void processHide();
/**
* @brief Handles showing the group's contents.
*/
void processShow();
protected:
void init(bool header);
/**
* @brief Paints the group.
* @param event The paint event.
*/
void paintEvent(QPaintEvent *event) override;
void paintEvent ( QPaintEvent * event ) override;
/**
* @brief Initializes the group.
* @param hasHeader Whether the group has a header.
*/
void init(bool hasHeader);
double m_foldStep, m_foldDelta, m_fullHeight, m_tempHeight;
int m_foldDirection;
double m_foldStep = 0; ///< Current folding animation step.
double m_foldDelta = 0; ///< Change in height per animation step.
double m_fullHeight = 0; ///< Full (expanded) height of the group.
double m_tempHeight = 0; ///< Temporary height during animation.
int m_foldDirection = 0; ///< Direction of folding animation.
QPixmap m_foldPixmap;
QPixmap m_foldPixmap; ///< Pixmap for the fold/unfold icon.
class TaskHeader *myHeader;
class TaskGroup *myGroup;
QWidget *myDummy;
ActionPanelScheme *myScheme;
TaskHeader *myHeader = nullptr; ///< The group's header.
TaskGroup *myGroup = nullptr; ///< The container for actions/widgets.
QWidget *myDummy = nullptr; ///< Dummy widget for animation.
ActionPanelScheme *myScheme = nullptr; ///< The color scheme.
};
} // namespace
} // namespace QSint
#endif // ACTIONGROUP_H
+18 -67
View File
@@ -9,67 +9,30 @@
#include <QApplication>
#include <QStyleOptionToolButton>
#include <QAction>
namespace QSint
{
const char* ActionLabelStyle =
"QSint--ActionLabel[class='action'] {"
"background-color: transparent;"
"border: 1px solid transparent;"
"color: #0033ff;"
"text-align: left;"
"font: 11px;"
"}"
"QSint--ActionLabel[class='action']:!enabled {"
"color: #999999;"
"}"
"QSint--ActionLabel[class='action']:hover {"
"color: #0099ff;"
"text-decoration: underline;"
"}"
"QSint--ActionLabel[class='action']:focus {"
"border: 1px dotted black;"
"}"
"QSint--ActionLabel[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
ActionLabel::ActionLabel(QWidget *parent) :
QToolButton(parent)
ActionLabel::ActionLabel(QWidget *parent)
: QToolButton(parent)
{
init();
}
ActionLabel::ActionLabel(QAction *action, QWidget *parent) :
QToolButton(parent)
ActionLabel::ActionLabel(QAction *action, QWidget *parent)
: QToolButton(parent)
{
init();
setDefaultAction(action);
}
void ActionLabel::init()
{
setProperty("class", "action");
setCursor(Qt::PointingHandCursor);
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
setStyleSheet(QString(ActionLabelStyle));
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setFocusPolicy(Qt::StrongFocus);
}
@@ -77,37 +40,27 @@ QSize ActionLabel::sizeHint() const
{
ensurePolished();
int w = 0, h = 0;
QStyleOptionToolButton opt;
initStyleOption(&opt);
QString s(text());
bool empty = s.isEmpty();
if (empty)
s = QStringLiteral("XXXX");
QFontMetrics fm = fontMetrics();
QSize sz = fm.size(Qt::TextShowMnemonic, s);
w += sz.width();
h = qMax(h, sz.height());
opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
QString s = text().isEmpty() ? QStringLiteral("XXXX") : text();
QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, s);
constexpr int padding = 10;
int width = textSize.width();
if (!icon().isNull()) {
int ih = opt.iconSize.height();
int iw = opt.iconSize.width() + 4;
w += iw;
h = qMax(h, ih);
width += opt.iconSize.width() + padding;
}
if (menu())
w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this);
if (menu()) {
width += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this);
}
h += 4;
w += 8;
int height = qMax(textSize.height(), opt.iconSize.height());
QSize sizeHint = style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this);
return sizeHint;
return style()->sizeFromContents(
QStyle::CT_PushButton, &opt, QSize(width + 2 * padding, height + padding), this
);
}
QSize ActionLabel::minimumSizeHint() const
@@ -115,6 +68,4 @@ QSize ActionLabel::minimumSizeHint() const
return sizeHint();
}
} // namespace
} // namespace QSint
+31 -57
View File
@@ -11,84 +11,58 @@
#include <QToolButton>
#include "qsint_global.h"
namespace QSint
{
/**
\brief Class representing an action similar to Windows Vista/7 control panel item.
\image html ActionLabel.png An example of ActionLabel
ActionLabel normally consists of an icon and text.
It also can have tooltip and status tip,
be clickable and checkable etc. i.e. behave like a normal QToolButton.
<b>Customization of ActionLabel via CSS</b>
ActionLabel objects are easily customizable via CSS technology - you can get
different look just by writing corresponding style sheet and applying it with setStyleSheet().
See the following example of the complete ActionLabel customization. Note that
\a QSint--ActionLabel is used as a main class name.
\code
// define a string representing CSS style
const char* ActionLabelNewStyle =
"QSint--ActionLabel[class='action'] {"
"background-color: transparent;"
"border: 1px solid transparent;"
"color: #0033ff;"
"text-align: left;"
"font: 11px;"
"}"
"QSint--ActionLabel[class='action']:hover {"
"color: #0099ff;"
"text-decoration: underline;"
"}"
"QSint--ActionLabel[class='action']:focus {"
"border: 1px dotted black;"
"}"
"QSint--ActionLabel[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
// apply the style
label1->setStyleSheet(ActionLabelNewStyle);
\endcode
*/
* @brief Represents an action, similar to a Windows Vista/7 control panel item.
*
* An ActionLabel typically displays an icon and text. It supports tooltips, status tips,
* clickability, checkability, and other features similar to a QToolButton.
*
* Customization via CSS: The class name `QSint--ActionLabel` is used.
*/
class QSINT_EXPORT ActionLabel : public QToolButton
{
Q_OBJECT
public:
/** Constructor.
*/
/**
* @brief Constructs an ActionLabel.
* @param parent The parent widget.
*/
explicit ActionLabel(QWidget *parent = nullptr);
/** Constructor. Creates ActionLabel from the \a action.
\since 0.2
*/
/**
* @brief Constructs an ActionLabel from a QAction.
* @param action The QAction to represent.
* @param parent The parent widget.
*/
explicit ActionLabel(QAction *action, QWidget *parent = nullptr);
/**
* @brief Destroys the ActionLabel.
*/
~ActionLabel() override = default;
/**
* @brief Returns the recommended size for the label.
* @return The size hint.
*/
QSize sizeHint() const override;
/**
* @brief Returns the minimum size the label can be.
* @return The minimum size hint.
*/
QSize minimumSizeHint() const override;
protected:
/**
* @brief Initializes the ActionLabel.
*/
void init();
};
} // namespace
#endif // ACTIONLABEL_H
+26 -52
View File
@@ -11,21 +11,17 @@
#include <QVariant>
namespace QSint
{
ActionPanel::ActionPanel(QWidget *parent) :
BaseClass(parent), mySpacer(nullptr)
{
setProperty("class", "panel");
setScheme(ActionPanelScheme::defaultScheme());
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
QVBoxLayout *vbl = new QVBoxLayout();
auto *vbl = new QVBoxLayout();
vbl->setContentsMargins(4, 8, 4, 8);
vbl->setSpacing(8);
setLayout(vbl);
@@ -33,88 +29,66 @@ ActionPanel::ActionPanel(QWidget *parent) :
void ActionPanel::setScheme(ActionPanelScheme *scheme)
{
if (scheme) {
if (!scheme) return;
myScheme = scheme;
setStyleSheet(myScheme->actionStyle);
// set scheme for children
QObjectList list(children());
Q_FOREACH(QObject *obj, list) {
if (dynamic_cast<ActionGroup*>(obj)) {
((ActionGroup*)obj)->setScheme(scheme);
continue;
}
}
update();
}
}
//void ActionPanel::paintEvent ( QPaintEvent * event )
//{
// //QPainter p(this);
// //p.setOpacity(0.5);
// //p.fillRect(rect(), myScheme->panelBackground);
//}
void ActionPanel::addWidget(QWidget *w)
{
if (w)
layout()->addWidget(w);
if (w) layout()->addWidget(w);
}
void ActionPanel::removeWidget(QWidget *w)
{
if (w)
layout()->removeWidget(w);
if (w) layout()->removeWidget(w);
}
void ActionPanel::addStretch(int s)
void ActionPanel::addStretch(int /*s*/)
{
Q_UNUSED(s);
//((QVBoxLayout*)layout())->addStretch(s);
if (!mySpacer) {
mySpacer = new QSpacerItem(0,0,QSizePolicy::Minimum, QSizePolicy::Expanding);
layout()->addItem(mySpacer);
}
if (!mySpacer) {
mySpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
layout()->addItem(mySpacer);
}
}
void ActionPanel::removeStretch()
{
if (mySpacer) {
layout()->removeItem(mySpacer);
delete mySpacer;
mySpacer = nullptr;
}
if (mySpacer) {
layout()->removeItem(mySpacer);
delete mySpacer;
mySpacer = nullptr;
}
}
ActionGroup * ActionPanel::createGroup()
ActionGroup *ActionPanel::createGroup()
{
ActionGroup * group = new ActionGroup(this);
auto *group = new ActionGroup(this);
addWidget(group);
return group;
}
ActionGroup * ActionPanel::createGroup(const QString &title, bool expandable)
ActionGroup *ActionPanel::createGroup(const QString &title, bool expandable)
{
ActionGroup * box = new ActionGroup(title, expandable, this);
addWidget(box);
return box;
auto *group = new ActionGroup(title, expandable, this);
addWidget(group);
return group;
}
ActionGroup * ActionPanel::createGroup(const QPixmap &icon, const QString &title, bool expandable)
ActionGroup *ActionPanel::createGroup(const QPixmap &icon, const QString &title, bool expandable)
{
ActionGroup * box = new ActionGroup(icon, title, expandable, this);
addWidget(box);
return box;
auto *group = new ActionGroup(icon, title, expandable, this);
addWidget(group);
return group;
}
QSize ActionPanel::minimumSizeHint() const
{
return {200,150};
}
} // namespace QSint
} // namespace
+53 -49
View File
@@ -15,90 +15,94 @@
namespace QSint
{
class ActionPanelScheme;
class ActionGroup;
/**
\brief Class representing panels of actions similar to Windows XP task panels.
\since 0.2
\image html ActionPanel1.png An example of ActionPanel
ActionPanel acts like a container for ActionGroup which in turn are containers for
the actions represented by ActionLabel.
The look and fill is complete styleable via setScheme().
Currently the following schemes available: ActionPanelScheme (the default),
WinXPPanelScheme and WinXPPanelScheme2 (blue Windows XP schemes),
WinVistaPanelScheme (Windows Vista variation), MacPanelScheme (MacOS variation),
AndroidPanelScheme (Android variation).
*/
* @brief Provides a panel of actions, similar to Windows XP task panels.
*
* An ActionPanel contains ActionGroups, which in turn contain actions (represented by ActionLabels).
*/
class QSINT_EXPORT ActionPanel : public QFrame
{
typedef QFrame BaseClass;
using BaseClass = QFrame;
Q_OBJECT
public:
/** Constructor.
*/
/**
* @brief Constructs an ActionPanel.
* @param parent The parent widget.
*/
explicit ActionPanel(QWidget *parent = nullptr);
/** Adds a widget \a w to the ActionPanel's vertical layout.
*/
/**
* @brief Adds a widget to the ActionPanel.
* @param w The widget to add.
*/
void addWidget(QWidget *w);
/** Removes the widget \a w from the ActionPanel's vertical layout.
*/
/**
* @brief Removes a widget from the ActionPanel.
* @param w The widget to remove.
*/
void removeWidget(QWidget *w);
/** Adds a spacer with width \a s to the ActionPanel's vertical layout.
Normally you should do this after all the ActionGroups were added, in order to
maintain some space below.
*/
/**
* @brief Adds a spacer to bottom of the ActionPanel.
* @param s The width of the spacer..
*/
void addStretch(int s = 0);
/** Removes the spacer -- if added -- from the ActionPanel's vertical layout.
*/
/**
* @brief Removes the spacer from the ActionPanel (if one was added).
*/
void removeStretch();
/** Creates and adds to the ActionPanel's vertical layout an empty ActionGroup without header.
*/
/**
* @brief Creates and adds an empty ActionGroup (without a header) to the panel.
* @return The newly created ActionGroup.
*/
ActionGroup* createGroup();
/** Creates and adds to the ActionPanel's vertical layout an empty ActionGroup with header's
text set to \a title, but with no icon.
If \a expandable set to \a true (default), the group can be expanded/collapsed by the user.
*/
/**
* @brief Creates and adds an ActionGroup (with a header) to the panel.
* @param title The title of the group's header.
* @param expandable If `true` (default), the group can be expanded/collapsed.
* @return The newly created ActionGroup.
*/
ActionGroup* createGroup(const QString &title, bool expandable = true);
/** Creates and adds to the ActionPanel's vertical layout an empty ActionGroup with header's
text set to \a title and icon set to \a icon.
If \a expandable set to \a true (default), the group can be expanded/collapsed by the user.
*/
/**
* @brief Creates and adds an ActionGroup (with a header) to the panel.
* @param icon The icon for the group's header.
* @param title The title of the group's header.
* @param expandable If `true` (default), the group can be expanded/collapsed.
* @return The newly created ActionGroup.
*/
ActionGroup* createGroup(const QPixmap &icon, const QString &title, bool expandable = true);
/** Sets the scheme of the panel and all the child groups to \a scheme.
By default, ActionPanelScheme::defaultScheme() is used.
*/
/**
* @brief Sets the color scheme for the panel and its child groups.
* @param scheme The new scheme to use. Defaults to `ActionPanelScheme::defaultScheme()`
* if not set.
*/
void setScheme(ActionPanelScheme *scheme);
/**
* @brief Returns the recommended minimum size for the panel.
* @return The minimum size hint.
*/
QSize minimumSizeHint() const override;
protected:
//virtual void paintEvent ( QPaintEvent * event );
/** @brief The color scheme used by the panel. */
ActionPanelScheme *myScheme;
/** @brief The spacer used for bottom spacing. */
QSpacerItem *mySpacer;
};
} // namespace
#endif // ACTIONPANEL_H
+114 -86
View File
@@ -8,122 +8,131 @@
#include "actionpanelscheme.h"
class StaticLibInitializer
{
public:
StaticLibInitializer()
{
Q_INIT_RESOURCE(schemes);
}
};
StaticLibInitializer staticLibInitializer;
namespace QSint
{
const char* ActionPanelDefaultStyle =
"QFrame[class='panel'] {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #99cccc, stop: 1 #EAF7FF);"
"}"
const QString ActionPanelScheme::minimumStyle = QStringLiteral(
"QSint--ActionGroup QFrame[class='header'] {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);"
"border: 1px solid #00aa99;"
"border-bottom: 1px solid #99cccc;"
"border-top-left-radius: 3px;"
"border-top-right-radius: 3px;"
"}"
"QSint--ActionGroup QFrame[class='header']:hover {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EAF7FF, stop: 1 #F9FDFF);"
"border: none;"
"}"
"QSint--ActionGroup QToolButton[class='header'] {"
"text-align: left;"
"font: 14px;"
"color: #006600;"
"background-color: transparent;"
"border: 1px solid transparent;"
"}"
"QSint--ActionGroup QToolButton[class='header']:hover {"
"color: #00cc00;"
"text-decoration: underline;"
"}"
"QSint--ActionGroup QFrame[class='content'] {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);"
"border: 1px solid #00aa99;"
"}"
"QSint--ActionGroup QFrame[class='content'][header='true'] {"
"border-top: none;"
"border: none;"
"font-weight: bold;"
"text-align: center;"
"background: none;"
"}"
"QSint--ActionGroup QToolButton[class='action'] {"
"background-color: transparent;"
"border: 1px solid transparent;"
"color: #0033ff;"
"text-align: left;"
"font: 11px;"
"}"
"QSint--ActionGroup QToolButton[class='action']:!enabled {"
"color: #999999;"
"border: none;"
"background: none;"
"}"
"QSint--ActionGroup QToolButton[class='action']:hover {"
"color: #0099ff;"
"text-decoration: underline;"
"}"
"QSint--ActionGroup QToolButton[class='action']:focus {"
"border: 1px dotted black;"
"QSint--ActionGroup QFrame[class='content'][header='true'] {"
"border: none;"
"}"
"QSint--ActionGroup QToolButton[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
);
// set a QGroupBox to avoid that the OS style is used, see
// https://github.com/FreeCAD/FreeCAD/issues/6102
// the px values are taken from Behave-dark.qss, except the padding
"QSint--ActionGroup QFrame[class='content'] QGroupBox {"
"border: 1px solid #bbbbbb;"
"border-radius: 3px;"
"margin-top: 10px;"
"padding: 2px;"
"}"
// since we set a custom frame we also need to set the title
"QSint--ActionGroup QFrame[class='content'] QGroupBox::title {"
"padding-left: 3px;"
"top: -6px;"
"left: 12px;"
"}"
;
QString ActionPanelScheme::systemStyle(const QPalette& p)
{
const QColor& highlightColor = p.color(QPalette::Highlight);
QColor headerBackground = highlightColor.darker(150);
const QColor& groupBackground = p.color(QPalette::Button);
QHash<QString, QString> replacements;
replacements["headerBackground"] = headerBackground.name();
replacements["groupBackground"] = groupBackground.name();;
QString style = QStringLiteral(
"QSint--ActionGroup QFrame[class='header'] {"
"background-color: {headerBackground};"
"}"
"QSint--ActionGroup QFrame[class='content'] {"
"background-color: {groupBackground};"
"}"
);
for (auto it = replacements.begin(); it != replacements.end(); ++it) {
style.replace("{" + it.key() + "}", it.value());
}
return style;
}
QPixmap ActionPanelScheme::drawFoldIcon(const QPalette& palette, bool fold, bool hover) const
{
QSize bSize = headerButtonSize;
QImage img(bSize.width(), bSize.height(), QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);
QPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing);
qreal penWidth = bSize.width() / 14.0;
qreal lef_X = 0.25 * bSize.width();
qreal mid_X = 0.50 * bSize.width();
qreal rig_X = 0.75 * bSize.width();
qreal bot_Y = 0.40 * bSize.height();
qreal top_Y = 0.64 * bSize.height();
if (hover) {
penWidth *= 1.8;
}
painter.setBrush(Qt::NoBrush);
painter.setPen(QPen(palette.color(QPalette::HighlightedText), penWidth));
QPolygon chevron;
if (fold) {
// Upward
chevron << QPoint(lef_X, top_Y)
<< QPoint(mid_X, bot_Y)
<< QPoint(rig_X, top_Y);
} else {
// Downward
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);
}
ActionPanelScheme::ActionPanelScheme()
{
headerSize = 28;
QFontMetrics fm(QApplication::font());
headerSize = fm.height() + 10;
headerAnimation = true;
headerButtonFold = QPixmap(":/default/Fold.png");
headerButtonFoldOver = QPixmap(":/default/FoldOver.png");
headerButtonUnfold = QPixmap(":/default/Unfold.png");
headerButtonUnfoldOver = QPixmap(":/default/UnfoldOver.png");
headerButtonSize = QSize(18,18);
QPalette p = QApplication::palette();
groupFoldSteps = 20; groupFoldDelay = 15;
headerButtonSize = QSize(16, 16);
headerButtonFold = drawFoldIcon(p, true, false);
headerButtonFoldOver = drawFoldIcon(p, true, true);
headerButtonUnfold = drawFoldIcon(p, false, false);
headerButtonUnfoldOver = drawFoldIcon(p, false, true);
builtinFold = headerButtonFold;
builtinFoldOver = headerButtonFoldOver;
builtinUnfold = headerButtonUnfold;
builtinUnfoldOver = headerButtonUnfoldOver;
groupFoldSteps = 20;
groupFoldDelay = 15;
groupFoldEffect = NoFolding;
groupFoldThaw = true;
actionStyle = QString(ActionPanelDefaultStyle);
actionStyle = minimumStyle + systemStyle(p);
builtinScheme = actionStyle;
}
ActionPanelScheme* ActionPanelScheme::defaultScheme()
@@ -132,5 +141,24 @@ ActionPanelScheme* ActionPanelScheme::defaultScheme()
return &scheme;
}
void ActionPanelScheme::clearActionStyle()
{
headerButtonFold = QPixmap();
headerButtonFoldOver = QPixmap();
headerButtonUnfold = QPixmap();
headerButtonUnfoldOver = QPixmap();
actionStyle = minimumStyle;
}
void ActionPanelScheme::restoreActionStyle()
{
headerButtonFold = builtinFold;
headerButtonFoldOver = builtinFoldOver;
headerButtonUnfold = builtinUnfold;
headerButtonUnfoldOver = builtinUnfoldOver;
actionStyle = builtinScheme;
}
} // namespace QSint
+129 -53
View File
@@ -5,79 +5,155 @@
* *
***************************************************************************/
#ifndef TASKPANELSCHEME_H
#define TASKPANELSCHEME_H
#ifndef ACTIONPANELSCHEME_H
#define ACTIONPANELSCHEME_H
#include <QPixmap>
#include <QSize>
#include <QString>
#include "qsint_global.h"
#include <QApplication>
#include <QImage>
#include <QPainter>
#include <QPalette>
#include <QPixmap>
#include <QHash>
#include <QSize>
#include <QString>
#include <QStyle>
#include <QFontMetrics>
namespace QSint
{
/**
\brief Class representing color scheme for ActionPanel and ActionGroup.
\since 0.2
\image html ActionPanel1.png Default ActionPanel scheme
*/
* @brief Provides a color scheme and layout parameters for ActionPanel and ActionGroup widgets.
*
* ActionPanels group related actions, and ActionGroups organize actions within a panel.
* This class defines the visual appearance and behavior (e.g., folding animation) of these components.
*/
class QSINT_EXPORT ActionPanelScheme
{
public:
/** \enum TaskPanelFoldEffect
\brief Animation effect during expanding/collapsing of the ActionGroup's contents.
*/
enum TaskPanelFoldEffect
/**
* @brief Animation effect used when expanding or collapsing an ActionGroup's contents.
*/
enum FoldEffect
{
/// No folding effect
NoFolding,
/// Folding by scaling group's contents
ShrunkFolding,
/// Folding by sliding group's contents
SlideFolding
NoFolding, ///< No folding animation.
ShrunkFolding, ///< Contents shrink to a point during folding.
SlideFolding ///< Contents slide in and out during folding.
};
/**
* @brief Constructs a default ActionPanelScheme.
*/
ActionPanelScheme();
ActionPanelScheme();
/**
* @brief Returns a pointer to the default ActionPanelScheme object.
* Derived classes can override this to provide a custom default scheme.
* @return A pointer to the default ActionPanelScheme.
*/
static ActionPanelScheme* defaultScheme();
/** Returns a pointer to the default scheme object.
Must be reimplemented in the own schemes.
*/
static ActionPanelScheme* defaultScheme();
/**
* @brief Height of the header area in pixels.
*/
int headerSize;
/// Height of the header in pixels.
int headerSize;
/// If set to \a true, moving mouse over the header results in changing its opacity slowly.
bool headerAnimation;
/**
* @brief Whether mouseover on the header triggers a slow opacity change.
*/
bool headerAnimation;
/// Image of folding button when the group is expanded.
QPixmap headerButtonFold;
/// Image of folding button when the group is expanded and mouse cursor is over the button.
QPixmap headerButtonFoldOver;
/// Image of folding button when the group is collapsed.
QPixmap headerButtonUnfold;
/// Image of folding button when the group is collapsed and mouse cursor is over the button.
QPixmap headerButtonUnfoldOver;
/**
* @brief Image of the folding button when the group is expanded.
*/
QPixmap headerButtonFold;
/**
* @brief Image of the folding button when the group is expanded and the mouse is over it.
*/
QPixmap headerButtonFoldOver;
/**
* @brief Image of the folding button when the group is collapsed.
*/
QPixmap headerButtonUnfold;
/**
* @brief Image of the folding button when the group is collapsed and the mouse is over it.
*/
QPixmap headerButtonUnfoldOver;
QSize headerButtonSize;
/**
* @brief Size of the header button.
*/
QSize headerButtonSize;
/// Number of steps made for expanding/collapsing animation (default 20).
int groupFoldSteps;
/// Delay in ms between steps made for expanding/collapsing animation (default 15).
int groupFoldDelay;
/// Sets folding effect during expanding/collapsing.
TaskPanelFoldEffect groupFoldEffect;
/// If set to \a true, changes group's opacity slowly during expanding/collapsing.
bool groupFoldThaw;
/**
* @brief Number of steps in the expanding/collapsing animation (default: 20).
*/
int groupFoldSteps;
/// The CSS for the ActionPanel/ActionGroup elements.
QString actionStyle;
/**
* @brief Delay in milliseconds between animation steps (default: 15).
*/
int groupFoldDelay;
/**
* @brief Folding effect used during expanding/collapsing.
*/
FoldEffect groupFoldEffect;
/**
* @brief Whether the group's opacity changes slowly during folding.
*/
bool groupFoldThaw;
/**
* @brief CSS style for ActionPanel/ActionGroup elements.
*/
QString actionStyle;
/**
* @brief Clears the custom action style, resetting to a minimal style.
*/
void clearActionStyle();
/**
* @brief Restores the original action style.
*/
void restoreActionStyle();
/**
* @brief Minimal CSS style.
*/
static const QString minimumStyle;
/**
* @brief Generates a custom system style based on the palette.
* @param p The palette to use for generating the style.
* @return The generated style.
*/
QString systemStyle(const QPalette& p);
protected:
/**
* @brief Draws a fold/unfold icon.
* @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 The icon as a QPixmap.
*/
QPixmap drawFoldIcon(const QPalette& p, bool fold, bool hover) const;
private:
/**
* @brief Stores the built-in icons for restoration.
*/
QPixmap builtinFold;
QPixmap builtinFoldOver;
QPixmap builtinUnfold;
QPixmap builtinUnfoldOver;
QString builtinScheme;
};
} // namespace QSint
}
#endif // TASKPANELSCHEME_H
#endif // ACTIONPANELSCHEME_H
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

@@ -1,82 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#include "androidpanelscheme.h"
namespace QSint
{
const char* ActionPanelAndroidStyle =
"QFrame[class='panel'] {"
"background-color: #424242;"
"color: #ffffff;"
"font-size: 10px;"
"}"
"QSint--ActionGroup QFrame[class='header'] {"
"background-color: #171717;"
"border-top: 1px solid white;"
"border-bottom: 1px solid white;"
"color: #ffffff;"
"}"
"QSint--ActionGroup QToolButton[class='header'] {"
"text-align: left;"
"color: #ffffff;"
"background-color: transparent;"
"border: 1px solid transparent;"
"font-size: 14px;"
"}"
"QSint--ActionGroup QFrame[class='content'] {"
"background-color: #171717;"
"}"
"QSint--ActionGroup QToolButton[class='action'] {"
"background-color: transparent;"
"border: 1px solid transparent;"
"color: #ffffff;"
"text-align: left;"
"font-size: 14px;"
"min-height: 32px;"
"}"
"QSint--ActionGroup QToolButton[class='action']:!enabled {"
"color: #666666;"
"}"
"QSint--ActionGroup QToolButton[class='action']:focus {"
"border: 1px dotted black;"
"}"
"QSint--ActionGroup QToolButton[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
AndroidPanelScheme::AndroidPanelScheme() : ActionPanelScheme()
{
headerSize = 40;
headerButtonFold = QPixmap(":/android/Fold.png");
headerButtonFoldOver = QPixmap(":/android/FoldOver.png");
headerButtonUnfold = QPixmap(":/android/Unfold.png");
headerButtonUnfoldOver = QPixmap(":/android/UnfoldOver.png");
headerButtonSize = QSize(33,33);
actionStyle = QString(ActionPanelAndroidStyle);
}
}
@@ -1,40 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#ifndef ANDROIDPANELSCHEME_H
#define ANDROIDPANELSCHEME_H
#include "actionpanelscheme.h"
namespace QSint
{
/**
\brief Android-like color scheme for ActionPanel and ActionGroup.
\since 0.2.1
\image html ActionPanel5.png Example of the scheme
*/
class QSINT_EXPORT AndroidPanelScheme : public ActionPanelScheme
{
public:
AndroidPanelScheme();
static ActionPanelScheme* defaultScheme()
{
static AndroidPanelScheme scheme;
return &scheme;
}
};
}
#endif // ANDROIDPANELSCHEME_H
Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

-351
View File
@@ -1,351 +0,0 @@
/***************************************************************************
* Copyright (c) 2015 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 "winvistapanelscheme.h"
#include "winxppanelscheme.h"
#include <QApplication>
#include <QImage>
#include <QPainter>
#include <QPalette>
#include <QHash>
namespace QSint
{
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));"
"}"
"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;"
"text-decoration: underline;"
"}"
"QSint--ActionGroup QToolButton[class='action']:focus {"
"border: 1px dotted black;"
"}"
"QSint--ActionGroup QToolButton[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
// set a QGroupBox to avoid that the OS style is used, see
// https://github.com/FreeCAD/FreeCAD/issues/6102
// the px values are taken from Behave-dark.qss, except the padding
"QSint--ActionGroup QFrame[class='content'] QGroupBox {"
"border: 1px solid #bbbbbb;"
"border-radius: 3px;"
"margin-top: 10px;"
"padding: 2px;"
"}"
// since we set a custom frame we also need to set the title
"QSint--ActionGroup QFrame[class='content'] QGroupBox::title {"
"padding-left: 3px;"
"top: -6px;"
"left: 12px;"
"}"
;
const char* MinimumActionPanelFreeCAD =
"QSint--ActionGroup QToolButton[class='header'] {"
"text-align: left;"
"background-color: transparent;"
"border: 1px solid transparent;"
"font-weight: bold;"
"}"
"QSint--ActionGroup QToolButton[class='action'] {"
"background-color: transparent;"
"border: 1px solid transparent;"
"text-align: left;"
"}"
"QSint--ActionGroup QToolButton[class='action']:hover {"
"text-decoration: underline;"
"}"
;
FreeCADPanelScheme::FreeCADPanelScheme() : ActionPanelScheme()
{
#if defined(Q_OS_WIN32)
ActionPanelScheme* panelStyle = WinXPPanelScheme2::defaultScheme();
actionStyle = QString(ActionPanelFreeCAD);
#elif defined(Q_OS_MACOS)
ActionPanelScheme* panelStyle = MacPanelScheme::defaultScheme();
actionStyle = panelStyle->actionStyle;
#elif defined(Q_OS_LINUX)
ActionPanelScheme* panelStyle = SystemPanelScheme::defaultScheme();
actionStyle = panelStyle->actionStyle;
#else
ActionPanelScheme* panelStyle = ActionPanelScheme::defaultScheme();
actionStyle = panelStyle->actionStyle;
#endif
builtinScheme = actionStyle;
minimumStyle = QString(MinimumActionPanelFreeCAD);
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;
builtinFold = headerButtonFold;
builtinFoldOver = headerButtonFoldOver;
builtinUnfold = headerButtonUnfold;
builtinUnfoldOver = headerButtonUnfoldOver;
}
void FreeCADPanelScheme::clearActionStyle()
{
headerButtonFold = QPixmap();
headerButtonFoldOver = QPixmap();
headerButtonUnfold = QPixmap();
headerButtonUnfoldOver = QPixmap();
actionStyle = minimumStyle;
}
void FreeCADPanelScheme::restoreActionStyle()
{
headerButtonFold = builtinFold;
headerButtonFoldOver = builtinFoldOver;
headerButtonUnfold = builtinUnfold;
headerButtonUnfoldOver = builtinUnfoldOver;
actionStyle = builtinScheme;
}
// -----------------------------------------------------
SystemPanelScheme::SystemPanelScheme()
{
headerSize = 25;
headerAnimation = true;
QPalette p = QApplication::palette();
headerButtonFold = drawFoldIcon(p, true, false);
headerButtonFoldOver = drawFoldIcon(p, true, true);
headerButtonUnfold = drawFoldIcon(p, false, false);
headerButtonUnfoldOver = drawFoldIcon(p, false, true);
headerButtonSize = QSize(17,17);
groupFoldSteps = 20;
groupFoldDelay = 15;
groupFoldEffect = NoFolding;
groupFoldThaw = true;
actionStyle = systemStyle(QApplication::palette());
}
QPixmap SystemPanelScheme::drawFoldIcon(const QPalette& palette, bool fold, bool hover) const
{
QSize bSize = headerButtonSize;
QImage img(bSize.width(), bSize.height(), QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);
QPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing);
qreal penWidth = bSize.width() / 14.0;
qreal lef_X = 0.25 * bSize.width();
qreal mid_X = 0.50 * bSize.width();
qreal rig_X = 0.75 * bSize.width();
qreal bot_Y = 0.40 * bSize.height();
qreal top_Y = 0.64 * bSize.height();
if (hover) {
penWidth *= 1.8;
}
painter.setBrush(Qt::NoBrush);
painter.setPen(QPen(palette.color(QPalette::HighlightedText), penWidth));
QPolygon chevron;
if (fold) {
// Upward
chevron << QPoint(lef_X, top_Y)
<< QPoint(mid_X, bot_Y)
<< QPoint(rig_X, top_Y);
} else {
// Downward
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;
replacements.insert(QStringLiteral("headerBackground"),
p.color(QPalette::Highlight).name());
replacements.insert(QStringLiteral("headerLabelText"),
p.color(QPalette::HighlightedText).name());
replacements.insert(QStringLiteral("headerLabelTextOver"),
p.color(QPalette::BrightText).name());
replacements.insert(QStringLiteral("groupBorder"),
p.color(QPalette::Mid).name());
replacements.insert(QStringLiteral("disabledActionText"),
p.color(QPalette::Disabled, QPalette::Text).name());
replacements.insert(QStringLiteral("actionSelectedBg"),
p.color(QPalette::Active, QPalette::Light).name());
replacements.insert(QStringLiteral("actionSelectedText"),
p.color(QPalette::Active, QPalette::ButtonText).name());
replacements.insert(QStringLiteral("actionSelectedBorder"),
p.color(QPalette::Active, QPalette::Highlight).name());
replacements.insert(QStringLiteral("panelBackground"),
p.color(QPalette::Window).name());
replacements.insert(QStringLiteral("groupBackground"),
p.color(QPalette::Button).name());
QString style = QStringLiteral(
"QFrame[class='panel'] {"
"background-color: {panelBackground};"
"}"
"QSint--ActionGroup QFrame[class='header'] {"
"border: 1px solid transparent;"
"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 {"
"color: {headerLabelTextOver};"
"}"
"QSint--ActionGroup QFrame[class='content'] {"
"border: 1px solid {groupBorder};"
"background-color: {groupBackground};"
"}"
"QSint--ActionGroup QFrame[class='content'][header='true'] {"
"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};"
"}"
"QSint--ActionGroup QToolButton[class='action']:on {"
"background-color: {actionSelectedBg};"
"color: {actionSelectedText};"
"}"
);
for (auto it = replacements.begin(); it != replacements.end(); ++it) {
style.replace("{" + it.key() + "}", it.value());
}
return style;
}
}
-75
View File
@@ -1,75 +0,0 @@
/***************************************************************************
* Copyright (c) 2015 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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:
QString builtinScheme;
QString minimumStyle;
QPixmap builtinFold;
QPixmap builtinFoldOver;
QPixmap builtinUnfold;
QPixmap builtinUnfoldOver;
};
class QSINT_EXPORT SystemPanelScheme : public ActionPanelScheme
{
public:
explicit SystemPanelScheme();
static ActionPanelScheme* defaultScheme()
{
static SystemPanelScheme scheme;
return &scheme;
}
private:
QPixmap drawFoldIcon(const QPalette& p, bool fold, bool hover) const;
QString systemStyle(const QPalette& p) const;
};
}
#endif // IISFREECADTASKPANELSCHEME_H
Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 685 B

@@ -1,73 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#include "macpanelscheme.h"
namespace QSint
{
const char* MacPanelStyle =
"QFrame[class='panel'] {"
"background-color: #D9DEE5;"
"border: 1px solid #BBBBBB;"
"}"
"QSint--ActionGroup QFrame[class='header'] {"
"border: none;"
"}"
"QSint--ActionGroup QToolButton[class='header'] {"
"text-align: left;"
"color: #828CA8;"
"background-color: transparent;"
"font-weight: bold;"
"}"
"QSint--ActionGroup QFrame[class='content'] {"
"background-color: #D9DEE5;"
"margin-left: 12px;"
"}"
"QSint--ActionGroup QToolButton[class='action'] {"
"color: #000000;"
"text-align: left;"
"background-color: transparent;"
"border: 1px solid transparent;"
"}"
"QSint--ActionGroup QToolButton[class='action']:!enabled {"
"color: #ffffff;"
"}"
"QSint--ActionGroup QToolButton[class='action']:focus {"
"border: 1px solid #1E6CBB;"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6FA6DE, stop: 1 #1E6CBB);"
"color: #ffffff;"
"}"
"QSint--ActionGroup QToolButton[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
MacPanelScheme::MacPanelScheme() : ActionPanelScheme()
{
actionStyle = QString(MacPanelStyle);
headerButtonFold = QPixmap();
headerButtonFoldOver = QPixmap(":/mac/FoldOver.png");
headerButtonUnfold = QPixmap();
headerButtonUnfoldOver = QPixmap(":/mac/UnfoldOver.png");
headerButtonSize = QSize(30,16);
}
}
@@ -1,39 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#ifndef MACPANELSCHEME_H
#define MACPANELSCHEME_H
#include "actionpanelscheme.h"
namespace QSint
{
/**
\brief MacOS-like color scheme for ActionPanel and ActionGroup.
\since 0.2
\image html ActionPanel6.png Example of the scheme
*/
class QSINT_EXPORT MacPanelScheme : public ActionPanelScheme
{
public:
explicit MacPanelScheme();
static ActionPanelScheme* defaultScheme()
{
static MacPanelScheme scheme;
return &scheme;
}
};
}
#endif // MACPANELSCHEME_H
-26
View File
@@ -1,26 +0,0 @@
<RCC>
<qresource prefix="/">
<file>default/Fold.png</file>
<file>default/FoldOver.png</file>
<file>default/Unfold.png</file>
<file>default/UnfoldOver.png</file>
<file>xp/Fold_Blue1.png</file>
<file>xp/Fold_Blue2.png</file>
<file>xp/FoldOver_Blue1.png</file>
<file>xp/FoldOver_Blue2.png</file>
<file>xp/Unfold_Blue1.png</file>
<file>xp/Unfold_Blue2.png</file>
<file>xp/UnfoldOver_Blue1.png</file>
<file>xp/UnfoldOver_Blue2.png</file>
<file>vista/Fold.png</file>
<file>vista/FoldOver.png</file>
<file>vista/Unfold.png</file>
<file>vista/UnfoldOver.png</file>
<file>mac/FoldOver.png</file>
<file>mac/UnfoldOver.png</file>
<file>android/Fold.png</file>
<file>android/Unfold.png</file>
<file>android/FoldOver.png</file>
<file>android/UnfoldOver.png</file>
</qresource>
</RCC>
+6 -33
View File
@@ -22,8 +22,6 @@ TaskGroup::TaskGroup(QWidget *parent, bool hasHeader)
setProperty("class", "content");
setProperty("header", hasHeader ? "true" : "false");
setScheme(ActionPanelScheme::defaultScheme());
QVBoxLayout *vbl = new QVBoxLayout();
vbl->setContentsMargins(4, 4, 4, 4);
vbl->setSpacing(0);
@@ -32,35 +30,22 @@ TaskGroup::TaskGroup(QWidget *parent, bool hasHeader)
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
}
void TaskGroup::setScheme(ActionPanelScheme *scheme)
{
if (scheme) {
myScheme = scheme;
setStyleSheet(myScheme->actionStyle);
update();
}
}
bool TaskGroup::addActionLabel(ActionLabel *label, bool addToLayout, bool addStretch)
{
if (!label)
if (!label) {
return false;
label->setStyleSheet("");
}
return addWidget(label, addToLayout, addStretch);
}
bool TaskGroup::addWidget(QWidget *widget, bool addToLayout, bool addStretch)
{
if (!widget)
if (!widget) {
return false;
if (!addToLayout)
}
if (!addToLayout) {
return true;
}
if (addStretch) {
QHBoxLayout *hbl = new QHBoxLayout();
hbl->setContentsMargins(0, 0, 0, 0);
@@ -87,18 +72,6 @@ QPixmap TaskGroup::transparentRender()
return pm;
}
void TaskGroup::paintEvent ( QPaintEvent * event )
{
// QPainter p(this);
// p.setBrush(myScheme->groupBackground);
// p.setPen(myScheme->groupBorder);
// p.drawRect(rect().adjusted(0,-(int)myHasHeader,-1,-1));
BaseClass::paintEvent(event);
}
void TaskGroup::keyPressEvent ( QKeyEvent * event )
{
switch (event->key())
+1 -4
View File
@@ -21,13 +21,11 @@ namespace QSint
class TaskGroup : public QFrame
{
typedef QFrame BaseClass;
using BaseClass = QFrame;
public:
TaskGroup(QWidget *parent, bool hasHeader = false);
void setScheme(ActionPanelScheme *scheme);
inline QBoxLayout* groupLayout()
{
return (QBoxLayout*)layout();
@@ -40,7 +38,6 @@ public:
QPixmap transparentRender();
protected:
void paintEvent ( QPaintEvent * event ) override;
void keyPressEvent ( QKeyEvent * event ) override;
void keyReleaseEvent ( QKeyEvent * event ) override;
+25 -31
View File
@@ -19,7 +19,6 @@
namespace QSint
{
TaskHeader::TaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent)
: BaseClass(parent),
myExpandable(expandable),
@@ -40,7 +39,7 @@ TaskHeader::TaskHeader(const QIcon &icon, const QString &title, bool expandable,
connect(myTitle, &ActionLabel::clicked, this, &TaskHeader::fold);
QHBoxLayout *hbl = new QHBoxLayout();
hbl->setContentsMargins(2, 2, 2, 2);
hbl->setContentsMargins(4, 2, 8, 2);
setLayout(hbl);
hbl->addWidget(myTitle);
@@ -48,7 +47,6 @@ TaskHeader::TaskHeader(const QIcon &icon, const QString &title, bool expandable,
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
setScheme(ActionPanelScheme::defaultScheme());
//myTitle->setSchemePointer(&myLabelScheme);
setExpandable(myExpandable);
}
@@ -58,9 +56,9 @@ void TaskHeader::setExpandable(bool expandable)
if (expandable) {
myExpandable = true;
if (myButton)
if (myButton) {
return;
}
myButton = new QLabel(this);
myButton->installEventFilter(this);
myButton->setFixedSize(myScheme->headerButtonSize);
@@ -71,9 +69,9 @@ void TaskHeader::setExpandable(bool expandable)
} else {
myExpandable = false;
if (!myButton)
if (!myButton) {
return;
}
myButton->removeEventFilter(this);
myButton->setParent(nullptr);
delete myButton;
@@ -86,8 +84,9 @@ bool TaskHeader::eventFilter(QObject *obj, QEvent *event)
{
switch (event->type()) {
case QEvent::MouseButtonPress:
if (myExpandable)
if (myExpandable) {
fold();
}
return true;
case QEvent::Enter:
@@ -110,16 +109,10 @@ void TaskHeader::setScheme(ActionPanelScheme *scheme)
{
if (scheme) {
myScheme = scheme;
//myLabelScheme = &(scheme->headerLabelScheme);
setStyleSheet(myScheme->actionStyle);
if (myExpandable) {
//setCursor(myLabelScheme->cursorOver ? Qt::PointingHandCursor : cursor());
changeIcons();
}
setFixedHeight(scheme->headerSize);
update();
}
}
@@ -128,21 +121,18 @@ void TaskHeader::paintEvent ( QPaintEvent * event )
{
QPainter p(this);
if (myScheme->headerAnimation)
if (myScheme->headerAnimation) {
p.setOpacity(m_opacity+0.7);
// p.setPen(m_over ? myScheme->headerBorderOver : myScheme->headerBorder);
// p.setBrush(m_over ? myScheme->headerBackgroundOver : myScheme->headerBackground);
// myScheme->headerCorners.draw(&p, rect());
}
BaseClass::paintEvent(event);
}
void TaskHeader::animate()
{
if (!myScheme->headerAnimation)
if (!myScheme->headerAnimation) {
return;
}
if (!isEnabled()) {
m_opacity = 0.1;
@@ -176,9 +166,9 @@ void TaskHeader::enterEvent ( QEnterEvent * /*event*/ )
{
m_over = true;
if (isEnabled())
if (isEnabled()) {
QTimer::singleShot(100, this, &TaskHeader::animate);
}
update();
}
@@ -186,9 +176,9 @@ void TaskHeader::leaveEvent ( QEvent * /*event*/ )
{
m_over = false;
if (isEnabled())
if (isEnabled()) {
QTimer::singleShot(100, this, &TaskHeader::animate);
}
update();
}
@@ -217,21 +207,25 @@ void TaskHeader::setFold(bool on)
void TaskHeader::changeIcons()
{
if (!myButton)
if (!myButton) {
return;
}
if (m_buttonOver)
{
if (m_fold)
if (m_fold) {
myButton->setPixmap(myScheme->headerButtonFoldOver);
else
}
else {
myButton->setPixmap(myScheme->headerButtonUnfoldOver);
}
} else
{
if (m_fold)
if (m_fold) {
myButton->setPixmap(myScheme->headerButtonFold);
else
}
else {
myButton->setPixmap(myScheme->headerButtonUnfold);
}
}
myButton->setFixedSize(myScheme->headerButtonSize);
+1 -1
View File
@@ -22,7 +22,7 @@ class TaskHeader : public QFrame
{
Q_OBJECT
typedef QFrame BaseClass;
using BaseClass = QFrame;
friend class ActionGroup;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

@@ -1,93 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#include "winvistapanelscheme.h"
namespace QSint
{
const char* ActionPanelWinVistaStyle =
"QFrame[class='panel'] {"
"background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #416FA6, stop: 1 #6BB86E);"
"}"
"QSint--ActionGroup QFrame[class='header'] {"
"background: transparent;"
"border: 1px solid transparent;"
"}"
"QSint--ActionGroup QFrame[class='header']:hover {"
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(249,253,255,100), stop: 0.5 rgba(234,247,255,20), stop: 1 rgba(249,253,255,100));"
"border: 1px solid transparent;"
"}"
"QSint--ActionGroup QToolButton[class='header'] {"
"text-align: left;"
"color: #ffffff;"
"background-color: transparent;"
"border: 1px solid transparent;"
"font-size: 12px;"
"}"
"QSint--ActionGroup QFrame[class='content'] {"
"background-color: transparent;"
"color: #ffffff;"
"}"
"QSint--ActionGroup QToolButton[class='action'] {"
"background-color: transparent;"
"border: 1px solid transparent;"
"color: #ffffff;"
"text-align: left;"
"}"
"QSint--ActionGroup QToolButton[class='action']:!enabled {"
"color: #666666;"
"}"
"QSint--ActionGroup QToolButton[class='action']:hover {"
"color: #DAF2FC;"
"text-decoration: underline;"
"}"
"QSint--ActionGroup QToolButton[class='action']:focus {"
"border: 1px dotted black;"
"}"
"QSint--ActionGroup QToolButton[class='action']:on {"
"background-color: #ddeeff;"
"color: #006600;"
"}"
;
WinVistaPanelScheme::WinVistaPanelScheme() : ActionPanelScheme()
{
headerSize = 25;
headerAnimation = false;
//headerLabelScheme.iconSize = 22;
headerButtonFold = QPixmap(":/vista/Fold.png");
headerButtonFoldOver = QPixmap(":/vista/FoldOver.png");
headerButtonUnfold = QPixmap(":/vista/Unfold.png");
headerButtonUnfoldOver = QPixmap(":/vista/UnfoldOver.png");
headerButtonSize = QSize(17,17);
groupFoldSteps = 20; groupFoldDelay = 15;
groupFoldThaw = true;
groupFoldEffect = SlideFolding;
actionStyle = QString(ActionPanelWinVistaStyle);
}
}
@@ -1,41 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#ifndef WINVISTAPANELSCHEME_H
#define WINVISTAPANELSCHEME_H
#include "actionpanelscheme.h"
namespace QSint
{
/**
\brief Windows Vista-like color scheme for ActionPanel and ActionGroup.
\since 0.2
\image html ActionPanel4.png Example of the scheme
*/
class QSINT_EXPORT WinVistaPanelScheme : public ActionPanelScheme
{
public:
WinVistaPanelScheme();
static ActionPanelScheme* defaultScheme()
{
static WinVistaPanelScheme scheme;
return &scheme;
}
};
}
#endif // WINVISTAPANELSCHEME_H
@@ -1,177 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#include "winxppanelscheme.h"
namespace QSint
{
const char* ActionPanelWinXPBlueStyle1 =
"QFrame[class='panel'] {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #7ba2e7, stop: 1 #6375d6);"
"}"
"QSint--ActionGroup QFrame[class='header'] {"
"background-color: #225aca;"
"border: 1px solid #225aca;"
"border-top-left-radius: 4px;"
"border-top-right-radius: 4px;"
"}"
"QSint--ActionGroup QToolButton[class='header'] {"
"text-align: left;"
"color: #ffffff;"
"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: #eff3ff;"
"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;"
"}"
;
const char* ActionPanelWinXPBlueStyle2 =
"QFrame[class='panel'] {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #7ba2e7, stop: 1 #6375d6);"
"}"
"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;"
"}"
;
WinXPPanelScheme::WinXPPanelScheme() : ActionPanelScheme()
{
headerSize = 25;
headerAnimation = false;
//headerLabelScheme.iconSize = 22;
headerButtonFold = QPixmap(":/xp/Fold_Blue1.png");
headerButtonFoldOver = QPixmap(":/xp/FoldOver_Blue1.png");
headerButtonUnfold = QPixmap(":/xp/Unfold_Blue1.png");
headerButtonUnfoldOver = QPixmap(":/xp/UnfoldOver_Blue1.png");
headerButtonSize = QSize(17,17);
groupFoldSteps = 20; groupFoldDelay = 15;
groupFoldThaw = true;
groupFoldEffect = SlideFolding;
actionStyle = QString(ActionPanelWinXPBlueStyle1);
}
WinXPPanelScheme2::WinXPPanelScheme2() : ActionPanelScheme()
{
headerSize = 25;
headerAnimation = false;
// headerLabelScheme.iconSize = 22;
headerButtonFold = QPixmap(":/xp/Fold_Blue2.png");
headerButtonFoldOver = QPixmap(":/xp/FoldOver_Blue2.png");
headerButtonUnfold = QPixmap(":/xp/Unfold_Blue2.png");
headerButtonUnfoldOver = QPixmap(":/xp/UnfoldOver_Blue2.png");
headerButtonSize = QSize(17,17);
groupFoldSteps = 20; groupFoldDelay = 15;
groupFoldThaw = true;
groupFoldEffect = SlideFolding;
actionStyle = QString(ActionPanelWinXPBlueStyle2);
}
}
@@ -1,57 +0,0 @@
/***************************************************************************
* *
* Copyright: https://code.google.com/p/qsint/ *
* License: LGPL *
* *
***************************************************************************/
#ifndef WinXPPanelScheme_H
#define WinXPPanelScheme_H
#include "actionpanelscheme.h"
namespace QSint
{
/**
\brief WindowsXP-like blue color scheme for ActionPanel and ActionGroup.
\since 0.2
\image html ActionPanel2.png Example of the scheme
*/
class QSINT_EXPORT WinXPPanelScheme : public ActionPanelScheme
{
public:
WinXPPanelScheme();
static ActionPanelScheme* defaultScheme()
{
static WinXPPanelScheme scheme;
return &scheme;
}
};
/**
\brief WindowsXP-like blue color scheme for ActionPanel and ActionGroup (variation 2).
\since 0.2
\image html ActionPanel3.png Example of the scheme
*/
class QSINT_EXPORT WinXPPanelScheme2 : public ActionPanelScheme
{
public:
WinXPPanelScheme2();
static ActionPanelScheme* defaultScheme()
{
static WinXPPanelScheme2 scheme;
return &scheme;
}
};
}
#endif // WinXPPanelScheme_H
Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 779 B

-4
View File
@@ -3,7 +3,3 @@
#include "../actionpanel/actiongroup.h"
#include "../actionpanel/actionpanel.h"
#include "../actionpanel/actionpanelscheme.h"
#include "../actionpanel/winxppanelscheme.h"
#include "../actionpanel/winvistapanelscheme.h"
#include "../actionpanel/macpanelscheme.h"
#include "../actionpanel/androidpanelscheme.h"
+8 -8
View File
@@ -47,7 +47,7 @@
#include <Gui/QSint/actionpanel/taskgroup_p.h>
#include <Gui/QSint/actionpanel/taskheader_p.h>
#include <Gui/QSint/actionpanel/freecadscheme.h>
#include <Gui/QSint/actionpanel/actionpanelscheme.h>
using namespace Gui::TaskView;
@@ -279,7 +279,7 @@ TaskView::TaskView(QWidget *parent)
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(taskPanel->sizePolicy().hasHeightForWidth());
taskPanel->setSizePolicy(sizePolicy);
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
taskPanel->setScheme(QSint::ActionPanelScheme::defaultScheme());
this->setWidget(taskPanel);
setWidgetResizable(true);
@@ -603,7 +603,7 @@ void TaskView::showDialog(TaskDialog *dlg)
taskPanel->addWidget(ActiveCtrl);
}
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
taskPanel->setScheme(QSint::ActionPanelScheme::defaultScheme());
if (!dlg->needsFullSpace())
taskPanel->addStretch();
@@ -764,7 +764,7 @@ void TaskView::addTaskWatcher()
}
#endif
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
taskPanel->setScheme(QSint::ActionPanelScheme::defaultScheme());
}
void TaskView::saveCurrentWidth()
@@ -870,14 +870,14 @@ void TaskView::clicked (QAbstractButton * button)
void TaskView::clearActionStyle()
{
static_cast<QSint::FreeCADPanelScheme*>(QSint::FreeCADPanelScheme::defaultScheme())->clearActionStyle();
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
static_cast<QSint::ActionPanelScheme*>(QSint::ActionPanelScheme::defaultScheme())->clearActionStyle();
taskPanel->setScheme(QSint::ActionPanelScheme::defaultScheme());
}
void TaskView::restoreActionStyle()
{
static_cast<QSint::FreeCADPanelScheme*>(QSint::FreeCADPanelScheme::defaultScheme())->restoreActionStyle();
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
static_cast<QSint::ActionPanelScheme*>(QSint::ActionPanelScheme::defaultScheme())->restoreActionStyle();
taskPanel->setScheme(QSint::ActionPanelScheme::defaultScheme());
}