~ubuntu-branches/debian/experimental/smplayer/experimental

« back to all changes in this revision

Viewing changes to src/minigui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-01-03 17:08:06 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090103170806-eodntb2slv6g2pb6
Tags: 0.6.6-0ubuntu1
* The "just before FF" release.
* New upstream release.
* debian/control: Bumped Standards-Version to 3.8.0.
* debian/copyright: Changed (C) to © to fix Lintian warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "myaction.h"
23
23
#include "mplayerwindow.h"
24
24
#include "global.h"
 
25
#include "helper.h"
 
26
#include "toolbareditor.h"
 
27
#include "desktopinfo.h"
25
28
 
26
29
#include <QToolBar>
27
30
#include <QStatusBar>
29
32
using namespace Global;
30
33
 
31
34
MiniGui::MiniGui( QWidget * parent, Qt::WindowFlags flags )
32
 
        : BaseGuiPlus( parent, flags ), 
33
 
                floating_control_width(80),
34
 
                floating_control_animated(true)
 
35
        : BaseGuiPlus( parent, flags )
35
36
{
36
37
        createActions();
37
38
        createControlWidget();
66
67
        volumeslider_action = createVolumeSliderAction(this);
67
68
        volumeslider_action->disable();
68
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)) );
69
76
}
70
77
 
71
78
 
76
83
        controlwidget->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
77
84
        addToolBar(Qt::BottomToolBarArea, controlwidget);
78
85
 
 
86
#if !USE_CONFIGURABLE_TOOLBARS
79
87
        controlwidget->addAction(playOrPauseAct);
80
88
        controlwidget->addAction(stopAct);
81
89
        controlwidget->addSeparator();
88
96
        controlwidget->addAction(volumeslider_action);
89
97
#endif
90
98
 
 
99
#endif // USE_CONFIGURABLE_TOOLBARS
91
100
}
92
101
 
93
102
void MiniGui::createFloatingControl() {
94
103
        // Floating control
95
104
        floating_control = new FloatingWidget(this);
96
105
 
 
106
#if !USE_CONFIGURABLE_TOOLBARS
97
107
        floating_control->toolbar()->addAction(playOrPauseAct);
98
108
        floating_control->toolbar()->addAction(stopAct);
99
109
        floating_control->toolbar()->addSeparator();
106
116
#endif
107
117
 
108
118
        floating_control->adjustSize();
 
119
#endif // USE_CONFIGURABLE_TOOLBARS
109
120
}
110
121
 
111
122
void MiniGui::retranslateStrings() {
168
179
}
169
180
 
170
181
void MiniGui::showFloatingControl(QPoint /*p*/) {
171
 
        floating_control->setAnimated( floating_control_animated );
172
 
        floating_control->showOver(panel, floating_control_width, 
 
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, 
173
189
                               FloatingWidget::Bottom);
174
190
}
175
191
 
177
193
        floating_control->hide();
178
194
}
179
195
 
180
 
#define TOOLBARS_VERSION 2
 
196
#if USE_MINIMUMSIZE
 
197
QSize MiniGui::minimumSizeHint() const {
 
198
        return QSize(controlwidget->sizeHint().width(), 0);
 
199
}
 
200
#endif
 
201
 
181
202
 
182
203
void MiniGui::saveConfig() {
183
204
        QSettings * set = settings;
184
205
 
185
206
        set->beginGroup( "mini_gui");
186
 
        set->setValue( "toolbars_state", saveState(TOOLBARS_VERSION) );
187
 
        set->setValue("floating_control_width", floating_control_width);
188
 
        set->setValue("floating_control_animated", floating_control_animated);
 
207
 
 
208
        if (pref->save_window_size_on_exit) {
 
209
                qDebug("MiniGui::saveConfig: w: %d h: %d", width(), height());
 
210
                set->setValue( "pos", pos() );
 
211
                set->setValue( "size", size() );
 
212
        }
 
213
 
 
214
        set->setValue( "toolbars_state", saveState(Helper::qtVersion()) );
 
215
 
 
216
#if USE_CONFIGURABLE_TOOLBARS
 
217
        set->beginGroup( "actions" );
 
218
        set->setValue("controlwidget", ToolbarEditor::save(controlwidget) );
 
219
        set->setValue("floating_control", ToolbarEditor::save(floating_control->toolbar()) );
 
220
        set->endGroup();
 
221
#endif
 
222
 
189
223
        set->endGroup();
190
224
}
191
225
 
193
227
        QSettings * set = settings;
194
228
 
195
229
        set->beginGroup( "mini_gui");
196
 
        restoreState( set->value( "toolbars_state" ).toByteArray(), TOOLBARS_VERSION );
197
 
        floating_control_width = set->value("floating_control_width", floating_control_width).toInt();
198
 
        floating_control_animated = set->value("floating_control_animated", floating_control_animated).toBool();
 
230
 
 
231
        if (pref->save_window_size_on_exit) {
 
232
                QPoint p = set->value("pos", pos()).toPoint();
 
233
                QSize s = set->value("size", size()).toSize();
 
234
 
 
235
                if ( (s.height() < 200) && (!pref->use_mplayer_window) ) {
 
236
                        s = pref->default_size;
 
237
                }
 
238
 
 
239
                move(p);
 
240
                resize(s);
 
241
 
 
242
                if (!DesktopInfo::isInsideScreen(this)) {
 
243
                        move(0,0);
 
244
                        qWarning("MiniGui::loadConfig: window is outside of the screen, moved to 0x0");
 
245
                }
 
246
        }
 
247
 
 
248
#if USE_CONFIGURABLE_TOOLBARS
 
249
        QList<QAction *> actions_list = findChildren<QAction *>();
 
250
        QStringList controlwidget_actions;
 
251
        controlwidget_actions << "play_or_pause" << "stop" << "separator" << "timeslider_action" << "separator"
 
252
                          << "fullscreen" << "mute" << "volumeslider_action";
 
253
 
 
254
        QStringList floatingcontrol_actions;
 
255
        floatingcontrol_actions << "play_or_pause" << "stop" << "separator" << "timeslider_action" << "separator"
 
256
                            << "fullscreen" << "mute";
 
257
#if USE_VOLUME_BAR
 
258
        floatingcontrol_actions << "volumeslider_action";
 
259
#endif
 
260
 
 
261
        floatingcontrol_actions << "separator" << "timelabel_action";
 
262
 
 
263
        set->beginGroup( "actions" );
 
264
        ToolbarEditor::load(controlwidget, set->value("controlwidget", controlwidget_actions).toStringList(), actions_list );
 
265
        ToolbarEditor::load(floating_control->toolbar(), set->value("floating_control", floatingcontrol_actions).toStringList(), actions_list );
 
266
        floating_control->adjustSize();
 
267
        set->endGroup();
 
268
#endif
 
269
 
 
270
        restoreState( set->value( "toolbars_state" ).toByteArray(), Helper::qtVersion() );
 
271
 
199
272
        set->endGroup();
200
273
}
201
274