[137] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[137] | 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 "skingui.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"
|
---|
[165] | 29 | #include "autohidewidget.h"
|
---|
[137] | 30 | #include "desktopinfo.h"
|
---|
| 31 | #include "editabletoolbar.h"
|
---|
| 32 | #include "mediabarpanel.h"
|
---|
| 33 | #include "actionseditor.h"
|
---|
| 34 |
|
---|
| 35 | #if DOCK_PLAYLIST
|
---|
| 36 | #include "playlistdock.h"
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | #include <QMenu>
|
---|
| 40 | #include <QSettings>
|
---|
| 41 | #include <QLabel>
|
---|
| 42 | #include <QStatusBar>
|
---|
| 43 | #include <QPushButton>
|
---|
| 44 | #include <QToolButton>
|
---|
| 45 | #include <QMenuBar>
|
---|
| 46 | #include <QLayout>
|
---|
| 47 | #include <QApplication>
|
---|
| 48 | #include <QDir>
|
---|
| 49 |
|
---|
| 50 | #define TOOLBAR_VERSION 1
|
---|
| 51 |
|
---|
| 52 | using namespace Global;
|
---|
| 53 |
|
---|
| 54 | SkinGui::SkinGui( QWidget * parent, Qt::WindowFlags flags )
|
---|
| 55 | : BaseGuiPlus( parent, flags )
|
---|
[165] | 56 | , was_muted(false)
|
---|
[137] | 57 | {
|
---|
| 58 | createActions();
|
---|
| 59 | createMainToolBars();
|
---|
| 60 | createControlWidget();
|
---|
| 61 | createFloatingControl();
|
---|
| 62 | createMenus();
|
---|
| 63 |
|
---|
| 64 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 65 | connect( editToolbar1Act, SIGNAL(triggered()),
|
---|
| 66 | toolbar1, SLOT(edit()) );
|
---|
[165] | 67 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
| 68 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
| 69 | iw->takeAvailableActionsFrom(this);
|
---|
| 70 | connect( editFloatingControlAct, SIGNAL(triggered()), iw, SLOT(edit()) );
|
---|
[137] | 71 | #endif
|
---|
| 72 | #endif
|
---|
| 73 |
|
---|
| 74 | retranslateStrings();
|
---|
| 75 |
|
---|
| 76 | loadConfig();
|
---|
| 77 |
|
---|
| 78 | //if (playlist_visible) showPlaylist(true);
|
---|
| 79 |
|
---|
| 80 | if (pref->compact_mode) {
|
---|
| 81 | controlwidget->hide();
|
---|
| 82 | toolbar1->hide();
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | statusBar()->hide();
|
---|
| 86 |
|
---|
[176] | 87 | applyStyles();
|
---|
[165] | 88 | mediaBarPanel->setVolume(50);
|
---|
[137] | 89 | }
|
---|
| 90 |
|
---|
| 91 | SkinGui::~SkinGui() {
|
---|
| 92 | saveConfig();
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | void SkinGui::createActions() {
|
---|
| 96 | qDebug("SkinGui::createActions");
|
---|
| 97 |
|
---|
| 98 | timeslider_action = createTimeSliderAction(this);
|
---|
| 99 | timeslider_action->disable();
|
---|
| 100 |
|
---|
| 101 | volumeslider_action = createVolumeSliderAction(this);
|
---|
| 102 | volumeslider_action->disable();
|
---|
| 103 |
|
---|
| 104 | // Create the time label
|
---|
[181] | 105 | time_label_action = createTimeLabelAction(TimeLabelAction::CurrentAndTotalTime, this);
|
---|
[137] | 106 | time_label_action->setObjectName("timelabel_action");
|
---|
| 107 |
|
---|
| 108 | #if MINI_ARROW_BUTTONS
|
---|
| 109 | QList<QAction*> rewind_actions;
|
---|
| 110 | rewind_actions << rewind1Act << rewind2Act << rewind3Act;
|
---|
| 111 | rewindbutton_action = new SeekingButton(rewind_actions, this);
|
---|
| 112 | rewindbutton_action->setObjectName("rewindbutton_action");
|
---|
| 113 |
|
---|
| 114 | QList<QAction*> forward_actions;
|
---|
| 115 | forward_actions << forward1Act << forward2Act << forward3Act;
|
---|
| 116 | forwardbutton_action = new SeekingButton(forward_actions, this);
|
---|
| 117 | forwardbutton_action->setObjectName("forwardbutton_action");
|
---|
| 118 | #endif
|
---|
| 119 |
|
---|
| 120 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 121 | editToolbar1Act = new MyAction( this, "edit_main_toolbar" );
|
---|
[165] | 122 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
[137] | 123 | editFloatingControlAct = new MyAction( this, "edit_floating_control" );
|
---|
| 124 | #endif
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 | playOrPauseAct->setCheckable(true);
|
---|
[156] | 128 |
|
---|
| 129 | viewVideoInfoAct = new MyAction(this, "toggle_video_info_skingui" );
|
---|
| 130 | viewVideoInfoAct->setCheckable(true);
|
---|
[176] | 131 |
|
---|
| 132 | scrollTitleAct = new MyAction(this, "toggle_scroll_title_skingui" );
|
---|
| 133 | scrollTitleAct->setCheckable(true);
|
---|
[137] | 134 | }
|
---|
| 135 |
|
---|
| 136 | #if AUTODISABLE_ACTIONS
|
---|
| 137 | void SkinGui::enableActionsOnPlaying() {
|
---|
| 138 | qDebug("SkinGui::enableActionsOnPlaying");
|
---|
| 139 | BaseGuiPlus::enableActionsOnPlaying();
|
---|
| 140 |
|
---|
| 141 | timeslider_action->enable();
|
---|
| 142 | volumeslider_action->enable();
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | void SkinGui::disableActionsOnStop() {
|
---|
| 146 | qDebug("SkinGui::disableActionsOnStop");
|
---|
| 147 | BaseGuiPlus::disableActionsOnStop();
|
---|
| 148 |
|
---|
| 149 | timeslider_action->disable();
|
---|
| 150 | volumeslider_action->disable();
|
---|
| 151 | }
|
---|
[176] | 152 | #endif // AUTODISABLE_ACTIONS
|
---|
[137] | 153 |
|
---|
| 154 | void SkinGui::togglePlayAction(Core::State state) {
|
---|
| 155 | qDebug("SkinGui::togglePlayAction");
|
---|
| 156 | BaseGuiPlus::togglePlayAction(state);
|
---|
| 157 |
|
---|
| 158 | if (state == Core::Playing) {
|
---|
| 159 | playOrPauseAct->setChecked(true);
|
---|
| 160 | }
|
---|
| 161 | else {
|
---|
| 162 | playOrPauseAct->setChecked(false);
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | void SkinGui::createMenus() {
|
---|
| 167 | menuBar()->setObjectName("menubar");
|
---|
| 168 | QFont font = menuBar()->font();
|
---|
| 169 | font.setPixelSize(11);
|
---|
| 170 | menuBar()->setFont(font);
|
---|
[165] | 171 | /*menuBar()->setFixedHeight(21);*/
|
---|
[137] | 172 |
|
---|
| 173 | toolbar_menu = new QMenu(this);
|
---|
| 174 | toolbar_menu->addAction(toolbar1->toggleViewAction());
|
---|
| 175 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 176 | toolbar_menu->addSeparator();
|
---|
| 177 | toolbar_menu->addAction(editToolbar1Act);
|
---|
[165] | 178 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
[137] | 179 | toolbar_menu->addAction(editFloatingControlAct);
|
---|
| 180 | #endif
|
---|
| 181 | #endif
|
---|
[156] | 182 |
|
---|
| 183 | statusbar_menu = new QMenu(this);
|
---|
| 184 | statusbar_menu->addAction(viewVideoInfoAct);
|
---|
[176] | 185 | statusbar_menu->addAction(scrollTitleAct);
|
---|
[181] | 186 |
|
---|
| 187 | populateMainMenu();
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | void SkinGui::populateMainMenu() {
|
---|
| 191 | BaseGuiPlus::populateMainMenu();
|
---|
| 192 |
|
---|
| 193 | optionsMenu->addSeparator();
|
---|
| 194 | optionsMenu->addMenu(toolbar_menu);
|
---|
[156] | 195 | optionsMenu->addMenu(statusbar_menu);
|
---|
[137] | 196 | }
|
---|
| 197 |
|
---|
| 198 | QMenu * SkinGui::createPopupMenu() {
|
---|
| 199 | QMenu * m = new QMenu(this);
|
---|
| 200 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 201 | m->addAction(editToolbar1Act);
|
---|
[165] | 202 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
[137] | 203 | m->addAction(editFloatingControlAct);
|
---|
| 204 | #endif
|
---|
| 205 | #else
|
---|
| 206 | m->addAction(toolbar1->toggleViewAction());
|
---|
| 207 | #endif
|
---|
| 208 | return m;
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | void SkinGui::createMainToolBars() {
|
---|
| 212 | toolbar1 = new EditableToolbar( this );
|
---|
| 213 | toolbar1->setObjectName("toolbar");
|
---|
| 214 | toolbar1->setMovable(false);
|
---|
[176] | 215 | //toolbar1->setFixedHeight(35);
|
---|
[137] | 216 | addToolBar(Qt::TopToolBarArea, toolbar1);
|
---|
| 217 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 218 | QStringList toolbar1_actions;
|
---|
| 219 | toolbar1_actions << "open_file" << "open_url" << "favorites_menu" << "separator"
|
---|
| 220 | << "screenshot" << "separator" << "show_file_properties"
|
---|
| 221 | << "show_find_sub_dialog" << "show_tube_browser" << "show_preferences";
|
---|
| 222 | toolbar1->setDefaultActions(toolbar1_actions);
|
---|
| 223 | #else
|
---|
| 224 | toolbar1->addAction(openFileAct);
|
---|
| 225 | toolbar1->addAction(openURLAct);
|
---|
| 226 | toolbar1->addSeparator();
|
---|
| 227 | toolbar1->addAction(compactAct);
|
---|
| 228 | toolbar1->addAction(fullscreenAct);
|
---|
| 229 | toolbar1->addSeparator();
|
---|
| 230 | toolbar1->addAction(screenshotAct);
|
---|
| 231 | toolbar1->addSeparator();
|
---|
| 232 | toolbar1->addAction(showPropertiesAct);
|
---|
| 233 | toolbar1->addAction(showFindSubtitlesDialogAct);
|
---|
| 234 | toolbar1->addAction(showPreferencesAct);
|
---|
| 235 | // Test:
|
---|
| 236 | //toolbar1->addSeparator();
|
---|
| 237 | //toolbar1->addAction(timeslider_action);
|
---|
| 238 | //toolbar1->addAction(volumeslider_action);
|
---|
| 239 | #endif
|
---|
| 240 |
|
---|
| 241 | // Modify toolbars' actions
|
---|
| 242 | QAction *tba;
|
---|
| 243 | tba = toolbar1->toggleViewAction();
|
---|
| 244 | tba->setObjectName("show_main_toolbar");
|
---|
| 245 | tba->setShortcut(Qt::Key_F5);
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | void SkinGui::createControlWidget() {
|
---|
| 250 | qDebug("SkinGui::createControlWidget");
|
---|
| 251 |
|
---|
| 252 | controlwidget = new QToolBar( this );
|
---|
| 253 | controlwidget->setObjectName("controlwidget");
|
---|
[156] | 254 | controlwidget->setLayoutDirection(Qt::LeftToRight);
|
---|
[137] | 255 | controlwidget->setStyleSheet("QToolBar { spacing: 0px; }");
|
---|
| 256 | controlwidget->setMovable(false);
|
---|
| 257 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
---|
| 258 |
|
---|
| 259 | mediaBarPanel = new MediaBarPanel(panel);
|
---|
| 260 | mediaBarPanel->setObjectName("mediabar-panel");
|
---|
| 261 | mediaBarPanel->setCore(core);
|
---|
| 262 | /* panel->layout()->addWidget(mediaBarPanel); */
|
---|
| 263 |
|
---|
| 264 | QList<QAction*> actions;
|
---|
| 265 | //actions << halveSpeedAct << playPrevAct << playOrPauseAct << stopAct << recordAct << playNextAct << doubleSpeedAct;
|
---|
| 266 | actions << rewind1Act << playPrevAct << playOrPauseAct << stopAct << playNextAct << forward1Act;
|
---|
| 267 | mediaBarPanel->setPlayControlActionCollection(actions);
|
---|
| 268 |
|
---|
| 269 | actions.clear();
|
---|
| 270 | //actions << timeslider_action << shuffleAct << repeatPlaylistAct;
|
---|
| 271 | QAction * shuffleAct = ActionsEditor::findAction(playlist, "pl_shuffle");
|
---|
| 272 | QAction * repeatPlaylistAct = ActionsEditor::findAction(playlist, "pl_repeat");
|
---|
| 273 | if (shuffleAct) actions << shuffleAct;
|
---|
| 274 | if (repeatPlaylistAct) actions << repeatPlaylistAct;
|
---|
| 275 | mediaBarPanel->setMediaPanelActionCollection(actions);
|
---|
| 276 | connect(core, SIGNAL(stateChanged(Core::State)), mediaBarPanel, SLOT(setMplayerState(Core::State)));
|
---|
| 277 |
|
---|
| 278 | actions.clear();
|
---|
| 279 | //actions << volumeslider_action << showPlaylistAct << fullscreenAct << equalizerAct;
|
---|
| 280 | actions << volumeslider_action << showPlaylistAct << fullscreenAct << videoEqualizerAct;
|
---|
| 281 | mediaBarPanel->setVolumeControlActionCollection(actions);
|
---|
| 282 |
|
---|
| 283 | actions.clear();
|
---|
| 284 | actions << openFileAct << openDirectoryAct << openDVDAct << openURLAct << screenshotAct << showPropertiesAct;
|
---|
| 285 | #ifdef FIND_SUBTITLES
|
---|
| 286 | actions << showFindSubtitlesDialogAct;
|
---|
| 287 | #endif
|
---|
| 288 | actions << showPreferencesAct;
|
---|
| 289 | mediaBarPanel->setToolbarActionCollection(actions);
|
---|
| 290 |
|
---|
| 291 | connect(mediaBarPanel, SIGNAL(volumeChanged(int)), core, SLOT(setVolume(int)));
|
---|
[142] | 292 | connect(mediaBarPanel, SIGNAL(volumeSliderMoved(int)), core, SLOT(setVolume(int)));
|
---|
[137] | 293 | connect(core, SIGNAL(volumeChanged(int)), mediaBarPanel, SLOT(setVolume(int)));
|
---|
| 294 |
|
---|
| 295 | #ifdef SEEKBAR_RESOLUTION
|
---|
| 296 | connect(mediaBarPanel, SIGNAL(seekerChanged(int)), core, SLOT(goToPosition(int)));
|
---|
| 297 | connect(core, SIGNAL(positionChanged(int)), mediaBarPanel, SLOT(setSeeker(int)));
|
---|
| 298 | #else
|
---|
| 299 | connect(mediaBarPanel, SIGNAL(seekerChanged(int)), core, SLOT(goToPos(int)));
|
---|
| 300 | connect(core, SIGNAL(posChanged(int)),mediaBarPanel, SLOT(setSeeker(int)));
|
---|
| 301 | #endif
|
---|
| 302 |
|
---|
[156] | 303 | connect( viewVideoInfoAct, SIGNAL(toggled(bool)),
|
---|
| 304 | mediaBarPanel, SLOT(setResolutionVisible(bool)) );
|
---|
| 305 |
|
---|
[176] | 306 | connect( scrollTitleAct, SIGNAL(toggled(bool)),
|
---|
| 307 | mediaBarPanel, SLOT(setScrollingEnabled(bool)) );
|
---|
| 308 |
|
---|
[165] | 309 | mediaBarPanelAction = controlwidget->addWidget(mediaBarPanel);
|
---|
[137] | 310 | }
|
---|
| 311 |
|
---|
| 312 | void SkinGui::createFloatingControl() {
|
---|
| 313 | // Floating control
|
---|
[181] | 314 | floating_control = new AutohideWidget(mplayerwindow);
|
---|
[165] | 315 | floating_control->setAutoHide(true);
|
---|
[137] | 316 |
|
---|
[165] | 317 | #ifndef SKIN_EDITABLE_CONTROL
|
---|
| 318 |
|
---|
| 319 | // floating_control->setInternalWidget(new QLabel("hello"));
|
---|
| 320 |
|
---|
| 321 | #else
|
---|
| 322 |
|
---|
| 323 | EditableToolbar * iw = new EditableToolbar(floating_control);
|
---|
| 324 |
|
---|
[137] | 325 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 326 | QStringList floatingcontrol_actions;
|
---|
| 327 | floatingcontrol_actions << "play" << "pause" << "stop" << "separator";
|
---|
| 328 | #if MINI_ARROW_BUTTONS
|
---|
| 329 | floatingcontrol_actions << "rewindbutton_action";
|
---|
| 330 | #else
|
---|
| 331 | floatingcontrol_actions << "rewind3" << "rewind2" << "rewind1";
|
---|
| 332 | #endif
|
---|
| 333 | floatingcontrol_actions << "timeslider_action";
|
---|
| 334 | #if MINI_ARROW_BUTTONS
|
---|
| 335 | floatingcontrol_actions << "forwardbutton_action";
|
---|
| 336 | #else
|
---|
| 337 | floatingcontrol_actions << "forward1" << "forward2" << "forward3";
|
---|
| 338 | #endif
|
---|
| 339 | floatingcontrol_actions << "separator" << "fullscreen" << "mute" << "volumeslider_action" << "separator" << "timelabel_action";
|
---|
[165] | 340 |
|
---|
| 341 | iw->setDefaultActions(floatingcontrol_actions);
|
---|
[137] | 342 | #else
|
---|
[165] | 343 | iw->addAction(playAct);
|
---|
| 344 | iw->addAction(pauseAct);
|
---|
| 345 | iw->addAction(stopAct);
|
---|
| 346 | iw->addSeparator();
|
---|
[137] | 347 |
|
---|
| 348 | #if MINI_ARROW_BUTTONS
|
---|
[165] | 349 | iw->addAction( rewindbutton_action );
|
---|
[137] | 350 | #else
|
---|
[165] | 351 | iw->addAction(rewind3Act);
|
---|
| 352 | iw->addAction(rewind2Act);
|
---|
| 353 | iw->addAction(rewind1Act);
|
---|
[137] | 354 | #endif
|
---|
| 355 |
|
---|
[165] | 356 | iw->addAction(timeslider_action);
|
---|
[137] | 357 |
|
---|
| 358 | #if MINI_ARROW_BUTTONS
|
---|
[165] | 359 | iw->addAction( forwardbutton_action );
|
---|
[137] | 360 | #else
|
---|
[165] | 361 | iw->addAction(forward1Act);
|
---|
| 362 | iw->addAction(forward2Act);
|
---|
| 363 | iw>addAction(forward3Act);
|
---|
[137] | 364 | #endif
|
---|
| 365 |
|
---|
[165] | 366 | iw->addSeparator();
|
---|
| 367 | iw->addAction(fullscreenAct);
|
---|
| 368 | iw->addAction(muteAct);
|
---|
| 369 | iw->addAction(volumeslider_action);
|
---|
| 370 | iw->addSeparator();
|
---|
| 371 | iw->addAction(time_label_action);
|
---|
[137] | 372 | #endif // USE_CONFIGURABLE_TOOLBARS
|
---|
| 373 |
|
---|
[165] | 374 | floating_control->setInternalWidget(iw);
|
---|
| 375 | #endif // SKIN_EDITABLE_CONTROL
|
---|
| 376 |
|
---|
| 377 | /*
|
---|
[137] | 378 | #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
---|
| 379 | // To make work the ESC key (exit fullscreen) and Ctrl-X (close) in Windows and OS2
|
---|
| 380 | floating_control->addAction(exitFullscreenAct);
|
---|
| 381 | floating_control->addAction(exitAct);
|
---|
| 382 | #endif
|
---|
[165] | 383 | */
|
---|
[137] | 384 |
|
---|
| 385 | #if !USE_CONFIGURABLE_TOOLBARS
|
---|
| 386 | floating_control->adjustSize();
|
---|
| 387 | #endif
|
---|
[165] | 388 |
|
---|
| 389 | floating_control->hide();
|
---|
[137] | 390 | }
|
---|
| 391 |
|
---|
| 392 | void SkinGui::retranslateStrings() {
|
---|
| 393 | BaseGuiPlus::retranslateStrings();
|
---|
| 394 |
|
---|
| 395 | toolbar_menu->menuAction()->setText( tr("&Toolbars") );
|
---|
| 396 | toolbar_menu->menuAction()->setIcon( Images::icon("toolbars") );
|
---|
| 397 |
|
---|
[156] | 398 | statusbar_menu->menuAction()->setText( tr("Status&bar") );
|
---|
| 399 | statusbar_menu->menuAction()->setIcon( Images::icon("statusbar") );
|
---|
| 400 |
|
---|
[137] | 401 | toolbar1->setWindowTitle( tr("&Main toolbar") );
|
---|
| 402 | toolbar1->toggleViewAction()->setIcon(Images::icon("main_toolbar"));
|
---|
| 403 |
|
---|
| 404 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 405 | editToolbar1Act->change( tr("Edit main &toolbar") );
|
---|
[165] | 406 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
[137] | 407 | editFloatingControlAct->change( tr("Edit &floating control") );
|
---|
| 408 | #endif
|
---|
| 409 | #endif
|
---|
| 410 |
|
---|
[156] | 411 | viewVideoInfoAct->change(Images::icon("view_video_info"), tr("&Video info") );
|
---|
[176] | 412 | scrollTitleAct->change(Images::icon("scroll_title"), tr("&Scroll title") );
|
---|
[137] | 413 | }
|
---|
| 414 |
|
---|
| 415 | void SkinGui::displayState(Core::State state) {
|
---|
| 416 | BaseGuiPlus::displayState(state);
|
---|
| 417 |
|
---|
| 418 | switch (state) {
|
---|
[176] | 419 | //case Core::Playing: mediaBarPanel->displayMessage( tr("Playing %1").arg(core->mdat.filename)); break;
|
---|
| 420 | case Core::Playing: mediaBarPanel->displayMessage( tr("Playing") ); break;
|
---|
[137] | 421 | case Core::Paused: mediaBarPanel->displayMessage( tr("Pause") ); break;
|
---|
| 422 | case Core::Stopped: mediaBarPanel->displayMessage( tr("Stop") ); break;
|
---|
[176] | 423 | case Core::Buffering: /* mediaBarPanel->displayMessage( tr("Buffering...") ); */ break;
|
---|
[137] | 424 | }
|
---|
| 425 | }
|
---|
| 426 |
|
---|
[156] | 427 | void SkinGui::displayMessage(QString message, int time) {
|
---|
| 428 | BaseGuiPlus::displayMessage(message, time);
|
---|
| 429 | mediaBarPanel->displayMessage(message, time);
|
---|
| 430 | }
|
---|
| 431 |
|
---|
[137] | 432 | void SkinGui::displayMessage(QString message) {
|
---|
| 433 | BaseGuiPlus::displayMessage(message);
|
---|
| 434 | mediaBarPanel->displayMessage(message);
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | void SkinGui::updateWidgets() {
|
---|
| 438 | qDebug("SkinGui::updateWidgets");
|
---|
| 439 |
|
---|
| 440 | BaseGuiPlus::updateWidgets();
|
---|
| 441 |
|
---|
| 442 | panel->setFocus();
|
---|
[165] | 443 |
|
---|
| 444 | bool muted = (pref->global_volume ? pref->mute : core->mset.mute);
|
---|
| 445 | if (was_muted != muted) {
|
---|
| 446 | was_muted = muted;
|
---|
| 447 | if (muted) {
|
---|
| 448 | mediaBarPanel->setVolume(0);
|
---|
| 449 | } else {
|
---|
| 450 | mediaBarPanel->setVolume(core->mset.volume);
|
---|
| 451 | }
|
---|
| 452 | }
|
---|
[137] | 453 | }
|
---|
| 454 |
|
---|
| 455 | void SkinGui::aboutToEnterFullscreen() {
|
---|
| 456 | qDebug("SkinGui::aboutToEnterFullscreen");
|
---|
| 457 |
|
---|
| 458 | BaseGuiPlus::aboutToEnterFullscreen();
|
---|
| 459 |
|
---|
[165] | 460 | #ifndef SKIN_EDITABLE_CONTROL
|
---|
| 461 | controlwidget->removeAction(mediaBarPanelAction);
|
---|
| 462 | floating_control->layout()->addWidget(mediaBarPanel);
|
---|
| 463 | mediaBarPanel->show();
|
---|
| 464 | floating_control->adjustSize();
|
---|
| 465 | #endif
|
---|
| 466 | floating_control->setMargin(pref->floating_control_margin);
|
---|
| 467 | floating_control->setPercWidth(pref->floating_control_width);
|
---|
| 468 | floating_control->setAnimated(pref->floating_control_animated);
|
---|
| 469 | floating_control->setActivationArea( (AutohideWidget::Activation) pref->floating_activation_area);
|
---|
| 470 | floating_control->setHideDelay(pref->floating_hide_delay);
|
---|
[176] | 471 | QTimer::singleShot(100, floating_control, SLOT(activate()));
|
---|
[165] | 472 |
|
---|
| 473 |
|
---|
[137] | 474 | // Save visibility of toolbars
|
---|
| 475 | fullscreen_toolbar1_was_visible = toolbar1->isVisible();
|
---|
| 476 |
|
---|
| 477 | if (!pref->compact_mode) {
|
---|
| 478 | controlwidget->hide();
|
---|
| 479 | toolbar1->hide();
|
---|
| 480 | }
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 | void SkinGui::aboutToExitFullscreen() {
|
---|
| 484 | qDebug("SkinGui::aboutToExitFullscreen");
|
---|
| 485 |
|
---|
| 486 | BaseGuiPlus::aboutToExitFullscreen();
|
---|
| 487 |
|
---|
[165] | 488 | floating_control->deactivate();
|
---|
| 489 | #ifndef SKIN_EDITABLE_CONTROL
|
---|
| 490 | floating_control->layout()->removeWidget(mediaBarPanel);
|
---|
| 491 | mediaBarPanelAction = controlwidget->addWidget(mediaBarPanel);
|
---|
| 492 | #endif
|
---|
[137] | 493 |
|
---|
| 494 | if (!pref->compact_mode) {
|
---|
| 495 | statusBar()->hide();
|
---|
| 496 | controlwidget->show();
|
---|
| 497 | toolbar1->setVisible( fullscreen_toolbar1_was_visible );
|
---|
| 498 | }
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | void SkinGui::aboutToEnterCompactMode() {
|
---|
| 502 |
|
---|
| 503 | BaseGuiPlus::aboutToEnterCompactMode();
|
---|
| 504 |
|
---|
| 505 | // Save visibility of toolbars
|
---|
| 506 | compact_toolbar1_was_visible = toolbar1->isVisible();
|
---|
| 507 |
|
---|
| 508 | controlwidget->hide();
|
---|
| 509 | toolbar1->hide();
|
---|
| 510 | }
|
---|
| 511 |
|
---|
| 512 | void SkinGui::aboutToExitCompactMode() {
|
---|
| 513 | BaseGuiPlus::aboutToExitCompactMode();
|
---|
| 514 |
|
---|
| 515 | statusBar()->hide();
|
---|
| 516 | controlwidget->show();
|
---|
| 517 | toolbar1->setVisible( compact_toolbar1_was_visible );
|
---|
| 518 |
|
---|
| 519 | // Recheck size of controlwidget
|
---|
| 520 | /* resizeEvent( new QResizeEvent( size(), size() ) ); */
|
---|
| 521 | }
|
---|
| 522 |
|
---|
| 523 | void SkinGui::saveConfig() {
|
---|
| 524 | qDebug("SkinGui::saveConfig");
|
---|
| 525 |
|
---|
| 526 | QSettings * set = settings;
|
---|
| 527 |
|
---|
| 528 | set->beginGroup( "skin_gui");
|
---|
| 529 |
|
---|
[156] | 530 | set->setValue("video_info", viewVideoInfoAct->isChecked());
|
---|
[176] | 531 | set->setValue("scroll_title", scrollTitleAct->isChecked());
|
---|
[156] | 532 |
|
---|
[137] | 533 | set->setValue("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible);
|
---|
| 534 | set->setValue("compact_toolbar1_was_visible", compact_toolbar1_was_visible);
|
---|
| 535 |
|
---|
| 536 | if (pref->save_window_size_on_exit) {
|
---|
| 537 | qDebug("SkinGui::saveConfig: w: %d h: %d", width(), height());
|
---|
| 538 | set->setValue( "pos", pos() );
|
---|
| 539 | set->setValue( "size", size() );
|
---|
[156] | 540 | set->setValue( "state", (int) windowState() );
|
---|
[137] | 541 | }
|
---|
| 542 |
|
---|
| 543 | set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
|
---|
| 544 |
|
---|
| 545 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 546 | set->beginGroup( "actions" );
|
---|
| 547 | set->setValue("toolbar1", toolbar1->actionsToStringList() );
|
---|
[165] | 548 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
| 549 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
| 550 | set->setValue("floating_control", iw->actionsToStringList() );
|
---|
[137] | 551 | #endif
|
---|
| 552 | set->setValue("toolbar1_version", TOOLBAR_VERSION);
|
---|
| 553 | set->endGroup();
|
---|
[176] | 554 |
|
---|
| 555 | set->beginGroup("toolbars_icon_size");
|
---|
| 556 | set->setValue("toolbar1", toolbar1->iconSize());
|
---|
| 557 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
| 558 | set->setValue("floating_control", iw->iconSize());
|
---|
| 559 | #endif
|
---|
| 560 | set->endGroup();
|
---|
[137] | 561 | #endif
|
---|
| 562 |
|
---|
| 563 | set->endGroup();
|
---|
| 564 | }
|
---|
| 565 |
|
---|
| 566 | void SkinGui::loadConfig() {
|
---|
| 567 | qDebug("SkinGui::loadConfig");
|
---|
| 568 |
|
---|
| 569 | QSettings * set = settings;
|
---|
| 570 |
|
---|
| 571 | set->beginGroup( "skin_gui");
|
---|
| 572 |
|
---|
[156] | 573 | viewVideoInfoAct->setChecked(set->value("video_info", false).toBool());
|
---|
[176] | 574 | scrollTitleAct->setChecked(set->value("scroll_title", false).toBool());
|
---|
[156] | 575 |
|
---|
[137] | 576 | fullscreen_toolbar1_was_visible = set->value("fullscreen_toolbar1_was_visible", fullscreen_toolbar1_was_visible).toBool();
|
---|
| 577 | compact_toolbar1_was_visible = set->value("compact_toolbar1_was_visible", compact_toolbar1_was_visible).toBool();
|
---|
| 578 |
|
---|
| 579 | if (pref->save_window_size_on_exit) {
|
---|
| 580 | QPoint p = set->value("pos", pos()).toPoint();
|
---|
| 581 | QSize s = set->value("size", size()).toSize();
|
---|
| 582 |
|
---|
| 583 | if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
|
---|
| 584 | s = pref->default_size;
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | move(p);
|
---|
| 588 | resize(s);
|
---|
| 589 |
|
---|
[156] | 590 | setWindowState( (Qt::WindowStates) set->value("state", 0).toInt() );
|
---|
| 591 |
|
---|
[137] | 592 | if (!DesktopInfo::isInsideScreen(this)) {
|
---|
[181] | 593 | QPoint tl = DesktopInfo::topLeftPrimaryScreen();
|
---|
| 594 | move(tl);
|
---|
| 595 | qWarning("DefaultGui::loadConfig: window is outside of the screen, moved to %d x %d", tl.x(), tl.y());
|
---|
[137] | 596 | }
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 | #if USE_CONFIGURABLE_TOOLBARS
|
---|
| 600 | set->beginGroup( "actions" );
|
---|
| 601 | int toolbar_version = set->value("toolbar1_version", 0).toInt();
|
---|
| 602 | if (toolbar_version >= TOOLBAR_VERSION) {
|
---|
| 603 | toolbar1->setActionsFromStringList( set->value("toolbar1", toolbar1->defaultActions()).toStringList() );
|
---|
| 604 | } else {
|
---|
| 605 | qDebug("SkinGui::loadConfig: toolbar too old, loading default one");
|
---|
| 606 | toolbar1->setActionsFromStringList( toolbar1->defaultActions() );
|
---|
| 607 | }
|
---|
[165] | 608 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
| 609 | EditableToolbar * iw = static_cast<EditableToolbar *>(floating_control->internalWidget());
|
---|
| 610 | iw->setActionsFromStringList( set->value("floating_control", iw->defaultActions()).toStringList() );
|
---|
[137] | 611 | floating_control->adjustSize();
|
---|
| 612 | #endif
|
---|
| 613 | set->endGroup();
|
---|
[176] | 614 |
|
---|
| 615 | set->beginGroup("toolbars_icon_size");
|
---|
| 616 | toolbar1->setIconSize(set->value("toolbar1", toolbar1->iconSize()).toSize());
|
---|
| 617 | #if defined(SKIN_EDITABLE_CONTROL)
|
---|
| 618 | iw->setIconSize(set->value("floating_control", iw->iconSize()).toSize());
|
---|
| 619 | #endif
|
---|
| 620 | set->endGroup();
|
---|
[137] | 621 | #endif
|
---|
| 622 |
|
---|
| 623 | restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
|
---|
| 624 |
|
---|
| 625 | #if DOCK_PLAYLIST
|
---|
| 626 | qDebug("SkinGui::loadConfig: playlist visible: %d", playlistdock->isVisible());
|
---|
| 627 | qDebug("SkinGui::loadConfig: playlist position: %d, %d", playlistdock->pos().x(), playlistdock->pos().y());
|
---|
| 628 | qDebug("SkinGui::loadConfig: playlist size: %d x %d", playlistdock->size().width(), playlistdock->size().height());
|
---|
| 629 | #endif
|
---|
| 630 |
|
---|
| 631 | set->endGroup();
|
---|
| 632 |
|
---|
| 633 | updateWidgets();
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | #include "moc_skingui.cpp"
|
---|