#endif
#include "downloadmanager.h"
#include "temporary.h"
-#include "updatechecker.h"
#include "ytsuggester.h"
#if defined(APP_MAC_SEARCHFIELD) && !defined(APP_MAC_QMACTOOLBAR)
#include "searchlineedit_mac.h"
#include "yt3.h"
#include "ytregions.h"
+#include "invidious.h"
+#include "videoapi.h"
+
#ifdef MEDIA_QTAV
#include "mediaqtav.h"
#endif
#include "mediampv.h"
#endif
+#ifdef UPDATER
+#include "updater.h"
+#endif
+
namespace {
MainWindow *mainWindowInstance;
}
showHome();
#endif
+ if (VideoAPI::impl() == VideoAPI::IV) {
+ Invidious::instance().initServers();
+ } else if (VideoAPI::impl() == VideoAPI::YT3) {
+ YT3::instance().initApiKeys();
+ }
+
QTimer::singleShot(100, this, &MainWindow::lazyInit);
}
ChannelAggregator::instance()->start();
- checkForUpdate();
+#ifdef UPDATER
+ Updater::instance().checkWithoutUI();
+#endif
initialized = true;
}
action->setStatusTip(tr("Hide videos that may contain inappropriate content"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
action->setCheckable(true);
+ action->setVisible(VideoAPI::impl() == VideoAPI::YT3);
actionMap.insert("safeSearch", action);
action = new QAction(tr("Toggle &Menu Bar"), this);
#endif
helpMenu->addAction(getAction("reportIssue"));
helpMenu->addAction(aboutAct);
+#ifdef UPDATER
+ helpMenu->addAction(Updater::instance().getAction());
+#endif
#ifdef APP_MAC_STORE
helpMenu->addSeparator();
}
}
-void MainWindow::checkForUpdate() {
- static const QString updateCheckKey = "updateCheck";
-
- // check every 24h
- QSettings settings;
- uint unixTime = QDateTime::currentDateTime().toTime_t();
- int lastCheck = settings.value(updateCheckKey).toInt();
- int secondsSinceLastCheck = unixTime - lastCheck;
- // qDebug() << "secondsSinceLastCheck" << unixTime << lastCheck << secondsSinceLastCheck;
- if (secondsSinceLastCheck < 86400) return;
-
- // check it out
- UpdateChecker *updateChecker = new UpdateChecker();
- connect(updateChecker, &UpdateChecker::newVersion, this,
- [this, updateChecker](const QString &version) {
- updateChecker->deleteLater();
- QSettings settings;
- QString checkedVersion = settings.value("checkedVersion").toString();
- if (checkedVersion == version) return;
-#ifdef APP_SIMPLEUPDATE
- simpleUpdateDialog(version);
-#elif defined(APP_EXTRA) && !defined(APP_MAC)
- UpdateDialog *dialog = new UpdateDialog(version, this);
- dialog->show();
-#endif
- });
- updateChecker->checkForUpdate();
- settings.setValue(updateCheckKey, unixTime);
-}
-
-void MainWindow::simpleUpdateDialog(const QString &version) {
- QMessageBox msgBox(this);
- msgBox.setIconPixmap(IconUtils::pixmap(":/images/64x64/app.png", devicePixelRatioF()));
- msgBox.setText(tr("%1 version %2 is now available.").arg(Constants::NAME, version));
- msgBox.setModal(true);
- msgBox.setWindowModality(Qt::WindowModal);
- msgBox.addButton(QMessageBox::Close);
- QPushButton *laterButton = msgBox.addButton(tr("Remind me later"), QMessageBox::RejectRole);
- QPushButton *updateButton = msgBox.addButton(tr("Update"), QMessageBox::AcceptRole);
- msgBox.exec();
- if (msgBox.clickedButton() != laterButton) {
- QSettings settings;
- settings.setValue("checkedVersion", version);
- }
- if (msgBox.clickedButton() == updateButton) visitSite();
-}
-
bool MainWindow::needStatusBar() {
return !statusToolBar->actions().isEmpty();
}