void DownloadQueueSet::addJob( HttpJob * const job ) { m_jobs.push( job ); mDebug() << "addJob: new job queue size:" << m_jobs.count(); emit jobAdded(); activateJobs(); }
TreeModel::TreeModel( QObject* parent ) : QAbstractItemModel( parent ) , m_rootItem( new TreeModelItem( downloadjob_ptr(), 0, this ) ) { addJobs( DownloadManager::instance()->jobs() ); connect( DownloadManager::instance(), SIGNAL( jobAdded( downloadjob_ptr ) ), SLOT( onJobAdded( downloadjob_ptr ) ) ); }
bool QueueLocal::submit(Job *job) { m_jobs.push_back(job); job->setStatus(Job::QUEUED); emit(jobAdded(job)); if (m_currentJob == m_jobs.size() - 1) runProgram(m_jobs.size() - 1); return true; }
void JobWidget::saveNew() { DEBUG << "SAVE NEW JOB"; if(_job->objectKey().isEmpty() && canSaveNew()) { _job->setName(_ui->jobNameLineEdit->text()); _job->setUrls(_ui->newJobTreeWidget->getSelectedUrls()); _job->setOptionPreservePaths(_ui->preservePathsCheckBox->isChecked()); _job->setOptionTraverseMount(_ui->traverseMountCheckBox->isChecked()); _job->setOptionFollowSymLinks(_ui->followSymLinksCheckBox->isChecked()); _job->setOptionSkipFilesSize(_ui->skipFilesSpinBox->value()); _job->save(); emit jobAdded(_job); } }
MainWindow::MainWindow(QWidget *parent) : QWidget(parent), _ui(new Ui::MainWindow), _tarsnapLogo(this), _menuBar(NULL), _appMenu(NULL), _actionAbout(this), _useSIPrefixes(false), _purgeTimerCount(0), _purgeCountdownWindow(this) { _ui->setupUi(this); _ui->backupListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); _ui->archiveListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); _ui->jobListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); QPixmap logo(":/resources/icons/tarsnap.png"); _tarsnapLogo.setPixmap(logo.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation)); _tarsnapLogo.adjustSize(); _tarsnapLogo.lower(); _tarsnapLogo.show(); Ui::aboutWidget aboutUi; aboutUi.setupUi(&_aboutWindow); aboutUi.versionLabel->setText(tr("version ") + QCoreApplication::applicationVersion()); _aboutWindow.setWindowFlags(Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint); connect(aboutUi.checkUpdateButton, &QPushButton::clicked, [=](){ QDesktopServices::openUrl(QUrl("https://github.com/Tarsnap/tarsnap-gui/releases")); }); if(_menuBar.isNativeMenuBar()) { _actionAbout.setMenuRole(QAction::AboutRole); connect(&_actionAbout, SIGNAL(triggered()), &_aboutWindow, SLOT(show())); _appMenu.addAction(&_actionAbout); _menuBar.addMenu(&_appMenu); } connect(_ui->aboutButton, SIGNAL(clicked()), &_aboutWindow, SLOT(show())); _ui->mainContentSplitter->setCollapsible(0, false); _ui->journalLog->hide(); _ui->archiveDetailsWidget->hide(); _ui->jobDetailsWidget->hide(); connect(&Debug::instance(), SIGNAL(message(QString)), this , SLOT(appendToConsoleLog(QString)) , Qt::QueuedConnection); loadSettings(); // Ui actions _ui->mainTabWidget->setCurrentWidget(_ui->backupTab); _ui->settingsToolbox->setCurrentWidget(_ui->settingsAccountPage); _ui->archiveListWidget->addAction(_ui->actionRefresh); connect(_ui->actionRefresh, SIGNAL(triggered()), _ui->archiveListWidget , SIGNAL(getArchiveList()), Qt::QueuedConnection); _ui->backupListWidget->addAction(_ui->actionClearList); connect(_ui->actionClearList, SIGNAL(triggered()), _ui->backupListWidget , SLOT(clear()), Qt::QueuedConnection); _ui->backupListWidget->addAction(_ui->actionBrowseItems); connect(_ui->actionBrowseItems, SIGNAL(triggered()), this, SLOT(browseForBackupItems())); _ui->jobListWidget->addAction(_ui->actionAddJob); connect(_ui->actionAddJob, SIGNAL(triggered()), this, SLOT(addJobClicked())); _ui->jobListWidget->addAction(_ui->actionJobBackup); connect(_ui->actionJobBackup, SIGNAL(triggered()), _ui->jobListWidget, SLOT(backupSelectedItems())); _ui->settingsTab->addAction(_ui->actionRefreshStats); connect(_ui->actionRefreshStats, SIGNAL(triggered()), this, SIGNAL(getOverallStats())); this->addAction(_ui->actionGoBackup); this->addAction(_ui->actionGoBrowse); this->addAction(_ui->actionGoJobs); this->addAction(_ui->actionGoSettings); this->addAction(_ui->actionGoHelp); connect(_ui->actionGoBackup, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->backupTab); }); connect(_ui->actionGoBrowse, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->archivesTab); }); connect(_ui->actionGoJobs, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->jobsTab); }); connect(_ui->actionGoSettings, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->settingsTab); }); connect(_ui->actionGoHelp, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->helpTab); }); connect(_ui->backupListInfoLabel, SIGNAL(linkActivated(QString)), this, SLOT(browseForBackupItems())); connect(_ui->backupButton, SIGNAL(clicked()), this, SLOT(backupButtonClicked())); connect(_ui->appendTimestampCheckBox, SIGNAL(toggled(bool)), this, SLOT(appendTimestampCheckBoxToggled(bool))); connect(_ui->accountMachineUseHostnameButton, SIGNAL(clicked()), this, SLOT(accountMachineUseHostnameButtonClicked())); connect(_ui->accountMachineKeyBrowseButton, SIGNAL(clicked()), this, SLOT(accountMachineKeyBrowseButtonClicked())); connect(_ui->tarsnapPathBrowseButton, SIGNAL(clicked()), this, SLOT(tarsnapPathBrowseButtonClicked())); connect(_ui->tarsnapCacheBrowseButton, SIGNAL(clicked()), this, SLOT(tarsnapCacheBrowseButton())); connect(_ui->repairCacheButton, SIGNAL(clicked()), this, SLOT(repairCacheButtonClicked())); connect(_ui->purgeArchivesButton, SIGNAL(clicked()), this, SLOT(purgeArchivesButtonClicked())); connect(_ui->runSetupWizard, SIGNAL(clicked()), this, SLOT(runSetupWizardClicked())); connect(_ui->expandJournalButton, SIGNAL(toggled(bool)), this, SLOT(expandJournalButtonToggled(bool))); connect(_ui->downloadsDirBrowseButton, SIGNAL(clicked()), this, SLOT(downloadsDirBrowseButtonClicked())); connect(_ui->busyWidget, SIGNAL(clicked()), this, SLOT(cancelRunningTasks())); connect(&_purgeTimer, SIGNAL(timeout()), this, SLOT(purgeTimerFired())); // Settings page connect(_ui->accountUserLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->accountMachineLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->accountMachineKeyLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->tarsnapPathLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->tarsnapCacheLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->aggressiveNetworkingCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->accountMachineKeyLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateMachineKeyPath())); connect(_ui->tarsnapPathLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateTarsnapPath())); connect(_ui->tarsnapCacheLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateTarsnapCache())); connect(_ui->siPrefixesCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->preservePathsCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->downloadsDirLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->traverseMountCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->followSymLinksCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->skipFilesSpinBox, SIGNAL(editingFinished()), this, SLOT(commitSettings())); // Backup and Browse connect(_ui->backupListWidget, SIGNAL(itemTotals(qint64,qint64)), this , SLOT(updateBackupItemTotals(qint64, qint64))); connect(_ui->archiveListWidget, SIGNAL(getArchiveList()), this, SIGNAL(getArchiveList())); connect(this, SIGNAL(archiveList(QList<ArchivePtr >)) , _ui->archiveListWidget, SLOT(addArchives(QList<ArchivePtr >))); connect(_ui->archiveListWidget, SIGNAL(inspectArchive(ArchivePtr)), this , SLOT(displayInspectArchive(ArchivePtr))); connect(_ui->archiveListWidget, SIGNAL(deleteArchives(QList<ArchivePtr>)), this , SIGNAL(deleteArchives(QList<ArchivePtr>))); connect(_ui->archiveListWidget, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), this, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions))); connect(_ui->mainTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPaneChanged(int))); // Jobs connect(_ui->addJobButton, SIGNAL(clicked()), this, SLOT(addJobClicked()), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(cancel()), this, SLOT(hideJobDetails()), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(jobAdded(JobPtr)), _ui->jobListWidget, SLOT(addJob(JobPtr)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(jobAdded(JobPtr)), this, SLOT(displayJobDetails(JobPtr)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(inspectJobArchive(ArchivePtr)), this, SLOT(displayInspectArchive(ArchivePtr)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(restoreJobArchive(ArchivePtr,ArchiveRestoreOptions)), this, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(deleteJobArchives(QList<ArchivePtr>)), this, SIGNAL(deleteArchives(QList<ArchivePtr>)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(enableSave(bool)), _ui->addJobButton, SLOT(setEnabled(bool)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(displayJobDetails(JobPtr)), this, SLOT(displayJobDetails(JobPtr)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(backupJob(BackupTaskPtr)), this, SIGNAL(backupNow(BackupTaskPtr)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), this, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(deleteJobArchives(QList<ArchivePtr>)), this, SIGNAL(deleteArchives(QList<ArchivePtr>)), Qt::QueuedConnection); //lambda slots to quickly update various UI components connect(_ui->archiveListWidget, &ArchiveListWidget::getArchiveList, [=](){updateStatusMessage(tr("Refreshing archives list..."));}); connect(this, &MainWindow::archiveList, [=](){updateStatusMessage(tr("Refreshing archives list...done"));}); connect(this, &MainWindow::loadArchiveStats, [=](const ArchivePtr archive){updateStatusMessage(tr("Fetching details for archive <i>%1</i>.").arg(archive->name()));}); connect(this, &MainWindow::loadArchiveContents, [=](const ArchivePtr archive){updateStatusMessage(tr("Fetching contents for archive <i>%1</i>.").arg(archive->name()));}); connect(_ui->archiveListWidget, &ArchiveListWidget::deleteArchives, [=](const QList<ArchivePtr> archives){archivesDeleted(archives,false);}); connect(_ui->backupNameLineEdit, &QLineEdit::textChanged, [=](const QString text){ if(text.isEmpty()) { _ui->backupButton->setEnabled(false); _ui->appendTimestampCheckBox->setChecked(false); } else if(_ui->backupListWidget->count()) { _ui->backupButton->setEnabled(true); } }); connect(this, &MainWindow::restoreArchive, [=](const ArchivePtr archive){updateStatusMessage(tr("Restoring archive <i>%1</i>...").arg(archive->name()));}); connect(_ui->downloadsDirLineEdit, &QLineEdit::textChanged, [=](){ QFileInfo file(_ui->downloadsDirLineEdit->text()); if(file.exists() && file.isDir() && file.isWritable()) _ui->downloadsDirLineEdit->setStyleSheet("QLineEdit{color:black;}"); else _ui->downloadsDirLineEdit->setStyleSheet("QLineEdit{color:red;}"); }); connect(_ui->jobListWidget, &JobListWidget::backupJob, [=](BackupTaskPtr backup){ connect(backup, SIGNAL(statusUpdate(const TaskStatus&)), this, SLOT(backupTaskUpdate(const TaskStatus&)), Qt::QueuedConnection); });
void Conveyor::emitJobAdded (Job * const j) { emit jobAdded(j); }
MainWindow::MainWindow() : QMainWindow(0) , ui(new Ui::MainWindow) , m_isKKeyPressed(false) { // Create the UI. ui->setupUi(this); #ifndef Q_WS_X11 ui->mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); #endif setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setDockNestingEnabled(true); // These use the icon theme on Linux, with fallbacks to the icons specified in QtDesigner for other platforms. ui->actionOpen->setIcon(QIcon::fromTheme("document-open", ui->actionOpen->icon())); ui->actionSave->setIcon(QIcon::fromTheme("document-save", ui->actionSave->icon())); ui->actionEncode->setIcon(QIcon::fromTheme("media-record", ui->actionEncode->icon())); // Connect UI signals. connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openVideo())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); // Accept drag-n-drop of files. this->setAcceptDrops(true); // Add the player widget. QLayout* layout = new QVBoxLayout(ui->playerPage); layout->setObjectName("centralWidgetLayout"); layout->setMargin(0); m_player = new Player(this); layout->addWidget(m_player); connect(this, SIGNAL(producerOpened()), m_player, SLOT(onProducerOpened())); connect(m_player, SIGNAL(showStatusMessage(QString)), this, SLOT(showStatusMessage(QString))); connect(m_player, SIGNAL(inChanged(int)), this, SLOT(onCutModified())); connect(m_player, SIGNAL(outChanged(int)), this, SLOT(onCutModified())); // Add the docks. m_propertiesDock = new QDockWidget(tr("Properties")); m_propertiesDock->hide(); m_propertiesDock->setObjectName("propertiesDock"); m_propertiesDock->setWindowIcon(QIcon((":/icons/icons/view-form.png"))); m_propertiesDock->toggleViewAction()->setIcon(QIcon::fromTheme("view-form", m_propertiesDock->windowIcon())); addDockWidget(Qt::LeftDockWidgetArea, m_propertiesDock); ui->menuView->addAction(m_propertiesDock->toggleViewAction()); ui->mainToolBar->addAction(m_propertiesDock->toggleViewAction()); connect(m_propertiesDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onPropertiesDockTriggered(bool))); m_recentDock = new RecentDock(this); m_recentDock->hide(); addDockWidget(Qt::LeftDockWidgetArea, m_recentDock); ui->menuView->addAction(m_recentDock->toggleViewAction()); ui->mainToolBar->addAction(m_recentDock->toggleViewAction()); connect(m_recentDock, SIGNAL(itemActivated(QString)), this, SLOT(open(QString))); connect(m_recentDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onRecentDockTriggered(bool))); m_playlistDock = new PlaylistDock(this); m_playlistDock->hide(); addDockWidget(Qt::LeftDockWidgetArea, m_playlistDock); ui->menuView->addAction(m_playlistDock->toggleViewAction()); ui->mainToolBar->addAction(m_playlistDock->toggleViewAction()); connect(m_playlistDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onPlaylistDockTriggered(bool))); connect(m_playlistDock, SIGNAL(clipOpened(void*,int,int)), this, SLOT(openCut(void*, int, int))); connect(m_playlistDock, SIGNAL(itemActivated(int)), this, SLOT(seekPlaylist(int))); connect(m_playlistDock, SIGNAL(showStatusMessage(QString)), this, SLOT(showStatusMessage(QString))); connect(m_playlistDock->model(), SIGNAL(created()), this, SLOT(onPlaylistCreated())); connect(m_playlistDock->model(), SIGNAL(cleared()), this, SLOT(onPlaylistCleared())); connect(m_playlistDock->model(), SIGNAL(closed()), this, SLOT(onPlaylistClosed())); connect(m_playlistDock->model(), SIGNAL(modified()), this, SLOT(onPlaylistModified())); connect(m_playlistDock->model(), SIGNAL(loaded()), this, SLOT(updateMarkers())); connect(m_playlistDock->model(), SIGNAL(modified()), this, SLOT(updateMarkers())); tabifyDockWidget(m_recentDock, m_propertiesDock); tabifyDockWidget(m_propertiesDock, m_playlistDock); m_recentDock->raise(); m_encodeDock = new EncodeDock(this); m_encodeDock->hide(); addDockWidget(Qt::RightDockWidgetArea, m_encodeDock); ui->menuView->addAction(m_encodeDock->toggleViewAction()); ui->mainToolBar->addAction(ui->actionEncode); connect(this, SIGNAL(producerOpened()), m_encodeDock, SLOT(onProducerOpened())); connect(m_encodeDock, SIGNAL(visibilityChanged(bool)), ui->actionEncode, SLOT(setChecked(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), m_player, SLOT(onCaptureStateChanged(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), m_propertiesDock, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), m_recentDock, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), ui->actionOpen, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), ui->actionOpenOther, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), ui->actionExit, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), this, SLOT(onCaptureStateChanged(bool))); m_jobsDock = new JobsDock(this); m_jobsDock->hide(); addDockWidget(Qt::RightDockWidgetArea, m_jobsDock); tabifyDockWidget(m_encodeDock, m_jobsDock); ui->menuView->addAction(m_jobsDock->toggleViewAction()); connect(&JOBS, SIGNAL(jobAdded()), m_jobsDock, SLOT(show())); connect(&JOBS, SIGNAL(jobAdded()), m_jobsDock, SLOT(raise())); connect(m_jobsDock, SIGNAL(visibilityChanged(bool)), this, SLOT(onJobsVisibilityChanged(bool))); // Connect signals. connect(this, SIGNAL(producerOpened()), this, SLOT(onProducerOpened())); // connect video widget signals #if defined(Q_WS_MAC) || defined(Q_WS_WIN) Mlt::GLWidget* videoWidget = (Mlt::GLWidget*) &(MLT); connect(videoWidget, SIGNAL(dragStarted()), m_playlistDock, SLOT(onPlayerDragStarted())); connect(videoWidget, SIGNAL(seekTo(int)), m_player, SLOT(seek(int))); #else if (m_settings.value("player/opengl", true).toBool()) { Mlt::GLWidget* videoWidget = (Mlt::GLWidget*) &(MLT); connect(videoWidget, SIGNAL(dragStarted()), m_playlistDock, SLOT(onPlayerDragStarted())); connect(videoWidget, SIGNAL(seekTo(int)), m_player, SLOT(seek(int))); } else { Mlt::SDLWidget* videoWidget = (Mlt::SDLWidget*) &(MLT); connect(videoWidget, SIGNAL(dragStarted()), m_playlistDock, SLOT(onPlayerDragStarted())); connect(videoWidget, SIGNAL(seekTo(int)), m_player, SLOT(seek(int))); } #endif readSettings(); setFocus(); setCurrentFile(""); }