Commit f472cb70 authored by Laurent Montel's avatar Laurent Montel 😁

Add scrollarea

parent 9d815c2f
......@@ -19,16 +19,30 @@
#include "grammalecteconfigdialogtest.h"
#include "grammalecteconfigdialog.h"
#include <QDialogButtonBox>
#include <QStandardPaths>
#include <QTest>
#include <QVBoxLayout>
#include <grammalecteconfigwidget.h>
QTEST_MAIN(GrammalecteConfigDialogTest)
GrammalecteConfigDialogTest::GrammalecteConfigDialogTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
void GrammalecteConfigDialogTest::shouldHaveDefaultValue()
{
GrammalecteConfigDialog w;
QVERIFY(!w.windowTitle().isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
GrammalecteConfigWidget *mConfigWidget = w.findChild<GrammalecteConfigWidget *>(QStringLiteral("configwidget"));
QVERIFY(mConfigWidget);
QDialogButtonBox *box = w.findChild<QDialogButtonBox *>(QStringLiteral("box"));
QVERIFY(box);
}
......@@ -22,6 +22,8 @@
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <KConfigGroup>
#include <KSharedConfig>
GrammalecteConfigDialog::GrammalecteConfigDialog(QWidget *parent)
: QDialog(parent)
......@@ -39,20 +41,25 @@ GrammalecteConfigDialog::GrammalecteConfigDialog(QWidget *parent)
mainLayout->addWidget(box);
connect(box, &QDialogButtonBox::accepted, this, &GrammalecteConfigDialog::accept);
connect(box, &QDialogButtonBox::rejected, this, &GrammalecteConfigDialog::reject);
readConfig();
}
GrammalecteConfigDialog::~GrammalecteConfigDialog()
{
writeConfig();
}
void GrammalecteConfigDialog::loadSettings()
void GrammalecteConfigDialog::writeConfig()
{
//TODO
KConfigGroup group(KSharedConfig::openConfig(), "GrammalecteConfigDialog");
group.writeEntry("Size", size());
}
void GrammalecteConfigDialog::saveSettings()
void GrammalecteConfigDialog::readConfig()
{
//TODO
KConfigGroup group(KSharedConfig::openConfig(), "GrammalecteConfigDialog");
const QSize sizeDialog = group.readEntry("Size", QSize(500, 300));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
......@@ -29,8 +29,8 @@ public:
explicit GrammalecteConfigDialog(QWidget *parent = nullptr);
~GrammalecteConfigDialog();
private:
void loadSettings();
void saveSettings();
void writeConfig();
void readConfig();
GrammalecteConfigWidget *mConfigWidget = nullptr;
};
......
......@@ -26,6 +26,7 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include <QCheckBox>
#include <QScrollArea>
GrammalecteConfigWidget::GrammalecteConfigWidget(QWidget *parent)
: QWidget(parent)
......@@ -38,8 +39,7 @@ GrammalecteConfigWidget::GrammalecteConfigWidget(QWidget *parent)
mTab->setObjectName(QStringLiteral("mTab"));
mainLayout->addWidget(mTab);
mTab->addTab(addGeneralTab(), i18n("General"));
mGrammarTabWidget = addGrammarTab();
mTab->addTab(mGrammarTabWidget, i18n("Grammar Settings"));
mTab->addTab(addGrammarTab(), i18n("Grammar Settings"));
loadSettings(); //First
loadGrammarSettings();
}
......@@ -73,12 +73,14 @@ void GrammalecteConfigWidget::slotGetSettingsFinished(const QVector<GrammalecteG
QWidget *GrammalecteConfigWidget::addGrammarTab()
{
QWidget *grammarTabWidget = new QWidget(this);
grammarTabWidget->setObjectName(QStringLiteral("grammar"));
QVBoxLayout *layout = new QVBoxLayout(grammarTabWidget);
QScrollArea *area = new QScrollArea(this);
area->setWidgetResizable(true);
mGrammarTabWidget = new QWidget;
mGrammarTabWidget->setObjectName(QStringLiteral("grammar"));
QVBoxLayout *layout = new QVBoxLayout(mGrammarTabWidget);
layout->setObjectName(QStringLiteral("grammartablayout"));
layout->setMargin(0);
return grammarTabWidget;
area->setWidget(mGrammarTabWidget);
return area;
}
QWidget *GrammalecteConfigWidget::addGeneralTab()
......
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