Commit 1e74ef4b authored by Camilo Higuita's avatar Camilo Higuita

work on open with dialog #6

parent a4883c4d
QT += qml quick quickcontrols2 sql widgets
android:
{
linux:unix:!android {
message(Building for Linux KDE)
include(kde/KDE.pri)
} else:android {
message(Building helpers for Android)
include(3rdparty/kirigami/kirigami.pri)
}
RESOURCES += kirigami-icons.qrc
} else {
message("Unknown configuration")
}
CONFIG += c++11
......@@ -37,11 +48,10 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
SUBDIRS += \
src/Pixs.pro
src/Pixs.pro \
RESOURCES += \
src/qml.qrc \
kirigami-icons.qrc
HEADERS += \
src/pix.h \
......
QT += KService KNotifications KNotifications KI18n
QT += KIOCore KIOFileWidgets KIOWidgets KNTLM
HEADERS += \
$$PWD/kde.h \
$$PWD/notify.h
SOURCES += \
$$PWD/kde.cpp \
$$PWD/notify.cpp
#include "kde.h"
#include <KService>
#include <KMimeTypeTrader>
#include <KLocalizedString>
#include <QDebug>
KDE::KDE(QObject *parent) : QObject(parent)
{
}
static QVariantMap createActionItem(const QString &label, const QString &actionId, const QVariant &argument = QVariant())
{
QVariantMap map;
map["text"] = label;
map["actionId"] = actionId;
if (argument.isValid()) {
map["actionArgument"] = argument;
}
return map;
}
QVariantList KDE::mimeApps(const QUrl &url)
{
QVariantList list;
if (url.isValid())
{
auto fileItem = new KFileItem(url);
fileItem->determineMimeType();
KService::List services = KMimeTypeTrader::self()->query(fileItem->mimetype(), "Application");
if (!services.isEmpty())
{
foreach (const KService::Ptr service, services)
{
const QString text = service->name().replace('&', "&&");
QVariantMap item = createActionItem(text, "_kicker_fileItem_openWith", service->entryPath());
item["icon"] = service->icon();
list << item;
}
}
list << createActionItem(i18n("Properties"), "_kicker_fileItem_properties");
qDebug()<<list;
return list;
} else return list;
}
#ifndef KDE_H
#define KDE_H
#include <QObject>
#include <QVariantList>
#include <KFileItem>
class KDE : public QObject
{
Q_OBJECT
public:
explicit KDE(QObject *parent = nullptr);
static QVariantList mimeApps(const QUrl &url);
signals:
public slots:
};
#endif // KDE_H
/*
Babe - tiny music player
Copyright (C) 2017 Camilo Higuita
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "notify.h"
Notify::Notify(QObject *parent) : QObject(parent)
{}
Notify::~Notify()
{
qDebug()<<"DELETING KNOTIFY";
}
void Notify::notify(const QString &title, const QString &body)
{
// notification->setComponentName(QStringLiteral("Babe"));
auto notification = new KNotification(QStringLiteral("Notify"),KNotification::CloseOnTimeout, this);
connect(notification, &KNotification::closed, notification, &KNotification::deleteLater);
notification->setTitle(QStringLiteral("%1").arg(title));
notification->setText(QStringLiteral("%1").arg(body));
notification->sendEvent();
}
#ifndef NOTIFY_H
#define NOTIFY_H
#include <QObject>
#include <QByteArray>
#include <klocalizedstring.h>
#include <knotifyconfig.h>
#include <knotification.h>
#include <QStandardPaths>
#include <QPixmap>
#include <QDebug>
#include <QMap>
#include "../src/utils/pic.h"
class Notify : public QObject
{
Q_OBJECT
public:
explicit Notify(QObject *parent = nullptr);
~Notify();
void notify(const QString &title, const QString &body);
private:
};
#endif // NOTIFY_H
......@@ -10,6 +10,11 @@
#include <QWidget>
#include <QColor>
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include "kde/notify.h"
#include "kde/kde.h"
#endif
using namespace PIX;
Pix::Pix(QObject *parent) : DBActions(parent)
......@@ -77,75 +82,11 @@ void Pix::populateDB(const QString &path)
fileLoader->requestPath(newPath);
}
QString Pix::backgroundColor()
{
#if defined(Q_OS_ANDROID)
return "#31363b";
#elif defined(Q_OS_LINUX)
QWidget widget;
return widget.palette().color(QPalette::Background).name();
#elif defined(Q_OS_WIN32)
return "#31363b";
#endif
}
QString Pix::foregroundColor()
{
#if defined(Q_OS_ANDROID)
return "#FFF";
#elif defined(Q_OS_LINUX)
QWidget widget;
return widget.palette().color(QPalette::Text).name();
#elif defined(Q_OS_WIN32)
return "#FFF";
#endif
}
QString Pix::hightlightColor()
{
#if defined(Q_OS_ANDROID)
return "";
#elif defined(Q_OS_LINUX)
QWidget widget;
return widget.palette().color(QPalette::Highlight).name();
#elif defined(Q_OS_WIN32)
return "";
#endif
}
QString Pix::midColor()
{
#if defined(Q_OS_ANDROID)
return "#31363b";
#elif defined(Q_OS_LINUX)
QWidget widget;
return widget.palette().color(QPalette::Midlight).name();
#elif defined(Q_OS_WIN32)
return "#31363b";
#endif
}
QString Pix::altColor()
{
#if defined(Q_OS_ANDROID)
return "#232629";
#elif defined(Q_OS_LINUX)
QWidget widget;
return widget.palette().color(QPalette::Base).name();
#elif defined(Q_OS_WIN32)
return "#232629";
#endif
}
QString Pix::pixColor()
{
return "#03A9F4";
}
bool Pix::isMobile()
{
return PIX::isMobile();
}
int Pix::screenGeometry(QString &side)
{
......@@ -212,5 +153,14 @@ QVariantMap Pix::getParentDir(const QString &path)
}
QVariantList Pix::openWith(const QString &url)
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
return KDE::mimeApps(url);
#elif defined (Q_OS_ANDROID)
return QVariantList();
#endif
}
......@@ -29,15 +29,8 @@ class Pix : public DBActions
Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE bool run(const QString &query);
Q_INVOKABLE static QString backgroundColor();
Q_INVOKABLE static QString foregroundColor();
Q_INVOKABLE static QString hightlightColor();
Q_INVOKABLE static QString midColor();
Q_INVOKABLE static QString altColor();
Q_INVOKABLE static QString pixColor();
Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static int screenGeometry(QString &side);
Q_INVOKABLE static int cursorPos(QString &axis);
......@@ -46,6 +39,7 @@ class Pix : public DBActions
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
Q_INVOKABLE static QVariantList openWith(const QString &url);
private:
FileLoader *fileLoader;
......
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