forked from qt-creator/qt-creator
Nim: Inline nimcodestylepreferenceswidget.ui
Change-Id: I4590e6666bd37b428c443ef78731202100040a58 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -25,7 +25,7 @@ add_qtc_plugin(Nim
|
||||
project/nimtoolchain.cpp project/nimtoolchain.h
|
||||
project/nimtoolchainfactory.cpp project/nimtoolchainfactory.h
|
||||
settings/nimcodestylepreferencesfactory.cpp settings/nimcodestylepreferencesfactory.h
|
||||
settings/nimcodestylepreferenceswidget.cpp settings/nimcodestylepreferenceswidget.h settings/nimcodestylepreferenceswidget.ui
|
||||
settings/nimcodestylepreferenceswidget.cpp settings/nimcodestylepreferenceswidget.h
|
||||
settings/nimcodestylesettingspage.cpp settings/nimcodestylesettingspage.h
|
||||
settings/nimsettings.cpp settings/nimsettings.h
|
||||
suggest/client.cpp suggest/client.h
|
||||
|
@@ -60,7 +60,7 @@ QtcPlugin {
|
||||
prefix: "settings/"
|
||||
files: [
|
||||
"nimcodestylepreferencesfactory.h", "nimcodestylepreferencesfactory.cpp",
|
||||
"nimcodestylepreferenceswidget.h", "nimcodestylepreferenceswidget.cpp", "nimcodestylepreferenceswidget.ui",
|
||||
"nimcodestylepreferenceswidget.h", "nimcodestylepreferenceswidget.cpp",
|
||||
"nimcodestylesettingspage.h", "nimcodestylesettingspage.cpp",
|
||||
"nimsettings.h", "nimsettings.cpp",
|
||||
]
|
||||
|
@@ -11,9 +11,6 @@
|
||||
|
||||
#include <texteditor/simplecodestylepreferences.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace Nim {
|
||||
@@ -44,7 +41,6 @@ TextEditor::CodeStyleEditorWidget *NimCodeStylePreferencesFactory::createEditor(
|
||||
{
|
||||
Q_UNUSED(project)
|
||||
auto result = new NimCodeStylePreferencesWidget(preferences, parent);
|
||||
result->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -2,20 +2,25 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "nimcodestylepreferenceswidget.h"
|
||||
#include "ui_nimcodestylepreferenceswidget.h"
|
||||
|
||||
#include "../nimconstants.h"
|
||||
#include "../editor/nimeditorfactory.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <texteditor/displaysettings.h>
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/icodestylepreferencesfactory.h>
|
||||
#include <texteditor/indenter.h>
|
||||
#include <texteditor/snippets/snippeteditor.h>
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
#include <texteditor/simplecodestylepreferenceswidget.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
@@ -24,11 +29,22 @@ namespace Nim {
|
||||
NimCodeStylePreferencesWidget::NimCodeStylePreferencesWidget(ICodeStylePreferences *preferences, QWidget *parent)
|
||||
: TextEditor::CodeStyleEditorWidget(parent)
|
||||
, m_preferences(preferences)
|
||||
, m_ui(new Ui::NimCodeStylePreferencesWidget())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->tabPreferencesWidget->setPreferences(preferences);
|
||||
m_ui->previewTextEdit->setPlainText(Nim::Constants::C_NIMCODESTYLEPREVIEWSNIPPET);
|
||||
auto tabPreferencesWidget = new SimpleCodeStylePreferencesWidget;
|
||||
tabPreferencesWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
tabPreferencesWidget->setPreferences(preferences);
|
||||
|
||||
m_previewTextEdit = new SnippetEditorWidget;
|
||||
m_previewTextEdit->setPlainText(Nim::Constants::C_NIMCODESTYLEPREVIEWSNIPPET);
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
Row {
|
||||
Column {
|
||||
tabPreferencesWidget,
|
||||
st,
|
||||
},
|
||||
m_previewTextEdit,
|
||||
}.attachTo(this, WithoutMargins);
|
||||
|
||||
decorateEditor(TextEditorSettings::fontSettings());
|
||||
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
|
||||
@@ -42,43 +58,38 @@ NimCodeStylePreferencesWidget::NimCodeStylePreferencesWidget(ICodeStylePreferenc
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
NimCodeStylePreferencesWidget::~NimCodeStylePreferencesWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
m_ui = nullptr;
|
||||
}
|
||||
NimCodeStylePreferencesWidget::~NimCodeStylePreferencesWidget() = default;
|
||||
|
||||
void NimCodeStylePreferencesWidget::decorateEditor(const FontSettings &fontSettings)
|
||||
{
|
||||
m_ui->previewTextEdit->textDocument()->setFontSettings(fontSettings);
|
||||
NimEditorFactory::decorateEditor(m_ui->previewTextEdit);
|
||||
m_previewTextEdit->textDocument()->setFontSettings(fontSettings);
|
||||
NimEditorFactory::decorateEditor(m_previewTextEdit);
|
||||
}
|
||||
|
||||
void NimCodeStylePreferencesWidget::setVisualizeWhitespace(bool on)
|
||||
{
|
||||
DisplaySettings displaySettings = m_ui->previewTextEdit->displaySettings();
|
||||
DisplaySettings displaySettings = m_previewTextEdit->displaySettings();
|
||||
displaySettings.m_visualizeWhitespace = on;
|
||||
m_ui->previewTextEdit->setDisplaySettings(displaySettings);
|
||||
m_previewTextEdit->setDisplaySettings(displaySettings);
|
||||
}
|
||||
|
||||
void NimCodeStylePreferencesWidget::updatePreview()
|
||||
{
|
||||
QTextDocument *doc = m_ui->previewTextEdit->document();
|
||||
QTextDocument *doc = m_previewTextEdit->document();
|
||||
|
||||
const TabSettings &ts = m_preferences
|
||||
? m_preferences->currentTabSettings()
|
||||
: TextEditorSettings::codeStyle()->tabSettings();
|
||||
m_ui->previewTextEdit->textDocument()->setTabSettings(ts);
|
||||
m_previewTextEdit->textDocument()->setTabSettings(ts);
|
||||
|
||||
QTextBlock block = doc->firstBlock();
|
||||
QTextCursor tc = m_ui->previewTextEdit->textCursor();
|
||||
QTextCursor tc = m_previewTextEdit->textCursor();
|
||||
tc.beginEditBlock();
|
||||
while (block.isValid()) {
|
||||
m_ui->previewTextEdit->textDocument()->indenter()->indentBlock(block, QChar::Null, ts);
|
||||
m_previewTextEdit->textDocument()->indenter()->indentBlock(block, QChar::Null, ts);
|
||||
block = block.next();
|
||||
}
|
||||
tc.endEditBlock();
|
||||
}
|
||||
|
||||
} // namespace Nim
|
||||
|
||||
} // Nim
|
||||
|
@@ -3,18 +3,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <texteditor/icodestylepreferencesfactory.h>
|
||||
|
||||
namespace TextEditor {
|
||||
class ICodeStylePreferences;
|
||||
class FontSettings;
|
||||
}
|
||||
class SnippetEditorWidget;
|
||||
} // TextEditor
|
||||
|
||||
namespace Nim {
|
||||
|
||||
namespace Ui { class NimCodeStylePreferencesWidget; }
|
||||
|
||||
class NimCodeStylePreferencesWidget : public TextEditor::CodeStyleEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -29,7 +26,7 @@ private:
|
||||
void updatePreview();
|
||||
|
||||
TextEditor::ICodeStylePreferences *m_preferences;
|
||||
Ui::NimCodeStylePreferencesWidget *m_ui;
|
||||
TextEditor::SnippetEditorWidget *m_previewTextEdit;
|
||||
};
|
||||
|
||||
} // namespace Nim
|
||||
} // Nim
|
||||
|
@@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Nim::NimCodeStylePreferencesWidget</class>
|
||||
<widget class="QWidget" name="Nim::NimCodeStylePreferencesWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>138</width>
|
||||
<height>112</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="TextEditor::SimpleCodeStylePreferencesWidget" name="tabPreferencesWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<widget class="TextEditor::SnippetEditorWidget" name="previewTextEdit">
|
||||
<property name="plainText">
|
||||
<string notr="true">import QtQuick 1.0
|
||||
|
||||
Rectangle {
|
||||
width: 360
|
||||
height: 360
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Hello World"
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
Qt.quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>267</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TextEditor::SimpleCodeStylePreferencesWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">texteditor/simplecodestylepreferenceswidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TextEditor::SnippetEditorWidget</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header location="global">texteditor/snippets/snippeteditor.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@@ -38,6 +38,7 @@ public:
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addWidget(editor);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user