source: smplayer/trunk/src/minigui.cpp@ 105

Last change on this file since 105 was 93, checked in by Silvan Scherrer, 16 years ago

smplayer: 0.6.9

File size: 7.5 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2010 Ricardo Villalba <[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 "minigui.h"
20#include "widgetactions.h"
21#include "floatingwidget.h"
22#include "myaction.h"
23#include "mplayerwindow.h"
24#include "global.h"
25#include "helper.h"
26#include "toolbareditor.h"
27#include "desktopinfo.h"
28
29#include <QToolBar>
30#include <QStatusBar>
31
32using namespace Global;
33
34MiniGui::MiniGui( QWidget * parent, Qt::WindowFlags flags )
35 : BaseGuiPlus( parent, flags )
36{
37 createActions();
38 createControlWidget();
39 createFloatingControl();
40
41 connect( this, SIGNAL(cursorNearBottom(QPoint)),
42 this, SLOT(showFloatingControl(QPoint)) );
43
44 connect( this, SIGNAL(cursorFarEdges()),
45 this, SLOT(hideFloatingControl()) );
46
47 statusBar()->hide();
48
49 retranslateStrings();
50
51 loadConfig();
52
53 if (pref->compact_mode) {
54 controlwidget->hide();
55 }
56}
57
58MiniGui::~MiniGui() {
59 saveConfig();
60}
61
62void MiniGui::createActions() {
63 timeslider_action = createTimeSliderAction(this);
64 timeslider_action->disable();
65
66#if USE_VOLUME_BAR
67 volumeslider_action = createVolumeSliderAction(this);
68 volumeslider_action->disable();
69#endif
70
71 time_label_action = new TimeLabelAction(this);
72 time_label_action->setObjectName("timelabel_action");
73
74 connect( this, SIGNAL(timeChanged(QString)),
75 time_label_action, SLOT(setText(QString)) );
76}
77
78
79void MiniGui::createControlWidget() {
80 controlwidget = new QToolBar( this );
81 controlwidget->setObjectName("controlwidget");
82 controlwidget->setMovable(true);
83 controlwidget->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
84 addToolBar(Qt::BottomToolBarArea, controlwidget);
85
86#if !USE_CONFIGURABLE_TOOLBARS
87 controlwidget->addAction(playOrPauseAct);
88 controlwidget->addAction(stopAct);
89 controlwidget->addSeparator();
90 controlwidget->addAction(timeslider_action);
91 controlwidget->addSeparator();
92 controlwidget->addAction(fullscreenAct);
93 controlwidget->addAction(muteAct);
94
95#if USE_VOLUME_BAR
96 controlwidget->addAction(volumeslider_action);
97#endif
98
99#endif // USE_CONFIGURABLE_TOOLBARS
100}
101
102void MiniGui::createFloatingControl() {
103 // Floating control
104 floating_control = new FloatingWidget(this);
105
106#if !USE_CONFIGURABLE_TOOLBARS
107 floating_control->toolbar()->addAction(playOrPauseAct);
108 floating_control->toolbar()->addAction(stopAct);
109 floating_control->toolbar()->addSeparator();
110 floating_control->toolbar()->addAction(timeslider_action);
111 floating_control->toolbar()->addSeparator();
112 floating_control->toolbar()->addAction(fullscreenAct);
113 floating_control->toolbar()->addAction(muteAct);
114#if USE_VOLUME_BAR
115 floating_control->toolbar()->addAction(volumeslider_action);
116#endif
117
118 floating_control->adjustSize();
119#endif // USE_CONFIGURABLE_TOOLBARS
120}
121
122void MiniGui::retranslateStrings() {
123 BaseGuiPlus::retranslateStrings();
124
125 controlwidget->setWindowTitle( tr("Control bar") );
126}
127
128#if AUTODISABLE_ACTIONS
129void MiniGui::enableActionsOnPlaying() {
130 BaseGuiPlus::enableActionsOnPlaying();
131
132 timeslider_action->enable();
133#if USE_VOLUME_BAR
134 volumeslider_action->enable();
135#endif
136}
137
138void MiniGui::disableActionsOnStop() {
139 BaseGuiPlus::disableActionsOnStop();
140
141 timeslider_action->disable();
142#if USE_VOLUME_BAR
143 volumeslider_action->disable();
144#endif
145}
146#endif // AUTODISABLE_ACTIONS
147
148void MiniGui::aboutToEnterFullscreen() {
149 BaseGuiPlus::aboutToEnterFullscreen();
150
151 if (!pref->compact_mode) {
152 controlwidget->hide();
153 }
154}
155
156void MiniGui::aboutToExitFullscreen() {
157 BaseGuiPlus::aboutToExitFullscreen();
158
159 floating_control->hide();
160
161 if (!pref->compact_mode) {
162 statusBar()->hide();
163 controlwidget->show();
164 }
165}
166
167void MiniGui::aboutToEnterCompactMode() {
168 BaseGuiPlus::aboutToEnterCompactMode();
169
170 controlwidget->hide();
171}
172
173void MiniGui::aboutToExitCompactMode() {
174 BaseGuiPlus::aboutToExitCompactMode();
175
176 statusBar()->hide();
177
178 controlwidget->show();
179}
180
181void MiniGui::showFloatingControl(QPoint /*p*/) {
182#ifndef Q_OS_WIN
183 floating_control->setBypassWindowManager(pref->bypass_window_manager);
184#endif
185 floating_control->setAnimated( pref->floating_control_animated );
186 floating_control->setMargin(pref->floating_control_margin);
187 floating_control->showOver(panel,
188 pref->floating_control_width,
189 FloatingWidget::Bottom);
190}
191
192void MiniGui::hideFloatingControl() {
193 floating_control->hide();
194}
195
196#if USE_MINIMUMSIZE
197QSize MiniGui::minimumSizeHint() const {
198 return QSize(controlwidget->sizeHint().width(), 0);
199}
200#endif
201
202
203void MiniGui::saveConfig() {
204 QSettings * set = settings;