~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to doc/html/slideshow-slideshow-cpp.html

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    </div>
47
47
    <div id="shortCut">
48
48
      <ul>
49
 
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1 BETA</a></span></li>
 
49
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1</a></span></li>
50
50
        <li class="shortCut-topleft-active"><a href="http://doc.qt.nokia.com">ALL VERSIONS        </a></li>
51
51
      </ul>
52
52
     </div>
188
188
 #include &lt;QtGui&gt;
189
189
 
190
190
 SlideShow::SlideShow(QWidget *parent)
191
 
     : QWidget(parent)
 
191
     : QMainWindow(parent)
192
192
     , imageViewer(0)
193
193
     , playlist(0)
194
194
     , statusLabel(0)
195
 
     , countdownLabel(0)
196
 
     , playButton(0)
197
 
     , stopButton(0)
 
195
     , countdownAction(0)
 
196
     , playAction(0)
 
197
     , stopAction(0)
198
198
     , viewerLayout(0)
199
199
 {
200
200
     imageViewer = new QMediaImageViewer(this);
233
233
     viewerLayout-&gt;addWidget(videoWidget);
234
234
     viewerLayout-&gt;addWidget(statusLabel);
235
235
 
236
 
     QMenu *openMenu = new QMenu(this);
237
 
     openMenu-&gt;addAction(tr(&quot;Directory...&quot;), this, SLOT(openDirectory()));
238
 
     openMenu-&gt;addAction(tr(&quot;Playlist...&quot;), this, SLOT(openPlaylist()));
239
 
 
240
 
     QToolButton *openButton = new QToolButton;
241
 
     openButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_DialogOpenButton));
242
 
     openButton-&gt;setMenu(openMenu);
243
 
     openButton-&gt;setPopupMode(QToolButton::InstantPopup);
244
 
 
245
 
     playButton = new QToolButton;
246
 
     playButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPlay));
247
 
     playButton-&gt;setEnabled(false);
248
 
 
249
 
     connect(playButton, SIGNAL(clicked()), this, SLOT(play()));
250
 
     connect(this, SIGNAL(enableButtons(bool)), playButton, SLOT(setEnabled(bool)));
251
 
 
252
 
     stopButton = new QToolButton;
253
 
     stopButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaStop));
254
 
     stopButton-&gt;setEnabled(false);
255
 
 
256
 
     connect(stopButton, SIGNAL(clicked()), imageViewer, SLOT(stop()));
257
 
 
258
 
     QAbstractButton *nextButton = new QToolButton;
259
 
     nextButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaSkipForward));
260
 
     nextButton-&gt;setEnabled(false);
261
 
 
262
 
     connect(nextButton, SIGNAL(clicked()), playlist, SLOT(next()));
263
 
     connect(this, SIGNAL(enableButtons(bool)), nextButton, SLOT(setEnabled(bool)));
264
 
 
265
 
     QAbstractButton *previousButton = new QToolButton;
266
 
     previousButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaSkipBackward));
267
 
     previousButton-&gt;setEnabled(false);
268
 
 
269
 
     connect(previousButton, SIGNAL(clicked()), playlist, SLOT(previous()));
270
 
     connect(this, SIGNAL(enableButtons(bool)), previousButton, SLOT(setEnabled(bool)));
271
 
 
272
 
     countdownLabel = new QLabel;
273
 
 
274
 
     QBoxLayout *controlLayout = new QHBoxLayout;
275
 
     controlLayout-&gt;setMargin(0);
276
 
     controlLayout-&gt;addWidget(openButton);
277
 
     controlLayout-&gt;addStretch(1);
278
 
     controlLayout-&gt;addWidget(previousButton);
279
 
     controlLayout-&gt;addWidget(stopButton);
280
 
     controlLayout-&gt;addWidget(playButton);
281
 
     controlLayout-&gt;addWidget(nextButton);
282
 
     controlLayout-&gt;addStretch(1);
283
 
     controlLayout-&gt;addWidget(countdownLabel);
284
 
 
285
 
     QBoxLayout *layout = new QVBoxLayout;
286
 
     layout-&gt;addLayout(viewerLayout);
287
 
     layout-&gt;addLayout(controlLayout);
288
 
 
289
 
     setLayout(layout);
290
 
 
 
236
     menuBar()-&gt;addAction(tr(&quot;Open Directory...&quot;), this, SLOT(openDirectory()));
 
237
     menuBar()-&gt;addAction(tr(&quot;Open Playlist...&quot;), this, SLOT(openPlaylist()));
 
238
 
 
239
     toolBar = new QToolBar;
 
240
     toolBar-&gt;setMovable(false);
 
241
     toolBar-&gt;setFloatable(false);
 
242
     toolBar-&gt;setEnabled(false);
 
243
 
 
244
     toolBar-&gt;addAction(
 
245
             style()-&gt;standardIcon(QStyle::SP_MediaSkipBackward),
 
246
             tr(&quot;Previous&quot;),
 
247
             playlist,
 
248
             SLOT(previous()));
 
249
     stopAction = toolBar-&gt;addAction(
 
250
             style()-&gt;standardIcon(QStyle::SP_MediaStop), tr(&quot;Stop&quot;), imageViewer, SLOT(stop()));
 
251
     playAction = toolBar-&gt;addAction(
 
252
             style()-&gt;standardIcon(QStyle::SP_MediaPlay), tr(&quot;Play&quot;), this, SLOT(play()));
 
253
     toolBar-&gt;addAction(
 
254
             style()-&gt;standardIcon(QStyle::SP_MediaSkipForward), tr(&quot;Next&quot;), playlist, SLOT(next()));
 
255
 
 
256
     QToolBar *countdownToolBar = new QToolBar;
 
257
     countdownToolBar-&gt;setMovable(false);
 
258
     countdownToolBar-&gt;setFloatable(false);
 
259
     countdownToolBar-&gt;setToolButtonStyle(Qt::ToolButtonTextOnly);
 
260
     countdownAction = countdownToolBar-&gt;addAction(QString());
 
261
 
 
262
     addToolBar(Qt::BottomToolBarArea, toolBar);
 
263
     addToolBar(Qt::BottomToolBarArea, countdownToolBar);
 
264
 
 
265
     QWidget *centralWidget = new QWidget;
 
266
     centralWidget-&gt;setLayout(viewerLayout);
 
267
 
 
268
     setCentralWidget(centralWidget);
291
269
 }
292
270
 
293
271
 void SlideShow::openPlaylist()
314
292
 
315
293
         statusChanged(imageViewer-&gt;mediaStatus());
316
294
 
317
 
         emit enableButtons(playlist-&gt;mediaCount() &gt; 0);
 
295
         toolBar-&gt;setEnabled(playlist-&gt;mediaCount() &gt; 0);
318
296
     }
319
297
 }
320
298
 
335
313
 {
336
314
     switch (state) {
337
315
     case QMediaImageViewer::StoppedState:
338
 
         stopButton-&gt;setEnabled(false);
339
 
         playButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPlay));
 
316
         stopAction-&gt;setEnabled(false);
 
317
         playAction-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPlay));
340
318
         break;
341
319
     case QMediaImageViewer::PlayingState:
342
 
         stopButton-&gt;setEnabled(true);
343
 
         playButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPause));
 
320
         stopAction-&gt;setEnabled(true);
 
321
         playAction-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPause));
344
322
         break;
345
323
     case QMediaImageViewer::PausedState:
346
 
         stopButton-&gt;setEnabled(true);
347
 
         playButton-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPlay));
 
324
         stopAction-&gt;setEnabled(true);
 
325
         playAction-&gt;setIcon(style()-&gt;standardIcon(QStyle::SP_MediaPlay));
348
326
         break;
349
327
     }
350
328
 }
383
361
 {
384
362
     statusChanged(imageViewer-&gt;mediaStatus());
385
363
 
386
 
     emit enableButtons(playlist-&gt;mediaCount() &gt; 0);
 
364
     toolBar-&gt;setEnabled(playlist-&gt;mediaCount() &gt; 0);
387
365
 }
388
366
 
389
367
 void SlideShow::playlistLoadFailed()
391
369
     statusLabel-&gt;setText(playlist-&gt;errorString());
392
370
     viewerLayout-&gt;setCurrentIndex(1);
393
371
 
394
 
     emit enableButtons(false);
 
372
     toolBar-&gt;setEnabled(false);
395
373
 }
396
374
 
397
375
 void SlideShow::elapsedTimeChanged(int time)
398
376
 {
399
377
     const int remaining = (imageViewer-&gt;timeout() - time) / 1000;
400
378
 
401
 
     countdownLabel-&gt;setText(tr(&quot;%1:%2&quot;)
 
379
     countdownAction-&gt;setText(tr(&quot;%1:%2&quot;)
402
380
             .arg(remaining / 60, 2, 10, QLatin1Char('0'))
403
381
             .arg(remaining % 60, 2, 10, QLatin1Char('0')));
404
382
 }</pre>