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

Last change on this file since 165 was 165, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to latest 0.8.7

  • Property svn:eol-style set to LF
File size: 14.3 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2014 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("Show video equalizer"), "video_equalizer" );
83 left_click_combo->addItem( tr("Show audio equalizer"), "audio_equalizer" );
84 left_click_combo->addItem( tr("Show context menu"), "show_context_menu" );
85 left_click_combo->addItem( tr("Change function of wheel"), "next_wheel_function" );
86#if DVDNAV_SUPPORT
87 left_click_combo->addItem( tr("Activate option under mouse in DVD menus"), "dvdnav_mouse" );
88 left_click_combo->addItem( tr("Return to main DVD menu"), "dvdnav_menu" );
89 left_click_combo->addItem( tr("Return to previous menu in DVD menus"), "dvdnav_prev" );
90 left_click_combo->addItem( tr("Move cursor up in DVD menus"), "dvdnav_up" );
91 left_click_combo->addItem( tr("Move cursor down in DVD menus"), "dvdnav_down" );
92 left_click_combo->addItem( tr("Move cursor left in DVD menus"), "dvdnav_left" );
93 left_click_combo->addItem( tr("Move cursor right in DVD menus"), "dvdnav_right" );
94 left_click_combo->addItem( tr("Activate highlighted option in DVD menus"), "dvdnav_select" );
95#endif
96
97 // Copy to other combos
98 for (int n=0; n < left_click_combo->count(); n++) {
99 double_click_combo->addItem( left_click_combo->itemText(n),
100 left_click_combo->itemData(n) );
101
102 right_click_combo->addItem( left_click_combo->itemText(n),
103 left_click_combo->itemData(n) );
104
105 middle_click_combo->addItem( left_click_combo->itemText(n),
106 left_click_combo->itemData(n) );
107
108 xbutton1_click_combo->addItem( left_click_combo->itemText(n),
109 left_click_combo->itemData(n) );
110
111 xbutton2_click_combo->addItem( left_click_combo->itemText(n),
112 left_click_combo->itemData(n) );
113 }
114}
115
116void PrefInput::retranslateStrings() {
117 int wheel_function = wheel_function_combo->currentIndex();
118
119 retranslateUi(this);
120
121 keyboard_icon->setPixmap( Images::icon("keyboard") );
122 mouse_icon->setPixmap( Images::icon("mouse") );
123
124 // Mouse function combos
125 int mouse_left = left_click_combo->currentIndex();
126 int mouse_right = right_click_combo->currentIndex();
127 int mouse_double = double_click_combo->currentIndex();
128 int mouse_middle = middle_click_combo->currentIndex();
129 int mouse_xclick1 = xbutton1_click_combo->currentIndex();
130 int mouse_xclick2 = xbutton2_click_combo->currentIndex();
131
132 createMouseCombos();
133
134 left_click_combo->setCurrentIndex(mouse_left);
135 right_click_combo->setCurrentIndex(mouse_right);
136 double_click_combo->setCurrentIndex(mouse_double);
137 middle_click_combo->setCurrentIndex(mouse_middle);
138 xbutton1_click_combo->setCurrentIndex(mouse_xclick1);
139 xbutton2_click_combo->setCurrentIndex(mouse_xclick2);
140
141 wheel_function_combo->clear();
142 wheel_function_combo->addItem( tr("No function"), Preferences::DoNothing );
143 wheel_function_combo->addItem( tr("Media seeking"), Preferences::Seeking );
144 wheel_function_combo->addItem( tr("Volume control"), Preferences::Volume );
145 wheel_function_combo->addItem( tr("Zoom video"), Preferences::Zoom );
146 wheel_function_combo->addItem( tr("Change speed"), Preferences::ChangeSpeed );
147 wheel_function_combo->setCurrentIndex(wheel_function);
148
149 wheel_function_seek->setText( tr("Media &seeking") );
150 wheel_function_zoom->setText( tr("&Zoom video") );
151 wheel_function_volume->setText( tr("&Volume control") );
152 wheel_function_speed->setText( tr("&Change speed") );
153
154#if !USE_SHORTCUTGETTER
155 actioneditor_desc->setText(
156 tr("Here you can change any key shortcut. To do it double click or "
157 "start typing over a shortcut cell. Optionally you can also save "
158 "the list to share it with other people or load it in another "
159 "computer.") );
160#endif
161
162 createHelp();
163}
164
165void PrefInput::setData(Preferences * pref) {
166 setLeftClickFunction( pref->mouse_left_click_function );
167 setRightClickFunction( pref->mouse_right_click_function );
168 setDoubleClickFunction( pref->mouse_double_click_function );
169 setMiddleClickFunction( pref->mouse_middle_click_function );
170 setXButton1ClickFunction( pref->mouse_xbutton1_click_function );
171 setXButton2ClickFunction( pref->mouse_xbutton2_click_function );
172 setWheelFunction( pref->wheel_function );
173 setWheelFunctionCycle(pref->wheel_function_cycle);
174 setWheelFunctionSeekingReverse(pref->wheel_function_seeking_reverse);
175 delay_left_check->setChecked(pref->delay_left_click);
176}
177
178void PrefInput::getData(Preferences * pref) {
179 requires_restart = false;
180
181 pref->mouse_left_click_function = leftClickFunction();
182 pref->mouse_right_click_function = rightClickFunction();
183 pref->mouse_double_click_function = doubleClickFunction();
184 pref->mouse_middle_click_function = middleClickFunction();
185 pref->mouse_xbutton1_click_function = xButton1ClickFunction();
186 pref->mouse_xbutton2_click_function = xButton2ClickFunction();
187 pref->wheel_function = wheelFunction();
188 pref->wheel_function_cycle = wheelFunctionCycle();
189 pref->wheel_function_seeking_reverse = wheelFunctionSeekingReverse();
190 pref->delay_left_click = delay_left_check->isChecked();
191}
192
193/*
194void PrefInput::setActionsList(QStringList l) {
195 left_click_combo->insertStringList( l );
196 double_click_combo->insertStringList( l );
197}
198*/
199
200void PrefInput::setLeftClickFunction(QString f) {
201 int pos = left_click_combo->findData(f);
202 if (pos == -1) pos = 0; //None
203 left_click_combo->setCurrentIndex(pos);
204}
205
206QString PrefInput::leftClickFunction() {
207 return left_click_combo->itemData( left_click_combo->currentIndex() ).toString();
208}
209
210void PrefInput::setRightClickFunction(QString f) {
211 int pos = right_click_combo->findData(f);
212 if (pos == -1) pos = 0; //None
213 right_click_combo->setCurrentIndex(pos);
214}
215
216QString PrefInput::rightClickFunction() {
217 return right_click_combo->itemData( right_click_combo->currentIndex() ).toString();
218}
219
220void PrefInput::setDoubleClickFunction(QString f) {
221 int pos = double_click_combo->findData(f);
222 if (pos == -1) pos = 0; //None
223 double_click_combo->setCurrentIndex(pos);
224}
225
226QString PrefInput::doubleClickFunction() {
227 return double_click_combo->itemData( double_click_combo->currentIndex() ).toString();
228}
229
230void PrefInput::setMiddleClickFunction(QString f) {
231 int pos = middle_click_combo->findData(f);
232 if (pos == -1) pos = 0; //None
233 middle_click_combo->setCurrentIndex(pos);
234}
235
236QString PrefInput::middleClickFunction() {
237 return middle_click_combo->itemData( middle_click_combo->currentIndex() ).toString();
238}
239
240void PrefInput::setXButton1ClickFunction(QString f) {
241 int pos = xbutton1_click_combo->findData(f);
242 if (pos == -1) pos = 0; //None
243 xbutton1_click_combo->setCurrentIndex(pos);
244}
245
246QString PrefInput::xButton1ClickFunction() {
247 return xbutton1_click_combo->itemData( xbutton1_click_combo->currentIndex() ).toString();
248}
249
250void PrefInput::setXButton2ClickFunction(QString f) {
251 int pos = xbutton2_click_combo->findData(f);
252 if (pos == -1) pos = 0; //None
253 xbutton2_click_combo->setCurrentIndex(pos);
254}
255
256QString PrefInput::xButton2ClickFunction() {
257 return xbutton2_click_combo->itemData( xbutton2_click_combo->currentIndex() ).toString();
258}
259
260void PrefInput::setWheelFunction(int function) {
261 int d = wheel_function_combo->findData(function);
262 if (d < 0) d = 0;
263 wheel_function_combo->setCurrentIndex( d );
264}
265
266int PrefInput::wheelFunction() {
267 return wheel_function_combo->itemData(wheel_function_combo->currentIndex()).toInt();
268}
269
270void PrefInput::setWheelFunctionCycle(Preferences::WheelFunctions flags){
271 wheel_function_seek->setChecked(flags.testFlag(Preferences::Seeking));
272 wheel_function_volume->setChecked(flags.testFlag(Preferences::Volume));
273 wheel_function_zoom->setChecked(flags.testFlag(Preferences::Zoom));
274 wheel_function_speed->setChecked(flags.testFlag(Preferences::ChangeSpeed));
275}
276
277Preferences::WheelFunctions PrefInput::wheelFunctionCycle(){
278 Preferences::WheelFunctions seekflags (QFlag ((int) Preferences::Seeking)) ;
279 Preferences::WheelFunctions volumeflags (QFlag ((int) Preferences::Volume)) ;
280 Preferences::WheelFunctions zoomflags (QFlag ((int) Preferences::Zoom)) ;
281 Preferences::WheelFunctions speedflags (QFlag ((int) Preferences::ChangeSpeed)) ;
282 Preferences::WheelFunctions out (QFlag (0));
283 if(wheel_function_seek->isChecked()){
284 out = out | seekflags;
285 }
286 if(wheel_function_volume->isChecked()){
287 out = out | volumeflags;
288 }
289 if(wheel_function_zoom->isChecked()){
290 out = out | zoomflags;
291 }
292 if(wheel_function_speed->isChecked()){
293 out = out | speedflags;
294 }
295 return out;
296}
297
298void PrefInput::setWheelFunctionSeekingReverse(bool b) {
299 wheel_function_seeking_reverse_check->setChecked(b);
300}
301
302bool PrefInput::wheelFunctionSeekingReverse() {
303 return wheel_function_seeking_reverse_check->isChecked();
304}
305
306void PrefInput::createHelp() {
307 clearHelp();
308
309 addSectionTitle(tr("Keyboard"));
310
311 setWhatsThis(actions_editor, tr("Shortcut editor"),
312 tr("This table allows you to change the key shortcuts of most "
313 "available actions. Double click or press enter on a item, or "
314 "press the <b>Change shortcut</b> button to enter in the "
315 "<i>Modify shortcut</i> dialog. There are two ways to change a "
316 "shortcut: if the <b>Capture</b> button is on then just "
317 "press the new key or combination of keys that you want to "
318 "assign for the action (unfortunately this doesn't work for all "
319 "keys). If the <b>Capture</b> button is off "
320 "then you could enter the full name of the key.") );
321
322 addSectionTitle(tr("Mouse"));
323
324 setWhatsThis(left_click_combo, tr("Left click"),
325 tr("Select the action for left click on the mouse.") );
326
327 setWhatsThis(double_click_combo, tr("Double click"),
328 tr("Select the action for double click on the mouse.") );
329
330 setWhatsThis(middle_click_combo, tr("Middle click"),
331 tr("Select the action for middle click on the mouse.") );
332
333 setWhatsThis(xbutton1_click_combo, tr("X Button 1"),
334 tr("Select the action for the X button 1.") );
335
336 setWhatsThis(xbutton2_click_combo, tr("X Button 2"),
337 tr("Select the action for the X button 2.") );
338
339 setWhatsThis(wheel_function_combo, tr("Wheel function"),
340 tr("Select the action for the mouse wheel.") );
341
342 setWhatsThis(delay_left_check, tr("Don't trigger the left click function with a double click"),
343 tr("If this option is enabled when you double click on the "
344 "video area only the double click function will be triggered. "
345 "The left click action won't be activated.") + " "+
346 tr("By enabling this option the left click is delayed %1 milliseconds "
347 "because it's necessary to wait that time to know if there's a double click or not.").arg(qApp->doubleClickInterval()+10) );
348
349 setWhatsThis(wheel_function_seeking_reverse_check, tr("Reverse mouse wheel seeking"),
350 tr("Check it to seek in the opposite direction.") );
351
352 addSectionTitle(tr("Mouse wheel functions"));
353
354 setWhatsThis(wheel_function_seek, tr("Media seeking"),
355 tr("Check it to enable seeking as one function.") );
356
357 setWhatsThis(wheel_function_volume, tr("Volume control"),
358 tr("Check it to enable changing volume as one function.") );
359
360 setWhatsThis(wheel_function_zoom, tr("Zoom video"),
361 tr("Check it to enable zooming as one function.") );
362
363 setWhatsThis(wheel_function_speed, tr("Change speed"),
364 tr("Check it to enable changing speed as one function.") );
365}
366
367#include "moc_prefinput.cpp"
Note: See TracBrowser for help on using the repository browser.