Commit 10d7cd4d authored by Linus Jahn's avatar Linus Jahn

Add Kaidan::getResourcePath for getting paths of external media

This is because we can't bundle CC BY-SA files with GPL'd code/binary.
And that is because the CC licenses are (of course) not GPL compatible.
parent 3e6f8eb8
......@@ -127,6 +127,8 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
VERSION_STRING="${VERSION_STRING}"
DEBUG_SOURCE_PATH="${CMAKE_SOURCE_DIR}"
BOOST_SIGNALS_NO_DEPRECATION_WARNING=True
${KAIDAN_COMPILE_DEFINITIONS}
......@@ -143,6 +145,11 @@ if(UNIX AND NOT APPLE)
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
)
# install kaidan media
# install(DIRECTORY "data/images"
# DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
# )
# install icon (scalable + 128x)
install(FILES "misc/kaidan.svg"
DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/scalable/apps"
......
......@@ -24,8 +24,10 @@
#include <iostream>
// Qt
#include <QDebug>
#include <QDir>
#include <QSettings>
#include <QString>
#include <QStandardPaths>
// Boost
#include <boost/bind.hpp>
// Swiften
......@@ -43,8 +45,8 @@ Kaidan::Kaidan(Swift::NetworkFactories* networkFactories, QObject *parent) : QOb
// Restore login data
//
// init settings (-> "KaidanIM/kaidan.conf")
settings = new QSettings(QString(ORGANIZAITON_NAME), QString(APPLICATION_NAME));
// init settings (-> "kaidan/kaidan.conf")
settings = new QSettings(QString(APPLICATION_NAME), QString(APPLICATION_NAME));
if (settings->value("auth/jid").toString() != "")
{
......@@ -190,3 +192,27 @@ void Kaidan::setPassword(QString password_)
// save to settings
settings->setValue("auth/password", password_);
}
QString Kaidan::getResourcePath(QString name_)
{
// get the standard app data locations for current platform
QStringList pathList = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
pathList << QString(DEBUG_SOURCE_PATH) + QString("/data"); // append debug directory
// search for file in directories
for(int i = 0; i < pathList.size(); i++)
{
// open directory
QDir directory(pathList.at(i));
// look up the file
if (directory.exists(name_))
{
// found the file, return the path
return directory.absoluteFilePath(name_);
}
}
// no file found
qWarning() << "Could NOT find media file:" << name_;
return QString("");
}
......@@ -61,6 +61,8 @@ public:
RosterController* getRosterController();
MessageController* getMessageController();
Q_INVOKABLE QString getResourcePath(QString);
signals:
void rosterControllerChanged();
void messageControllerChanged();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment