forked from qt-creator/qt-creator
Have your debug button back
This commit is contained in:
@@ -264,31 +264,8 @@ FancyActionBar::FancyActionBar(QWidget *parent)
|
|||||||
spacerLayout->setSpacing(0);
|
spacerLayout->setSpacing(0);
|
||||||
setLayout(spacerLayout);
|
setLayout(spacerLayout);
|
||||||
setContentsMargins(0,2,0,0);
|
setContentsMargins(0,2,0,0);
|
||||||
|
|
||||||
m_runButton = m_debugButton = 0;
|
|
||||||
m_inDebugMode = false;
|
|
||||||
|
|
||||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
|
||||||
this, SLOT(modeChanged(Core::IMode*)));
|
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
qApp->installEventFilter(this);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
bool FancyActionBar::eventFilter(QObject *, QEvent *e)
|
|
||||||
{
|
|
||||||
if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
|
|
||||||
if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt)
|
|
||||||
updateRunDebug();
|
|
||||||
} else if (e->type() == QEvent::WindowDeactivate)
|
|
||||||
updateRunDebug();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void FancyActionBar::addProjectSelector(QAction *action)
|
void FancyActionBar::addProjectSelector(QAction *action)
|
||||||
{
|
{
|
||||||
FancyToolButton* toolButton = new FancyToolButton(this);
|
FancyToolButton* toolButton = new FancyToolButton(this);
|
||||||
@@ -300,40 +277,11 @@ void FancyActionBar::addProjectSelector(QAction *action)
|
|||||||
void FancyActionBar::insertAction(int index, QAction *action)
|
void FancyActionBar::insertAction(int index, QAction *action)
|
||||||
{
|
{
|
||||||
FancyToolButton *toolButton = new FancyToolButton(this);
|
FancyToolButton *toolButton = new FancyToolButton(this);
|
||||||
if (action->objectName() == QLatin1String("ProjectExplorer.Run"))
|
|
||||||
m_runButton = toolButton;
|
|
||||||
if (action->objectName() == QLatin1String("ProjectExplorer.Debug"))
|
|
||||||
m_debugButton = toolButton;
|
|
||||||
|
|
||||||
toolButton->setDefaultAction(action);
|
toolButton->setDefaultAction(action);
|
||||||
connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged()));
|
connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged()));
|
||||||
m_actionsLayout->insertWidget(index, toolButton);
|
m_actionsLayout->insertWidget(index, toolButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyActionBar::modeChanged(Core::IMode *mode)
|
|
||||||
{
|
|
||||||
m_inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug"));
|
|
||||||
updateRunDebug();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FancyActionBar::updateRunDebug()
|
|
||||||
{
|
|
||||||
if (!m_runButton || !m_debugButton)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool doDebug = m_inDebugMode;
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
if (QApplication::keyboardModifiers() && Qt::AltModifier)
|
|
||||||
doDebug = !doDebug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout()->setEnabled(false);
|
|
||||||
m_runButton->forceVisible(!doDebug);
|
|
||||||
m_debugButton->forceVisible(doDebug);
|
|
||||||
layout()->setEnabled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QLayout *FancyActionBar::actionsLayout() const
|
QLayout *FancyActionBar::actionsLayout() const
|
||||||
{
|
{
|
||||||
return m_actionsLayout;
|
return m_actionsLayout;
|
||||||
|
|||||||
@@ -75,23 +75,13 @@ class FancyActionBar : public QWidget
|
|||||||
public:
|
public:
|
||||||
FancyActionBar(QWidget *parent = 0);
|
FancyActionBar(QWidget *parent = 0);
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
bool eventFilter(QObject *, QEvent *);
|
|
||||||
#endif
|
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void insertAction(int index, QAction *action);
|
void insertAction(int index, QAction *action);
|
||||||
void addProjectSelector(QAction *action);
|
void addProjectSelector(QAction *action);
|
||||||
QLayout *actionsLayout() const;
|
QLayout *actionsLayout() const;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void modeChanged(Core::IMode *mode);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateRunDebug();
|
|
||||||
bool m_inDebugMode;
|
|
||||||
QVBoxLayout *m_actionsLayout;
|
QVBoxLayout *m_actionsLayout;
|
||||||
FancyToolButton *m_runButton;
|
|
||||||
FancyToolButton *m_debugButton;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user