Skip to content
Snippets Groups Projects
Commit d13dfe44 authored by mae's avatar mae
Browse files

Some tuning of the fancy action bar

Done-with: jbache
parent a2fe486b
No related branches found
No related tags found
No related merge requests found
...@@ -57,10 +57,17 @@ using namespace Internal; ...@@ -57,10 +57,17 @@ using namespace Internal;
FancyToolButton::FancyToolButton(QWidget *parent) FancyToolButton::FancyToolButton(QWidget *parent)
: QToolButton(parent), m_fader(0) : QToolButton(parent), m_fader(0)
{ {
m_hasForceVisible = false;
setAttribute(Qt::WA_Hover, true); setAttribute(Qt::WA_Hover, true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
} }
void FancyToolButton::forceVisible(bool visible)
{
m_hasForceVisible = true;
setVisible(visible);
}
bool FancyToolButton::event(QEvent *e) bool FancyToolButton::event(QEvent *e)
{ {
switch(e->type()) { switch(e->type()) {
...@@ -220,8 +227,10 @@ void FancyToolButton::actionChanged() ...@@ -220,8 +227,10 @@ void FancyToolButton::actionChanged()
{ {
// the default action changed in some way, e.g. it might got hidden // 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 // since we inherit a tool button we won't get invisible, so do this here
if (QAction* action = defaultAction()) if (!m_hasForceVisible) {
setVisible(action->isVisible()); if (QAction* action = defaultAction())
setVisible(action->isVisible());
}
} }
FancyActionBar::FancyActionBar(QWidget *parent) FancyActionBar::FancyActionBar(QWidget *parent)
...@@ -270,8 +279,8 @@ void FancyActionBar::modeChanged(Core::IMode *mode) ...@@ -270,8 +279,8 @@ void FancyActionBar::modeChanged(Core::IMode *mode)
if (m_runButton && m_debugButton) { if (m_runButton && m_debugButton) {
bool inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug")); bool inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug"));
layout()->setEnabled(false); layout()->setEnabled(false);
m_runButton->setVisible(!inDebugMode); m_runButton->forceVisible(!inDebugMode);
m_debugButton->setVisible(inDebugMode); m_debugButton->forceVisible(inDebugMode);
layout()->setEnabled(true); layout()->setEnabled(true);
} }
} }
......
...@@ -60,8 +60,13 @@ public: ...@@ -60,8 +60,13 @@ public:
float fader() { return m_fader; } float fader() { return m_fader; }
void setFader(float value) { m_fader = value; update(); } void setFader(float value) { m_fader = value; update(); }
void forceVisible(bool visible);
private slots: private slots:
void actionChanged(); void actionChanged();
private:
bool m_hasForceVisible;
}; };
class FancyActionBar : public QWidget class FancyActionBar : public QWidget
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
using namespace Core; using namespace Core;
const int notificationTimeout = 8000;
void FadeWidgetHack::paintEvent(QPaintEvent *) void FadeWidgetHack::paintEvent(QPaintEvent *)
{ {
if (m_opacity == 0) if (m_opacity == 0)
...@@ -187,7 +189,7 @@ bool FutureProgress::eventFilter(QObject *, QEvent *e) ...@@ -187,7 +189,7 @@ bool FutureProgress::eventFilter(QObject *, QEvent *e)
if (m_waitingForUserInteraction if (m_waitingForUserInteraction
&& (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) { && (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) {
qApp->removeEventFilter(this); qApp->removeEventFilter(this);
QTimer::singleShot(5000, this, SLOT(fadeAway())); QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
} }
return false; return false;
} }
...@@ -205,7 +207,7 @@ void FutureProgress::setFinished() ...@@ -205,7 +207,7 @@ void FutureProgress::setFinished()
m_waitingForUserInteraction = true; m_waitingForUserInteraction = true;
qApp->installEventFilter(this); qApp->installEventFilter(this);
} else { } else {
QTimer::singleShot(5000, this, SLOT(fadeAway())); QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment