mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-30 19:15:08 +01:00
Show a tooltip for sidebar tabs: only when needed for large side bar, always in the other cases, as I guess text will be elided most of the time.
Update issue 1202 This work around this issue a bit.
This commit is contained in:
parent
2081c30893
commit
bc5aa4055c
@ -304,6 +304,24 @@ void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||
paintTab(&p, currentIndex());
|
||||
}
|
||||
|
||||
bool FancyTab::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
QFontMetrics metrics (font());
|
||||
int text_width = metrics.width(text);
|
||||
|
||||
if (text_width > sizeHint().width()) {
|
||||
// The text is elided: show the tooltip
|
||||
QHelpEvent* he = static_cast<QHelpEvent*>(event);
|
||||
QToolTip::showText(he->globalPos(), text);
|
||||
} else {
|
||||
QToolTip::hideText();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void FancyTab::enterEvent(QEvent*)
|
||||
{
|
||||
fadeIn();
|
||||
@ -364,6 +382,7 @@ void FancyTabBar::addTab(const QIcon& icon, const QString& label) {
|
||||
FancyTab *tab = new FancyTab(this);
|
||||
tab->icon = icon;
|
||||
tab->text = label;
|
||||
tab->setToolTip(label);
|
||||
m_tabs.append(tab);
|
||||
qobject_cast<QVBoxLayout*>(layout())->insertWidget(layout()->count()-1, tab);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ protected:
|
||||
bool eventFilter(QObject* o, QEvent* e);
|
||||
};
|
||||
|
||||
class FancyTab : public QWidget{
|
||||
class FancyTab : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||
@ -82,6 +82,7 @@ public:
|
||||
QString text;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user