/** * @brief Called when the action "Save all" was clicked * Delegates the event down to the current subwidget */ void MainWindow::onActionSaveAll() { qDebug() << "Entered, currentIndex=" << ui->stackedWidget->currentIndex(); if (ui->stackedWidget->currentIndex() == 0) ui->movieWidget->saveAll(); else if (ui->stackedWidget->currentIndex() == 1) ui->tvShowWidget->onSaveAll(); else if (ui->stackedWidget->currentIndex() == 3) ui->concertWidget->onSaveAll(); setNewMarks(); }
/** * @brief Restores all menu icons to defaults and enables actions * @param widget Current widget */ void MainWindow::onMenu(MainWidgets widget) { m_icons.insert(WidgetMovies, QIcon(":/img/video_menu.png")); m_icons.insert(WidgetTvShows, QIcon(":/img/display_on_menu.png")); m_icons.insert(WidgetMovieSets, QIcon(":/img/movieSets_menu.png")); m_icons.insert(WidgetGenres, QIcon(":/img/genre_menu.png")); m_icons.insert(WidgetCertifications, QIcon(":/img/certification2_menu.png")); m_icons.insert(WidgetConcerts, QIcon(":/img/concerts_menu.png")); m_icons.insert(WidgetDownloads, QIcon(":/img/downloads_menu.png")); if (widget == WidgetMovies) m_icons.insert(widget, QIcon(":/img/video_menuActive.png")); else if (widget == WidgetTvShows) m_icons.insert(widget, QIcon(":/img/display_on_menuActive.png")); else if (widget == WidgetConcerts) m_icons.insert(widget, QIcon(":/img/concerts_menuActive.png")); else if (widget == WidgetGenres) m_icons.insert(widget, QIcon(":/img/genre_menuActive.png")); else if (widget == WidgetMovieSets) m_icons.insert(widget, QIcon(":/img/movieSets_menuActive.png")); else if (widget == WidgetCertifications) m_icons.insert(widget, QIcon(":/img/certification2_menuActive.png")); else if (widget == WidgetDownloads) m_icons.insert(widget, QIcon(":/img/downloads_menuActive.png")); ui->buttonMovies->setIcon(m_icons.value(WidgetMovies)); ui->buttonMovieSets->setIcon(m_icons.value(WidgetMovieSets)); ui->buttonGenres->setIcon(m_icons.value(WidgetGenres)); ui->buttonCertifications->setIcon(m_icons.value(WidgetCertifications)); ui->buttonTvshows->setIcon(m_icons.value(WidgetTvShows)); ui->buttonConcerts->setIcon(m_icons.value(WidgetConcerts)); ui->buttonDownloads->setIcon(m_icons.value(WidgetDownloads)); setNewMarks(); setNewMarkForImports(ui->downloadsWidget->hasNewItems()); ui->navbar->setActionSearchEnabled(m_actions[widget][ActionSearch]); ui->navbar->setActionSaveEnabled(m_actions[widget][ActionSave]); ui->navbar->setActionSaveAllEnabled(m_actions[widget][ActionSaveAll]); ui->navbar->setActionRenameEnabled(m_actions[widget][ActionRename]); ui->navbar->setFilterWidgetEnabled(m_actions[widget][ActionFilterWidget]); ui->navbar->setActiveWidget(widget); ui->navbar->setActionReloadEnabled(widget == WidgetMovies || widget == WidgetTvShows || widget == WidgetConcerts || widget == WidgetDownloads); if (widget == WidgetMovies) ui->navbar->setReloadToolTip(tr("Reload all Movies (%1)").arg(QKeySequence(QKeySequence::Refresh).toString(QKeySequence::NativeText))); else if (widget == WidgetTvShows) ui->navbar->setReloadToolTip(tr("Reload all TV Shows (%1)").arg(QKeySequence(QKeySequence::Refresh).toString(QKeySequence::NativeText))); else if (widget == WidgetConcerts) ui->navbar->setReloadToolTip(tr("Reload all Concerts (%1)").arg(QKeySequence(QKeySequence::Refresh).toString(QKeySequence::NativeText))); else if (widget == WidgetDownloads) ui->navbar->setReloadToolTip(tr("Reload all Downloads (%1)").arg(QKeySequence(QKeySequence::Refresh).toString(QKeySequence::NativeText))); }
/** * @brief Called when the action "Save" was clicked * Delegates the event down to the current subwidget */ void MainWindow::onActionSave() { qDebug() << "Entered, currentIndex=" << ui->stackedWidget->currentIndex(); if (ui->stackedWidget->currentIndex() == 0) ui->movieWidget->saveInformation(); else if (ui->stackedWidget->currentIndex() == 1) ui->tvShowWidget->onSaveInformation(); else if (ui->stackedWidget->currentIndex() == 2) ui->setsWidget->saveSet(); else if (ui->stackedWidget->currentIndex() == 3) ui->concertWidget->onSaveInformation(); else if (ui->stackedWidget->currentIndex() == 4) ui->genreWidget->onSaveInformation(); else if (ui->stackedWidget->currentIndex() == 5) ui->certificationWidget->onSaveInformation(); setNewMarks(); }
/** * @brief MainWindow::MainWindow * @param parent */ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); MainWindow::m_instance = this; qDebug() << "MediaElch version" << QApplication::applicationVersion() << "starting up"; for (int i=WidgetMovies ; i!=WidgetCertifications ; i++) { QMap<MainActions, bool> actions; for (int n=ActionSearch ; n!=ActionExport ; n++) { actions.insert(static_cast<MainActions>(n), false); } if (static_cast<MainWidgets>(i) == WidgetMovies || static_cast<MainWidgets>(i) == WidgetTvShows || static_cast<MainWidgets>(i) == WidgetConcerts) actions[ActionFilterWidget] = true; m_actions.insert(static_cast<MainWidgets>(i), actions); } m_aboutDialog = new AboutDialog(ui->centralWidget); m_supportDialog = new SupportDialog(ui->centralWidget); m_settingsWindow = new SettingsWindow(ui->centralWidget); m_filterWidget = new FilterWidget(); m_fileScannerDialog = new FileScannerDialog(ui->centralWidget); m_xbmcSync = new XbmcSync(ui->centralWidget); m_renamer = new Renamer(ui->centralWidget); m_settings = Settings::instance(this); m_exportDialog = new ExportDialog(this); setupToolbar(); MessageBox::instance(this)->reposition(this->size()); Manager::instance(); if (!m_settings->mainSplitterState().isNull()) { ui->movieSplitter->restoreState(m_settings->mainSplitterState()); ui->tvShowSplitter->restoreState(m_settings->mainSplitterState()); ui->setsWidget->splitter()->restoreState(m_settings->mainSplitterState()); ui->concertSplitter->restoreState(m_settings->mainSplitterState()); ui->genreWidget->splitter()->restoreState(m_settings->mainSplitterState()); ui->certificationWidget->splitter()->restoreState(m_settings->mainSplitterState()); } if (m_settings->mainWindowSize().isValid() && !m_settings->mainWindowPosition().isNull()) { #ifdef Q_OS_MAC // Ugly workaround from https://bugreports.qt-project.org/browse/QTBUG-3116 // to fix invisible toolbar on mac bool workaround = !isVisible(); if (workaround) { // make "invisible" setWindowOpacity(0); // let Qt update its frameStruts show(); } resize(m_settings->mainWindowSize()); if (workaround) { move(m_settings->mainWindowPosition()); setWindowOpacity(1); } #else resize(m_settings->mainWindowSize()); move(m_settings->mainWindowPosition()); #endif #ifdef Q_OS_WIN32 if (m_settings->mainWindowMaximized()) showMaximized(); #endif } // Size for Screenshots // resize(1121, 735); #ifdef Q_OS_MAC MacFullscreen::addFullscreen(this); #endif connect(ui->filesWidget, SIGNAL(movieSelected(Movie*)), ui->movieWidget, SLOT(setMovie(Movie*))); connect(ui->filesWidget, SIGNAL(movieSelected(Movie*)), ui->movieWidget, SLOT(setEnabledTrue(Movie*))); connect(ui->filesWidget, SIGNAL(noMovieSelected()), ui->movieWidget, SLOT(clear())); connect(ui->filesWidget, SIGNAL(noMovieSelected()), ui->movieWidget, SLOT(setDisabledTrue())); connect(ui->filesWidget, SIGNAL(sigStartSearch()), this, SLOT(onActionSearch())); connect(ui->concertFilesWidget, SIGNAL(concertSelected(Concert*)), ui->concertWidget, SLOT(setConcert(Concert*))); connect(ui->concertFilesWidget, SIGNAL(concertSelected(Concert*)), ui->concertWidget, SLOT(setEnabledTrue(Concert*))); connect(ui->concertFilesWidget, SIGNAL(noConcertSelected()), ui->concertWidget, SLOT(clear())); connect(ui->concertFilesWidget, SIGNAL(noConcertSelected()), ui->concertWidget, SLOT(setDisabledTrue())); connect(ui->tvShowFilesWidget, SIGNAL(sigTvShowSelected(TvShow*)), ui->tvShowWidget, SLOT(onTvShowSelected(TvShow*))); connect(ui->tvShowFilesWidget, SIGNAL(sigSeasonSelected(TvShow*,int)), ui->tvShowWidget, SLOT(onSeasonSelected(TvShow*,int))); connect(ui->tvShowFilesWidget, SIGNAL(sigEpisodeSelected(TvShowEpisode*)), ui->tvShowWidget, SLOT(onEpisodeSelected(TvShowEpisode*))); connect(ui->tvShowFilesWidget, SIGNAL(sigTvShowSelected(TvShow*)), ui->tvShowWidget, SLOT(onSetEnabledTrue(TvShow*))); connect(ui->tvShowFilesWidget, SIGNAL(sigSeasonSelected(TvShow*,int)), ui->tvShowWidget, SLOT(onSetEnabledTrue(TvShow*, int))); connect(ui->tvShowFilesWidget, SIGNAL(sigEpisodeSelected(TvShowEpisode*)), ui->tvShowWidget, SLOT(onSetEnabledTrue(TvShowEpisode*))); connect(ui->tvShowFilesWidget, SIGNAL(sigNothingSelected()), ui->tvShowWidget, SLOT(onClear())); connect(ui->tvShowFilesWidget, SIGNAL(sigNothingSelected()), ui->tvShowWidget, SLOT(onSetDisabledTrue())); connect(ui->movieWidget, SIGNAL(actorDownloadProgress(int,int,int)), this, SLOT(progressProgress(int,int,int))); connect(ui->movieWidget, SIGNAL(actorDownloadStarted(QString,int)), this, SLOT(progressStarted(QString,int))); connect(ui->movieWidget, SIGNAL(actorDownloadFinished(int)), this, SLOT(progressFinished(int))); connect(ui->tvShowWidget, SIGNAL(sigDownloadsStarted(QString,int)), this, SLOT(progressStarted(QString,int))); connect(ui->tvShowWidget, SIGNAL(sigDownloadsProgress(int,int,int)), this, SLOT(progressProgress(int,int,int))); connect(ui->tvShowWidget, SIGNAL(sigDownloadsFinished(int)), this, SLOT(progressFinished(int))); connect(m_filterWidget, SIGNAL(sigFilterChanged(QList<Filter*>,QString)), this, SLOT(onFilterChanged(QList<Filter*>,QString))); connect(ui->movieSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int))); connect(ui->tvShowSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int))); connect(ui->setsWidget->splitter(), SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int))); connect(ui->genreWidget->splitter(), SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int))); connect(ui->certificationWidget->splitter(), SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int))); connect(ui->concertSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(moveSplitter(int,int))); connect(Manager::instance()->tvShowFileSearcher(), SIGNAL(tvShowsLoaded(int)), ui->tvShowFilesWidget, SLOT(renewModel())); connect(m_fileScannerDialog, SIGNAL(accepted()), this, SLOT(setNewMarks())); connect(m_xbmcSync, SIGNAL(sigTriggerReload()), this, SLOT(onTriggerReloadAll())); connect(m_xbmcSync, SIGNAL(sigFinished()), this, SLOT(onXbmcSyncFinished())); connect(m_renamer, SIGNAL(sigFilesRenamed(Renamer::RenameType)), this, SLOT(onFilesRenamed(Renamer::RenameType))); connect(m_settingsWindow, SIGNAL(sigSaved()), this, SLOT(onRenewModels()), Qt::QueuedConnection); connect(ui->setsWidget, SIGNAL(sigJumpToMovie(Movie*)), this, SLOT(onJumpToMovie(Movie*))); connect(ui->certificationWidget, SIGNAL(sigJumpToMovie(Movie*)), this, SLOT(onJumpToMovie(Movie*))); connect(ui->genreWidget, SIGNAL(sigJumpToMovie(Movie*)), this, SLOT(onJumpToMovie(Movie*))); MovieSearch::instance(ui->centralWidget); TvShowSearch::instance(ui->centralWidget); ImageDialog::instance(ui->centralWidget); MovieListDialog::instance(ui->centralWidget); ImagePreviewDialog::instance(ui->centralWidget); ConcertSearch::instance(ui->centralWidget); TrailerDialog::instance(ui->centralWidget); TvTunesDialog::instance(ui->centralWidget); NameFormatter::instance(this); MovieMultiScrapeDialog::instance(ui->centralWidget); #ifdef Q_OS_WIN32 setStyleSheet(styleSheet() + " #centralWidget { border-bottom: 1px solid rgba(0, 0, 0, 100); } "); QFont font = ui->labelMovies->font(); font.setPointSize(font.pointSize()-3); font.setBold(true); ui->labelMovies->setFont(font); ui->labelConcerts->setFont(font); ui->labelShows->setFont(font); #endif // hack. without only the fileScannerDialog pops up and blocks until it has finished show(); onMenu(WidgetMovies); // Start scanning for files QTimer::singleShot(0, m_fileScannerDialog, SLOT(exec())); }