| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 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 | #include "defaultgui.h"
|
|---|
| 20 | #include "helper.h"
|
|---|
| 21 | #include "colorutils.h"
|
|---|
| 22 | #include "core.h"
|
|---|
| 23 | #include "global.h"
|
|---|
| 24 | #include "widgetactions.h"
|
|---|
| 25 | #include "playlist.h"
|
|---|
| 26 | #include "mplayerwindow.h"
|
|---|
| 27 | #include "myaction.h"
|
|---|
| 28 | #include "images.h"
|
|---|
| 29 | #include "floatingwidget.h"
|
|---|
| 30 | #include "desktopinfo.h"
|
|---|
| 31 | #include "editabletoolbar.h"
|
|---|
| 32 |
|
|---|
| 33 | #if DOCK_PLAYLIST
|
|---|
| 34 | #include "playlistdock.h"
|
|---|
| 35 | #endif
|
|---|
| 36 |
|
|---|
| 37 | #include <QMenu>
|
|---|
| 38 | #include <QSettings>
|
|---|
| 39 | #include <QLabel>
|
|---|
| 40 | #include <QStatusBar>
|
|---|
| 41 | #include <QPushButton>
|
|---|
| 42 | #include <QToolButton>
|
|---|
| 43 | #include <QMenuBar>
|
|---|
| 44 |
|
|---|
| 45 | #define TOOLBAR_VERSION 1
|
|---|
| 46 |
|
|---|
| 47 | using namespace Global;
|
|---|
| 48 |
|
|---|
| 49 | DefaultGui::DefaultGui( QWidget * parent, Qt::WindowFlags flags )
|
|---|
| 50 | : BaseGuiPlus( parent, flags )
|
|---|
| 51 | {
|
|---|
| 52 | createStatusBar();
|
|---|
| 53 |
|
|---|
| 54 | connect( this, SIGNAL(timeChanged(QString)),
|
|---|
| 55 | this, SLOT(displayTime(QString)) );
|
|---|
| 56 | connect( this, SIGNAL(frameChanged(int)),
|
|---|
| 57 | this, SLOT(displayFrame(int)) );
|
|---|
| 58 | connect( this, SIGNAL(ABMarkersChanged(int,int)),
|
|---|
| 59 | this, SLOT(displayABSection(int,int)) );
|
|---|
| 60 | connect( this, SIGNAL(videoInfoChanged(int,int,double)),
|
|---|
| 61 | this, SLOT(displayVideoInfo(int,int,double)) );
|
|---|
| 62 |
|
|---|
| 63 | connect( this, SIGNAL(cursorNearBottom(QPoint)),
|
|---|
| 64 | this, SLOT(showFloatingControl(QPoint)) );
|
|---|
| 65 | connect( this, SIGNAL(cursorNearTop(QPoint)),
|
|---|
| 66 | this, SLOT(showFloatingMenu(QPoint)) );
|
|---|
| 67 | connect( this, SIGNAL(cursorFarEdges()),
|
|---|
| 68 | this, SLOT(hideFloatingControls()) );
|
|---|
| 69 |
|
|---|
| 70 | createActions();
|
|---|
| 71 | createMainToolBars();
|
|---|
| 72 | createControlWidget();
|
|---|
| 73 | createControlWidgetMini();
|
|---|
| 74 | createFloatingControl();
|
|---|
| 75 | createMenus();
|
|---|
| 76 |
|
|---|
| 77 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 78 | connect( editToolbar1Act, SIGNAL(triggered()),
|
|---|
| 79 | toolbar1, SLOT(edit()) );
|
|---|
| 80 | connect( editControl1Act, SIGNAL(triggered()),
|
|---|
| 81 | controlwidget, SLOT(edit()) );
|
|---|
| 82 | connect( editControl2Act, SIGNAL(triggered()),
|
|---|
| 83 | controlwidget_mini, SLOT(edit()) );
|
|---|
| 84 | floating_control->toolbar()->takeAvailableActionsFrom(this);
|
|---|
| 85 | connect( editFloatingControlAct, SIGNAL(triggered()),
|
|---|
| 86 | floating_control->toolbar(), SLOT(edit()) );
|
|---|
| 87 | #endif
|
|---|
| 88 |
|
|---|
| 89 | retranslateStrings();
|
|---|
| 90 |
|
|---|
| 91 | loadConfig();
|
|---|
| 92 |
|
|---|
| 93 | //if (playlist_visible) showPlaylist(true);
|
|---|
| 94 |
|
|---|
| 95 | if (pref->compact_mode) {
|
|---|
| 96 | controlwidget->hide();
|
|---|
| 97 | toolbar1->hide();
|
|---|
| 98 | toolbar2->hide();
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | DefaultGui::~DefaultGui() {
|
|---|
| 103 | saveConfig();
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | /*
|
|---|
| 107 | void DefaultGui::closeEvent( QCloseEvent * ) {
|
|---|
| 108 | qDebug("DefaultGui::closeEvent");
|
|---|
| 109 |
|
|---|
| 110 | //BaseGuiPlus::closeEvent(e);
|
|---|
| 111 | qDebug("w: %d h: %d", width(), height() );
|
|---|
| 112 | }
|
|---|
| 113 | */
|
|---|
| 114 |
|
|---|
| 115 | void DefaultGui::createActions() {
|
|---|
| 116 | qDebug("DefaultGui::createActions");
|
|---|
| 117 |
|
|---|
| 118 | timeslider_action = createTimeSliderAction(this);
|
|---|
| 119 | timeslider_action->disable();
|
|---|
| 120 |
|
|---|
| 121 | volumeslider_action = createVolumeSliderAction(this);
|
|---|
| 122 | volumeslider_action->disable();
|
|---|
| 123 |
|
|---|
| 124 | // Create the time label
|
|---|
| 125 | time_label_action = new TimeLabelAction(this);
|
|---|
| 126 | time_label_action->setObjectName("timelabel_action");
|
|---|
| 127 |
|
|---|
| 128 | #if MINI_ARROW_BUTTONS
|
|---|
| 129 | QList<QAction*> rewind_actions;
|
|---|
| 130 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
|---|
| 131 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
|---|
| 132 | rewindbutton_action->setObjectName("rewindbutton_action");
|
|---|
| 133 |
|
|---|
| 134 | QList<QAction*> forward_actions;
|
|---|
| 135 | forward_actions << forward1Act << forward2Act << forward3Act;
|
|---|
| 136 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
|---|
| 137 | forwardbutton_action->setObjectName("forwardbutton_action");
|
|---|
| 138 | #endif
|
|---|
| 139 |
|
|---|
| 140 | // Statusbar
|
|---|
| 141 | viewVideoInfoAct = new MyAction(this, "toggle_video_info" );
|
|---|
| 142 | viewVideoInfoAct->setCheckable(true);
|
|---|
| 143 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
|---|
| 144 | video_info_display, SLOT(setVisible(bool)) );
|
|---|
| 145 |
|
|---|
| 146 | viewFrameCounterAct = new MyAction( this, "toggle_frame_counter" );
|
|---|
| 147 | viewFrameCounterAct->setCheckable( true );
|
|---|
| 148 | connect( viewFrameCounterAct, SIGNAL(toggled(bool)),
|
|---|
| 149 | frame_display, SLOT(setVisible(bool)) );
|
|---|
| 150 |
|
|---|
| 151 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 152 | editToolbar1Act = new MyAction( this, "edit_main_toolbar" );
|
|---|
| 153 | editControl1Act = new MyAction( this, "edit_control1" );
|
|---|
| 154 | editControl2Act = new MyAction( this, "edit_control2" );
|
|---|
| 155 | editFloatingControlAct = new MyAction( this, "edit_floating_control" );
|
|---|
| 156 | #endif
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | #if AUTODISABLE_ACTIONS
|
|---|
| 160 | void DefaultGui::enableActionsOnPlaying() {
|
|---|
| 161 | qDebug("DefaultGui::enableActionsOnPlaying");
|
|---|
| 162 | BaseGuiPlus::enableActionsOnPlaying();
|
|---|
| 163 |
|
|---|
| 164 | timeslider_action->enable();
|
|---|
| 165 | volumeslider_action->enable();
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | void DefaultGui::disableActionsOnStop() {
|
|---|
| 169 | qDebug("DefaultGui::disableActionsOnStop");
|
|---|
| 170 | BaseGuiPlus::disableActionsOnStop();
|
|---|
| 171 |
|
|---|
| 172 | timeslider_action->disable();
|
|---|
| 173 | volumeslider_action->disable();
|
|---|
| 174 | }
|
|---|
| 175 | #endif // AUTODISABLE_ACTIONS
|
|---|
| 176 |
|
|---|
| 177 | void DefaultGui::createMenus() {
|
|---|
| 178 | toolbar_menu = new QMenu(this);
|
|---|
| 179 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
|---|
| 180 | toolbar_menu->addAction(toolbar2->toggleViewAction());
|
|---|
| 181 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 182 | toolbar_menu->addSeparator();
|
|---|
| 183 | toolbar_menu->addAction(editToolbar1Act);
|
|---|
| 184 | toolbar_menu->addAction(editControl1Act);
|
|---|
| 185 | toolbar_menu->addAction(editControl2Act);
|
|---|
| 186 | toolbar_menu->addAction(editFloatingControlAct);
|
|---|
| 187 | #endif
|
|---|
| 188 | optionsMenu->addSeparator();
|
|---|
| 189 | optionsMenu->addMenu(toolbar_menu);
|
|---|
| 190 |
|
|---|
| 191 | statusbar_menu = new QMenu(this);
|
|---|
| 192 | statusbar_menu->addAction(viewVideoInfoAct);
|
|---|
| 193 | statusbar_menu->addAction(viewFrameCounterAct);
|
|---|
| 194 |
|
|---|
| 195 | optionsMenu->addMenu(statusbar_menu);
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | QMenu * DefaultGui::createPopupMenu() {
|
|---|
| 199 | QMenu * m = new QMenu(this);
|
|---|
| 200 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 201 | m->addAction(editToolbar1Act);
|
|---|
| 202 | m->addAction(editControl1Act);
|
|---|
| 203 | m->addAction(editControl2Act);
|
|---|
| 204 | m->addAction(editFloatingControlAct);
|
|---|
| 205 | #else
|
|---|
| 206 | m->addAction(toolbar1->toggleViewAction());
|
|---|
| 207 | m->addAction(toolbar2->toggleViewAction());
|
|---|
| 208 | #endif
|
|---|
| 209 | return m;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | void DefaultGui::createMainToolBars() {
|
|---|
| 213 | toolbar1 = new EditableToolbar( this );
|
|---|
| 214 | toolbar1->setObjectName("toolbar1");
|
|---|
| 215 | //toolbar1->setMovable(false);
|
|---|
| 216 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
|---|
| 217 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 218 | QStringList toolbar1_actions;
|
|---|
| 219 | toolbar1_actions << "open_file" << "open_url" << "favorites_menu" << "separator"
|
|---|
| 220 | << "screenshot" << "separator" << "show_file_properties" << "show_playlist"
|
|---|
| 221 | << "show_preferences" << "separator" << "play_prev" << "play_next";
|
|---|
| 222 | toolbar1->setDefaultActions(toolbar1_actions);
|
|---|
| 223 | #else
|
|---|
| 224 | toolbar1->addAction(openFileAct);
|
|---|
| 225 | toolbar1->addAction(openDVDAct);
|
|---|
| 226 | toolbar1->addAction(openURLAct);
|
|---|
| 227 | toolbar1->addSeparator();
|
|---|
| 228 | toolbar1->addAction(compactAct);
|
|---|
| 229 | toolbar1->addAction(fullscreenAct);
|
|---|
| 230 | toolbar1->addSeparator();
|
|---|
| 231 | toolbar1->addAction(screenshotAct);
|
|---|
| 232 | toolbar1->addSeparator();
|
|---|
| 233 | toolbar1->addAction(showPropertiesAct);
|
|---|
| 234 | toolbar1->addAction(showPlaylistAct);
|
|---|
| 235 | toolbar1->addAction(showPreferencesAct);
|
|---|
| 236 | toolbar1->addSeparator();
|
|---|
| 237 | toolbar1->addAction(playPrevAct);
|
|---|
| 238 | toolbar1->addAction(playNextAct);
|
|---|
| 239 | // Test:
|
|---|
| 240 | //toolbar1->addSeparator();
|
|---|
| 241 | //toolbar1->addAction(timeslider_action);
|
|---|
| 242 | //toolbar1->addAction(volumeslider_action);
|
|---|
| 243 | #endif
|
|---|
| 244 |
|
|---|
| 245 | toolbar2 = new QToolBar( this );
|
|---|
| 246 | toolbar2->setObjectName("toolbar2");
|
|---|
| 247 | //toolbar2->setMovable(false);
|
|---|
| 248 | addToolBar(Qt::TopToolBarArea, toolbar2);
|
|---|
| 249 |
|
|---|
| 250 | select_audio = new QPushButton( this );
|
|---|
| 251 | select_audio->setMenu( audiotrack_menu );
|
|---|
| 252 | toolbar2->addWidget(select_audio);
|
|---|
| 253 |
|
|---|
| 254 | select_subtitle = new QPushButton( this );
|
|---|
| 255 | select_subtitle->setMenu( subtitlestrack_menu );
|
|---|
| 256 | toolbar2->addWidget(select_subtitle);
|
|---|
| 257 |
|
|---|
| 258 | /*
|
|---|
| 259 | toolbar1->show();
|
|---|
| 260 | toolbar2->show();
|
|---|
| 261 | */
|
|---|
| 262 |
|
|---|
| 263 | // Modify toolbars' actions
|
|---|
| 264 | QAction *tba;
|
|---|
| 265 | tba = toolbar1->toggleViewAction();
|
|---|
| 266 | tba->setObjectName("show_main_toolbar");
|
|---|
| 267 | tba->setShortcut(Qt::Key_F5);
|
|---|
| 268 |
|
|---|
| 269 | tba = toolbar2->toggleViewAction();
|
|---|
| 270 | tba->setObjectName("show_language_toolbar");
|
|---|
| 271 | tba->setShortcut(Qt::Key_F6);
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 | void DefaultGui::createControlWidgetMini() {
|
|---|
| 276 | qDebug("DefaultGui::createControlWidgetMini");
|
|---|
| 277 |
|
|---|
| 278 | controlwidget_mini = new EditableToolbar( this );
|
|---|
| 279 | controlwidget_mini->setObjectName("controlwidget_mini");
|
|---|
| 280 | //controlwidget_mini->setResizeEnabled(false);
|
|---|
| 281 | controlwidget_mini->setMovable(false);
|
|---|
| 282 | //addDockWindow(controlwidget_mini, Qt::DockBottom );
|
|---|
| 283 | addToolBar(Qt::BottomToolBarArea, controlwidget_mini);
|
|---|
| 284 |
|
|---|
| 285 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 286 | QStringList controlwidget_mini_actions;
|
|---|
| 287 | controlwidget_mini_actions << "play_or_pause" << "stop" << "separator" << "rewind1" << "timeslider_action"
|
|---|
| 288 | << "forward1" << "separator" << "mute" << "volumeslider_action";
|
|---|
| 289 | controlwidget_mini->setDefaultActions(controlwidget_mini_actions);
|
|---|
| 290 | #else
|
|---|
| 291 | controlwidget_mini->addAction(playOrPauseAct);
|
|---|
| 292 | controlwidget_mini->addAction(stopAct);
|
|---|
| 293 | controlwidget_mini->addSeparator();
|
|---|
| 294 |
|
|---|
| 295 | controlwidget_mini->addAction(rewind1Act);
|
|---|
| 296 |
|
|---|
| 297 | controlwidget_mini->addAction(timeslider_action);
|
|---|
| 298 |
|
|---|
| 299 | controlwidget_mini->addAction(forward1Act);
|
|---|
| 300 |
|
|---|
| 301 | controlwidget_mini->addSeparator();
|
|---|
| 302 |
|
|---|
| 303 | controlwidget_mini->addAction(muteAct );
|
|---|
| 304 |
|
|---|
| 305 | controlwidget_mini->addAction(volumeslider_action);
|
|---|
| 306 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 307 |
|
|---|
| 308 | controlwidget_mini->hide();
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | void DefaultGui::createControlWidget() {
|
|---|
| 312 | qDebug("DefaultGui::createControlWidget");
|
|---|
| 313 |
|
|---|
| 314 | controlwidget = new EditableToolbar( this );
|
|---|
| 315 | controlwidget->setObjectName("controlwidget");
|
|---|
| 316 | //controlwidget->setResizeEnabled(false);
|
|---|
| 317 | controlwidget->setMovable(false);
|
|---|
| 318 | //addDockWindow(controlwidget, Qt::DockBottom );
|
|---|
| 319 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
|---|
| 320 |
|
|---|
| 321 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 322 | QStringList controlwidget_actions;
|
|---|
| 323 | controlwidget_actions << "play" << "pause_and_frame_step" << "stop" << "separator";
|
|---|
| 324 | #if MINI_ARROW_BUTTONS
|
|---|
| 325 | controlwidget_actions << "rewindbutton_action";
|
|---|
| 326 | #else
|
|---|
| 327 | controlwidget_actions << "rewind3" << "rewind2" << "rewind1";
|
|---|
| 328 | #endif
|
|---|
| 329 | controlwidget_actions << "timeslider_action";
|
|---|
| 330 | #if MINI_ARROW_BUTTONS
|
|---|
| 331 | controlwidget_actions << "forwardbutton_action";
|
|---|
| 332 | #else
|
|---|
| 333 | controlwidget_actions << "forward1" << "forward2" << "forward3";
|
|---|
| 334 | #endif
|
|---|
| 335 | controlwidget_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
|---|
| 336 | controlwidget->setDefaultActions(controlwidget_actions);
|
|---|
| 337 | #else
|
|---|
| 338 | controlwidget->addAction(playAct);
|
|---|
| 339 | controlwidget->addAction(pauseAndStepAct);
|
|---|
| 340 | controlwidget->addAction(stopAct);
|
|---|
| 341 |
|
|---|
| 342 | controlwidget->addSeparator();
|
|---|
| 343 |
|
|---|
| 344 | #if MINI_ARROW_BUTTONS
|
|---|
| 345 | controlwidget->addAction( rewindbutton_action );
|
|---|
| 346 | #else
|
|---|
| 347 | controlwidget->addAction(rewind3Act);
|
|---|
| 348 | controlwidget->addAction(rewind2Act);
|
|---|
| 349 | controlwidget->addAction(rewind1Act);
|
|---|
| 350 | #endif
|
|---|
| 351 |
|
|---|
| 352 | controlwidget->addAction(timeslider_action);
|
|---|
| 353 |
|
|---|
| 354 | #if MINI_ARROW_BUTTONS
|
|---|
| 355 | controlwidget->addAction( forwardbutton_action );
|
|---|
| 356 | #else
|
|---|
| 357 | controlwidget->addAction(forward1Act);
|
|---|
| 358 | controlwidget->addAction(forward2Act);
|
|---|
| 359 | controlwidget->addAction(forward3Act);
|
|---|
| 360 | #endif
|
|---|
| 361 |
|
|---|
| 362 | controlwidget->addSeparator();
|
|---|
| 363 |
|
|---|
| 364 | controlwidget->addAction(fullscreenAct);
|
|---|
| 365 | controlwidget->addAction(muteAct);
|
|---|
| 366 |
|
|---|
| 367 | controlwidget->addAction(volumeslider_action);
|
|---|
| 368 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 369 |
|
|---|
| 370 | /*
|
|---|
| 371 | controlwidget->show();
|
|---|
| 372 | */
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | void DefaultGui::createFloatingControl() {
|
|---|
| 376 | // Floating control
|
|---|
| 377 | floating_control = new FloatingWidget(this);
|
|---|
| 378 |
|
|---|
| 379 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 380 | QStringList floatingcontrol_actions;
|
|---|
| 381 | floatingcontrol_actions << "play" << "pause" << "stop" << "separator";
|
|---|
| 382 | #if MINI_ARROW_BUTTONS
|
|---|
| 383 | floatingcontrol_actions << "rewindbutton_action";
|
|---|
| 384 | #else
|
|---|
| 385 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
|---|
| 386 | #endif
|
|---|
| 387 | floatingcontrol_actions << "timeslider_action";
|
|---|
| 388 | #if MINI_ARROW_BUTTONS
|
|---|
| 389 | floatingcontrol_actions << "forwardbutton_action";
|
|---|
| 390 | #else
|
|---|
| 391 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
|---|
| 392 | #endif
|
|---|
| 393 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action" << "separator" << "timelabel_action";
|
|---|
| 394 | floating_control->toolbar()->setDefaultActions(floatingcontrol_actions);
|
|---|
| 395 | #else
|
|---|
| 396 | floating_control->toolbar()->addAction(playAct);
|
|---|
| 397 | floating_control->toolbar()->addAction(pauseAct);
|
|---|
| 398 | floating_control->toolbar()->addAction(stopAct);
|
|---|
| 399 | floating_control->toolbar()->addSeparator();
|
|---|
| 400 |
|
|---|
| 401 | #if MINI_ARROW_BUTTONS
|
|---|
| 402 | floating_control->toolbar()->addAction( rewindbutton_action );
|
|---|
| 403 | #else
|
|---|
| 404 | floating_control->toolbar()->addAction(rewind3Act);
|
|---|
| 405 | floating_control->toolbar()->addAction(rewind2Act);
|
|---|
| 406 | floating_control->toolbar()->addAction(rewind1Act);
|
|---|
| 407 | #endif
|
|---|
| 408 |
|
|---|
| 409 | floating_control->toolbar()->addAction(timeslider_action);
|
|---|
| 410 |
|
|---|
| 411 | #if MINI_ARROW_BUTTONS
|
|---|
| 412 | floating_control->toolbar()->addAction( forwardbutton_action );
|
|---|
| 413 | #else
|
|---|
| 414 | floating_control->toolbar()->addAction(forward1Act);
|
|---|
| 415 | floating_control->toolbar()->addAction(forward2Act);
|
|---|
| 416 | floating_control->toolbar()->addAction(forward3Act);
|
|---|
| 417 | #endif
|
|---|
| 418 |
|
|---|
| 419 | floating_control->toolbar()->addSeparator();
|
|---|
| 420 | floating_control->toolbar()->addAction(fullscreenAct);
|
|---|
| 421 | floating_control->toolbar()->addAction(muteAct);
|
|---|
| 422 | floating_control->toolbar()->addAction(volumeslider_action);
|
|---|
| 423 | floating_control->toolbar()->addSeparator();
|
|---|
| 424 | floating_control->toolbar()->addAction(time_label_action);
|
|---|
| 425 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 426 |
|
|---|
| 427 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
|---|
| 428 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
|---|
| 429 | floating_control->addAction(exitFullscreenAct);
|
|---|
| 430 | floating_control->addAction(exitAct);
|
|---|
| 431 | #endif
|
|---|
| 432 |
|
|---|
| 433 | #if !USE_CONFIGURABLE_TOOLBARS
|
|---|
| 434 | floating_control->adjustSize();
|
|---|
| 435 | #endif
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | void DefaultGui::createStatusBar() {
|
|---|
| 439 | qDebug("DefaultGui::createStatusBar");
|
|---|
| 440 |
|
|---|
| 441 | time_display = new QLabel( statusBar() );
|
|---|
| 442 | time_display->setAlignment(Qt::AlignRight);
|
|---|
| 443 | time_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 444 | time_display->setText(" 88:88:88 / 88:88:88 ");
|
|---|
| 445 | time_display->setMinimumSize(time_display->sizeHint());
|
|---|
| 446 |
|
|---|
| 447 | frame_display = new QLabel( statusBar() );
|
|---|
| 448 | frame_display->setAlignment(Qt::AlignRight);
|
|---|
| 449 | frame_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 450 | frame_display->setText("88888888");
|
|---|
| 451 | frame_display->setMinimumSize(frame_display->sizeHint());
|
|---|
| 452 |
|
|---|
| 453 | ab_section_display = new QLabel( statusBar() );
|
|---|
| 454 | ab_section_display->setAlignment(Qt::AlignRight);
|
|---|
| 455 | ab_section_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 456 | // ab_section_display->setText("A:0:00:00 B:0:00:00");
|
|---|
| 457 | // ab_section_display->setMinimumSize(ab_section_display->sizeHint());
|
|---|
| 458 |
|
|---|
| 459 | video_info_display = new QLabel( statusBar() );
|
|---|
| 460 | video_info_display->setAlignment(Qt::AlignRight);
|
|---|
| 461 | video_info_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 462 |
|
|---|
| 463 | statusBar()->setAutoFillBackground(TRUE);
|
|---|
| 464 |
|
|---|
| 465 | ColorUtils::setBackgroundColor( statusBar(), QColor(0,0,0) );
|
|---|
| 466 | ColorUtils::setForegroundColor( statusBar(), QColor(255,255,255) );
|
|---|
| 467 | ColorUtils::setBackgroundColor( time_display, QColor(0,0,0) );
|
|---|
| 468 | ColorUtils::setForegroundColor( time_display, QColor(255,255,255) );
|
|---|
| 469 | ColorUtils::setBackgroundColor( frame_display, QColor(0,0,0) );
|
|---|
| 470 | ColorUtils::setForegroundColor( frame_display, QColor(255,255,255) );
|
|---|
| 471 | ColorUtils::setBackgroundColor( ab_section_display, QColor(0,0,0) );
|
|---|
| 472 | ColorUtils::setForegroundColor( ab_section_display, QColor(255,255,255) );
|
|---|
| 473 | ColorUtils::setBackgroundColor( video_info_display, QColor(0,0,0) );
|
|---|
| 474 | ColorUtils::setForegroundColor( video_info_display, QColor(255,255,255) );
|
|---|
| 475 | statusBar()->setSizeGripEnabled(FALSE);
|
|---|
| 476 |
|
|---|
| 477 | statusBar()->addPermanentWidget( video_info_display );
|
|---|
| 478 | statusBar()->addPermanentWidget( ab_section_display );
|
|---|
| 479 |
|
|---|
| 480 | statusBar()->showMessage( tr("Welcome to SMPlayer") );
|
|---|
| 481 | statusBar()->addPermanentWidget( frame_display, 0 );
|
|---|
| 482 | frame_display->setText( "0" );
|
|---|
| 483 |
|
|---|
| 484 | statusBar()->addPermanentWidget( time_display, 0 );
|
|---|
| 485 | time_display->setText(" 00:00:00 / 00:00:00 ");
|
|---|
| 486 |
|
|---|
| 487 | time_display->show();
|
|---|
| 488 | frame_display->hide();
|
|---|
| 489 | ab_section_display->show();
|
|---|
| 490 | video_info_display->hide();
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | void DefaultGui::retranslateStrings() {
|
|---|
| 494 | BaseGuiPlus::retranslateStrings();
|
|---|
| 495 |
|
|---|
| 496 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
|---|
| 497 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
|---|
| 498 |
|
|---|
| 499 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
|---|
| 500 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
|---|
| 501 |
|
|---|
| 502 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
|---|
| 503 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
|---|
| 504 |
|
|---|
| 505 | toolbar2->setWindowTitle( tr("&Language toolbar") );
|
|---|
| 506 | toolbar2->toggleViewAction()->setIcon(Images::icon("lang_toolbar"));
|
|---|
| 507 |
|
|---|
| 508 | select_audio->setText( tr("Audio") );
|
|---|
| 509 | select_subtitle->setText( tr("Subtitle") );
|
|---|
| 510 |
|
|---|
| 511 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
|---|
| 512 | viewFrameCounterAct->change( Images::icon("frame_counter"), tr("&Frame counter") );
|
|---|
| 513 |
|
|---|
| 514 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 515 | editToolbar1Act->change( tr("Edit main &toolbar") );
|
|---|
| 516 | editControl1Act->change( tr("Edit &control bar") );
|
|---|
| 517 | editControl2Act->change( tr("Edit m&ini control bar") );
|
|---|
| 518 | editFloatingControlAct->change( tr("Edit &floating control") );
|
|---|
| 519 | #endif
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 523 | void DefaultGui::displayTime(QString text) {
|
|---|
| 524 | time_display->setText( text );
|
|---|
| 525 | time_label_action->setText(text);
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | void DefaultGui::displayFrame(int frame) {
|
|---|
| 529 | if (frame_display->isVisible()) {
|
|---|
| 530 | frame_display->setNum( frame );
|
|---|
| 531 | }
|
|---|
| 532 | }
|
|---|
| 533 |
|
|---|
| 534 | void DefaultGui::displayABSection(int secs_a, int secs_b) {
|
|---|
| 535 | QString s;
|
|---|
| 536 | if (secs_a > -1) s = tr("A:%1").arg(Helper::formatTime(secs_a));
|
|---|
| 537 |
|
|---|
| 538 | if (secs_b > -1) {
|
|---|
| 539 | if (!s.isEmpty()) s += " ";
|
|---|
| 540 | s += tr("B:%1").arg(Helper::formatTime(secs_b));
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | ab_section_display->setText( s );
|
|---|
| 544 |
|
|---|
| 545 | ab_section_display->setShown( !s.isEmpty() );
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | void DefaultGui::displayVideoInfo(int width, int height, double fps) {
|
|---|
| 549 | video_info_display->setText(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 552 | void DefaultGui::updateWidgets() {
|
|---|
| 553 | qDebug("DefaultGui::updateWidgets");
|
|---|
| 554 |
|
|---|
| 555 | BaseGuiPlus::updateWidgets();
|
|---|
| 556 |
|
|---|
| 557 | panel->setFocus();
|
|---|
| 558 | }
|
|---|
| 559 |
|
|---|
| 560 | void DefaultGui::aboutToEnterFullscreen() {
|
|---|
| 561 | qDebug("DefaultGui::aboutToEnterFullscreen");
|
|---|
| 562 |
|
|---|
| 563 | BaseGuiPlus::aboutToEnterFullscreen();
|
|---|
| 564 |
|
|---|
| 565 | // Save visibility of toolbars
|
|---|
| 566 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
|---|
| 567 | fullscreen_toolbar2_was_visible = toolbar2->isVisible();
|
|---|
| 568 |
|
|---|
| 569 | if (!pref->compact_mode) {
|
|---|
| 570 | //menuBar()->hide();
|
|---|
| 571 | //statusBar()->hide();
|
|---|
| 572 | controlwidget->hide();
|
|---|
| 573 | controlwidget_mini->hide();
|
|---|
| 574 | toolbar1->hide();
|
|---|
| 575 | toolbar2->hide();
|
|---|
| 576 | }
|
|---|
| 577 | }
|
|---|
| 578 |
|
|---|
| 579 | void DefaultGui::aboutToExitFullscreen() {
|
|---|
| 580 | qDebug("DefaultGui::aboutToExitFullscreen");
|
|---|
| 581 |
|
|---|
| 582 | BaseGuiPlus::aboutToExitFullscreen();
|
|---|
| 583 |
|
|---|
| 584 | floating_control->hide();
|
|---|
| 585 |
|
|---|
| 586 | if (!pref->compact_mode) {
|
|---|
| 587 | //menuBar()->show();
|
|---|
| 588 | //statusBar()->show();
|
|---|
| 589 | controlwidget->show();
|
|---|
| 590 |
|
|---|
| 591 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
|---|
| 592 | toolbar2->setVisible( fullscreen_toolbar2_was_visible );
|
|---|
| 593 | }
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | void DefaultGui::aboutToEnterCompactMode() {
|
|---|
| 597 |
|
|---|
| 598 | BaseGuiPlus::aboutToEnterCompactMode();
|
|---|
| 599 |
|
|---|
| 600 | // Save visibility of toolbars
|
|---|
| 601 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
|---|
| 602 | compact_toolbar2_was_visible = toolbar2->isVisible();
|
|---|
| 603 |
|
|---|
| 604 | //menuBar()->hide();
|
|---|
| 605 | //statusBar()->hide();
|
|---|
| 606 | controlwidget->hide();
|
|---|
| 607 | controlwidget_mini->hide();
|
|---|
| 608 | toolbar1->hide();
|
|---|
| 609 | toolbar2->hide();
|
|---|
| 610 | }
|
|---|
| 611 |
|
|---|
| 612 | void DefaultGui::aboutToExitCompactMode() {
|
|---|
| 613 | BaseGuiPlus::aboutToExitCompactMode();
|
|---|
| 614 |
|
|---|
| 615 | //menuBar()->show();
|
|---|
| 616 | //statusBar()->show();
|
|---|
| 617 | controlwidget->show();
|
|---|
| 618 |
|
|---|
| 619 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
|---|
| 620 | toolbar2->setVisible( compact_toolbar2_was_visible );
|
|---|
| 621 |
|
|---|
| 622 | // Recheck size of controlwidget
|
|---|
| 623 | resizeEvent( new QResizeEvent( size(), size() ) );
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | void DefaultGui::showFloatingControl(QPoint /*p*/) {
|
|---|
| 627 | qDebug("DefaultGui::showFloatingControl");
|
|---|
| 628 |
|
|---|
| 629 | #if CONTROLWIDGET_OVER_VIDEO
|
|---|
| 630 | if ((pref->compact_mode) && (!pref->fullscreen)) {
|
|---|
| 631 | floating_control->setAnimated( false );
|
|---|
| 632 | } else {
|
|---|
| 633 | floating_control->setAnimated( pref->floating_control_animated );
|
|---|
| 634 | }
|
|---|
| 635 | floating_control->setMargin(pref->floating_control_margin);
|
|---|
| 636 | #ifndef Q_OS_WIN
|
|---|
| 637 | floating_control->setBypassWindowManager(pref->bypass_window_manager);
|
|---|
| 638 | #endif
|
|---|
| 639 | floating_control->showOver(panel, pref->floating_control_width);
|
|---|
| 640 | #else
|
|---|
| 641 | if (!controlwidget->isVisible()) {
|
|---|
| 642 | controlwidget->show();
|
|---|
| 643 | }
|
|---|
| 644 | #endif
|
|---|
| 645 | }
|
|---|
| 646 |
|
|---|
| 647 | void DefaultGui::showFloatingMenu(QPoint /*p*/) {
|
|---|
| 648 | #if !CONTROLWIDGET_OVER_VIDEO
|
|---|
| 649 | qDebug("DefaultGui::showFloatingMenu");
|
|---|
| 650 |
|
|---|
| 651 | if (!menuBar()->isVisible())
|
|---|
| 652 | menuBar()->show();
|
|---|
| 653 | #endif
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | void DefaultGui::hideFloatingControls() {
|
|---|
| 657 | qDebug("DefaultGui::hideFloatingControls");
|
|---|
| 658 |
|
|---|
| 659 | #if CONTROLWIDGET_OVER_VIDEO
|
|---|
| 660 | floating_control->hide();
|
|---|
| 661 | #else
|
|---|
| 662 | if (controlwidget->isVisible())
|
|---|
| 663 | controlwidget->hide();
|
|---|
| 664 |
|
|---|
| 665 | if (menuBar()->isVisible())
|
|---|
| 666 | menuBar()->hide();
|
|---|
| 667 | #endif
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | void DefaultGui::resizeEvent( QResizeEvent * ) {
|
|---|
| 671 | /*
|
|---|
| 672 | qDebug("defaultGui::resizeEvent");
|
|---|
| 673 | qDebug(" controlwidget width: %d", controlwidget->width() );
|
|---|
| 674 | qDebug(" controlwidget_mini width: %d", controlwidget_mini->width() );
|
|---|
| 675 | */
|
|---|
| 676 |
|
|---|
| 677 | #if QT_VERSION < 0x040000
|
|---|
| 678 | #define LIMIT 470
|
|---|
| 679 | #else
|
|---|
| 680 | #define LIMIT 570
|
|---|
| 681 | #endif
|
|---|
| 682 |
|
|---|
| 683 | if ( (controlwidget->isVisible()) && (width() < LIMIT) ) {
|
|---|
| 684 | controlwidget->hide();
|
|---|
| 685 | controlwidget_mini->show();
|
|---|
| 686 | }
|
|---|
| 687 | else
|
|---|
| 688 | if ( (controlwidget_mini->isVisible()) && (width() > LIMIT) ) {
|
|---|
| 689 | controlwidget_mini->hide();
|
|---|
| 690 | controlwidget->show();
|
|---|
| 691 | }
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | #if USE_MINIMUMSIZE
|
|---|
| 695 | QSize DefaultGui::minimumSizeHint() const {
|
|---|
| 696 | return QSize(controlwidget_mini->sizeHint().width(), 0);
|
|---|
| 697 | }
|
|---|
| 698 | #endif
|
|---|
| 699 |
|
|---|
| 700 |
|
|---|
| 701 | void DefaultGui::saveConfig() {
|
|---|
| 702 | qDebug("DefaultGui::saveConfig");
|
|---|
| 703 |
|
|---|
| 704 | QSettings * set = settings;
|
|---|
| 705 |
|
|---|
| 706 | set->beginGroup( "default_gui");
|
|---|
| 707 |
|
|---|
| 708 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
|---|
| 709 | set->setValue("frame_counter", viewFrameCounterAct->isChecked());
|
|---|
| 710 |
|
|---|
| 711 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
|---|
| 712 | set->setValue("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible);
|
|---|
| 713 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
|---|
| 714 | set->setValue("compact_toolbar2_was_visible", compact_toolbar2_was_visible);
|
|---|
| 715 |
|
|---|
| 716 | if (pref->save_window_size_on_exit) {
|
|---|
| 717 | qDebug("DefaultGui::saveConfig: w: %d h: %d", width(), height());
|
|---|
| 718 | set->setValue( "pos", pos() );
|
|---|
| 719 | set->setValue( "size", size() );
|
|---|
| 720 | }
|
|---|
| 721 |
|
|---|
| 722 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
|---|
| 723 |
|
|---|
| 724 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 725 | set->beginGroup( "actions" );
|
|---|
| 726 | set->setValue("toolbar1", toolbar1->actionsToStringList() );
|
|---|
| 727 | set->setValue("controlwidget", controlwidget->actionsToStringList() );
|
|---|
| 728 | set->setValue("controlwidget_mini", controlwidget_mini->actionsToStringList() );
|
|---|
| 729 | set->setValue("floating_control", floating_control->toolbar()->actionsToStringList() );
|
|---|
| 730 | set->setValue("toolbar1_version", TOOLBAR_VERSION);
|
|---|
| 731 | set->endGroup();
|
|---|
| 732 | #endif
|
|---|
| 733 |
|
|---|
| 734 | set->endGroup();
|
|---|
| 735 | }
|
|---|
| 736 |
|
|---|
| 737 | void DefaultGui::loadConfig() {
|
|---|
| 738 | qDebug("DefaultGui::loadConfig");
|
|---|
| 739 |
|
|---|
| 740 | QSettings * set = settings;
|
|---|
| 741 |
|
|---|
| 742 | set->beginGroup( "default_gui");
|
|---|
| 743 |
|
|---|
| 744 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
|---|
| 745 | viewFrameCounterAct->setChecked(set->value("frame_counter", false).toBool());
|
|---|
| 746 |
|
|---|
| 747 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
|---|
| 748 | fullscreen_toolbar2_was_visible = set->value("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible).toBool();
|
|---|
| 749 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
|---|
| 750 | compact_toolbar2_was_visible = set->value("compact_toolbar2_was_visible", compact_toolbar2_was_visible).toBool();
|
|---|
| 751 |
|
|---|
| 752 | if (pref->save_window_size_on_exit) {
|
|---|
| 753 | QPoint p = set->value("pos", pos()).toPoint();
|
|---|
| 754 | QSize s = set->value("size", size()).toSize();
|
|---|
| 755 |
|
|---|
| 756 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
|---|
| 757 | s = pref->default_size;
|
|---|
| 758 | }
|
|---|
| 759 |
|
|---|
| 760 | move(p);
|
|---|
| 761 | resize(s);
|
|---|
| 762 |
|
|---|
| 763 | if (!DesktopInfo::isInsideScreen(this)) {
|
|---|
| 764 | move(0,0);
|
|---|
| 765 | qWarning("DefaultGui::loadConfig: window is outside of the screen, moved to 0x0");
|
|---|
| 766 | }
|
|---|
| 767 | }
|
|---|
| 768 |
|
|---|
| 769 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 770 | set->beginGroup( "actions" );
|
|---|
| 771 | int toolbar_version = set->value("toolbar1_version", 0).toInt();
|
|---|
| 772 | if (toolbar_version >= TOOLBAR_VERSION) {
|
|---|
| 773 | toolbar1->setActionsFromStringList( set->value("toolbar1", toolbar1->defaultActions()).toStringList() );
|
|---|
| 774 | } else {
|
|---|
| 775 | qDebug("DefaultGui::loadConfig: toolbar too old, loading default one");
|
|---|
| 776 | toolbar1->setActionsFromStringList( toolbar1->defaultActions() );
|
|---|
| 777 | }
|
|---|
| 778 | controlwidget->setActionsFromStringList( set->value("controlwidget", controlwidget->defaultActions()).toStringList() );
|
|---|
| 779 | controlwidget_mini->setActionsFromStringList( set->value("controlwidget_mini", controlwidget_mini->defaultActions()).toStringList() );
|
|---|
| 780 | floating_control->toolbar()->setActionsFromStringList( set->value("floating_control", floating_control->toolbar()->defaultActions()).toStringList() );
|
|---|
| 781 | floating_control->adjustSize();
|
|---|
| 782 | set->endGroup();
|
|---|
| 783 | #endif
|
|---|
| 784 |
|
|---|
| 785 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
|---|
| 786 |
|
|---|
| 787 | #if DOCK_PLAYLIST
|
|---|
| 788 | qDebug("DefaultGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
|---|
| 789 | qDebug("DefaultGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
|---|
| 790 | qDebug("DefaultGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
|---|
| 791 | #endif
|
|---|
| 792 |
|
|---|
| 793 | set->endGroup();
|
|---|
| 794 |
|
|---|
| 795 | updateWidgets();
|
|---|
| 796 | }
|
|---|
| 797 |
|
|---|
| 798 | #include "moc_defaultgui.cpp"
|
|---|