From f14b71d3744bdbf2e0a909f4b2ebe868f4b51ceb Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 7 Jul 2015 12:34:20 +0200 Subject: [PATCH] + usage of QSint --- src/Gui/CombiView.cpp | 9 ++- src/Gui/Control.cpp | 1 + src/Gui/TaskView/TaskDialogPython.cpp | 1 + src/Gui/TaskView/TaskView.cpp | 93 +++++++++++++++++++++++++++ src/Gui/TaskView/TaskView.h | 62 +++++++++++++++++- src/Gui/Workbench.cpp | 4 ++ src/Mod/Mesh/Gui/DlgSmoothing.cpp | 4 ++ 7 files changed, 168 insertions(+), 6 deletions(-) diff --git a/src/Gui/CombiView.cpp b/src/Gui/CombiView.cpp index 29f08572a9..5d5c1ce016 100644 --- a/src/Gui/CombiView.cpp +++ b/src/Gui/CombiView.cpp @@ -22,6 +22,9 @@ #include "PreCompiled.h" +#ifndef _PreComp_ +# include +#endif /// Here the FreeCAD includes sorted by Base,App,Gui...... @@ -75,11 +78,11 @@ CombiView::CombiView(Gui::Document* pcDocument, QWidget *parent) // task panel taskPanel = new Gui::TaskView::TaskView(this); - tabs->addTab(taskPanel, trUtf8("Tasks")); - + tabs->addTab(taskPanel, trUtf8("Tasks")); + // task panel //projectView = new Gui::ProjectWidget(this); - //tabs->addTab(projectView, trUtf8("Project")); + //tabs->addTab(projectView, trUtf8("Project")); } CombiView::~CombiView() diff --git a/src/Gui/Control.cpp b/src/Gui/Control.cpp index 9488fffa3c..d0b6c99c3d 100644 --- a/src/Gui/Control.cpp +++ b/src/Gui/Control.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include # include # include diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index 4be4baf386..110d9dbd8e 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -25,6 +25,7 @@ #ifndef _PreComp_ # include +# include # include #endif diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index bb75222853..e8c42c2b07 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -25,7 +25,9 @@ #ifndef _PreComp_ # include +# include # include +# include #endif #include "TaskView.h" @@ -37,6 +39,12 @@ #include #include +#if defined (QSINT_ACTIONPANEL) +#include +#include +#include +#endif + using namespace Gui::TaskView; //************************************************************************** @@ -67,6 +75,7 @@ TaskWidget::~TaskWidget() // TaskGroup //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#if !defined (QSINT_ACTIONPANEL) TaskGroup::TaskGroup(QWidget *parent) : iisTaskGroup(parent, false) { @@ -128,17 +137,76 @@ void TaskGroup::actionEvent (QActionEvent* e) break; } } +#else +TaskGroup::TaskGroup(QWidget *parent) + : QSint::ActionBox(parent) +{ +} +TaskGroup::TaskGroup(const QString & headerText, QWidget *parent) + : QSint::ActionBox(headerText, parent) +{ +} + +TaskGroup::TaskGroup(const QPixmap & icon, const QString & headerText, QWidget *parent) + : QSint::ActionBox(icon, headerText, parent) +{ +} + +TaskGroup::~TaskGroup() +{ +} + +void TaskGroup::actionEvent (QActionEvent* e) +{ + QAction *action = e->action(); + switch (e->type()) { + case QEvent::ActionAdded: + { + QSint::ActionLabel *label = this->createItem(action); + break; + } + case QEvent::ActionChanged: + { + break; + } + case QEvent::ActionRemoved: + { + // cannot change anything + break; + } + default: + break; + } +} +#endif //************************************************************************** //************************************************************************** // TaskBox //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#if !defined (QSINT_ACTIONPANEL) TaskBox::TaskBox(const QPixmap &icon, const QString &title, bool expandable, QWidget *parent) : iisTaskBox(icon, title, expandable, parent), wasShown(false) { setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); } +#else +TaskBox::TaskBox(QWidget *parent) + : QSint::ActionGroup(parent), wasShown(false) +{ +} + +TaskBox::TaskBox(const QString &title, bool expandable, QWidget *parent) + : QSint::ActionGroup(title, expandable, parent), wasShown(false) +{ +} + +TaskBox::TaskBox(const QPixmap &icon, const QString &title, bool expandable, QWidget *parent) + : QSint::ActionGroup(icon, title, expandable, parent), wasShown(false) +{ +} +#endif TaskBox::~TaskBox() { @@ -202,14 +270,20 @@ void TaskBox::actionEvent (QActionEvent* e) switch (e->type()) { case QEvent::ActionAdded: { +#if !defined (QSINT_ACTIONPANEL) TaskIconLabel *label = new TaskIconLabel( action->icon(), action->text(), this); this->addIconLabel(label); connect(label,SIGNAL(clicked()),action,SIGNAL(triggered())); +#else + QSint::ActionLabel *label = new QSint::ActionLabel(action, this); + this->addActionLabel(label, true, false); +#endif break; } case QEvent::ActionChanged: { +#if !defined (QSINT_ACTIONPANEL) // update label when action changes QBoxLayout* bl = myGroup->groupLayout(); int index = this->actions().indexOf(action); @@ -217,6 +291,7 @@ void TaskBox::actionEvent (QActionEvent* e) QWidgetItem* item = static_cast(bl->itemAt(index)); TaskIconLabel* label = static_cast(item->widget()); label->setTitle(action->text()); +#endif break; } case QEvent::ActionRemoved: @@ -241,8 +316,18 @@ TaskView::TaskView(QWidget *parent) //addWidget(new TaskEditControl(this)); //addWidget(new TaskAppearance(this)); //addStretch(); +#if !defined (QSINT_ACTIONPANEL) taskPanel = new iisTaskPanel(this); taskPanel->setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); +#else + taskPanel = new QSint::ActionPanel(this); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(taskPanel->sizePolicy().hasHeightForWidth()); + taskPanel->setSizePolicy(sizePolicy); + taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); +#endif this->setWidget(taskPanel); setWidgetResizable(true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -408,6 +493,10 @@ void TaskView::showDialog(TaskDialog *dlg) taskPanel->addWidget(ActiveCtrl); } +#if defined (QSINT_ACTIONPANEL) + taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); +#endif + if (!dlg->needsFullSpace()) taskPanel->addStretch(); @@ -487,6 +576,10 @@ void TaskView::addTaskWatcher(void) if (!ActiveWatcher.empty()) taskPanel->addStretch(); updateWatcher(); + +#if defined (QSINT_ACTIONPANEL) + taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); +#endif } void TaskView::removeTaskWatcher(void) diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index 528b011e32..8c785d3d1a 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -24,12 +24,19 @@ #ifndef GUI_TASKVIEW_TASKVIEW_H #define GUI_TASKVIEW_TASKVIEW_H +//#define QSINT_ACTIONPANEL + #include #include #include #include +#include +#if !defined (QSINT_ACTIONPANEL) #include +#else +#include +#endif #include #include "TaskWatcher.h" @@ -57,6 +64,7 @@ public: //~TaskContent(); }; +#if !defined (QSINT_ACTIONPANEL) class GuiExport TaskGroup : public iisTaskGroup, public TaskContent { Q_OBJECT @@ -68,14 +76,58 @@ public: protected: void actionEvent (QActionEvent*); }; - -/// Father class of content with header and Icon -class GuiExport TaskBox : public iisTaskBox, public TaskContent +#else +class GuiExport TaskGroup : public QSint::ActionBox, public TaskContent { Q_OBJECT public: + explicit TaskGroup(QWidget *parent = 0); + explicit TaskGroup(const QString & headerText, QWidget *parent = 0); + explicit TaskGroup(const QPixmap & icon, const QString & headerText, QWidget *parent = 0); + ~TaskGroup(); + +protected: + void actionEvent (QActionEvent*); +}; +#endif + +/// Father class of content with header and Icon +#if !defined (QSINT_ACTIONPANEL) +class GuiExport TaskBox : public iisTaskBox, public TaskContent +#else +class GuiExport TaskBox : public QSint::ActionGroup, public TaskContent +#endif +{ + Q_OBJECT + +public: +#if !defined (QSINT_ACTIONPANEL) TaskBox(const QPixmap &icon, const QString &title, bool expandable, QWidget *parent); +#else + /** Constructor. Creates TaskBox without header. + */ + explicit TaskBox(QWidget *parent = 0); + + /** Constructor. Creates TaskBox 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. + */ + explicit TaskBox(const QString& title, + bool expandable = true, + QWidget *parent = 0); + + /** Constructor. Creates TaskBox 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. + */ + explicit TaskBox(const QPixmap& icon, + const QString& title, + bool expandable = true, + QWidget *parent = 0); +#endif ~TaskBox(); void hideGroupBox(); bool isGroupVisible() const; @@ -145,7 +197,11 @@ protected: std::vector ActiveWatcher; +#if !defined (QSINT_ACTIONPANEL) iisTaskPanel* taskPanel; +#else + QSint::ActionPanel* taskPanel; +#endif TaskDialog *ActiveDialog; TaskEditControl *ActiveCtrl; diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 589b57a74e..6b38b4de54 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -22,6 +22,10 @@ #include "PreCompiled.h" +#ifndef _PreComp_ +# include +# include +#endif #include "Workbench.h" #include "WorkbenchPy.h" diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index 4541d83e7c..c369e772d6 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -149,7 +149,11 @@ TaskSmoothing::TaskSmoothing() selection = new Selection(); selection->setObjects(Gui::Selection().getSelectionEx(0, Mesh::Feature::getClassTypeId())); +#if !defined (QSINT_ACTIONPANEL) Gui::TaskView::TaskGroup* tasksel = new Gui::TaskView::TaskGroup(); +#else + Gui::TaskView::TaskBox* tasksel = new Gui::TaskView::TaskBox(); +#endif tasksel->groupLayout()->addWidget(selection); tasksel->hide(); Content.push_back(tasksel);