From 6a67442d21323b01f58d4fecf7a595b7ae77229a Mon Sep 17 00:00:00 2001 From: peri4 Date: Thu, 18 Jan 2024 18:36:51 +0300 Subject: [PATCH] smaller icons in Ribbon --- libs/application/ribbon.cpp | 29 ++++++++++++++++++++++------- libs/application/ribbon.h | 27 ++++++++------------------- libs/blockview/drawtools.ui | 13 +++++++++++++ 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/libs/application/ribbon.cpp b/libs/application/ribbon.cpp index 54ebf3f..a8a9d2c 100644 --- a/libs/application/ribbon.cpp +++ b/libs/application/ribbon.cpp @@ -6,11 +6,6 @@ Ribbon::Ribbon(QMainWindow * parent_): QToolBar() { - tab = 0; - scroll_area = 0; - delay_e = true; - delay = 1000; - hovered = -1; setObjectName("ribbon"); setProperty("ribbon", true); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); @@ -67,8 +62,8 @@ void Ribbon::_resize() { void Ribbon::_setIconsSize() { // qDebug() << "resize" << preferredIconSize() << QApplication::font(); - setTabIconSize(preferredIconSize(2, this)); - setIconSize(preferredIconSize(3, this)); + setTabIconSize(preferredIconSize(1.6, this)); + setIconSize(preferredIconSize(2.4, this)); } @@ -82,6 +77,14 @@ void Ribbon::_setButtonText(QToolButton * b, QAction * a) { } +void Ribbon::tabHovered(int tab) { + if (!delay_e) return; + hovers.clear(); + hovered = tab; + hovers.insert(startTimer(delay), tab); +} + + void Ribbon::setVisible(bool yes) { QToolBar::setVisible(yes); if (parent == 0) return; @@ -250,3 +253,15 @@ void Ribbon::setTabIconSize(const QSize & size) { #endif _resize(); } + + +void Ribbon::setButtonStyle(const Qt::ToolButtonStyle & style) { + foreach(QToolButton * i, buttons) + i->setToolButtonStyle(style); +} + + +void Ribbon::setCurrentTab(int tab_) { + if (tab_ < 0 || tab_ >= tab->count()) return; + tab->setCurrentIndex(tab_); +} diff --git a/libs/application/ribbon.h b/libs/application/ribbon.h index 8e5a51a..bcf4772 100644 --- a/libs/application/ribbon.h +++ b/libs/application/ribbon.h @@ -46,16 +46,10 @@ public: void retranslate(); void setIconSize(const QSize & size); void setTabIconSize(const QSize & size); - void setButtonStyle(const Qt::ToolButtonStyle & style) { - foreach(QToolButton * i, buttons) - i->setToolButtonStyle(style); - } + void setButtonStyle(const Qt::ToolButtonStyle & style); void setAutoSwitchEnabled(bool yes) { delay_e = yes; } void setAutoSwitchDelay(float delay_s) { delay = delay_s * 1000; } - void setCurrentTab(int tab_) { - if (tab_ < 0 || tab_ >= tab->count()) return; - tab->setCurrentIndex(tab_); - } + void setCurrentTab(int tab_); int currentTab() const { return tab->currentIndex(); } QTabWidget * tabWidget() const { return tab; } @@ -67,21 +61,16 @@ private: void _setIconsSize(); void _setButtonText(QToolButton * b, QAction * a); - int hovered, delay; - bool delay_e; + int hovered = -1, delay = 1000; + bool delay_e = true; QList buttons; QMap hovers; - ETabWidget * tab; - QScrollArea * scroll_area; - QMainWindow * parent; + ETabWidget * tab = nullptr; + QScrollArea * scroll_area = nullptr; + QMainWindow * parent = nullptr; private slots: - void tabHovered(int tab) { - if (!delay_e) return; - hovers.clear(); - hovered = tab; - hovers.insert(startTimer(delay), tab); - } + void tabHovered(int tab); public slots: void setVisible(bool yes); diff --git a/libs/blockview/drawtools.ui b/libs/blockview/drawtools.ui index 5f1ac52..0924e50 100644 --- a/libs/blockview/drawtools.ui +++ b/libs/blockview/drawtools.ui @@ -150,6 +150,12 @@ + + + 20 + 20 + + 0 @@ -777,9 +783,15 @@ false + + 0 + 4 + + 2 + @@ -886,6 +898,7 @@ IconedLabel QFrame
iconedlabel.h
+ 1