Commit 7e13468a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to save/load dialog size

parent ab8be3fe
Pipeline #92213 passed with stage
in 51 minutes and 11 seconds
......@@ -6,15 +6,24 @@
#include "scamconfiguresettingsdialogtest.h"
#include "../scamconfiguresettingsdialog.h"
#include "../scamconfiguresettingswidget.h"
#include <QStandardPaths>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(ScamConfigureSettingsDialogTest)
ScamConfigureSettingsDialogTest::ScamConfigureSettingsDialogTest(QObject *parent)
: QObject{parent}
{
QStandardPaths::setTestModeEnabled(true);
}
void ScamConfigureSettingsDialogTest::shouldHaveDefaultValues()
{
ScamConfigureSettingsDialog d;
// TODO
auto mScamConfigureSettingsWidget = d.findChild<ScamConfigureSettingsWidget *>(QStringLiteral("mScamConfigureSettingsWidget"));
QVERIFY(mScamConfigureSettingsWidget);
auto mainLayout = d.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QVERIFY(!d.windowTitle().isEmpty());
}
......@@ -6,10 +6,16 @@
#include "scamconfiguresettingsdialog.h"
#include "scamconfiguresettingswidget.h"
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QVBoxLayout>
namespace
{
static const char myScamConfigureSettingsDialogConfigGroupName[] = "ScamConfigureSettingsDialog";
}
ScamConfigureSettingsDialog::ScamConfigureSettingsDialog(QWidget *parent)
: QDialog(parent)
, mScamConfigureSettingsWidget(new ScamConfigureSettingsWidget(this))
......@@ -20,8 +26,26 @@ ScamConfigureSettingsDialog::ScamConfigureSettingsDialog(QWidget *parent)
mScamConfigureSettingsWidget->setObjectName(QStringLiteral("mScamConfigureSettingsWidget"));
mainLayout->addWidget(mScamConfigureSettingsWidget);
readConfig();
}
ScamConfigureSettingsDialog::~ScamConfigureSettingsDialog()
{
writeConfig();
}
void ScamConfigureSettingsDialog::readConfig()
{
KConfigGroup grp(KSharedConfig::openStateConfig(), myScamConfigureSettingsDialogConfigGroupName);
const QSize size = grp.readEntry("Size", QSize(300, 200));
if (size.isValid()) {
resize(size);
}
}
void ScamConfigureSettingsDialog::writeConfig()
{
KConfigGroup grp(KSharedConfig::openStateConfig(), myScamConfigureSettingsDialogConfigGroupName);
grp.writeEntry("Size", size());
grp.sync();
}
......@@ -17,5 +17,7 @@ public:
~ScamConfigureSettingsDialog() override;
private:
void readConfig();
void writeConfig();
ScamConfigureSettingsWidget *const mScamConfigureSettingsWidget;
};
......@@ -11,6 +11,9 @@
ScamConfigureSettingsWidget::ScamConfigureSettingsWidget(QWidget *parent)
: QWidget{parent}
{
auto mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setContentsMargins({});
}
ScamConfigureSettingsWidget::~ScamConfigureSettingsWidget()
......
Supports Markdown
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