Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qtextpad and re-add code folding support. #53

Merged
merged 2 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ endif()
find_package(HSPlasma REQUIRED)
find_package(string_theory 2.0 REQUIRED)
find_package(Qt5 5.8 REQUIRED COMPONENTS Core Gui Widgets)
find_package(KF5SyntaxHighlighting REQUIRED)
find_package(PythonInterp REQUIRED)

if(KF5SyntaxHighlighting_VERSION VERSION_LESS "5.39.0")
Expand Down
12 changes: 8 additions & 4 deletions src/PlasmaShop/OptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ OptionsDialog::OptionsDialog(QWidget* parent)
// Editor tab
QWidget* tabEditor = new QWidget(tabs);
fSciLineNumbers = new QCheckBox(tr("&Line numbers"), tabEditor);
fSciFolding = new QCheckBox(tr("Code f&olding"), tabEditor);
fSciUseSpaces = new QCheckBox(tr("Use &spaces instead of tabs"), tabEditor);
fSciAutoIndent = new QCheckBox(tr("&Auto-indent"), tabEditor);
fSciIndentGuides = new QCheckBox(tr("Show in&dentation guides"), tabEditor);
Expand All @@ -110,10 +111,11 @@ OptionsDialog::OptionsDialog(QWidget* parent)
layEditor->setContentsMargins(8, 8, 8, 8);
layEditor->setVerticalSpacing(4);
layEditor->addWidget(fSciLineNumbers, 0, 0);
layEditor->addWidget(fSciUseSpaces, 1, 0);
layEditor->addWidget(fSciAutoIndent, 2, 0);
layEditor->addWidget(fSciIndentGuides, 3, 0);
layEditor->addWidget(fSciShowWhitespace, 4, 0);
layEditor->addWidget(fSciFolding, 1, 0);
layEditor->addWidget(fSciUseSpaces, 2, 0);
layEditor->addWidget(fSciAutoIndent, 3, 0);
layEditor->addWidget(fSciIndentGuides, 4, 0);
layEditor->addWidget(fSciShowWhitespace, 5, 0);
layEditor->addItem(new QSpacerItem(32, 0, QSizePolicy::Minimum, QSizePolicy::Minimum), 0, 1);
layEditor->addWidget(fSciFont, 0, 2, 1, 2);
layEditor->addItem(new QSpacerItem(0, 16, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 2, 1, 2);
Expand Down Expand Up @@ -143,6 +145,7 @@ OptionsDialog::OptionsDialog(QWidget* parent)
fVaultEditorPath->setText(settings.value("VaultEditorPath", DEFAULT_VAULT_EDITOR).toString());
fImageEditorPath->setText(settings.value("ImageEditorPath", "").toString());
fSciLineNumbers->setChecked(settings.value("SciLineNumberMargin", true).toBool());
fSciFolding->setChecked(settings.value("SciFoldMargin", false).toBool());
fSciUseSpaces->setChecked(settings.value("SciUseSpaces", true).toBool());
fSciAutoIndent->setChecked(settings.value("SciAutoIndent", true).toBool());
fSciIndentGuides->setChecked(settings.value("SciIndentGuides", false).toBool());
Expand Down Expand Up @@ -198,6 +201,7 @@ void OptionsDialog::onSave()
settings.setValue("VaultEditorPath", fVaultEditorPath->text());
settings.setValue("ImageEditorPath", fImageEditorPath->text());
settings.setValue("SciLineNumberMargin", fSciLineNumbers->isChecked());
settings.setValue("SciFoldMargin", fSciFolding->isChecked());
settings.setValue("SciUseSpaces", fSciUseSpaces->isChecked());
settings.setValue("SciAutoIndent", fSciAutoIndent->isChecked());
settings.setValue("SciIndentGuides", fSciIndentGuides->isChecked());
Expand Down
1 change: 1 addition & 0 deletions src/PlasmaShop/OptionsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class OptionsDialog : public QDialog
QLineEdit* fImageEditorPath;

QCheckBox* fSciLineNumbers;
QCheckBox* fSciFolding;
QCheckBox* fSciUseSpaces;
QCheckBox* fSciAutoIndent;
QCheckBox* fSciIndentGuides;
Expand Down
11 changes: 2 additions & 9 deletions src/PlasmaShop/QPlasmaTextDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,8 @@ void QPlasmaTextDoc::updateSettings()
? SyntaxTextEdit::IndentSpaces : SyntaxTextEdit::IndentTabs);
fEditor->setAutoIndent(settings.value("SciAutoIndent", true).toBool());

if (settings.value("SciMargin", true).toBool())
fEditor->setShowLineNumbers(settings.value("SciLineNumberMargin", true).toBool());
else
fEditor->setShowLineNumbers(false);
fEditor->setShowLineNumbers(settings.value("SciLineNumberMargin", true).toBool());
fEditor->setShowFolding(settings.value("SciFoldMargin", false).toBool());

QTextOption opt = fEditor->document()->defaultTextOption();
if (settings.value("SciShowWhitespace", false).toBool())
Expand All @@ -362,11 +360,6 @@ void QPlasmaTextDoc::updateSettings()
fEditor->setShowLongLineEdge(settings.value("SciLongLineMark", false).toBool());
fEditor->setLongLineWidth(settings.value("SciLongLineSize", 80).toInt());
fEditor->setShowIndentGuides(settings.value("SciIndentGuides", false).toBool());

/* TODO if necessary:
if (settings.value("SciMargin", true).toBool())
fEditor->setFoldingEnabled(settings.value("SciFoldMargin", true).toBool());
*/
}

void QPlasmaTextDoc::textFind()
Expand Down
12 changes: 2 additions & 10 deletions src/PrpShop/QPrcEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,8 @@ void QPrcEditor::updateSettings()
fEditor->setTabWidth(settings.value("SciTabWidth", 4).toInt());
fEditor->setAutoIndent(settings.value("SciAutoIndent", true).toBool());

if (settings.value("SciMargin", true).toBool())
fEditor->setShowLineNumbers(settings.value("SciLineNumberMargin", true).toBool());
else
fEditor->setShowLineNumbers(false);

/* TODO if necessary:
fEditor->setIndentationGuides(settings.value("SciIndentGuides", false).toBool());
if (settings.value("SciMargin", true).toBool())
fEditor->setFoldingEnabled(settings.value("SciFoldMargin", true).toBool());
*/
fEditor->setShowLineNumbers(settings.value("SciLineNumberMargin", true).toBool());
fEditor->setShowFolding(settings.value("SciFoldMargin", false).toBool());
}

void QPrcEditor::showCursorPosition()
Expand Down
4 changes: 0 additions & 4 deletions src/QPlasmaTextEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ QPlasmaTextEdit::QPlasmaTextEdit(QWidget* parent)
{
setTabWidth(8);
setHighlightCurrentLine(true);

setTheme((palette().color(QPalette::Base).lightness() < 128)
? SyntaxRepo()->defaultTheme(KSyntaxHighlighting::Repository::DarkTheme)
: SyntaxRepo()->defaultTheme(KSyntaxHighlighting::Repository::LightTheme));
}

void QPlasmaTextEdit::setSyntax(const QString& name)
Expand Down