forked from qt-creator/qt-creator
Some tuning of the fancy action bar
Done-with: jbache
This commit is contained in:
@@ -57,10 +57,17 @@ using namespace Internal;
|
||||
FancyToolButton::FancyToolButton(QWidget *parent)
|
||||
: QToolButton(parent), m_fader(0)
|
||||
{
|
||||
m_hasForceVisible = false;
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void FancyToolButton::forceVisible(bool visible)
|
||||
{
|
||||
m_hasForceVisible = true;
|
||||
setVisible(visible);
|
||||
}
|
||||
|
||||
bool FancyToolButton::event(QEvent *e)
|
||||
{
|
||||
switch(e->type()) {
|
||||
@@ -220,8 +227,10 @@ void FancyToolButton::actionChanged()
|
||||
{
|
||||
// the default action changed in some way, e.g. it might got hidden
|
||||
// since we inherit a tool button we won't get invisible, so do this here
|
||||
if (!m_hasForceVisible) {
|
||||
if (QAction* action = defaultAction())
|
||||
setVisible(action->isVisible());
|
||||
}
|
||||
}
|
||||
|
||||
FancyActionBar::FancyActionBar(QWidget *parent)
|
||||
@@ -270,8 +279,8 @@ void FancyActionBar::modeChanged(Core::IMode *mode)
|
||||
if (m_runButton && m_debugButton) {
|
||||
bool inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug"));
|
||||
layout()->setEnabled(false);
|
||||
m_runButton->setVisible(!inDebugMode);
|
||||
m_debugButton->setVisible(inDebugMode);
|
||||
m_runButton->forceVisible(!inDebugMode);
|
||||
m_debugButton->forceVisible(inDebugMode);
|
||||
layout()->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,13 @@ public:
|
||||
float fader() { return m_fader; }
|
||||
void setFader(float value) { m_fader = value; update(); }
|
||||
|
||||
void forceVisible(bool visible);
|
||||
|
||||
private slots:
|
||||
void actionChanged();
|
||||
|
||||
private:
|
||||
bool m_hasForceVisible;
|
||||
};
|
||||
|
||||
class FancyActionBar : public QWidget
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
|
||||
using namespace Core;
|
||||
|
||||
const int notificationTimeout = 8000;
|
||||
|
||||
void FadeWidgetHack::paintEvent(QPaintEvent *)
|
||||
{
|
||||
if (m_opacity == 0)
|
||||
@@ -187,7 +189,7 @@ bool FutureProgress::eventFilter(QObject *, QEvent *e)
|
||||
if (m_waitingForUserInteraction
|
||||
&& (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) {
|
||||
qApp->removeEventFilter(this);
|
||||
QTimer::singleShot(5000, this, SLOT(fadeAway()));
|
||||
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -205,7 +207,7 @@ void FutureProgress::setFinished()
|
||||
m_waitingForUserInteraction = true;
|
||||
qApp->installEventFilter(this);
|
||||
} else {
|
||||
QTimer::singleShot(5000, this, SLOT(fadeAway()));
|
||||
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user