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);
|
setCodeStyleSettings(m_preferences->currentCodeStyleSettings(), false);
|
||||||
slotCurrentPreferencesChanged(m_preferences->currentPreferences(), false);
|
slotCurrentPreferencesChanged(m_preferences->currentPreferences(), false);
|
||||||
|
|
||||||
|
m_originalCppCodeStyleSettings = cppCodeStyleSettings();
|
||||||
|
m_originalTabSettings = tabSettings();
|
||||||
|
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,6 +256,12 @@ void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
|
|||||||
if (m_blockUpdates)
|
if (m_blockUpdates)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_preferences) {
|
||||||
|
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||||
|
if (current)
|
||||||
|
current->setCodeStyleSettings(cppCodeStyleSettings());
|
||||||
|
}
|
||||||
|
|
||||||
emit codeStyleSettingsChanged(cppCodeStyleSettings());
|
emit codeStyleSettingsChanged(cppCodeStyleSettings());
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
@@ -262,6 +271,12 @@ void CppCodeStylePreferencesWidget::slotTabSettingsChanged(const TabSettings &se
|
|||||||
if (m_blockUpdates)
|
if (m_blockUpdates)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_preferences) {
|
||||||
|
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||||
|
if (current)
|
||||||
|
current->setTabSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
emit tabSettingsChanged(settings);
|
emit tabSettingsChanged(settings);
|
||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
@@ -344,19 +359,21 @@ void CppCodeStylePreferencesWidget::addTab(CppCodeStyleWidget *page, QString tab
|
|||||||
|
|
||||||
void CppCodeStylePreferencesWidget::apply()
|
void CppCodeStylePreferencesWidget::apply()
|
||||||
{
|
{
|
||||||
if (m_preferences) {
|
m_originalTabSettings = tabSettings();
|
||||||
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
m_originalCppCodeStyleSettings = cppCodeStyleSettings();
|
||||||
if (current) {
|
|
||||||
current->setTabSettings(tabSettings());
|
|
||||||
current->setCodeStyleSettings(cppCodeStyleSettings());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit applyEmitted();
|
emit applyEmitted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeStylePreferencesWidget::finish()
|
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();
|
emit finishEmitted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <texteditor/icodestylepreferencesfactory.h>
|
#include <texteditor/icodestylepreferencesfactory.h>
|
||||||
|
#include <texteditor/tabsettings.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class FontSettings;
|
class FontSettings;
|
||||||
class TabSettings;
|
|
||||||
class SnippetEditorWidget;
|
class SnippetEditorWidget;
|
||||||
class CodeStyleEditor;
|
class CodeStyleEditor;
|
||||||
class CodeStyleEditorWidget;
|
class CodeStyleEditorWidget;
|
||||||
@@ -72,6 +72,8 @@ private:
|
|||||||
CppCodeStylePreferences *m_preferences = nullptr;
|
CppCodeStylePreferences *m_preferences = nullptr;
|
||||||
Ui::CppCodeStyleSettingsPage *m_ui;
|
Ui::CppCodeStyleSettingsPage *m_ui;
|
||||||
QList<TextEditor::SnippetEditorWidget *> m_previews;
|
QList<TextEditor::SnippetEditorWidget *> m_previews;
|
||||||
|
CppCodeStyleSettings m_originalCppCodeStyleSettings;
|
||||||
|
TextEditor::TabSettings m_originalTabSettings;
|
||||||
bool m_blockUpdates = false;
|
bool m_blockUpdates = false;
|
||||||
signals:
|
signals:
|
||||||
void codeStyleSettingsChanged(const CppEditor::CppCodeStyleSettings &);
|
void codeStyleSettingsChanged(const CppEditor::CppCodeStyleSettings &);
|
||||||
|
Reference in New Issue
Block a user