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
Commits on Source (179)
Showing
with 320 additions and 207 deletions
*.pro.user *.pro.user
build_*/ build_*/
lib/qtlib/ lib/qtil/
stages:
- build
ubuntu_deb:
stage: build
image: ubuntu:14.04
only:
- master
- /^release\-.+/
script:
- ./scripts/package ubuntu_deb
artifacts:
paths:
- build_*/ocs-url*.deb
expire_in: 2 days
fedora_rpm:
stage: build
image: fedora:20
only:
- master
- /^release\-.+/
script:
- ./scripts/package fedora_rpm
artifacts:
paths:
- build_*/RPMS/x86_64/ocs-url*.rpm
expire_in: 2 days
opensuse_rpm:
stage: build
image: opensuse:42.3
only:
- master
- /^release\-.+/
script:
- ./scripts/package opensuse_rpm
artifacts:
paths:
- build_*/RPMS/x86_64/ocs-url*.rpm
expire_in: 2 days
archlinux_pkg:
stage: build
image: archlinux/base:latest
only:
- master
- /^release\-.+/
script:
- ./scripts/package archlinux_pkg
artifacts:
paths:
- build_*/ocs-url*.pkg.tar.xz
expire_in: 2 days
# ocs-url # ocs-url
An install helper program for items served on OpenCollaborationServices (OCS). [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
Copyright: 2016-2017, Akira Ohgaki An install helper program for items served via OpenCollaborationServices (ocs://).
Copyright: 2016-2019, Opendesktop.org
License: GPL-3+ License: GPL-3+
Download Linux package from: Download Linux package from:
https://www.linux-apps.com/p/1136805/ https://www.opendesktop.org/p/1136805/
And please check the ocs-url wiki for more information.
https://github.com/ocs-url/ocs-url/wiki And please see docs/* for more information.
CONFIG += c++11
QT += \ QT += \
core \ core \
gui \ gui \
widgets \
qml \ qml \
quick \ quick \
svg svg
...@@ -16,6 +19,7 @@ SOURCES += \ ...@@ -16,6 +19,7 @@ SOURCES += \
RESOURCES += \ RESOURCES += \
$${PWD}/configs/configs.qrc \ $${PWD}/configs/configs.qrc \
$${PWD}/images/images.qrc \
$${PWD}/qml/qml.qrc $${PWD}/qml/qml.qrc
INCLUDEPATH += $${PWD}/src INCLUDEPATH += $${PWD}/src
{ {
"id": "ocs-url", "id": "ocs-url",
"name": "ocs-url", "name": "ocs-url",
"version": "2.0.3", "version": "3.1.0",
"organization": "ocs-url", "organization": "Opendesktop.org",
"domain": "com.ocs-url.ocs-url", "domain": "org.opendesktop.ocs-url",
"icon": ":/desktop/ocs-url.svg", "icon": ":/desktop/ocs-url.svg",
"description": "An install helper program for items served on OpenCollaborationServices (OCS).", "description": "An install helper program for items served via OpenCollaborationServices (ocs://).",
"license": "GPL-3+", "license": "GPL-3+",
"author": "Akira Ohgaki", "author": "Opendesktop.org",
"contact": "akiraohgaki@gmail.com", "contact": "contact@opendesktop.org",
"homepage": "https://github.com/ocs-url/ocs-url" "homepage": "https://git.opendesktop.org/akiraohgaki/ocs-url"
} }
{ {
"bin": { "bin": {
"name": "Softwares", "name": "Software",
"destination": "$HOME/.local/bin", "destination": "$HOME/.local/bin",
"generic_destination": "$APP_DATA/bin" "generic_destination": "$APP_DATA/bin"
}, },
"downloads": { "downloads": {
"name": "Downloads", "name": "Downloads",
"destination": "$HOME/Downloads", "destination": "$XDG_DOWNLOAD_DIR",
"generic_destination": "$APP_DATA/downloads" "generic_destination": "$APP_DATA/downloads"
}, },
"documents": { "documents": {
"name": "Documents", "name": "Documents",
"destination": "$HOME/Documents", "destination": "$XDG_DOCUMENTS_DIR",
"generic_destination": "$APP_DATA/documents" "generic_destination": "$APP_DATA/documents"
}, },
"pictures": { "pictures": {
"name": "Pictures", "name": "Pictures",
"destination": "$HOME/Pictures", "destination": "$XDG_PICTURES_DIR",
"generic_destination": "$APP_DATA/pictures" "generic_destination": "$APP_DATA/pictures"
}, },
"music": { "music": {
"name": "Music", "name": "Music",
"destination": "$HOME/Music", "destination": "$XDG_MUSIC_DIR",
"generic_destination": "$APP_DATA/music" "generic_destination": "$APP_DATA/music"
}, },
"videos": { "videos": {
"name": "Videos", "name": "Videos",
"destination": "$HOME/Videos", "destination": "$XDG_VIDEOS_DIR",
"generic_destination": "$APP_DATA/videos" "generic_destination": "$APP_DATA/videos"
}, },
"wallpapers": { "wallpapers": {
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M64,8 C33.072,8 8,33.072 8,64 C8,94.928 33.072,120 64,120 C94.928,120 120,94.928 120,64 C120,33.072 94.928,8 64,8 z M64,24 C68.418,24 72,27.582 72,32 C72,36.418 68.418,40 64,40 C59.582,40 56,36.418 56,32 C56,27.582 59.582,24 64,24 z M48,48 L72,48 L72,96 L80,96 L80,104 L48,104 L48,96 L56,96 L56,56 L48,56 L48,48 z" fill="#000000" id="dialog-information"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M64,16 L8,112 L120,112 L64,16 z M56,48 L72,48 L72,80 L56,80 L56,48 z M64,88 C68.418,88 72,91.582 72,96 C72,100.418 68.418,104 64,104 C59.582,104 56,100.418 56,96 C56,91.582 59.582,88 64,88 z" fill="#000000" id="dialog-warning"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M64,8 C33.072,8 8,33.072 8,64 C8,94.928 33.072,120 64,120 C94.928,120 120,94.928 120,64 C120,33.072 94.928,8 64,8 z M80,32 L104,32 L56,104 L32,80 L32,56 L56,80 L80,32 z" fill="#000000" id="emblem-default"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="128" height="128" viewBox="0, 0, 128, 128">
<g id="icon">
<path d="M40,8 L40,48 L16,48 L64,96 L112,48 L88,48 L88,8 L40,8 z M8,72 L8,120 L120,120 L120,72 L104,72 L104,104 L24,104 L24,72 L8,72 z" fill="#000000" id="emblem-downloads"/>
</g>
</svg>
<RCC>
<qresource prefix="/images">
<file>icons/dialog-information.svg</file>
<file>icons/dialog-warning.svg</file>
<file>icons/emblem-default.svg</file>
<file>icons/emblem-downloads.svg</file>
</qresource>
</RCC>
// Still support Qt 5.2, so doesn't use QtQuick.Dialogs 1.2
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0 import QtQuick.Controls 1.0
...@@ -8,23 +6,25 @@ import "ui" as Ui ...@@ -8,23 +6,25 @@ import "ui" as Ui
import "scripts/Utility.js" as Utility import "scripts/Utility.js" as Utility
Window { ApplicationWindow {
id: app id: app
title: configHandler.getAppConfigApplication().name title: configHandler.getAppConfigApplication().name
visible: true
width: 400 width: 400
minimumWidth: width
maximumWidth: width
height: 200 height: 200
minimumWidth: 400 minimumHeight: height
minimumHeight: 200 maximumHeight: height
maximumWidth: 800
maximumHeight: 400
visible: true
function init() { function init() {
var metadata = ocsUrlHandler.metadata(); var metadata = ocsUrlHandler.metadata();
var primaryMessages = { var primaryMessages = {
"success_download": qsTr("Download successfull"), "success_download": qsTr("Download successful"),
"success_install": qsTr("Installation successfull"), "success_install": qsTr("Installation successful"),
"error_validation": qsTr("Validation error"), "error_validation": qsTr("Validation error"),
"error_network": qsTr("Network error"), "error_network": qsTr("Network error"),
"error_save": qsTr("Saving file failed"), "error_save": qsTr("Saving file failed"),
...@@ -40,7 +40,7 @@ Window { ...@@ -40,7 +40,7 @@ Window {
progressDialog.close(); progressDialog.close();
infoDialog.primaryText = primaryMessages[result.status]; infoDialog.primaryText = primaryMessages[result.status];
infoDialog.informativeText = metadata.filename; infoDialog.informativeText = metadata.filename;
//infoDialog.detailedText = result.message; infoDialog.detailedText = result.message;
infoDialog.open(); infoDialog.open();
}); });
...@@ -48,15 +48,15 @@ Window { ...@@ -48,15 +48,15 @@ Window {
progressDialog.close(); progressDialog.close();
errorDialog.primaryText = primaryMessages[result.status]; errorDialog.primaryText = primaryMessages[result.status];
errorDialog.informativeText = metadata.filename; errorDialog.informativeText = metadata.filename;
//errorDialog.detailedText = result.message; errorDialog.detailedText = result.message;
errorDialog.open(); errorDialog.open();
}); });
ocsUrlHandler.downloadProgress.connect(function(id, bytesReceived, bytesTotal) { ocsUrlHandler.downloadProgress.connect(function(id, bytesReceived, bytesTotal) {
progressDialog.primaryText = qsTr("Downloading"); progressDialog.primaryText = qsTr("Downloading");
progressDialog.informativeText = metadata.filename; progressDialog.informativeText = metadata.filename;
progressDialog.progress = bytesReceived / bytesTotal; progressDialog.detailedContentLoader.item.progressBar = bytesReceived / bytesTotal;
progressDialog.progressText progressDialog.detailedContentLoader.item.progressText
= Utility.convertByteToHumanReadable(bytesReceived) = Utility.convertByteToHumanReadable(bytesReceived)
+ " / " + Utility.convertByteToHumanReadable(bytesTotal); + " / " + Utility.convertByteToHumanReadable(bytesTotal);
}); });
...@@ -69,33 +69,45 @@ Window { ...@@ -69,33 +69,45 @@ Window {
confirmDialog.primaryText = qsTr("Do you want to install?"); confirmDialog.primaryText = qsTr("Do you want to install?");
} }
confirmDialog.informativeText = metadata.filename; confirmDialog.informativeText = metadata.filename;
/*
confirmDialog.detailedText confirmDialog.detailedText
= qsTr("URL") + ": " + metadata.url + "\n\n" = qsTr("URL") + ": " + metadata.url + "\n"
+ qsTr("File") + ": " + metadata.filename + "\n\n" + qsTr("File") + ": " + metadata.filename + "\n"
+ qsTr("Type") + ": " + configHandler.getAppConfigInstallTypes()[metadata.type].name; + qsTr("Type") + ": " + configHandler.getAppConfigInstallTypes()[metadata.type].name;
*/
confirmDialog.open(); confirmDialog.open();
} }
else { else {
errorDialog.primaryText = primaryMessages["error_validation"]; errorDialog.primaryText = primaryMessages["error_validation"];
errorDialog.informativeText = qsTr("Invalid OCS-URL"); errorDialog.detailedText = qsTr("Invalid OCS-URL");
errorDialog.open(); errorDialog.open();
} }
} }
function fixWindowSize(dialog) {
if (dialog.visible) {
app.height = dialog.implicitHeight + (dialog.anchors.margins * 2);
app.minimumHeight = app.height;
app.maximumHeight = app.height;
}
}
Ui.Dialog { Ui.Dialog {
id: confirmDialog id: confirmDialog
//icon: StandardIcon.Question icon: "qrc:/images/icons/dialog-information.svg"
actionButton.text: qsTr("Details")
actionButton.onClicked: toggleDetails()
acceptButton.text: qsTr("OK") acceptButton.text: qsTr("OK")
acceptButton.onClicked: ocsUrlHandler.process() acceptButton.onClicked: ocsUrlHandler.process()
rejectButton.text: qsTr("Cancel") rejectButton.text: qsTr("Cancel")
rejectButton.onClicked: Qt.quit() rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(confirmDialog)
onImplicitHeightChanged: app.fixWindowSize(confirmDialog)
} }
Ui.Dialog { Ui.Dialog {
id: infoDialog id: infoDialog
//icon: StandardIcon.Information icon: "qrc:/images/icons/emblem-default.svg"
actionButton.text: qsTr("Details")
actionButton.onClicked: toggleDetails()
acceptButton.text: qsTr("Open") acceptButton.text: qsTr("Open")
acceptButton.onClicked: { acceptButton.onClicked: {
ocsUrlHandler.openDestination(); ocsUrlHandler.openDestination();
...@@ -103,25 +115,28 @@ Window { ...@@ -103,25 +115,28 @@ Window {
} }
rejectButton.text: qsTr("Close") rejectButton.text: qsTr("Close")
rejectButton.onClicked: Qt.quit() rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(infoDialog)
onImplicitHeightChanged: app.fixWindowSize(infoDialog)
} }
Ui.Dialog { Ui.Dialog {
id: errorDialog id: errorDialog
//icon: StandardIcon.Warning icon: "qrc:/images/icons/dialog-warning.svg"
actionButton.text: qsTr("Details")
actionButton.onClicked: toggleDetails()
rejectButton.text: qsTr("Close") rejectButton.text: qsTr("Close")
rejectButton.onClicked: Qt.quit() rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(errorDialog)
onImplicitHeightChanged: app.fixWindowSize(errorDialog)
} }
Ui.Dialog { Component {
id: progressDialog id: progressComponent
//icon: StandardIcon.NoIcon ColumnLayout {
rejectButton.text: qsTr("Cancel") property alias progressBar: progressBar.value
rejectButton.onClicked: Qt.quit() property alias progressText: progressText.text
property alias progress: progressBar.value
property alias progressText: progressText.text
content: ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 8 spacing: 4
ProgressBar { ProgressBar {
id: progressBar id: progressBar
minimumValue: 0 minimumValue: 0
...@@ -132,11 +147,22 @@ Window { ...@@ -132,11 +147,22 @@ Window {
Label { Label {
id: progressText id: progressText
text: "" text: ""
anchors.right: parent.right Layout.alignment: Qt.AlignRight
} }
} }
} }
Ui.Dialog {
id: progressDialog
icon: "qrc:/images/icons/emblem-downloads.svg"
detailsVisible: true
detailedContentLoader.sourceComponent: progressComponent
rejectButton.text: qsTr("Cancel")
rejectButton.onClicked: Qt.quit()
onVisibleChanged: app.fixWindowSize(progressDialog)
onImplicitHeightChanged: app.fixWindowSize(progressDialog)
}
Component.onCompleted: { Component.onCompleted: {
app.init(); app.init();
} }
......
...@@ -5,15 +5,20 @@ import QtQuick.Controls 1.0 ...@@ -5,15 +5,20 @@ import QtQuick.Controls 1.0
ColumnLayout { ColumnLayout {
id: dialog id: dialog
visible: false
anchors.fill: parent anchors.fill: parent
anchors.margins: 12 anchors.margins: 12
spacing: 8 spacing: 12
visible: false
property alias icon: icon.source property alias icon: icon.source
property alias primaryText: primaryText.text property alias primaryText: primaryText.text
property alias informativeText: informativeText.text property alias informativeText: informativeText.text
property alias content: content.children
property alias detailsVisible: details.visible
property alias detailedText: detailedText.text
property alias detailedContentLoader: detailedContentLoader
property alias actionButton: actionButton
property alias acceptButton: acceptButton property alias acceptButton: acceptButton
property alias rejectButton: rejectButton property alias rejectButton: rejectButton
...@@ -25,42 +30,72 @@ ColumnLayout { ...@@ -25,42 +30,72 @@ ColumnLayout {
dialog.visible = false; dialog.visible = false;
} }
function toggleDetails() {
details.visible = details.visible ? false : true;
}
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true spacing: 12
spacing: parent.spacing
Image { Image {
id: icon id: icon
source: "" source: ""
Layout.implicitWidth: 32
Layout.implicitHeight: 32
visible: source.toString() ? true : false visible: source.toString() ? true : false
Layout.preferredWidth: 48
Layout.preferredHeight: 48
sourceSize.width: 128
sourceSize.height: 128
} }
ColumnLayout { ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: parent.spacing spacing: 4
Label { Label {
id: primaryText id: primaryText
text: "" text: ""
font.bold: true
visible: text ? true : false visible: text ? true : false
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
font.bold: true
font.pixelSize: 14
} }
Label { Label {
id: informativeText id: informativeText
text: "" text: ""
visible: text ? true : false visible: text ? true : false
}
Item {
id: content
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true wrapMode: Text.WrapAnywhere
} }
} }
} }
ColumnLayout {
id: details
visible: false
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 12
Label {
id: detailedText
text: ""
visible: text ? true : false
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
}
Loader {
id: detailedContentLoader
visible: (source.toString() || sourceComponent) ? true : false
Layout.fillWidth: true
}
}
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: parent.spacing spacing: 4
Button {
id: actionButton
text: ""
visible: text ? true : false
}
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
......
#include "confighandler.h" #include "confighandler.h"
#include <QStringList> #include <QStringList>
#include <QStandardPaths>
#include "qtlib_dir.h" #include "qtil_dir.h"
ConfigHandler::ConfigHandler(QObject *parent) ConfigHandler::ConfigHandler(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
appConfig_ = qtlib::Config(":/configs"); appConfig_ = Qtil::Config(":/configs");
importAppConfigApplication();
importAppConfigInstallTypes();
} }
QJsonObject ConfigHandler::getAppConfigApplication() QJsonObject ConfigHandler::getAppConfigApplication() const
{ {
if (appConfigApplication_.isEmpty()) {
appConfigApplication_ = appConfig_.get("application");
}
return appConfigApplication_; return appConfigApplication_;
} }
QJsonObject ConfigHandler::getAppConfigInstallTypes() QJsonObject ConfigHandler::getAppConfigInstallTypes() const
{ {
if (appConfigInstallTypes_.isEmpty()) { return appConfigInstallTypes_;
QJsonObject installTypes = appConfig_.get("install_types"); }
foreach (const QString &key, installTypes.keys()) {
QJsonObject installtype = installTypes[key].toObject(); void ConfigHandler::importAppConfigApplication()
installtype["destination"] = convertPathString(installtype["destination"].toString()); {
installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString()); appConfigApplication_ = appConfig_.get("application");
installTypes[key] = installtype; }
}
QJsonObject installTypesAlias = appConfig_.get("install_types_alias"); void ConfigHandler::importAppConfigInstallTypes()
foreach (const QString &key, installTypesAlias.keys()) { {
QJsonObject installTypeAlias = installTypesAlias[key].toObject(); auto installTypes = appConfig_.get("install_types");
QString baseKey = installTypeAlias["base"].toString(); for (const auto &key : installTypes.keys()) {
if (installTypes.contains(baseKey)) { auto installtype = installTypes[key].toObject();
QJsonObject installType = installTypes[baseKey].toObject(); installtype["destination"] = convertPathString(installtype["destination"].toString());
installType["base"] = baseKey; installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString());
installType["name"] = installTypeAlias["name"].toString(); installTypes[key] = installtype;
installTypes[key] = installType; }
} auto installTypesAlias = appConfig_.get("install_types_alias");
for (const auto &key : installTypesAlias.keys()) {
auto installTypeAlias = installTypesAlias[key].toObject();
auto baseKey = installTypeAlias["base"].toString();
if (installTypes.contains(baseKey)) {
auto installType = installTypes[baseKey].toObject();
installType["base"] = baseKey;
installType["name"] = installTypeAlias["name"].toString();
installTypes[key] = installType;
} }
appConfigInstallTypes_ = installTypes;
} }
return appConfigInstallTypes_; appConfigInstallTypes_ = installTypes;
} }
QString ConfigHandler::convertPathString(const QString &path) QString ConfigHandler::convertPathString(const QString &path) const
{ {
QString newPath = path; auto newPath = path;
if (newPath.contains("$HOME")) { if (newPath.contains("$HOME")) {
newPath.replace("$HOME", qtlib::Dir::homePath()); newPath.replace("$HOME", Qtil::Dir::homePath());
}
else if (newPath.contains("$XDG_DOCUMENTS_DIR")) {
newPath.replace("$XDG_DOCUMENTS_DIR", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
}
else if (newPath.contains("$XDG_DOWNLOAD_DIR")) {
newPath.replace("$XDG_DOWNLOAD_DIR", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
}
else if (newPath.contains("$XDG_PICTURES_DIR")) {
newPath.replace("$XDG_PICTURES_DIR", QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
}
else if (newPath.contains("$XDG_MUSIC_DIR")) {
newPath.replace("$XDG_MUSIC_DIR", QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
}
else if (newPath.contains("$XDG_VIDEOS_DIR")) {
newPath.replace("$XDG_VIDEOS_DIR", QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
} }
else if (newPath.contains("$XDG_DATA_HOME")) { else if (newPath.contains("$XDG_DATA_HOME")) {
newPath.replace("$XDG_DATA_HOME", qtlib::Dir::genericDataPath()); newPath.replace("$XDG_DATA_HOME", Qtil::Dir::genericDataPath());
} }
else if (newPath.contains("$KDEHOME")) { else if (newPath.contains("$KDEHOME")) {
newPath.replace("$KDEHOME", qtlib::Dir::kdehomePath()); newPath.replace("$KDEHOME", Qtil::Dir::kdehomePath());
} }
else if (newPath.contains("$APP_DATA")) { else if (newPath.contains("$APP_DATA")) {
newPath.replace("$APP_DATA", qtlib::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString()); newPath.replace("$APP_DATA", Qtil::Dir::genericDataPath() + "/" + getAppConfigApplication()["id"].toString());
} }
return newPath; return newPath;
} }
...@@ -3,23 +3,25 @@ ...@@ -3,23 +3,25 @@
#include <QObject> #include <QObject>
#include <QJsonObject> #include <QJsonObject>
#include "qtlib_config.h" #include "qtil_config.h"
class ConfigHandler : public QObject class ConfigHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigHandler(QObject *parent = 0); explicit ConfigHandler(QObject *parent = nullptr);
public slots: public slots:
QJsonObject getAppConfigApplication(); QJsonObject getAppConfigApplication() const;
QJsonObject getAppConfigInstallTypes(); QJsonObject getAppConfigInstallTypes() const;
private: private:
QString convertPathString(const QString &path); void importAppConfigApplication();
void importAppConfigInstallTypes();
QString convertPathString(const QString &path) const;
qtlib::Config appConfig_; Qtil::Config appConfig_;
QJsonObject appConfigApplication_; QJsonObject appConfigApplication_;
QJsonObject appConfigInstallTypes_; QJsonObject appConfigInstallTypes_;
}; };
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
#include <QUrlQuery> #include <QUrlQuery>
#include <QDesktopServices> #include <QDesktopServices>
#include "qtlib_file.h" #include "qtil_file.h"
#include "qtlib_dir.h" #include "qtil_dir.h"
#include "qtlib_networkresource.h" #include "qtil_networkresource.h"
#include "qtlib_package.h" #include "qtil_package.h"
#include "handlers/confighandler.h" #include "handlers/confighandler.h"
...@@ -39,15 +39,15 @@ void OcsUrlHandler::process() ...@@ -39,15 +39,15 @@ void OcsUrlHandler::process()
return; return;
} }
QString url = metadata_["url"].toString(); auto url = metadata_["url"].toString();
qtlib::NetworkResource *resource = new qtlib::NetworkResource(url, QUrl(url), true, this); auto *resource = new Qtil::NetworkResource(url, QUrl(url), true, this);
connect(resource, &qtlib::NetworkResource::downloadProgress, this, &OcsUrlHandler::downloadProgress); connect(resource, &Qtil::NetworkResource::downloadProgress, this, &OcsUrlHandler::downloadProgress);
connect(resource, &qtlib::NetworkResource::finished, this, &OcsUrlHandler::networkResourceFinished); connect(resource, &Qtil::NetworkResource::finished, this, &OcsUrlHandler::networkResourceFinished);
resource->get(); resource->get();
emit started(); emit started();
} }
bool OcsUrlHandler::isValid() bool OcsUrlHandler::isValid() const
{ {
QString scheme = metadata_["scheme"].toString(); QString scheme = metadata_["scheme"].toString();
QString command = metadata_["command"].toString(); QString command = metadata_["command"].toString();
...@@ -55,8 +55,7 @@ bool OcsUrlHandler::isValid() ...@@ -55,8 +55,7 @@ bool OcsUrlHandler::isValid()
QString type = metadata_["type"].toString(); QString type = metadata_["type"].toString();
QString filename = metadata_["filename"].toString(); QString filename = metadata_["filename"].toString();
// Still support xdg and xdgs schemes for backward compatibility if ((scheme == "ocs" || scheme == "ocss")
if ((scheme == "ocs" || scheme == "ocss" || scheme == "xdg" || scheme == "xdgs")
&& (command == "download" || command == "install") && (command == "download" || command == "install")
&& QUrl(url).isValid() && QUrl(url).isValid()
&& configHandler_->getAppConfigInstallTypes().contains(type) && configHandler_->getAppConfigInstallTypes().contains(type)
...@@ -66,13 +65,13 @@ bool OcsUrlHandler::isValid() ...@@ -66,13 +65,13 @@ bool OcsUrlHandler::isValid()
return false; return false;
} }
void OcsUrlHandler::openDestination() void OcsUrlHandler::openDestination() const
{ {
QString type = metadata_["type"].toString(); auto type = metadata_["type"].toString();
QDesktopServices::openUrl(QUrl("file://" + configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString())); QDesktopServices::openUrl(QUrl("file://" + configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString()));
} }
void OcsUrlHandler::networkResourceFinished(qtlib::NetworkResource *resource) void OcsUrlHandler::networkResourceFinished(Qtil::NetworkResource *resource)
{ {
if (!resource->isFinishedWithNoError()) { if (!resource->isFinishedWithNoError()) {
QJsonObject result; QJsonObject result;
...@@ -127,14 +126,14 @@ void OcsUrlHandler::parse() ...@@ -127,14 +126,14 @@ void OcsUrlHandler::parse()
} }
} }
void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource) void OcsUrlHandler::saveDownloadedFile(Qtil::NetworkResource *resource)
{ {
QJsonObject result; QJsonObject result;
QString type = metadata_["type"].toString(); auto type = metadata_["type"].toString();
qtlib::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString()); Qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString());
destDir.make(); destDir.make();
qtlib::File destFile(destDir.path() + "/" + metadata_["filename"].toString()); Qtil::File destFile(destDir.path() + "/" + metadata_["filename"].toString());
if (!resource->saveData(destFile.path())) { if (!resource->saveData(destFile.path())) {
result["status"] = QString("error_save"); result["status"] = QString("error_save");
...@@ -151,11 +150,11 @@ void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource) ...@@ -151,11 +150,11 @@ void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
resource->deleteLater(); resource->deleteLater();
} }
void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource) void OcsUrlHandler::installDownloadedFile(Qtil::NetworkResource *resource)
{ {
QJsonObject result; QJsonObject result;
qtlib::File tempFile(qtlib::Dir::tempPath() + "/" + metadata_["filename"].toString()); Qtil::File tempFile(Qtil::Dir::tempPath() + "/" + metadata_["filename"].toString());
if (!resource->saveData(tempFile.path())) { if (!resource->saveData(tempFile.path())) {
result["status"] = QString("error_save"); result["status"] = QString("error_save");
...@@ -165,11 +164,11 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource) ...@@ -165,11 +164,11 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
return; return;
} }
qtlib::Package package(tempFile.path()); Qtil::Package package(tempFile.path());
QString type = metadata_["type"].toString(); auto type = metadata_["type"].toString();
qtlib::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString()); Qtil::Dir destDir(configHandler_->getAppConfigInstallTypes()[type].toObject()["destination"].toString());
destDir.make(); destDir.make();
qtlib::File destFile(destDir.path() + "/" + metadata_["filename"].toString()); Qtil::File destFile(destDir.path() + "/" + metadata_["filename"].toString());
if (type == "bin" if (type == "bin"
&& package.installAsProgram(destFile.path())) { && package.installAsProgram(destFile.path())) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <QObject> #include <QObject>
#include <QJsonObject> #include <QJsonObject>
namespace qtlib { namespace Qtil {
class NetworkResource; class NetworkResource;
} }
...@@ -14,7 +14,7 @@ class OcsUrlHandler : public QObject ...@@ -14,7 +14,7 @@ class OcsUrlHandler : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit OcsUrlHandler(const QString &ocsUrl, ConfigHandler *configHandler, QObject *parent = 0); explicit OcsUrlHandler(const QString &ocsUrl, ConfigHandler *configHandler, QObject *parent = nullptr);
signals: signals:
void started(); void started();
...@@ -27,16 +27,16 @@ public slots: ...@@ -27,16 +27,16 @@ public slots:
QJsonObject metadata() const; QJsonObject metadata() const;
void process(); void process();
bool isValid(); bool isValid() const;
void openDestination(); void openDestination() const;
private slots: private slots:
void networkResourceFinished(qtlib::NetworkResource *resource); void networkResourceFinished(Qtil::NetworkResource *resource);
private: private:
void parse(); void parse();
void saveDownloadedFile(qtlib::NetworkResource *resource); void saveDownloadedFile(Qtil::NetworkResource *resource);
void installDownloadedFile(qtlib::NetworkResource *resource); void installDownloadedFile(Qtil::NetworkResource *resource);
QString ocsUrl_; QString ocsUrl_;
ConfigHandler *configHandler_; ConfigHandler *configHandler_;
......
...@@ -18,8 +18,8 @@ int main(int argc, char *argv[]) ...@@ -18,8 +18,8 @@ int main(int argc, char *argv[])
// Init // Init
QApplication app(argc, argv); QApplication app(argc, argv);
ConfigHandler *configHandler = new ConfigHandler(); auto *configHandler = new ConfigHandler();
QJsonObject appConfigApplication = configHandler->getAppConfigApplication(); auto appConfigApplication = configHandler->getAppConfigApplication();
app.setApplicationName(appConfigApplication["name"].toString()); app.setApplicationName(appConfigApplication["name"].toString());
app.setApplicationVersion(appConfigApplication["version"].toString()); app.setApplicationVersion(appConfigApplication["version"].toString());
...@@ -41,17 +41,17 @@ int main(int argc, char *argv[]) ...@@ -41,17 +41,17 @@ int main(int argc, char *argv[])
clParser.addPositionalArgument("OCS-URL", "OCS-URL that starts with ocs://"); clParser.addPositionalArgument("OCS-URL", "OCS-URL that starts with ocs://");
clParser.process(app); clParser.process(app);
QStringList args = clParser.positionalArguments(); auto args = clParser.positionalArguments();
if (args.size() != 1) { if (args.size() != 1) {
clParser.showHelp(1); clParser.showHelp(1);
} }
QString ocsUrl = args.at(0); auto ocsUrl = QString(args.at(0));
// Setup QML // Setup QML
QQmlApplicationEngine qmlAppEngine; QQmlApplicationEngine qmlAppEngine;
QQmlContext *qmlContext = qmlAppEngine.rootContext(); auto *qmlContext = qmlAppEngine.rootContext();
configHandler->setParent(&qmlAppEngine); configHandler->setParent(&qmlAppEngine);
qmlContext->setContextProperty("configHandler", configHandler); qmlContext->setContextProperty("configHandler", configHandler);
qmlContext->setContextProperty("ocsUrlHandler", new OcsUrlHandler(ocsUrl, configHandler, &qmlAppEngine)); qmlContext->setContextProperty("ocsUrlHandler", new OcsUrlHandler(ocsUrl, configHandler, &qmlAppEngine));
......
pipelines:
custom:
build-ubuntu:
- step:
image: ubuntu:14.04
script:
- apt update -qq
- apt -y install sudo git curl
- apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
- apt -y install devscripts debhelper fakeroot
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh ubuntu
build-fedora:
- step:
image: fedora:20
script:
# dnf >= fedora:22
- yum -y install sudo git curl
- yum -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
- yum -y install rpm-build
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh fedora
build-archlinux:
- step:
image: finalduty/archlinux:latest
script:
- pacman -Syu --noconfirm
- pacman -S --noconfirm sudo git curl
- pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh archlinux
build-snap:
- step:
image: ubuntu:16.04
script:
- apt update -qq
- apt -y install sudo git curl
- apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
- apt -y install snapcraft
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh snap
build-appimage:
- step:
image: ubuntu:14.04
script:
# Require docker run with --cap-add SYS_ADMIN --device /dev/fuse
- echo 'appimage build is disabled currently'
- exit 1
- apt update -qq
- apt -y install sudo git curl
- apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
- apt -y install fuse zsync desktop-file-utils
#- modprobe fuse
- useradd -m pkgbuilder
- export HOME=/home/pkgbuilder
- chown -R pkgbuilder:pkgbuilder $(pwd)
- sudo -u pkgbuilder sh scripts/build.sh appimage
...@@ -6,4 +6,4 @@ Type=Application ...@@ -6,4 +6,4 @@ Type=Application
Terminal=false Terminal=false
NoDisplay=true NoDisplay=true
Categories=Network;Utility; Categories=Network;Utility;
MimeType=x-scheme-handler/ocs;x-scheme-handler/ocss;x-scheme-handler/xdg;x-scheme-handler/xdgs; MimeType=x-scheme-handler/ocs;x-scheme-handler/ocss;