forked from qt-creator/qt-creator
Make IOutputPane behaviour more granular
The commit looks big, but it's mostly trivial. Also any build/run related popups are now "flashes" if the current mode has no placeholder. Task-number: QTCREATORBUG-7875 Change-Id: I3af40557f7af01798f905c0d1829423c80058cb6 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -75,21 +75,22 @@ public:
|
||||
virtual void goToNext() = 0;
|
||||
virtual void goToPrev() = 0;
|
||||
|
||||
enum Flag { NoModeSwitch = 0, ModeSwitch = 1, WithFocus = 2, EnsureSizeHint = 4};
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
public slots:
|
||||
void popup() { popup(true, false); }
|
||||
void popup(bool withFocus) { popup(withFocus, false); }
|
||||
void popup(bool withFocus, bool ensureSizeHint) { emit showPage(withFocus, ensureSizeHint); }
|
||||
void popup(int flags) { emit showPage(flags); }
|
||||
|
||||
void hide() { emit hidePage(); }
|
||||
void toggle() { toggle(true); }
|
||||
void toggle(bool withFocusIfShown) { emit togglePage(withFocusIfShown); }
|
||||
void toggle(int flags) { emit togglePage(flags); }
|
||||
void navigateStateChanged() { emit navigateStateUpdate(); }
|
||||
void flash() { emit flashButton(); }
|
||||
void setIconBadgeNumber(int number) { emit setBadgeNumber(number); }
|
||||
|
||||
signals:
|
||||
void showPage(bool withFocus, bool ensureSizeHint);
|
||||
void showPage(int flags);
|
||||
void hidePage();
|
||||
void togglePage(bool withFocusIfShown);
|
||||
void togglePage(int flags);
|
||||
void navigateStateUpdate();
|
||||
void flashButton();
|
||||
void setBadgeNumber(int number);
|
||||
@@ -97,4 +98,6 @@ signals:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IOutputPane::Flags)
|
||||
|
||||
#endif // IOUTPUTPANE_H
|
||||
|
||||
@@ -65,7 +65,7 @@ void MessageManager::init()
|
||||
void MessageManager::showOutputPane()
|
||||
{
|
||||
if (m_messageOutputWindow)
|
||||
m_messageOutputWindow->popup(false);
|
||||
m_messageOutputWindow->popup(IOutputPane::ModeSwitch);
|
||||
}
|
||||
|
||||
void MessageManager::printToOutputPane(const QString &text, bool bringToForeground)
|
||||
@@ -73,7 +73,7 @@ void MessageManager::printToOutputPane(const QString &text, bool bringToForegrou
|
||||
if (!m_messageOutputWindow)
|
||||
return;
|
||||
if (bringToForeground)
|
||||
m_messageOutputWindow->popup(false);
|
||||
m_messageOutputWindow->popup(IOutputPane::ModeSwitch);
|
||||
m_messageOutputWindow->append(text + QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
|
||||
@@ -257,9 +257,9 @@ void OutputPaneManager::init()
|
||||
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
|
||||
QTC_CHECK(idx == i);
|
||||
|
||||
connect(outPane, SIGNAL(showPage(bool,bool)), this, SLOT(showPage(bool,bool)));
|
||||
connect(outPane, SIGNAL(showPage(int)), this, SLOT(showPage(int)));
|
||||
connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
|
||||
connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool)));
|
||||
connect(outPane, SIGNAL(togglePage(int)), this, SLOT(togglePage(int)));
|
||||
connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
|
||||
connect(outPane, SIGNAL(flashButton()), this, SLOT(flashButton()));
|
||||
connect(outPane, SIGNAL(setBadgeNumber(int)), this, SLOT(setBadgeNumber(int)));
|
||||
@@ -364,7 +364,7 @@ void OutputPaneManager::buttonTriggered(int idx)
|
||||
// we should toggle and the page is already visible and we are actually closeable
|
||||
slotHide();
|
||||
} else {
|
||||
showPage(idx, true);
|
||||
showPage(idx, IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,45 +462,47 @@ void OutputPaneManager::setBadgeNumber(int number)
|
||||
}
|
||||
|
||||
// Slot connected to showPage signal of each page
|
||||
void OutputPaneManager::showPage(bool focus, bool ensureSizeHint)
|
||||
void OutputPaneManager::showPage(int flags)
|
||||
{
|
||||
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
||||
OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent();
|
||||
if (!ph)
|
||||
m_buttons.value(idx)->flash();
|
||||
else
|
||||
showPage(idx, focus);
|
||||
|
||||
if (ensureSizeHint && ph)
|
||||
ph->ensureSizeHintAsMinimum();
|
||||
showPage(idx, flags);
|
||||
}
|
||||
|
||||
void OutputPaneManager::showPage(int idx, bool focus)
|
||||
void OutputPaneManager::showPage(int idx, int flags)
|
||||
{
|
||||
QTC_ASSERT(idx >= 0, return);
|
||||
if (!OutputPanePlaceHolder::getCurrent()) {
|
||||
OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent();
|
||||
|
||||
if (!ph && flags & IOutputPane::ModeSwitch) {
|
||||
// In this mode we don't have a placeholder
|
||||
// switch to the output mode and switch the page
|
||||
ModeManager::activateMode(Id(Constants::MODE_EDIT));
|
||||
ph = OutputPanePlaceHolder::getCurrent();
|
||||
}
|
||||
if (OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent()) {
|
||||
|
||||
if (ph) {
|
||||
// make the page visible
|
||||
ph->setVisible(true);
|
||||
ensurePageVisible(idx);
|
||||
IOutputPane *out = m_panes.at(idx);
|
||||
out->visibilityChanged(true);
|
||||
if (focus && out->canFocus())
|
||||
if (flags & IOutputPane::WithFocus && out->canFocus())
|
||||
out->setFocus();
|
||||
|
||||
if (flags & IOutputPane::EnsureSizeHint)
|
||||
ph->ensureSizeHintAsMinimum();
|
||||
} else {
|
||||
m_buttons.value(idx)->flash();
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPaneManager::togglePage(bool focus)
|
||||
void OutputPaneManager::togglePage(int flags)
|
||||
{
|
||||
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
||||
if (OutputPanePlaceHolder::isCurrentVisible() && currentIndex() == idx)
|
||||
slotHide();
|
||||
else
|
||||
showPage(idx, focus);
|
||||
showPage(idx, flags);
|
||||
}
|
||||
|
||||
void OutputPaneManager::focusInEvent(QFocusEvent *e)
|
||||
@@ -558,7 +560,7 @@ void OutputPaneManager::popupMenu()
|
||||
button->hide();
|
||||
} else {
|
||||
button->show();
|
||||
showPage(idx, false);
|
||||
showPage(idx, IOutputPane::ModeSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ protected:
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
|
||||
private slots:
|
||||
void showPage(bool focus, bool ensureSizeHint);
|
||||
void togglePage(bool focus);
|
||||
void showPage(int flags);
|
||||
void togglePage(int flags);
|
||||
void clearPage();
|
||||
void buttonTriggered();
|
||||
void updateNavigateState();
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
explicit OutputPaneManager(QWidget *parent = 0);
|
||||
~OutputPaneManager();
|
||||
|
||||
void showPage(int idx, bool focus);
|
||||
void showPage(int idx, int flags);
|
||||
void ensurePageVisible(int idx);
|
||||
int findIndexForPage(IOutputPane *out);
|
||||
int currentIndex() const;
|
||||
|
||||
Reference in New Issue
Block a user