smaller icons in Ribbon

This commit is contained in:
2024-01-18 18:36:51 +03:00
parent 8feb5c240c
commit 6a67442d21
3 changed files with 43 additions and 26 deletions

View File

@@ -6,11 +6,6 @@
Ribbon::Ribbon(QMainWindow * parent_): QToolBar() { Ribbon::Ribbon(QMainWindow * parent_): QToolBar() {
tab = 0;
scroll_area = 0;
delay_e = true;
delay = 1000;
hovered = -1;
setObjectName("ribbon"); setObjectName("ribbon");
setProperty("ribbon", true); setProperty("ribbon", true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -67,8 +62,8 @@ void Ribbon::_resize() {
void Ribbon::_setIconsSize() { void Ribbon::_setIconsSize() {
// qDebug() << "resize" << preferredIconSize() << QApplication::font(); // qDebug() << "resize" << preferredIconSize() << QApplication::font();
setTabIconSize(preferredIconSize(2, this)); setTabIconSize(preferredIconSize(1.6, this));
setIconSize(preferredIconSize(3, 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) { void Ribbon::setVisible(bool yes) {
QToolBar::setVisible(yes); QToolBar::setVisible(yes);
if (parent == 0) return; if (parent == 0) return;
@@ -250,3 +253,15 @@ void Ribbon::setTabIconSize(const QSize & size) {
#endif #endif
_resize(); _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_);
}

View File

@@ -46,16 +46,10 @@ public:
void retranslate(); void retranslate();
void setIconSize(const QSize & size); void setIconSize(const QSize & size);
void setTabIconSize(const QSize & size); void setTabIconSize(const QSize & size);
void setButtonStyle(const Qt::ToolButtonStyle & style) { void setButtonStyle(const Qt::ToolButtonStyle & style);
foreach(QToolButton * i, buttons)
i->setToolButtonStyle(style);
}
void setAutoSwitchEnabled(bool yes) { delay_e = yes; } void setAutoSwitchEnabled(bool yes) { delay_e = yes; }
void setAutoSwitchDelay(float delay_s) { delay = delay_s * 1000; } void setAutoSwitchDelay(float delay_s) { delay = delay_s * 1000; }
void setCurrentTab(int tab_) { void setCurrentTab(int tab_);
if (tab_ < 0 || tab_ >= tab->count()) return;
tab->setCurrentIndex(tab_);
}
int currentTab() const { return tab->currentIndex(); } int currentTab() const { return tab->currentIndex(); }
QTabWidget * tabWidget() const { return tab; } QTabWidget * tabWidget() const { return tab; }
@@ -67,21 +61,16 @@ private:
void _setIconsSize(); void _setIconsSize();
void _setButtonText(QToolButton * b, QAction * a); void _setButtonText(QToolButton * b, QAction * a);
int hovered, delay; int hovered = -1, delay = 1000;
bool delay_e; bool delay_e = true;
QList<QToolButton *> buttons; QList<QToolButton *> buttons;
QMap<int, int> hovers; QMap<int, int> hovers;
ETabWidget * tab; ETabWidget * tab = nullptr;
QScrollArea * scroll_area; QScrollArea * scroll_area = nullptr;
QMainWindow * parent; QMainWindow * parent = nullptr;
private slots: private slots:
void tabHovered(int tab) { void tabHovered(int tab);
if (!delay_e) return;
hovers.clear();
hovered = tab;
hovers.insert(startTimer(delay), tab);
}
public slots: public slots:
void setVisible(bool yes); void setVisible(bool yes);

View File

@@ -150,6 +150,12 @@
</item> </item>
<item> <item>
<widget class="QWidget" name="widgetAlign9" native="true"> <widget class="QWidget" name="widgetAlign9" native="true">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@@ -777,9 +783,15 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>4</number> <number>4</number>
</property> </property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="checkVLEnabled"> <widget class="QCheckBox" name="checkVLEnabled">
<property name="text"> <property name="text">
@@ -886,6 +898,7 @@
<class>IconedLabel</class> <class>IconedLabel</class>
<extends>QFrame</extends> <extends>QFrame</extends>
<header>iconedlabel.h</header> <header>iconedlabel.h</header>
<container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>