Adapt to locateConfigFile() removal in qtutilities

This commit is contained in:
Martchus 2019-08-20 22:27:15 +02:00
parent 06b6ef5052
commit 566639c6cb
4 changed files with 5 additions and 36 deletions

View File

@ -67,6 +67,7 @@ set(SRC_FILES
network/testdownload.cpp
network/vimeodownload.cpp
network/youtubedownload.cpp
resources/json.qrc
)
set(WIDGETS_HEADER_FILES
@ -163,22 +164,6 @@ use_qt_utilities()
# add Qt modules which can currently not be detected automatically
list(APPEND ADDITIONAL_QT_MODULES Network)
# add installs for JSON resource files
install(FILES resources/json/groovesharkauthenticationinfo.json
DESTINATION share/${META_PROJECT_NAME}/json
COMPONENT json-res
)
install(FILES resources/json/itaginfo.json
DESTINATION share/${META_PROJECT_NAME}/json
COMPONENT json-res
)
if(NOT TARGET install-json-res)
add_custom_target(install-json-res
DEPENDS ${META_PROJECT_NAME}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=json-res -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
# include modules to apply configuration
include(BasicConfig)
include(QtGuiConfig)

View File

@ -481,19 +481,10 @@ void restoreSettings()
UiPage::multiSelection() = settings.value("multiselection").toBool();
// 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(PROJECT_NAME), QStringLiteral("json/groovesharkauthenticationinfo.json"), &settings);
QString reason;
if (!groovesharkAuthenticationFile.isEmpty()) {
if (!GroovesharkDownload::loadAuthenticationInformationFromFile(groovesharkAuthenticationFile, &reason)) {
QMessageBox::warning(nullptr, QApplication::applicationName(), errorMsg.arg(reason));
}
} else {
if (!GroovesharkDownload::loadAuthenticationInformationFromFile(QStringLiteral(":/jsonobjects/groovesharkauthenticationinfo"), &reason)) {
QMessageBox::warning(nullptr, QApplication::applicationName(),
errorMsg.arg(QApplication::translate("QtGui::Settings", "Unable to find \"groovesharkauthenticationinfo.json\".")));
QCoreApplication::translate("QtGui::restoreSettings", "Unable to load Grooveshark authentication file: %1").arg(reason));
}
}

View File

@ -4,13 +4,10 @@
#include "resources/config.h"
#include <qtutilities/resources/resources.h>
#include <QJsonDocument>
#include <QUrlQuery>
using namespace CppUtilities;
using namespace QtUtilities;
using namespace Application;
namespace Network {
@ -62,12 +59,7 @@ Download *YoutubeDownload::infoRequestDownload(bool &success, QString &reasonFor
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(PROJECT_NAME), QStringLiteral("json/itaginfo.json"));
if (path.isEmpty()) {
path = QStringLiteral(":/jsonobjects/itaginfo");
}
m_itagInfo = loadJsonObjectFromResource(path);
m_itagInfo = loadJsonObjectFromResource(QStringLiteral(":/jsonobjects/itaginfo"));
}
QString videoInfo(videoInfoBuffer->readAll());
QStringList completeFields = videoInfo.split(QChar('&'), QString::SkipEmptyParts, Qt::CaseSensitive);

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/jsonobjects">
<file alias="itaginfo">json/itaginfo.json</file>
<file alias="groovesharkauthenticationinfo">json/groovesharkauthenticationinfo.json</file>
</qresource>
</RCC>