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