Verified Commit dde24f12 authored by Alexander Lohnau's avatar Alexander Lohnau
Browse files

Fix linking issues in generated settings

At runtime kmymoney crashes if the classes are named the same
parent badf2917
Pipeline #90949 failed with stage
in 1 minute and 49 seconds
......@@ -6,12 +6,12 @@ set(checkprinting_PART_SRCS
checkprinting.cpp
)
kconfig_add_kcfg_files(checkprinting_PART_SRCS pluginsettings.kcfgc)
qt5_add_resources(checkprinting_PART_SRCS checkprinting.qrc)
kmymoney_add_plugin(checkprinting
SOURCES ${checkprinting_PART_SRCS})
kconfig_add_kcfg_files(checkprinting checkprintingsettings.kcfgc)
target_link_libraries(checkprinting
Qt5::PrintSupport
......@@ -34,7 +34,7 @@ set(kcm_checkprinting_PART_SRCS
kcm_checkprinting.cpp
)
kconfig_add_kcfg_files(kcm_checkprinting_PART_SRCS pluginsettings.kcfgc)
kconfig_add_kcfg_files(kcm_checkprinting_PART_SRCS checkprintingsettings.kcfgc)
ki18n_wrap_ui(kcm_checkprinting_PART_SRCS pluginsettingsdecl.ui)
......
......@@ -35,9 +35,9 @@
#include "selectedobjects.h"
#include "viewinterface.h"
#include "numbertowords.h"
#include "pluginsettings.h"
#include "checkprintingsettings.h"
#include "mymoneyenums.h"
#include "numbertowords.h"
#include "kmm_printer.h"
......@@ -77,11 +77,10 @@ struct CheckPrinting::Private {
void readCheckTemplate()
{
QFile* checkTemplateHTMLFile = new QFile(CheckPrintingSettings::checkTemplateFile());
QFile *checkTemplateHTMLFile = new QFile(PluginSettings::checkTemplateFile());
if (!PluginSettings::useCustomCheckTemplate() || PluginSettings::checkTemplateFile().isEmpty() || !checkTemplateHTMLFile->exists())
checkTemplateHTMLFile = new QFile(PluginSettings::defaultCheckTemplateFileValue());
if (!CheckPrintingSettings::useCustomCheckTemplate() || CheckPrintingSettings::checkTemplateFile().isEmpty() || !checkTemplateHTMLFile->exists())
checkTemplateHTMLFile = new QFile(CheckPrintingSettings::defaultCheckTemplateFileValue());
if (!(checkTemplateHTMLFile->open(QIODevice::ReadOnly)))
qDebug() << "Failed to open the template from" << checkTemplateHTMLFile->fileName();
else
......@@ -191,8 +190,7 @@ CheckPrinting::CheckPrinting(QObject *parent, const KPluginMetaData &metaData, c
// wait until a transaction is selected before enabling the action
d->m_action->setEnabled(false);
PluginSettings::self();
d->m_printedTransactionIdList = PluginSettings::printedChecks();
d->m_printedTransactionIdList = CheckPrintingSettings::printedChecks();
d->readCheckTemplate();
//! @todo Christian: Replace
......@@ -227,7 +225,7 @@ void CheckPrinting::slotPrintCheck()
}
}
updateActions(d->selections);
PluginSettings::setPrintedChecks(d->m_printedTransactionIdList);
CheckPrintingSettings::setPrintedChecks(d->m_printedTransactionIdList);
}
void CheckPrinting::updateActions(const SelectedObjects& selections)
......@@ -260,10 +258,10 @@ void CheckPrinting::updateActions(const SelectedObjects& selections)
// the plugin's configurations has changed
void CheckPrinting::updateConfiguration()
{
PluginSettings::self()->load();
CheckPrintingSettings::self()->load();
// re-read the data because the configuration has changed
d->readCheckTemplate();
d->m_printedTransactionIdList = PluginSettings::printedChecks();
d->m_printedTransactionIdList = CheckPrintingSettings::printedChecks();
}
K_PLUGIN_CLASS_WITH_JSON(CheckPrinting, "checkprinting.json")
......
# Code generation options for kconfig_compiler
File=pluginsettings.kcfg
ClassName=PluginSettings
File=checkprintingsettings.kcfg
ClassName=CheckPrintingSettings
Singleton=true
Mutators=true
DefaultValueGetters=true
......
......@@ -17,7 +17,7 @@
// ----------------------------------------------------------------------------
// Project Includes
#include "pluginsettings.h"
#include "checkprintingsettings.h"
#include "kcm_checkprinting.h"
PluginSettingsWidget::PluginSettingsWidget(QWidget *parent)
......@@ -31,7 +31,7 @@ PluginSettingsWidget::PluginSettingsWidget(QWidget *parent)
m_previewFrame->setLayout(layout);
layout->addWidget(m_checkTemplatePreviewHTMLPart);
if (PluginSettings::checkTemplateFile().isEmpty()) {
if (CheckPrintingSettings::checkTemplateFile().isEmpty()) {
restoreDefaultSettings();
}
......@@ -51,12 +51,10 @@ PluginSettingsWidget::PluginSettingsWidget(QWidget *parent)
void PluginSettingsWidget::urlSelected()
{
if (kcfg_useCustomCheckTemplate->checkState() == Qt::Unchecked
|| PluginSettings::checkTemplateFile().isEmpty()
if (kcfg_useCustomCheckTemplate->checkState() == Qt::Unchecked || CheckPrintingSettings::checkTemplateFile().isEmpty()
|| kcfg_checkTemplateFile->url().isEmpty()) {
urlSelected(QUrl::fromUserInput(PluginSettings::defaultCheckTemplateFileValue()));
}
else {
urlSelected(QUrl::fromUserInput(CheckPrintingSettings::defaultCheckTemplateFileValue()));
} else {
urlSelected(kcfg_checkTemplateFile->url());
}
}
......@@ -86,16 +84,16 @@ void PluginSettingsWidget::urlSelected(const QUrl &url)
void PluginSettingsWidget::textChanged(const QString& text)
{
// conceal the default "qrc:/" value to avoid confusing regular users
if (text == PluginSettings::defaultCheckTemplateFileValue()) {
if (text == CheckPrintingSettings::defaultCheckTemplateFileValue()) {
kcfg_checkTemplateFile->setText("");
}
}
void PluginSettingsWidget::restoreDefaultSettings() const
{
PluginSettings::setUseCustomCheckTemplate(false);
PluginSettings::setCheckTemplateFile(PluginSettings::defaultCheckTemplateFileValue());
PluginSettings::self()->save();
CheckPrintingSettings::setUseCustomCheckTemplate(false);
CheckPrintingSettings::setCheckTemplateFile(CheckPrintingSettings::defaultCheckTemplateFileValue());
CheckPrintingSettings::self()->save();
}
PluginSettingsWidget::~PluginSettingsWidget()
......@@ -109,13 +107,13 @@ KCMCheckPrinting::KCMCheckPrinting(QWidget *parent, const QVariantList& args)
: KCModule(parent, args)
{
PluginSettingsWidget* w = new PluginSettingsWidget(this);
addConfig(PluginSettings::self(), w);
addConfig(CheckPrintingSettings::self(), w);
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
layout->addWidget(w);
load();
w->urlSelected(PluginSettings::useCustomCheckTemplate() ? PluginSettings::checkTemplateFile()
: PluginSettings::defaultCheckTemplateFileValue());
w->urlSelected(CheckPrintingSettings::useCustomCheckTemplate() ? CheckPrintingSettings::checkTemplateFile()
: CheckPrintingSettings::defaultCheckTemplateFileValue());
}
KCMCheckPrinting::~KCMCheckPrinting()
......
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