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

Extract load tool button

parent 95f4b6be
......@@ -19,8 +19,9 @@
*/
#include "kdebugsettingsdialogtest.h"
#include "../src/kdebugsettingsdialog.h"
#include "../src/categorywarning.h"
#include "kdebugsettingsdialog.h"
#include "categorywarning.h"
#include "loadtoolbutton.h"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QTabWidget>
......@@ -55,7 +56,7 @@ void KDebugSettingsDialogTest::shouldHaveDefaultValue()
}
auto saveAs = buttonBox->findChild<QToolButton *>(QStringLiteral("saveas_button"));
QVERIFY(saveAs);
auto load = buttonBox->findChild<QToolButton *>(QStringLiteral("load_button"));
auto load = buttonBox->findChild<LoadToolButton *>(QStringLiteral("load_button"));
QVERIFY(load);
QVERIFY(load->menu());
auto insertCategories = buttonBox->findChild<QPushButton *>(QStringLiteral("insert_button"));
......
......@@ -26,6 +26,7 @@ set(kdebugsettings_LIB_SRCS
environmentsettingsrulespage.cpp
kdeapplicationtreelistwidget.cpp
categorywarning.cpp
loadtoolbutton.cpp
${kdebugsettings_debug_SRCS}
)
......
......@@ -26,7 +26,7 @@
#include "categorywarning.h"
#include "loadcategoriesjob.h"
#include "saverulesjob.h"
#include "loadgroupmenu.h"
#include "loadtoolbutton.h"
#include <KLocalizedString>
#include <KConfigGroup>
......@@ -78,16 +78,12 @@ KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
buttonBox->addButton(saveAs, QDialogButtonBox::ActionRole);
connect(saveAs, &QToolButton::clicked, this, &KDebugSettingsDialog::slotSaveAs);
QToolButton *load = new QToolButton(this);
load->setText(i18n("Load..."));
LoadToolButton *load = new LoadToolButton(this);
load->setObjectName(QStringLiteral("load_button"));
buttonBox->addButton(load, QDialogButtonBox::ActionRole);
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);
connect(load, &LoadToolButton::loadGroupRequested, this, &KDebugSettingsDialog::slotLoadGroup);
QPushButton *insertCategories = new QPushButton(i18n("Insert..."), this);
insertCategories->setObjectName(QStringLiteral("insert_button"));
......
/*
Copyright (c) 2020 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "loadgroupmenu.h"
#include "loadtoolbutton.h"
#include <KLocalizedString>
LoadToolButton::LoadToolButton(QWidget *parent)
: QToolButton(parent)
{
setText(i18n("Load..."));
LoadGroupMenu *loadMenu = new LoadGroupMenu(this);
loadMenu->setObjectName(QStringLiteral("loadMenu"));
connect(loadMenu, &LoadGroupMenu::loadGroupRequested, this, &LoadToolButton::loadGroupRequested);
setMenu(loadMenu);
}
LoadToolButton::~LoadToolButton()
{
}
/*
Copyright (c) 2020 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef LOADTOOLBUTTON_H
#define LOADTOOLBUTTON_H
#include <QToolButton>
#include "libkdebugsettings_private_export.h"
class LIBKDEBUGSETTINGS_EXPORT_TEST_EXPORT LoadToolButton : public QToolButton
{
Q_OBJECT
public:
explicit LoadToolButton(QWidget *parent = nullptr);
~LoadToolButton() override;
Q_SIGNALS:
void loadGroupRequested(const QString &fullPath);
};
#endif // LOADTOOLBUTTON_H
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