1 #include "mainwindow.h"
2 #include "mediavideowidget.h"
4 #if defined(WIN32) && defined(RELEASE)
7 #endif // defined(WIN32) && defined(RELEASE)
10 /*===============================================================================*/
11 /*======================== Contructors / Destructor =============================*/
12 /*===============================================================================*/
14 MainWindow::MainWindow(QWidget
*parent
)
16 setWindowTitle(tr("CT KuK"));
18 setWindowIcon(QIcon(":/images/icon.ico")); // low resolution
20 setWindowIcon(QIcon(":/images/icon-big.png")); // nice pleasure from hi resolution only for big boys
23 setContextMenuPolicy(Qt::CustomContextMenu
);
30 m_pStreamReciever
= 0;
36 MainWindow::~MainWindow()
43 /*===============================================================================*/
44 /*=========================== Private functions =================================*/
45 /*===============================================================================*/
47 void MainWindow::createMenu()
50 QMenu
*fileMenu
= menuBar()->addMenu(tr("&File"));
52 saveAction
= fileMenu
->addAction(tr("&Save buffer.."));
53 saveAction
->setShortcuts(QKeySequence::SaveAs
);
54 exitAction
= fileMenu
->addAction(tr("E&xit"));
55 exitAction
->setShortcuts(QKeySequence::Quit
);
57 // Playing menu section
58 QMenu
*playingMenu
= menuBar()->addMenu(tr("&Playing"));
59 playPauseAction
= playingMenu
->addAction(tr("&Play/Pause"));
60 stopAction
= playingMenu
->addAction(tr("&Stop"));
63 QMenu
*viewMenu
= menuBar()->addMenu(tr("&View"));
65 fullViewAction
= viewMenu
->addAction(tr("&Full view"));
66 fullViewAction
->setCheckable(true);
67 fullViewAction
->setChecked(true); // default value
69 playerViewAction
= viewMenu
->addAction(tr("&Player view"));
70 playerViewAction
->setCheckable(true);
72 minimalViewAction
= viewMenu
->addAction(tr("&Minimal view"));
73 minimalViewAction
->setCheckable(true);
77 QActionGroup
*viewGroup
= new QActionGroup(this);
78 viewGroup
->addAction(fullViewAction
);
79 viewGroup
->addAction(playerViewAction
);
80 viewGroup
->addAction(minimalViewAction
);
83 QMenu
*helpMenu
= menuBar()->addMenu(tr("&Help"));
84 aboutAction
= helpMenu
->addAction(tr("&About"));
86 connect(fullViewAction
,SIGNAL(triggered()),this,SLOT(setFullView()));
87 connect(playerViewAction
,SIGNAL(triggered()),this,SLOT(setPlayerView()));
88 connect(minimalViewAction
,SIGNAL(triggered()),this,SLOT(setMinimalView()));
90 connect(exitAction
, SIGNAL(triggered()), qApp
, SLOT(quit()));
91 connect(aboutAction
,SIGNAL(triggered()),&m_aboutDialog
,SLOT(show()));
93 #if defined(WIN32) && defined(RELEASE)
94 updateAction
= helpMenu
->addAction(tr("&Check for updates"));
95 connect(updateAction
,SIGNAL(triggered()), this,SLOT(checkForUpdates()));
96 #endif // defined(WIN32) && defined(RELEASE)
99 void MainWindow::buildGUI()
101 m_pFrame
= new QFrame(this);
103 QGridLayout
*mainLayout
= new QGridLayout(m_pFrame
);
104 mainLayout
->setContentsMargins(0, 0, 0, 0);
106 m_pStatusBar
= new QStatusBar(this);
108 this->resize(minimumSizeHint());
109 this->setCentralWidget(m_pFrame
);
110 this->setStatusBar(m_pStatusBar
);
112 // Fake video panel setup (shows splash picture)
113 m_pInfo
= new QLabel(this);
114 m_pInfo
->setMinimumHeight(200);
115 m_pInfo
->setMinimumWidth(308);
116 //info->setFixedSize(308,200);
118 m_pInfo
->setPixmap(QPixmap(":/images/background.png").scaledToHeight(m_pInfo
->height()));
120 m_pInfo
->setAcceptDrops(false);
121 m_pInfo
->setMargin(2);
122 m_pInfo
->setFrameStyle(QFrame::StyledPanel
| QFrame::Sunken
);
123 m_pInfo
->setLineWidth(2);
124 m_pInfo
->setAutoFillBackground(true);
125 m_pInfo
->setSizePolicy(QSizePolicy::Expanding
,QSizePolicy::Expanding
);
127 palette
.setBrush(QPalette::WindowText
, Qt::white
);
128 m_pInfo
->setPalette(palette
);
129 mainLayout
->addWidget(m_pInfo
);
132 m_pAudioOutput
= new Phonon::AudioOutput(Phonon::VideoCategory
, this);
133 m_audioOutputPath
= Phonon::createPath(&m_MediaObject
, m_pAudioOutput
);
134 m_videoWidget
= new MediaVideoWidget(this);
135 m_videoWidget
->setContextMenuPolicy(Qt::CustomContextMenu
);
136 m_videoWidgetPath
= Phonon::createPath(&m_MediaObject
, m_videoWidget
);
138 QVBoxLayout
*videoLayout
= new QVBoxLayout(&m_videoWindow
);
139 videoLayout
->addWidget(m_videoWidget
);
140 videoLayout
->setContentsMargins(0, 0, 0, 0);
141 m_videoWindow
.setLayout(videoLayout
);
142 m_videoWindow
.setMinimumSize(100,200);
143 m_videoWindow
.hide();
144 m_videoWindow
.setSizePolicy(QSizePolicy::Expanding
,QSizePolicy::Expanding
);
145 mainLayout
->addWidget(&m_videoWindow
);
149 m_pButtonPanelWidget
= new QWidget(this);
150 m_pButtonPanelWidget
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Fixed
);
152 QVBoxLayout
*controlPanelLayout
= new QVBoxLayout(m_pButtonPanelWidget
);
153 controlPanelLayout
->setContentsMargins(0,0,0,0);
154 m_pButtonPanelWidget
->setLayout(controlPanelLayout
);
156 mainLayout
->addWidget(m_pButtonPanelWidget
);
158 // Control panel setup
159 QHBoxLayout
*_pButtonPanelLayout
= new QHBoxLayout();
160 _pButtonPanelLayout
->setContentsMargins(0,0,0,0);
162 m_pPlayButton
= new QPushButton(this);
164 playIcon
= QPixmap(":/images/play.png");
166 pauseIcon
= QPixmap(":/images/pause.png");
167 m_pPlayButton
->setIcon(playIcon
);
168 m_pPlayButton
->setFlat(true);
169 m_pPlayButton
->setFixedSize(35,35);
170 m_pPlayButton
->setIconSize(QSize(32,32));
171 m_pPlayButton
->setEnabled(false);
173 m_pStopButton
= new QPushButton(this);
174 m_pStopButton
->setIcon(QPixmap(":/images/stop.png"));
175 m_pStopButton
->setFlat(true);
176 m_pStopButton
->setFixedSize(35,35);
177 m_pStopButton
->setIconSize(QSize(32,32));
178 m_pStopButton
->setEnabled(false);
180 m_pRewindButton
= new QPushButton(this);
181 m_pRewindButton
->setIcon(QPixmap(":/images/prev.png"));
182 //m_pRewindButton->setFlat(true);
183 m_pRewindButton
->setEnabled(false);
184 m_pForwardButton
= new QPushButton(this);
185 m_pForwardButton
->setIcon(QPixmap(":/images/next.png"));
186 //m_pForwardButton->setFlat(true);
187 m_pForwardButton
->setEnabled(false);
189 // schovat tlacitka zpet a dalsi dokud nebudou neco delat..
190 m_pRewindButton
->hide();
191 m_pForwardButton
->hide();
195 _pButtonPanelLayout
->addWidget(m_pRewindButton
);
196 _pButtonPanelLayout
->addWidget(m_pPlayButton
);
197 _pButtonPanelLayout
->addWidget(m_pStopButton
);
198 _pButtonPanelLayout
->addWidget(m_pForwardButton
);
199 _pButtonPanelLayout
->addStretch();
202 m_pVolumeSlider
= new VolumeWidget(this);
203 m_pVolumeSlider
->setAudioOutput(m_pAudioOutput
);
204 _pButtonPanelLayout
->addWidget(m_pVolumeSlider
);
206 controlPanelLayout
->addLayout(_pButtonPanelLayout
);
208 m_pTimeSlider
= new TimeBufferedSlider(this);
209 m_pTimeSlider
->setMinimum(0);
210 m_pTimeSlider
->setMaximum(100);
211 m_pTimeSlider
->setMinimumBuffer(0);
212 m_pTimeSlider
->setMaximumBuffer(100);
213 //m_pTimeSlider->setValue(40);
214 //m_pTimeSlider->setBufferValue(60);
215 m_pTimeSlider
->setEnabled(false);
216 //controlPanelLayout->addWidget(m_pTimeSlider);
217 m_pTimeSlider
->setMediaObject(&m_MediaObject
);
219 timeLabel
= new QLabel(this);
220 //timeLabel->setText("0/0");
221 progressLabel
= new QLabel(this);
222 QWidget
*sliderPanel
= new QWidget(this);
223 QHBoxLayout
*sliderLayout
= new QHBoxLayout(sliderPanel
);
224 sliderLayout
->setContentsMargins(0, 0, 0, 0);
225 sliderLayout
->addWidget(m_pTimeSlider
);
226 sliderLayout
->addWidget(timeLabel
);
227 sliderLayout
->addWidget(progressLabel
);
228 sliderPanel
->setLayout(sliderLayout
);
229 controlPanelLayout
->addWidget(sliderPanel
);
233 m_pListArchive
= new QTreeWidget(this);
234 m_pListArchive
->setHeaderLabel(tr("Programme: "));
235 m_pListArchive
->setRootIsDecorated(false);
237 m_pListEpisodes
= new QTreeWidget(this);
238 m_pListEpisodes
->setHeaderLabel(tr("Episode: "));
239 m_pListEpisodes
->setRootIsDecorated(false);
241 mainLayout
->addWidget(m_pListArchive
,0,1,5,1);
242 mainLayout
->addWidget(m_pListEpisodes
,4,0);
245 labelIcon
= new QLabel
;
246 labelIcon
->setFixedSize(16,16);
247 movieLoading
= new QMovie(":/images/loading.gif");
248 labelIcon
->setMovie(movieLoading
);
249 this->statusBar()->addWidget(labelIcon
);
250 movieLoading
->start();
252 pixmapOk
= new QPixmap(QPixmap(":/images/ok.png").scaledToHeight(16,Qt::SmoothTransformation
));
253 pixmapErr
= new QPixmap(QPixmap(":/images/err.png").scaledToHeight(16,Qt::SmoothTransformation
));
254 pixmapPlay
= new QPixmap(QPixmap(":/images/play.png").scaledToHeight(16,Qt::SmoothTransformation
));
255 pixmapPause
= new QPixmap(QPixmap(":/images/pause.png").scaledToHeight(16,Qt::SmoothTransformation
));
256 pixmapStop
= new QPixmap(QPixmap(":/images/stop.png").scaledToHeight(16,Qt::SmoothTransformation
));
258 labelText
= new QLabel
;
259 labelText
->setText(tr("Loading list of the programmes..."));
260 this->statusBar()->addWidget(labelText
);
267 void MainWindow::activateConnects()
269 // Web Engine connects
270 connect(m_pListArchive
, SIGNAL(itemDoubleClicked(QTreeWidgetItem
*, int)),
271 this , SLOT(showSelected(QTreeWidgetItem
*, int)));
272 connect(m_pListEpisodes
, SIGNAL(itemDoubleClicked(QTreeWidgetItem
*, int)),
273 this , SLOT(episodeSelected(QTreeWidgetItem
*, int)));
276 connect(m_pPlayButton
, SIGNAL(clicked()), this, SLOT(playPause()));
277 connect(m_pStopButton
, SIGNAL(clicked()), this, SLOT(stop()));
278 connect(m_pRewindButton
, SIGNAL(clicked()),this,SLOT(rewind()));
279 connect(m_pForwardButton
,SIGNAL(clicked()),this,SLOT(forward()));
280 connect(&m_MediaObject
, SIGNAL(stateChanged(Phonon::State
, Phonon::State
)),
281 this, SLOT(stateChanged(Phonon::State
, Phonon::State
)));
282 connect(&m_MediaObject
, SIGNAL(totalTimeChanged(qint64
)), this, SLOT(updateTime()));
283 connect(&m_MediaObject
, SIGNAL(tick(qint64
)), this, SLOT(updateTime()));
284 connect(&m_MediaObject
, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int)));
288 void MainWindow::afterStart()
290 #if defined(WIN32) && defined(RELEASE)
295 m_webengine
= new WebEngine(this);
297 connect(m_webengine
, SIGNAL(showsByAlphaReady(QVector
<LinkInfo
*> *)),
298 this , SLOT(addListArchiveItems(QVector
<LinkInfo
*> *)));
299 connect(m_webengine
, SIGNAL(showVideoReady(VideoInfo
*)),
300 this , SLOT(addListEpisodeItem(VideoInfo
*)));
301 connect(m_webengine
, SIGNAL(showAllVideosReady()),
302 this , SLOT(allEpisodeItemsReady()));
303 connect(m_webengine
, SIGNAL(videoLinkReady(QString
*)),
304 this , SLOT(getVideoPlaylist(QString
*)));
305 connect(m_webengine
, SIGNAL(remoteFileReady(QByteArray
*)),
306 this , SLOT(openVideo(QByteArray
*)));
307 connect(m_webengine
, SIGNAL(error(WebEngineError
*)),
308 this , SLOT(webEngineError(WebEngineError
*)));
310 m_webengine
->getShowsByAlpha("abeceda-vse");
313 void MainWindow::finishUpdate()
316 #if defined(WIN32) && defined(RELEASE)
318 if(QCoreApplication::arguments().size() == 2) // ctkuk.exe SUPPOSED_VERSION_I_UPDATED_TO
321 argv
.push_back(QCoreApplication::applicationVersion());
322 argv
.push_back(QCoreApplication::arguments().at(1));
323 QProcess::startDetached("updater.exe", argv
);
325 #endif // defined(WIN32) && defined(RELEASE)
329 /*===============================================================================*/
330 /*=========================== Public slots =================================*/
331 /*===============================================================================*/
333 void MainWindow::openVideo(QByteArray
*data
)
336 labelIcon
->setMovie(movieLoading
);
337 labelText
->setText(tr("Opening video..."));
340 int start
= url
.indexOf("base=\"", url
.indexOf("<switchItem")) + 7;
341 int end
= url
.indexOf("\"", start
);
342 url
= url
.mid(start
, end
- start
);
344 m_pStreamReciever
= new StreamReciever(url
);
346 connect(m_pStreamReciever
, SIGNAL(percentage(int)), m_pTimeSlider
, SLOT(setBufferValue(int)));
347 connect(m_pStreamReciever
, SIGNAL(bufferReady(const QString
&)), this, SLOT(openFile(const QString
&)));
348 connect(m_pStreamReciever
,SIGNAL(error(QString
)),this,SLOT(StreamRecieverError(QString
)));
349 connect(m_pStreamReciever
, SIGNAL(finished()),this,SLOT(destroyStreamReciever()));
350 connect(m_pTimeSlider
, SIGNAL(sliderReleased(qint64
)), this, SLOT(seekVideo(qint64
)));
352 m_pStreamReciever
->start();
355 void MainWindow::openFile(const QString
&file
)
357 if (!m_pStreamReciever
)
360 labelIcon
->movie()->stop();
361 labelIcon
->setPixmap(*pixmapErr
);
362 labelText
->setText("Getting stream error.");
368 m_MediaObject
.clearQueue();
369 m_MediaObject
.setCurrentSource(Phonon::MediaSource(file
));
370 m_bufferGuard
.setBufferSize(m_pStreamReciever
->getBufferSize());
371 m_bufferGuard
.setPreloadTime(10); // 10s
374 // TotalTime se nastavi az pri zmene stavu do LoadingState,
375 // protoze pred tim neni tento parametr k dispozici
377 connect(&m_MediaObject
,SIGNAL(tick(qint64
)),&m_bufferGuard
,SLOT(timeTick(qint64
)));
378 connect(&m_MediaObject
,SIGNAL(totalTimeChanged(qint64
)),&m_bufferGuard
,SLOT(setTotalTime(qint64
)));
379 connect(m_pStreamReciever
,SIGNAL(loaded(qint64
)),&m_bufferGuard
,SLOT(bufferTick(qint64
)));
380 connect(&m_bufferGuard
,SIGNAL(preloadExceeded()),this,SLOT(bufferExceeded()));
382 m_bufferGuard
.setTotalTime(m_pStreamReciever
->getTotalPlayTime());
383 m_pTimeSlider
->setMaximum(m_pStreamReciever
->getTotalPlayTime());
384 m_pTimeSlider
->setValue(m_pTimeSlider
->minimum());
385 m_pTimeSlider
->setEnabled(true);
386 qApp
->processEvents();
389 m_videoWindow
.setVisible(true);
390 m_pInfo
->setVisible(false);
396 void MainWindow::playPause()
398 if (m_MediaObject
.state() == Phonon::PlayingState
)
400 m_MediaObject
.pause();
405 if (m_MediaObject
.currentTime() == m_bufferGuard
.getTotalTime())
406 m_MediaObject
.seek(0);
408 m_MediaObject
.play();
409 labelText
->setText(tr("Loading video..."));
410 labelIcon
->setMovie(movieLoading
);
414 void MainWindow::stop()
416 if (m_MediaObject
.state() != Phonon::StoppedState
)
417 m_MediaObject
.stop();
419 m_videoWindow
.setVisible(false);
420 m_pInfo
->setVisible(true);
421 m_pTimeSlider
->setEnabled(false);
422 timeLabel
->setText("");
424 labelText
->setText("");
425 labelIcon
->setMovie(NULL
);
427 disconnect(m_pTimeSlider
, SIGNAL(sliderReleased(qint64
)), this, SLOT(seekVideo(qint64
)));
428 disconnect(&m_MediaObject
,SIGNAL(tick(qint64
)), &m_bufferGuard
, SLOT(timeTick(qint64
)));
429 disconnect(&m_MediaObject
,SIGNAL(totalTimeChanged(qint64
)), &m_bufferGuard
, SLOT(setTotalTime(qint64
)));
430 disconnect(&m_bufferGuard
,SIGNAL(preloadExceeded()), this, SLOT(bufferExceeded()));
432 destroyStreamReciever();
436 void MainWindow::rewind()
441 void MainWindow::forward()
446 void MainWindow::destroyStreamReciever()
448 if (m_pStreamReciever
)
450 disconnect(m_pStreamReciever
,SIGNAL(loaded(qint64
)),&m_bufferGuard
,SLOT(bufferTick(qint64
)));
451 disconnect(m_pStreamReciever
, SIGNAL(finished()),this,SLOT(destroyStreamReciever()));
452 disconnect(m_pStreamReciever
, SIGNAL(percentage(int)), m_pTimeSlider
, SLOT(setBufferValue(int)));
453 disconnect(m_pStreamReciever
, SIGNAL(bufferReady(const QString
&)), this, SLOT(openFile(const QString
&)));
454 disconnect(m_pStreamReciever
,SIGNAL(error(QString
)),this,SLOT(StreamRecieverError(QString
)));
457 if (m_pStreamReciever
->isRunning())
459 m_pStreamReciever
->terminate();
460 m_pStreamReciever
->wait();
462 QFile::remove(m_pStreamReciever
->getTempFileName());
464 delete m_pStreamReciever
;
465 m_pStreamReciever
= 0;
470 void MainWindow::stateChanged(Phonon::State newstate
, Phonon::State oldstate
)
473 case Phonon::ErrorState
:
474 QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject
.errorString(), QMessageBox::Close
);
475 m_pStopButton
->setEnabled(false);
476 if (m_MediaObject
.errorType() == Phonon::FatalError
) {
477 m_pPlayButton
->setEnabled(false);
478 // rewindButton->setEnabled(false);
480 m_MediaObject
.pause();
481 labelIcon
->setPixmap(*pixmapErr
);
482 labelText
->setText(tr("Error!"));
485 case Phonon::PausedState
:
486 m_pStopButton
->setEnabled(true);
487 labelText
->setText(tr("Paused"));
488 labelIcon
->setPixmap(*pixmapPause
);
489 m_pPlayButton
->setIcon(playIcon
);
490 if (m_MediaObject
.currentSource().type() != Phonon::MediaSource::Invalid
){
491 m_pPlayButton
->setEnabled(true);
493 m_pPlayButton
->setEnabled(false);
496 case Phonon::StoppedState
:
497 labelText
->setText(tr("Stopped"));
498 labelIcon
->setPixmap(*pixmapStop
);
499 m_pStopButton
->setEnabled(false);
500 m_pPlayButton
->setIcon(playIcon
);
501 m_pPlayButton
->setEnabled(false);
502 m_pRewindButton
->setEnabled(false);
504 case Phonon::PlayingState
:
505 labelText
->setText(tr("Playing..."));
506 labelIcon
->setPixmap(*pixmapPlay
);
507 m_pStopButton
->setEnabled(true);
508 m_pPlayButton
->setEnabled(true);
509 m_pPlayButton
->setIcon(pauseIcon
);
510 if (m_MediaObject
.hasVideo())
511 m_videoWindow
.show();
513 case Phonon::BufferingState
:
514 case Phonon::LoadingState
:
520 void MainWindow::bufferExceeded()
522 m_MediaObject
.pause();
523 labelIcon
->setMovie(movieLoading
);
524 labelIcon
->movie()->start();
525 labelText
->setText(tr("Loading buffer..."));
526 disconnect(&m_bufferGuard
,SIGNAL(preloadExceeded()),this,SLOT(bufferExceeded()));
527 QTimer::singleShot(1000, this, SLOT(bufferReadyToPlay()));
531 void MainWindow::bufferReadyToPlay()
533 if (m_bufferGuard
.isReady())
535 // reconect signal and play it
536 connect(&m_bufferGuard
,SIGNAL(preloadExceeded()),this,SLOT(bufferExceeded()));
537 m_MediaObject
.play();
541 QTimer::singleShot(1000, this, SLOT(bufferReadyToPlay()));
545 void MainWindow::StreamRecieverError(QString error
)
547 /*! @todo tady by stopka asi byt nemela */
549 labelIcon
->setPixmap(*pixmapErr
);
550 labelText
->setText(error
);
553 void MainWindow::seekVideo(qint64 position
)
555 m_MediaObject
.seek(m_bufferGuard
.alignValue(position
));
559 void MainWindow::updateTime()
561 long len
= m_bufferGuard
.getTotalTime();
562 long pos
= m_MediaObject
.currentTime();
571 QTime
playTime(hour
%60, min
%60, sec
%60, msec
%1000);
577 QTime
stopTime(hour
%60, min
%60, sec
%60, msec
%1000);
578 QString timeFormat
= "m:ss";
580 timeFormat
= "h:mm:ss";
581 timeString
= playTime
.toString(timeFormat
);
583 timeString
+= " / " + stopTime
.toString(timeFormat
);
585 timeLabel
->setText(timeString
);
590 void MainWindow::bufferStatus(int percent
)
592 if (percent
== 0 || percent
== 100)
593 progressLabel
->setText(QString());
595 QString str
= QString::fromLatin1("(%1%)").arg(percent
);
596 progressLabel
->setText(str
);
601 /* ======================== Web engine slots=====================================*/
604 void MainWindow::addListArchiveItems(QVector
<LinkInfo
*> *shows
)
606 m_pListArchive
->clear();
608 QList
<QTreeWidgetItem
*> listArchiveItems
;
609 QTreeWidgetItem
*widget
;
610 for (int i
= 0, im
= shows
->size(); i
< im
; ++i
)
612 widget
= new QTreeWidgetItem();
613 widget
->setText(0, shows
->at(i
)->title
);
615 widget
->setData(0, Qt::UserRole
, shows
->at(i
)->id
);
616 listArchiveItems
.append(widget
);
619 m_pListArchive
->addTopLevelItems(listArchiveItems
);
621 labelIcon
->movie()->stop();
622 labelIcon
->setPixmap(*pixmapOk
);
623 labelText
->setText(tr("Done."));
626 m_pListArchive
->repaint();
629 void MainWindow::showSelected(QTreeWidgetItem
*item
, int column
)
631 m_pListEpisodes
->clear();
633 QString id
= item
->data(column
, Qt::UserRole
).toString();
634 m_webengine
->getShowVideos(id
);
636 labelIcon
->setMovie(movieLoading
);
637 labelIcon
->movie()->start();
638 labelText
->setText(tr("Loading list of the episodes..."));
641 void MainWindow::episodeSelected(QTreeWidgetItem
*item
, int column
)
643 QString id
= item
->data(column
, Qt::UserRole
).toString();
644 m_webengine
->getVideoLink(id
);
646 labelIcon
->setMovie(movieLoading
);
647 labelIcon
->movie()->start();
648 labelText
->setText(tr("Getting information about the video..."));
651 void MainWindow::addListEpisodeItem(VideoInfo
*video
)
653 static QTreeWidgetItem
*widget
;
654 widget
= new QTreeWidgetItem();
655 widget
->setText(0, video
->date
.toString("d.M.yyyy") + ": " + video
->desc
);
656 widget
->setData(0, Qt::UserRole
, video
->id
);
657 m_pListEpisodes
->addTopLevelItem(widget
);
661 void MainWindow::allEpisodeItemsReady()
663 labelIcon
->movie()->stop();
664 labelIcon
->setPixmap(*pixmapOk
);
665 labelText
->setText(tr("Done."));
667 m_pListEpisodes
->repaint();
671 void MainWindow::webEngineError(WebEngineError
*err
)
673 //labelIcon->movie()->stop();
674 labelIcon
->setPixmap(*pixmapErr
);
675 labelText
->setText(err
->getErrDesc());
678 void MainWindow::getVideoPlaylist(QString
*url
)
680 m_webengine
->getRemoteFile(*url
);
682 labelText
->setText(tr("Downloading playlist..."));
685 /* ======================== Action slots=====================================*/
687 void MainWindow::setFullView()
689 m_pListArchive
->show();
690 m_pListEpisodes
->show();
691 m_pButtonPanelWidget
->show();
693 m_pInfo
->setPixmap(QPixmap(":/images/background.png").scaledToHeight(m_pInfo
->height()));
698 void MainWindow::setPlayerView()
701 m_pListArchive
->hide();
702 m_pListEpisodes
->hide();
703 m_pButtonPanelWidget
->show();
705 m_pInfo
->setPixmap(QPixmap(":/images/background.png").scaledToHeight(m_pInfo
->height()));
706 resize(m_pInfo
->size());
711 void MainWindow::setMinimalView()
713 m_pListArchive
->hide();
714 m_pListEpisodes
->hide();
715 m_pButtonPanelWidget
->hide();
717 m_pInfo
->setPixmap(QPixmap(":/images/background.png").scaledToHeight(m_pInfo
->height()));
719 //this->setWindowFlags(Qt::WindowStaysOnTopHint);
721 resize(m_pInfo
->size());
729 #if defined(WIN32) && defined(RELEASE)
730 void MainWindow::checkForUpdates()
732 // brand new process for updater
733 QProcess::startDetached("updater.exe", QStringList(QCoreApplication::applicationVersion()));
735 close(); // sends closeEvent
737 #endif // defined(WIN32) && defined(RELEASE)