Commit 4d568e4b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add dialog box for process output

parent b342fe58
......@@ -15,6 +15,10 @@ target_sources(akonadidatasetools PRIVATE
akonadidatabasetoolsjob.cpp
akonadidatabasetoolsutils.cpp
akonadidatabasetoolsutils.h
akonadidatabasetoolsdialog.h
akonadidatabasetoolsdialog.cpp
akonadidatabasetoolswidget.h
akonadidatabasetoolswidget.cpp
)
generate_export_header(akonadidatasetools BASE_NAME akonadidatasetools)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
......
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "akonadidatabasetoolsdialog.h"
#include "akonadidatabasetoolswidget.h"
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QVBoxLayout>
namespace
{
static const char myConfigGroupName[] = "AkonadiDatabaseToolsDialog";
}
AkonadiDatabaseToolsDialog::AkonadiDatabaseToolsDialog(QWidget *parent)
: QDialog(parent)
, mAkonadiDatabaseToolsWidget(new AkonadiDatabaseToolsWidget(this))
{
setWindowTitle(i18nc("@title:window", "Akonadi Database Tool"));
auto mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mAkonadiDatabaseToolsWidget->setObjectName(QStringLiteral("mAkonadiDatabaseToolsWidget"));
mainLayout->addWidget(mAkonadiDatabaseToolsWidget);
auto box = new QDialogButtonBox(QDialogButtonBox::Close, this);
box->setObjectName(QStringLiteral("box"));
mainLayout->addWidget(box);
connect(box, &QDialogButtonBox::accepted, this, &AkonadiDatabaseToolsDialog::accept);
connect(box, &QDialogButtonBox::rejected, this, &AkonadiDatabaseToolsDialog::reject);
readConfig();
}
AkonadiDatabaseToolsDialog::~AkonadiDatabaseToolsDialog()
{
writeConfig();
}
void AkonadiDatabaseToolsDialog::appendText(const QString &text)
{
mAkonadiDatabaseToolsWidget->appendText(text);
}
void AkonadiDatabaseToolsDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openStateConfig(), myConfigGroupName);
group.writeEntry("Size", size());
}
void AkonadiDatabaseToolsDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openStateConfig(), myConfigGroupName);
const QSize sizeDialog = group.readEntry("Size", QSize(500, 300));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "akonadidatasetools_export.h"
#include <QDialog>
class AkonadiDatabaseToolsWidget;
class AKONADIDATASETOOLS_EXPORT AkonadiDatabaseToolsDialog : public QDialog
{
Q_OBJECT
public:
explicit AkonadiDatabaseToolsDialog(QWidget *parent = nullptr);
~AkonadiDatabaseToolsDialog() override;
void appendText(const QString &text);
private:
void writeConfig();
void readConfig();
AkonadiDatabaseToolsWidget *const mAkonadiDatabaseToolsWidget;
};
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "akonadidatabasetoolswidget.h"
#include <QVBoxLayout>
AkonadiDatabaseToolsWidget::AkonadiDatabaseToolsWidget(QWidget *parent)
: QWidget{parent}
{
auto mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setContentsMargins(QMargins{});
}
AkonadiDatabaseToolsWidget::~AkonadiDatabaseToolsWidget() = default;
void AkonadiDatabaseToolsWidget::appendText(const QString &text)
{
// TODO
}
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QWidget>
class AkonadiDatabaseToolsWidget : public QWidget
{
Q_OBJECT
public:
explicit AkonadiDatabaseToolsWidget(QWidget *parent = nullptr);
~AkonadiDatabaseToolsWidget() override;
void appendText(const QString &text);
};
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