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
756eb4fe
Commit
756eb4fe
authored
Nov 17, 2011
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: simplify too complex UI for keys
Noone understood this UI, but me...
parent
ae8b4b81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
81 deletions
+37
-81
modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.cpp
+31
-53
modules/gui/qt4/components/preferences_widgets.hpp
modules/gui/qt4/components/preferences_widgets.hpp
+6
-28
No files found.
modules/gui/qt4/components/preferences_widgets.cpp
View file @
756eb4fe
...
@@ -1297,7 +1297,7 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
...
@@ -1297,7 +1297,7 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
qtr
(
"Select an action to change the associated hotkey"
)
);
qtr
(
"Select an action to change the associated hotkey"
)
);
QLabel
*
searchLabel
=
new
QLabel
(
qtr
(
"Search"
)
);
QLabel
*
searchLabel
=
new
QLabel
(
qtr
(
"Search"
)
);
actionSearch
=
new
SearchLineEdit
(
keyContainer
);
SearchLineEdit
*
actionSearch
=
new
SearchLineEdit
(
keyContainer
);
table
=
new
QTreeWidget
;
table
=
new
QTreeWidget
;
table
->
setColumnCount
(
3
);
table
->
setColumnCount
(
3
);
...
@@ -1307,27 +1307,17 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
...
@@ -1307,27 +1307,17 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
table
->
setAlternatingRowColors
(
true
);
table
->
setAlternatingRowColors
(
true
);
table
->
setSelectionBehavior
(
QAbstractItemView
::
SelectItems
);
table
->
setSelectionBehavior
(
QAbstractItemView
::
SelectItems
);
shortcutValue
=
new
KeyShortcutEdit
;
table
->
installEventFilter
(
this
);
shortcutValue
->
setReadOnly
(
true
);
QPushButton
*
clearButton
=
new
QPushButton
(
qtr
(
"Clear"
)
);
QPushButton
*
setButton
=
new
QPushButton
(
qtr
(
"Apply"
)
);
setButton
->
setDefault
(
true
);
finish
();
finish
();
gLayout
->
addWidget
(
label
,
0
,
0
,
1
,
4
);
gLayout
->
addWidget
(
label
,
0
,
0
,
1
,
4
);
gLayout
->
addWidget
(
searchLabel
,
1
,
0
,
1
,
2
);
gLayout
->
addWidget
(
searchLabel
,
1
,
0
,
1
,
2
);
gLayout
->
addWidget
(
actionSearch
,
1
,
2
,
1
,
2
);
gLayout
->
addWidget
(
actionSearch
,
1
,
2
,
1
,
2
);
gLayout
->
addWidget
(
table
,
2
,
0
,
1
,
4
);
gLayout
->
addWidget
(
table
,
2
,
0
,
1
,
4
);
gLayout
->
addWidget
(
clearButton
,
3
,
0
,
1
,
1
);
gLayout
->
addWidget
(
shortcutValue
,
3
,
1
,
1
,
2
);
gLayout
->
addWidget
(
setButton
,
3
,
3
,
1
,
1
);
l
->
addWidget
(
keyContainer
,
line
,
0
,
1
,
-
1
);
l
->
addWidget
(
keyContainer
,
line
,
0
,
1
,
-
1
);
CONNECT
(
clearButton
,
clicked
(),
shortcutValue
,
clear
()
);
CONNECT
(
clearButton
,
clicked
(),
this
,
setTheKey
()
);
BUTTONACT
(
setButton
,
setTheKey
()
);
CONNECT
(
actionSearch
,
textChanged
(
const
QString
&
),
CONNECT
(
actionSearch
,
textChanged
(
const
QString
&
),
this
,
filter
(
const
QString
&
)
);
this
,
filter
(
const
QString
&
)
);
}
}
...
@@ -1396,14 +1386,8 @@ void KeySelectorControl::finish()
...
@@ -1396,14 +1386,8 @@ void KeySelectorControl::finish()
table
->
resizeColumnToContents
(
0
);
table
->
resizeColumnToContents
(
0
);
CONNECT
(
table
,
item
DoubleClick
ed
(
QTreeWidgetItem
*
,
int
),
CONNECT
(
table
,
item
Activat
ed
(
QTreeWidgetItem
*
,
int
),
this
,
selectKey
(
QTreeWidgetItem
*
,
int
)
);
this
,
selectKey
(
QTreeWidgetItem
*
,
int
)
);
CONNECT
(
table
,
itemClicked
(
QTreeWidgetItem
*
,
int
),
this
,
select
(
QTreeWidgetItem
*
,
int
)
);
CONNECT
(
table
,
itemSelectionChanged
(),
this
,
select1Key
()
);
CONNECT
(
shortcutValue
,
pressed
(),
this
,
selectKey
()
);
}
}
void
KeySelectorControl
::
filter
(
const
QString
&
qs_search
)
void
KeySelectorControl
::
filter
(
const
QString
&
qs_search
)
...
@@ -1417,20 +1401,6 @@ void KeySelectorControl::filter( const QString &qs_search )
...
@@ -1417,20 +1401,6 @@ void KeySelectorControl::filter( const QString &qs_search )
}
}
}
}
void
KeySelectorControl
::
select
(
QTreeWidgetItem
*
,
int
column
)
{
shortcutValue
->
setGlobal
(
column
==
2
);
}
/* Show the key selected from the table in the keySelector */
void
KeySelectorControl
::
select1Key
()
{
QTreeWidgetItem
*
keyItem
=
table
->
currentItem
();
shortcutValue
->
setText
(
keyItem
->
text
(
1
)
);
shortcutValue
->
setValue
(
keyItem
->
data
(
1
,
Qt
::
UserRole
).
toString
()
);
shortcutValue
->
setGlobal
(
false
);
}
void
KeySelectorControl
::
selectKey
(
QTreeWidgetItem
*
keyItem
,
int
column
)
void
KeySelectorControl
::
selectKey
(
QTreeWidgetItem
*
keyItem
,
int
column
)
{
{
/* This happens when triggered by ClickEater */
/* This happens when triggered by ClickEater */
...
@@ -1452,10 +1422,8 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
...
@@ -1452,10 +1422,8 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
if
(
d
->
result
()
==
QDialog
::
Accepted
)
if
(
d
->
result
()
==
QDialog
::
Accepted
)
{
{
QString
newKey
=
VLCKeyToString
(
d
->
keyValue
);
QString
newKey
=
VLCKeyToString
(
d
->
keyValue
);
shortcutValue
->
setText
(
newKey
);
shortcutValue
->
setValue
(
newKey
);
shortcutValue
->
setGlobal
(
b_global
);
/* In case of conflict, reset other keys*/
if
(
d
->
conflicts
)
if
(
d
->
conflicts
)
{
{
QTreeWidgetItem
*
it
;
QTreeWidgetItem
*
it
;
...
@@ -1470,22 +1438,14 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
...
@@ -1470,22 +1438,14 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
it
->
setText
(
1
+
b_global
,
qtr
(
"Unset"
)
);
it
->
setText
(
1
+
b_global
,
qtr
(
"Unset"
)
);
}
}
}
}
/* We already made an OK once. */
setTheKey
();
}
}
keyItem
->
setText
(
column
,
newKey
);
keyItem
->
setData
(
column
,
Qt
::
UserRole
,
newKey
);
}
}
delete
d
;
delete
d
;
}
}
void
KeySelectorControl
::
setTheKey
()
{
if
(
!
table
->
currentItem
()
)
return
;
table
->
currentItem
()
->
setText
(
shortcutValue
->
getGlobal
()
?
2
:
1
,
shortcutValue
->
text
()
);
table
->
currentItem
()
->
setData
(
shortcutValue
->
getGlobal
()
?
2
:
1
,
Qt
::
UserRole
,
shortcutValue
->
getValue
()
);
}
void
KeySelectorControl
::
doApply
()
void
KeySelectorControl
::
doApply
()
{
{
QTreeWidgetItem
*
it
;
QTreeWidgetItem
*
it
;
...
@@ -1504,6 +1464,29 @@ void KeySelectorControl::doApply()
...
@@ -1504,6 +1464,29 @@ void KeySelectorControl::doApply()
}
}
}
}
bool
KeySelectorControl
::
eventFilter
(
QObject
*
obj
,
QEvent
*
e
)
{
if
(
obj
!=
table
||
e
->
type
()
!=
QEvent
::
KeyPress
)
return
ConfigControl
::
eventFilter
(
obj
,
e
);
QKeyEvent
*
keyEv
=
static_cast
<
QKeyEvent
*>
(
e
);
QTreeWidget
*
aTable
=
static_cast
<
QTreeWidget
*>
(
obj
);
if
(
keyEv
->
key
()
==
Qt
::
Key_Escape
)
{
aTable
->
clearFocus
();
return
true
;
}
else
if
(
keyEv
->
key
()
==
Qt
::
Key_Return
||
keyEv
->
key
()
==
Qt
::
Key_Enter
)
{
selectKey
(
aTable
->
currentItem
(),
aTable
->
currentColumn
()
);
return
true
;
}
else
return
false
;
}
/**
/**
* Class KeyInputDialog
* Class KeyInputDialog
**/
**/
...
@@ -1521,7 +1504,7 @@ KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
...
@@ -1521,7 +1504,7 @@ KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
+
qtr
(
"Hotkey for "
)
+
keyToChange
);
+
qtr
(
"Hotkey for "
)
+
keyToChange
);
setWindowRole
(
"vlc-key-input"
);
setWindowRole
(
"vlc-key-input"
);
vLayout
=
new
QVBoxLayout
(
this
);
QVBoxLayout
*
vLayout
=
new
QVBoxLayout
(
this
);
selected
=
new
QLabel
(
qtr
(
"Press the new keys for "
)
+
keyToChange
);
selected
=
new
QLabel
(
qtr
(
"Press the new keys for "
)
+
keyToChange
);
vLayout
->
addWidget
(
selected
,
Qt
::
AlignCenter
);
vLayout
->
addWidget
(
selected
,
Qt
::
AlignCenter
);
...
@@ -1586,8 +1569,3 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e )
...
@@ -1586,8 +1569,3 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e )
keyValue
=
i_vlck
;
keyValue
=
i_vlck
;
}
}
void
KeyShortcutEdit
::
mousePressEvent
(
QMouseEvent
*
)
{
emit
pressed
();
}
modules/gui/qt4/components/preferences_widgets.hpp
View file @
756eb4fe
...
@@ -446,26 +446,6 @@ private slot:
...
@@ -446,26 +446,6 @@ private slot:
/**********************************************************************
/**********************************************************************
* Key selector widget
* Key selector widget
**********************************************************************/
**********************************************************************/
class
KeyShortcutEdit
:
public
QLineEdit
{
Q_OBJECT
public:
void
setValue
(
const
QString
&
value
){
this
->
value
=
value
;
}
QString
getValue
()
const
{
return
value
;
}
void
setGlobal
(
bool
_value
)
{
b_global
=
_value
;
}
bool
getGlobal
()
const
{
return
b_global
;
}
public
slots
:
virtual
void
clear
(
void
)
{
value
=
qfu
(
""
);
QLineEdit
::
clear
();
}
private:
QString
value
;
bool
b_global
;
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
signals:
void
pressed
();
};
class
SearchLineEdit
;
class
KeySelectorControl
:
public
ConfigControl
class
KeySelectorControl
:
public
ConfigControl
{
{
Q_OBJECT
Q_OBJECT
...
@@ -476,18 +456,15 @@ public:
...
@@ -476,18 +456,15 @@ public:
virtual
void
hide
()
{
table
->
hide
();
if
(
label
)
label
->
hide
();
}
virtual
void
hide
()
{
table
->
hide
();
if
(
label
)
label
->
hide
();
}
virtual
void
show
()
{
table
->
show
();
if
(
label
)
label
->
show
();
}
virtual
void
show
()
{
table
->
show
();
if
(
label
)
label
->
show
();
}
virtual
void
doApply
();
virtual
void
doApply
();
protected:
virtual
bool
eventFilter
(
QObject
*
,
QEvent
*
);
private:
private:
void
finish
();
void
finish
();
QLabel
*
label
;
QLabel
*
label
;
QTreeWidget
*
table
;
QTreeWidget
*
table
;
KeyShortcutEdit
*
shortcutValue
;
QList
<
module_config_t
*>
values
;
QList
<
module_config_t
*>
values
;
SearchLineEdit
*
actionSearch
;
private
slots
:
private
slots
:
void
setTheKey
();
void
selectKey
(
QTreeWidgetItem
*
=
NULL
,
int
column
=
1
);
void
selectKey
(
QTreeWidgetItem
*
=
NULL
,
int
column
=
1
);
void
select
(
QTreeWidgetItem
*
=
NULL
,
int
column
=
1
);
void
select1Key
();
void
filter
(
const
QString
&
);
void
filter
(
const
QString
&
);
};
};
...
@@ -497,14 +474,15 @@ public:
...
@@ -497,14 +474,15 @@ public:
KeyInputDialog
(
QTreeWidget
*
,
const
QString
&
,
QWidget
*
,
bool
b_global
=
false
);
KeyInputDialog
(
QTreeWidget
*
,
const
QString
&
,
QWidget
*
,
bool
b_global
=
false
);
int
keyValue
;
int
keyValue
;
bool
conflicts
;
bool
conflicts
;
private:
private:
QTreeWidget
*
table
;
QTreeWidget
*
table
;
QLabel
*
selected
,
*
warning
;
QDialogButtonBox
*
buttonBox
;
void
checkForConflicts
(
int
i_vlckey
);
void
checkForConflicts
(
int
i_vlckey
);
void
keyPressEvent
(
QKeyEvent
*
);
void
keyPressEvent
(
QKeyEvent
*
);
void
wheelEvent
(
QWheelEvent
*
);
void
wheelEvent
(
QWheelEvent
*
);
QLabel
*
selected
,
*
warning
;
QVBoxLayout
*
vLayout
;
QDialogButtonBox
*
buttonBox
;
bool
b_global
;
bool
b_global
;
};
};
#endif
#endif
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