Commit dedaa32a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

implement load group

parent 6599b89e
include_directories(${kdebugsettings_BINARY_DIR}/src ${kdebugsettings_BINARY_DIR})
add_definitions( -DKDEBUGSETTINGS_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
add_definitions( -DKDEBUGSETTINGS_BINARY_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data" )
# convenience macro to add qtest unit tests
macro(add_unittest _source _additionalsource)
set(_test ${_source} ${_additionalsource})
......
......@@ -26,6 +26,7 @@
#include <QTabWidget>
#include <QStandardPaths>
#include <QTest>
#include <QToolButton>
KDebugSettingsDialogTest::KDebugSettingsDialogTest(QObject *parent)
: QObject(parent)
......@@ -54,8 +55,9 @@ void KDebugSettingsDialogTest::shouldHaveDefaultValue()
}
auto *saveAs = buttonBox->findChild<QPushButton *>(QStringLiteral("saveas_button"));
QVERIFY(saveAs);
auto *load = buttonBox->findChild<QPushButton *>(QStringLiteral("load_button"));
auto *load = buttonBox->findChild<QToolButton *>(QStringLiteral("load_button"));
QVERIFY(load);
QVERIFY(load->menu());
auto *insertCategories = buttonBox->findChild<QPushButton *>(QStringLiteral("insert_button"));
QVERIFY(insertCategories);
auto *categoryWarning = dlg.findChild<CategoryWarning *>(QStringLiteral("categorywarning"));
......
......@@ -26,11 +26,13 @@
#include "categorywarning.h"
#include "loadcategoriesjob.h"
#include "saverulesjob.h"
#include "loadgroupmenu.h"
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KMessageBox>
#include <QToolButton>
#include <QFileDialog>
#include <QDialogButtonBox>
......@@ -75,10 +77,16 @@ KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
buttonBox->addButton(saveAs, QDialogButtonBox::ActionRole);
connect(saveAs, &QPushButton::clicked, this, &KDebugSettingsDialog::slotSaveAs);
QPushButton *load = new QPushButton(i18n("Load..."), this);
QToolButton *load = new QToolButton(this);
load->setText(i18n("Load..."));
load->setObjectName(QStringLiteral("load_button"));
buttonBox->addButton(load, QDialogButtonBox::ActionRole);
connect(load, &QPushButton::clicked, this, &KDebugSettingsDialog::slotLoad);
connect(load, &QToolButton::clicked, this, &KDebugSettingsDialog::slotLoad);
LoadGroupMenu *loadMenu = new LoadGroupMenu(this);
loadMenu->setObjectName(QStringLiteral("loadMenu"));
connect(loadMenu, &LoadGroupMenu::loadGroupRequested, this, &KDebugSettingsDialog::slotLoadGroup);
load->setMenu(loadMenu);
QPushButton *insertCategories = new QPushButton(i18n("Insert..."), this);
insertCategories->setObjectName(QStringLiteral("insert_button"));
......@@ -117,6 +125,14 @@ void KDebugSettingsDialog::saveConfig()
group.sync();
}
void KDebugSettingsDialog::slotLoadGroup(const QString &fullPath)
{
if (!fullPath.isEmpty()) {
mLoggings.readCategoriesFiles(fullPath);
updateLogginsCategories();
}
}
void KDebugSettingsDialog::readQtLoggingFile()
{
mLoggings.readQtLoggingFile();
......
......@@ -54,6 +54,7 @@ private:
void saveConfig();
void readConfig();
void updateLogginsCategories();
void slotLoadGroup(const QString &fullPath);
KdeLoggingCategory::List mCategoriesList;
KDebugSettingsLoadingCategories mLoggings;
QTabWidget *mTabWidget = nullptr;
......
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