forked from qt-creator/qt-creator
CodeStyle: Fix preview update
Fixes: QTCREATORBUG-28621 Change-Id: I66a66d9c16933ebd8197f9e286e72dce7a621933 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -165,6 +165,9 @@ void CppCodeStylePreferencesWidget::setCodeStyle(CppCodeStylePreferences *codeSt
|
||||
setCodeStyleSettings(m_preferences->currentCodeStyleSettings(), false);
|
||||
slotCurrentPreferencesChanged(m_preferences->currentPreferences(), false);
|
||||
|
||||
m_originalCppCodeStyleSettings = cppCodeStyleSettings();
|
||||
m_originalTabSettings = tabSettings();
|
||||
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
@@ -253,6 +256,12 @@ void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
|
||||
if (m_blockUpdates)
|
||||
return;
|
||||
|
||||
if (m_preferences) {
|
||||
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||
if (current)
|
||||
current->setCodeStyleSettings(cppCodeStyleSettings());
|
||||
}
|
||||
|
||||
emit codeStyleSettingsChanged(cppCodeStyleSettings());
|
||||
updatePreview();
|
||||
}
|
||||
@@ -262,6 +271,12 @@ void CppCodeStylePreferencesWidget::slotTabSettingsChanged(const TabSettings &se
|
||||
if (m_blockUpdates)
|
||||
return;
|
||||
|
||||
if (m_preferences) {
|
||||
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||
if (current)
|
||||
current->setTabSettings(settings);
|
||||
}
|
||||
|
||||
emit tabSettingsChanged(settings);
|
||||
updatePreview();
|
||||
}
|
||||
@@ -344,19 +359,21 @@ void CppCodeStylePreferencesWidget::addTab(CppCodeStyleWidget *page, QString tab
|
||||
|
||||
void CppCodeStylePreferencesWidget::apply()
|
||||
{
|
||||
if (m_preferences) {
|
||||
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||
if (current) {
|
||||
current->setTabSettings(tabSettings());
|
||||
current->setCodeStyleSettings(cppCodeStyleSettings());
|
||||
}
|
||||
}
|
||||
m_originalTabSettings = tabSettings();
|
||||
m_originalCppCodeStyleSettings = cppCodeStyleSettings();
|
||||
|
||||
emit applyEmitted();
|
||||
}
|
||||
|
||||
void CppCodeStylePreferencesWidget::finish()
|
||||
{
|
||||
if (m_preferences) {
|
||||
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentDelegate());
|
||||
if (current) {
|
||||
current->setCodeStyleSettings(m_originalCppCodeStyleSettings);
|
||||
current->setTabSettings(m_originalTabSettings);
|
||||
}
|
||||
}
|
||||
emit finishEmitted();
|
||||
}
|
||||
|
||||
|
@@ -8,13 +8,13 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <texteditor/icodestylepreferencesfactory.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
|
||||
namespace TextEditor {
|
||||
class FontSettings;
|
||||
class TabSettings;
|
||||
class SnippetEditorWidget;
|
||||
class CodeStyleEditor;
|
||||
class CodeStyleEditorWidget;
|
||||
@@ -72,6 +72,8 @@ private:
|
||||
CppCodeStylePreferences *m_preferences = nullptr;
|
||||
Ui::CppCodeStyleSettingsPage *m_ui;
|
||||
QList<TextEditor::SnippetEditorWidget *> m_previews;
|
||||
CppCodeStyleSettings m_originalCppCodeStyleSettings;
|
||||
TextEditor::TabSettings m_originalTabSettings;
|
||||
bool m_blockUpdates = false;
|
||||
signals:
|
||||
void codeStyleSettingsChanged(const CppEditor::CppCodeStyleSettings &);
|
||||
|
Reference in New Issue
Block a user