diff --git a/addons/lspclient/CMakeLists.txt b/addons/lspclient/CMakeLists.txt index 8a7177d08..3eb0f279e 100644 --- a/addons/lspclient/CMakeLists.txt +++ b/addons/lspclient/CMakeLists.txt @@ -1,46 +1,49 @@ find_package(KF5ItemModels QUIET) set_package_properties(KF5ItemModels PROPERTIES PURPOSE "Required to build the lspclient addon") if(NOT KF5ItemModels_FOUND) return() endif() add_library(lspclientplugin MODULE "") target_compile_definitions(lspclientplugin PRIVATE TRANSLATION_DOMAIN="lspclient") +ki18n_wrap_ui(UI_SOURCES lspconfigwidget.ui) + target_link_libraries( lspclientplugin PRIVATE KF5::ItemModels KF5::TextEditor ) include(ECMQtDeclareLoggingCategory) ecm_qt_declare_logging_category( DEBUG_SOURCES HEADER lspclient_debug.h IDENTIFIER LSPCLIENT CATEGORY_NAME "katelspclientplugin" ) target_sources(lspclientplugin PRIVATE ${DEBUG_SOURCES}) target_sources( lspclientplugin PRIVATE lspclientcompletion.cpp lspclientconfigpage.cpp lspclienthover.cpp lspclientplugin.cpp lspclientpluginview.cpp lspclientserver.cpp lspclientservermanager.cpp lspclientsymbolview.cpp plugin.qrc + ${UI_SOURCES} ) kcoreaddons_desktop_to_json(lspclientplugin lspclientplugin.desktop) install(TARGETS lspclientplugin DESTINATION ${PLUGIN_INSTALL_DIR}/ktexteditor) if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/addons/lspclient/lspclientconfigpage.cpp b/addons/lspclient/lspclientconfigpage.cpp index 68f4213ac..a2d9b1bab 100644 --- a/addons/lspclient/lspclientconfigpage.cpp +++ b/addons/lspclient/lspclientconfigpage.cpp @@ -1,164 +1,121 @@ /* SPDX-License-Identifier: MIT Copyright (C) 2019 Mark Nauwelaerts Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "lspclientconfigpage.h" #include "lspclientplugin.h" - -#include -#include -#include -#include +#include "ui_lspconfigwidget.h" #include -#include LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugin) : KTextEditor::ConfigPage(parent) , m_plugin(plugin) { - QVBoxLayout *layout = new QVBoxLayout(this); - - QGroupBox *outlineBox = new QGroupBox(i18n("Symbol Outline Options"), this); - QVBoxLayout *top = new QVBoxLayout(outlineBox); - m_symbolDetails = new QCheckBox(i18n("Display symbol details")); - m_symbolTree = new QCheckBox(i18n("Tree mode outline")); - m_symbolExpand = new QCheckBox(i18n("Automatically expand nodes in tree mode")); - m_symbolSort = new QCheckBox(i18n("Sort symbols alphabetically")); - top->addWidget(m_symbolDetails); - top->addWidget(m_symbolTree); - top->addWidget(m_symbolExpand); - top->addWidget(m_symbolSort); - layout->addWidget(outlineBox); - - outlineBox = new QGroupBox(i18n("General Options"), this); - top = new QVBoxLayout(outlineBox); - m_complDoc = new QCheckBox(i18n("Show selected completion documentation")); - m_refDeclaration = new QCheckBox(i18n("Include declaration in references")); - m_autoHover = new QCheckBox(i18n("Show hover information")); - m_onTypeFormatting = new QCheckBox(i18n("Format on typing")); - m_incrementalSync = new QCheckBox(i18n("Incremental document synchronization")); - QHBoxLayout *diagLayout = new QHBoxLayout(); - m_diagnostics = new QCheckBox(i18n("Show diagnostics notifications")); - m_diagnosticsHighlight = new QCheckBox(i18n("Add highlights")); - m_diagnosticsMark = new QCheckBox(i18n("Add markers")); - top->addWidget(m_complDoc); - top->addWidget(m_refDeclaration); - top->addWidget(m_autoHover); - top->addWidget(m_onTypeFormatting); - top->addWidget(m_incrementalSync); - diagLayout->addWidget(m_diagnostics); - diagLayout->addStretch(1); - diagLayout->addWidget(m_diagnosticsHighlight); - diagLayout->addStretch(1); - diagLayout->addWidget(m_diagnosticsMark); - top->addLayout(diagLayout); - layout->addWidget(outlineBox); - - outlineBox = new QGroupBox(i18n("Server Configuration"), this); - top = new QVBoxLayout(outlineBox); - m_configPath = new KUrlRequester(this); - top->addWidget(m_configPath); - layout->addWidget(outlineBox); - - layout->addStretch(1); + ui = new Ui::LspConfigWidget(); + ui->setupUi(this); reset(); - for (const auto &cb : {m_symbolDetails, m_symbolExpand, m_symbolSort, m_symbolTree, m_complDoc, m_refDeclaration, m_diagnostics, m_diagnosticsMark, m_onTypeFormatting, m_incrementalSync, m_autoHover}) + for (const auto &cb : {ui->chkSymbolDetails, ui->chkSymbolExpand, ui->chkSymbolSort, ui->chkSymbolTree, ui->chkComplDoc, ui->chkRefDeclaration, ui->chkDiagnostics, ui->chkDiagnosticsMark, ui->chkOnTypeFormatting, ui->chkIncrementalSync, ui->chkAutoHover}) connect(cb, &QCheckBox::toggled, this, &LSPClientConfigPage::changed); - connect(m_configPath, &KUrlRequester::textChanged, this, &LSPClientConfigPage::changed); - connect(m_configPath, &KUrlRequester::urlSelected, this, &LSPClientConfigPage::changed); + connect(ui->edtConfigPath, &KUrlRequester::textChanged, this, &LSPClientConfigPage::changed); + connect(ui->edtConfigPath, &KUrlRequester::urlSelected, this, &LSPClientConfigPage::changed); // custom control logic auto h = [this]() { - bool enabled = m_diagnostics->isChecked(); - m_diagnosticsHighlight->setEnabled(enabled); - m_diagnosticsMark->setEnabled(enabled); + bool enabled = ui->chkDiagnostics->isChecked(); + ui->chkDiagnosticsHighlight->setEnabled(enabled); + ui->chkDiagnosticsMark->setEnabled(enabled); }; connect(this, &LSPClientConfigPage::changed, this, h); } +LSPClientConfigPage::~LSPClientConfigPage() +{ + delete ui; +} + QString LSPClientConfigPage::name() const { return QString(i18n("LSP Client")); } QString LSPClientConfigPage::fullName() const { return QString(i18n("LSP Client")); } QIcon LSPClientConfigPage::icon() const { return QIcon::fromTheme(QLatin1String("code-context")); } void LSPClientConfigPage::apply() { - m_plugin->m_symbolDetails = m_symbolDetails->isChecked(); - m_plugin->m_symbolTree = m_symbolTree->isChecked(); - m_plugin->m_symbolExpand = m_symbolExpand->isChecked(); - m_plugin->m_symbolSort = m_symbolSort->isChecked(); + m_plugin->m_symbolDetails = ui->chkSymbolDetails->isChecked(); + m_plugin->m_symbolTree = ui->chkSymbolTree->isChecked(); + m_plugin->m_symbolExpand = ui->chkSymbolExpand->isChecked(); + m_plugin->m_symbolSort = ui->chkSymbolSort->isChecked(); - m_plugin->m_complDoc = m_complDoc->isChecked(); - m_plugin->m_refDeclaration = m_refDeclaration->isChecked(); + m_plugin->m_complDoc = ui->chkComplDoc->isChecked(); + m_plugin->m_refDeclaration = ui->chkRefDeclaration->isChecked(); - m_plugin->m_diagnostics = m_diagnostics->isChecked(); - m_plugin->m_diagnosticsHighlight = m_diagnosticsHighlight->isChecked(); - m_plugin->m_diagnosticsMark = m_diagnosticsMark->isChecked(); + m_plugin->m_diagnostics = ui->chkDiagnostics->isChecked(); + m_plugin->m_diagnosticsHighlight = ui->chkDiagnosticsHighlight->isChecked(); + m_plugin->m_diagnosticsMark = ui->chkDiagnosticsMark->isChecked(); - m_plugin->m_autoHover = m_autoHover->isChecked(); - m_plugin->m_onTypeFormatting = m_onTypeFormatting->isChecked(); - m_plugin->m_incrementalSync = m_incrementalSync->isChecked(); + m_plugin->m_autoHover = ui->chkAutoHover->isChecked(); + m_plugin->m_onTypeFormatting = ui->chkOnTypeFormatting->isChecked(); + m_plugin->m_incrementalSync = ui->chkIncrementalSync->isChecked(); - m_plugin->m_configPath = m_configPath->url(); + m_plugin->m_configPath = ui->edtConfigPath->url(); m_plugin->writeConfig(); } void LSPClientConfigPage::reset() { - m_symbolDetails->setChecked(m_plugin->m_symbolDetails); - m_symbolTree->setChecked(m_plugin->m_symbolTree); - m_symbolExpand->setChecked(m_plugin->m_symbolExpand); - m_symbolSort->setChecked(m_plugin->m_symbolSort); + ui->chkSymbolDetails->setChecked(m_plugin->m_symbolDetails); + ui->chkSymbolTree->setChecked(m_plugin->m_symbolTree); + ui->chkSymbolExpand->setChecked(m_plugin->m_symbolExpand); + ui->chkSymbolSort->setChecked(m_plugin->m_symbolSort); - m_complDoc->setChecked(m_plugin->m_complDoc); - m_refDeclaration->setChecked(m_plugin->m_refDeclaration); + ui->chkComplDoc->setChecked(m_plugin->m_complDoc); + ui->chkRefDeclaration->setChecked(m_plugin->m_refDeclaration); - m_diagnostics->setChecked(m_plugin->m_diagnostics); - m_diagnosticsHighlight->setChecked(m_plugin->m_diagnosticsHighlight); - m_diagnosticsMark->setChecked(m_plugin->m_diagnosticsMark); + ui->chkDiagnostics->setChecked(m_plugin->m_diagnostics); + ui->chkDiagnosticsHighlight->setChecked(m_plugin->m_diagnosticsHighlight); + ui->chkDiagnosticsMark->setChecked(m_plugin->m_diagnosticsMark); - m_autoHover->setChecked(m_plugin->m_autoHover); - m_onTypeFormatting->setChecked(m_plugin->m_onTypeFormatting); - m_incrementalSync->setChecked(m_plugin->m_incrementalSync); + ui->chkAutoHover->setChecked(m_plugin->m_autoHover); + ui->chkOnTypeFormatting->setChecked(m_plugin->m_onTypeFormatting); + ui->chkIncrementalSync->setChecked(m_plugin->m_incrementalSync); - m_configPath->setUrl(m_plugin->m_configPath); + ui->edtConfigPath->setUrl(m_plugin->m_configPath); } void LSPClientConfigPage::defaults() { reset(); } diff --git a/addons/lspclient/lspclientconfigpage.h b/addons/lspclient/lspclientconfigpage.h index 8750d1489..330fe279e 100644 --- a/addons/lspclient/lspclientconfigpage.h +++ b/addons/lspclient/lspclientconfigpage.h @@ -1,72 +1,56 @@ /* SPDX-License-Identifier: MIT Copyright (C) 2019 Mark Nauwelaerts Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef LSPCLIENTCONFIGPAGE_H #define LSPCLIENTCONFIGPAGE_H #include class LSPClientPlugin; -class QCheckBox; -class QLineEdit; - -class KUrlRequester; +namespace Ui { class LspConfigWidget; } class LSPClientConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: explicit LSPClientConfigPage(QWidget *parent = nullptr, LSPClientPlugin *plugin = nullptr); - ~LSPClientConfigPage() override {}; + ~LSPClientConfigPage() override; QString name() const override; QString fullName() const override; QIcon icon() const override; public Q_SLOTS: void apply() override; void defaults() override; void reset() override; private: - QCheckBox *m_symbolDetails; - QCheckBox *m_symbolExpand; - QCheckBox *m_symbolTree; - QCheckBox *m_symbolSort; - QCheckBox *m_complDoc; - QCheckBox *m_refDeclaration; - QCheckBox *m_diagnostics; - QCheckBox *m_diagnosticsHighlight; - QCheckBox *m_diagnosticsMark; - QCheckBox *m_autoHover; - QCheckBox *m_onTypeFormatting; - QCheckBox *m_incrementalSync; - KUrlRequester *m_configPath; - + Ui::LspConfigWidget *ui; LSPClientPlugin *m_plugin; }; #endif diff --git a/addons/lspclient/lspconfigwidget.ui b/addons/lspclient/lspconfigwidget.ui new file mode 100644 index 000000000..41d5b49b3 --- /dev/null +++ b/addons/lspclient/lspconfigwidget.ui @@ -0,0 +1,171 @@ + + + LspConfigWidget + + + + 0 + 0 + 556 + 528 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Symbol Outline Options + + + + + + Display symbol details + + + + + + + Tree mode outline + + + + + + + Automatically expand nodes in tree mode + + + + + + + Sort symbols alphabetically + + + + + + + + + + General Options + + + + + + Show selected completion documentation + + + + + + + Include declaration in references + + + + + + + Show hover information + + + + + + + Format on typing + + + + + + + Incremental document synchronization + + + + + + + + + Show diagnostics notifications + + + + + + + Add highlights + + + + + + + Add markers + + + + + + + + + + + + Server Configuration + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KUrlRequester + QWidget +
kurlrequester.h
+
+
+ + +