| 1 | /* Mpcgui for SMPlayer.
|
|---|
| 2 | Copyright (C) 2008 matt_ <[email protected]>
|
|---|
| 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 "mpcgui.h"
|
|---|
| 20 | #include "mpcstyles.h"
|
|---|
| 21 | #include "widgetactions.h"
|
|---|
| 22 | #include "autohidewidget.h"
|
|---|
| 23 | #include "myaction.h"
|
|---|
| 24 | #include "mplayerwindow.h"
|
|---|
| 25 | #include "global.h"
|
|---|
| 26 | #include "helper.h"
|
|---|
| 27 | #include "desktopinfo.h"
|
|---|
| 28 | #include "colorutils.h"
|
|---|
| 29 |
|
|---|
| 30 | #include <QToolBar>
|
|---|
| 31 | #include <QStatusBar>
|
|---|
| 32 | #include <QLabel>
|
|---|
| 33 | #include <QSlider>
|
|---|
| 34 | #include <QLayout>
|
|---|
| 35 | #include <QApplication>
|
|---|
| 36 |
|
|---|
| 37 | using namespace Global;
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | MpcGui::MpcGui( QWidget * parent, Qt::WindowFlags flags )
|
|---|
| 41 | : BaseGuiPlus( parent, flags )
|
|---|
| 42 | {
|
|---|
| 43 | createActions();
|
|---|
| 44 | createControlWidget();
|
|---|
| 45 | createStatusBar();
|
|---|
| 46 | createFloatingControl();
|
|---|
| 47 | populateMainMenu();
|
|---|
| 48 |
|
|---|
| 49 | retranslateStrings();
|
|---|
| 50 |
|
|---|
| 51 | loadConfig();
|
|---|
| 52 |
|
|---|
| 53 | if (pref->compact_mode) {
|
|---|
| 54 | controlwidget->hide();
|
|---|
| 55 | timeslidewidget->hide();
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | applyStyles();
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | MpcGui::~MpcGui() {
|
|---|
| 62 | saveConfig();
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | void MpcGui::createActions() {
|
|---|
| 66 | timeslider_action = createTimeSliderAction(this);
|
|---|
| 67 | timeslider_action->disable();
|
|---|
| 68 | timeslider_action->setCustomStyle( new MpcTimeSlideStyle() );
|
|---|
| 69 |
|
|---|
| 70 | #if USE_VOLUME_BAR
|
|---|
| 71 | volumeslider_action = createVolumeSliderAction(this);
|
|---|
| 72 | volumeslider_action->disable();
|
|---|
| 73 | volumeslider_action->setCustomStyle( new MpcVolumeSlideStyle() );
|
|---|
| 74 | volumeslider_action->setFixedSize( QSize(50,18) );
|
|---|
| 75 | volumeslider_action->setTickPosition( QSlider::NoTicks );
|
|---|
| 76 | #endif
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | void MpcGui::createControlWidget() {
|
|---|
| 81 | controlwidget = new QToolBar( this );
|
|---|
| 82 | controlwidget->setObjectName("controlwidget");
|
|---|
| 83 | controlwidget->setLayoutDirection(Qt::LeftToRight);
|
|---|
| 84 |
|
|---|
| 85 | controlwidget->setMovable(false);
|
|---|
| 86 | controlwidget->setAllowedAreas(Qt::BottomToolBarArea);
|
|---|
| 87 | controlwidget->addAction(playAct);
|
|---|
| 88 | controlwidget->addAction(pauseAct);
|
|---|
| 89 | controlwidget->addAction(stopAct);
|
|---|
| 90 | controlwidget->addSeparator();
|
|---|
| 91 | controlwidget->addAction(rewind3Act);
|
|---|
| 92 | controlwidget->addAction(rewind1Act);
|
|---|
| 93 | controlwidget->addAction(forward1Act);
|
|---|
| 94 | controlwidget->addAction(forward3Act);
|
|---|
| 95 | controlwidget->addSeparator();
|
|---|
| 96 | controlwidget->addAction(frameStepAct);
|
|---|
| 97 | controlwidget->addSeparator();
|
|---|
| 98 |
|
|---|
| 99 | QLabel* pLabel = new QLabel(this);
|
|---|
| 100 | pLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
|
|---|
| 101 | controlwidget->addWidget(pLabel);
|
|---|
| 102 |
|
|---|
| 103 | controlwidget->addAction(muteAct);
|
|---|
| 104 | controlwidget->addAction(volumeslider_action);
|
|---|
| 105 |
|
|---|
| 106 | timeslidewidget = new QToolBar( this );
|
|---|
| 107 | timeslidewidget->setObjectName("timeslidewidget");
|
|---|
| 108 | timeslidewidget->setLayoutDirection(Qt::LeftToRight);
|
|---|
| 109 | timeslidewidget->addAction(timeslider_action);
|
|---|
| 110 | timeslidewidget->setMovable(false);
|
|---|
| 111 |
|
|---|
| 112 | /*
|
|---|
| 113 | QColor SliderColor = palette().color(QPalette::Window);
|
|---|
| 114 | QColor SliderBorderColor = palette().color(QPalette::Dark);
|
|---|
| 115 | */
|
|---|
| 116 | setIconSize( QSize( 16 , 16 ) );
|
|---|
| 117 |
|
|---|
| 118 | addToolBar(Qt::BottomToolBarArea, controlwidget);
|
|---|
| 119 | addToolBarBreak(Qt::BottomToolBarArea);
|
|---|
| 120 | addToolBar(Qt::BottomToolBarArea, timeslidewidget);
|
|---|
| 121 |
|
|---|
| 122 | controlwidget->setStyle(new MpcToolbarStyle() );
|
|---|
| 123 | timeslidewidget->setStyle(new MpcToolbarStyle() );
|
|---|
| 124 |
|
|---|
| 125 | statusBar()->show();
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | void MpcGui::createFloatingControl() {
|
|---|
| 129 | // Floating control
|
|---|
| 130 | floating_control = new AutohideWidget(mplayerwindow);
|
|---|
| 131 | floating_control->setAutoHide(true);
|
|---|
| 132 | floating_control->hide();
|
|---|
| 133 | spacer = new QSpacerItem(10,10);
|
|---|
| 134 |
|
|---|
| 135 | floating_control_time = new QLabel(floating_control);
|
|---|
| 136 | floating_control_time->setAlignment(Qt::AlignRight);
|
|---|
| 137 | floating_control_time->setAutoFillBackground(true);
|
|---|
| 138 | floating_control_time->setObjectName("floating_control_time");
|
|---|
| 139 | #ifdef CHANGE_WIDGET_COLOR
|
|---|
| 140 | ColorUtils::setBackgroundColor( floating_control_time, QColor(0,0,0) );
|
|---|
| 141 | ColorUtils::setForegroundColor( floating_control_time, QColor(255,255,255) );
|
|---|
| 142 | #endif
|
|---|
| 143 |
|
|---|
| 144 | connect(this, SIGNAL(timeChanged(QString)), floating_control_time, SLOT(setText(QString)));
|
|---|
|
|---|