forked from qt-creator/qt-creator
General Messages Pane: Add font settings and zoom
As the settings are managed by TextEditor, but Core does not depend on TextEditor, no signal connection can be used. Instead, call the needed functions in MessageManager directly. Fixes: QTCREATORBUG-18908 Change-Id: Idc81f1071d5228cd6582e3a00189a5db24288fc6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
68a10d71e7
commit
ee801a0eb5
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
static MessageManager *m_instance = nullptr;
|
static MessageManager *m_instance = nullptr;
|
||||||
@@ -76,6 +78,20 @@ void MessageManager::init()
|
|||||||
ExtensionSystem::PluginManager::addObject(m_messageOutputWindow);
|
ExtensionSystem::PluginManager::addObject(m_messageOutputWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageManager::setFont(const QFont &font)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_messageOutputWindow, return);
|
||||||
|
|
||||||
|
m_messageOutputWindow->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageManager::setWheelZoomEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_messageOutputWindow, return);
|
||||||
|
|
||||||
|
m_messageOutputWindow->setWheelZoomEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageManager::write(const QString &text, PrintToOutputPaneFlags flags)
|
void MessageManager::write(const QString &text, PrintToOutputPaneFlags flags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_messageOutputWindow, return);
|
QTC_ASSERT(m_messageOutputWindow, return);
|
||||||
|
@@ -31,6 +31,10 @@
|
|||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QFont;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
namespace Internal { class MainWindow; }
|
namespace Internal { class MainWindow; }
|
||||||
@@ -55,6 +59,9 @@ public:
|
|||||||
|
|
||||||
static void showOutputPane(Core::MessageManager::PrintToOutputPaneFlags flags = NoModeSwitch);
|
static void showOutputPane(Core::MessageManager::PrintToOutputPaneFlags flags = NoModeSwitch);
|
||||||
|
|
||||||
|
static void setFont(const QFont &font);
|
||||||
|
static void setWheelZoomEnabled(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
static void write(const QString &text,
|
static void write(const QString &text,
|
||||||
Core::MessageManager::PrintToOutputPaneFlags flags = NoModeSwitch);
|
Core::MessageManager::PrintToOutputPaneFlags flags = NoModeSwitch);
|
||||||
|
@@ -30,11 +30,20 @@
|
|||||||
#include "find/basetextfind.h"
|
#include "find/basetextfind.h"
|
||||||
|
|
||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
MessageOutputWindow::MessageOutputWindow()
|
const char zoomSettingsKey[] = "Core/MessageOutput/Zoom";
|
||||||
|
|
||||||
|
MessageOutputWindow::MessageOutputWindow() :
|
||||||
|
m_zoomInButton(new QToolButton),
|
||||||
|
m_zoomOutButton(new QToolButton)
|
||||||
{
|
{
|
||||||
m_widget = new OutputWindow(Context(Constants::C_GENERAL_OUTPUT_PANE));
|
m_widget = new OutputWindow(Context(Constants::C_GENERAL_OUTPUT_PANE));
|
||||||
m_widget->setReadOnly(true);
|
m_widget->setReadOnly(true);
|
||||||
@@ -49,10 +58,27 @@ MessageOutputWindow::MessageOutputWindow()
|
|||||||
auto agg = new Aggregation::Aggregate;
|
auto agg = new Aggregation::Aggregate;
|
||||||
agg->add(m_widget);
|
agg->add(m_widget);
|
||||||
agg->add(new BaseTextFind(m_widget));
|
agg->add(new BaseTextFind(m_widget));
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
|
m_zoomInButton->setToolTip(tr("Increase Font Size"));
|
||||||
|
m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
||||||
|
m_zoomInButton->setAutoRaise(true);
|
||||||
|
connect(m_zoomInButton, &QToolButton::clicked, this, [this] { m_widget->zoomIn(1); });
|
||||||
|
|
||||||
|
m_zoomOutButton->setToolTip(tr("Decrease Font Size"));
|
||||||
|
m_zoomOutButton->setIcon(Utils::Icons::MINUS.icon());
|
||||||
|
m_zoomOutButton->setAutoRaise(true);
|
||||||
|
connect(m_zoomOutButton, &QToolButton::clicked, this, [this] { m_widget->zoomOut(1); });
|
||||||
|
|
||||||
|
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
|
||||||
|
this, &MessageOutputWindow::storeSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageOutputWindow::~MessageOutputWindow()
|
MessageOutputWindow::~MessageOutputWindow()
|
||||||
{
|
{
|
||||||
|
delete m_zoomInButton;
|
||||||
|
delete m_zoomOutButton;
|
||||||
delete m_widget;
|
delete m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +108,11 @@ QWidget *MessageOutputWindow::outputWidget(QWidget *parent)
|
|||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QWidget *> MessageOutputWindow::toolBarWidgets() const
|
||||||
|
{
|
||||||
|
return {m_zoomInButton, m_zoomOutButton};
|
||||||
|
}
|
||||||
|
|
||||||
QString MessageOutputWindow::displayName() const
|
QString MessageOutputWindow::displayName() const
|
||||||
{
|
{
|
||||||
return tr("General Messages");
|
return tr("General Messages");
|
||||||
@@ -126,5 +157,30 @@ bool MessageOutputWindow::canNavigate() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageOutputWindow::setFont(const QFont &font)
|
||||||
|
{
|
||||||
|
m_widget->setBaseFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageOutputWindow::setWheelZoomEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_widget->setWheelZoomEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageOutputWindow::storeSettings() const
|
||||||
|
{
|
||||||
|
QSettings * const s = Core::ICore::settings();
|
||||||
|
|
||||||
|
s->setValue(zoomSettingsKey, m_widget->fontZoom());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageOutputWindow::loadSettings()
|
||||||
|
{
|
||||||
|
QSettings * const s = Core::ICore::settings();
|
||||||
|
|
||||||
|
float zoom = s->value(zoomSettingsKey, 0).toFloat();
|
||||||
|
m_widget->setFontZoom(zoom);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
#include "ioutputpane.h"
|
#include "ioutputpane.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QFont;
|
||||||
|
class QToolButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class OutputWindow;
|
class OutputWindow;
|
||||||
|
|
||||||
@@ -41,7 +46,7 @@ public:
|
|||||||
~MessageOutputWindow() override;
|
~MessageOutputWindow() override;
|
||||||
|
|
||||||
QWidget *outputWidget(QWidget *parent) override;
|
QWidget *outputWidget(QWidget *parent) override;
|
||||||
QList<QWidget*> toolBarWidgets() const override { return {}; }
|
QList<QWidget*> toolBarWidgets() const override;
|
||||||
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
int priorityInStatusBar() const override;
|
int priorityInStatusBar() const override;
|
||||||
@@ -59,8 +64,16 @@ public:
|
|||||||
void goToPrev() override;
|
void goToPrev() override;
|
||||||
bool canNavigate() const override;
|
bool canNavigate() const override;
|
||||||
|
|
||||||
|
void setFont(const QFont &font);
|
||||||
|
void setWheelZoomEnabled(bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void storeSettings() const;
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
OutputWindow *m_widget;
|
OutputWindow *m_widget;
|
||||||
|
QToolButton *m_zoomInButton = nullptr;
|
||||||
|
QToolButton *m_zoomOutButton = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -367,14 +368,27 @@ TextEditorSettings::TextEditorSettings()
|
|||||||
new SnippetsSettingsPage(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS, this);
|
new SnippetsSettingsPage(Constants::TEXT_EDITOR_SNIPPETS_SETTINGS, this);
|
||||||
d->m_completionSettingsPage = new CompletionSettingsPage(this);
|
d->m_completionSettingsPage = new CompletionSettingsPage(this);
|
||||||
|
|
||||||
|
auto updateGeneralMessagesFontSettings = []() {
|
||||||
|
Core::MessageManager::setFont(d->m_fontSettingsPage->fontSettings().font());
|
||||||
|
};
|
||||||
connect(d->m_fontSettingsPage, &FontSettingsPage::changed,
|
connect(d->m_fontSettingsPage, &FontSettingsPage::changed,
|
||||||
this, &TextEditorSettings::fontSettingsChanged);
|
this, &TextEditorSettings::fontSettingsChanged);
|
||||||
|
connect(d->m_fontSettingsPage, &FontSettingsPage::changed,
|
||||||
|
this, updateGeneralMessagesFontSettings);
|
||||||
|
updateGeneralMessagesFontSettings();
|
||||||
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::typingSettingsChanged,
|
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::typingSettingsChanged,
|
||||||
this, &TextEditorSettings::typingSettingsChanged);
|
this, &TextEditorSettings::typingSettingsChanged);
|
||||||
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::storageSettingsChanged,
|
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::storageSettingsChanged,
|
||||||
this, &TextEditorSettings::storageSettingsChanged);
|
this, &TextEditorSettings::storageSettingsChanged);
|
||||||
|
auto updateGeneralMessagesBehaviorSettings = []() {
|
||||||
|
bool wheelZoom = d->m_behaviorSettingsPage->behaviorSettings().m_scrollWheelZooming;
|
||||||
|
Core::MessageManager::setWheelZoomEnabled(wheelZoom);
|
||||||
|
};
|
||||||
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::behaviorSettingsChanged,
|
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::behaviorSettingsChanged,
|
||||||
this, &TextEditorSettings::behaviorSettingsChanged);
|
this, &TextEditorSettings::behaviorSettingsChanged);
|
||||||
|
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::behaviorSettingsChanged,
|
||||||
|
this, updateGeneralMessagesBehaviorSettings);
|
||||||
|
updateGeneralMessagesBehaviorSettings();
|
||||||
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::extraEncodingSettingsChanged,
|
connect(d->m_behaviorSettingsPage, &BehaviorSettingsPage::extraEncodingSettingsChanged,
|
||||||
this, &TextEditorSettings::extraEncodingSettingsChanged);
|
this, &TextEditorSettings::extraEncodingSettingsChanged);
|
||||||
connect(d->m_displaySettingsPage, &DisplaySettingsPage::marginSettingsChanged,
|
connect(d->m_displaySettingsPage, &DisplaySettingsPage::marginSettingsChanged,
|
||||||
|
Reference in New Issue
Block a user