Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
e564f592
Commit
e564f592
authored
Dec 22, 2012
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: hotkeys: add check for app's menu shortcuts (fix #7930)
parent
7117284e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
6 deletions
+56
-6
modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.cpp
+43
-3
modules/gui/qt4/components/preferences_widgets.hpp
modules/gui/qt4/components/preferences_widgets.hpp
+13
-3
No files found.
modules/gui/qt4/components/preferences_widgets.cpp
View file @
e564f592
...
...
@@ -51,6 +51,8 @@
#include <QDialogButtonBox>
#include <QKeyEvent>
#include <QColorDialog>
#include <QAction>
#include <QKeySequence>
#define MINWIDTH_BOX 90
#define LAST_COLUMN 10
...
...
@@ -1144,6 +1146,12 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
table
->
installEventFilter
(
this
);
/* Find the top most widget */
QWidget
*
parent
,
*
rootWidget
=
p
;
while
(
parent
=
rootWidget
->
parentWidget
()
)
rootWidget
=
parent
;
buildAppHotkeysList
(
rootWidget
);
finish
();
CONNECT
(
actionSearch
,
textChanged
(
const
QString
&
),
...
...
@@ -1162,6 +1170,17 @@ void KeySelectorControl::fillGrid( QGridLayout *l, int line )
int
KeySelectorControl
::
getType
()
const
{
return
CONFIG_ITEM_KEY
;
}
void
KeySelectorControl
::
buildAppHotkeysList
(
QWidget
*
rootWidget
)
{
QList
<
QAction
*>
actionsList
=
rootWidget
->
findChildren
<
QAction
*>
();
foreach
(
const
QAction
*
action
,
actionsList
)
{
const
QList
<
QKeySequence
>
shortcuts
=
action
->
shortcuts
();
foreach
(
const
QKeySequence
&
keySequence
,
shortcuts
)
existingkeys
<<
keySequence
.
toString
();
}
}
void
KeySelectorControl
::
finish
()
{
if
(
label
&&
p_item
->
psz_longtext
)
...
...
@@ -1269,6 +1288,7 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
/* Launch a small dialog to ask for a new key */
KeyInputDialog
*
d
=
new
KeyInputDialog
(
table
,
keyItem
->
text
(
0
),
table
,
b_global
);
d
->
setExistingkeysSet
(
&
existingkeys
);
d
->
exec
();
if
(
d
->
result
()
==
QDialog
::
Accepted
)
...
...
@@ -1366,6 +1386,7 @@ KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
{
setModal
(
true
);
conflicts
=
false
;
existingkeys
=
NULL
;
table
=
_table
;
setWindowTitle
(
(
b_global
?
qtr
(
"Global"
)
+
QString
(
" "
)
:
""
)
...
...
@@ -1398,7 +1419,12 @@ KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
BUTTONACT
(
unset
,
unsetAction
()
);
}
void
KeyInputDialog
::
checkForConflicts
(
int
i_vlckey
)
void
KeyInputDialog
::
setExistingkeysSet
(
const
QSet
<
QString
>
*
keyset
)
{
existingkeys
=
keyset
;
}
void
KeyInputDialog
::
checkForConflicts
(
int
i_vlckey
,
const
QString
&
sequence
)
{
QList
<
QTreeWidgetItem
*>
conflictList
=
table
->
findItems
(
VLCKeyToString
(
i_vlckey
),
Qt
::
MatchExactly
,
...
...
@@ -1416,6 +1442,19 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
conflicts
=
true
;
}
else
if
(
existingkeys
&&
!
sequence
.
isEmpty
()
&&
existingkeys
->
contains
(
sequence
)
)
{
warning
->
setText
(
qtr
(
"Warning: <b>%1</b> is already an application menu shortcut"
)
.
arg
(
sequence
)
);
warning
->
show
();
ok
->
show
();
unset
->
hide
();
conflicts
=
true
;
}
else
accept
();
}
...
...
@@ -1429,9 +1468,10 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e )
e
->
key
()
==
Qt
::
Key_AltGr
)
return
;
int
i_vlck
=
qtEventToVLCKey
(
e
);
QKeySequence
sequence
(
e
->
key
()
|
e
->
modifiers
()
);
selected
->
setText
(
qtr
(
"Key or combination: "
)
+
QString
(
"<b>%1</b>"
).
arg
(
VLCKeyToString
(
i_vlck
)
)
);
checkForConflicts
(
i_vlck
);
checkForConflicts
(
i_vlck
,
sequence
.
toString
()
);
keyValue
=
i_vlck
;
}
...
...
@@ -1439,7 +1479,7 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e )
{
int
i_vlck
=
qtWheelEventToVLCKey
(
e
);
selected
->
setText
(
qtr
(
"Key: "
)
+
VLCKeyToString
(
i_vlck
)
);
checkForConflicts
(
i_vlck
);
checkForConflicts
(
i_vlck
,
QString
()
);
keyValue
=
i_vlck
;
}
...
...
modules/gui/qt4/components/preferences_widgets.hpp
View file @
e564f592
...
...
@@ -486,10 +486,12 @@ private slot:
class
KeySelectorControl
:
public
ConfigControl
{
Q_OBJECT
public:
KeySelectorControl
(
vlc_object_t
*
,
module_config_t
*
,
QWidget
*
);
explicit
KeySelectorControl
(
vlc_object_t
*
,
module_config_t
*
,
QWidget
*
);
virtual
int
getType
()
const
;
virtual
void
doApply
();
protected:
virtual
bool
eventFilter
(
QObject
*
,
QEvent
*
);
virtual
void
changeVisibility
(
bool
b
)
...
...
@@ -498,13 +500,17 @@ protected:
if
(
label
)
label
->
setVisible
(
b
);
}
virtual
void
fillGrid
(
QGridLayout
*
,
int
);
private:
void
buildAppHotkeysList
(
QWidget
*
rootWidget
);
void
finish
();
QLabel
*
label
;
QLabel
*
searchLabel
;
SearchLineEdit
*
actionSearch
;
QTreeWidget
*
table
;
QList
<
module_config_t
*>
values
;
QSet
<
QString
>
existingkeys
;
private
slots
:
void
selectKey
(
QTreeWidgetItem
*
=
NULL
,
int
column
=
1
);
void
filter
(
const
QString
&
);
...
...
@@ -513,20 +519,24 @@ private slots:
class
KeyInputDialog
:
public
QDialog
{
Q_OBJECT
public:
KeyInputDialog
(
QTreeWidget
*
,
const
QString
&
,
QWidget
*
,
bool
b_global
=
false
);
explicit
KeyInputDialog
(
QTreeWidget
*
,
const
QString
&
,
QWidget
*
,
bool
b_global
=
false
);
int
keyValue
;
bool
conflicts
;
void
setExistingkeysSet
(
const
QSet
<
QString
>
*
keyset
=
NULL
);
private:
QTreeWidget
*
table
;
QLabel
*
selected
,
*
warning
;
QPushButton
*
ok
,
*
unset
;
void
checkForConflicts
(
int
i_vlckey
);
void
checkForConflicts
(
int
i_vlckey
,
const
QString
&
sequence
);
void
keyPressEvent
(
QKeyEvent
*
);
void
wheelEvent
(
QWheelEvent
*
);
bool
b_global
;
const
QSet
<
QString
>
*
existingkeys
;
private
slots
:
void
unsetAction
();
};
...
...
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