Compare commits

..

2 Commits

Author SHA1 Message Date
cristian64
597c1d56b0 DolphinQt: Use vertical tabs in Hotkey Settings dialog.
At this time, only the **Hotkey Settings** dialog will use vertical
tabs. This dialog happens to feature many tabs that, when horizontal
tabs are used, require horizontal scroll. Also, with these many tabs,
it can make good use of the vertical space that the vertical tabs
require.

| Before | After |
| ------ | ----- |
| <img width="918" height="679" alt="[Dolphin Emulator] Hotkey Settings dialog" title="[Dolphin Emulator] Hotkey Settings dialog" src="https://github.com/user-attachments/assets/7c9d9964-f36b-4872-ab52-6ebbe974a8ca" /> | <img width="1041" height="653" alt="[Dolphin Emulator] Hotkey Settings dialog with vertical tabs" title="[Dolphin Emulator] Hotkey Settings dialog with vertical tabs" src="https://github.com/user-attachments/assets/c6d875f9-f52d-4564-9d68-0555521a77fa" /> |
2025-08-30 19:12:56 +01:00
cristian64
c13d7dfd2d DolphinQt: Add tab widget with vertical tabs. 2025-08-30 18:36:51 +01:00

View File

@ -25,42 +25,29 @@ protected:
void paintEvent(QPaintEvent* const event) override
{
QStylePainter painter(this);
const int current_tab_index{currentIndex()};
QStyleOptionTab option;
const int tab_count{count()};
for (int i{0}; i < tab_count; ++i)
{
if (i != current_tab_index)
paintTab(painter, i);
painter.save();
initStyleOption(&option, i);
painter.drawControl(QStyle::CE_TabBarTabShape, option);
const QSize size{option.rect.size().transposed()};
QRect rect(QPoint(), size);
rect.moveCenter(option.rect.center());
option.rect = rect;
const QPoint center{tabRect(i).center()};
painter.translate(center);
painter.rotate(90.0);
painter.translate(-center);
painter.drawControl(QStyle::CE_TabBarTabLabel, option);
painter.restore();
}
// Current tab is painted last as, depending on the [system] style, it is possible that the
// decoration is required to occlude the adjacent tab underneath.
paintTab(painter, current_tab_index);
}
private:
void paintTab(QStylePainter& painter, const int tab_index)
{
painter.save();
QStyleOptionTab option;
initStyleOption(&option, tab_index);
painter.drawControl(QStyle::CE_TabBarTabShape, option);
const QSize size{option.rect.size().transposed()};
QRect rect(QPoint(), size);
rect.moveCenter(option.rect.center());
option.rect = rect;
const QPoint center{tabRect(tab_index).center()};
painter.translate(center);
painter.rotate(90.0);
painter.translate(-center);
painter.drawControl(QStyle::CE_TabBarTabLabel, option);
painter.restore();
}
};
} // namespace