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

Last change on this file since 148 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

  • Property svn:eol-style set to LF
File size: 13.7 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 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}
176
177void PrefInput::getData(Preferences * pref) {
178 requires_restart = false;
179
180 pref->mouse_left_click_function = leftClickFunction();
181 pref->mouse_right_click_function = rightClickFunction();
182 pref->mouse_double_click_function = doubleClickFunction();
183 pref->mouse_middle_click_function = middleClickFunction();
184 pref->mouse_xbutton1_click_function = xButton1ClickFunction();
185 pref->mouse_xbutton2_click_function = xButton2ClickFunction();
186 pref->wheel_function = wheelFunction();
187 pref->wheel_function_cycle = wheelFunctionCycle();
188 pref->wheel_function_seeking_reverse = wheelFunctionSeekingReverse();
189}
190
191/*
192void PrefInput::setActionsList(QStringList l) {
193 left_click_combo->insertStringList( l );
194 double_click_combo->insertStringList( l );
195}
196*/
197
198void PrefInput::setLeftClickFunction(QString f) {
199 int pos = left_click_combo->findData(f);
200 if (pos == -1) pos = 0; //None
201 left_click_combo->setCurrentIndex(pos);
202}
203
204QString PrefInput::leftClickFunction() {
205 return left_click_combo->itemData( left_click_combo->currentIndex() ).toString();
206}
207
208void PrefInput::setRightClickFunction(QString f) {
209 int pos = right_click_combo->findData(f);
210 if (pos == -1) pos = 0; //None
211 right_click_combo->setCurrentIndex(pos);
212}
213
214QString PrefInput::rightClickFunction() {
215 return right_click_combo->itemData( right_click_combo->currentIndex() ).toString();
216}
217
218void PrefInput::setDoubleClickFunction(QString f) {
219 int pos = double_click_combo->findData(f);
220 if (pos == -1) pos = 0; //None
221 double_click_combo->setCurrentIndex(pos);
222}
223
224QString PrefInput::doubleClickFunction() {
225 return double_click_combo->itemData( double_click_combo->currentIndex() ).toString();
226}
227
228void PrefInput::setMiddleClickFunction(QString f) {
229 int pos = middle_click_combo->findData(f);
230 if (pos == -1) pos = 0; //None
231 middle_click_combo->setCurrentIndex(pos);
232}
233
234QString PrefInput::middleClickFunction() {
235 return middle_click_combo->itemData( middle_click_combo->currentIndex() ).toString();
236}
237
238void PrefInput::setXButton1ClickFunction(QString f) {
239 int pos = xbutton1_click_combo->findData(f);
240 if (pos == -1) pos = 0; //None
241 xbutton1_click_combo->setCurrentIndex(pos);
242}
243
244QString PrefInput::xButton1ClickFunction() {
245 return xbutton1_click_combo->itemData( xbutton1_click_combo->currentIndex() ).toString();
246}
247
248void PrefInput::setXButton2ClickFunction(QString f) {
249 int pos = xbutton2_click_combo->findData(f);
250 if (pos == -1) pos = 0; //None
251 xbutton2_click_combo->setCurrentIndex(pos);
252}
253
254QString PrefInput::xButton2ClickFunction() {
255 return xbutton2_click_combo->itemData( xbutton2_click_combo->currentIndex() ).toString();
256}
257
258void PrefInput::setWheelFunction(int function) {
259 int d = wheel_function_combo->findData(function);
260 if (d < 0) d = 0;
261 wheel_function_combo->setCurrentIndex( d );
262}
263
264int PrefInput::wheelFunction() {
265 return wheel_function_combo->itemData(wheel_function_combo->currentIndex()).toInt();
266}
267
268void PrefInput::setWheelFunctionCycle(QFlags<Preferences::WheelFunctions> flags){
269 wheel_function_seek->setChecked(flags.testFlag(Preferences::Seeking));
270 wheel_function_volume->setChecked(flags.testFlag(Preferences::Volume));
271 wheel_function_zoom->setChecked(flags.testFlag(Preferences::Zoom));
272 wheel_function_speed->setChecked(flags.testFlag(Preferences::ChangeSpeed));
273}
274
275QFlags<Preferences::WheelFunctions> PrefInput::wheelFunctionCycle(){
276 QFlags<Preferences::WheelFunctions> seekflags (QFlag ((int) Preferences::Seeking)) ;
277 QFlags<Preferences::WheelFunctions> volumeflags (QFlag ((int) Preferences::Volume)) ;
278 QFlags<Preferences::WheelFunctions> zoomflags (QFlag ((int) Preferences::Zoom)) ;
279 QFlags<Preferences::WheelFunctions> speedflags (QFlag ((int) Preferences::ChangeSpeed)) ;
280 QFlags<Preferences::WheelFunctions> out (QFlag (0));
281 if(wheel_function_seek->isChecked()){
282 out = out | seekflags;
283 }
284 if(wheel_function_volume->isChecked()){
285 out = out | volumeflags;
286 }
287 if(wheel_function_zoom->isChecked()){
288 out = out | zoomflags;
289 }
290 if(wheel_function_speed->isChecked()){
291 out = out | speedflags;
292 }
293 return out;
294}
295
296void PrefInput::setWheelFunctionSeekingReverse(bool b) {
297 wheel_function_seeking_reverse_check->setChecked(b);
298}
299
300bool PrefInput::wheelFunctionSeekingReverse() {
301 return wheel_function_seeking_reverse_check->isChecked();
302}
303
304void PrefInput::createHelp() {
305 clearHelp();
306
307 addSectionTitle(tr("Keyboard"));
308
309 setWhatsThis(actions_editor, tr("Shortcut editor"),
310 tr("This table allows you to change the key shortcuts of most "
311 "available actions. Double click or press enter on a item, or "
312 "press the <b>Change shortcut</b> button to enter in the "
313 "<i>Modify shortcut</i> dialog. There are two ways to change a "
314 "shortcut: if the <b>Capture</b> button is on then just "
315 "press the new key or combination of keys that you want to "
316 "assign for the action (unfortunately this doesn't work for all "
317 "keys). If the <b>Capture</b> button is off "
318 "then you could enter the full name of the key.") );
319
320 addSectionTitle(tr("Mouse"));
321
322 setWhatsThis(left_click_combo, tr("Left click"),
323 tr("Select the action for left click on the mouse.") );
324
325 setWhatsThis(double_click_combo, tr("Double click"),
326 tr("Select the action for double click on the mouse.") );
327
328 setWhatsThis(middle_click_combo, tr("Middle click"),
329 tr("Select the action for middle click on the mouse.") );
330
331 setWhatsThis(xbutton1_click_combo, tr("X Button 1"),
332 tr("Select the action for the X button 1.") );
333
334 setWhatsThis(xbutton2_click_combo, tr("X Button 2"),
335 tr("Select the action for the X button 2.") );
336
337 setWhatsThis(wheel_function_combo, tr("Wheel function"),
338 tr("Select the action for the mouse wheel.") );
339
340 addSectionTitle(tr("Mouse wheel functions"));
341
342 setWhatsThis(wheel_function_seek, tr("Media seeking"),
343 tr("Check it to enable seeking as one function.") );
344
345 setWhatsThis(wheel_function_volume, tr("Volume control"),
346 tr("Check it to enable changing volume as one function.") );
347
348 setWhatsThis(wheel_function_zoom, tr("Zoom video"),
349 tr("Check it to enable zooming as one function.") );
350
351 setWhatsThis(wheel_function_speed, tr("Change speed"),
352 tr("Check it to enable changing speed as one function.") );
353
354 setWhatsThis(wheel_function_seeking_reverse_check, tr("Reverse mouse wheel seeking"),
355 tr("Check it to seek in the opposite direction.") );
356
357}
358
359#include "moc_prefinput.cpp"
Note: See TracBrowser for help on using the repository browser.