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
4d466c88
Commit
4d466c88
authored
Jul 11, 2021
by
Laurent Montel
😁
Browse files
Avoid to close dialogbox when we press enter/return
parent
d4776f62
Pipeline
#69911
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/customdebugsettingspage.cpp
View file @
4d466c88
...
...
@@ -12,6 +12,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLabel>
#include <QListWidget>
#include <QMenu>
...
...
@@ -45,10 +46,10 @@ CustomDebugSettingsPage::CustomDebugSettingsPage(QWidget *parent)
connect
(
mListWidget
,
&
QListWidget
::
itemSelectionChanged
,
this
,
&
CustomDebugSettingsPage
::
updateButtons
);
connect
(
mListWidget
,
&
QListWidget
::
itemDoubleClicked
,
this
,
&
CustomDebugSettingsPage
::
slotEditRule
);
connect
(
mListWidget
,
&
QListWidget
::
customContextMenuRequested
,
this
,
&
CustomDebugSettingsPage
::
slotCustomContextMenu
);
auto
s
earchLine
=
new
KListWidgetSearchLine
(
this
,
mListWidget
);
s
earchLine
->
setObjectName
(
QStringLiteral
(
"searchline"
));
s
earchLine
->
setPlaceholderText
(
i18n
(
"Search..."
));
vbox
->
addWidget
(
s
earchLine
);
mTreeListWidgetS
earchLine
=
new
KListWidgetSearchLine
(
this
,
mListWidget
);
mTreeListWidgetS
earchLine
->
setObjectName
(
QStringLiteral
(
"searchline"
));
mTreeListWidgetS
earchLine
->
setPlaceholderText
(
i18n
(
"Search..."
));
vbox
->
addWidget
(
mTreeListWidgetS
earchLine
);
vbox
->
addWidget
(
mListWidget
);
auto
buttonLayout
=
new
QVBoxLayout
;
...
...
@@ -67,12 +68,25 @@ CustomDebugSettingsPage::CustomDebugSettingsPage(QWidget *parent)
buttonLayout
->
addStretch
();
connect
(
mRemoveRule
,
&
QAbstractButton
::
clicked
,
this
,
&
CustomDebugSettingsPage
::
slotRemoveRules
);
updateButtons
();
mTreeListWidgetSearchLine
->
installEventFilter
(
this
);
}
CustomDebugSettingsPage
::~
CustomDebugSettingsPage
()
{
}
bool
CustomDebugSettingsPage
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
KeyPress
&&
obj
==
mTreeListWidgetSearchLine
)
{
auto
key
=
static_cast
<
QKeyEvent
*>
(
event
);
if
((
key
->
key
()
==
Qt
::
Key_Enter
)
||
(
key
->
key
()
==
Qt
::
Key_Return
))
{
event
->
accept
();
return
true
;
}
}
return
QWidget
::
eventFilter
(
obj
,
event
);
}
void
CustomDebugSettingsPage
::
slotCustomContextMenu
(
const
QPoint
&
pos
)
{
QMenu
menu
(
this
);
...
...
src/customdebugsettingspage.h
View file @
4d466c88
...
...
@@ -12,6 +12,7 @@
#include <QWidget>
class
QListWidget
;
class
QPushButton
;
class
KListWidgetSearchLine
;
class
LIBKDEBUGSETTINGS_EXPORT
CustomDebugSettingsPage
:
public
QWidget
{
Q_OBJECT
...
...
@@ -22,6 +23,9 @@ public:
void
fillList
(
const
LoggingCategory
::
List
&
list
);
Q_REQUIRED_RESULT
LoggingCategory
::
List
rules
()
const
;
protected:
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
override
;
private:
void
slotRemoveRules
();
void
slotAddRule
();
...
...
@@ -33,5 +37,6 @@ private:
QPushButton
*
const
mAddRule
;
QPushButton
*
const
mEditRule
;
QPushButton
*
const
mRemoveRule
;
KListWidgetSearchLine
*
mTreeListWidgetSearchLine
=
nullptr
;
};
Write
Preview
Markdown
is supported
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