| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #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 "autohidewidget.h"
|
|---|
| 30 | #include "desktopinfo.h"
|
|---|
| 31 | #include "editabletoolbar.h"
|
|---|
| 32 |
|
|---|
| 33 | #if !USE_CONFIGURABLE_TOOLBARS
|
|---|
| 34 | #include "favorites.h"
|
|---|
| 35 | #endif
|
|---|
| 36 |
|
|---|
| 37 | #if DOCK_PLAYLIST
|
|---|
| 38 | #include "playlistdock.h"
|
|---|
| 39 | #endif
|
|---|
| 40 |
|
|---|
| 41 | #ifdef BUFFERING_ANIMATION
|
|---|
| 42 | #include "statewidget.h"
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | #include <QMenu>
|
|---|
| 46 | #include <QSettings>
|
|---|
| 47 | #include <QLabel>
|
|---|
| 48 | #include <QStatusBar>
|
|---|
| 49 | #include <QPushButton>
|
|---|
| 50 | #include <QToolButton>
|
|---|
| 51 | #include <QMenuBar>
|
|---|
| 52 | #include <QMovie>
|
|---|
| 53 |
|
|---|
| 54 | #define TOOLBAR_VERSION 2
|
|---|
| 55 | #define CONTROLWIDGET_VERSION 0
|
|---|
| 56 | #define FLOATING_CONTROL_VERSION 1
|
|---|
| 57 |
|
|---|
| 58 | using namespace Global;
|
|---|
| 59 |
|
|---|
| 60 | DefaultGui::DefaultGui( QWidget * parent, Qt::WindowFlags flags )
|
|---|
| 61 | : BaseGuiPlus( parent, flags )
|
|---|
| 62 | {
|
|---|
| 63 | createStatusBar();
|
|---|
| 64 |
|
|---|
| 65 | connect( this, SIGNAL(frameChanged(int)),
|
|---|
| 66 | this, SLOT(displayFrame(int)) );
|
|---|
| 67 | connect( this, SIGNAL(ABMarkersChanged(int,int)),
|
|---|
| 68 | this, SLOT(displayABSection(int,int)) );
|
|---|
| 69 | connect( this, SIGNAL(videoInfoChanged(int,int,double)),
|
|---|
| 70 | this, SLOT(displayVideoInfo(int,int,double)) );
|
|---|
| 71 |
|
|---|
| 72 | createActions();
|
|---|
| 73 | createMainToolBars();
|
|---|
| 74 | createControlWidget();
|
|---|
| 75 | createControlWidgetMini();
|
|---|
| 76 | createFloatingControl();
|
|---|
| 77 | createMenus();
|
|---|
| 78 |
|
|---|
| 79 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 80 | connect( editToolbar1Act, SIGNAL(triggered()),
|
|---|
| 81 | toolbar1, SLOT(edit()) );
|
|---|
| 82 | connect( editControl1Act, SIGNAL(triggered()),
|
|---|
| 83 | controlwidget, SLOT(edit()) );
|
|---|
| 84 | connect( editControl2Act, SIGNAL(triggered()),
|
|---|
| 85 | controlwidget_mini, SLOT(edit()) );
|
|---|
| 86 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
|---|
| 87 | iw->takeAvailableActionsFrom(this);
|
|---|
| 88 | connect( editFloatingControlAct, SIGNAL(triggered()),
|
|---|
| 89 | iw, SLOT(edit()) );
|
|---|
| 90 | #endif
|
|---|
| 91 |
|
|---|
| 92 | connect(this, SIGNAL(preferencesChanged()), this, SLOT(checkCompactMode()));
|
|---|
| 93 |
|
|---|
| 94 | menuBar()->setObjectName("menubar");
|
|---|
| 95 |
|
|---|
| 96 | retranslateStrings();
|
|---|
| 97 |
|
|---|
| 98 | loadConfig();
|
|---|
| 99 |
|
|---|
| 100 | //if (playlist_visible) showPlaylist(true);
|
|---|
| 101 |
|
|---|
| 102 | if (pref->compact_mode) {
|
|---|
| 103 | controlwidget->hide();
|
|---|
| 104 | toolbar1->hide();
|
|---|
| 105 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 106 | toolbar2->hide();
|
|---|
| 107 | #endif
|
|---|
| 108 |
|
|---|
| 109 | if (pref->floating_display_in_compact_mode) {
|
|---|
| 110 | reconfigureFloatingControl();
|
|---|
| 111 | floating_control->activate();
|
|---|
| 112 | }
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | applyStyles();
|
|---|
| 116 |
|
|---|
| 117 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 118 | connect(this, SIGNAL(tabletModeChanged(bool)), this, SLOT(adaptForTabletMode()));
|
|---|
| 119 | adaptForTabletMode();
|
|---|
| 120 | #endif
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | DefaultGui::~DefaultGui() {
|
|---|
| 124 | qDebug("DefaultGui::~DefaultGui");
|
|---|
| 125 | saveConfig();
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | /*
|
|---|
| 129 | void DefaultGui::closeEvent( QCloseEvent * ) {
|
|---|
| 130 | qDebug("DefaultGui::closeEvent");
|
|---|
| 131 |
|
|---|
| 132 | //BaseGuiPlus::closeEvent(e);
|
|---|
| 133 | qDebug("w: %d h: %d", width(), height() );
|
|---|
| 134 | }
|
|---|
| 135 | */
|
|---|
| 136 |
|
|---|
| 137 | void DefaultGui::createActions() {
|
|---|
| 138 | qDebug("DefaultGui::createActions");
|
|---|
| 139 |
|
|---|
| 140 | timeslider_action = createTimeSliderAction(this);
|
|---|
| 141 | volumeslider_action = createVolumeSliderAction(this);
|
|---|
| 142 |
|
|---|
| 143 | #if AUTODISABLE_ACTIONS
|
|---|
| 144 | timeslider_action->disable();
|
|---|
| 145 | volumeslider_action->disable();
|
|---|
| 146 | #endif
|
|---|
| 147 |
|
|---|
| 148 | // Create the time label
|
|---|
| 149 | time_label_action = createTimeLabelAction(TimeLabelAction::CurrentAndTotalTime, this);
|
|---|
| 150 | time_label_action->setObjectName("timelabel_action");
|
|---|
| 151 |
|
|---|
| 152 | current_time_label_action = createTimeLabelAction(TimeLabelAction::CurrentTime, this);
|
|---|
| 153 | current_time_label_action->setObjectName("current_timelabel_action");
|
|---|
| 154 |
|
|---|
| 155 | total_time_label_action = createTimeLabelAction(TimeLabelAction::TotalTime, this);
|
|---|
| 156 | total_time_label_action->setObjectName("total_timelabel_action");
|
|---|
| 157 |
|
|---|
| 158 | remaining_time_label_action = createTimeLabelAction(TimeLabelAction::RemainingTime, this);
|
|---|
| 159 | remaining_time_label_action->setObjectName("remaining_timelabel_action");
|
|---|
| 160 |
|
|---|
| 161 | #if MINI_ARROW_BUTTONS
|
|---|
| 162 | QList<QAction*> rewind_actions;
|
|---|
| 163 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
|---|
| 164 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
|---|
| 165 | rewindbutton_action->setObjectName("rewindbutton_action");
|
|---|
| 166 |
|
|---|
| 167 | QList<QAction*> forward_actions;
|
|---|
| 168 | forward_actions << forward1Act << forward2Act << forward3Act;
|
|---|
| 169 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
|---|
| 170 | forwardbutton_action->setObjectName("forwardbutton_action");
|
|---|
| 171 | #endif
|
|---|
| 172 |
|
|---|
| 173 | // Statusbar
|
|---|
| 174 | viewVideoInfoAct = new MyAction(this, "toggle_video_info" );
|
|---|
| 175 | viewVideoInfoAct->setCheckable(true);
|
|---|
| 176 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
|---|
| 177 | video_info_display, SLOT(setVisible(bool)) );
|
|---|
| 178 |
|
|---|
| 179 | viewFrameCounterAct = new MyAction( this, "toggle_frame_counter" );
|
|---|
| 180 | viewFrameCounterAct->setCheckable( true );
|
|---|
| 181 | connect( viewFrameCounterAct, SIGNAL(toggled(bool)),
|
|---|
| 182 | frame_display, SLOT(setVisible(bool)) );
|
|---|
| 183 |
|
|---|
| 184 | viewFormatInfoAct = new MyAction( this, "toggle_format_info" );
|
|---|
| 185 | viewFormatInfoAct->setCheckable( true );
|
|---|
| 186 | connect( viewFormatInfoAct, SIGNAL(toggled(bool)),
|
|---|
| 187 | format_info_display, SLOT(setVisible(bool)) );
|
|---|
| 188 |
|
|---|
| 189 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 190 | editToolbar1Act = new MyAction( this, "edit_main_toolbar" );
|
|---|
| 191 | editControl1Act = new MyAction( this, "edit_control1" );
|
|---|
| 192 | editControl2Act = new MyAction( this, "edit_control2" );
|
|---|
| 193 | editFloatingControlAct = new MyAction( this, "edit_floating_control" );
|
|---|
| 194 | #endif
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | #if AUTODISABLE_ACTIONS
|
|---|
| 198 | void DefaultGui::enableActionsOnPlaying() {
|
|---|
| 199 | qDebug("DefaultGui::enableActionsOnPlaying");
|
|---|
| 200 | BaseGuiPlus::enableActionsOnPlaying();
|
|---|
| 201 |
|
|---|
| 202 | timeslider_action->enable();
|
|---|
| 203 | volumeslider_action->enable();
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | void DefaultGui::disableActionsOnStop() {
|
|---|
| 207 | qDebug("DefaultGui::disableActionsOnStop");
|
|---|
| 208 | BaseGuiPlus::disableActionsOnStop();
|
|---|
| 209 |
|
|---|
| 210 | timeslider_action->disable();
|
|---|
| 211 | volumeslider_action->disable();
|
|---|
| 212 | }
|
|---|
| 213 | #endif // AUTODISABLE_ACTIONS
|
|---|
| 214 |
|
|---|
| 215 | void DefaultGui::togglePlayAction(Core::State state) {
|
|---|
| 216 | qDebug("DefaultGui::togglePlayAction");
|
|---|
| 217 | BaseGui::togglePlayAction(state);
|
|---|
| 218 |
|
|---|
| 219 | if (state == Core::Playing) {
|
|---|
| 220 | playOrPauseAct->setIcon(Images::icon("pause"));
|
|---|
| 221 | } else {
|
|---|
| 222 | playOrPauseAct->setIcon(Images::icon("play"));
|
|---|
| 223 | }
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | void DefaultGui::createMenus() {
|
|---|
| 227 | toolbar_menu = new QMenu(this);
|
|---|
| 228 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
|---|
| 229 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 230 | toolbar_menu->addAction(toolbar2->toggleViewAction());
|
|---|
| 231 | #endif
|
|---|
| 232 |
|
|---|
| 233 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 234 | toolbar_menu->addSeparator();
|
|---|
| 235 | toolbar_menu->addAction(editToolbar1Act);
|
|---|
| 236 | toolbar_menu->addAction(editControl1Act);
|
|---|
| 237 | toolbar_menu->addAction(editControl2Act);
|
|---|
| 238 | toolbar_menu->addAction(editFloatingControlAct);
|
|---|
| 239 | #endif
|
|---|
| 240 |
|
|---|
| 241 | statusbar_menu = new QMenu(this);
|
|---|
| 242 | statusbar_menu->addAction(viewVideoInfoAct);
|
|---|
| 243 | statusbar_menu->addAction(viewFormatInfoAct);
|
|---|
| 244 | statusbar_menu->addAction(viewFrameCounterAct);
|
|---|
| 245 |
|
|---|
| 246 | populateMainMenu();
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | void DefaultGui::populateMainMenu() {
|
|---|
| 250 | qDebug("DefaultGui::populateMainMenu");
|
|---|
| 251 |
|
|---|
| 252 | BaseGuiPlus::populateMainMenu();
|
|---|
| 253 |
|
|---|
| 254 | optionsMenu->addSeparator();
|
|---|
| 255 | optionsMenu->addMenu(toolbar_menu);
|
|---|
| 256 | optionsMenu->addMenu(statusbar_menu);
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | QMenu * DefaultGui::createPopupMenu() {
|
|---|
| 260 | QMenu * m = new QMenu(this);
|
|---|
| 261 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 262 | m->addAction(editToolbar1Act);
|
|---|
| 263 | m->addAction(editControl1Act);
|
|---|
| 264 | m->addAction(editControl2Act);
|
|---|
| 265 | m->addAction(editFloatingControlAct);
|
|---|
| 266 | #else
|
|---|
| 267 | m->addAction(toolbar1->toggleViewAction());
|
|---|
| 268 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 269 | m->addAction(toolbar2->toggleViewAction());
|
|---|
| 270 | #endif
|
|---|
| 271 | #endif
|
|---|
| 272 | return m;
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | void DefaultGui::createMainToolBars() {
|
|---|
| 276 | toolbar1 = new EditableToolbar( this );
|
|---|
| 277 | toolbar1->setObjectName("toolbar1");
|
|---|
| 278 | //toolbar1->setMovable(false);
|
|---|
| 279 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
|---|
| 280 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 281 | QStringList toolbar1_actions;
|
|---|
| 282 | toolbar1_actions << "open_file" << "open_url" << "favorites_menu" << "separator"
|
|---|
| 283 | << "screenshot" << "separator" << "show_file_properties" << "show_playlist"
|
|---|
| 284 | #ifndef IDOPT_BUILD
|
|---|
| 285 | << "show_tube_browser"
|
|---|
| 286 | #endif
|
|---|
| 287 | << "separator" << "show_preferences"
|
|---|
| 288 | #ifndef IDOPT_BUILD
|
|---|
| 289 | << "separator" << "play_prev" << "play_next"
|
|---|
| 290 | #endif
|
|---|
| 291 | << "separator" << "audiotrack_menu" << "subtitlestrack_menu"
|
|---|
| 292 | #ifdef IDOPT_BUILD
|
|---|
| 293 | << "separator" << "send_to_screen_menu" << "tablet_mode"
|
|---|
| 294 | #endif
|
|---|
| 295 | ;
|
|---|
| 296 |
|
|---|
| 297 | toolbar1->setDefaultActions(toolbar1_actions);
|
|---|
| 298 | #else
|
|---|
| 299 | toolbar1->addAction(openFileAct);
|
|---|
| 300 | /* toolbar1->addAction(openDVDAct); */
|
|---|
| 301 | toolbar1->addAction(openURLAct);
|
|---|
| 302 | toolbar1->addAction(favorites->menuAction());
|
|---|
| 303 | toolbar1->addSeparator();
|
|---|
| 304 | /*
|
|---|
| 305 | toolbar1->addAction(compactAct);
|
|---|
| 306 | toolbar1->addAction(fullscreenAct);
|
|---|
| 307 | toolbar1->addSeparator();
|
|---|
| 308 | */
|
|---|
| 309 | toolbar1->addAction(screenshotAct);
|
|---|
| 310 | toolbar1->addSeparator();
|
|---|
| 311 | toolbar1->addAction(showPropertiesAct);
|
|---|
| 312 | toolbar1->addAction(showPlaylistAct);
|
|---|
| 313 | toolbar1->addAction(showPreferencesAct);
|
|---|
| 314 | toolbar1->addSeparator();
|
|---|
| 315 | toolbar1->addAction(playPrevAct);
|
|---|
| 316 | toolbar1->addAction(playNextAct);
|
|---|
| 317 | toolbar1->addSeparator();
|
|---|
| 318 | toolbar1->addAction(audiotrack_menu->menuAction());
|
|---|
| 319 | toolbar1->addAction(subtitles_track_menu->menuAction());
|
|---|
| 320 |
|
|---|
| 321 | // Test:
|
|---|
| 322 | //toolbar1->addSeparator();
|
|---|
| 323 | //toolbar1->addAction(timeslider_action);
|
|---|
| 324 | //toolbar1->addAction(volumeslider_action);
|
|---|
| 325 |
|
|---|
| 326 | QToolButton * button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(favorites->menuAction()));
|
|---|
| 327 | button->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 328 |
|
|---|
| 329 | button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(audiotrack_menu->menuAction()));
|
|---|
| 330 | button->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 331 |
|
|---|
| 332 | button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(subtitles_track_menu->menuAction()));
|
|---|
| 333 | button->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 334 |
|
|---|
| 335 | #ifdef IDOPT_BUILD
|
|---|
| 336 | toolbar1->addSeparator();
|
|---|
| 337 | toolbar1->addAction(sendToScreen_menu->menuAction());
|
|---|
| 338 | toolbar1->addAction(tabletModeAct);
|
|---|
| 339 |
|
|---|
| 340 | button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(sendToScreen_menu->menuAction()));
|
|---|
| 341 | button->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 342 | #endif
|
|---|
| 343 | #endif
|
|---|
| 344 |
|
|---|
| 345 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 346 | toolbar2 = new QToolBar( this );
|
|---|
| 347 | toolbar2->setObjectName("toolbar2");
|
|---|
| 348 | //toolbar2->setMovable(false);
|
|---|
| 349 | addToolBar(Qt::TopToolBarArea, toolbar2);
|
|---|
| 350 |
|
|---|
| 351 | select_audio = new QPushButton( this );
|
|---|
| 352 | select_audio->setMenu( audiotrack_menu );
|
|---|
| 353 | toolbar2->addWidget(select_audio);
|
|---|
| 354 |
|
|---|
| 355 | select_subtitle = new QPushButton( this );
|
|---|
| 356 | select_subtitle->setMenu( subtitles_track_menu );
|
|---|
| 357 | toolbar2->addWidget(select_subtitle);
|
|---|
| 358 | #endif
|
|---|
| 359 |
|
|---|
| 360 | /*
|
|---|
| 361 | toolbar1->show();
|
|---|
| 362 | toolbar2->show();
|
|---|
| 363 | */
|
|---|
| 364 |
|
|---|
| 365 | // Modify toolbars' actions
|
|---|
| 366 | QAction *tba;
|
|---|
| 367 | tba = toolbar1->toggleViewAction();
|
|---|
| 368 | tba->setObjectName("show_main_toolbar");
|
|---|
| 369 | tba->setShortcut(Qt::Key_F5);
|
|---|
| 370 |
|
|---|
| 371 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 372 | tba = toolbar2->toggleViewAction();
|
|---|
| 373 | tba->setObjectName("show_language_toolbar");
|
|---|
| 374 | tba->setShortcut(Qt::Key_F6);
|
|---|
| 375 | #endif
|
|---|
| 376 |
|
|---|
| 377 | toolbar1->setIconSize(QSize(32,32));
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 | void DefaultGui::createControlWidgetMini() {
|
|---|
| 382 | qDebug("DefaultGui::createControlWidgetMini");
|
|---|
| 383 |
|
|---|
| 384 | controlwidget_mini = new EditableToolbar( this );
|
|---|
| 385 | controlwidget_mini->setObjectName("controlwidget_mini");
|
|---|
| 386 | controlwidget_mini->setLayoutDirection(Qt::LeftToRight);
|
|---|
| 387 | //controlwidget_mini->setResizeEnabled(false);
|
|---|
| 388 | controlwidget_mini->setMovable(false);
|
|---|
| 389 | //addDockWindow(controlwidget_mini, Qt::DockBottom );
|
|---|
| 390 | addToolBar(Qt::BottomToolBarArea, controlwidget_mini);
|
|---|
| 391 |
|
|---|
| 392 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 393 | QStringList controlwidget_mini_actions;
|
|---|
| 394 | controlwidget_mini_actions << "play_or_pause" << "stop" << "separator" << "rewind1" << "timeslider_action"
|
|---|
| 395 | << "forward1" << "separator" << "mute" << "volumeslider_action";
|
|---|
| 396 | controlwidget_mini->setDefaultActions(controlwidget_mini_actions);
|
|---|
| 397 | #else
|
|---|
| 398 | controlwidget_mini->addAction(playOrPauseAct);
|
|---|
| 399 | controlwidget_mini->addAction(stopAct);
|
|---|
| 400 | controlwidget_mini->addSeparator();
|
|---|
| 401 |
|
|---|
| 402 | controlwidget_mini->addAction(rewind1Act);
|
|---|
| 403 |
|
|---|
| 404 | controlwidget_mini->addAction(timeslider_action);
|
|---|
| 405 |
|
|---|
| 406 | controlwidget_mini->addAction(forward1Act);
|
|---|
| 407 |
|
|---|
| 408 | controlwidget_mini->addSeparator();
|
|---|
| 409 |
|
|---|
| 410 | controlwidget_mini->addAction(muteAct );
|
|---|
| 411 |
|
|---|
| 412 | controlwidget_mini->addAction(volumeslider_action);
|
|---|
| 413 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 414 |
|
|---|
| 415 | controlwidget_mini->hide();
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | void DefaultGui::createControlWidget() {
|
|---|
| 419 | qDebug("DefaultGui::createControlWidget");
|
|---|
| 420 |
|
|---|
| 421 | controlwidget = new EditableToolbar( this );
|
|---|
| 422 | controlwidget->setObjectName("controlwidget");
|
|---|
| 423 | controlwidget->setLayoutDirection(Qt::LeftToRight);
|
|---|
| 424 | //controlwidget->setResizeEnabled(false);
|
|---|
| 425 | controlwidget->setMovable(false);
|
|---|
| 426 | //addDockWindow(controlwidget, Qt::DockBottom );
|
|---|
| 427 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
|---|
| 428 |
|
|---|
| 429 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 430 | QStringList controlwidget_actions;
|
|---|
| 431 | controlwidget_actions << "play_or_pause" << "stop" << "separator";
|
|---|
| 432 | #if MINI_ARROW_BUTTONS
|
|---|
| 433 | controlwidget_actions << "rewindbutton_action";
|
|---|
| 434 | #else
|
|---|
| 435 | controlwidget_actions << "rewind3" << "rewind2" << "rewind1";
|
|---|
| 436 | #endif
|
|---|
| 437 | controlwidget_actions << "timeslider_action";
|
|---|
| 438 | #if MINI_ARROW_BUTTONS
|
|---|
| 439 | controlwidget_actions << "forwardbutton_action";
|
|---|
| 440 | #else
|
|---|
| 441 | controlwidget_actions << "forward1" << "forward2" << "forward3";
|
|---|
| 442 | #endif
|
|---|
| 443 | controlwidget_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
|---|
| 444 |
|
|---|
| 445 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 446 | controlwidget_actions << "quick_access_menu";
|
|---|
| 447 | #endif
|
|---|
| 448 |
|
|---|
| 449 | controlwidget->setDefaultActions(controlwidget_actions);
|
|---|
| 450 | #else
|
|---|
| 451 | /*
|
|---|
| 452 | controlwidget->addAction(playAct);
|
|---|
| 453 | controlwidget->addAction(pauseAndStepAct);
|
|---|
| 454 | */
|
|---|
| 455 | controlwidget->addAction(playOrPauseAct);
|
|---|
| 456 | controlwidget->addAction(stopAct);
|
|---|
| 457 |
|
|---|
| 458 | controlwidget->addSeparator();
|
|---|
| 459 |
|
|---|
| 460 | #if MINI_ARROW_BUTTONS
|
|---|
| 461 | controlwidget->addAction( rewindbutton_action );
|
|---|
| 462 | #else
|
|---|
| 463 | controlwidget->addAction(rewind3Act);
|
|---|
| 464 | controlwidget->addAction(rewind2Act);
|
|---|
| 465 | controlwidget->addAction(rewind1Act);
|
|---|
| 466 | #endif
|
|---|
| 467 |
|
|---|
| 468 | controlwidget->addAction(timeslider_action);
|
|---|
| 469 |
|
|---|
| 470 | #if MINI_ARROW_BUTTONS
|
|---|
| 471 | controlwidget->addAction( forwardbutton_action );
|
|---|
| 472 | #else
|
|---|
| 473 | controlwidget->addAction(forward1Act);
|
|---|
| 474 | controlwidget->addAction(forward2Act);
|
|---|
| 475 | controlwidget->addAction(forward3Act);
|
|---|
| 476 | #endif
|
|---|
| 477 |
|
|---|
| 478 | controlwidget->addSeparator();
|
|---|
| 479 |
|
|---|
| 480 | controlwidget->addAction(fullscreenAct);
|
|---|
| 481 | controlwidget->addAction(muteAct);
|
|---|
| 482 |
|
|---|
| 483 | controlwidget->addAction(volumeslider_action);
|
|---|
| 484 |
|
|---|
| 485 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 486 | controlwidget->addAction(access_menu->menuAction());
|
|---|
| 487 | QToolButton * button = qobject_cast<QToolButton *>(controlwidget->widgetForAction(access_menu->menuAction()));
|
|---|
| 488 | button->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 489 | #endif
|
|---|
| 490 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 491 |
|
|---|
| 492 | /*
|
|---|
| 493 | controlwidget->show();
|
|---|
| 494 | */
|
|---|
| 495 |
|
|---|
| 496 | controlwidget->setIconSize(QSize(40,40));
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | void DefaultGui::createFloatingControl() {
|
|---|
| 500 | // Floating control
|
|---|
| 501 | floating_control = new AutohideWidget(mplayerwindow);
|
|---|
| 502 | floating_control->setAutoHide(true);
|
|---|
| 503 |
|
|---|
| 504 | EditableToolbar * iw = new EditableToolbar(floating_control);
|
|---|
| 505 | iw->setObjectName("floating_control");
|
|---|
| 506 | connect(iw, SIGNAL(iconSizeChanged(const QSize &)), this, SLOT(adjustFloatingControlSize()));
|
|---|
| 507 |
|
|---|
| 508 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 509 | QStringList floatingcontrol_actions;
|
|---|
| 510 | floatingcontrol_actions << "play_or_pause" << "stop" << "separator";
|
|---|
| 511 | /*
|
|---|
| 512 | #if MINI_ARROW_BUTTONS
|
|---|
| 513 | floatingcontrol_actions << "rewindbutton_action";
|
|---|
| 514 | #else
|
|---|
| 515 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
|---|
| 516 | #endif
|
|---|
| 517 | */
|
|---|
| 518 | floatingcontrol_actions << "rewind1";
|
|---|
| 519 | floatingcontrol_actions << "current_timelabel_action" << "timeslider_action" << "total_timelabel_action";
|
|---|
| 520 | /*
|
|---|
| 521 | #if MINI_ARROW_BUTTONS
|
|---|
| 522 | floatingcontrol_actions << "forwardbutton_action";
|
|---|
| 523 | #else
|
|---|
| 524 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
|---|
| 525 | #endif
|
|---|
| 526 | */
|
|---|
| 527 | floatingcontrol_actions << "forward1";
|
|---|
| 528 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
|---|
| 529 | iw->setDefaultActions(floatingcontrol_actions);
|
|---|
| 530 | #else
|
|---|
| 531 | /*
|
|---|
| 532 | iw->addAction(playAct);
|
|---|
| 533 | iw->addAction(pauseAct);
|
|---|
| 534 | */
|
|---|
| 535 | iw->addAction(playOrPauseAct);
|
|---|
| 536 | iw->addAction(stopAct);
|
|---|
| 537 | iw->addSeparator();
|
|---|
| 538 |
|
|---|
| 539 | #if MINI_ARROW_BUTTONS
|
|---|
| 540 | iw->addAction( rewindbutton_action );
|
|---|
| 541 | #else
|
|---|
| 542 | iw->addAction(rewind3Act);
|
|---|
| 543 | iw->addAction(rewind2Act);
|
|---|
| 544 | iw->addAction(rewind1Act);
|
|---|
| 545 | #endif
|
|---|
| 546 |
|
|---|
| 547 | iw->addAction(current_time_label_action);
|
|---|
| 548 | iw->addAction(timeslider_action);
|
|---|
| 549 | iw->addAction(total_time_label_action);
|
|---|
| 550 |
|
|---|
| 551 | #if MINI_ARROW_BUTTONS
|
|---|
| 552 | iw->addAction( forwardbutton_action );
|
|---|
| 553 | #else
|
|---|
| 554 | iw->addAction(forward1Act);
|
|---|
| 555 | iw->addAction(forward2Act);
|
|---|
| 556 | iw->addAction(forward3Act);
|
|---|
| 557 | #endif
|
|---|
| 558 |
|
|---|
| 559 | iw->addSeparator();
|
|---|
| 560 | iw->addAction(fullscreenAct);
|
|---|
| 561 | iw->addAction(muteAct);
|
|---|
| 562 | iw->addAction(volumeslider_action);
|
|---|
| 563 | /*
|
|---|
| 564 | iw->addSeparator();
|
|---|
| 565 | iw->addAction(time_label_action);
|
|---|
| 566 | */
|
|---|
| 567 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 568 |
|
|---|
| 569 | floating_control->setInternalWidget(iw);
|
|---|
| 570 | iw->setIconSize(QSize(48,48));
|
|---|
| 571 |
|
|---|
| 572 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
|---|
| 573 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
|---|
| 574 | /*
|
|---|
| 575 | floating_control->addAction(exitFullscreenAct);
|
|---|
| 576 | floating_control->addAction(exitAct);
|
|---|
| 577 | */
|
|---|
| 578 | //floating_control->addActions(actions());
|
|---|
| 579 | #endif
|
|---|
| 580 |
|
|---|
| 581 | #if !USE_CONFIGURABLE_TOOLBARS
|
|---|
| 582 | floating_control->adjustSize();
|
|---|
| 583 | #endif
|
|---|
| 584 |
|
|---|
| 585 | floating_control->hide();
|
|---|
| 586 | }
|
|---|
| 587 |
|
|---|
| 588 | void DefaultGui::createStatusBar() {
|
|---|
| 589 | qDebug("DefaultGui::createStatusBar");
|
|---|
| 590 |
|
|---|
| 591 | time_display = new QLabel( statusBar() );
|
|---|
| 592 | time_display->setObjectName("time_display");
|
|---|
| 593 | time_display->setAlignment(Qt::AlignRight);
|
|---|
| 594 | time_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 595 | time_display->setText(" 88:88:88 / 88:88:88 ");
|
|---|
| 596 | time_display->setMinimumSize(time_display->sizeHint());
|
|---|
| 597 | connect(this, SIGNAL(timeChanged(QString)), time_display, SLOT(setText(QString)));
|
|---|
| 598 |
|
|---|
| 599 | frame_display = new QLabel( statusBar() );
|
|---|
| 600 | frame_display->setObjectName("frame_display");
|
|---|
| 601 | frame_display->setAlignment(Qt::AlignRight);
|
|---|
| 602 | frame_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 603 | frame_display->setText("88888888");
|
|---|
| 604 | frame_display->setMinimumSize(frame_display->sizeHint());
|
|---|
| 605 |
|
|---|
| 606 | ab_section_display = new QLabel( statusBar() );
|
|---|
| 607 | ab_section_display->setObjectName("ab_section_display");
|
|---|
| 608 | ab_section_display->setAlignment(Qt::AlignRight);
|
|---|
| 609 | ab_section_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 610 | // ab_section_display->setText("A:0:00:00 B:0:00:00");
|
|---|
| 611 | // ab_section_display->setMinimumSize(ab_section_display->sizeHint());
|
|---|
| 612 |
|
|---|
| 613 | video_info_display = new QLabel( statusBar() );
|
|---|
| 614 | video_info_display->setObjectName("video_info_display");
|
|---|
| 615 | video_info_display->setAlignment(Qt::AlignRight);
|
|---|
| 616 | video_info_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 617 |
|
|---|
| 618 | format_info_display = new QLabel( statusBar() );
|
|---|
| 619 | format_info_display->setObjectName("format_info_display");
|
|---|
| 620 | format_info_display->setAlignment(Qt::AlignRight);
|
|---|
| 621 | format_info_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 622 |
|
|---|
| 623 | #ifdef BUFFERING_ANIMATION
|
|---|
| 624 | state_widget = new StateWidget(statusBar());
|
|---|
| 625 | connect(core, SIGNAL(stateChanged(Core::State)), state_widget, SLOT(watchState(Core::State)));
|
|---|
| 626 | statusBar()->addPermanentWidget(state_widget);
|
|---|
| 627 | #endif
|
|---|
| 628 |
|
|---|
| 629 | statusBar()->setAutoFillBackground(true);
|
|---|
| 630 |
|
|---|
| 631 | /*
|
|---|
| 632 | ColorUtils::setBackgroundColor( statusBar(), QColor(0,0,0) );
|
|---|
| 633 | ColorUtils::setForegroundColor( statusBar(), QColor(255,255,255) );
|
|---|
| 634 | ColorUtils::setBackgroundColor( time_display, QColor(0,0,0) );
|
|---|
| 635 | ColorUtils::setForegroundColor( time_display, QColor(255,255,255) );
|
|---|
| 636 | ColorUtils::setBackgroundColor( frame_display, QColor(0,0,0) );
|
|---|
| 637 | ColorUtils::setForegroundColor( frame_display, QColor(255,255,255) );
|
|---|
| 638 | ColorUtils::setBackgroundColor( ab_section_display, QColor(0,0,0) );
|
|---|
| 639 | ColorUtils::setForegroundColor( ab_section_display, QColor(255,255,255) );
|
|---|
| 640 | ColorUtils::setBackgroundColor( video_info_display, QColor(0,0,0) );
|
|---|
| 641 | ColorUtils::setForegroundColor( video_info_display, QColor(255,255,255) );
|
|---|
| 642 | */
|
|---|
| 643 | statusBar()->setSizeGripEnabled(false);
|
|---|
| 644 |
|
|---|
| 645 | statusBar()->addPermanentWidget( video_info_display );
|
|---|
| 646 | statusBar()->addPermanentWidget( format_info_display );
|
|---|
| 647 | statusBar()->addPermanentWidget( ab_section_display );
|
|---|
| 648 |
|
|---|
| 649 | statusBar()->showMessage( tr("Ready") );
|
|---|
| 650 | statusBar()->addPermanentWidget( frame_display, 0 );
|
|---|
| 651 | frame_display->setText( "0" );
|
|---|
| 652 |
|
|---|
| 653 | statusBar()->addPermanentWidget( time_display, 0 );
|
|---|
| 654 | time_display->setText(" 00:00:00 / 00:00:00 ");
|
|---|
| 655 |
|
|---|
| 656 | time_display->show();
|
|---|
| 657 | frame_display->hide();
|
|---|
| 658 | ab_section_display->show();
|
|---|
| 659 | video_info_display->hide();
|
|---|
| 660 | format_info_display->hide();
|
|---|
| 661 | }
|
|---|
| 662 |
|
|---|
| 663 | void DefaultGui::retranslateStrings() {
|
|---|
| 664 | BaseGuiPlus::retranslateStrings();
|
|---|
| 665 |
|
|---|
| 666 | // Change the icon of the play/pause action
|
|---|
| 667 | playOrPauseAct->setIcon(Images::icon("play"));
|
|---|
| 668 |
|
|---|
| 669 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
|---|
| 670 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
|---|
| 671 |
|
|---|
| 672 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
|---|
| 673 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
|---|
| 674 |
|
|---|
| 675 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
|---|
| 676 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
|---|
| 677 |
|
|---|
| 678 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 679 | toolbar2->setWindowTitle( tr("&Language toolbar") );
|
|---|
| 680 | toolbar2->toggleViewAction()->setIcon(Images::icon("lang_toolbar"));
|
|---|
| 681 |
|
|---|
| 682 | select_audio->setText( tr("Audio") );
|
|---|
| 683 | select_subtitle->setText( tr("Subtitle") );
|
|---|
| 684 | #endif
|
|---|
| 685 |
|
|---|
| 686 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
|---|
| 687 | viewFrameCounterAct->change( Images::icon("frame_counter"), tr("&Frame counter") );
|
|---|
| 688 | viewFormatInfoAct->change( Images::icon("view_format_info"), tr("F&ormat info") );
|
|---|
| 689 |
|
|---|
| 690 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 691 | editToolbar1Act->change( tr("Edit main &toolbar") );
|
|---|
| 692 | editControl1Act->change( tr("Edit &control bar") );
|
|---|
| 693 | editControl2Act->change( tr("Edit m&ini control bar") );
|
|---|
| 694 | editFloatingControlAct->change( tr("Edit &floating control") );
|
|---|
| 695 | #endif
|
|---|
| 696 |
|
|---|
| 697 | #ifdef BUFFERING_ANIMATION
|
|---|
| 698 | state_widget->setAnimation(Images::file("buffering.gif"));
|
|---|
| 699 | #endif
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 | void DefaultGui::displayFrame(int frame) {
|
|---|
| 704 | if (frame_display->isVisible()) {
|
|---|
| 705 | frame_display->setNum( frame );
|
|---|
| 706 | }
|
|---|
| 707 | }
|
|---|
| 708 |
|
|---|
| 709 | void DefaultGui::displayABSection(int secs_a, int secs_b) {
|
|---|
| 710 | QString s;
|
|---|
| 711 | if (secs_a > -1) s = tr("A:%1").arg(Helper::formatTime(secs_a));
|
|---|
| 712 |
|
|---|
| 713 | if (secs_b > -1) {
|
|---|
| 714 | if (!s.isEmpty()) s += " ";
|
|---|
| 715 | s += tr("B:%1").arg(Helper::formatTime(secs_b));
|
|---|
| 716 | }
|
|---|
| 717 |
|
|---|
| 718 | ab_section_display->setText( s );
|
|---|
| 719 |
|
|---|
| 720 | ab_section_display->setVisible( !s.isEmpty() );
|
|---|
| 721 | }
|
|---|
| 722 |
|
|---|
| 723 | void DefaultGui::displayVideoInfo(int width, int height, double fps) {
|
|---|
| 724 | if ((width != 0) && (height != 0)) {
|
|---|
| 725 | video_info_display->setText(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
|
|---|
| 726 | } else {
|
|---|
| 727 | video_info_display->setText(" ");
|
|---|
| 728 | }
|
|---|
| 729 |
|
|---|
| 730 | QString format = core->mdat.video_format;
|
|---|
| 731 | if (!format.isEmpty() && !core->mdat.audio_format.isEmpty()) format += " / ";
|
|---|
| 732 | format += core->mdat.audio_format;
|
|---|
| 733 | format_info_display->setText(format.toUpper());
|
|---|
| 734 | }
|
|---|
| 735 |
|
|---|
| 736 | void DefaultGui::updateWidgets() {
|
|---|
| 737 | qDebug("DefaultGui::updateWidgets");
|
|---|
| 738 |
|
|---|
| 739 | BaseGuiPlus::updateWidgets();
|
|---|
| 740 |
|
|---|
| 741 | panel->setFocus();
|
|---|
| 742 | }
|
|---|
| 743 |
|
|---|
| 744 | void DefaultGui::checkCompactMode() {
|
|---|
| 745 | qDebug("DefaultGui::checkCompactMode");
|
|---|
| 746 |
|
|---|
| 747 | if ((pref->compact_mode) && (pref->floating_display_in_compact_mode)) {
|
|---|
| 748 | reconfigureFloatingControl();
|
|---|
| 749 | floating_control->activate();
|
|---|
| 750 | } else {
|
|---|
| 751 | floating_control->deactivate();
|
|---|
| 752 | }
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 756 | void DefaultGui::adaptForTabletMode() {
|
|---|
| 757 | qDebug("DefaultGui::adaptForTabletMode");
|
|---|
| 758 |
|
|---|
| 759 | bool b = pref->tablet_mode;
|
|---|
| 760 |
|
|---|
| 761 | if (!pref->compact_mode) {
|
|---|
| 762 | menuBar()->setVisible(!b);
|
|---|
| 763 | toolbar1->setVisible(!b);
|
|---|
| 764 | }
|
|---|
| 765 | access_menu->menuAction()->setVisible(b);
|
|---|
| 766 | }
|
|---|
| 767 | #endif
|
|---|
| 768 |
|
|---|
| 769 | void DefaultGui::reconfigureFloatingControl() {
|
|---|
| 770 | floating_control->setMargin(pref->floating_control_margin);
|
|---|
| 771 | floating_control->setPercWidth(pref->floating_control_width);
|
|---|
| 772 | floating_control->setAnimated(pref->floating_control_animated);
|
|---|
| 773 | floating_control->setActivationArea( (AutohideWidget::Activation) pref->floating_activation_area);
|
|---|
| 774 | floating_control->setHideDelay(pref->floating_hide_delay);
|
|---|
| 775 | }
|
|---|
| 776 |
|
|---|
| 777 | void DefaultGui::aboutToEnterFullscreen() {
|
|---|
| 778 | qDebug("DefaultGui::aboutToEnterFullscreen");
|
|---|
| 779 |
|
|---|
| 780 | BaseGuiPlus::aboutToEnterFullscreen();
|
|---|
| 781 |
|
|---|
| 782 | // Show floating_control
|
|---|
| 783 | reconfigureFloatingControl();
|
|---|
| 784 | floating_control->deactivate(); // Hide the control in case it was running from compact mode
|
|---|
| 785 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 | // Save visibility of toolbars
|
|---|
| 789 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
|---|
| 790 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 791 | fullscreen_toolbar2_was_visible = toolbar2->isVisible();
|
|---|
| 792 | #endif
|
|---|
| 793 |
|
|---|
| 794 | if (!pref->compact_mode) {
|
|---|
| 795 | //menuBar()->hide();
|
|---|
| 796 | //statusBar()->hide();
|
|---|
| 797 | controlwidget->hide();
|
|---|
| 798 | controlwidget_mini->hide();
|
|---|
| 799 | toolbar1->hide();
|
|---|
| 800 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 801 | toolbar2->hide();
|
|---|
| 802 | #endif
|
|---|
| 803 | }
|
|---|
| 804 | }
|
|---|
| 805 |
|
|---|
| 806 | void DefaultGui::aboutToExitFullscreen() {
|
|---|
| 807 | qDebug("DefaultGui::aboutToExitFullscreen");
|
|---|
| 808 |
|
|---|
| 809 | BaseGuiPlus::aboutToExitFullscreen();
|
|---|
| 810 |
|
|---|
| 811 | // Hide floating_control
|
|---|
| 812 | if (!pref->compact_mode || !pref->floating_display_in_compact_mode) {
|
|---|
| 813 | floating_control->deactivate();
|
|---|
| 814 | }
|
|---|
| 815 |
|
|---|
| 816 | if (!pref->compact_mode) {
|
|---|
| 817 | //menuBar()->show();
|
|---|
| 818 | //statusBar()->show();
|
|---|
| 819 | controlwidget->show();
|
|---|
| 820 |
|
|---|
| 821 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
|---|
| 822 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 823 | toolbar2->setVisible( fullscreen_toolbar2_was_visible );
|
|---|
| 824 | #endif
|
|---|
| 825 | }
|
|---|
| 826 |
|
|---|
| 827 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 828 | if (pref->tablet_mode) menuBar()->hide();
|
|---|
| 829 | #endif
|
|---|
| 830 | }
|
|---|
| 831 |
|
|---|
| 832 | void DefaultGui::aboutToEnterCompactMode() {
|
|---|
| 833 |
|
|---|
| 834 | BaseGuiPlus::aboutToEnterCompactMode();
|
|---|
| 835 |
|
|---|
| 836 | // Show floating_control
|
|---|
| 837 | if (pref->floating_display_in_compact_mode) {
|
|---|
| 838 | reconfigureFloatingControl();
|
|---|
| 839 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
|---|
| 840 | }
|
|---|
| 841 |
|
|---|
| 842 |
|
|---|
| 843 | // Save visibility of toolbars
|
|---|
| 844 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
|---|
| 845 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 846 | compact_toolbar2_was_visible = toolbar2->isVisible();
|
|---|
| 847 | #endif
|
|---|
| 848 |
|
|---|
| 849 | //menuBar()->hide();
|
|---|
| 850 | //statusBar()->hide();
|
|---|
| 851 | controlwidget->hide();
|
|---|
| 852 | controlwidget_mini->hide();
|
|---|
| 853 | toolbar1->hide();
|
|---|
| 854 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 855 | toolbar2->hide();
|
|---|
| 856 | #endif
|
|---|
| 857 | }
|
|---|
| 858 |
|
|---|
| 859 | void DefaultGui::aboutToExitCompactMode() {
|
|---|
| 860 | BaseGuiPlus::aboutToExitCompactMode();
|
|---|
| 861 |
|
|---|
| 862 | // Hide floating_control
|
|---|
| 863 | if (pref->floating_display_in_compact_mode) {
|
|---|
| 864 | floating_control->deactivate();
|
|---|
| 865 | }
|
|---|
| 866 |
|
|---|
| 867 | //menuBar()->show();
|
|---|
| 868 | //statusBar()->show();
|
|---|
| 869 | controlwidget->show();
|
|---|
| 870 |
|
|---|
| 871 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
|---|
| 872 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 873 | toolbar2->setVisible( compact_toolbar2_was_visible );
|
|---|
| 874 | #endif
|
|---|
| 875 |
|
|---|
| 876 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 877 | if (pref->tablet_mode) menuBar()->hide();
|
|---|
| 878 | #endif
|
|---|
| 879 |
|
|---|
| 880 | // Recheck size of controlwidget
|
|---|
| 881 | resizeEvent( new QResizeEvent( size(), size() ) );
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | void DefaultGui::resizeEvent( QResizeEvent * ) {
|
|---|
| 885 | /*
|
|---|
| 886 | qDebug("defaultGui::resizeEvent");
|
|---|
| 887 | qDebug(" controlwidget width: %d", controlwidget->width() );
|
|---|
| 888 | qDebug(" controlwidget_mini width: %d", controlwidget_mini->width() );
|
|---|
| 889 | */
|
|---|
| 890 |
|
|---|
| 891 | #if QT_VERSION < 0x040000
|
|---|
| 892 | #define LIMIT 470
|
|---|
| 893 | #else
|
|---|
| 894 | #define LIMIT 570
|
|---|
| 895 | #endif
|
|---|
| 896 |
|
|---|
| 897 | if ( (controlwidget->isVisible()) && (width() < LIMIT) ) {
|
|---|
| 898 | controlwidget->hide();
|
|---|
| 899 | controlwidget_mini->show();
|
|---|
| 900 | }
|
|---|
| 901 | else
|
|---|
| 902 | if ( (controlwidget_mini->isVisible()) && (width() > LIMIT) ) {
|
|---|
| 903 | controlwidget_mini->hide();
|
|---|
| 904 | controlwidget->show();
|
|---|
| 905 | }
|
|---|
| 906 | }
|
|---|
| 907 |
|
|---|
| 908 | #if USE_MINIMUMSIZE
|
|---|
| 909 | QSize DefaultGui::minimumSizeHint() const {
|
|---|
| 910 | return QSize(controlwidget_mini->sizeHint().width(), 0);
|
|---|
| 911 | }
|
|---|
| 912 | #endif
|
|---|
| 913 |
|
|---|
| 914 | void DefaultGui::adjustFloatingControlSize() {
|
|---|
| 915 | qDebug("DefaultGui::adjustFloatingControlSize");
|
|---|
| 916 | //floating_control->adjustSize();
|
|---|
| 917 | QWidget *iw = floating_control->internalWidget();
|
|---|
| 918 | if (iw) {
|
|---|
| 919 | QSize iws = iw->size();
|
|---|
| 920 | QMargins m = floating_control->contentsMargins();
|
|---|
| 921 | int new_height = iws.height() + m.top() + m.bottom();
|
|---|
| 922 | if (new_height < 32) new_height = 32;
|
|---|
| 923 | floating_control->resize(floating_control->width(), new_height);
|
|---|
| 924 | }
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | void DefaultGui::saveConfig() {
|
|---|
| 928 | qDebug("DefaultGui::saveConfig");
|
|---|
| 929 |
|
|---|
| 930 | QSettings * set = settings;
|
|---|
| 931 |
|
|---|
| 932 | set->beginGroup( "default_gui");
|
|---|
| 933 |
|
|---|
| 934 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
|---|
| 935 | set->setValue("frame_counter", viewFrameCounterAct->isChecked());
|
|---|
| 936 | set->setValue("format_info", viewFormatInfoAct->isChecked());
|
|---|
| 937 |
|
|---|
| 938 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
|---|
| 939 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
|---|
| 940 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 941 | set->setValue("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible);
|
|---|
| 942 | set->setValue("compact_toolbar2_was_visible", compact_toolbar2_was_visible);
|
|---|
| 943 | #endif
|
|---|
| 944 |
|
|---|
| 945 | if (pref->save_window_size_on_exit) {
|
|---|
| 946 | qDebug("DefaultGui::saveConfig: w: %d h: %d", width(), height());
|
|---|
| 947 | set->setValue( "pos", pos() );
|
|---|
| 948 | set->setValue( "size", size() );
|
|---|
| 949 | set->setValue( "state", (int) windowState() );
|
|---|
| 950 | }
|
|---|
| 951 |
|
|---|
| 952 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
|---|
| 953 |
|
|---|
| 954 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 955 | set->beginGroup( "actions" );
|
|---|
| 956 | set->setValue("toolbar1", toolbar1->actionsToStringList() );
|
|---|
| 957 | set->setValue("controlwidget", controlwidget->actionsToStringList() );
|
|---|
| 958 | set->setValue("controlwidget_mini", controlwidget_mini->actionsToStringList() );
|
|---|
| 959 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
|---|
| 960 | set->setValue("floating_control", iw->actionsToStringList() );
|
|---|
| 961 | set->setValue("toolbar1_version", TOOLBAR_VERSION);
|
|---|
| 962 | set->setValue("controlwidget_version", CONTROLWIDGET_VERSION);
|
|---|
| 963 | set->setValue("floating_control_version", FLOATING_CONTROL_VERSION);
|
|---|
| 964 | set->endGroup();
|
|---|
| 965 |
|
|---|
| 966 | set->beginGroup("toolbars_icon_size");
|
|---|
| 967 | set->setValue("toolbar1", toolbar1->iconSize());
|
|---|
| 968 | set->setValue("controlwidget", controlwidget->iconSize());
|
|---|
| 969 | set->setValue("controlwidget_mini", controlwidget_mini->iconSize());
|
|---|
| 970 | set->setValue("floating_control", iw->iconSize());
|
|---|
| 971 | set->endGroup();
|
|---|
| 972 | #endif
|
|---|
| 973 |
|
|---|
| 974 | set->endGroup();
|
|---|
| 975 | }
|
|---|
| 976 |
|
|---|
| 977 | void DefaultGui::loadConfig() {
|
|---|
| 978 | qDebug("DefaultGui::loadConfig");
|
|---|
| 979 |
|
|---|
| 980 | QSettings * set = settings;
|
|---|
| 981 |
|
|---|
| 982 | set->beginGroup( "default_gui");
|
|---|
| 983 |
|
|---|
| 984 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
|---|
| 985 | viewFrameCounterAct->setChecked(set->value("frame_counter", false).toBool());
|
|---|
| 986 | viewFormatInfoAct->setChecked(set->value("format_info", false).toBool());
|
|---|
| 987 |
|
|---|
| 988 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
|---|
| 989 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
|---|
| 990 | #ifdef LANGUAGE_TOOLBAR
|
|---|
| 991 | fullscreen_toolbar2_was_visible = set->value("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible).toBool();
|
|---|
| 992 | compact_toolbar2_was_visible = set->value("compact_toolbar2_was_visible", compact_toolbar2_was_visible).toBool();
|
|---|
| 993 | #endif
|
|---|
| 994 |
|
|---|
| 995 | if (pref->save_window_size_on_exit) {
|
|---|
| 996 | QPoint p = set->value("pos", pos()).toPoint();
|
|---|
| 997 | QSize s = set->value("size", size()).toSize();
|
|---|
| 998 |
|
|---|
| 999 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
|---|
| 1000 | s = pref->default_size;
|
|---|
| 1001 | }
|
|---|
| 1002 |
|
|---|
| 1003 | move(p);
|
|---|
| 1004 | resize(s);
|
|---|
| 1005 |
|
|---|
| 1006 | setWindowState( (Qt::WindowStates) set->value("state", 0).toInt() );
|
|---|
| 1007 |
|
|---|
| 1008 | if (!DesktopInfo::isInsideScreen(this)) {
|
|---|
| 1009 | QPoint tl = DesktopInfo::topLeftPrimaryScreen();
|
|---|
| 1010 | move(tl);
|
|---|
| 1011 | qWarning("DefaultGui::loadConfig: window is outside of the screen, moved to %d x %d", tl.x(), tl.y());
|
|---|
| 1012 | }
|
|---|
| 1013 | }
|
|---|
| 1014 |
|
|---|
| 1015 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 1016 | set->beginGroup( "actions" );
|
|---|
| 1017 | int toolbar_version = set->value("toolbar1_version", 0).toInt();
|
|---|
| 1018 | if (toolbar_version >= TOOLBAR_VERSION) {
|
|---|
| 1019 | toolbar1->setActionsFromStringList( set->value("toolbar1", toolbar1->defaultActions()).toStringList() );
|
|---|
| 1020 | } else {
|
|---|
| 1021 | qDebug("DefaultGui::loadConfig: toolbar too old, loading default one");
|
|---|
| 1022 | toolbar1->setActionsFromStringList( toolbar1->defaultActions() );
|
|---|
| 1023 | }
|
|---|
| 1024 |
|
|---|
| 1025 | int controlwidget_version = set->value("controlwidget_version", 0).toInt();
|
|---|
| 1026 | if (controlwidget_version >= CONTROLWIDGET_VERSION) {
|
|---|
| 1027 | QStringList l = set->value("controlwidget", controlwidget->defaultActions()).toStringList();
|
|---|
| 1028 | #ifdef ADD_QUICK_ACCESS
|
|---|
| 1029 | if (l.indexOf("quick_access_menu") == -1) l << "quick_access_menu";
|
|---|
| 1030 | #endif
|
|---|
| 1031 | controlwidget->setActionsFromStringList(l);
|
|---|
| 1032 | } else {
|
|---|
| 1033 | controlwidget->setActionsFromStringList( controlwidget->defaultActions() );
|
|---|
| 1034 | }
|
|---|
| 1035 |
|
|---|
| 1036 | controlwidget_mini->setActionsFromStringList( set->value("controlwidget_mini", controlwidget_mini->defaultActions()).toStringList() );
|
|---|
| 1037 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
|---|
| 1038 |
|
|---|
| 1039 | int floating_control_version = set->value("floating_control_version", 0).toInt();
|
|---|
| 1040 | if (floating_control_version >= FLOATING_CONTROL_VERSION) {
|
|---|
| 1041 | iw->setActionsFromStringList( set->value("floating_control", iw->defaultActions()).toStringList() );
|
|---|
| 1042 | } else {
|
|---|
| 1043 | qDebug("DefaultGui::loadConfig: floating control too old, loading default one");
|
|---|
| 1044 | iw->setActionsFromStringList( iw->defaultActions() );
|
|---|
| 1045 | }
|
|---|
| 1046 | set->endGroup();
|
|---|
| 1047 |
|
|---|
| 1048 | set->beginGroup("toolbars_icon_size");
|
|---|
| 1049 | toolbar1->setIconSize(set->value("toolbar1", toolbar1->iconSize()).toSize());
|
|---|
| 1050 | controlwidget->setIconSize(set->value("controlwidget", controlwidget->iconSize()).toSize());
|
|---|
| 1051 | controlwidget_mini->setIconSize(set->value("controlwidget_mini", controlwidget_mini->iconSize()).toSize());
|
|---|
| 1052 | iw->setIconSize(set->value("floating_control", iw->iconSize()).toSize());
|
|---|
| 1053 | set->endGroup();
|
|---|
| 1054 |
|
|---|
| 1055 | floating_control->adjustSize();
|
|---|
| 1056 | #endif
|
|---|
| 1057 |
|
|---|
| 1058 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
|---|
| 1059 |
|
|---|
| 1060 | #if DOCK_PLAYLIST
|
|---|
| 1061 | qDebug("DefaultGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
|---|
| 1062 | qDebug("DefaultGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
|---|
| 1063 | qDebug("DefaultGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
|---|
| 1064 | #endif
|
|---|
| 1065 |
|
|---|
| 1066 | set->endGroup();
|
|---|
| 1067 |
|
|---|
| 1068 | updateWidgets();
|
|---|
| 1069 | }
|
|---|
| 1070 |
|
|---|
| 1071 | #include "moc_defaultgui.cpp"
|
|---|