MessageManger::printToOutputPane: Add more control over the popup

Change-Id: I40254c0d152bf1d94c74e2602e5bfb642fe933e1
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Daniel Teske
2013-03-12 16:13:34 +01:00
parent 2bb2628054
commit f4b19e0e8f
2 changed files with 32 additions and 4 deletions

View File

@@ -43,6 +43,7 @@ MessageManager::MessageManager()
: m_messageOutputWindow(0) : m_messageOutputWindow(0)
{ {
m_instance = this; m_instance = this;
qRegisterMetaType<Core::MessageManager::PrintToOutputPaneFlags>();
} }
MessageManager::~MessageManager() MessageManager::~MessageManager()
@@ -68,21 +69,33 @@ void MessageManager::showOutputPane()
} }
void MessageManager::printToOutputPane(const QString &text, bool bringToForeground) void MessageManager::printToOutputPane(const QString &text, bool bringToForeground)
{
printToOutputPane(text, bringToForeground ? ModeSwitch
: Silent);
}
void MessageManager::printToOutputPane(const QString &text, PrintToOutputPaneFlags flags)
{ {
if (!m_messageOutputWindow) if (!m_messageOutputWindow)
return; return;
if (bringToForeground) if (flags & Flash) {
m_messageOutputWindow->popup(IOutputPane::ModeSwitch); m_messageOutputWindow->flash();
} else if (flags & Silent) {
// Do nothing
} else {
m_messageOutputWindow->popup(Core::IOutputPane::Flag(int(flags)));
}
m_messageOutputWindow->append(text + QLatin1Char('\n')); m_messageOutputWindow->append(text + QLatin1Char('\n'));
} }
void MessageManager::printToOutputPanePopup(const QString &text) void MessageManager::printToOutputPanePopup(const QString &text)
{ {
printToOutputPane(text, true); printToOutputPane(text, ModeSwitch);
} }
void MessageManager::printToOutputPane(const QString &text) void MessageManager::printToOutputPane(const QString &text)
{ {
printToOutputPane(text, false); printToOutputPane(text, Silent);
} }

View File

@@ -31,6 +31,9 @@
#define MESSAGEMANAGER_H #define MESSAGEMANAGER_H
#include "core_global.h" #include "core_global.h"
#include "ioutputpane.h"
#include <QMetaType>
#include <QObject> #include <QObject>
namespace Core { namespace Core {
@@ -52,11 +55,21 @@ public:
static MessageManager *instance() { return m_instance; } static MessageManager *instance() { return m_instance; }
void showOutputPane(); void showOutputPane();
enum PrintToOutputPaneFlag {
NoModeSwitch = Core::IOutputPane::NoModeSwitch,
ModeSwitch = Core::IOutputPane::ModeSwitch,
WithFocus = Core::IOutputPane::WithFocus,
EnsureSizeHint = Core::IOutputPane::EnsureSizeHint,
Silent = 256,
Flash = 512 };
Q_DECLARE_FLAGS(PrintToOutputPaneFlags, PrintToOutputPaneFlag)
public slots: public slots:
void printToOutputPane(const QString &text, bool bringToForeground); void printToOutputPane(const QString &text, bool bringToForeground);
void printToOutputPanePopup(const QString &text); // pops up void printToOutputPanePopup(const QString &text); // pops up
void printToOutputPane(const QString &text); void printToOutputPane(const QString &text);
void printToOutputPane(const QString &text, Core::MessageManager::PrintToOutputPaneFlags flags);
private: private:
Internal::MessageOutputWindow *m_messageOutputWindow; Internal::MessageOutputWindow *m_messageOutputWindow;
@@ -66,4 +79,6 @@ private:
} // namespace Core } // namespace Core
Q_DECLARE_METATYPE(Core::MessageManager::PrintToOutputPaneFlags)
#endif // MESSAGEMANAGER_H #endif // MESSAGEMANAGER_H