Commit 07c01d61 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement configure elements

parent dbc2d411
Pipeline #67510 canceled with stage
add_library(kmailconfirmbeforedeleting)
target_sources(kmailconfirmbeforedeleting PRIVATE
confirmbeforedeletingdialog.cpp
confirmbeforedeletingwidget.cpp
)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
set_target_properties(kmailconfirmbeforedeleting PROPERTIES UNITY_BUILD ON)
endif()
generate_export_header(kmailconfirmbeforedeleting BASE_NAME kmailconfirmbeforedeleting)
target_link_libraries(kmailconfirmbeforedeleting
KF5::MessageComposer
KF5::I18n
Qt::WebEngineWidgets
discount::Lib
KF5::SyntaxHighlighting
)
set_target_properties(kmailconfirmbeforedeleting
PROPERTIES OUTPUT_NAME kmailconfirmbeforedeleting VERSION ${KDEPIMADDONS_LIB_VERSION} SOVERSION ${KDEPIMADDONS_LIB_SOVERSION}
)
install(TARGETS kmailconfirmbeforedeleting ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
kcoreaddons_add_plugin(kmail_confirmbeforedeletingplugin JSON kmail_confirmbeforedeletingplugin.json INSTALL_NAMESPACE messageviewer/checkbeforedeleting)
target_sources(kmail_confirmbeforedeletingplugin PRIVATE
confirmbeforedeletinginterface.cpp
confirmbeforedeletingplugin.cpp
)
ecm_qt_declare_logging_category(kmail_confirmbeforedeletingplugin HEADER confirmbeforedeletingplugin_debug.h IDENTIFIER KMAIL_CONFIRMBEFOREDELETING_PLUGIN_LOG CATEGORY_NAME org.kde.pim.kmail_confirmbeforedeletingplugin
......@@ -17,5 +48,5 @@ if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
endif()
target_link_libraries(kmail_confirmbeforedeletingplugin
KF5::MessageViewer KF5::I18n KF5::PimCommon KF5::Libkdepim
KF5::MessageViewer KF5::I18n KF5::PimCommon KF5::Libkdepim kmailconfirmbeforedeleting
)
macro(add_kmail_checkbeforedeleting_unittest _source _additional)
set( _test ${_source} ${_additional} ${kmail_markdownplugin_debug_SRCS})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(kmail_checkbeforedeleting-${_name})
target_link_libraries( ${_name} Qt::Test KF5::XmlGui KF5::MessageViewer KF5::I18n kmailconfirmbeforedeleting)
endmacro ()
/* This file is part of the KDE project
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "kmailconfirmbeforedeleting_export.h"
/* Classes which are exported only for unit tests */
#ifdef BUILD_TESTING
#ifndef KMAILCONFIRMBEFOREDELETING_TESTS_EXPORT
#define KMAILCONFIRMBEFOREDELETING_TESTS_EXPORT KMAILCONFIRMBEFOREDELETING_EXPORT
#endif
#else /* not compiling tests */
#define KMAILCONFIRMBEFOREDELETING_TESTS_EXPORT
#endif
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "confirmbeforedeletingdialog.h"
#include "confirmbeforedeletingwidget.h"
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QVBoxLayout>
namespace
{
static const char myConfirmBeforeDeletingConfigGroupName[] = "ConfirmBeforeDeletingDialog";
}
ConfirmBeforeDeletingDialog::ConfirmBeforeDeletingDialog(QWidget *parent)
: QDialog(parent)
, mConfirmBeforeDeletingWidget(new ConfirmBeforeDeletingWidget(this))
{
setWindowTitle(i18nc("@title:window", "Configure Before Deleting Mail"));
auto mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mConfirmBeforeDeletingWidget->setObjectName(QStringLiteral("mConfirmBeforeDeletingWidget"));
mainLayout->addWidget(mConfirmBeforeDeletingWidget);
auto box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
box->setObjectName(QStringLiteral("box"));
mainLayout->addWidget(box);
connect(box, &QDialogButtonBox::accepted, this, &ConfirmBeforeDeletingDialog::accept);
connect(box, &QDialogButtonBox::rejected, this, &ConfirmBeforeDeletingDialog::reject);
readConfig();
}
ConfirmBeforeDeletingDialog::~ConfirmBeforeDeletingDialog()
{
writeConfig();
}
void ConfirmBeforeDeletingDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openStateConfig(), myConfirmBeforeDeletingConfigGroupName);
group.writeEntry("Size", size());
}
void ConfirmBeforeDeletingDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openStateConfig(), myConfirmBeforeDeletingConfigGroupName);
const QSize sizeDialog = group.readEntry("Size", QSize(500, 300));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include <QDialog>
class ConfirmBeforeDeletingWidget;
class ConfirmBeforeDeletingDialog : public QDialog
{
Q_OBJECT
public:
explicit ConfirmBeforeDeletingDialog(QWidget *parent = nullptr);
~ConfirmBeforeDeletingDialog() override;
private:
void writeConfig();
void readConfig();
ConfirmBeforeDeletingWidget *const mConfirmBeforeDeletingWidget;
};
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "confirmbeforedeletingplugin.h"
#include "confirmbeforedeletingdialog.h"
#include <QPointer>
ConfirmBeforeDeletingPlugin::ConfirmBeforeDeletingPlugin(QObject *parent)
: MessageViewer::MessageViewerCheckBeforeDeletingPlugin(parent)
{
}
ConfirmBeforeDeletingPlugin::~ConfirmBeforeDeletingPlugin()
{
}
void ConfirmBeforeDeletingPlugin::showConfigureDialog(QWidget *parent)
{
// TODO
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include <MessageViewer/MessageViewerCheckBeforeDeletingPlugin>
class ConfirmBeforeDeletingPlugin : public MessageViewer::MessageViewerCheckBeforeDeletingPlugin
{
Q_OBJECT
public:
explicit ConfirmBeforeDeletingPlugin(QObject *parent = nullptr);
~ConfirmBeforeDeletingPlugin() override;
void showConfigureDialog(QWidget *parent) override;
};
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "confirmbeforedeletingwidget.h"
#include <QVBoxLayout>
ConfirmBeforeDeletingWidget::ConfirmBeforeDeletingWidget(QWidget *parent)
: QWidget(parent)
{
auto mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins({});
mainLayout->setObjectName(QStringLiteral("mainlayout"));
// TODO
}
ConfirmBeforeDeletingWidget::~ConfirmBeforeDeletingWidget()
{
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "confirmbeforedeleting_private_export.h"
#include <QWidget>
class KMAILCONFIRMBEFOREDELETING_TESTS_EXPORT ConfirmBeforeDeletingWidget : public QWidget
{
Q_OBJECT
public:
explicit ConfirmBeforeDeletingWidget(QWidget *parent = nullptr);
~ConfirmBeforeDeletingWidget() override;
};
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