Adapt to locateConfigFile() removal in qtutilities
This commit is contained in:
parent
06b6ef5052
commit
566639c6cb
|
@ -67,6 +67,7 @@ set(SRC_FILES
|
||||||
network/testdownload.cpp
|
network/testdownload.cpp
|
||||||
network/vimeodownload.cpp
|
network/vimeodownload.cpp
|
||||||
network/youtubedownload.cpp
|
network/youtubedownload.cpp
|
||||||
|
resources/json.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(WIDGETS_HEADER_FILES
|
set(WIDGETS_HEADER_FILES
|
||||||
|
@ -163,22 +164,6 @@ use_qt_utilities()
|
||||||
# add Qt modules which can currently not be detected automatically
|
# add Qt modules which can currently not be detected automatically
|
||||||
list(APPEND ADDITIONAL_QT_MODULES Network)
|
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 modules to apply configuration
|
||||||
include(BasicConfig)
|
include(BasicConfig)
|
||||||
include(QtGuiConfig)
|
include(QtGuiConfig)
|
||||||
|
|
|
@ -481,19 +481,10 @@ void restoreSettings()
|
||||||
UiPage::multiSelection() = settings.value("multiselection").toBool();
|
UiPage::multiSelection() = settings.value("multiselection").toBool();
|
||||||
|
|
||||||
// load grooveshark authentication file
|
// 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;
|
QString reason;
|
||||||
if (!groovesharkAuthenticationFile.isEmpty()) {
|
if (!GroovesharkDownload::loadAuthenticationInformationFromFile(QStringLiteral(":/jsonobjects/groovesharkauthenticationinfo"), &reason)) {
|
||||||
if (!GroovesharkDownload::loadAuthenticationInformationFromFile(groovesharkAuthenticationFile, &reason)) {
|
|
||||||
QMessageBox::warning(nullptr, QApplication::applicationName(), errorMsg.arg(reason));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QMessageBox::warning(nullptr, QApplication::applicationName(),
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,10 @@
|
||||||
|
|
||||||
#include "resources/config.h"
|
#include "resources/config.h"
|
||||||
|
|
||||||
#include <qtutilities/resources/resources.h>
|
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
|
|
||||||
using namespace CppUtilities;
|
using namespace CppUtilities;
|
||||||
using namespace QtUtilities;
|
|
||||||
using namespace Application;
|
using namespace Application;
|
||||||
|
|
||||||
namespace Network {
|
namespace Network {
|
||||||
|
@ -62,12 +59,7 @@ Download *YoutubeDownload::infoRequestDownload(bool &success, QString &reasonFor
|
||||||
void YoutubeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
|
void YoutubeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
|
||||||
{
|
{
|
||||||
if (m_itagInfo.isEmpty()) {
|
if (m_itagInfo.isEmpty()) {
|
||||||
// allow an external config file to be used instead of built-in values
|
m_itagInfo = loadJsonObjectFromResource(QStringLiteral(":/jsonobjects/itaginfo"));
|
||||||
QString path = ConfigFile::locateConfigFile(QStringLiteral(PROJECT_NAME), QStringLiteral("json/itaginfo.json"));
|
|
||||||
if (path.isEmpty()) {
|
|
||||||
path = QStringLiteral(":/jsonobjects/itaginfo");
|
|
||||||
}
|
|
||||||
m_itagInfo = loadJsonObjectFromResource(path);
|
|
||||||
}
|
}
|
||||||
QString videoInfo(videoInfoBuffer->readAll());
|
QString videoInfo(videoInfoBuffer->readAll());
|
||||||
QStringList completeFields = videoInfo.split(QChar('&'), QString::SkipEmptyParts, Qt::CaseSensitive);
|
QStringList completeFields = videoInfo.split(QChar('&'), QString::SkipEmptyParts, Qt::CaseSensitive);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/jsonobjects">
|
<qresource prefix="/jsonobjects">
|
||||||
<file alias="itaginfo">json/itaginfo.json</file>
|
<file alias="itaginfo">json/itaginfo.json</file>
|
||||||
|
<file alias="groovesharkauthenticationinfo">json/groovesharkauthenticationinfo.json</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in New Issue