Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
KDebugSettings
Commits
77679d8f
Commit
77679d8f
authored
Dec 18, 2020
by
Laurent Montel
😁
Browse files
Implement save group
TODO: manage list of group
parent
1e19e83f
Pipeline
#44512
passed with stage
in 9 minutes and 15 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/kdebugsettingsdialog.cpp
View file @
77679d8f
...
...
@@ -28,6 +28,8 @@
#include "saverulesjob.h"
#include "loadtoolbutton.h"
#include "savetoolbutton.h"
#include "loadgroupmenu.h"
#include "kdebugsettings_debug.h"
#include <KLocalizedString>
#include <KConfigGroup>
...
...
@@ -42,7 +44,7 @@
#include <QPushButton>
#include <QDesktopServices>
#include <QUrl>
#include
"kdebugsettings_debug.h"
#include
<QInputDialog>
namespace
{
constexpr
char
KDebugSettingsDialogGroupName
[]
=
"KDebugSettingsDialog"
;
}
...
...
@@ -85,6 +87,7 @@ KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
buttonBox
->
addButton
(
load
,
QDialogButtonBox
::
ActionRole
);
connect
(
load
,
&
LoadToolButton
::
loadFromFile
,
this
,
&
KDebugSettingsDialog
::
slotLoad
);
connect
(
load
,
&
LoadToolButton
::
loadGroupRequested
,
this
,
&
KDebugSettingsDialog
::
slotLoadGroup
);
connect
(
this
,
&
KDebugSettingsDialog
::
updateLoadGroupMenu
,
load
,
&
LoadToolButton
::
updateLoadGroupMenu
);
QPushButton
*
insertCategories
=
new
QPushButton
(
i18n
(
"Insert..."
),
this
);
insertCategories
->
setObjectName
(
QStringLiteral
(
"insert_button"
));
...
...
@@ -210,7 +213,12 @@ void KDebugSettingsDialog::slotInsertCategories()
void
KDebugSettingsDialog
::
slotSaveAsGroup
()
{
//TODO
const
QString
groupPath
=
LoadGroupMenu
::
defaultGroupPath
();
const
QString
name
=
QInputDialog
::
getText
(
this
,
i18n
(
"Group Name"
),
i18n
(
"Name"
));
if
(
!
name
.
isEmpty
())
{
saveRules
(
groupPath
+
QLatin1Char
(
'/'
)
+
name
,
true
);
Q_EMIT
updateLoadGroupMenu
();
}
}
void
KDebugSettingsDialog
::
slotSaveAs
()
...
...
src/kdebugsettingsdialog.h
View file @
77679d8f
...
...
@@ -39,6 +39,9 @@ public:
explicit
KDebugSettingsDialog
(
QWidget
*
parent
=
nullptr
);
~
KDebugSettingsDialog
()
override
;
Q_SIGNALS:
void
updateLoadGroupMenu
();
private:
void
slotAccepted
();
void
slotHelpRequested
();
...
...
src/loadgroupmenu.cpp
View file @
77679d8f
...
...
@@ -42,9 +42,14 @@ void LoadGroupMenu::refreshMenu()
init
();
}
QString
LoadGroupMenu
::
defaultGroupPath
()
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
QLatin1String
(
"/groups"
);
}
void
LoadGroupMenu
::
init
()
{
const
QString
groupPath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
QLatin1String
(
"/groups"
);
const
QString
groupPath
=
LoadGroupMenu
::
defaultGroupPath
(
);
if
(
groupPath
.
isEmpty
())
{
setEnabled
(
false
);
return
;
...
...
src/loadgroupmenu.h
View file @
77679d8f
...
...
@@ -32,6 +32,8 @@ public:
void
refreshMenu
();
static
Q_REQUIRED_RESULT
QString
defaultGroupPath
();
Q_SIGNALS:
void
loadGroupRequested
(
const
QString
&
filePath
);
...
...
src/loadtoolbutton.cpp
View file @
77679d8f
...
...
@@ -24,6 +24,7 @@
LoadToolButton
::
LoadToolButton
(
QWidget
*
parent
)
:
QToolButton
(
parent
)
,
mLoadMenu
(
new
LoadGroupMenu
(
this
))
{
setPopupMode
(
QToolButton
::
InstantPopup
);
setText
(
i18n
(
"Load..."
));
...
...
@@ -33,13 +34,17 @@ LoadToolButton::LoadToolButton(QWidget *parent)
QAction
*
act
=
mainMenu
->
addAction
(
i18n
(
"Load From File..."
));
connect
(
act
,
&
QAction
::
triggered
,
this
,
&
LoadToolButton
::
loadFromFile
);
LoadGroupMenu
*
loadMenu
=
new
LoadGroupMenu
(
this
);
loadMenu
->
setObjectName
(
QStringLiteral
(
"loadMenu"
));
connect
(
loadMenu
,
&
LoadGroupMenu
::
loadGroupRequested
,
this
,
&
LoadToolButton
::
loadGroupRequested
);
mainMenu
->
addMenu
(
loadMenu
);
mLoadMenu
->
setObjectName
(
QStringLiteral
(
"loadMenu"
));
connect
(
mLoadMenu
,
&
LoadGroupMenu
::
loadGroupRequested
,
this
,
&
LoadToolButton
::
loadGroupRequested
);
mainMenu
->
addMenu
(
mLoadMenu
);
}
LoadToolButton
::~
LoadToolButton
()
{
}
void
LoadToolButton
::
updateLoadGroupMenu
()
{
mLoadMenu
->
refreshMenu
();
}
src/loadtoolbutton.h
View file @
77679d8f
...
...
@@ -24,15 +24,20 @@
#include <QToolButton>
#include "libkdebugsettings_private_export.h"
class
LoadGroupMenu
;
class
LIBKDEBUGSETTINGS_EXPORT_TEST_EXPORT
LoadToolButton
:
public
QToolButton
{
Q_OBJECT
public:
explicit
LoadToolButton
(
QWidget
*
parent
=
nullptr
);
~
LoadToolButton
()
override
;
void
updateLoadGroupMenu
();
Q_SIGNALS:
void
loadGroupRequested
(
const
QString
&
fullPath
);
void
loadFromFile
();
private:
LoadGroupMenu
*
const
mLoadMenu
;
};
#endif // LOADTOOLBUTTON_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment