forked from qt-creator/qt-creator
TextEditor: Make TextEditorSettings all static
Move the fading indicator to the widget Change-Id: I762c46845153c93c75ea0198c993b655559fad3b Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
0f8a3abb8b
commit
3f46e3da30
@@ -81,6 +81,7 @@
|
||||
#include <utils/linecolumnlabel.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/dropsupport.h>
|
||||
#include <utils/fadingindicator.h>
|
||||
#include <utils/filesearch.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
@@ -3022,11 +3023,6 @@ void TextEditorWidgetPrivate::setupDocumentSignals()
|
||||
connect(settings, &TextEditorSettings::extraEncodingSettingsChanged,
|
||||
q, &TextEditorWidget::setExtraEncodingSettings);
|
||||
|
||||
connect(q, &TextEditorWidget::requestFontZoom,
|
||||
settings, &TextEditorSettings::fontZoomRequested);
|
||||
connect(q, &TextEditorWidget::requestZoomReset,
|
||||
settings, &TextEditorSettings::zoomResetRequested);
|
||||
|
||||
// Apply current settings
|
||||
m_document->setFontSettings(settings->fontSettings());
|
||||
m_document->setTabSettings(settings->codeStyle()->tabSettings()); // also set through code style ???
|
||||
@@ -5494,12 +5490,15 @@ void TextEditorWidget::zoomF(float delta)
|
||||
else if (step < 0 && step > -1)
|
||||
step = -1;
|
||||
|
||||
emit requestFontZoom(step);
|
||||
const int newZoom = TextEditorSettings::instance()->increaseFontZoom(int(step));
|
||||
Utils::FadingIndicator::showText(this,
|
||||
tr("Zoom: %1%").arg(newZoom),
|
||||
Utils::FadingIndicator::SmallText);
|
||||
}
|
||||
|
||||
void TextEditorWidget::zoomReset()
|
||||
{
|
||||
emit requestZoomReset();
|
||||
TextEditorSettings::instance()->resetFontZoom();
|
||||
}
|
||||
|
||||
TextEditorWidget::Link TextEditorWidget::findLinkAt(const QTextCursor &, bool, bool)
|
||||
|
||||
@@ -479,8 +479,6 @@ signals:
|
||||
void assistFinished(); // Used in tests.
|
||||
void readOnlyChanged();
|
||||
|
||||
void requestFontZoom(int zoom);
|
||||
void requestZoomReset();
|
||||
void requestBlockUpdate(const QTextBlock &);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/fadingindicator.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QApplication>
|
||||
@@ -509,23 +508,19 @@ Core::Id TextEditorSettings::languageId(const QString &mimeType)
|
||||
return d->m_mimeTypeToLanguage.value(mimeType);
|
||||
}
|
||||
|
||||
void TextEditorSettings::fontZoomRequested(int zoom)
|
||||
int TextEditorSettings::increaseFontZoom(int step)
|
||||
{
|
||||
FontSettings &fs = const_cast<FontSettings&>(d->m_fontSettingsPage->fontSettings());
|
||||
const int previousZoom = fs.fontZoom();
|
||||
const int newZoom = qMax(10, previousZoom + zoom);
|
||||
if (newZoom == previousZoom)
|
||||
return;
|
||||
const int newZoom = qMax(10, previousZoom + step);
|
||||
if (newZoom != previousZoom) {
|
||||
fs.setFontZoom(newZoom);
|
||||
if (QWidget *editor = qobject_cast<QWidget *>(sender())) {
|
||||
Utils::FadingIndicator::showText(editor,
|
||||
tr("Zoom: %1%").arg(newZoom),
|
||||
Utils::FadingIndicator::SmallText);
|
||||
}
|
||||
d->m_fontSettingsPage->saveSettings();
|
||||
}
|
||||
return newZoom;
|
||||
}
|
||||
|
||||
void TextEditorSettings::zoomResetRequested()
|
||||
void TextEditorSettings::resetFontZoom()
|
||||
{
|
||||
FontSettings &fs = const_cast<FontSettings&>(d->m_fontSettingsPage->fontSettings());
|
||||
fs.setFontZoom(100);
|
||||
|
||||
@@ -103,8 +103,8 @@ public:
|
||||
|
||||
static void registerMimeTypeForLanguageId(const char *mimeType, Core::Id languageId);
|
||||
static Core::Id languageId(const QString &mimeType);
|
||||
void fontZoomRequested(int zoom);
|
||||
void zoomResetRequested();
|
||||
static int increaseFontZoom(int step);
|
||||
static void resetFontZoom();
|
||||
|
||||
signals:
|
||||
void fontSettingsChanged(const TextEditor::FontSettings &);
|
||||
|
||||
Reference in New Issue
Block a user