forked from qt-creator/qt-creator
Animate sidebar tabs independently
This commit is contained in:
@@ -44,12 +44,26 @@ QT_END_NAMESPACE
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
struct FancyTab{
|
||||
QIcon icon;
|
||||
QString text;
|
||||
QString toolTip;
|
||||
bool enabled;
|
||||
};
|
||||
class FancyTab : public QObject{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||
public:
|
||||
FancyTab(QWidget *tabbar) : enabled(false), tabbar(tabbar), m_fader(0) {}
|
||||
float fader() { return m_fader; }
|
||||
void setFader(float value) { m_fader = value; tabbar->update(); }
|
||||
|
||||
void fadeIn();
|
||||
void fadeOut();
|
||||
|
||||
QIcon icon;
|
||||
QString text;
|
||||
QString toolTip;
|
||||
bool enabled;
|
||||
private:
|
||||
QWidget *tabbar;
|
||||
float m_fader;
|
||||
};
|
||||
|
||||
class FancyTabBar : public QWidget
|
||||
{
|
||||
@@ -67,6 +81,7 @@ public:
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); }
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
@@ -75,24 +90,24 @@ public:
|
||||
bool isTabEnabled(int index) const;
|
||||
|
||||
void insertTab(int index, const QIcon &icon, const QString &label) {
|
||||
FancyTab tab;
|
||||
tab.enabled = true;
|
||||
tab.icon = icon;
|
||||
tab.text = label;
|
||||
FancyTab *tab = new FancyTab(this);
|
||||
tab->icon = icon;
|
||||
tab->text = label;
|
||||
m_tabs.insert(index, tab);
|
||||
}
|
||||
void setEnabled(int index, bool enabled);
|
||||
void removeTab(int index) {
|
||||
m_tabs.removeAt(index);
|
||||
FancyTab *tab = m_tabs.takeAt(index);
|
||||
delete tab;
|
||||
}
|
||||
void setCurrentIndex(int index);
|
||||
int currentIndex() const { return m_currentIndex; }
|
||||
|
||||
void setTabToolTip(int index, QString toolTip) { m_tabs[index].toolTip = toolTip; }
|
||||
QString tabToolTip(int index) const { return m_tabs.at(index).toolTip; }
|
||||
void setTabToolTip(int index, QString toolTip) { m_tabs[index]->toolTip = toolTip; }
|
||||
QString tabToolTip(int index) const { return m_tabs.at(index)->toolTip; }
|
||||
|
||||
QIcon tabIcon(int index) const {return m_tabs.at(index).icon; }
|
||||
QString tabText(int index) const { return m_tabs.at(index).text; }
|
||||
QIcon tabIcon(int index) const {return m_tabs.at(index)->icon; }
|
||||
QString tabText(int index) const { return m_tabs.at(index)->text; }
|
||||
int count() const {return m_tabs.count(); }
|
||||
QRect tabRect(int index) const;
|
||||
|
||||
@@ -105,11 +120,10 @@ public slots:
|
||||
private:
|
||||
static const int m_rounding;
|
||||
static const int m_textPadding;
|
||||
QTimeLine m_hoverControl;
|
||||
QRect m_hoverRect;
|
||||
int m_hoverIndex;
|
||||
int m_currentIndex;
|
||||
QList<FancyTab> m_tabs;
|
||||
QList<FancyTab*> m_tabs;
|
||||
|
||||
QSize tabSizeHint(bool minimum = false) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user