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
Showing
with 127 additions and 1155 deletions
#!/bin/bash
PKGNAME='ocs-url'
PKGUSER='pkgbuilder'
PKGSCRIPT="${0}"
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
BUILDDIR="${PROJDIR}/build_${PKGNAME}"
ubuntu_deb() { # docker-image: ubuntu:14.04
install_build_deps_ubuntu_deb
add_pkguser
su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_ubuntu_deb" ${PKGUSER}
}
install_build_deps_ubuntu_deb() {
apt update -qq
apt -y install curl git
apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
apt -y install devscripts debhelper fakeroot
}
build_ubuntu_deb() {
rm -rf "${BUILDDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
tar -xzf "${BUILDDIR}/${PKGNAME}.tar.gz" -C "${BUILDDIR}"
cp -r "${PROJDIR}/pkg/ubuntu/debian" "${BUILDDIR}/${PKGNAME}"
cd "${BUILDDIR}/${PKGNAME}"
debuild -uc -us -b
}
fedora_rpm() { # docker-image: fedora:20
install_build_deps_fedora_rpm
add_pkguser
su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_fedora_rpm" ${PKGUSER}
}
install_build_deps_fedora_rpm() {
yum -y install curl git
yum -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
yum -y install rpm-build
}
build_fedora_rpm() {
rm -rf "${BUILDDIR}"
mkdir -p "${BUILDDIR}"
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
export_srcarchive "${BUILDDIR}/SOURCES/${PKGNAME}.tar.gz"
cp "${PROJDIR}/pkg/fedora/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
opensuse_rpm() { # docker-image: opensuse:42.3
install_build_deps_opensuse_rpm
add_pkguser
su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_opensuse_rpm" ${PKGUSER}
}
install_build_deps_opensuse_rpm() {
zypper --non-interactive refresh
zypper --non-interactive install curl git
zypper --non-interactive install make automake gcc gcc-c++ libtool libqt5-qtbase-devel libqt5-qtsvg-devel libqt5-qtdeclarative-devel
zypper --non-interactive install rpm-build
}
build_opensuse_rpm() {
rm -rf "${BUILDDIR}"
mkdir -p "${BUILDDIR}"
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
export_srcarchive "${BUILDDIR}/SOURCES/${PKGNAME}.tar.gz"
cp "${PROJDIR}/pkg/opensuse/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
archlinux_pkg() { # docker-image: archlinux/base:latest
install_build_deps_archlinux_pkg
add_pkguser
su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_archlinux_pkg" ${PKGUSER}
}
install_build_deps_archlinux_pkg() {
pacman -Syu --noconfirm
pacman -S --noconfirm curl git
pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
pacman -S --noconfirm pacman-contrib
}
build_archlinux_pkg() {
rm -rf "${BUILDDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
cp "${PROJDIR}/pkg/archlinux/PKGBUILD" "${BUILDDIR}"
cd "${BUILDDIR}"
updpkgsums
makepkg -s
}
add_pkguser() {
useradd -m ${PKGUSER}
chown -R ${PKGUSER} "${PROJDIR}"
}
export_srcarchive() {
if [ "${1}" ]; then
(cd "${PROJDIR}" && git archive --prefix="${PKGNAME}/" --output="${1}" HEAD)
fi
}
if [ "${1}" ]; then
${1}
fi
#!/bin/bash
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
if [ ! -d "${PROJDIR}/lib/qtil" ]; then
git clone https://github.com/akiraohgaki/qtil.git -b release-0.4.0 --single-branch --depth=1 "${PROJDIR}/lib/qtil"
fi
DISTFILES += \
$${PWD}/package \
$${PWD}/prepare
{
"id": "xdgurl",
"name": "xdgurl",
"version": "2.0.0",
"organization": "xdgurl",
"domain": "com.xdgurl.xdgurl",
"icon": ":/desktop/xdgurl.svg",
"description": "An install helper program for desktop stuff.",
"license": "GPL-3+",
"author": "Akira Ohgaki",
"contact": "akiraohgaki@gmail.com",
"homepage": "https://github.com/xdgurl/xdgurl"
}
{
"bin": "$HOME/.bin",
"downloads": "$HOME/Downloads",
"documents": "$HOME/Documents",
"pictures": "$HOME/Pictures",
"music": "$HOME/Music",
"videos": "$HOME/Videos",
"wallpapers": "$XDG_DATA_HOME/wallpapers",
"fonts": "$HOME/.fonts",
"cursors": "$HOME/.icons",
"icons": "$XDG_DATA_HOME/icons",
"emoticons": "$XDG_DATA_HOME/emoticons",
"themes": "$HOME/.themes",
"emerald_themes": "$HOME/.emerald/themes",
"enlightenment_themes": "$HOME/.e/e/themes",
"enlightenment_backgrounds": "$HOME/.e/e/backgrounds",
"fluxbox_styles": "$HOME/.fluxbox/styles",
"pekwm_themes": "$HOME/.pekwm/themes",
"icewm_themes": "$HOME/.icewm/themes",
"plasma_plasmoids": "$XDG_DATA_HOME/plasma/plasmoids",
"plasma_look_and_feel": "$XDG_DATA_HOME/plasma/look-and-feel",
"plasma_desktopthemes": "$XDG_DATA_HOME/plasma/desktoptheme",
"kwin_effects": "$XDG_DATA_HOME/kwin/effects",
"kwin_scripts": "$XDG_DATA_HOME/kwin/scripts",
"kwin_tabbox": "$XDG_DATA_HOME/kwin/tabbox",
"aurorae_themes": "$XDG_DATA_HOME/aurorae/themes",
"dekorator_themes": "$XDG_DATA_HOME/deKorator/themes",
"qtcurve": "$XDG_DATA_HOME/QtCurve",
"color_schemes": "$XDG_DATA_HOME/color-schemes",
"gnome_shell_extensions": "$XDG_DATA_HOME/gnome-shell/extensions",
"cinnamon_applets": "$XDG_DATA_HOME/cinnamon/applets",
"cinnamon_desklets": "$XDG_DATA_HOME/cinnamon/desklets",
"cinnamon_extensions": "$XDG_DATA_HOME/cinnamon/extensions",
"nautilus_scripts": "$XDG_DATA_HOME/nautilus/scripts",
"amarok_scripts": "$KDEHOME/share/apps/amarok/scripts",
"yakuake_skins": "$KDEHOME/share/apps/yakuake/skins",
"cairo_clock_themes": "$HOME/.cairo-clock/themes"
}
{
"gnome_shell_themes": "themes",
"cinnamon_themes": "themes",
"gtk2_themes": "themes",
"gtk3_themes": "themes",
"metacity_themes": "themes",
"xfwm4_themes": "themes",
"openbox_themes": "themes",
"kvantum_themes": "themes",
"compiz_themes": "emerald_themes",
"beryl_themes": "emerald_themes",
"plasma4_plasmoids": "plasma_plasmoids",
"plasma5_plasmoids": "plasma_plasmoids",
"plasma5_look_and_feel": "plasma_look_and_feel",
"plasma5_desktopthemes": "plasma_desktopthemes",
"plasma_color_schemes": "color_schemes"
}
#pragma once
#include <QObject>
#include <QJsonObject>
class QNetworkReply;
namespace utils {
class Config;
class Network;
}
namespace handlers {
class XdgUrl : public QObject
{
Q_OBJECT
public:
explicit XdgUrl(const QString &xdgUrl, utils::Config *config, utils::Network *network, QObject *parent = 0);
signals:
void started();
void finished(const QJsonObject &result);
void error(const QJsonObject &result);
void downloadProgress(const qint64 &received, const qint64 &total);
public slots:
void process();
bool isValid();
void openDestination();
QString xdgUrl() const;
QJsonObject metadata() const;
private slots:
void downloaded(QNetworkReply *reply);
private:
void parse();
void loadDestinations();
QString convertPathString(const QString &path);
void saveDownloadedFile(QNetworkReply *reply);
void installDownloadedFile(QNetworkReply *reply);
QString xdgUrl_;
utils::Config *config_;
utils::Network *network_;
QJsonObject metadata_;
QJsonObject destinations_;
QString destination_;
};
} // namespace handlers
#include <QtGlobal>
#include <QString>
#include <QStringList>
#include <QUrl>
#include <QJsonObject>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QGuiApplication>
#include <QIcon>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "../libs/utils/config.h"
#include "../libs/utils/network.h"
#include "handlers/xdgurl.h"
int main(int argc, char *argv[])
{
// Init
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
utils::Config *config = new utils::Config(":/configs");
utils::Network *network = new utils::Network(true);
QJsonObject configApplication = config->get("application");
app.setApplicationName(configApplication["name"].toString());
app.setApplicationVersion(configApplication["version"].toString());
app.setOrganizationName(configApplication["organization"].toString());
app.setOrganizationDomain(configApplication["domain"].toString());
app.setWindowIcon(QIcon::fromTheme(configApplication["id"].toString(), QIcon(configApplication["icon"].toString())));
// Setup CLI
QCommandLineParser clParser;
clParser.setApplicationDescription(configApplication["description"].toString());
clParser.addHelpOption();
clParser.addVersionOption();
clParser.addPositionalArgument("xdgurl", "XDG-URL");
clParser.process(app);
QStringList args = clParser.positionalArguments();
if (args.size() != 1) {
clParser.showHelp(1);
}
QString xdgUrl = args.at(0);
// Setup QML
QQmlApplicationEngine qmlAppEngine;
QQmlContext *qmlContext = qmlAppEngine.rootContext();
qmlContext->setContextProperty("xdgUrlHandler", new handlers::XdgUrl(xdgUrl, config, network));
qmlAppEngine.load(QUrl("qrc:/qml/main.qml"));
return app.exec();
}
import QtQuick 2.3
import QtQuick.Window 2.0
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import 'scripts/Utility.js' as Utility
Window {
id: root
title: Qt.application.name
width: 400
height: 200
minimumWidth: 400
minimumHeight: 200
maximumWidth: 800
maximumHeight: 400
MessageDialog {
id: confirmDialog
title: root.title
icon: StandardIcon.Question
text: ''
informativeText: ''
detailedText: ''
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: xdgUrlHandler.process()
onRejected: Qt.quit()
}
MessageDialog {
id: infoDialog
title: root.title
icon: StandardIcon.Information
text: ''
informativeText: ''
detailedText: ''
standardButtons: StandardButton.Open | StandardButton.Close
onAccepted: {
xdgUrlHandler.openDestination();
Qt.quit();
}
onRejected: Qt.quit()
}
MessageDialog {
id: errorDialog
title: root.title
icon: StandardIcon.Warning
text: ''
informativeText: ''
detailedText: ''
standardButtons: StandardButton.Close
onRejected: Qt.quit()
}
Dialog {
id: progressDialog
title: root.title
contentItem: Item {
implicitWidth: 400
implicitHeight: 150
Column {
anchors.fill: parent
anchors.margins: 12
spacing: 8
Label {
id: primaryLabel
text: ''
font.bold: true
}
Label {
id: informativeLabel
text: ''
}
ProgressBar {
id: progressBar
maximumValue: 1
minimumValue: 0
value: 0
anchors.left: parent.left
anchors.right: parent.right
}
Label {
id: progressLabel
text: ''
anchors.right: parent.right
}
Button {
id: cancelButton
text: 'Cancel'
anchors.right: parent.right
onClicked: Qt.quit()
}
}
}
property alias primaryLabel: primaryLabel
property alias informativeLabel: informativeLabel
property alias progressBar: progressBar
property alias progressLabel: progressLabel
}
Component.onCompleted: {
var metadata = xdgUrlHandler.metadata();
var primaryMessages = {
'success_download': 'Download successfull',
'success_install': 'Installation successfull',
'error_validation': 'Validation error',
'error_network': 'Network error',
'error_save': 'Saving file failed',
'error_install': 'Installation failed'
};
xdgUrlHandler.started.connect(function() {
progressDialog.open();
});
xdgUrlHandler.finished.connect(function(result) {
progressDialog.close();
infoDialog.text = primaryMessages[result.status];
infoDialog.informativeText = metadata.filename;
infoDialog.detailedText = result.message;
infoDialog.open();
});
xdgUrlHandler.error.connect(function(result) {
progressDialog.close();
errorDialog.text = primaryMessages[result.status];
errorDialog.informativeText = metadata.filename;
errorDialog.detailedText = result.message;
errorDialog.open();
});
xdgUrlHandler.downloadProgress.connect(function(received, total) {
progressDialog.primaryLabel.text = 'Downloading... ';
progressDialog.informativeLabel.text = metadata.filename;
progressDialog.progressBar.value = received / total;
progressDialog.progressLabel.text = Utility.convertByteToHumanReadable(received)
+ ' / ' + Utility.convertByteToHumanReadable(total)
});
if (xdgUrlHandler.isValid()) {
confirmDialog.text = 'Do you want to ' + metadata.command + '?';
confirmDialog.informativeText = metadata.filename;
confirmDialog.detailedText = 'URL: ' + metadata.url + '\n\n'
+ 'File: ' + metadata.filename + '\n\n'
+ 'Type: ' + metadata.type;
confirmDialog.open();
}
else {
errorDialog.text = 'Validation error';
errorDialog.detailedText = 'Invalid XDG-URL ' + xdgUrlHandler.xdgUrl();
errorDialog.open();
}
}
}
#!/bin/bash
# The purpose of this script is to provide lightweight desktop integration
# into the host system without special help from the host system.
# If you want to have fuller and automatic desktop integration, you might
# consider to use the optional appimaged daemon instead.
# Exit on errors
set -e
# Be verbose if $DEBUG=1 is set
if [ ! -z "$DEBUG" ] ; then
env
set -x
fi
THIS="$0"
args=("$@") # http://stackoverflow.com/questions/3190818/
NUMBER_OF_ARGS="$#"
# Please do not change $VENDORPREFIX as it will allow for desktop files
# belonging to AppImages to be recognized by future AppImageKit components
# such as desktop integration daemons
VENDORPREFIX=appimagekit
APPDIR="$(dirname "$(readlink -f "${THIS}")")"
BIN="${APPDIR}/xdgurl"
export PATH="${APPDIR}/usr/bin:$PATH"
trap atexit EXIT
# Note that the following handles 0, 1 or more arguments (file paths)
# which can include blanks but uses a bashism; can the same be achieved
# in POSIX-shell? (FIXME)
# http://stackoverflow.com/questions/3190818
atexit()
{
if [ $NUMBER_OF_ARGS -eq 0 ] ; then
exec "${BIN}"
else
exec "${BIN}" "${args[@]}"
fi
}
error()
{
if [ -x /usr/bin/zenity ] ; then
LD_LIBRARY_PATH="" zenity --error --text "${1}" 2>/dev/null
elif [ -x /usr/bin/kdialog ] ; then
LD_LIBRARY_PATH="" kdialog --msgbox "${1}" 2>/dev/null
elif [ -x /usr/bin/Xdialog ] ; then
LD_LIBRARY_PATH="" Xdialog --msgbox "${1}" 2>/dev/null
else
echo "${1}"
fi
exit 1
}
yesno()
{
TITLE=$1
TEXT=$2
if [ -x /usr/bin/zenity ] ; then
LD_LIBRARY_PATH="" zenity --question --title="$TITLE" --text="$TEXT" 2>/dev/null || exit 0
elif [ -x /usr/bin/kdialog ] ; then
LD_LIBRARY_PATH="" kdialog --caption "" --title "$TITLE" -yesno "$TEXT" || exit 0
elif [ -x /usr/bin/Xdialog ] ; then
LD_LIBRARY_PATH="" Xdialog --title "$TITLE" --clear --yesno "$TEXT" 10 80 || exit 0
else
echo "zenity, kdialog, Xdialog missing. Skipping ${THIS}."
exit 0
fi
}
check_prevent()
{
FILE=$1
if [ -e "$FILE" ] ; then
exit 0
fi
}
# Exit immediately of one of these files is present
# (e.g., because the desktop environment wants to handle desktop integration itself)
check_prevent "$HOME/.local/share/$VENDORPREFIX/no_desktopintegration"
check_prevent "/usr/share/$VENDORPREFIX/no_desktopintegration"
check_prevent "/etc/$VENDORPREFIX/no_desktopintegration"
# Exit immediately if appimaged is running
pidof appimaged 2>/dev/null && exit 0
# Exit immediately if $DESKTOPINTEGRATION is not empty
if [ ! -z "$DESKTOPINTEGRATION" ] ; then
exit 0
fi
check_dep()
{
DEP=$1
if [ -z $(which $DEP) ] ; then
echo "$DEP is missing. Skipping ${THIS}."
exit 0
fi
}
DIRNAME="$APPDIR"
# Check whether dependencies are present in base system (we do not bundle these)
# http://cgit.freedesktop.org/xdg/desktop-file-utils/
check_dep desktop-file-validate
check_dep update-desktop-database
check_dep desktop-file-install
check_dep xdg-icon-resource
check_dep xdg-mime
check_dep xdg-desktop-menu
DESKTOPFILE=$(find "$APPDIR" -maxdepth 1 -name "*.desktop" | head -n 1)
# echo "$DESKTOPFILE"
DESKTOPFILE_NAME=$(basename "${DESKTOPFILE}")
if [ ! -f "$DESKTOPFILE" ] ; then
echo "Desktop file is missing. Please run ${THIS} from within an AppImage."
exit 0
fi
if [ -z "$APPIMAGE" ] ; then
APPIMAGE="$APPDIR/AppRun"
# Not running from within an AppImage; hence using the AppRun for Exec=
fi
ABS_APPIMAGE=$(readlink -e "$APPIMAGE")
ICONFILE="$APPDIR/.DirIcon"
# $XDG_DATA_DIRS contains the default paths /usr/local/share:/usr/share
# desktop file has to be installed in an applications subdirectory
# of one of the $XDG_DATA_DIRS components
if [ -z "$XDG_DATA_DIRS" ] ; then
XDG_DATA_DIRS=/usr/local/share:/usr/share
fi
# Determine where the desktop file should be installed
if [[ $EUID -ne 0 ]]; then
DESTINATION_DIR_DESKTOP="$HOME/.local/share/applications"
SYSTEM_WIDE=""
else
# TODO: Check $XDG_DATA_DIRS
DESTINATION_DIR_DESKTOP="/usr/local/share/applications"
SYSTEM_WIDE="--mode system" # for xdg-mime and xdg-icon-resource
fi
# Check if the desktop file is already there
# and if so, whether it points to the same AppImage
if [ -e "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME" ] ; then
# echo "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME already there"
EXEC=$(grep "^Exec=" "$DESTINATION_DIR_DESKTOP/$VENDORPREFIX-$DESKTOPFILE_NAME" | head -n 1 | cut -d " " -f 1)
# echo $EXEC
if [ "Exec=\"$APPIMAGE\"" == "$EXEC" ] ; then
exit 0
fi
fi
# We ask the user only if we have found no reason to skip until here
if [ -z "$SKIP" ] ; then
yesno "Install" "Would you like to integrate $APPIMAGE with your system?\n\nThis will add it to your applications menu and install icons.\nIf you don't do this you can still launch the application by double-clicking on the AppImage."
fi
APP=$(echo "$DESKTOPFILE_NAME" | sed -e 's/.desktop//g')
# If the user has agreed, rewrite and install the desktop file, and the MIME information
if [ -z "$SKIP" ] ; then
# desktop-file-install is supposed to install .desktop files to the user's
# applications directory when run as a non-root user,
# and to /usr/share/applications if run as root
# but that does not really work for me...
#
# For Exec we must use quotes
# For TryExec quotes is not supported, so, space must be replaced to \s
# https://askubuntu.com/questions/175404/how-to-add-space-to-exec-path-in-a-thumbnailer-descrption/175567
desktop-file-install --rebuild-mime-info-cache \
--vendor=$VENDORPREFIX --set-key=Exec --set-value="\"${APPIMAGE}\" %u" \
--set-key=X-AppImage-Comment --set-value="Generated by ${THIS}" \
--set-icon="$ICONFILE" --set-key=TryExec --set-value=${APPIMAGE// /\\s} "$DESKTOPFILE" \
--dir "$DESTINATION_DIR_DESKTOP"
chmod a+x "$DESTINATION_DIR_DESKTOP/"*
RESOURCE_NAME=$(echo "$VENDORPREFIX-$DESKTOPFILE_NAME" | sed -e 's/.desktop//g')
# echo $RESOURCE_NAME
# Install the icon files for the application; TODO: scalable
ICONS=$(find "${APPDIR}/usr/share/icons/" -wholename "*/apps/${APP}.png" 2>/dev/null || true)
for ICON in $ICONS ; do
ICON_SIZE=$(echo "${ICON}" | rev | cut -d "/" -f 3 | rev | cut -d "x" -f 1)
xdg-icon-resource install --context apps --size ${ICON_SIZE} "${ICON}" "${RESOURCE_NAME}"
done
# Install mime type
find "${APPDIR}/usr/share/mime/" -type f -name *xml -exec xdg-mime install $SYSTEM_WIDE --novendor {} \; 2>/dev/null || true
# Install the icon files for the mime type; TODO: scalable
ICONS=$(find "${APPDIR}/usr/share/icons/" -wholename "*/mimetypes/*.png" 2>/dev/null || true)
for ICON in $ICONS ; do
ICON_SIZE=$(echo "${ICON}" | rev | cut -d "/" -f 3 | rev | cut -d "x" -f 1)
xdg-icon-resource install --context mimetypes --size ${ICON_SIZE} "${ICON}" $(basename $ICON | sed -e 's/.png//g')
done
xdg-desktop-menu forceupdate
gtk-update-icon-cache # for MIME
fi
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
id="svg2"
viewBox="0 0 1000 1000"
height="1000"
width="1000">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-52.362161)"
id="layer1">
<circle
r="475"
cy="552.36218"
cx="500"
id="path4138"
style="fill:#19a2ff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<circle
r="450"
cy="552.36218"
cx="500"
id="path4138-0"
style="fill:#53b2ff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<g
transform="translate(0,20)"
id="g4205">
<path
id="path4145"
style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:medium;line-height:125%;font-family:Futura;-inkscape-font-specification:'Futura Medium';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 192.87313,533.47911 -74.36008,-101.11803 56.93857,0 46.10326,64.24502 46.95309,-64.24502 58.63824,0 -76.48467,101.11803 88.59474,119.21524 -56.93858,0 -60.76282,-82.34221 -62.25002,82.34221 -58.42577,0 91.99404,-119.21524 z" />
<path
id="path4147"
style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:medium;line-height:125%;font-family:Futura;-inkscape-font-specification:'Futura Medium';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 472.62967,312.47491 48.01537,0 0,340.84056 -48.01537,0 0,-21.67066 c -18.83789,18.41297 -40.15445,27.61946 -63.94968,27.61946 -28.32765,0 -51.83961,-10.33959 -70.53586,-31.01878 -18.55461,-21.1041 -27.83192,-47.44882 -27.83192,-79.03415 0,-30.87715 9.27731,-56.65531 27.83192,-77.3345 18.41298,-20.82082 41.57084,-31.23123 69.47357,-31.23123 24.22015,0 45.8908,9.91468 65.01197,29.74403 z M 359.17742,549.21134 c 0,19.82935 5.31143,35.97612 15.9343,48.44029 10.90615,12.60581 24.64506,18.90871 41.21674,18.90871 17.70478,0 32.01024,-6.09045 42.91639,-18.27134 10.90615,-12.60581 16.35922,-28.61093 16.35922,-48.01537 0,-19.40445 -5.45307,-35.40957 -16.35922,-48.01538 -10.90615,-12.32253 -25.06997,-18.48379 -42.49148,-18.48379 -16.43004,0 -30.16895,6.23208 -41.21673,18.69625 -10.90615,12.60581 -16.35922,28.18602 -16.35922,46.74063 z" />
<path
id="path4149"
style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:medium;line-height:125%;font-family:Futura;-inkscape-font-specification:'Futura Medium';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 722.24998,648.95295 c 0,9.77304 -0.3541,18.34215 -1.06229,25.70734 -0.56655,7.50683 -1.41638,14.09301 -2.54949,19.75854 -3.39932,15.58021 -10.05632,28.96502 -19.97099,40.15445 -18.69625,21.52901 -44.4036,32.29352 -77.12204,32.29352 -27.61947,0 -50.35241,-7.43601 -68.19883,-22.30802 -18.41297,-15.29693 -29.03584,-36.47186 -31.86861,-63.52477 l 48.01537,0 c 1.8413,10.19796 4.88652,18.05889 9.13567,23.58278 9.91468,12.88908 24.36178,19.33362 43.34131,19.33362 34.98465,0 52.47698,-21.4582 52.47698,-64.37459 l 0,-28.89421 c -18.97953,19.40444 -40.86264,29.10666 -65.64934,29.10666 -28.18601,0 -51.27305,-10.19795 -69.26111,-30.59386 -18.1297,-20.67919 -27.19455,-46.52817 -27.19455,-77.54695 0,-30.16895 8.42748,-55.80548 25.28243,-76.90959 18.1297,-22.37884 42.06657,-33.56826 71.81061,-33.56826 26.06144,0 47.73209,9.70222 65.01196,29.10666 l 0,-27.37031 47.80292,0 z m -45.8908,-98.15532 c 0,-20.11264 -5.38225,-36.18859 -16.14676,-48.22784 C 649.30627,490.24726 635.3549,484.086 618.35831,484.086 c -18.1297,0 -32.43517,6.72782 -42.9164,20.18345 -9.48976,12.03925 -14.23464,27.61946 -14.23464,46.74063 0,18.83789 4.74488,34.27647 14.23464,46.31572 10.33959,13.17236 24.64506,19.75854 42.9164,19.75854 18.27133,0 32.71844,-6.657 43.34131,-19.971 9.77304,-12.03925 14.65956,-27.47782 14.65956,-46.31571 z" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 739.50519,490.21255 36,0 0,36 -36,0 z"
id="rect4156" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 739.53345,589.21057 36,0 0,36 -36,0 z"
id="rect4156-9" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 852.99238,412.46896 22,0 -94.33913,290.17369 -22,0 z"
id="rect4156-5" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 902.99238,412.46896 22,0 -94.33913,290.17369 -22,0 z"
id="rect4156-5-3" />
</g>
</g>
</svg>
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#include "android.h"
#include <QAndroidJniObject>
namespace utils {
Android::Android(QObject *parent) : QObject(parent)
{}
bool Android::openApk(const QString &uri)
{
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
if (activity.isValid()) {
QAndroidJniObject fileUri = QAndroidJniObject::fromString(uri);
QAndroidJniObject parsedUri = QAndroidJniObject::callStaticObjectMethod("android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", fileUri.object());
QAndroidJniObject mimeType = QAndroidJniObject::fromString("application/vnd.android.package-archive");
QAndroidJniObject activityKind = QAndroidJniObject::fromString("android.intent.action.VIEW");
QAndroidJniObject intent("android/content/Intent", "(Ljava/lang/String;)V", activityKind.object());
intent = intent.callObjectMethod("setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", parsedUri.object(), mimeType.object());
intent = intent.callObjectMethod("setFlags", "(I)Landroid/content/Intent;", 0x10000000); // 0x10000000 = FLAG_ACTIVITY_NEW_TASK
activity.callObjectMethod("startActivity", "(Landroid/content/Intent;)V", intent.object());
return true;
}
return false;
}
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#pragma once
#include <QObject>
namespace utils {
class Android : public QObject
{
Q_OBJECT
public:
explicit Android(QObject *parent = 0);
static bool openApk(const QString &uri);
};
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#include "config.h"
#include "file.h"
#include "json.h"
namespace utils {
Config::Config(const QString &configsDir, QObject *parent) :
QObject(parent), configsDir_(configsDir)
{}
QJsonObject Config::get(const QString &name)
{
QString configFile = configsDir_ + "/" + name + ".json";
if (!cacheData_.contains(name)) {
QString json = utils::File::readText(configFile);
if (json.isEmpty()) {
json = "{}"; // Blank JSON data as default
}
cacheData_[name] = utils::Json::convertStrToObj(json);
}
return cacheData_[name].toObject();
}
bool Config::set(const QString &name, const QJsonObject &jsonObj)
{
QString configFile = configsDir_ + "/" + name + ".json";
QString json = utils::Json::convertObjToStr(jsonObj);
utils::File::makeDir(configsDir_);
if (utils::File::writeText(configFile, json)) {
cacheData_[name] = jsonObj;
return true;
}
return false;
}
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#pragma once
#include <QObject>
#include <QJsonObject>
namespace utils {
class Config : public QObject
{
Q_OBJECT
public:
explicit Config(const QString &configsDir, QObject *parent = 0);
QJsonObject get(const QString &name);
bool set(const QString &name, const QJsonObject &jsonObj);
private:
QString configsDir_;
QJsonObject cacheData_;
};
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#include "file.h"
#include <QIODevice>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
namespace utils {
File::File(QObject *parent) : QObject(parent)
{}
QString File::rootPath()
{
return QDir::rootPath();
}
QString File::tempPath()
{
return QDir::tempPath();
}
QString File::homePath()
{
return QDir::homePath();
}
QString File::genericDataPath()
{
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
}
QString File::genericConfigPath()
{
return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
}
QString File::genericCachePath()
{
return QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
}
QString File::kdehomePath()
{
// KDE System Administration/Environment Variables
// https://userbase.kde.org/KDE_System_Administration/Environment_Variables
// KDE 4 maybe uses $KDEHOME
QString path = QString::fromLocal8Bit(qgetenv("KDEHOME").constData());
if (path.isEmpty()) {
path = homePath() + "/.kde";
}
return path;
}
QFileInfoList File::readDir(const QString &path)
{
QDir dir(path);
dir.setFilter(QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
//dir.setSorting(QDir::DirsFirst | QDir::Name);
return dir.entryInfoList();
}
bool File::makeDir(const QString &path)
{
// This function will create all parent directories
QDir dir(path);
if (!dir.exists() && dir.mkpath(path)) {
return true;
}
return false;
}
QString File::readText(const QString &path)
{
QString data;
QFile file(path);
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file);
in.setCodec("UTF-8");
data = in.readAll();
file.close();
}
return data;
}
bool File::writeText(const QString &path, const QString &data)
{
QFile file(path);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&file);
out.setCodec("UTF-8");
out << data;
file.close();
return true;
}
return false;
}
QByteArray File::readBinary(const QString &path)
{
QByteArray data;
QFile file(path);
if (file.exists() && file.open(QIODevice::ReadOnly)) {
data = file.readAll();
file.close();
}
return data;
}
bool File::writeBinary(const QString &path, const QByteArray &data)
{
QFile file(path);
if (file.open(QIODevice::WriteOnly)) {
file.write(data);
file.close();
return true;
}
return false;
}
bool File::copy(const QString &path, const QString &targetPath)
{
// This function will copy files recursively
QFileInfo fileInfo(path);
if (fileInfo.isFile()) {
QFile file(path);
if (file.copy(targetPath)) {
return true;
}
}
else if (fileInfo.isDir()) {
QDir targetDir(targetPath);
QString targetDirName = targetDir.dirName();
targetDir.cdUp();
if (targetDir.mkdir(targetDirName)) {
QDir dir(path);
dir.setFilter(QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
QStringList entries = dir.entryList();
foreach (const QString &entry, entries) {
if (!copy(path + "/" + entry, targetPath + "/" + entry)) {
return false;
}
}
return true;
}
}
return false;
}
bool File::move(const QString &path, const QString &targetPath)
{
QFileInfo fileInfo(path);
if (fileInfo.isFile()) {
QFile file(path);
if (file.rename(targetPath)) {
return true;
}
}
else if (fileInfo.isDir()) {
QDir dir(path);
if (dir.rename(path, targetPath)) {
return true;
}
}
return false;
}
bool File::remove(const QString &path)
{
// This function will remove files recursively
QFileInfo fileInfo(path);
if (fileInfo.isFile()) {
QFile file(path);
if (file.remove()) {
return true;
}
}
else if (fileInfo.isDir()) {
QDir dir(path);
if (dir.removeRecursively()) {
return true;
}
}
return false;
}
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#pragma once
#include <QObject>
class QFileInfo;
typedef QList<QFileInfo> QFileInfoList;
namespace utils {
class File : public QObject
{
Q_OBJECT
public:
explicit File(QObject *parent = 0);
static QString rootPath();
static QString tempPath();
static QString homePath();
static QString genericDataPath();
static QString genericConfigPath();
static QString genericCachePath();
static QString kdehomePath();
static QFileInfoList readDir(const QString &path);
static bool makeDir(const QString &path);
static QString readText(const QString &path);
static bool writeText(const QString &path, const QString &data);
static QByteArray readBinary(const QString &path);
static bool writeBinary(const QString &path, const QByteArray &data);
static bool copy(const QString &path, const QString &targetPath);
static bool move(const QString &path, const QString &targetPath);
static bool remove(const QString &path);
};
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#include "json.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
namespace utils {
Json::Json(QObject *parent) : QObject(parent)
{}
QString Json::convertObjToStr(const QJsonObject &jsonObj)
{
QJsonDocument jsonDoc(jsonObj);
return QString::fromUtf8(jsonDoc.toJson());
}
QJsonObject Json::convertStrToObj(const QString &json)
{
QJsonObject jsonObj;
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(json.toUtf8(), &jsonError);
if (jsonError.error == QJsonParseError::NoError && jsonDoc.isObject()) {
jsonObj = jsonDoc.object();
}
return jsonObj;
}
bool Json::isValid(const QString &json)
{
QJsonParseError jsonError;
QJsonDocument::fromJson(json.toUtf8(), &jsonError);
if (jsonError.error == QJsonParseError::NoError) {
return true;
}
return false;
}
} // namespace utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#pragma once
#include <QObject>
namespace utils {
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 utils
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
#include "network.h"
#include <QEventLoop>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
namespace utils {
Network::Network(const bool &async, QObject *parent) :
QObject(parent), async_(async)
{
manager_ = new QNetworkAccessManager(this);
connect(manager_, &QNetworkAccessManager::finished, this, &utils::Network::finished);
if (!async_) {
eventLoop_ = new QEventLoop();
connect(manager_, &QNetworkAccessManager::finished, eventLoop_, &QEventLoop::quit);
}
}
Network::~Network()
{
manager_->deleteLater();
if (!async_) {
delete eventLoop_;
}
}
QNetworkReply *Network::head(const QUrl &uri)
{
QNetworkReply *reply = manager_->head(QNetworkRequest(uri));
if (!async_) {
eventLoop_->exec();
}
return reply;
}
QNetworkReply *Network::get(const QUrl &uri)
{
QNetworkReply *reply = manager_->get(QNetworkRequest(uri));
connect(reply, &QNetworkReply::downloadProgress, this, &utils::Network::downloadProgress);
if (!async_) {
eventLoop_->exec();
}
return reply;
}
} // namespace utils