From faecd5b2fa931f6555fb6e5f0767ba40dfdbaff4 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 5 Dec 2015 22:56:32 +0100 Subject: [PATCH] added simple CMake project file --- CMakeLists.txt | 76 +++++ application/main.cpp | 5 + config.h.in | 9 + general.pri | 2 +- gui/adddownloaddialog.cpp | 3 +- gui/addmultipledownloadsdialog.cpp | 438 ----------------------------- gui/addmultipledownloadsdialog.h | 76 ----- gui/addmultipledownloadsdialog.ui | 308 -------------------- gui/downloadwidget.cpp | 2 +- gui/initiate.cpp | 5 + gui/mainwindow.cpp | 2 +- gui/setrangedialog.cpp | 2 +- gui/settings.cpp | 7 +- gui/settings.h | 6 +- network/groovesharkdownload.cpp | 5 + network/youtubedownload.cpp | 7 +- videodownloader.pro | 2 +- 17 files changed, 121 insertions(+), 834 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 config.h.in delete mode 100644 gui/addmultipledownloadsdialog.cpp delete mode 100644 gui/addmultipledownloadsdialog.h delete mode 100644 gui/addmultipledownloadsdialog.ui diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..64e9e19 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) + +# meta data +set(META_PROJECT_NAME videodownloader) +set(META_APP_NAME "Video Downloader") +set(META_APP_AUTHOR "Martchus") +set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") +set(META APP_DESCRIPTION "A video downloader with Qt GUI (currently only YouTube and Vimeo are maintained).") +set(META_VERSION_MAJOR 1) +set(META_VERSION_MINOR 2) +set(META_VERSION_PATCH 1) + +# define project +project(${META_PROJECT_NAME}) + +# stringification of meta data +set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"") +set(META_APP_NAME_STR "\"${META_APP_NAME}\"") +set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"") +set(META_APP_URL_STR "\"${META_APP_URL}\"") +set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"") +set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"") + +# add configuration header +configure_file ( + "${PROJECT_SOURCE_DIR}/config.h.in" + "${PROJECT_BINARY_DIR}/config.h" +) +include_directories("${PROJECT_BINARY_DIR}") + +# add source and header files +file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "application/*.cpp" "cli/*.cpp" "model/*.cpp" "network/*.cpp" "resources/json.qrc") +file(GLOB_RECURSE WIDGETS_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gui/*.cpp" "itemdelegates/*.cpp" "resources/icons.qrc") +file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "application/*.h" "cli/*.h" "model/*.h" "network/*.h") +file(GLOB_RECURSE WIDGETS_HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gui/*.h" "itemdelegates/*.h") + +# enable only Qt Widgets GUI +add_definitions(-DGUI_QTWIDGETS -DMODEL_UNDO_SUPPORT) + +# check required Qt 5 modules +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Widgets REQUIRED) +find_package(Qt5Network REQUIRED) + +# enable moc, uic and rcc +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# executable and linking +add_executable(${META_PROJECT_NAME} ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES}) +target_link_libraries(${META_PROJECT_NAME} c++utilities qtutilities Qt5::Core Qt5::Widgets Qt5::Network) + +# enable C++11 +set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11) + +# add install target +install(TARGETS ${META_PROJECT_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +install(FILES resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg + DESTINATION share/icons/hicolor/scalable/apps +) +install(FILES resources/desktop/applications/${META_PROJECT_NAME}.desktop + DESTINATION share/applications +) +install(FILES resources/json/groovesharkauthenticationinfo.json + DESTINATION share/${META_PROJECT_NAME}/json +) +install(FILES resources/json/itaginfo.json + DESTINATION share/${META_PROJECT_NAME}/json +) diff --git a/application/main.cpp b/application/main.cpp index 3418cef..2389aa9 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -1,6 +1,11 @@ #include "../cli/mainfeatures.h" #include "../gui/initiate.h" +// include configuration from separate header file when building with CMake +#ifndef APP_METADATA_AVAIL +#include "config.h" +#endif + #if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) # include #else diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..2f9ca46 --- /dev/null +++ b/config.h.in @@ -0,0 +1,9 @@ +#ifndef APP_METADATA_AVAIL +#define APP_METADATA_AVAIL +#define PROJECT_NAME @META_PROJECT_NAME_STR@ +#define APP_NAME @META_APP_NAME_STR@ +#define APP_VERSION @META_APP_VERSION_STR@ +#define APP_AUTHOR @META_APP_AUTHOR_STR@ +#define APP_URL @META_APP_URL_STR@ +#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@ +#endif // APP_METADATA_AVAIL diff --git a/general.pri b/general.pri index 60bf445..6e654cd 100644 --- a/general.pri +++ b/general.pri @@ -1,5 +1,4 @@ #dirs -UI_DIR = ./gui MOC_DIR = ./moc OBJECTS_DIR = ./obj RCC_DIR = ./res @@ -18,6 +17,7 @@ CONFIG(debug, debug|release) { TARGET = $${targetprefix}$${projectname} } # add defines +DEFINES += "APP_METADATA_AVAIL" DEFINES += "'PROJECT_NAME=\"$${projectname}\"'" DEFINES += "'APP_NAME=\"$${appname}\"'" DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'" diff --git a/gui/adddownloaddialog.cpp b/gui/adddownloaddialog.cpp index 6a3851b..407aeb2 100644 --- a/gui/adddownloaddialog.cpp +++ b/gui/adddownloaddialog.cpp @@ -10,7 +10,7 @@ #include "../network/spotifydownload.h" #endif -#include "gui/ui_adddownloaddialog.h" +#include "ui_adddownloaddialog.h" #include @@ -237,7 +237,6 @@ void AddDownloadDialog::setLastUrl() m_lastUrl = m_ui->urlLineEdit->text(); settings.setValue("lasturl", m_lastUrl); settings.endGroup(); - } } diff --git a/gui/addmultipledownloadsdialog.cpp b/gui/addmultipledownloadsdialog.cpp deleted file mode 100644 index 2a6801f..0000000 --- a/gui/addmultipledownloadsdialog.cpp +++ /dev/null @@ -1,438 +0,0 @@ -#include "addmultipledownloadsdialog.h" -#include "ui_addmultipledownloadsdialog.h" - -#include "download/finder/youtubeplaylist.h" -#include "download/finder/groovesharksearcher.h" - -#include -#include -#include -#include - -#define checkForExistingQuery if(m_finder) { return; } - -using namespace ChronoUtilities; - -const int AddMultipleDownloadsDialog::m_maxInfoRequests = 3; - -const int AddMultipleDownloadsDialog::m_titleCol = 0; -const int AddMultipleDownloadsDialog::m_uploaderCol = 1; -const int AddMultipleDownloadsDialog::m_nrCol = 2; -const int AddMultipleDownloadsDialog::m_collectionCol = 3; -const int AddMultipleDownloadsDialog::m_durationCol = 4; -const int AddMultipleDownloadsDialog::m_idCol = 5; - -const QString &emptyField() -{ - static const QString value = QStringLiteral("-"); - return value; -} - -const QString &retrievingField() -{ - static const QString value = QApplication::translate("AddMultipleDownloadsDialog", "retrieving ..."); - return value; -} - -AddMultipleDownloadsDialog::AddMultipleDownloadsDialog(QWidget *parent, const QNetworkProxy &proxy) : - QDialog(parent), - m_ui(new Ui::AddMultipleDownloadsDialog), - m_selectedSource(SelectedSource::YoutubePlaylist), - m_proxy(proxy) -{ - // setup ui - m_ui->setupUi(this); -#ifdef Q_OS_WIN32 - setStyleSheet(QStringLiteral("* { font: 9pt \"Segoe UI\"; } #mainWidget { color: black; background-color: white; border: none; } #bottomWidget { background-color: #F0F0F0; border-top: 1px solid #DFDFDF; } QMessageBox QLabel, QInputDialog QLabel, QCommandLinkButton { font-size: 12pt; color: #003399; } #buttonsTabWidget, #resultsTabWidget { background-color: white; } #tabWidget:pane { border: none; }")); -#else - setStyleSheet(QStringLiteral("#tabWidget:pane { border: none; }")); -#endif - - m_ui->tabWidget->tabBar()->setHidden(true); - m_ui->tabWidget->setCurrentIndex(0); - m_ui->progressBar->setHidden(true); - m_ui->selectAllPushButton->setHidden(true); - m_ui->addPushButton->setHidden(true); - m_ui->searchPushButton->setHidden(true); - m_ui->moreDownloadsAvailableLabel->setHidden(true); - - // setup tree view - m_model = new QStandardItemModel(this); - m_model->setHorizontalHeaderLabels(QStringList() << "Title" << "Uploader or Artist" << "Nr." << "Collection name" << "Duration" << "Id"); - m_ui->downloadsTreeView->setModel(m_model); - if(QScrollBar *sb = m_ui->downloadsTreeView->verticalScrollBar()) - connect(sb, &QScrollBar::valueChanged, this, &AddMultipleDownloadsDialog::scrollBarValueChanged); - - // connect signals and slots - connect(m_ui->backPushButton, &QPushButton::clicked, this, &AddMultipleDownloadsDialog::back); - connect(m_ui->addPushButton, &QPushButton::clicked, this, &AddMultipleDownloadsDialog::addResultsClicked); - connect(m_ui->addPushButton, &QPushButton::clicked, this, &AddMultipleDownloadsDialog::accept); - connect(m_ui->searchPushButton, &QPushButton::clicked, this, &AddMultipleDownloadsDialog::startSearch); - connect(m_ui->termLineEdit, &QLineEdit::returnPressed, this, &AddMultipleDownloadsDialog::startSearch); - connect(m_ui->youtubePlaylistCommandLinkButton, &QCommandLinkButton::clicked, this, &AddMultipleDownloadsDialog::youtubePlaylistSelected); - connect(m_ui->groovesharkAlbumCommandLinkButton, &QCommandLinkButton::clicked, this, &AddMultipleDownloadsDialog::groovesharkAlbumSelected); - connect(m_ui->groovesharkPlaylistCommandLinkButton, &QCommandLinkButton::clicked, this, &AddMultipleDownloadsDialog::groovesharkPlaylistSelected); - connect(m_ui->selectAllPushButton, &QPushButton::clicked, this, &AddMultipleDownloadsDialog::selectAll); - connect(m_ui->downloadsTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &AddMultipleDownloadsDialog::updateControls); - - // set fields - m_currentInfoRequests = 0; -} - -AddMultipleDownloadsDialog::~AddMultipleDownloadsDialog() -{ } - -QList AddMultipleDownloadsDialog::results() -{ - QList res; - Download *download; - int rowCount = m_model->rowCount(); - QModelIndexList selectedIndexes = m_ui->downloadsTreeView->selectionModel()->selectedRows(); - QModelIndex index; - QStandardItem *item; - - for(int i = 0; i < rowCount; ++i) { - index = m_model->index(i, 0); - if(selectedIndexes.contains(index)) { - item = m_model->item(i, 0); - download = item->data(Qt::UserRole + 1).value(); - if(download->status() != DownloadStatus::Failed) - res.append(download); - } - } - return res; -} - -void AddMultipleDownloadsDialog::downloadChangedStatus(Download *download) -{ - switch(download->status()) { - case DownloadStatus::Failed: - showDownloadError(download); - --m_currentInfoRequests; - break; - case DownloadStatus::Ready: - addDownloadInformation(download); - --m_currentInfoRequests; - break; - default: - ; - } - - while(m_currentInfoRequests < m_maxInfoRequests - && !m_pendingDownloads.isEmpty()) { - Download *download = m_pendingDownloads.takeFirst(); - if(!download->isInitiated() && download->isInitiatingInstantlyRecommendable()) { - ++m_currentInfoRequests; - download->init(); - } - } -} - -void AddMultipleDownloadsDialog::addFinder(DownloadFinder *finder) -{ - m_finder.reset(finder); - m_finder->setContinueAutomatically(false); - - connect(finder, &DownloadFinder::newResultsAvailable, this, &AddMultipleDownloadsDialog::addResults); - connect(finder, &DownloadFinder::finished, this, &AddMultipleDownloadsDialog::retrievingFinished); - - m_ui->tabWidget->setCurrentIndex(2); - m_ui->progressBar->setHidden(false); - m_ui->addPushButton->setHidden(false); - m_ui->selectAllPushButton->setHidden(false); - m_ui->searchPushButton->setHidden(true); - m_pendingDownloads.clear(); - m_currentInfoRequests = 0; - m_ui->titleLabel->setText(tr("Retrieving downloads ...")); - - finder->start(); -} - -void AddMultipleDownloadsDialog::addDownloadInformation(Download *download) -{ - QStandardItem *item; - for(int row = 0; row < m_model->rowCount(); ++row) { - item = m_model->item(row, 0); - - if(item->data(Qt::UserRole + 1).value() == download) { - const QString &title = download->title(); - const QString &id = download->id(); - const QString &uploader = download->uploader(); - const QString &collectionName = download->collectionName(); - int nr = download->positionInCollection(); - TimeSpan duration = download->duration(); - - m_model->item(row, m_titleCol)->setText(title.isEmpty() ? emptyField() : title); - m_model->item(row, m_uploaderCol)->setText(uploader.isEmpty() ? emptyField() : uploader); - m_model->item(row, m_nrCol)->setText(nr == 0 ? emptyField() : QStringLiteral("%1").arg(nr)); - m_model->item(row, m_collectionCol)->setText(collectionName.isEmpty() ? emptyField() : collectionName); - m_model->item(row, m_durationCol)->setText(duration.isNull() ? emptyField() : QString::fromStdString(duration.toString(TimeSpanOutputFormat::WithMeasures))); - m_model->item(row, m_idCol)->setText(id.isEmpty() ? emptyField() : id); - break; - } - } -} - -void AddMultipleDownloadsDialog::showDownloadError(Download *download) -{ - QStandardItem *item; - for(int row = 0; row < m_model->rowCount(); ++row) { - item = m_model->item(row, 0); - - if(item->data(Qt::UserRole +1).value() == download) { - for(int i = m_titleCol; i <= m_idCol; i++) { - item = m_model->item(row, i); - if(i != m_titleCol) - item->setText(QStringLiteral("not found")); - item->setSelectable(false); - } - break; - } - } -} - -void AddMultipleDownloadsDialog::youtubePlaylistSelected() -{ - checkForExistingQuery; - m_ui->enterTermLabel->setText(tr("Enter the url of the playlist or the id:")); - m_ui->termLineEdit->setInputMethodHints(Qt::ImhUrlCharactersOnly); - m_ui->termLineEdit->setText(m_ui->byIdCheckBox->isChecked() ? QString() : QStringLiteral("http://www.youtube.com/playlist?list=")); - m_ui->termLineEdit->selectAll(); - m_ui->byIdCheckBox->setHidden(false); - m_ui->verifiedCheckBox->setHidden(true); - m_ui->addPushButton->setHidden(true); - m_ui->searchPushButton->setHidden(false); - m_selectedSource = SelectedSource::YoutubePlaylist; - m_ui->tabWidget->setCurrentIndex(1); -} - -void AddMultipleDownloadsDialog::groovesharkAlbumSelected() -{ - checkForExistingQuery; - m_ui->enterTermLabel->setText(tr("Enter a search term or the album id:")); - m_ui->termLineEdit->setInputMethodHints(Qt::ImhNone); - m_ui->termLineEdit->clear(); - m_ui->byIdCheckBox->setHidden(false); - m_ui->verifiedCheckBox->setHidden(false); - m_ui->addPushButton->setHidden(true); - m_ui->searchPushButton->setHidden(false); - m_selectedSource = SelectedSource::GroovesharkAlbum; - m_ui->tabWidget->setCurrentIndex(1); - // "124486" -} - -void AddMultipleDownloadsDialog::groovesharkPlaylistSelected() -{ - checkForExistingQuery; - m_ui->enterTermLabel->setText(tr("Enter a search term or the playlist id:")); - m_ui->termLineEdit->setInputMethodHints(Qt::ImhNone); - m_ui->termLineEdit->clear(); - m_ui->byIdCheckBox->setHidden(false); - m_ui->verifiedCheckBox->setHidden(false); - m_ui->addPushButton->setHidden(true); - m_ui->searchPushButton->setHidden(false); - m_selectedSource = SelectedSource::GroovesharkPlaylist; - m_ui->tabWidget->setCurrentIndex(1); -} - -void AddMultipleDownloadsDialog::startSearch() -{ - if(m_ui->tabWidget->currentIndex() != 1) - return; - - if(m_ui->termLineEdit->text().isEmpty()) - return; - - m_ui->searchPushButton->setHidden(false); - - switch(m_selectedSource) { - case SelectedSource::YoutubePlaylist: - addFinder(new YoutubePlaylist( - m_ui->byIdCheckBox->isChecked() ? - QUrl(QStringLiteral("http://www.youtube.com/playlist?list=%1").arg(m_ui->termLineEdit->text())) : - m_ui->termLineEdit->text(), - parent())); - break; - case SelectedSource::GroovesharkAlbum: - addFinder(new GroovesharkSearcher( - m_ui->termLineEdit->text(), - m_ui->byIdCheckBox->isChecked() ? GroovesharkSearchTermRole::AlbumId : GroovesharkSearchTermRole::AlbumName, - m_ui->verifiedCheckBox->isChecked(), - parent())); - break; - case SelectedSource::GroovesharkPlaylist: - addFinder(new GroovesharkSearcher( - m_ui->termLineEdit->text(), - m_ui->byIdCheckBox->isChecked() ? GroovesharkSearchTermRole::PlaylistId : GroovesharkSearchTermRole::PlaylistName, - m_ui->verifiedCheckBox->isChecked(), - parent())); - break; - } -} - -void AddMultipleDownloadsDialog::addResults(const QList &results) -{ - if(m_ui->tabWidget->currentIndex() != 2) - return; - - foreach(Download *download, results) { - QList items; - QStandardItem *item; - - item = new QStandardItem(download->title()); - item->setEditable(false); - item->setData(QVariant::fromValue(download), Qt::UserRole + 1); - items << item; - - item = new QStandardItem(download->uploader().isEmpty() ? retrievingField() : download->uploader()); - item->setEditable(false); - items << item; - - item = new QStandardItem(download->positionInCollection() == 0 ? retrievingField() : QString("%1").arg(download->positionInCollection())); - item->setEditable(false); - items << item; - - item = new QStandardItem(download->collectionName().isEmpty() ? retrievingField() : download->collectionName()); - item->setEditable(false); - items << item; - - item = new QStandardItem(download->duration().isNull() ? retrievingField() : QString::fromStdString(download->duration().toString())); - item->setEditable(false); - items << item; - - item = new QStandardItem(download->id().isEmpty() ? retrievingField() : download->id()); - item->setEditable(false); - items << item; - - m_model->appendRow(items); - - connect(download, &Download::statusChanged, this, &AddMultipleDownloadsDialog::downloadChangedStatus); - - if(download->isInitiated() || (!download->isInitiatingInstantlyRecommendable())) - addDownloadInformation(download); - else { - if(m_currentInfoRequests < m_maxInfoRequests) { - ++m_currentInfoRequests; - download->setProxy(m_proxy); - download->init(); - } else { - m_pendingDownloads.append(download); - } - } - } - - m_ui->selectAllPushButton->setText(tr("Select all")); - if(m_finder) { - if(!m_finder->collectionTitle().isEmpty()) { - m_ui->titleLabel->setText(m_listName + m_finder->collectionTitle()); - } - - if(!m_finder->hasFinished() && !m_finder->isDownloading()) { - QScrollBar *sb = m_ui->downloadsTreeView->verticalScrollBar(); - if(!sb || ((sb->maximum() + sb->minimum()) == 0)) { - m_ui->progressBar->setHidden(false); - m_finder->start(); - } else { - m_ui->progressBar->setHidden(true); - } - } - } -} - -void AddMultipleDownloadsDialog::scrollBarValueChanged() -{ - if(m_finder && !m_finder->hasFinished() && !m_finder->isDownloading()) { - QScrollBar *sb = m_ui->downloadsTreeView->verticalScrollBar(); - if(!sb || (sb->value() == sb->maximum()) || ((sb->maximum() + sb->minimum()) == 0)) { - m_ui->progressBar->setHidden(false); - m_finder->start(); - } else { - m_ui->progressBar->setHidden(true); - } - } else { - m_ui->progressBar->setHidden(true); - } -} - -void AddMultipleDownloadsDialog::retrievingFinished(bool sucess, const QString &reasonForFail) -{ - if(m_finder) { - m_ui->progressBar->setHidden(true); - m_ui->selectAllPushButton->setHidden(false); - m_ui->addPushButton->setHidden(false); - m_ui->titleLabel->setText(sucess - ? (m_listName + m_finder->collectionTitle()) - : tr("Failed to retrieve downloads: %1").arg(reasonForFail)); - m_finder.release()->deleteLater(); - } -} - -void AddMultipleDownloadsDialog::updateControls(const QItemSelection &, const QItemSelection &) -{ - int count = m_ui->downloadsTreeView->selectionModel()->selectedRows().count(); - if(count > 0) { - m_ui->addPushButton->setText(tr("Add selected downloads (%1)").arg(count)); - m_ui->addPushButton->setEnabled(true); - } else { - m_ui->addPushButton->setText(tr("Add selected downloads")); - m_ui->addPushButton->setEnabled(false); - } - - if(count >= m_model->rowCount()) - m_ui->selectAllPushButton->setText(tr("Repeal selection")); - else - m_ui->selectAllPushButton->setText(tr("Select all")); -} - -void AddMultipleDownloadsDialog::selectAll() -{ - QItemSelectionModel *selectionModel = m_ui->downloadsTreeView->selectionModel(); - if(selectionModel->selectedRows().length() >= m_model->rowCount()) - selectionModel->clearSelection(); - else - m_ui->downloadsTreeView->selectAll(); -} - -void AddMultipleDownloadsDialog::back() -{ - m_finder.reset(); - switch(m_ui->tabWidget->currentIndex()) { - case 0: - close(); - break; - case 1: - reset(); - break; - case 2: - abortSearch(); - break; - } -} - -void AddMultipleDownloadsDialog::reset() -{ - m_finder.reset(); - m_ui->progressBar->setHidden(true); - m_ui->selectAllPushButton->setHidden(true); - m_ui->addPushButton->setHidden(true); - m_ui->searchPushButton->setHidden(true); - m_ui->tabWidget->setCurrentIndex(0); - m_model->removeRows(0, m_model->rowCount()); - m_pendingDownloads.clear(); - m_currentInfoRequests = 0; -} - - -void AddMultipleDownloadsDialog::abortSearch() -{ - m_finder.reset(); - m_ui->tabWidget->setCurrentIndex(1); - m_ui->progressBar->setHidden(true); - m_ui->selectAllPushButton->setHidden(true); - m_ui->addPushButton->setHidden(true); - m_ui->searchPushButton->setHidden(false); - m_model->removeRows(0, m_model->rowCount()); - m_pendingDownloads.clear(); - m_currentInfoRequests = 0; - m_ui->titleLabel->setText(tr("Aborted")); -} diff --git a/gui/addmultipledownloadsdialog.h b/gui/addmultipledownloadsdialog.h deleted file mode 100644 index 475e081..0000000 --- a/gui/addmultipledownloadsdialog.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef ADDMULTIPLEDOWNLOADSDIALOG_H -#define ADDMULTIPLEDOWNLOADSDIALOG_H - -#include "download/download.h" -#include "download/finder/downloadfinder.h" - -#include -#include -#include -#include - -namespace Ui { -class AddMultipleDownloadsDialog; -} - -class AddMultipleDownloadsDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AddMultipleDownloadsDialog(QWidget *parent = nullptr, const QNetworkProxy &proxy = QNetworkProxy()); - ~AddMultipleDownloadsDialog(); - QList results(); - -public slots: - void selectAll(); - void back(); - void reset(); - void abortSearch(); - -signals: - void addResultsClicked(); - -private slots: - void youtubePlaylistSelected(); - void groovesharkAlbumSelected(); - void groovesharkPlaylistSelected(); - void startSearch(); - void downloadChangedStatus(Download *download); - void addResults(const QList &results); - void retrievingFinished(bool sucess, const QString &reasonForFail); - void updateControls(const QItemSelection &selected, const QItemSelection &deselected); - void scrollBarValueChanged(); - - -private: - enum class SelectedSource - { - YoutubePlaylist, - GroovesharkAlbum, - GroovesharkPlaylist - }; - - void addFinder(DownloadFinder *finder); - void addDownloadInformation(Download *download); - void showDownloadError(Download *download); - - std::unique_ptr m_ui; - QStandardItemModel *m_model; - std::unique_ptr m_finder; - SelectedSource m_selectedSource; - QString m_listName; - static const int m_maxInfoRequests; - int m_currentInfoRequests; - QList m_pendingDownloads; - const QNetworkProxy &m_proxy; - static const int m_titleCol; - static const int m_uploaderCol; - static const int m_nrCol; - static const int m_collectionCol; - static const int m_durationCol; - static const int m_idCol; - -}; - -#endif // ADDMULTIPLEDOWNLOADSDIALOG_H diff --git a/gui/addmultipledownloadsdialog.ui b/gui/addmultipledownloadsdialog.ui deleted file mode 100644 index a3cc380..0000000 --- a/gui/addmultipledownloadsdialog.ui +++ /dev/null @@ -1,308 +0,0 @@ - - - AddMultipleDownloadsDialog - - - - 0 - 0 - 702 - 329 - - - - Add multiple downloads - - - #tabWidget::pane { -border: none; -} - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - 2 - - - - Select source - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Select the source you want to add downloads from: - - - - - - - Youtube playlist - - - - - - - Grooveshark album - - - - - - - Grooveshark playlist - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Enter search term - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Enter search term - - - - - - - - - - search by id - - - - - - - retrieve only verified songs if possible - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Results - - - - - - font-weight: bold; - - - Retrieving downloads ... - - - - - - - QAbstractItemView::MultiSelection - - - 0 - - - true - - - true - - - - - - - there are more downloads available - - - - - - - - - - - - - - - 16777215 - 55 - - - - - - - Select all - - - - - - - - - - - - 0 - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Back - - - - - - - - - - - - Start search - - - - - - - - - - - - false - - - Add selected downloads - - - - - - - - true - - - - - - - - - - - Widgets::ClearLineEdit - QLineEdit -
qtutilities/widgets/clearlineedit.h
-
-
- - -
diff --git a/gui/downloadwidget.cpp b/gui/downloadwidget.cpp index a13dc94..11e9af2 100644 --- a/gui/downloadwidget.cpp +++ b/gui/downloadwidget.cpp @@ -1,6 +1,6 @@ #include "./downloadwidget.h" -#include "gui/ui_downloadwidget.h" +#include "ui_downloadwidget.h" #include #include diff --git a/gui/initiate.cpp b/gui/initiate.cpp index 68b4ddc..cba124e 100644 --- a/gui/initiate.cpp +++ b/gui/initiate.cpp @@ -2,6 +2,11 @@ #include "./settings.h" #include "./mainwindow.h" +// include configuration from separate header file when building with CMake +#ifndef APP_METADATA_AVAIL +#include "config.h" +#endif + #include #include diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 1a3ca37..8201f86 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -19,7 +19,7 @@ #include "../itemdelegates/progressbaritemdelegate.h" #include "../itemdelegates/comboboxitemdelegate.h" -#include "gui/ui_mainwindow.h" +#include "ui_mainwindow.h" #include #include diff --git a/gui/setrangedialog.cpp b/gui/setrangedialog.cpp index cc6493c..d633d5b 100644 --- a/gui/setrangedialog.cpp +++ b/gui/setrangedialog.cpp @@ -2,7 +2,7 @@ #include "../network/downloadrange.h" -#include "gui/ui_setrangedialog.h" +#include "ui_setrangedialog.h" #include diff --git a/gui/settings.cpp b/gui/settings.cpp index b234715..304ec94 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -3,6 +3,11 @@ #include "../network/download.h" #include "../network/groovesharkdownload.h" +// include configuration from separate header file when building with CMake +#ifndef APP_METADATA_AVAIL +#include "config.h" +#endif + #include #include #include @@ -466,7 +471,7 @@ void restoreSettings() // load grooveshark authentication file const auto errorMsg = QApplication::translate("QtGui::Settings", "Unable to read Grooveshark authentication information file.\n\nReason: %1\n\nThe values stored in this file are required when connection to Grooveshark. Built-in will values be used instead, but these might be deprecated."); - const auto groovesharkAuthenticationFile = ConfigFile::locateConfigFile(QStringLiteral("videodownloader"), QStringLiteral("json/groovesharkauthenticationinfo.json"), &settings); + const auto groovesharkAuthenticationFile = ConfigFile::locateConfigFile(QStringLiteral(PROJECT_NAME), QStringLiteral("json/groovesharkauthenticationinfo.json"), &settings); QString reason; if(!groovesharkAuthenticationFile.isEmpty()) { if(!GroovesharkDownload::loadAuthenticationInformationFromFile(groovesharkAuthenticationFile, &reason)) { diff --git a/gui/settings.h b/gui/settings.h index 282c5fb..01dff1e 100644 --- a/gui/settings.h +++ b/gui/settings.h @@ -2,9 +2,9 @@ #define SETTINGSDIALOG_H // is not required here when building with GCC 4.9.1 or Clan 3.5 - MinGW 4.9.1 fails without including UI headers here -#include "gui/ui_targetpage.h" -#include "gui/ui_proxypage.h" -#include "gui/ui_useragentpage.h" +#include "ui_targetpage.h" +#include "ui_proxypage.h" +#include "ui_useragentpage.h" #include #include diff --git a/network/groovesharkdownload.cpp b/network/groovesharkdownload.cpp index 8af6423..bf325dc 100644 --- a/network/groovesharkdownload.cpp +++ b/network/groovesharkdownload.cpp @@ -2,6 +2,11 @@ #include "../application/utils.h" +// include configuration from separate header file when building with CMake +#ifndef APP_METADATA_AVAIL +#include "config.h" +#endif + #include #include #include diff --git a/network/youtubedownload.cpp b/network/youtubedownload.cpp index bf8ade6..1c2d0fe 100644 --- a/network/youtubedownload.cpp +++ b/network/youtubedownload.cpp @@ -2,6 +2,11 @@ #include "../application/utils.h" +// include configuration from separate header file when building with CMake +#ifndef APP_METADATA_AVAIL +#include "config.h" +#endif + #include #include @@ -58,7 +63,7 @@ void YoutubeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer) { if(m_itagInfo.isEmpty()) { // allow an external config file to be used instead of built-in values - QString path = ConfigFile::locateConfigFile(QStringLiteral("videodownloader"), QStringLiteral("json/itaginfo.json")); + QString path = ConfigFile::locateConfigFile(QStringLiteral(PROJECT_NAME), QStringLiteral("json/itaginfo.json")); if(path.isEmpty()) { path = QStringLiteral(":/jsonobjects/itaginfo"); } diff --git a/videodownloader.pro b/videodownloader.pro index 2cd9db6..f9d519d 100644 --- a/videodownloader.pro +++ b/videodownloader.pro @@ -2,7 +2,7 @@ projectname = videodownloader appname = "Video Downloader" appauthor = Martchus appurl = "https://github.com/$${appauthor}/$${projectname}" -QMAKE_TARGET_DESCRIPTION = "A video downloader with Qt GUI (currently only YouTube is maintained)." +QMAKE_TARGET_DESCRIPTION = "A video downloader with Qt GUI (currently only YouTube and Vimeo are maintained)." VERSION = 1.2.1 # include ../../common.pri when building as part of a subdirs project; otherwise include general.pri