git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#ifndef RIBBON_H
|
|
#define RIBBON_H
|
|
|
|
#include <QMainWindow>
|
|
#include <QActionGroup>
|
|
#include <QWidgetAction>
|
|
#include <QMenuBar>
|
|
#include <QTabWidget>
|
|
#include <QGroupBox>
|
|
#include <QDockWidget>
|
|
#include <QToolBar>
|
|
#include <QScrollArea>
|
|
#include "etabwidget.h"
|
|
|
|
|
|
class Ribbon: public QToolBar
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit Ribbon(QMainWindow * parent = 0);
|
|
~Ribbon();
|
|
|
|
void init();
|
|
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 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_);}
|
|
int currentTab() const {return tab->currentIndex();}
|
|
QTabWidget * tabWidget() const {return tab;}
|
|
|
|
private:
|
|
bool eventFilter(QObject * o, QEvent * e);
|
|
void timerEvent(QTimerEvent * e);
|
|
void _resize();
|
|
|
|
int hovered, delay;
|
|
bool delay_e;
|
|
QList<QToolButton * > buttons;
|
|
QMap<int, int> hovers;
|
|
ETabWidget * tab;
|
|
QScrollArea * scroll_area;
|
|
QMainWindow * parent;
|
|
|
|
private slots:
|
|
void tabHovered(int tab) {if (!delay_e) return; hovers.clear(); hovered = tab; hovers.insert(startTimer(delay), tab);}
|
|
|
|
public slots:
|
|
void setVisible(bool yes);
|
|
void setHidden(bool yes) {setVisible(!yes);}
|
|
void show() {setVisible(true);}
|
|
void hide() {setVisible(false);}
|
|
|
|
signals:
|
|
void currentTabChanged(int);
|
|
|
|
};
|
|
|
|
#endif // RIBBON_H
|