source: smplayer/trunk/src/prefinput.cpp@ 178

Last change on this file since 178 was 176, checked in by Silvan Scherrer, 9 years ago

smplayer: update trunk to version 16.4

  • Property svn:eol-style set to LF
File size: 15.6 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19
20#include "prefinput.h"
21#include "images.h"
22#include "config.h"
23#include "guiconfig.h"
24
25PrefInput::PrefInput(QWidget * parent, Qt::WindowFlags f)
26 : PrefWidget(parent, f )
27{
28 setupUi(this);
29
30 retranslateStrings();
31}
32
33PrefInput::~PrefInput()
34{
35}
36
37QString PrefInput::sectionName() {
38 return tr("Keyboard and mouse");
39}
40
41QPixmap PrefInput::sectionIcon() {
42 return Images::icon("input_devices", 22);
43}
44
45void PrefInput::createMouseCombos() {
46 left_click_combo->clear();
47 right_click_combo->clear();
48 double_click_combo->clear();
49 middle_click_combo->clear();
50 xbutton1_click_combo->clear();
51 xbutton2_click_combo->clear();
52
53 left_click_combo->addItem( tr("None"), "" );
54 left_click_combo->addItem( tr("Play"), "play" );
55 left_click_combo->addItem( tr("Play / Pause"), "play_or_pause" );
56 left_click_combo->addItem( tr("Pause"), "pause" );
57 left_click_combo->addItem( tr("Pause / Frame step"), "pause_and_frame_step" );
58 left_click_combo->addItem( tr("Stop"), "stop" );
59 left_click_combo->addItem( tr("Go backward (short)"), "rewind1" );
60 left_click_combo->addItem( tr("Go backward (medium)"), "rewind2" );
61 left_click_combo->addItem( tr("Go backward (long)"), "rewind3" );
62 left_click_combo->addItem( tr("Go forward (short)"), "forward1" );
63 left_click_combo->addItem( tr("Go forward (medium)"), "forward2" );
64 left_click_combo->addItem( tr("Go forward (long)"), "forward3" );
65 left_click_combo->addItem( tr("Increase volume"), "increase_volume" );
66 left_click_combo->addItem( tr("Decrease volume"), "decrease_volume" );
67 left_click_combo->addItem( tr("Fullscreen"), "fullscreen" );
68 left_click_combo->addItem( tr("Compact"), "compact" );
69 left_click_combo->addItem( tr("Screenshot"), "screenshot" );
70 left_click_combo->addItem( tr("Always on top"), "on_top_always" );
71 left_click_combo->addItem( tr("Never on top"), "on_top_never" );
72 left_click_combo->addItem( tr("On top while playing"), "on_top_while_playing" );
73 left_click_combo->addItem( tr("Mute"), "mute" );
74 left_click_combo->addItem( tr("OSD - Next level"), "next_osd" );
75 left_click_combo->addItem( tr("Playlist"), "show_playlist" );
76 left_click_combo->addItem( tr("Reset zoom"), "reset_zoom" );
77 left_click_combo->addItem( tr("Exit fullscreen"), "exit_fullscreen" );
78 left_click_combo->addItem( tr("Normal speed"), "normal_speed" );
79 left_click_combo->addItem( tr("Frame counter"), "frame_counter" );
80 left_click_combo->addItem( tr("Preferences"), "show_preferences" );
81 left_click_combo->addItem( tr("Double size"), "toggle_double_size" );
82 left_click_combo->addItem( tr("Next chapter"), "next_chapter" );
83 left_click_combo->addItem( tr("Previous chapter"), "prev_chapter" );
84 left_click_combo->addItem( tr("Show video equalizer"), "video_equalizer" );
85 left_click_combo->addItem( tr("Show audio equalizer"), "audio_equalizer" );
86 left_click_combo->addItem( tr("Show context menu"), "show_context_menu" );
87 left_click_combo->addItem( tr("Change function of wheel"), "next_wheel_function" );
88#if DVDNAV_SUPPORT
89 left_click_combo->addItem( tr("Activate option under mouse in DVD menus"), "dvdnav_mouse" );
90 left_click_combo->addItem( tr("Return to main DVD menu"), "dvdnav_menu" );
91 left_click_combo->addItem( tr("Return to previous menu in DVD menus"), "dvdnav_prev" );
92 left_click_combo->addItem( tr("Move cursor up in DVD menus"), "dvdnav_up" );
93 left_click_combo->addItem( tr("Move cursor down in DVD menus"), "dvdnav_down" );
94 left_click_combo->addItem( tr("Move cursor left in DVD menus"), "dvdnav_left" );
95 left_click_combo->addItem( tr("Move cursor right in DVD menus"), "dvdnav_right" );
96 left_click_combo->addItem( tr("Activate highlighted option in DVD menus"), "dvdnav_select" );
97#endif
98
99 // Copy to other combos
100 for (int n=0; n < left_click_combo->count(); n++) {
101 double_click_combo->addItem( left_click_combo->itemText(n),
102 left_click_combo->itemData(n) );
103
104 right_click_combo->addItem( left_click_combo->itemText(n),
105 left_click_combo->itemData(n) );
106
107 middle_click_combo->addItem( left_click_combo->itemText(n),
108 left_click_combo->itemData(n) );
109
110 xbutton1_click_combo->addItem( left_click_combo->itemText(n),
111 left_click_combo->itemData(n) );
112
113 xbutton2_click_combo->addItem( left_click_combo->itemText(n),
114 left_click_combo->itemData(n) );
115 }
116}
117
118void PrefInput::retranslateStrings() {
119 int wheel_function = wheel_function_combo->currentIndex();
120
121 retranslateUi(this);
122
123 keyboard_icon->setPixmap( Images::icon("keyboard") );
124 mouse_icon->setPixmap( Images::icon("mouse") );
125
126 // Mouse function combos
127 int mouse_left = left_click_combo->currentIndex();
128 int mouse_right = right_click_combo->currentIndex();
129 int mouse_double = double_click_combo->currentIndex();
130 int mouse_middle = middle_click_combo->currentIndex();
131 int mouse_xclick1 = xbutton1_click_combo->currentIndex();
132 int mouse_xclick2 = xbutton2_click_combo->currentIndex();
133
134 createMouseCombos();
135
136 left_click_combo->setCurrentIndex(mouse_left);
137 right_click_combo->setCurrentIndex(mouse_right);
138 double_click_combo->setCurrentIndex(mouse_double);
139 middle_click_combo->setCurrentIndex(mouse_middle);
140 xbutton1_click_combo->setCurrentIndex(mouse_xclick1);
141 xbutton2_click_combo->setCurrentIndex(mouse_xclick2);
142
143 wheel_function_combo->clear();
144 wheel_function_combo->addItem( tr("No function"), Preferences::DoNothing );
145 wheel_function_combo->addItem( tr("Media seeking"), Preferences::Seeking );
146 wheel_function_combo->addItem( tr("Volume control"), Preferences::Volume );
147 wheel_function_combo->addItem( tr("Zoom video"), Preferences::Zoom );
148 wheel_function_combo->addItem( tr("Change speed"), Preferences::ChangeSpeed );
149 wheel_function_combo->setCurrentIndex(wheel_function);
150
151 wheel_function_seek->setText( tr("Media &seeking") );
152 wheel_function_zoom->setText( tr("&Zoom video") );
153 wheel_function_volume->setText( tr("&Volume control") );
154 wheel_function_speed->setText( tr("&Change speed") );
155
156 int drag_function = drag_function_combo->currentIndex();
157 drag_function_combo->clear();
158 drag_function_combo->addItem( tr("None"), Preferences::DragDisabled);
159 drag_function_combo->addItem( tr("Move window"), Preferences::MoveWindow);
160#ifdef MOUSE_GESTURES
161 drag_function_combo->addItem( tr("Seek and volume"), Preferences::Gestures);
162#endif
163 drag_function_combo->setCurrentIndex(drag_function);
164
165#if !USE_SHORTCUTGETTER
166 actioneditor_desc->setText(
167 tr("Here you can change any key shortcut. To do it double click or "
168 "start typing over a shortcut cell. Optionally you can also save "
169 "the list to share it with other people or load it in another "
170 "computer.") );
171#endif
172
173 createHelp();
174}
175
176void PrefInput::setData(Preferences * pref) {
177 setLeftClickFunction( pref->mouse_left_click_function );
178 setRightClickFunction( pref->mouse_right_click_function );
179 setDoubleClickFunction( pref->mouse_double_click_function );
180 setMiddleClickFunction( pref->mouse_middle_click_function );
181 setXButton1ClickFunction( pref->mouse_xbutton1_click_function );
182 setXButton2ClickFunction( pref->mouse_xbutton2_click_function );
183 setWheelFunction( pref->wheel_function );
184 setWheelFunctionCycle(pref->wheel_function_cycle);
185 setWheelFunctionSeekingReverse(pref->wheel_function_seeking_reverse);
186 delay_left_check->setChecked(pref->delay_left_click);
187
188 setDragFunction(pref->drag_function);
189}
190
191void PrefInput::getData(Preferences * pref) {
192 requires_restart = false;
193
194 pref->mouse_left_click_function = leftClickFunction();
195 pref->mouse_right_click_function = rightClickFunction();
196 pref->mouse_double_click_function = doubleClickFunction();
197 pref->mouse_middle_click_function = middleClickFunction();
198 pref->mouse_xbutton1_click_function = xButton1ClickFunction();
199 pref->mouse_xbutton2_click_function = xButton2ClickFunction();
200 pref->wheel_function = wheelFunction();
201 pref->wheel_function_cycle = wheelFunctionCycle();
202 pref->wheel_function_seeking_reverse = wheelFunctionSeekingReverse();
203 pref->delay_left_click = delay_left_check->isChecked();
204
205 pref->drag_function = dragFunction();
206}
207
208/*
209void PrefInput::setActionsList(QStringList l) {
210 left_click_combo->insertStringList( l );
211 double_click_combo->insertStringList( l );
212}
213*/
214
215void PrefInput::setLeftClickFunction(QString f) {
216 int pos = left_click_combo->findData(f);
217 if (pos == -1) pos = 0; //None
218 left_click_combo->setCurrentIndex(pos);
219}
220
221QString PrefInput::leftClickFunction() {
222 return left_click_combo->itemData( left_click_combo->currentIndex() ).toString();
223}
224
225void PrefInput::setRightClickFunction(QString f) {
226 int pos = right_click_combo->findData(f);
227 if (pos == -1) pos = 0; //None
228 right_click_combo->setCurrentIndex(pos);
229}
230
231QString PrefInput::rightClickFunction() {
232 return right_click_combo->itemData( right_click_combo->currentIndex() ).toString();
233}
234
235void PrefInput::setDoubleClickFunction(QString f) {
236 int pos = double_click_combo->findData(f);
237 if (pos == -1) pos = 0; //None
238 double_click_combo->setCurrentIndex(pos);
239}
240
241QString PrefInput::doubleClickFunction() {
242 return double_click_combo->itemData( double_click_combo->currentIndex() ).toString();
243}
244
245void PrefInput::setMiddleClickFunction(QString f) {
246 int pos = middle_click_combo->findData(f);
247 if (pos == -1) pos = 0; //None
248 middle_click_combo->setCurrentIndex(pos);
249}
250
251QString PrefInput::middleClickFunction() {
252 return middle_click_combo->itemData( middle_click_combo->currentIndex() ).toString();
253}
254
255void PrefInput::setXButton1ClickFunction(QString f) {
256 int pos = xbutton1_click_combo->findData(f);
257 if (pos == -1) pos = 0; //None
258 xbutton1_click_combo->setCurrentIndex(pos);
259}
260
261QString PrefInput::xButton1ClickFunction() {
262 return xbutton1_click_combo->itemData( xbutton1_click_combo->currentIndex() ).toString();
263}
264
265void PrefInput::setXButton2ClickFunction(QString f) {
266 int pos = xbutton2_click_combo->findData(f);
267 if (pos == -1) pos = 0; //None
268 xbutton2_click_combo->setCurrentIndex(pos);
269}
270
271QString PrefInput::xButton2ClickFunction() {
272 return xbutton2_click_combo->itemData( xbutton2_click_combo->currentIndex() ).toString();
273}
274
275void PrefInput::setWheelFunction(int function) {
276 int d = wheel_function_combo->findData(function);
277 if (d < 0) d = 0;
278 wheel_function_combo->setCurrentIndex( d );
279}
280
281int PrefInput::wheelFunction() {
282 return wheel_function_combo->itemData(wheel_function_combo->currentIndex()).toInt();
283}
284
285void PrefInput::setWheelFunctionCycle(Preferences::WheelFunctions flags){
286 wheel_function_seek->setChecked(flags.testFlag(Preferences::Seeking));
287 wheel_function_volume->setChecked(flags.testFlag(Preferences::Volume));
288 wheel_function_zoom->setChecked(flags.testFlag(Preferences::Zoom));
289 wheel_function_speed->setChecked(flags.testFlag(Preferences::ChangeSpeed));
290}
291
292Preferences::WheelFunctions PrefInput::wheelFunctionCycle(){
293 Preferences::WheelFunctions seekflags (QFlag ((int) Preferences::Seeking)) ;
294 Preferences::WheelFunctions volumeflags (QFlag ((int) Preferences::Volume)) ;
295 Preferences::WheelFunctions zoomflags (QFlag ((int) Preferences::Zoom)) ;
296 Preferences::WheelFunctions speedflags (QFlag ((int) Preferences::ChangeSpeed)) ;
297 Preferences::WheelFunctions out (QFlag (0));
298 if(wheel_function_seek->isChecked()){
299 out = out | seekflags;
300 }
301 if(wheel_function_volume->isChecked()){
302 out = out | volumeflags;
303 }
304 if(wheel_function_zoom->isChecked()){
305 out = out | zoomflags;
306 }
307 if(wheel_function_speed->isChecked()){
308 out = out | speedflags;
309 }
310 return out;
311}
312
313void PrefInput::setWheelFunctionSeekingReverse(bool b) {
314 wheel_function_seeking_reverse_check->setChecked(b);
315}
316
317bool PrefInput::wheelFunctionSeekingReverse() {
318 return wheel_function_seeking_reverse_check->isChecked();
319}
320
321void PrefInput::setDragFunction(int function) {
322 int d = drag_function_combo->findData(function);
323 if (d < 0) d = 0;
324 drag_function_combo->setCurrentIndex( d );
325}
326
327int PrefInput::dragFunction() {
328 return drag_function_combo->itemData(drag_function_combo->currentIndex()).toInt();
329}
330
331void PrefInput::createHelp() {
332 clearHelp();
333
334 addSectionTitle(tr("Keyboard"));
335
336 setWhatsThis(actions_editor, tr("Shortcut editor"),
337 tr("This table allows you to change the key shortcuts of most "
338 "available actions. Double click or press enter on a item, or "
339 "press the <b>Change shortcut</b> button to enter in the "
340 "<i>Modify shortcut</i> dialog. There are two ways to change a "
341 "shortcut: if the <b>Capture</b> button is on then just "
342 "press the new key or combination of keys that you want to "
343 "assign for the action (unfortunately this doesn't work for all "
344 "keys). If the <b>Capture</b> button is off "
345 "then you could enter the full name of the key.") );
346
347 addSectionTitle(tr("Mouse"));
348
349 setWhatsThis(left_click_combo, tr("Left click"),
350 tr("Select the action for left click on the mouse.") );
351
352 setWhatsThis(double_click_combo, tr("Double click"),
353 tr("Select the action for double click on the mouse.") );
354
355 setWhatsThis(middle_click_combo, tr("Middle click"),
356 tr("Select the action for middle click on the mouse.") );
357
358 setWhatsThis(xbutton1_click_combo, tr("X Button 1"),
359 tr("Select the action for the X button 1.") );
360
361 setWhatsThis(xbutton2_click_combo, tr("X Button 2"),
362 tr("Select the action for the X button 2.") );
363
364 setWhatsThis(wheel_function_combo, tr("Wheel function"),
365 tr("Select the action for the mouse wheel.") );
366
367 setWhatsThis(drag_function_combo, tr("Drag function"),
368 tr("This option controls what to do when the mouse is moved while pressing the left button.") + "<br>" +
369 "<b>" + tr("Move window") + "</b>:" + tr("the main window is moved") + "<br>"
370#ifdef MOUSE_GESTURES
371 + "<b>" + tr("Seek and volume") + "</b>:" +
372 tr("a horizontal movement changes the time position while a vertical movement changes the volume")
373#endif
374 );
375
376 setWhatsThis(delay_left_check, tr("Don't trigger the left click function with a double click"),
377 tr("If this option is enabled when you double click on the "
378 "video area only the double click function will be triggered. "
379 "The left click action won't be activated.") + " "+
380 tr("By enabling this option the left click is delayed %1 milliseconds "
381 "because it's necessary to wait that time to know if there's a double click or not.").arg(qApp->doubleClickInterval()+10) );
382
383 setWhatsThis(wheel_function_seeking_reverse_check, tr("Reverse mouse wheel seeking"),
384 tr("Check it to seek in the opposite direction.") );
385
386 addSectionTitle(tr("Mouse wheel functions"));
387
388 setWhatsThis(wheel_function_seek, tr("Media seeking"),
389 tr("Check it to enable seeking as one function.") );
390
391 setWhatsThis(wheel_function_volume, tr("Volume control"),
392 tr("Check it to enable changing volume as one function.") );
393
394 setWhatsThis(wheel_function_zoom, tr("Zoom video"),
395 tr("Check it to enable zooming as one function.") );
396
397 setWhatsThis(wheel_function_speed, tr("Change speed"),
398 tr("Check it to enable changing speed as one function.") );
399}
400
401#include "moc_prefinput.cpp"
Note: See TracBrowser for help on using the repository browser.