Commit 0b0e8a5b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Save default splitter size

parent aab2348d
Pipeline #43217 passed with stage
in 60 minutes and 26 seconds
......@@ -7,11 +7,18 @@
#include "folderconfiguresettingspagewidget.h"
#include "folderconfiguresettingswidget.h"
#include "folderconfiguretreewidget.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <QHBoxLayout>
#include <QSplitter>
namespace {
static const char myConfigGroupName[] = "FolderConfigureSettingsWidget";
}
FolderConfigureSettingsWidget::FolderConfigureSettingsWidget(QWidget *parent)
: QWidget(parent)
, mFolderConfigureTreeWidget(new FolderConfigureTreeWidget(this))
, mFolderConfigureSettingsPageWidget(new FolderConfigureSettingsPageWidget(this))
, mSplitter(new QSplitter(this))
{
auto *mainLayout = new QHBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
......@@ -19,22 +26,21 @@ FolderConfigureSettingsWidget::FolderConfigureSettingsWidget(QWidget *parent)
//TODO add label ?
auto *splitter = new QSplitter(this);
splitter->setObjectName(QStringLiteral("splitter"));
splitter->setChildrenCollapsible(false);
mainLayout->addWidget(splitter);
mSplitter->setObjectName(QStringLiteral("splitter"));
mSplitter->setChildrenCollapsible(false);
mainLayout->addWidget(mSplitter);
mFolderConfigureTreeWidget = new FolderConfigureTreeWidget(this);
mFolderConfigureTreeWidget->setObjectName(QStringLiteral("mFolderConfigureTreeWidget"));
splitter->addWidget(mFolderConfigureTreeWidget);
mSplitter->addWidget(mFolderConfigureTreeWidget);
mFolderConfigureSettingsPageWidget = new FolderConfigureSettingsPageWidget(this);
mFolderConfigureSettingsPageWidget->setObjectName(QStringLiteral("mFolderConfigureSettingsPageWidget"));
splitter->addWidget(mFolderConfigureSettingsPageWidget);
mSplitter->addWidget(mFolderConfigureSettingsPageWidget);
readConfig();
}
FolderConfigureSettingsWidget::~FolderConfigureSettingsWidget()
{
saveConfig();
}
void FolderConfigureSettingsWidget::save()
......@@ -42,3 +48,18 @@ void FolderConfigureSettingsWidget::save()
const Akonadi::Collection::List collections = mFolderConfigureTreeWidget->listCollections();
mFolderConfigureSettingsPageWidget->save(collections);
}
void FolderConfigureSettingsWidget::readConfig()
{
KConfigGroup grp(KSharedConfig::openConfig(), myConfigGroupName);
const QList<int> defaultSizes{200, 400};
const QList<int> sizes = grp.readEntry("SplitterSize", defaultSizes);
mSplitter->setSizes(sizes);
}
void FolderConfigureSettingsWidget::saveConfig()
{
const QList<int> sizes = mSplitter->sizes();
KConfigGroup grp(KSharedConfig::openConfig(), myConfigGroupName);
grp.writeEntry("SplitterSize", sizes );
}
......@@ -11,6 +11,7 @@
#include "folderconfiguresettings_private_export.h"
class FolderConfigureTreeWidget;
class FolderConfigureSettingsPageWidget;
class QSplitter;
class LIBFOLDERCONFIGURESETTINGS_TESTS_EXPORT FolderConfigureSettingsWidget : public QWidget
{
Q_OBJECT
......@@ -19,8 +20,11 @@ public:
~FolderConfigureSettingsWidget() override;
void save();
private:
FolderConfigureTreeWidget *mFolderConfigureTreeWidget = nullptr;
FolderConfigureSettingsPageWidget *mFolderConfigureSettingsPageWidget = nullptr;
void readConfig();
void saveConfig();
FolderConfigureTreeWidget *const mFolderConfigureTreeWidget;
FolderConfigureSettingsPageWidget *const mFolderConfigureSettingsPageWidget;
QSplitter *const mSplitter;
};
#endif // FOLDERCONFIGURESETTINGSWIDGET_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment