Commit ff6e9333 authored by Daniel Teske's avatar Daniel Teske

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: default avatarEike Ziller <eike.ziller@nokia.com>
parent aafac06a
......@@ -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;
......
......@@ -285,7 +285,7 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search)
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
Find::SearchResultWindow::instance()->popup(true);
Find::SearchResultWindow::instance()->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
QFuture<Usage> result;
result = QtConcurrent::run(&find_helper, workingCopy,
......@@ -661,7 +661,7 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
Find::SearchResultWindow::instance()->popup(true);
Find::SearchResultWindow::instance()->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
......
......@@ -175,7 +175,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool)));
window->popup(true);
window->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
SymbolsFindParameters parameters;
parameters.text = txt;
......
......@@ -184,7 +184,8 @@ namespace Internal {
QTC_ASSERT(widget, return);
int internalIndex = m_searchResultWidgets.indexOf(widget) + 1/*account for "new search" entry*/;
setCurrentIndex(internalIndex, focus);
q->popup(focus);
q->popup(focus ? Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus
: Core::IOutputPane::NoModeSwitch);
}
}
......@@ -480,7 +481,7 @@ void SearchResultWindow::setTextEditorFont(const QFont &font)
void SearchResultWindow::openNewSearchPanel()
{
d->setCurrentIndex(0);
popup(true/*focus*/, true/*sizeHint*/);
popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus | IOutputPane::EnsureSizeHint);
}
/*!
......
......@@ -309,7 +309,8 @@ void FetchContext::startWritePatchFile()
void FetchContext::startCherryPick()
{
VcsBase::VcsBaseOutputWindow::instance()->popup(); // Point user to errors.
// Point user to errors.
VcsBase::VcsBaseOutputWindow::instance()->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
VcsBase::VcsBaseOutputWindow::instance()->append(tr("Cherry-picking %1...").arg(m_patchFileName));
QStringList args;
args << QLatin1String("cherry-pick") << QLatin1String("FETCH_HEAD");
......
......@@ -591,7 +591,7 @@ void PerforcePlugin::printOpenedFileList()
outWin->appendSilently(mapped + QLatin1Char(' ') + line.mid(delimiterPos));
}
}
outWin->popup();
outWin->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
}
void PerforcePlugin::startSubmitProject()
......
......@@ -284,17 +284,17 @@ void BuildManager::clearBuildQueue()
void BuildManager::toggleOutputWindow()
{
d->m_outputWindow->toggle(false);
d->m_outputWindow->toggle(Core::IOutputPane::ModeSwitch);
}
void BuildManager::showTaskWindow()
{
d->m_taskWindow->popup(false);
d->m_taskWindow->popup(Core::IOutputPane::NoModeSwitch);
}
void BuildManager::toggleTaskWindow()
{
d->m_taskWindow->toggle(false);
d->m_taskWindow->toggle(Core::IOutputPane::ModeSwitch);
}
bool BuildManager::tasksAvailable() const
......@@ -546,12 +546,12 @@ bool BuildManager::buildLists(QList<BuildStepList *> bsls, const QStringList &st
bool success = buildQueueAppend(steps, names);
if (!success) {
d->m_outputWindow->popup(false);
d->m_outputWindow->popup(Core::IOutputPane::NoModeSwitch);
return false;
}
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput)
d->m_outputWindow->popup(false);
d->m_outputWindow->popup(Core::IOutputPane::NoModeSwitch);
startBuildQueue(preambelMessage);
return true;
}
......@@ -560,11 +560,11 @@ void BuildManager::appendStep(BuildStep *step, const QString &name)
{
bool success = buildQueueAppend(QList<BuildStep *>() << step, QStringList() << name);
if (!success) {
d->m_outputWindow->popup(false);
d->m_outputWindow->popup(Core::IOutputPane::NoModeSwitch);
return;
}
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput)
d->m_outputWindow->popup(false);
d->m_outputWindow->popup(Core::IOutputPane::NoModeSwitch);
startBuildQueue();
}
......
......@@ -1595,10 +1595,10 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, RunMode runM
{
d->m_outputPane->createNewOutputWindow(runControl);
if (runMode == NormalRunMode && d->m_projectExplorerSettings.showRunOutput)
d->m_outputPane->popup(false);
d->m_outputPane->popup(Core::IOutputPane::NoModeSwitch);
if ((runMode == DebugRunMode || runMode == DebugRunModeWithBreakOnMain)
&& d->m_projectExplorerSettings.showDebugOutput)
d->m_outputPane->popup(false);
d->m_outputPane->popup(Core::IOutputPane::NoModeSwitch);
d->m_outputPane->showTabFor(runControl);
connect(runControl, SIGNAL(finished()), this, SLOT(runControlFinished()));
runControl->start();
......
......@@ -53,7 +53,8 @@ bool ShowOutputTaskHandler::canHandle(const ProjectExplorer::Task &task) const
void ShowOutputTaskHandler::handle(const ProjectExplorer::Task &task)
{
Q_ASSERT(canHandle(task));
m_window->popup(); // popup first as this does move the visible area!
// popup first as this does move the visible area!
m_window->popup(Core::IOutputPane::Flags(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus));
m_window->showPositionOf(task);
}
......
......@@ -31,6 +31,7 @@
#include "taskhub.h"
#include "extensionsystem/pluginmanager.h"
#include "projectexplorer.h"
#include <coreplugin/ioutputpane.h>
#include <texteditor/basetextmark.h>
#include <QMetaType>
......@@ -152,7 +153,7 @@ void TaskHub::setCategoryVisibility(const Core::Id &categoryId, bool visible)
void TaskHub::requestPopup()
{
emit popupRequested(false);
emit popupRequested(Core::IOutputPane::NoModeSwitch);
}
QIcon TaskHub::taskTypeIcon(Task::TaskType t) const
......
......@@ -67,7 +67,7 @@ signals:
void taskFileNameUpdated(unsigned int id, const QString &fileName);
void taskLineNumberUpdated(unsigned int id, int line);
void categoryVisibilityChanged(const Core::Id &categoryId, bool visible);
void popupRequested(bool withFocus);
void popupRequested(int);
void showTask(unsigned int id);
void openTask(unsigned int id);
private:
......
......@@ -305,8 +305,8 @@ TaskWindow::TaskWindow(TaskHub *taskhub) : d(new TaskWindowPrivate)
this, SLOT(clearTasks(Core::Id)));
connect(d->m_taskHub, SIGNAL(categoryVisibilityChanged(Core::Id,bool)),
this, SLOT(setCategoryVisibility(Core::Id,bool)));
connect(d->m_taskHub, SIGNAL(popupRequested(bool)),
this, SLOT(popup(bool)));
connect(d->m_taskHub, SIGNAL(popupRequested(int)),
this, SLOT(popup(int)));
connect(d->m_taskHub, SIGNAL(showTask(uint)),
this, SLOT(showTask(uint)));
connect(d->m_taskHub, SIGNAL(openTask(uint)),
......@@ -456,7 +456,7 @@ void TaskWindow::showTask(unsigned int id)
QModelIndex sourceIdx = d->m_model->index(sourceRow, 0);
QModelIndex filterIdx = d->m_filter->mapFromSource(sourceIdx);
d->m_listview->setCurrentIndex(filterIdx);
popup(false);
popup(Core::IOutputPane::ModeSwitch);
}
void TaskWindow::openTask(unsigned int id)
......
......@@ -941,7 +941,7 @@ void FindReferences::displayResults(int first, int last)
this, SLOT(openEditor(Find::SearchResultItem)));
connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel()));
connect(m_currentSearch, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
Find::SearchResultWindow::instance()->popup(true);
Find::SearchResultWindow::instance()->popup(Core::IOutputPane::Flags(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus));
Core::ProgressManager *progressManager = Core::ICore::progressManager();
Core::FutureProgress *progress = progressManager->addTask(
......
......@@ -148,7 +148,7 @@ void BaseFileFind::runSearch(Find::SearchResult *search)
FileFindParameters parameters = search->userData().value<FileFindParameters>();
CountingLabel *label = new CountingLabel;
connect(search, SIGNAL(countChanged(int)), label, SLOT(updateCount(int)));
Find::SearchResultWindow::instance()->popup(true);
Find::SearchResultWindow::instance()->popup(Core::IOutputPane::Flags(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus));
QFutureWatcher<FileSearchResultList> *watcher = new QFutureWatcher<FileSearchResultList>();
m_watchers.insert(watcher, search);
watcher->setPendingResultsLimit(1);
......
......@@ -191,7 +191,7 @@ void ValgrindEngine::receiveProcessError(const QString &error, QProcess::Process
QList<Core::IOutputPane *> panes = ExtensionSystem::PluginManager::getObjects<Core::IOutputPane>();
foreach (Core::IOutputPane *pane, panes) {
if (pane->displayName() == tr("Application Output")) {
pane->popup(false);
pane->popup(Core::IOutputPane::NoModeSwitch);
break;
}
}
......
......@@ -370,23 +370,22 @@ void VcsBaseOutputWindow::appendSilently(const QString &text)
void VcsBaseOutputWindow::append(const QString &text)
{
appendSilently(text);
// Pop up without focus
if (!d->plainTextEdit()->isVisible())
popup(false);
popup(Core::IOutputPane::NoModeSwitch);
}
void VcsBaseOutputWindow::appendError(const QString &text)
{
d->plainTextEdit()->appendError(text);
if (!d->plainTextEdit()->isVisible())
popup(false); // Pop up without focus
popup(Core::IOutputPane::NoModeSwitch);
}
void VcsBaseOutputWindow::appendWarning(const QString &text)
{
d->plainTextEdit()->appendWarning(text);
if (!d->plainTextEdit()->isVisible())
popup(false); // Pop up without focus
popup(Core::IOutputPane::NoModeSwitch);
}
// Helper to format arguments for log windows hiding common password
......@@ -441,7 +440,7 @@ void VcsBaseOutputWindow::appendData(const QByteArray &data)
{
appendDataSilently(data);
if (!d->plainTextEdit()->isVisible())
popup(false); // Pop up without focus
popup(Core::IOutputPane::NoModeSwitch);
}
void VcsBaseOutputWindow::appendDataSilently(const QByteArray &data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment