forked from qt-creator/qt-creator
make zoom-in/-out apply to all editors
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
#include <coreplugin/stylehelper.h>
|
#include <coreplugin/stylehelper.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <find/basetextfind.h>
|
#include <find/basetextfind.h>
|
||||||
#include <texteditor/fontsettings.h>
|
|
||||||
#include <utils/reloadpromptutils.h>
|
#include <utils/reloadpromptutils.h>
|
||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -3114,8 +3114,9 @@ void BaseTextEditor::zoomIn(int range)
|
|||||||
const int newSize = f.pointSize() + range;
|
const int newSize = f.pointSize() + range;
|
||||||
if (newSize <= 0)
|
if (newSize <= 0)
|
||||||
return;
|
return;
|
||||||
f.setPointSize(newSize);
|
emit requestFontSize(newSize);
|
||||||
setFont(f);
|
// f.setPointSize(newSize);
|
||||||
|
// setFont(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditor::zoomOut(int range)
|
void BaseTextEditor::zoomOut(int range)
|
||||||
@@ -3837,6 +3838,24 @@ void BaseTextEditor::unCommentSelection()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextEditor::showEvent(QShowEvent* e)
|
||||||
|
{
|
||||||
|
if (!d->m_fontSettings.isEmpty()) {
|
||||||
|
setFontSettings(d->m_fontSettings);
|
||||||
|
d->m_fontSettings.clear();
|
||||||
|
}
|
||||||
|
QPlainTextEdit::showEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BaseTextEditor::setFontSettingsIfVisible(const TextEditor::FontSettings &fs)
|
||||||
|
{
|
||||||
|
if (!isVisible()) {
|
||||||
|
d->m_fontSettings = fs;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setFontSettings(fs);
|
||||||
|
}
|
||||||
void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
||||||
{
|
{
|
||||||
const QTextCharFormat textFormat = fs.toTextCharFormat(QLatin1String(Constants::C_TEXT));
|
const QTextCharFormat textFormat = fs.toTextCharFormat(QLatin1String(Constants::C_TEXT));
|
||||||
|
|||||||
@@ -408,6 +408,8 @@ protected:
|
|||||||
void wheelEvent(QWheelEvent *e);
|
void wheelEvent(QWheelEvent *e);
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
// reimplemented to support block selection
|
// reimplemented to support block selection
|
||||||
QMimeData *createMimeDataFromSelection() const;
|
QMimeData *createMimeDataFromSelection() const;
|
||||||
bool canInsertFromMimeData(const QMimeData *source) const;
|
bool canInsertFromMimeData(const QMimeData *source) const;
|
||||||
@@ -483,6 +485,7 @@ public slots:
|
|||||||
virtual void format();
|
virtual void format();
|
||||||
virtual void unCommentSelection();
|
virtual void unCommentSelection();
|
||||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||||
|
void setFontSettingsIfVisible(const TextEditor::FontSettings &);
|
||||||
virtual void setTabSettings(const TextEditor::TabSettings &);
|
virtual void setTabSettings(const TextEditor::TabSettings &);
|
||||||
virtual void setDisplaySettings(const TextEditor::DisplaySettings &);
|
virtual void setDisplaySettings(const TextEditor::DisplaySettings &);
|
||||||
virtual void setStorageSettings(const TextEditor::StorageSettings &);
|
virtual void setStorageSettings(const TextEditor::StorageSettings &);
|
||||||
@@ -511,6 +514,7 @@ protected slots:
|
|||||||
virtual void slotUpdateBlockNotify(const QTextBlock &);
|
virtual void slotUpdateBlockNotify(const QTextBlock &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void requestFontSize(int pointSize);
|
||||||
void requestBlockUpdate(const QTextBlock &);
|
void requestBlockUpdate(const QTextBlock &);
|
||||||
void requestAutoCompletion(ITextEditable *editor, bool forced);
|
void requestAutoCompletion(ITextEditable *editor, bool forced);
|
||||||
void requestQuickFix(ITextEditable *editor);
|
void requestQuickFix(ITextEditable *editor);
|
||||||
@@ -534,6 +538,7 @@ private:
|
|||||||
|
|
||||||
QTextBlock collapsedBlockAt(const QPoint &pos, QRect *box = 0) const;
|
QTextBlock collapsedBlockAt(const QPoint &pos, QRect *box = 0) const;
|
||||||
|
|
||||||
|
|
||||||
// parentheses matcher
|
// parentheses matcher
|
||||||
private slots:
|
private slots:
|
||||||
void _q_matchParentheses();
|
void _q_matchParentheses();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#define BASETEXTEDITOR_P_H
|
#define BASETEXTEDITOR_P_H
|
||||||
|
|
||||||
#include "basetexteditor.h"
|
#include "basetexteditor.h"
|
||||||
|
#include <texteditor/fontsettings.h>
|
||||||
|
|
||||||
#include <QtCore/QBasicTimer>
|
#include <QtCore/QBasicTimer>
|
||||||
#include <QtCore/QSharedData>
|
#include <QtCore/QSharedData>
|
||||||
@@ -174,6 +175,7 @@ public:
|
|||||||
|
|
||||||
QWidget *m_extraArea;
|
QWidget *m_extraArea;
|
||||||
DisplaySettings m_displaySettings;
|
DisplaySettings m_displaySettings;
|
||||||
|
TextEditor::FontSettings m_fontSettings;
|
||||||
|
|
||||||
int extraAreaSelectionAnchorBlockNumber;
|
int extraAreaSelectionAnchorBlockNumber;
|
||||||
int extraAreaToggleMarkBlockNumber;
|
int extraAreaToggleMarkBlockNumber;
|
||||||
|
|||||||
@@ -136,12 +136,11 @@ bool Format::equals(const Format &f) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- FontSettings
|
// -- FontSettings
|
||||||
FontSettings::FontSettings(const FormatDescriptions &fd) :
|
FontSettings::FontSettings() :
|
||||||
m_family(defaultFixedFontFamily()),
|
m_family(defaultFixedFontFamily()),
|
||||||
m_fontSize(DEFAULT_FONT_SIZE),
|
m_fontSize(DEFAULT_FONT_SIZE),
|
||||||
m_antialias(DEFAULT_ANTIALIAS)
|
m_antialias(DEFAULT_ANTIALIAS)
|
||||||
{
|
{
|
||||||
Q_UNUSED(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettings::clear()
|
void FontSettings::clear()
|
||||||
@@ -149,7 +148,8 @@ void FontSettings::clear()
|
|||||||
m_family = defaultFixedFontFamily();
|
m_family = defaultFixedFontFamily();
|
||||||
m_fontSize = DEFAULT_FONT_SIZE;
|
m_fontSize = DEFAULT_FONT_SIZE;
|
||||||
m_antialias = DEFAULT_ANTIALIAS;
|
m_antialias = DEFAULT_ANTIALIAS;
|
||||||
qFill(m_formats.begin(), m_formats.end(), Format());
|
m_formats.clear();
|
||||||
|
//qFill(m_formats.begin(), m_formats.end(), Format());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettings::toSettings(const QString &category,
|
void FontSettings::toSettings(const QString &category,
|
||||||
|
|||||||
@@ -88,8 +88,9 @@ class TEXTEDITOR_EXPORT FontSettings
|
|||||||
public:
|
public:
|
||||||
typedef QList<FormatDescription> FormatDescriptions;
|
typedef QList<FormatDescription> FormatDescriptions;
|
||||||
|
|
||||||
FontSettings(const FormatDescriptions &fd);
|
FontSettings();
|
||||||
void clear();
|
void clear();
|
||||||
|
inline bool isEmpty() const { return m_formats.isEmpty(); }
|
||||||
|
|
||||||
void toSettings(const QString &category,
|
void toSettings(const QString &category,
|
||||||
const FormatDescriptions &descriptions,
|
const FormatDescriptions &descriptions,
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ FontSettingsPagePrivate::FontSettingsPagePrivate(const TextEditor::FormatDescrip
|
|||||||
m_category(category),
|
m_category(category),
|
||||||
m_trCategory(trCategory),
|
m_trCategory(trCategory),
|
||||||
m_descriptions(fd),
|
m_descriptions(fd),
|
||||||
m_value(fd),
|
|
||||||
m_lastValue(fd),
|
|
||||||
m_curItem(-1)
|
m_curItem(-1)
|
||||||
{
|
{
|
||||||
bool settingsFound = false;
|
bool settingsFound = false;
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor)
|
|||||||
{
|
{
|
||||||
// Connect to settings change signals
|
// Connect to settings change signals
|
||||||
connect(this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
connect(this, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
||||||
editor, SLOT(setFontSettings(TextEditor::FontSettings)));
|
editor, SLOT(setFontSettingsIfVisible(TextEditor::FontSettings)));
|
||||||
connect(this, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)),
|
connect(this, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)),
|
||||||
editor, SLOT(setTabSettings(TextEditor::TabSettings)));
|
editor, SLOT(setTabSettings(TextEditor::TabSettings)));
|
||||||
connect(this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
connect(this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
||||||
@@ -160,6 +160,9 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor)
|
|||||||
connect(this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
|
connect(this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
|
||||||
editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
|
editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
|
||||||
|
|
||||||
|
connect(editor, SIGNAL(requestFontSize(int)),
|
||||||
|
this, SLOT(fontSizeRequested(int)));
|
||||||
|
|
||||||
// Apply current settings (tab settings depend on font settings)
|
// Apply current settings (tab settings depend on font settings)
|
||||||
editor->setFontSettings(fontSettings());
|
editor->setFontSettings(fontSettings());
|
||||||
editor->setTabSettings(tabSettings());
|
editor->setTabSettings(tabSettings());
|
||||||
@@ -167,6 +170,14 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor)
|
|||||||
editor->setDisplaySettings(displaySettings());
|
editor->setDisplaySettings(displaySettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TextEditorSettings::fontSizeRequested(int pointSize)
|
||||||
|
{
|
||||||
|
FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings());
|
||||||
|
fs.setFontSize(pointSize);
|
||||||
|
emit fontSettingsChanged(m_fontSettingsPage->fontSettings());
|
||||||
|
}
|
||||||
|
|
||||||
FontSettings TextEditorSettings::fontSettings() const
|
FontSettings TextEditorSettings::fontSettings() const
|
||||||
{
|
{
|
||||||
return m_fontSettingsPage->fontSettings();
|
return m_fontSettingsPage->fontSettings();
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ signals:
|
|||||||
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
||||||
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void fontSizeRequested(int pointSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FontSettingsPage *m_fontSettingsPage;
|
FontSettingsPage *m_fontSettingsPage;
|
||||||
BehaviorSettingsPage *m_behaviorSettingsPage;
|
BehaviorSettingsPage *m_behaviorSettingsPage;
|
||||||
|
|||||||
Reference in New Issue
Block a user