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

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

smplayer: update trunk to version 16.8.0

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