Pimcommon

configurepluginswidget.cpp
1/*
2 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "configurepluginswidget.h"
8using namespace Qt::Literals::StringLiterals;
9
10#include "configurepluginslistwidget.h"
11
12#include <KConfigGroup>
13#include <KLocalizedString>
14#include <KMessageWidget>
15#include <KSharedConfig>
16
17#include <QSplitter>
18#include <QTextEdit>
19#include <QVBoxLayout>
20
21using namespace PimCommon;
22
23ConfigurePluginsWidget::ConfigurePluginsWidget(QWidget *parent)
24 : QWidget(parent)
25{
26 initLayout();
27}
28
29ConfigurePluginsWidget::ConfigurePluginsWidget(ConfigurePluginsListWidget *configurePluginListWidget, QWidget *parent)
30 : QWidget(parent)
31{
32 initLayout(configurePluginListWidget);
33}
34
35ConfigurePluginsWidget::~ConfigurePluginsWidget()
36{
37 writeConfig();
38}
39
40void ConfigurePluginsWidget::initLayout(ConfigurePluginsListWidget *configurePluginListWidget)
41{
42 auto layout = new QVBoxLayout(this);
44
45 mMessageWidget = new KMessageWidget(i18n("Restart is necessary for applying the changes."), this);
46 mMessageWidget->setObjectName("mMessageWidget"_L1);
47 mMessageWidget->setCloseButtonVisible(false);
48 mMessageWidget->setVisible(false);
49 mMessageWidget->setPosition(KMessageWidget::Header);
50 layout->addWidget(mMessageWidget);
51
52 mSplitter = new QSplitter(this);
53 mSplitter->setObjectName("splitter"_L1);
54 mSplitter->setChildrenCollapsible(false);
55 layout->addWidget(mSplitter);
56
57 if (!configurePluginListWidget) {
58 mConfigureListWidget = new ConfigurePluginsListWidget(this);
59 } else {
60 mConfigureListWidget = configurePluginListWidget;
61 }
62 mConfigureListWidget->setObjectName("configureListWidget"_L1);
63 mSplitter->addWidget(mConfigureListWidget);
64
65 mDescription = new QTextEdit(this);
66 mDescription->setObjectName("description"_L1);
67 mDescription->setReadOnly(true);
68
69 mSplitter->addWidget(mDescription);
70
71 connect(mConfigureListWidget, &ConfigurePluginsListWidget::descriptionChanged, mDescription, &QTextEdit::setText);
72 connect(mConfigureListWidget, &ConfigurePluginsListWidget::changed, this, &ConfigurePluginsWidget::slotConfigChanged);
73
74 initialize();
75 readConfig();
76}
77
78void ConfigurePluginsWidget::slotConfigChanged()
79{
80 mMessageWidget->animatedShow();
81 Q_EMIT changed();
82}
83
84void ConfigurePluginsWidget::save()
85{
86 mConfigureListWidget->save();
87}
88
89void ConfigurePluginsWidget::defaults()
90{
91 mConfigureListWidget->defaults();
92}
93
94void ConfigurePluginsWidget::doLoadFromGlobalSettings()
95{
96 mConfigureListWidget->doLoadFromGlobalSettings();
97}
98
99void ConfigurePluginsWidget::doResetToDefaultsOther()
100{
101 mConfigureListWidget->doResetToDefaultsOther();
102}
103
104void ConfigurePluginsWidget::readConfig()
105{
106 KConfigGroup group(KSharedConfig::openStateConfig(), QStringLiteral("ConfigurePluginsWidget"));
107 const QList<int> size = {400, 100};
108 mSplitter->setSizes(group.readEntry("splitter", size));
109}
110
111void ConfigurePluginsWidget::writeConfig()
112{
113 KConfigGroup group(KSharedConfig::openStateConfig(), QStringLiteral("ConfigurePluginsWidget"));
114 group.writeEntry("splitter", mSplitter->sizes());
115}
116
117void ConfigurePluginsWidget::initialize()
118{
119 mConfigureListWidget->initialize();
120}
121
122#include "moc_configurepluginswidget.cpp"
void setCloseButtonVisible(bool visible)
void animatedShow()
void setPosition(Position position)
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
The ConfigurePluginsListWidget class.
QString i18n(const char *text, const TYPE &arg...)
folderdialogacltab.h
void addWidget(QWidget *w)
void setContentsMargins(const QMargins &margins)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setObjectName(QAnyStringView name)
void addWidget(QWidget *widget)
void setChildrenCollapsible(bool)
void setSizes(const QList< int > &list)
QList< int > sizes() const const
void setReadOnly(bool ro)
void setText(const QString &text)
QLayout * layout() const const
virtual void setVisible(bool visible)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.