Commit 545c9b91 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Text editor settings cleanup to avoid some copying

parent ed5a0fb0
......@@ -195,17 +195,17 @@ void BehaviorSettingsPage::settingsToUI()
m_d->m_page.scrollWheelZooming->setChecked(behaviorSettings.m_scrollWheelZooming);
}
TabSettings BehaviorSettingsPage::tabSettings() const
const TabSettings &BehaviorSettingsPage::tabSettings() const
{
return m_d->m_tabSettings;
}
StorageSettings BehaviorSettingsPage::storageSettings() const
const StorageSettings &BehaviorSettingsPage::storageSettings() const
{
return m_d->m_storageSettings;
}
BehaviorSettings BehaviorSettingsPage::behaviorSettings() const
const BehaviorSettings &BehaviorSettingsPage::behaviorSettings() const
{
return m_d->m_behaviorSettings;
}
......
......@@ -69,9 +69,9 @@ public:
void apply();
void finish() { }
TabSettings tabSettings() const;
StorageSettings storageSettings() const;
BehaviorSettings behaviorSettings() const;
const TabSettings &tabSettings() const;
const StorageSettings &storageSettings() const;
const BehaviorSettings &behaviorSettings() const;
virtual bool matches(const QString &s) const;
......
......@@ -113,17 +113,7 @@ void DisplaySettingsPage::apply()
DisplaySettings newDisplaySettings;
settingsFromUI(newDisplaySettings);
Core::ICore *core = Core::ICore::instance();
QSettings *s = core->settings();
if (newDisplaySettings != m_d->m_displaySettings) {
m_d->m_displaySettings = newDisplaySettings;
if (s)
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
emit displaySettingsChanged(newDisplaySettings);
}
setDisplaySettings(newDisplaySettings);
}
void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
......@@ -157,7 +147,7 @@ void DisplaySettingsPage::settingsToUI()
m_d->m_page.autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
}
DisplaySettings DisplaySettingsPage::displaySettings() const
const DisplaySettings &DisplaySettingsPage::displaySettings() const
{
return m_d->m_displaySettings;
}
......
......@@ -68,8 +68,7 @@ public:
void finish() { }
virtual bool matches(const QString &s) const;
DisplaySettings displaySettings() const;
void setDisplaySettings(const DisplaySettings &);
const DisplaySettings &displaySettings() const;
signals:
void displaySettingsChanged(const TextEditor::DisplaySettings &);
......@@ -77,6 +76,8 @@ signals:
private:
void settingsFromUI(DisplaySettings &displaySettings) const;
void settingsToUI();
void setDisplaySettings(const DisplaySettings &);
struct DisplaySettingsPagePrivate;
DisplaySettingsPagePrivate *m_d;
};
......
......@@ -190,39 +190,39 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor)
void TextEditorSettings::fontZoomRequested(int zoom)
{
FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings());
FontSettings &fs = const_cast<FontSettings&>(fontSettings());
fs.setFontZoom(qMax(10, fs.fontZoom() + zoom));
m_fontSettingsPage->saveSettings();
}
void TextEditorSettings::zoomResetRequested()
{
FontSettings &fs = const_cast<FontSettings&>(m_fontSettingsPage->fontSettings());
FontSettings &fs = const_cast<FontSettings&>(fontSettings());
fs.setFontZoom(100);
m_fontSettingsPage->saveSettings();
}
FontSettings TextEditorSettings::fontSettings() const
const FontSettings &TextEditorSettings::fontSettings() const
{
return m_fontSettingsPage->fontSettings();
}
TabSettings TextEditorSettings::tabSettings() const
const TabSettings &TextEditorSettings::tabSettings() const
{
return m_behaviorSettingsPage->tabSettings();
}
StorageSettings TextEditorSettings::storageSettings() const
const StorageSettings &TextEditorSettings::storageSettings() const
{
return m_behaviorSettingsPage->storageSettings();
}
BehaviorSettings TextEditorSettings::behaviorSettings() const
const BehaviorSettings &TextEditorSettings::behaviorSettings() const
{
return m_behaviorSettingsPage->behaviorSettings();
}
DisplaySettings TextEditorSettings::displaySettings() const
const DisplaySettings &TextEditorSettings::displaySettings() const
{
return m_displaySettingsPage->displaySettings();
}
......@@ -63,11 +63,11 @@ public:
void initializeEditor(BaseTextEditor *editor);
FontSettings fontSettings() const;
TabSettings tabSettings() const;
StorageSettings storageSettings() const;
BehaviorSettings behaviorSettings() const;
DisplaySettings displaySettings() const;
const FontSettings &fontSettings() const;
const TabSettings &tabSettings() const;
const StorageSettings &storageSettings() const;
const BehaviorSettings &behaviorSettings() const;
const DisplaySettings &displaySettings() const;
signals:
void fontSettingsChanged(const TextEditor::FontSettings &);
......
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