Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • akiraohgaki/ocs-url
  • ab3875o/ocs-url
  • dembego3/ocs-url
  • arakun/ocs-url
  • longviauroy/ocs-url
  • rolfen/ocs-url
  • hemm/ocs-url
  • simonsvw0000/ocs-url
  • dfn2/ocs-url
  • rws77/ocs-url
  • bitwalk/ocs-url
  • visdom/ocs-url
  • ricatfarker/ocs-url
  • mussah/ocs-url
  • tigefa/ocs-url
  • cobalt2727/ocs-url
  • ammark226/ocs-url
  • violethaze74/ocs-url
  • armedssault/ocs-url
  • billflick/ocs-url
  • kimblejeremy/ocs-url
  • yuvrajsm/ocs-url
  • wawmart/ocs-url
  • jhefry/ocs-url
  • robcdntruckin/ocs-url
  • bigmake2266/ocs-url
  • kamil-chbeir/ocs-url
  • jocker73/ocs-url
  • laboties/ocs-url
  • smekke61279-522014/ocs-url
  • coolduck/ocs-url
  • zulfikar-lahiya/ocs-url
  • faz-83/ocs-url
  • dado105/ocs-url
34 results
Show changes
#ifndef UTILITY_JSON_H
#define UTILITY_JSON_H
#include <QObject>
namespace Utility {
class Json : public QObject
{
Q_OBJECT
public:
explicit Json(QObject *parent = 0);
static QString convertObjToStr(const QJsonObject &jsonObj);
static QJsonObject convertStrToObj(const QString &json);
static bool isValid(const QString &json);
};
} // namespace Utility
#endif // UTILITY_JSON_H
#include <QJsonObject>
#include <QMimeDatabase>
#include <QProcess>
#include "package.h"
namespace Utility {
Package::Package(QObject *parent) : QObject(parent)
{}
bool Package::installProgram(const QString &path, const QString &targetPath)
{
QString program = "install";
QStringList arguments;
arguments << "-m" << "755" << "-p" << path << targetPath;
return _process(program, arguments);
}
bool Package::installFile(const QString &path, const QString &targetPath)
{
QString program = "install";
QStringList arguments;
arguments << "-m" << "644" << "-p" << path << targetPath;
return _process(program, arguments);
}
bool Package::installPlasmapkg(const QString &path, const QString &type)
{
QString program = "plasmapkg2";
QStringList arguments;
arguments << "-t" << type << "-i" << path;
return _process(program, arguments);
}
bool Package::uninstallPlasmapkg(const QString &path, const QString &type)
{
QString program = "plasmapkg2";
QStringList arguments;
arguments << "-t" << type << "-r" << path;
return _process(program, arguments);
}
bool Package::uncompressArchive(const QString &path, const QString &targetDir)
{
QJsonObject archiveTypes;
archiveTypes["application/x-tar"] = QString("tar");
archiveTypes["application/x-gzip"] = QString("tar");
archiveTypes["application/gzip"] = QString("tar");
archiveTypes["application/x-bzip"] = QString("tar");
archiveTypes["application/x-bzip2"] = QString("tar");
archiveTypes["application/x-xz"] = QString("tar");
archiveTypes["application/x-lzma"] = QString("tar");
archiveTypes["application/x-lzip"] = QString("tar");
archiveTypes["application/x-compressed-tar"] = QString("tar");
archiveTypes["application/x-bzip-compressed-tar"] = QString("tar");
archiveTypes["application/x-bzip2-compressed-tar"] = QString("tar");
archiveTypes["application/x-xz-compressed-tar"] = QString("tar");
archiveTypes["application/x-lzma-compressed-tar"] = QString("tar");
archiveTypes["application/x-lzip-compressed-tar"] = QString("tar");
archiveTypes["application/zip"] = QString("zip");
archiveTypes["application/x-7z-compressed"] = QString("7z");
archiveTypes["application/x-rar"] = QString("rar");
archiveTypes["application/x-rar-compressed"] = QString("rar");
QMimeDatabase mimeDb;
QString mimeType = mimeDb.mimeTypeForFile(path).name();
if (archiveTypes.contains(mimeType)) {
QString archiveType = archiveTypes[mimeType].toString();
QString program;
QStringList arguments;
if (archiveType == "tar") {
program = "tar";
arguments << "-xf" << path << "-C" << targetDir;
}
else if (archiveType == "zip") {
program = "unzip";
arguments << "-o" << path << "-d" << targetDir;
}
else if (archiveType == "7z") {
program = "7z";
arguments << "x" << path << "-o" + targetDir; // No space between -o and directory
}
else if (archiveType == "rar") {
program = "unrar";
arguments << "e" << path << targetDir;
}
return _process(program, arguments);
}
return false;
}
bool Package::_process(const QString &program, const QStringList &arguments)
{
QProcess process;
process.start(program, arguments);
if (process.waitForFinished()) {
process.waitForReadyRead();
return true;
}
return false;
}
} // namespace Utility
#ifndef UTILITY_PACKAGE_H
#define UTILITY_PACKAGE_H
#include <QObject>
namespace Utility {
class Package : public QObject
{
Q_OBJECT
public:
explicit Package(QObject *parent = 0);
static bool installProgram(const QString &path, const QString &targetPath);
static bool installFile(const QString &path, const QString &targetPath);
static bool installPlasmapkg(const QString &path, const QString &type = "plasmoid");
static bool uninstallPlasmapkg(const QString &path, const QString &type = "plasmoid");
static bool uncompressArchive(const QString &path, const QString &targetDir);
private:
static bool _process(const QString &program, const QStringList &arguments);
};
} // namespace Utility
#endif // UTILITY_PACKAGE_H
TARGET = xdgurl
TEMPLATE = app
QT += \
core \
gui \
widgets \
qml \
quick \
svg \
network
CONFIG += \
c++11
SOURCES += \
src/main.cpp \
src/core/config.cpp \
src/core/network.cpp \
src/handlers/xdgurl.cpp \
src/utility/file.cpp \
src/utility/json.cpp \
src/utility/package.cpp
HEADERS += \
src/core/config.h \
src/core/network.h \
src/handlers/xdgurl.h \
src/utility/file.h \
src/utility/json.h \
src/utility/package.h
RESOURCES += \
src/configs.qrc \
src/qml.qrc \
src/desktop.qrc
# Additional RPATH
#include(rpath.pri)
# Deployment rules
include(deployment.pri)