mediaObject(0),
audioOutput(0),
#endif
- m_fullscreen(false),
- m_compact(false) {
+ fullscreenFlag(false),
+ m_compact(false),
+ initialized(false) {
singleton = this;
#endif
// views mechanism
- history = new QStack<QWidget*>();
views = new QStackedWidget();
views->hide();
setCentralWidget(views);
QTimer::singleShot(0, this, SLOT(lazyInit()));
}
-MainWindow::~MainWindow() {
- delete history;
-}
-
void MainWindow::lazyInit() {
#ifdef APP_PHONON
initPhonon();
JsFunctions::instance();
- checkForUpdate();
-
// Hack to give focus to searchlineedit
QMetaObject::invokeMethod(views->currentWidget(), "appear");
View* view = qobject_cast<View *> (views->currentWidget());
QString desc = view->metadata().value("description").toString();
if (!desc.isEmpty()) showMessage(desc);
+#ifdef APP_INTEGRITY
+ if (!Extra::integrityCheck()) {
+ deleteLater();
+ return;
+ }
+#endif
+
ChannelAggregator::instance()->start();
+
+ checkForUpdate();
+
+ initialized = true;
}
void MainWindow::changeEvent(QEvent *e) {
bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
- if (m_fullscreen && e->type() == QEvent::MouseMove) {
-
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (e);
- const int x = mouseEvent->pos().x();
- const QString className = QString(obj->metaObject()->className());
+ if (fullscreenFlag && e->type() == QEvent::MouseMove) {
+ const char *className = obj->metaObject()->className();
const bool isHoveringVideo =
(className == QLatin1String("QGLWidget")) ||
(className == QLatin1String("VideoAreaWidget"));
// qDebug() << obj << mouseEvent->pos() << isHoveringVideo << mediaView->isPlaylistVisible();
- if (mediaView && mediaView->isPlaylistVisible()) {
- if (isHoveringVideo && x > 5) mediaView->setPlaylistVisible(false);
- } else {
- if (isHoveringVideo && x >= 0 && x < 5) mediaView->setPlaylistVisible(true);
- }
+ if (isHoveringVideo) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (e);
+ const int x = mouseEvent->pos().x();
+
+ if (mediaView->isPlaylistVisible()) {
+ if (x > 5) mediaView->setPlaylistVisible(false);
+ } else {
+ if (x >= 0 && x < 5) mediaView->setPlaylistVisible(true);
+ }
#ifndef APP_MAC
- const int y = mouseEvent->pos().y();
- if (mainToolBar->isVisible()) {
- if (isHoveringVideo && y > 5) mainToolBar->setVisible(false);
- } else {
- if (isHoveringVideo && y >= 0 && y < 5) mainToolBar->setVisible(true);
- }
+ const int y = mouseEvent->pos().y();
+ if (mainToolBar->isVisible()) {
+ if (y > 5) mainToolBar->setVisible(false);
+ } else {
+ if (y >= 0 && y < 5) mainToolBar->setVisible(true);
+ }
#endif
+ }
+
// show the normal cursor
unsetCursor();
// then hide it again after a few seconds
mouseTimer->start();
-
}
if (e->type() == QEvent::ToolTip) {
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
action->setCheckable(true);
action->setIcon(IconUtils::icon("document-save"));
- action->setVisible(false);
connect(action, SIGNAL(toggled(bool)), SLOT(toggleDownloads(bool)));
actions->insert("downloads", action);
toolbarSearch = searchWrapper->getSearchLineEdit();
#else
toolbarSearch = new SearchLineEdit(this);
- qDebug() << "Qt SearchLineEdit" << toolbarSearch;
#endif
toolbarSearch->setMinimumWidth(toolbarSearch->fontInfo().pixelSize()*15);
toolbarSearch->setSuggester(new YTSuggester(this));
statusToolBar = new QToolBar(this);
statusToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
statusToolBar->setIconSize(QSize(16, 16));
- // statusToolBar->addAction(The::globalActions()->value("downloads"));
regionAction = new QAction(this);
regionAction->setStatusTip(tr("Choose your content location"));
#endif
if (show) {
statusToolBar->insertAction(statusToolBar->actions().first(), action);
- if (statusBar()->isHidden() && !m_fullscreen)
+ if (statusBar()->isHidden() && !fullscreenFlag)
setStatusBarVisibility(true);
} else {
statusToolBar->removeAction(action);
if (statusBar()->isVisible() && !needStatusBar())
- if (m_fullscreen && views->currentWidget() == mediaView)
- setStatusBarVisibility(false);
+ setStatusBarVisibility(false);
}
}
void MainWindow::writeSettings() {
QSettings settings;
- settings.setValue("geometry", saveGeometry());
+ if (!isReallyFullScreen())
+ settings.setValue("geometry", saveGeometry());
mediaView->saveSplitterState();
#ifdef APP_PHONON
}
void MainWindow::goBack() {
- if ( history->size() > 1 ) {
- history->pop();
- QWidget *widget = history->pop();
+ if (history.size() > 1) {
+ history.pop();
+ QWidget *widget = history.pop();
showWidget(widget);
}
}
else title += QLatin1String(" - ") + Constants::NAME;
setWindowTitle(title);
+ statusToolBar->setUpdatesEnabled(false);
+
// dynamic view actions
foreach (QAction* action, viewActions)
showActionInStatusBar(action, false);
adjustStatusBarVisibility();
messageLabel->hide();
+ statusToolBar->setUpdatesEnabled(true);
+
/*
QString desc = metadata.value("description").toString();
if (!desc.isEmpty()) showMessage(desc);
*/
}
- history->push(widget);
+ history.push(widget);
}
void MainWindow::about() {
}
#endif
// do not save geometry when in full screen or in compact mode
- if (!m_fullscreen && !compactViewAct->isChecked()) {
+ if (!fullscreenFlag && !compactViewAct->isChecked()) {
writeSettings();
}
// mediaView->stop();
bool MainWindow::confirmQuit() {
if (DownloadManager::instance()->activeItems() > 0) {
QMessageBox msgBox(this);
- msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ msgBox.setIconPixmap(IconUtils::pixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
msgBox.setText(tr("Do you want to exit %1 with a download in progress?").arg(Constants::NAME));
msgBox.setInformativeText(tr("If you close %1 now, this download will be cancelled.").arg(Constants::NAME));
msgBox.setModal(true);
mediaView->stop();
}
-void MainWindow::resizeEvent(QResizeEvent*e) {
+void MainWindow::resizeEvent(QResizeEvent *e) {
Q_UNUSED(e);
#ifdef APP_MAC
- if (mac::CanGoFullScreen(winId())) {
+ if (initialized && mac::CanGoFullScreen(winId())) {
bool isFullscreen = mac::IsFullScreen(winId());
- if (isFullscreen != m_fullscreen) {
+ if (isFullscreen != fullscreenFlag) {
if (compactViewAct->isChecked()) {
compactViewAct->setChecked(false);
compactView(false);
}
- m_fullscreen = isFullscreen;
+ fullscreenFlag = isFullscreen;
updateUIForFullscreen();
}
}
if (compactViewAct->isChecked())
compactViewAct->toggle();
- m_fullscreen = !m_fullscreen;
-
#ifdef APP_MAC
WId handle = winId();
if (mac::CanGoFullScreen(handle)) {
}
#endif
- if (m_fullscreen) {
+ fullscreenFlag = !fullscreenFlag;
+
+ if (fullscreenFlag) {
// Enter full screen
m_maximized = isMaximized();
static QList<QKeySequence> fsShortcuts;
static QString fsText;
- if (m_fullscreen) {
+ if (fullscreenFlag) {
fsShortcuts = fullscreenAct->shortcuts();
fsText = fullscreenAct->text();
+ if (fsText.isEmpty()) qDebug() << "[taking Empty!]";
fullscreenAct->setShortcuts(QList<QKeySequence>(fsShortcuts)
<< QKeySequence(Qt::Key_Escape));
fullscreenAct->setText(tr("Leave &Full Screen"));
setStatusBarVisibility(false);
} else {
fullscreenAct->setShortcuts(fsShortcuts);
+ if (fsText.isEmpty()) fsText = "[Empty!]";
fullscreenAct->setText(fsText);
fullscreenAct->setIcon(IconUtils::icon("view-fullscreen"));
}
// No compact view action when in full screen
- compactViewAct->setVisible(!m_fullscreen);
+ compactViewAct->setVisible(!fullscreenFlag);
compactViewAct->setChecked(false);
// Hide anything but the video
- mediaView->setPlaylistVisible(!m_fullscreen);
- if (mainToolBar) mainToolBar->setVisible(!m_fullscreen);
+ mediaView->setPlaylistVisible(!fullscreenFlag);
+ if (mainToolBar) mainToolBar->setVisible(!fullscreenFlag);
#ifndef APP_MAC
- menuBar()->setVisible(!m_fullscreen);
+ menuBar()->setVisible(!fullscreenFlag);
#endif
- if (m_fullscreen) {
+ if (fullscreenFlag) {
stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_MediaStop));
} else {
stopAct->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop));
}
#ifdef Q_OS_MAC
- MacSupport::fullScreenActions(The::globalActions()->values(), m_fullscreen);
+ MacSupport::fullScreenActions(The::globalActions()->values(), fullscreenFlag);
#endif
if (views->currentWidget() == mediaView)
mediaView->setFocus();
- if (m_fullscreen) {
+ if (fullscreenFlag) {
hideMouse();
} else {
mouseTimer->stop();
}
void MainWindow::showFullscreenToolbar(bool show) {
- if (!m_fullscreen) return;
+ if (!fullscreenFlag) return;
mainToolBar->setVisible(show);
}
void MainWindow::showFullscreenPlaylist(bool show) {
- if (!m_fullscreen) return;
+ if (!fullscreenFlag) return;
mediaView->setPlaylistVisible(show);
}
void MainWindow::simpleUpdateDialog(const QString &version) {
QMessageBox msgBox(this);
msgBox.setIconPixmap(
- QPixmap(":/images/app.png")
+ IconUtils::pixmap(":/images/app.png")
.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
msgBox.setText(tr("%1 version %2 is now available.").arg(Constants::NAME, version));
msgBox.setModal(true);