File indexing completed on 2024-04-21 05:49:00
0001 /* 0002 SPDX-FileCopyrightText: 2010 Marco Mentasti <marcomentasti@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "katesqlconfigpage.h" 0008 #include "outputstylewidget.h" 0009 0010 #include <KConfigGroup> 0011 #include <KLocalizedString> 0012 #include <KSharedConfig> 0013 0014 #include <QCheckBox> 0015 #include <QGroupBox> 0016 #include <QVBoxLayout> 0017 0018 KateSQLConfigPage::KateSQLConfigPage(QWidget *parent) 0019 : KTextEditor::ConfigPage(parent) 0020 { 0021 QVBoxLayout *layout = new QVBoxLayout(this); 0022 0023 m_box = new QCheckBox(i18nc("@option:check", "Save and restore connections in Kate session"), this); 0024 0025 QGroupBox *stylesGroupBox = new QGroupBox(i18nc("@title:group", "Output Customization"), this); 0026 QVBoxLayout *stylesLayout = new QVBoxLayout(stylesGroupBox); 0027 0028 m_outputStyleWidget = new OutputStyleWidget(this); 0029 0030 stylesLayout->addWidget(m_outputStyleWidget); 0031 0032 layout->addWidget(m_box); 0033 layout->addWidget(stylesGroupBox, 1); 0034 0035 setLayout(layout); 0036 0037 reset(); 0038 0039 connect(m_box, &QCheckBox::stateChanged, this, &KateSQLConfigPage::changed); 0040 connect(m_outputStyleWidget, &OutputStyleWidget::changed, this, &KateSQLConfigPage::changed); 0041 } 0042 0043 KateSQLConfigPage::~KateSQLConfigPage() 0044 { 0045 } 0046 0047 QString KateSQLConfigPage::name() const 0048 { 0049 return i18nc("@title", "SQL"); 0050 } 0051 0052 QString KateSQLConfigPage::fullName() const 0053 { 0054 return i18nc("@title:window", "SQL ConfigPage Settings"); 0055 } 0056 0057 QIcon KateSQLConfigPage::icon() const 0058 { 0059 return QIcon::fromTheme(QLatin1String("server-database")); 0060 } 0061 0062 void KateSQLConfigPage::apply() 0063 { 0064 KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("KateSQLPlugin")); 0065 0066 config.writeEntry("SaveConnections", m_box->isChecked()); 0067 0068 m_outputStyleWidget->writeConfig(); 0069 0070 config.sync(); 0071 0072 Q_EMIT settingsChanged(); 0073 } 0074 0075 void KateSQLConfigPage::reset() 0076 { 0077 KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("KateSQLPlugin")); 0078 0079 m_box->setChecked(config.readEntry("SaveConnections", true)); 0080 0081 m_outputStyleWidget->readConfig(); 0082 } 0083 0084 void KateSQLConfigPage::defaults() 0085 { 0086 KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("KateSQLPlugin")); 0087 0088 config.revertToDefault("SaveConnections"); 0089 config.revertToDefault("OutputCustomization"); 0090 } 0091 0092 #include "moc_katesqlconfigpage.cpp"