| 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 1
|
|---|
| 55 |
|
|---|
| 56 | using namespace Global;
|
|---|
| 57 |
|
|---|
| 58 | DefaultGui::DefaultGui( QWidget * parent, Qt::WindowFlags flags )
|
|---|
| 59 | : BaseGuiPlus( parent, flags )
|
|---|
| 60 | {
|
|---|
| 61 | createStatusBar();
|
|---|
| 62 |
|
|---|
| 63 | connect( this, SIGNAL(timeChanged(QString)),
|
|---|
| 64 | this, SLOT(displayTime(QString)) );
|
|---|
| 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 | menuBar()->setObjectName("menubar");
|
|---|
| 93 |
|
|---|
| 94 | retranslateStrings();
|
|---|
| 95 |
|
|---|
| 96 | loadConfig();
|
|---|
| 97 |
|
|---|
| 98 | //if (playlist_visible) showPlaylist(true);
|
|---|
| 99 |
|
|---|
| 100 | if (pref->compact_mode) {
|
|---|
| 101 | controlwidget->hide();
|
|---|
| 102 | toolbar1->hide();
|
|---|
| 103 | toolbar2->hide();
|
|---|
| 104 |
|
|---|
| 105 | if (pref->floating_display_in_compact_mode) {
|
|---|
| 106 | reconfigureFloatingControl();
|
|---|
| 107 | floating_control->activate();
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | applyStyles();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | DefaultGui::~DefaultGui() {
|
|---|
| 115 | qDebug("DefaultGui::~DefaultGui");
|
|---|
| 116 | saveConfig();
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | /*
|
|---|
| 120 | void DefaultGui::closeEvent( QCloseEvent * ) {
|
|---|
| 121 | qDebug("DefaultGui::closeEvent");
|
|---|
| 122 |
|
|---|
| 123 | //BaseGuiPlus::closeEvent(e);
|
|---|
| 124 | qDebug("w: %d h: %d", width(), height() );
|
|---|
| 125 | }
|
|---|
| 126 | */
|
|---|
| 127 |
|
|---|
| 128 | void DefaultGui::createActions() {
|
|---|
| 129 | qDebug("DefaultGui::createActions");
|
|---|
| 130 |
|
|---|
| 131 | timeslider_action = createTimeSliderAction(this);
|
|---|
| 132 | volumeslider_action = createVolumeSliderAction(this);
|
|---|
| 133 |
|
|---|
| 134 | #if AUTODISABLE_ACTIONS
|
|---|
| 135 | timeslider_action->disable();
|
|---|
| 136 | volumeslider_action->disable();
|
|---|
| 137 | #endif
|
|---|
| 138 |
|
|---|
| 139 | // Create the time label
|
|---|
| 140 | time_label_action = new TimeLabelAction(this);
|
|---|
| 141 | time_label_action->setObjectName("timelabel_action");
|
|---|
| 142 |
|
|---|
| 143 | #if MINI_ARROW_BUTTONS
|
|---|
| 144 | QList<QAction*> rewind_actions;
|
|---|
| 145 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
|---|
| 146 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
|---|
| 147 | rewindbutton_action->setObjectName("rewindbutton_action");
|
|---|
| 148 |
|
|---|
| 149 | QList<QAction*> forward_actions;
|
|---|
| 150 | forward_actions << forward1Act << forward2Act << forward3Act;
|
|---|
| 151 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
|---|
| 152 | forwardbutton_action->setObjectName("forwardbutton_action");
|
|---|
| 153 | #endif
|
|---|
| 154 |
|
|---|
| 155 | // Statusbar
|
|---|
| 156 | viewVideoInfoAct = new MyAction(this, "toggle_video_info" );
|
|---|
| 157 | viewVideoInfoAct->setCheckable(true);
|
|---|
| 158 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
|---|
| 159 | video_info_display, SLOT(setVisible(bool)) );
|
|---|
| 160 |
|
|---|
| 161 | viewFrameCounterAct = new MyAction( this, "toggle_frame_counter" );
|
|---|
| 162 | viewFrameCounterAct->setCheckable( true );
|
|---|
| 163 | connect( viewFrameCounterAct, SIGNAL(toggled(bool)),
|
|---|
| 164 | frame_display, SLOT(setVisible(bool)) );
|
|---|
| 165 |
|
|---|
| 166 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 167 | editToolbar1Act = new MyAction( this, "edit_main_toolbar" );
|
|---|
| 168 | editControl1Act = new MyAction( this, "edit_control1" );
|
|---|
| 169 | editControl2Act = new MyAction( this, "edit_control2" );
|
|---|
| 170 | editFloatingControlAct = new MyAction( this, "edit_floating_control" );
|
|---|
| 171 | #endif
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | #if AUTODISABLE_ACTIONS
|
|---|
| 175 | void DefaultGui::enableActionsOnPlaying() {
|
|---|
| 176 | qDebug("DefaultGui::enableActionsOnPlaying");
|
|---|
| 177 | BaseGuiPlus::enableActionsOnPlaying();
|
|---|
| 178 |
|
|---|
| 179 | timeslider_action->enable();
|
|---|
| 180 | volumeslider_action->enable();
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | void DefaultGui::disableActionsOnStop() {
|
|---|
| 184 | qDebug("DefaultGui::disableActionsOnStop");
|
|---|
| 185 | BaseGuiPlus::disableActionsOnStop();
|
|---|
| 186 |
|
|---|
| 187 | timeslider_action->disable();
|
|---|
| 188 | volumeslider_action->disable();
|
|---|
| 189 | }
|
|---|
| 190 | #endif // AUTODISABLE_ACTIONS
|
|---|
| 191 |
|
|---|
| 192 | void DefaultGui::togglePlayAction(Core::State state) {
|
|---|
| 193 | qDebug("DefaultGui::togglePlayAction");
|
|---|
| 194 | BaseGui::togglePlayAction(state);
|
|---|
| 195 |
|
|---|
| 196 | if (state == Core::Playing) {
|
|---|
| 197 | playOrPauseAct->setIcon(Images::icon("pause"));
|
|---|
| 198 | } else {
|
|---|
| 199 | playOrPauseAct->setIcon(Images::icon("play"));
|
|---|
| 200 | }
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | void DefaultGui::createMenus() {
|
|---|
| 204 | toolbar_menu = new QMenu(this);
|
|---|
| 205 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
|---|
| 206 | toolbar_menu->addAction(toolbar2->toggleViewAction());
|
|---|
| 207 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 208 | toolbar_menu->addSeparator();
|
|---|
| 209 | toolbar_menu->addAction(editToolbar1Act);
|
|---|
| 210 | toolbar_menu->addAction(editControl1Act);
|
|---|
| 211 | toolbar_menu->addAction(editControl2Act);
|
|---|
| 212 | toolbar_menu->addAction(editFloatingControlAct);
|
|---|
| 213 | #endif
|
|---|
| 214 | optionsMenu->addSeparator();
|
|---|
| 215 | optionsMenu->addMenu(toolbar_menu);
|
|---|
| 216 |
|
|---|
| 217 | statusbar_menu = new QMenu(this);
|
|---|
| 218 | statusbar_menu->addAction(viewVideoInfoAct);
|
|---|
| 219 | statusbar_menu->addAction(viewFrameCounterAct);
|
|---|
| 220 |
|
|---|
| 221 | optionsMenu->addMenu(statusbar_menu);
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | QMenu * DefaultGui::createPopupMenu() {
|
|---|
| 225 | QMenu * m = new QMenu(this);
|
|---|
| 226 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 227 | m->addAction(editToolbar1Act);
|
|---|
| 228 | m->addAction(editControl1Act);
|
|---|
| 229 | m->addAction(editControl2Act);
|
|---|
| 230 | m->addAction(editFloatingControlAct);
|
|---|
| 231 | #else
|
|---|
| 232 | m->addAction(toolbar1->toggleViewAction());
|
|---|
| 233 | m->addAction(toolbar2->toggleViewAction());
|
|---|
| 234 | #endif
|
|---|
| 235 | return m;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | void DefaultGui::createMainToolBars() {
|
|---|
| 239 | toolbar1 = new EditableToolbar( this );
|
|---|
| 240 | toolbar1->setObjectName("toolbar1");
|
|---|
| 241 | //toolbar1->setMovable(false);
|
|---|
| 242 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
|---|
| 243 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 244 | QStringList toolbar1_actions;
|
|---|
| 245 | toolbar1_actions << "open_file" << "open_url" << "favorites_menu" << "separator"
|
|---|
| 246 | << "screenshot" << "separator" << "show_file_properties" << "show_playlist"
|
|---|
| 247 | << "show_tube_browser" << "separator" << "show_preferences"
|
|---|
| 248 | << "separator" << "play_prev" << "play_next";
|
|---|
| 249 |
|
|---|
| 250 | toolbar1->setDefaultActions(toolbar1_actions);
|
|---|
| 251 | #else
|
|---|
| 252 | toolbar1->addAction(openFileAct);
|
|---|
| 253 | /* toolbar1->addAction(openDVDAct); */
|
|---|
| 254 | toolbar1->addAction(openURLAct);
|
|---|
| 255 | toolbar1->addAction(favorites->menuAction());
|
|---|
| 256 | toolbar1->addSeparator();
|
|---|
| 257 | /*
|
|---|
| 258 | toolbar1->addAction(compactAct);
|
|---|
| 259 | toolbar1->addAction(fullscreenAct);
|
|---|
| 260 | toolbar1->addSeparator();
|
|---|
| 261 | */
|
|---|
| 262 | toolbar1->addAction(screenshotAct);
|
|---|
| 263 | toolbar1->addSeparator();
|
|---|
| 264 | toolbar1->addAction(showPropertiesAct);
|
|---|
| 265 | toolbar1->addAction(showPlaylistAct);
|
|---|
| 266 | toolbar1->addAction(showPreferencesAct);
|
|---|
| 267 | toolbar1->addSeparator();
|
|---|
| 268 | toolbar1->addAction(playPrevAct);
|
|---|
| 269 | toolbar1->addAction(playNextAct);
|
|---|
| 270 | // Test:
|
|---|
| 271 | //toolbar1->addSeparator();
|
|---|
| 272 | //toolbar1->addAction(timeslider_action);
|
|---|
| 273 | //toolbar1->addAction(volumeslider_action);
|
|---|
| 274 |
|
|---|
| 275 | QToolButton * button = qobject_cast<QToolButton *>(toolbar1->widgetForAction(favorites->menuAction()));
|
|---|
| 276 | button->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 277 | #endif
|
|---|
| 278 |
|
|---|
| 279 | toolbar2 = new QToolBar( this );
|
|---|
| 280 | toolbar2->setObjectName("toolbar2");
|
|---|
| 281 | //toolbar2->setMovable(false);
|
|---|
| 282 | addToolBar(Qt::TopToolBarArea, toolbar2);
|
|---|
| 283 |
|
|---|
| 284 | select_audio = new QPushButton( this );
|
|---|
| 285 | select_audio->setMenu( audiotrack_menu );
|
|---|
| 286 | toolbar2->addWidget(select_audio);
|
|---|
| 287 |
|
|---|
| 288 | select_subtitle = new QPushButton( this );
|
|---|
| 289 | select_subtitle->setMenu( subtitles_track_menu );
|
|---|
| 290 | toolbar2->addWidget(select_subtitle);
|
|---|
| 291 |
|
|---|
| 292 | /*
|
|---|
| 293 | toolbar1->show();
|
|---|
| 294 | toolbar2->show();
|
|---|
| 295 | */
|
|---|
| 296 |
|
|---|
| 297 | // Modify toolbars' actions
|
|---|
| 298 | QAction *tba;
|
|---|
| 299 | tba = toolbar1->toggleViewAction();
|
|---|
| 300 | tba->setObjectName("show_main_toolbar");
|
|---|
| 301 | tba->setShortcut(Qt::Key_F5);
|
|---|
| 302 |
|
|---|
| 303 | tba = toolbar2->toggleViewAction();
|
|---|
| 304 | tba->setObjectName("show_language_toolbar");
|
|---|
| 305 | tba->setShortcut(Qt::Key_F6);
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 | void DefaultGui::createControlWidgetMini() {
|
|---|
| 310 | qDebug("DefaultGui::createControlWidgetMini");
|
|---|
| 311 |
|
|---|
| 312 | controlwidget_mini = new EditableToolbar( this );
|
|---|
| 313 | controlwidget_mini->setObjectName("controlwidget_mini");
|
|---|
| 314 | controlwidget_mini->setLayoutDirection(Qt::LeftToRight);
|
|---|
| 315 | //controlwidget_mini->setResizeEnabled(false);
|
|---|
| 316 | controlwidget_mini->setMovable(false);
|
|---|
| 317 | //addDockWindow(controlwidget_mini, Qt::DockBottom );
|
|---|
| 318 | addToolBar(Qt::BottomToolBarArea, controlwidget_mini);
|
|---|
| 319 |
|
|---|
| 320 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 321 | QStringList controlwidget_mini_actions;
|
|---|
| 322 | controlwidget_mini_actions << "play_or_pause" << "stop" << "separator" << "rewind1" << "timeslider_action"
|
|---|
| 323 | << "forward1" << "separator" << "mute" << "volumeslider_action";
|
|---|
| 324 | controlwidget_mini->setDefaultActions(controlwidget_mini_actions);
|
|---|
| 325 | #else
|
|---|
| 326 | controlwidget_mini->addAction(playOrPauseAct);
|
|---|
| 327 | controlwidget_mini->addAction(stopAct);
|
|---|
| 328 | controlwidget_mini->addSeparator();
|
|---|
| 329 |
|
|---|
| 330 | controlwidget_mini->addAction(rewind1Act);
|
|---|
| 331 |
|
|---|
| 332 | controlwidget_mini->addAction(timeslider_action);
|
|---|
| 333 |
|
|---|
| 334 | controlwidget_mini->addAction(forward1Act);
|
|---|
| 335 |
|
|---|
| 336 | controlwidget_mini->addSeparator();
|
|---|
| 337 |
|
|---|
| 338 | controlwidget_mini->addAction(muteAct );
|
|---|
| 339 |
|
|---|
| 340 | controlwidget_mini->addAction(volumeslider_action);
|
|---|
| 341 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 342 |
|
|---|
| 343 | controlwidget_mini->hide();
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | void DefaultGui::createControlWidget() {
|
|---|
| 347 | qDebug("DefaultGui::createControlWidget");
|
|---|
| 348 |
|
|---|
| 349 | controlwidget = new EditableToolbar( this );
|
|---|
| 350 | controlwidget->setObjectName("controlwidget");
|
|---|
| 351 | controlwidget->setLayoutDirection(Qt::LeftToRight);
|
|---|
| 352 | //controlwidget->setResizeEnabled(false);
|
|---|
| 353 | controlwidget->setMovable(false);
|
|---|
| 354 | //addDockWindow(controlwidget, Qt::DockBottom );
|
|---|
| 355 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
|---|
| 356 |
|
|---|
| 357 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 358 | QStringList controlwidget_actions;
|
|---|
| 359 | controlwidget_actions << "play_or_pause" << "stop" << "separator";
|
|---|
| 360 | #if MINI_ARROW_BUTTONS
|
|---|
| 361 | controlwidget_actions << "rewindbutton_action";
|
|---|
| 362 | #else
|
|---|
| 363 | controlwidget_actions << "rewind3" << "rewind2" << "rewind1";
|
|---|
| 364 | #endif
|
|---|
| 365 | controlwidget_actions << "timeslider_action";
|
|---|
| 366 | #if MINI_ARROW_BUTTONS
|
|---|
| 367 | controlwidget_actions << "forwardbutton_action";
|
|---|
| 368 | #else
|
|---|
| 369 | controlwidget_actions << "forward1" << "forward2" << "forward3";
|
|---|
| 370 | #endif
|
|---|
| 371 | controlwidget_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action";
|
|---|
| 372 | controlwidget->setDefaultActions(controlwidget_actions);
|
|---|
| 373 | #else
|
|---|
| 374 | /*
|
|---|
| 375 | controlwidget->addAction(playAct);
|
|---|
| 376 | controlwidget->addAction(pauseAndStepAct);
|
|---|
| 377 | */
|
|---|
| 378 | controlwidget->addAction(playOrPauseAct);
|
|---|
| 379 | controlwidget->addAction(stopAct);
|
|---|
| 380 |
|
|---|
| 381 | controlwidget->addSeparator();
|
|---|
| 382 |
|
|---|
| 383 | #if MINI_ARROW_BUTTONS
|
|---|
| 384 | controlwidget->addAction( rewindbutton_action );
|
|---|
| 385 | #else
|
|---|
| 386 | controlwidget->addAction(rewind3Act);
|
|---|
| 387 | controlwidget->addAction(rewind2Act);
|
|---|
| 388 | controlwidget->addAction(rewind1Act);
|
|---|
| 389 | #endif
|
|---|
| 390 |
|
|---|
| 391 | controlwidget->addAction(timeslider_action);
|
|---|
| 392 |
|
|---|
| 393 | #if MINI_ARROW_BUTTONS
|
|---|
| 394 | controlwidget->addAction( forwardbutton_action );
|
|---|
| 395 | #else
|
|---|
| 396 | controlwidget->addAction(forward1Act);
|
|---|
| 397 | controlwidget->addAction(forward2Act);
|
|---|
| 398 | controlwidget->addAction(forward3Act);
|
|---|
| 399 | #endif
|
|---|
| 400 |
|
|---|
| 401 | controlwidget->addSeparator();
|
|---|
| 402 |
|
|---|
| 403 | controlwidget->addAction(fullscreenAct);
|
|---|
| 404 | controlwidget->addAction(muteAct);
|
|---|
| 405 |
|
|---|
| 406 | controlwidget->addAction(volumeslider_action);
|
|---|
| 407 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 408 |
|
|---|
| 409 | /*
|
|---|
| 410 | controlwidget->show();
|
|---|
| 411 | */
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | void DefaultGui::createFloatingControl() {
|
|---|
| 415 | // Floating control
|
|---|
| 416 | floating_control = new AutohideWidget(panel);
|
|---|
| 417 | floating_control->setAutoHide(true);
|
|---|
| 418 |
|
|---|
| 419 | EditableToolbar * iw = new EditableToolbar(floating_control);
|
|---|
| 420 | iw->setObjectName("floating_control");
|
|---|
| 421 | connect(iw, SIGNAL(iconSizeChanged(const QSize &)), this, SLOT(adjustFloatingControlSize()));
|
|---|
| 422 |
|
|---|
| 423 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 424 | QStringList floatingcontrol_actions;
|
|---|
| 425 | floatingcontrol_actions << "play" << "pause" << "stop" << "separator";
|
|---|
| 426 | #if MINI_ARROW_BUTTONS
|
|---|
| 427 | floatingcontrol_actions << "rewindbutton_action";
|
|---|
| 428 | #else
|
|---|
| 429 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
|---|
| 430 | #endif
|
|---|
| 431 | floatingcontrol_actions << "timeslider_action";
|
|---|
| 432 | #if MINI_ARROW_BUTTONS
|
|---|
| 433 | floatingcontrol_actions << "forwardbutton_action";
|
|---|
| 434 | #else
|
|---|
| 435 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
|---|
| 436 | #endif
|
|---|
| 437 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action" << "separator" << "timelabel_action";
|
|---|
| 438 | iw->setDefaultActions(floatingcontrol_actions);
|
|---|
| 439 | #else
|
|---|
| 440 | iw->addAction(playAct);
|
|---|
| 441 | iw->addAction(pauseAct);
|
|---|
| 442 | iw->addAction(stopAct);
|
|---|
| 443 | iw->addSeparator();
|
|---|
| 444 |
|
|---|
| 445 | #if MINI_ARROW_BUTTONS
|
|---|
| 446 | iw->addAction( rewindbutton_action );
|
|---|
| 447 | #else
|
|---|
| 448 | iw->addAction(rewind3Act);
|
|---|
| 449 | iw->addAction(rewind2Act);
|
|---|
| 450 | iw->addAction(rewind1Act);
|
|---|
| 451 | #endif
|
|---|
| 452 |
|
|---|
| 453 | iw->addAction(timeslider_action);
|
|---|
| 454 |
|
|---|
| 455 | #if MINI_ARROW_BUTTONS
|
|---|
| 456 | iw->addAction( forwardbutton_action );
|
|---|
| 457 | #else
|
|---|
| 458 | iw->addAction(forward1Act);
|
|---|
| 459 | iw->addAction(forward2Act);
|
|---|
| 460 | iw->addAction(forward3Act);
|
|---|
| 461 | #endif
|
|---|
| 462 |
|
|---|
| 463 | iw->addSeparator();
|
|---|
| 464 | iw->addAction(fullscreenAct);
|
|---|
| 465 | iw->addAction(muteAct);
|
|---|
| 466 | iw->addAction(volumeslider_action);
|
|---|
| 467 | iw->addSeparator();
|
|---|
| 468 | iw->addAction(time_label_action);
|
|---|
| 469 | #endif // USE_CONFIGURABLE_TOOLBARS
|
|---|
| 470 |
|
|---|
| 471 | floating_control->setInternalWidget(iw);
|
|---|
| 472 |
|
|---|
| 473 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
|---|
| 474 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
|---|
| 475 | /*
|
|---|
| 476 | floating_control->addAction(exitFullscreenAct);
|
|---|
| 477 | floating_control->addAction(exitAct);
|
|---|
| 478 | */
|
|---|
| 479 | //floating_control->addActions(actions());
|
|---|
| 480 | #endif
|
|---|
| 481 |
|
|---|
| 482 | #if !USE_CONFIGURABLE_TOOLBARS
|
|---|
| 483 | floating_control->adjustSize();
|
|---|
| 484 | #endif
|
|---|
| 485 |
|
|---|
| 486 | floating_control->hide();
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | void DefaultGui::createStatusBar() {
|
|---|
| 490 | qDebug("DefaultGui::createStatusBar");
|
|---|
| 491 |
|
|---|
| 492 | time_display = new QLabel( statusBar() );
|
|---|
| 493 | time_display->setObjectName("time_display");
|
|---|
| 494 | time_display->setAlignment(Qt::AlignRight);
|
|---|
| 495 | time_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 496 | time_display->setText(" 88:88:88 / 88:88:88 ");
|
|---|
| 497 | time_display->setMinimumSize(time_display->sizeHint());
|
|---|
| 498 |
|
|---|
| 499 | frame_display = new QLabel( statusBar() );
|
|---|
| 500 | frame_display->setObjectName("frame_display");
|
|---|
| 501 | frame_display->setAlignment(Qt::AlignRight);
|
|---|
| 502 | frame_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 503 | frame_display->setText("88888888");
|
|---|
| 504 | frame_display->setMinimumSize(frame_display->sizeHint());
|
|---|
| 505 |
|
|---|
| 506 | ab_section_display = new QLabel( statusBar() );
|
|---|
| 507 | ab_section_display->setObjectName("ab_section_display");
|
|---|
| 508 | ab_section_display->setAlignment(Qt::AlignRight);
|
|---|
| 509 | ab_section_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 510 | // ab_section_display->setText("A:0:00:00 B:0:00:00");
|
|---|
| 511 | // ab_section_display->setMinimumSize(ab_section_display->sizeHint());
|
|---|
| 512 |
|
|---|
| 513 | video_info_display = new QLabel( statusBar() );
|
|---|
| 514 | video_info_display->setObjectName("video_info_display");
|
|---|
| 515 | video_info_display->setAlignment(Qt::AlignRight);
|
|---|
| 516 | video_info_display->setFrameShape(QFrame::NoFrame);
|
|---|
| 517 |
|
|---|
| 518 | #ifdef BUFFERING_ANIMATION
|
|---|
| 519 | state_widget = new StateWidget(statusBar());
|
|---|
| 520 | connect(core, SIGNAL(stateChanged(Core::State)), state_widget, SLOT(watchState(Core::State)));
|
|---|
| 521 | statusBar()->addPermanentWidget(state_widget);
|
|---|
| 522 | #endif
|
|---|
| 523 |
|
|---|
| 524 | statusBar()->setAutoFillBackground(true);
|
|---|
| 525 |
|
|---|
| 526 | ColorUtils::setBackgroundColor( statusBar(), QColor(0,0,0) );
|
|---|
| 527 | ColorUtils::setForegroundColor( statusBar(), QColor(255,255,255) );
|
|---|
| 528 | ColorUtils::setBackgroundColor( time_display, QColor(0,0,0) );
|
|---|
| 529 | ColorUtils::setForegroundColor( time_display, QColor(255,255,255) );
|
|---|
| 530 | ColorUtils::setBackgroundColor( frame_display, QColor(0,0,0) );
|
|---|
| 531 | ColorUtils::setForegroundColor( frame_display, QColor(255,255,255) );
|
|---|
| 532 | ColorUtils::setBackgroundColor( ab_section_display, QColor(0,0,0) );
|
|---|
| 533 | ColorUtils::setForegroundColor( ab_section_display, QColor(255,255,255) );
|
|---|
| 534 | ColorUtils::setBackgroundColor( video_info_display, QColor(0,0,0) );
|
|---|
| 535 | ColorUtils::setForegroundColor( video_info_display, QColor(255,255,255) );
|
|---|
| 536 | statusBar()->setSizeGripEnabled(false);
|
|---|
| 537 |
|
|---|
| 538 | statusBar()->addPermanentWidget( video_info_display );
|
|---|
| 539 | statusBar()->addPermanentWidget( ab_section_display );
|
|---|
| 540 |
|
|---|
| 541 | statusBar()->showMessage( tr("Ready") );
|
|---|
| 542 | statusBar()->addPermanentWidget( frame_display, 0 );
|
|---|
| 543 | frame_display->setText( "0" );
|
|---|
| 544 |
|
|---|
| 545 | statusBar()->addPermanentWidget( time_display, 0 );
|
|---|
| 546 | time_display->setText(" 00:00:00 / 00:00:00 ");
|
|---|
| 547 |
|
|---|
| 548 | time_display->show();
|
|---|
| 549 | frame_display->hide();
|
|---|
| 550 | ab_section_display->show();
|
|---|
| 551 | video_info_display->hide();
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | void DefaultGui::retranslateStrings() {
|
|---|
| 555 | BaseGuiPlus::retranslateStrings();
|
|---|
| 556 |
|
|---|
| 557 | // Change the icon of the play/pause action
|
|---|
| 558 | playOrPauseAct->setIcon(Images::icon("play"));
|
|---|
| 559 |
|
|---|
| 560 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
|---|
| 561 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
|---|
| 562 |
|
|---|
| 563 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
|---|
| 564 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
|---|
| 565 |
|
|---|
| 566 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
|---|
| 567 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
|---|
| 568 |
|
|---|
| 569 | toolbar2->setWindowTitle( tr("&Language toolbar") );
|
|---|
| 570 | toolbar2->toggleViewAction()->setIcon(Images::icon("lang_toolbar"));
|
|---|
| 571 |
|
|---|
| 572 | select_audio->setText( tr("Audio") );
|
|---|
| 573 | select_subtitle->setText( tr("Subtitle") );
|
|---|
| 574 |
|
|---|
| 575 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
|---|
| 576 | viewFrameCounterAct->change( Images::icon("frame_counter"), tr("&Frame counter") );
|
|---|
| 577 |
|
|---|
| 578 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 579 | editToolbar1Act->change( tr("Edit main &toolbar") );
|
|---|
| 580 | editControl1Act->change( tr("Edit &control bar") );
|
|---|
| 581 | editControl2Act->change( tr("Edit m&ini control bar") );
|
|---|
| 582 | editFloatingControlAct->change( tr("Edit &floating control") );
|
|---|
| 583 | #endif
|
|---|
| 584 |
|
|---|
| 585 | #ifdef BUFFERING_ANIMATION
|
|---|
| 586 | state_widget->setAnimation(Images::file("buffering.gif"));
|
|---|
| 587 | #endif
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 | void DefaultGui::displayTime(QString text) {
|
|---|
| 592 | time_display->setText( text );
|
|---|
| 593 | time_label_action->setText(text);
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | void DefaultGui::displayFrame(int frame) {
|
|---|
| 597 | if (frame_display->isVisible()) {
|
|---|
| 598 | frame_display->setNum( frame );
|
|---|
| 599 | }
|
|---|
| 600 | }
|
|---|
| 601 |
|
|---|
| 602 | void DefaultGui::displayABSection(int secs_a, int secs_b) {
|
|---|
| 603 | QString s;
|
|---|
| 604 | if (secs_a > -1) s = tr("A:%1").arg(Helper::formatTime(secs_a));
|
|---|
| 605 |
|
|---|
| 606 | if (secs_b > -1) {
|
|---|
| 607 | if (!s.isEmpty()) s += " ";
|
|---|
| 608 | s += tr("B:%1").arg(Helper::formatTime(secs_b));
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | ab_section_display->setText( s );
|
|---|
| 612 |
|
|---|
| 613 | ab_section_display->setVisible( !s.isEmpty() );
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | void DefaultGui::displayVideoInfo(int width, int height, double fps) {
|
|---|
| 617 | if ((width != 0) && (height != 0)) {
|
|---|
| 618 | video_info_display->setText(tr("%1x%2 %3 fps", "width + height + fps").arg(width).arg(height).arg(fps));
|
|---|
| 619 | } else {
|
|---|
| 620 | video_info_display->setText(" ");
|
|---|
| 621 | }
|
|---|
| 622 | }
|
|---|
| 623 |
|
|---|
| 624 | void DefaultGui::updateWidgets() {
|
|---|
| 625 | qDebug("DefaultGui::updateWidgets");
|
|---|
| 626 |
|
|---|
| 627 | BaseGuiPlus::updateWidgets();
|
|---|
| 628 |
|
|---|
| 629 | panel->setFocus();
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | void DefaultGui::applyNewPreferences() {
|
|---|
| 633 | qDebug("DefaultGui::applyNewPreferences");
|
|---|
| 634 |
|
|---|
| 635 | if ((pref->compact_mode) && (pref->floating_display_in_compact_mode)) {
|
|---|
| 636 | reconfigureFloatingControl();
|
|---|
| 637 | floating_control->activate();
|
|---|
| 638 | } else {
|
|---|
| 639 | floating_control->deactivate();
|
|---|
| 640 | }
|
|---|
| 641 |
|
|---|
| 642 | BaseGuiPlus::applyNewPreferences();
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 | void DefaultGui::reconfigureFloatingControl() {
|
|---|
| 646 | floating_control->setMargin(pref->floating_control_margin);
|
|---|
| 647 | floating_control->setPercWidth(pref->floating_control_width);
|
|---|
| 648 | floating_control->setAnimated(pref->floating_control_animated);
|
|---|
| 649 | floating_control->setActivationArea( (AutohideWidget::Activation) pref->floating_activation_area);
|
|---|
| 650 | floating_control->setHideDelay(pref->floating_hide_delay);
|
|---|
| 651 | }
|
|---|
| 652 |
|
|---|
| 653 | void DefaultGui::aboutToEnterFullscreen() {
|
|---|
| 654 | qDebug("DefaultGui::aboutToEnterFullscreen");
|
|---|
| 655 |
|
|---|
| 656 | BaseGuiPlus::aboutToEnterFullscreen();
|
|---|
| 657 |
|
|---|
| 658 | // Show floating_control
|
|---|
| 659 | reconfigureFloatingControl();
|
|---|
| 660 | floating_control->deactivate(); // Hide the control in case it was running from compact mode
|
|---|
| 661 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
|---|
| 662 |
|
|---|
| 663 |
|
|---|
| 664 | // Save visibility of toolbars
|
|---|
| 665 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
|---|
| 666 | fullscreen_toolbar2_was_visible = toolbar2->isVisible();
|
|---|
| 667 |
|
|---|
| 668 | if (!pref->compact_mode) {
|
|---|
| 669 | //menuBar()->hide();
|
|---|
| 670 | //statusBar()->hide();
|
|---|
| 671 | controlwidget->hide();
|
|---|
| 672 | controlwidget_mini->hide();
|
|---|
| 673 | toolbar1->hide();
|
|---|
| 674 | toolbar2->hide();
|
|---|
| 675 | }
|
|---|
| 676 | }
|
|---|
| 677 |
|
|---|
| 678 | void DefaultGui::aboutToExitFullscreen() {
|
|---|
| 679 | qDebug("DefaultGui::aboutToExitFullscreen");
|
|---|
| 680 |
|
|---|
| 681 | BaseGuiPlus::aboutToExitFullscreen();
|
|---|
| 682 |
|
|---|
| 683 | // Hide floating_control
|
|---|
| 684 | if (!pref->compact_mode || !pref->floating_display_in_compact_mode) {
|
|---|
| 685 | floating_control->deactivate();
|
|---|
| 686 | }
|
|---|
| 687 |
|
|---|
| 688 | if (!pref->compact_mode) {
|
|---|
| 689 | //menuBar()->show();
|
|---|
| 690 | //statusBar()->show();
|
|---|
| 691 | controlwidget->show();
|
|---|
| 692 |
|
|---|
| 693 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
|---|
| 694 | toolbar2->setVisible( fullscreen_toolbar2_was_visible );
|
|---|
| 695 | }
|
|---|
| 696 | }
|
|---|
| 697 |
|
|---|
| 698 | void DefaultGui::aboutToEnterCompactMode() {
|
|---|
| 699 |
|
|---|
| 700 | BaseGuiPlus::aboutToEnterCompactMode();
|
|---|
| 701 |
|
|---|
| 702 | // Show floating_control
|
|---|
| 703 | if (pref->floating_display_in_compact_mode) {
|
|---|
| 704 | reconfigureFloatingControl();
|
|---|
| 705 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
|---|
| 706 | }
|
|---|
| 707 |
|
|---|
| 708 |
|
|---|
| 709 | // Save visibility of toolbars
|
|---|
| 710 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
|---|
| 711 | compact_toolbar2_was_visible = toolbar2->isVisible();
|
|---|
| 712 |
|
|---|
| 713 | //menuBar()->hide();
|
|---|
| 714 | //statusBar()->hide();
|
|---|
| 715 | controlwidget->hide();
|
|---|
| 716 | controlwidget_mini->hide();
|
|---|
| 717 | toolbar1->hide();
|
|---|
| 718 | toolbar2->hide();
|
|---|
| 719 | }
|
|---|
| 720 |
|
|---|
| 721 | void DefaultGui::aboutToExitCompactMode() {
|
|---|
| 722 | BaseGuiPlus::aboutToExitCompactMode();
|
|---|
| 723 |
|
|---|
| 724 | // Hide floating_control
|
|---|
| 725 | if (pref->floating_display_in_compact_mode) {
|
|---|
| 726 | floating_control->deactivate();
|
|---|
| 727 | }
|
|---|
| 728 |
|
|---|
| 729 | //menuBar()->show();
|
|---|
| 730 | //statusBar()->show();
|
|---|
| 731 | controlwidget->show();
|
|---|
| 732 |
|
|---|
| 733 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
|---|
| 734 | toolbar2->setVisible( compact_toolbar2_was_visible );
|
|---|
| 735 |
|
|---|
| 736 | // Recheck size of controlwidget
|
|---|
| 737 | resizeEvent( new QResizeEvent( size(), size() ) );
|
|---|
| 738 | }
|
|---|
| 739 |
|
|---|
| 740 | void DefaultGui::resizeEvent( QResizeEvent * ) {
|
|---|
| 741 | /*
|
|---|
| 742 | qDebug("defaultGui::resizeEvent");
|
|---|
| 743 | qDebug(" controlwidget width: %d", controlwidget->width() );
|
|---|
| 744 | qDebug(" controlwidget_mini width: %d", controlwidget_mini->width() );
|
|---|
| 745 | */
|
|---|
| 746 |
|
|---|
| 747 | #if QT_VERSION < 0x040000
|
|---|
| 748 | #define LIMIT 470
|
|---|
| 749 | #else
|
|---|
| 750 | #define LIMIT 570
|
|---|
| 751 | #endif
|
|---|
| 752 |
|
|---|
| 753 | if ( (controlwidget->isVisible()) && (width() < LIMIT) ) {
|
|---|
| 754 | controlwidget->hide();
|
|---|
| 755 | controlwidget_mini->show();
|
|---|
| 756 | }
|
|---|
| 757 | else
|
|---|
| 758 | if ( (controlwidget_mini->isVisible()) && (width() > LIMIT) ) {
|
|---|
| 759 | controlwidget_mini->hide();
|
|---|
| 760 | controlwidget->show();
|
|---|
| 761 | }
|
|---|
| 762 | }
|
|---|
| 763 |
|
|---|
| 764 | #if USE_MINIMUMSIZE
|
|---|
| 765 | QSize DefaultGui::minimumSizeHint() const {
|
|---|
| 766 | return QSize(controlwidget_mini->sizeHint().width(), 0);
|
|---|
| 767 | }
|
|---|
| 768 | #endif
|
|---|
| 769 |
|
|---|
| 770 | void DefaultGui::adjustFloatingControlSize() {
|
|---|
| 771 | qDebug("DefaultGui::adjustFloatingControlSize");
|
|---|
| 772 | //floating_control->adjustSize();
|
|---|
| 773 | QWidget *iw = floating_control->internalWidget();
|
|---|
| 774 | QSize iws = iw->size();
|
|---|
| 775 | QMargins m = floating_control->contentsMargins();
|
|---|
| 776 | int new_height = iws.height() + m.top() + m.bottom();
|
|---|
| 777 | if (new_height < 32) new_height = 32;
|
|---|
| 778 | floating_control->resize(floating_control->width(), new_height);
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | void DefaultGui::saveConfig() {
|
|---|
| 782 | qDebug("DefaultGui::saveConfig");
|
|---|
| 783 |
|
|---|
| 784 | QSettings * set = settings;
|
|---|
| 785 |
|
|---|
| 786 | set->beginGroup( "default_gui");
|
|---|
| 787 |
|
|---|
| 788 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
|---|
| 789 | set->setValue("frame_counter", viewFrameCounterAct->isChecked());
|
|---|
| 790 |
|
|---|
| 791 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
|---|
| 792 | set->setValue("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible);
|
|---|
| 793 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
|---|
| 794 | set->setValue("compact_toolbar2_was_visible", compact_toolbar2_was_visible);
|
|---|
| 795 |
|
|---|
| 796 | if (pref->save_window_size_on_exit) {
|
|---|
| 797 | qDebug("DefaultGui::saveConfig: w: %d h: %d", width(), height());
|
|---|
| 798 | set->setValue( "pos", pos() );
|
|---|
| 799 | set->setValue( "size", size() );
|
|---|
| 800 | set->setValue( "state", (int) windowState() );
|
|---|
| 801 | }
|
|---|
| 802 |
|
|---|
| 803 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
|---|
| 804 |
|
|---|
| 805 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 806 | set->beginGroup( "actions" );
|
|---|
| 807 | set->setValue("toolbar1", toolbar1->actionsToStringList() );
|
|---|
| 808 | set->setValue("controlwidget", controlwidget->actionsToStringList() );
|
|---|
| 809 | set->setValue("controlwidget_mini", controlwidget_mini->actionsToStringList() );
|
|---|
| 810 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
|---|
| 811 | set->setValue("floating_control", iw->actionsToStringList() );
|
|---|
| 812 | set->setValue("toolbar1_version", TOOLBAR_VERSION);
|
|---|
| 813 | set->endGroup();
|
|---|
| 814 |
|
|---|
| 815 | set->beginGroup("toolbars_icon_size");
|
|---|
| 816 | set->setValue("toolbar1", toolbar1->iconSize());
|
|---|
| 817 | set->setValue("controlwidget", controlwidget->iconSize());
|
|---|
| 818 | set->setValue("controlwidget_mini", controlwidget_mini->iconSize());
|
|---|
| 819 | set->setValue("floating_control", iw->iconSize());
|
|---|
| 820 | set->endGroup();
|
|---|
| 821 | #endif
|
|---|
| 822 |
|
|---|
| 823 | set->endGroup();
|
|---|
| 824 | }
|
|---|
| 825 |
|
|---|
| 826 | void DefaultGui::loadConfig() {
|
|---|
| 827 | qDebug("DefaultGui::loadConfig");
|
|---|
| 828 |
|
|---|
| 829 | QSettings * set = settings;
|
|---|
| 830 |
|
|---|
| 831 | set->beginGroup( "default_gui");
|
|---|
| 832 |
|
|---|
| 833 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
|---|
| 834 | viewFrameCounterAct->setChecked(set->value("frame_counter", false).toBool());
|
|---|
| 835 |
|
|---|
| 836 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
|---|
| 837 | fullscreen_toolbar2_was_visible = set->value("fullscreen_toolbar2_was_visible", fullscreen_toolbar2_was_visible).toBool();
|
|---|
| 838 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
|---|
| 839 | compact_toolbar2_was_visible = set->value("compact_toolbar2_was_visible", compact_toolbar2_was_visible).toBool();
|
|---|
| 840 |
|
|---|
| 841 | if (pref->save_window_size_on_exit) {
|
|---|
| 842 | QPoint p = set->value("pos", pos()).toPoint();
|
|---|
| 843 | QSize s = set->value("size", size()).toSize();
|
|---|
| 844 |
|
|---|
| 845 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
|---|
| 846 | s = pref->default_size;
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | move(p);
|
|---|
| 850 | resize(s);
|
|---|
| 851 |
|
|---|
| 852 | setWindowState( (Qt::WindowStates) set->value("state", 0).toInt() );
|
|---|
| 853 |
|
|---|
| 854 | if (!DesktopInfo::isInsideScreen(this)) {
|
|---|
| 855 | move(0,0);
|
|---|
| 856 | qWarning("DefaultGui::loadConfig: window is outside of the screen, moved to 0x0");
|
|---|
| 857 | }
|
|---|
| 858 | }
|
|---|
| 859 |
|
|---|
| 860 | #if USE_CONFIGURABLE_TOOLBARS
|
|---|
| 861 | set->beginGroup( "actions" );
|
|---|
| 862 | int toolbar_version = set->value("toolbar1_version", 0).toInt();
|
|---|
| 863 | if (toolbar_version >= TOOLBAR_VERSION) {
|
|---|
| 864 | toolbar1->setActionsFromStringList( set->value("toolbar1", toolbar1->defaultActions()).toStringList() );
|
|---|
| 865 | } else {
|
|---|
| 866 | qDebug("DefaultGui::loadConfig: toolbar too old, loading default one");
|
|---|
| 867 | toolbar1->setActionsFromStringList( toolbar1->defaultActions() );
|
|---|
| 868 | }
|
|---|
| 869 | controlwidget->setActionsFromStringList( set->value("controlwidget", controlwidget->defaultActions()).toStringList() );
|
|---|
| 870 | controlwidget_mini->setActionsFromStringList( set->value("controlwidget_mini", controlwidget_mini->defaultActions()).toStringList() );
|
|---|
| 871 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
|---|
| 872 | iw->setActionsFromStringList( set->value("floating_control", iw->defaultActions()).toStringList() );
|
|---|
| 873 | set->endGroup();
|
|---|
| 874 |
|
|---|
| 875 | set->beginGroup("toolbars_icon_size");
|
|---|
| 876 | toolbar1->setIconSize(set->value("toolbar1", toolbar1->iconSize()).toSize());
|
|---|
| 877 | controlwidget->setIconSize(set->value("controlwidget", controlwidget->iconSize()).toSize());
|
|---|
| 878 | controlwidget_mini->setIconSize(set->value("controlwidget_mini", controlwidget_mini->iconSize()).toSize());
|
|---|
| 879 | iw->setIconSize(set->value("floating_control", iw->iconSize()).toSize());
|
|---|
| 880 | set->endGroup();
|
|---|
| 881 |
|
|---|
| 882 | floating_control->adjustSize();
|
|---|
| 883 | #endif
|
|---|
| 884 |
|
|---|
| 885 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
|---|
| 886 |
|
|---|
| 887 | #if DOCK_PLAYLIST
|
|---|
| 888 | qDebug("DefaultGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
|---|
| 889 | qDebug("DefaultGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
|---|
| 890 | qDebug("DefaultGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
|---|
| 891 | #endif
|
|---|
| 892 |
|
|---|
| 893 | set->endGroup();
|
|---|
| 894 |
|
|---|
| 895 | updateWidgets();
|
|---|
| 896 | }
|
|---|
| 897 |
|
|---|
| 898 | #include "moc_defaultgui.cpp"
|
|---|