diff --git a/sources/projectview.cpp b/sources/projectview.cpp index d9a9330d1..84afbab7c 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -810,7 +810,7 @@ void ProjectView::initWidgets() { fallback_label_ -> setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); // initialize tabs - m_tab = new QTabWidget(this); + m_tab = new WheelEnabledTabBar(this); //----- m_tab -> setMovable(true); QToolButton *add_new_diagram_button = new QToolButton; diff --git a/sources/projectview.h b/sources/projectview.h index f1becd5ba..bd4591eff 100644 --- a/sources/projectview.h +++ b/sources/projectview.h @@ -19,10 +19,35 @@ #define PROJECT_VIEW_H #include +#include +#include #include "templatelocation.h" #include "qetresult.h" + + +//class WheelEnabledTabBar : public QTabBar +class WheelEnabledTabBar : public QTabWidget +{ +public: + WheelEnabledTabBar(QWidget *parent = nullptr) +// : QTabBar(parent) + : QTabWidget(parent) + {} + + void wheelEvent(QWheelEvent *event) override + { + int index = currentIndex(); + if (index != -1) { + index += event->delta() > 0 ? -1 : 1; + if (index >= 0 && index < count()) + setCurrentIndex(index); + } + } +}; + + class QETProject; class DiagramView; class Diagram; @@ -31,6 +56,7 @@ class QTabWidget; class QLabel; class QVBoxLayout; + /** This class provides a widget displaying the diagrams of a particular project using tabs. @@ -131,10 +157,12 @@ class ProjectView : public QWidget QVBoxLayout *layout_; QWidget *fallback_widget_; QLabel *fallback_label_; - QTabWidget *m_tab; + //QTabWidget *m_tab; + WheelEnabledTabBar *m_tab; QMap m_diagram_ids; int m_previous_tab_index = -1; QList m_diagram_view_list; }; + #endif