Commit 1e19e83f authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement save tool button

parent 16d67980
Pipeline #44510 passed with stage
in 9 minutes and 1 second
......@@ -30,5 +30,8 @@ SaveToolButtonTest::SaveToolButtonTest(QObject *parent)
void SaveToolButtonTest::shouldHaveDefaultValues()
{
//TODO
SaveToolButton w;
QVERIFY(w.menu());
QVERIFY(!w.text().isEmpty());
QCOMPARE(w.popupMode(), QToolButton::InstantPopup);
}
......@@ -77,7 +77,8 @@ KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
saveAs->setText(i18n("Save As..."));
saveAs->setObjectName(QStringLiteral("saveas_button"));
buttonBox->addButton(saveAs, QDialogButtonBox::ActionRole);
connect(saveAs, &SaveToolButton::clicked, this, &KDebugSettingsDialog::slotSaveAs);
connect(saveAs, &SaveToolButton::saveAsFile, this, &KDebugSettingsDialog::slotSaveAs);
connect(saveAs, &SaveToolButton::saveAsGroup, this, &KDebugSettingsDialog::slotSaveAsGroup);
LoadToolButton *load = new LoadToolButton(this);
load->setObjectName(QStringLiteral("load_button"));
......@@ -207,6 +208,11 @@ void KDebugSettingsDialog::slotInsertCategories()
}
}
void KDebugSettingsDialog::slotSaveAsGroup()
{
//TODO
}
void KDebugSettingsDialog::slotSaveAs()
{
const QString path = QFileDialog::getSaveFileName(this, i18n("Save As"), QString(), i18n("KDebugSettings File (*.kdebugsettingsrules)"));
......
......@@ -55,6 +55,7 @@ private:
void readConfig();
void updateLogginsCategories();
void slotLoadGroup(const QString &fullPath);
void slotSaveAsGroup();
KdeLoggingCategory::List mCategoriesList;
KDebugSettingsLoadingCategories mLoggings;
QTabWidget *mTabWidget = nullptr;
......
......@@ -19,12 +19,22 @@
*/
#include "savetoolbutton.h"
#include <KLocalizedString>
#include <QAction>
#include <QMenu>
SaveToolButton::SaveToolButton(QWidget *parent)
: QToolButton(parent)
{
setText(i18n("Save As..."));
//TODO
setPopupMode(QToolButton::InstantPopup);
QMenu *mainMenu = new QMenu(this);
setMenu(mainMenu);
QAction *act = mainMenu->addAction(i18n("Save As File..."));
connect(act, &QAction::triggered, this, &SaveToolButton::saveAsFile);
QAction *actGroup = mainMenu->addAction(i18n("Save As Group..."));
connect(actGroup, &QAction::triggered, this, &SaveToolButton::saveAsGroup);
}
SaveToolButton::~SaveToolButton()
......
......@@ -30,6 +30,9 @@ class LIBKDEBUGSETTINGS_EXPORT_TEST_EXPORT SaveToolButton : public QToolButton
public:
explicit SaveToolButton(QWidget *parent = nullptr);
~SaveToolButton() override;
Q_SIGNALS:
void saveAsFile();
void saveAsGroup();
};
#endif // SAVETOOLBUTTON_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