@@ -0,0 +1,18 | |||||
|
1 | #ifndef SCIQLOP_MACSCROLLBARSTYLE_H | |||
|
2 | #define SCIQLOP_MACSCROLLBARSTYLE_H | |||
|
3 | ||||
|
4 | #include <QProxyStyle> | |||
|
5 | ||||
|
6 | /** | |||
|
7 | * @brief Special style to always display the scrollbars on MAC. | |||
|
8 | */ | |||
|
9 | class MacScrollBarStyle : public QProxyStyle { | |||
|
10 | ||||
|
11 | public: | |||
|
12 | int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, | |||
|
13 | QStyleHintReturn *returnData) const; | |||
|
14 | ||||
|
15 | void selfInstallOn(QWidget *widget, bool installOnSubWidgets); | |||
|
16 | }; | |||
|
17 | ||||
|
18 | #endif // SCIQLOP_MACSCROLLBARSTYLE_H |
@@ -0,0 +1,40 | |||||
|
1 | #include "Visualization/MacScrollBarStyle.h" | |||
|
2 | ||||
|
3 | #include <QWidget> | |||
|
4 | ||||
|
5 | int MacScrollBarStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, | |||
|
6 | const QWidget *widget, QStyleHintReturn *returnData) const | |||
|
7 | { | |||
|
8 | switch (hint) { | |||
|
9 | case SH_ScrollBar_Transient: | |||
|
10 | return false; // Makes the scrollbar always visible | |||
|
11 | case SH_ScrollView_FrameOnlyAroundContents: | |||
|
12 | return true; // Avoid that the scrollbar is drawn on top of the widget | |||
|
13 | default: | |||
|
14 | break; | |||
|
15 | } | |||
|
16 | ||||
|
17 | return QProxyStyle::styleHint(hint, option, widget, returnData); | |||
|
18 | } | |||
|
19 | ||||
|
20 | void MacScrollBarStyle::selfInstallOn(QWidget *widget, bool installOnSubWidgets) | |||
|
21 | { | |||
|
22 | // Note: a style can be installed on a particular widget but it is not automatically applied its | |||
|
23 | // children widgets. | |||
|
24 | ||||
|
25 | QList<QWidget *> widgetsToStyle{widget}; | |||
|
26 | while (!widgetsToStyle.isEmpty()) { | |||
|
27 | ||||
|
28 | auto widget = widgetsToStyle.takeFirst(); | |||
|
29 | widget->setStyle(this); | |||
|
30 | ||||
|
31 | if (installOnSubWidgets) { | |||
|
32 | for (auto child : widget->children()) { | |||
|
33 | auto childWidget = qobject_cast<QWidget *>(child); | |||
|
34 | if (childWidget) { | |||
|
35 | widgetsToStyle << childWidget; | |||
|
36 | } | |||
|
37 | } | |||
|
38 | } | |||
|
39 | } | |||
|
40 | } |
@@ -78,7 +78,8 gui_sources = [ | |||||
78 | 'src/Visualization/VisualizationDragDropContainer.cpp', |
|
78 | 'src/Visualization/VisualizationDragDropContainer.cpp', | |
79 | 'src/Visualization/VisualizationDragWidget.cpp', |
|
79 | 'src/Visualization/VisualizationDragWidget.cpp', | |
80 | 'src/Visualization/AxisRenderingUtils.cpp', |
|
80 | 'src/Visualization/AxisRenderingUtils.cpp', | |
81 | 'src/Visualization/PlottablesRenderingUtils.cpp' |
|
81 | 'src/Visualization/PlottablesRenderingUtils.cpp', | |
|
82 | 'src/Visualization/MacScrollBarStyle.cpp' | |||
82 | ] |
|
83 | ] | |
83 |
|
84 | |||
84 | gui_inc = include_directories(['include']) |
|
85 | gui_inc = include_directories(['include']) |
@@ -5,6 +5,8 | |||||
5 | #include "Visualization/VisualizationGraphWidget.h" |
|
5 | #include "Visualization/VisualizationGraphWidget.h" | |
6 | #include "Visualization/VisualizationZoneWidget.h" |
|
6 | #include "Visualization/VisualizationZoneWidget.h" | |
7 |
|
7 | |||
|
8 | #include "Visualization/MacScrollBarStyle.h" | |||
|
9 | ||||
8 | #include "Variable/VariableController.h" |
|
10 | #include "Variable/VariableController.h" | |
9 |
|
11 | |||
10 | #include "Common/MimeTypesDef.h" |
|
12 | #include "Common/MimeTypesDef.h" | |
@@ -55,6 +57,10 struct VisualizationTabWidget::VisualizationTabWidgetPrivate { | |||||
55 |
|
57 | |||
56 | QString m_Name; |
|
58 | QString m_Name; | |
57 |
|
59 | |||
|
60 | #ifdef Q_OS_MAC | |||
|
61 | std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>(); | |||
|
62 | #endif | |||
|
63 | ||||
58 | void dropGraph(int index, VisualizationTabWidget *tabWidget); |
|
64 | void dropGraph(int index, VisualizationTabWidget *tabWidget); | |
59 | void dropZone(int index, VisualizationTabWidget *tabWidget); |
|
65 | void dropZone(int index, VisualizationTabWidget *tabWidget); | |
60 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, |
|
66 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, | |
@@ -68,6 +74,10 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par | |||||
68 | { |
|
74 | { | |
69 | ui->setupUi(this); |
|
75 | ui->setupUi(this); | |
70 |
|
76 | |||
|
77 | #ifdef Q_OS_MAC | |||
|
78 | impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true); | |||
|
79 | #endif | |||
|
80 | ||||
71 | ui->dragDropContainer->setPlaceHolderType(DragDropHelper::PlaceHolderType::Zone, "Zone"); |
|
81 | ui->dragDropContainer->setPlaceHolderType(DragDropHelper::PlaceHolderType::Zone, "Zone"); | |
72 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 5); |
|
82 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 5); | |
73 | ui->dragDropContainer->addAcceptedMimeType( |
|
83 | ui->dragDropContainer->addAcceptedMimeType( |
General Comments 0
You need to be logged in to leave comments.
Login now