Commit 1db5aa00 authored by Camilo higuita's avatar Camilo higuita

stop using qmltermwidget as embeded into the projetc and rather use system installation

parent e0116317
TEMPLATE = subdirs
QT += qml
QT += quick
QT += sql
CONFIG += ordered
SUBDIRS += app
CONFIG += c++11
TARGET = index
#DESTDIR = $$OUT_PWD/../
linux:unix:!android {
message(Building Terminal for Linux KDE)
SUBDIRS += $$PWD/kde/qmltermwidget
message(Building for Linux KDE)
include($$PWD/src/kde/kde.pri)
} else:android {
message(Building helpers for Android)
include($$PWD/mauikit/mauikit.pri)
include($$PWD/3rdparty/kirigami/kirigami.pri)
DEFINES += STATIC_KIRIGAMI
} else {
message("Unknown configuration")
}
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
$$PWD/src/main.cpp \
$$PWD/src/index.cpp
RESOURCES += \
$$PWD/src/qml.qrc \
$$PWD/src/assets.qrc \
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
$$PWD/src/index.h \
$$PWD/src/inx.h
include($$PWD/install.pri)
DISTFILES += \
$$PWD/org.kde.index.desktop
function bookmarkFolders(urls)
{
}
function showPreviews()
{
browser.previews = !browser.previews
Maui.FM.setDirConf(browser.currentPath+"/.directory", "MAUIFM", "ShowThumbnail", browser.previews)
}
function showHiddenFiles()
{
var state = Maui.FM.dirConf(browser.currentPath+"/.directory").hidden
Maui.FM.setDirConf(browser.currentPath+"/.directory", "Settings", "HiddenFilesShown", !state)
browser.refresh()
}
function createFolder()
{
newFolderDialog.open()
}
function createFile()
{
newFileDialog.open()
}
function bookmarkFolder()
{
browser.bookmarkFolder([browser.currentPath])
}
QT += qml
QT += quick
QT += sql
CONFIG += c++11
TARGET = index
DESTDIR = $$OUT_PWD/../
linux:unix:!android {
message(Building for Linux KDE)
include($$PWD/../kde/kde.pri)
} else:android {
message(Building helpers for Android)
include($$PWD/../mauikit/mauikit.pri)
include($$PWD/../3rdparty/kirigami/kirigami.pri)
DEFINES += STATIC_KIRIGAMI
} else {
message("Unknown configuration")
}
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp \
index.cpp
RESOURCES += qml.qrc \
assets.qrc \
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
index.h \
inx.h
include($$PWD/../install.pri)
DISTFILES += \
../org.kde.index.desktop
<RCC>
<qresource prefix="/">
<file>index.png</file>
<file>assets/Astronaut.png</file>
<file>assets/Bench.png</file>
<file>assets/Bread.png</file>
<file>assets/Get started.png</file>
<file>assets/Grow.png</file>
<file>assets/HDD.png</file>
<file>assets/CPU.png</file>
<file>assets/ElectricPlug.png</file>
<file>assets/index.svg</file>
<file>assets/MoonSki.png</file>
<file>assets/Package.png</file>
<file>assets/Submarine.png</file>
<file>assets/SunSki.png</file>
<file>assets/tent.png</file>
</qresource>
</RCC>
This diff is collapsed.
This diff is collapsed.
#include "index.h"
#include <QFileInfo>
#include <QMimeType>
#include <QDirIterator>
#include <QDesktopServices>
#include <QUrl>
#include <QDebug>
#include "inx.h"
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include "kde/notify.h"
#include "kde/kde.h"
#endif
Index::Index(QObject *parent) : FM(parent)
{
}
QVariantList Index::getCustomPathContent(const QString &path)
{
QVariantList res;
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
if(path.startsWith(INX::CUSTOMPATH_PATH[INX::CUSTOMPATH::APPS]+"/"))
return KDE::getApps(QString(path).replace(INX::CUSTOMPATH_PATH[INX::CUSTOMPATH::APPS]+"/",""));
else
return KDE::getApps();
#endif
return res;
}
bool Index::isCustom(const QString &path)
{
return path.startsWith("#");
}
bool Index::isApp(const QString &path)
{
return /*QFileInfo(path).isExecutable() ||*/ path.endsWith(".desktop");
}
bool Index::openFile(const QString &path)
{
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}
void Index::openPaths(const QStringList &paths)
{
QStringList urls;
for(auto path : paths)
{
QFileInfo file(path);
if(file.isDir())
urls << path;
else
urls << file.dir().absolutePath();
}
emit this->openPath(urls);
}
QVariantList Index::getCustomPaths()
{
#ifdef Q_OS_ANDROID
return QVariantList();
#endif
return QVariantList
{
QVariantMap
{
{INX::MODEL_NAME[INX::MODEL_KEY::ICON], "system-run"},
{INX::MODEL_NAME[INX::MODEL_KEY::LABEL], INX::CUSTOMPATH_NAME[INX::CUSTOMPATH::APPS]},
{INX::MODEL_NAME[INX::MODEL_KEY::PATH], INX::CUSTOMPATH_PATH[INX::CUSTOMPATH::APPS]},
{INX::MODEL_NAME[INX::MODEL_KEY::TYPE], INX::PATHTYPE_NAME[INX::PATHTYPE_KEY::PLACES]}
}
};
}
QVariantMap Index::getDirInfo(const QString &path, const QString &type)
{
QFileInfo file (path);
QVariantMap data =
{
{INX::MODEL_NAME[INX::MODEL_KEY::ICON], INX::getIconName(path)},
{INX::MODEL_NAME[INX::MODEL_KEY::LABEL], file.baseName()},
{INX::MODEL_NAME[INX::MODEL_KEY::PATH], path},
{INX::MODEL_NAME[INX::MODEL_KEY::TYPE], type}
};
return data;
}
QVariantMap Index::getFileInfo(const QString &path)
{
QFileInfo file(path);
if(!file.exists()) return QVariantMap();
auto mime = FMH::getMime(path);
QVariantMap res =
{
{INX::MODEL_NAME[INX::MODEL_KEY::GROUP], file.group()},
{INX::MODEL_NAME[INX::MODEL_KEY::OWNER], file.owner()},
{INX::MODEL_NAME[INX::MODEL_KEY::SUFFIX], file.completeSuffix()},
{INX::MODEL_NAME[INX::MODEL_KEY::LABEL], file.completeBaseName()},
{INX::MODEL_NAME[INX::MODEL_KEY::NAME], file.fileName()},
{INX::MODEL_NAME[INX::MODEL_KEY::DATE], file.birthTime().toString()},
{INX::MODEL_NAME[INX::MODEL_KEY::MODIFIED], file.lastModified().toString()},
{INX::MODEL_NAME[INX::MODEL_KEY::MIME], mime },
{INX::MODEL_NAME[INX::MODEL_KEY::ICON], INX::getIconName(path)}
};
return res;
}
void Index::runApplication(const QString &exec, const QString &url)
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
return KDE::launchApp(exec);
#endif
}
void Index::saveSettings(const QString &key, const QVariant &value, const QString &group)
{
INX::saveSettings(key, value, group);
}
QVariant Index::loadSettings(const QString &key, const QString &group, const QVariant &defaultValue)
{
return INX::loadSettings(key, group, defaultValue);
}
#ifndef INDEX_H
#define INDEX_H
#include <QObject>
#include <QVariantList>
#include <QStringList>
#include <QFileSystemWatcher>
#ifdef STATIC_KIRIGAMI
#include "fm.h"
#else
#include "MauiKit/fm.h"
#endif
class Index : public FM
{
Q_OBJECT
public:
explicit Index(QObject *parent = nullptr);
Q_INVOKABLE static QVariantList getCustomPathContent(const QString &path);
Q_INVOKABLE static bool isCustom(const QString &path);
Q_INVOKABLE static bool isApp(const QString &path);
Q_INVOKABLE static bool openFile(const QString &path);
Q_INVOKABLE void openPaths(const QStringList &paths);
Q_INVOKABLE static QVariantList getCustomPaths();
Q_INVOKABLE static void saveSettings(const QString &key, const QVariant &value, const QString &group);
Q_INVOKABLE static QVariant loadSettings(const QString &key, const QString &group, const QVariant &defaultValue);
Q_INVOKABLE static QVariantMap getDirInfo(const QString &path, const QString &type);
Q_INVOKABLE static QVariantMap getFileInfo(const QString &path);
/*KDE*/
Q_INVOKABLE static void runApplication(const QString &exec, const QString &url);
signals:
void openPath(QStringList paths);
public slots:
};
#endif // INDEX_H
src/index.png

654 Bytes

#ifndef INX_H
#define INX_H
#include <QString>
#include <QDebug>
#include <QStandardPaths>
#include <QFileInfo>
#include <QImage>
#include <QTime>
#include <QSettings>
#include <QDirIterator>
#include <QVariantList>
#include <QMimeType>
#include <QMimeData>
#include <QMimeDatabase>
#if defined(Q_OS_ANDROID)
#include "../mauikit/src/android/mauiandroid.h"
#endif
namespace INX
{
Q_NAMESPACE
inline bool isMobile()
{
#if defined(Q_OS_ANDROID)
return true;
#elif defined(Q_OS_LINUX)
return false;
#elif defined(Q_OS_WIN32)
return false;
#elif defined(Q_OS_WIN64)
return false;
#elif defined(Q_OS_MACOS)
return false;
#elif defined(Q_OS_IOS)
return true;
#elif defined(Q_OS_HAIKU)
return false;
#endif
}
inline bool isAndroid()
{
#if defined(Q_OS_ANDROID)
return true;
#elif defined(Q_OS_LINUX)
return false;
#elif defined(Q_OS_WIN32)
return false;
#elif defined(Q_OS_WIN64)
return false;
#elif defined(Q_OS_MACOS)
return false;
#elif defined(Q_OS_IOS)
return false;
#elif defined(Q_OS_HAIKU)
return false;
#endif
}
#if defined(Q_OS_ANDROID)
const QString PicturesPath = PATHS::PicturesPath;
const QString DownloadsPath = PATHS::DownloadsPath;
const QString DocumentsPath = PATHS::DocumentsPath;
const QString HomePath = PATHS::HomePath;
const QString MusicPath = PATHS::MusicPath;
const QString VideosPath = PATHS::VideosPath;
const QStringList defaultPaths =
{
HomePath,
DocumentsPath,
PicturesPath,
MusicPath,
VideosPath,
DownloadsPath
};
const QMap<QString, QString> folderIcon
{
{PicturesPath, "folder-pictures"},
{DownloadsPath, "folder-download"},
{DocumentsPath, "folder-documents"},
{HomePath, "user-home"},
{MusicPath, "folder-music"},
{VideosPath, "folder-videos"},
};
#else
const QString PicturesPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
const QString DownloadsPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
const QString DocumentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
const QString HomePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString MusicPath = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
const QString VideosPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
const QString DesktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
const QString AppsPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
const QString RootPath = "/";
const QStringList defaultPaths =
{
HomePath,
DesktopPath,
DocumentsPath,
PicturesPath,
MusicPath,
VideosPath,
DownloadsPath
};
const QMap<QString, QString> folderIcon
{
{PicturesPath, "folder-pictures"},
{DownloadsPath, "folder-download"},
{DocumentsPath, "folder-documents"},
{HomePath, "user-home"},
{MusicPath, "folder-music"},
{VideosPath, "folder-videos"},
{DesktopPath, "user-desktop"},
{AppsPath, "system-run"},
{RootPath, "folder-root"}
};
#endif
inline QString getIconName(const QString &path)
{
if(QFileInfo(path).isDir())
{
if(folderIcon.contains(path))
return folderIcon[path];
else return "folder";
}else
{
QMimeDatabase mime;
auto type = mime.mimeTypeForFile(path);
return isAndroid() ? type.genericIconName() : type.iconName();
}
return "unkown";
}
enum class MODEL_KEY : uint_fast8_t
{
ICON,
LABEL,
PATH,
TYPE,
GROUP,
OWNER,
SUFFIX,
NAME,
DATE,
MODIFIED,
MIME,
TAGS,
PERMISSIONS
};
static const QMap<MODEL_KEY, QString> MODEL_NAME =
{
{MODEL_KEY::ICON, "icon"},
{MODEL_KEY::LABEL, "label"},
{MODEL_KEY::PATH, "path"},
{MODEL_KEY::TYPE, "type"},
{MODEL_KEY::GROUP, "group"},
{MODEL_KEY::OWNER, "owner"},
{MODEL_KEY::SUFFIX, "suffix"},
{MODEL_KEY::NAME, "name"},
{MODEL_KEY::DATE, "date"},
{MODEL_KEY::MODIFIED, "modified"},
{MODEL_KEY::MIME, "mime"},
{MODEL_KEY::TAGS, "tags"},
{MODEL_KEY::PERMISSIONS, "permissions"}
};
enum class CUSTOMPATH : uint_fast8_t
{
APPS,
TAGS,
TRASH
};
static const QMap<CUSTOMPATH, QString> CUSTOMPATH_PATH =
{
{CUSTOMPATH::APPS, "#apps"},
{CUSTOMPATH::TAGS, "#tags"},
{CUSTOMPATH::TRASH, "#trash"}
};
static const QMap<CUSTOMPATH, QString> CUSTOMPATH_NAME =
{
{CUSTOMPATH::APPS, "Apps"},
{CUSTOMPATH::TAGS, "Tags"},
{CUSTOMPATH::TRASH, "Trash"}
};
enum class PATHTYPE_KEY : uint_fast8_t
{
PLACES,
DRIVES,
BOOKMARKS,
TAGS
};
static const QMap<PATHTYPE_KEY, QString> PATHTYPE_NAME =
{
{PATHTYPE_KEY::PLACES, "Places"},
{PATHTYPE_KEY::DRIVES, "Drives"},
{PATHTYPE_KEY::BOOKMARKS, "Bookmarks"},
{PATHTYPE_KEY::TAGS, "Tags"}
};
const QString SettingPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/pix/";
const QString CachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)+"/pix/";
const QString NotifyDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
const QString app = "Index";
const QString version = "0.1.0";
const QString description = "File manager";
inline void saveSettings(const QString &key, const QVariant &value, const QString &group)
{
QSettings setting(INX::app,INX::app);
setting.beginGroup(group);
setting.setValue(key,value);
setting.endGroup();
}
inline QVariant loadSettings(const QString &key, const QString &group, const QVariant &defaultValue)
{
QVariant variant;
QSettings setting(INX::app,INX::app);
setting.beginGroup(group);
variant = setting.value(key,defaultValue);
setting.endGroup();
return variant;
}
}
#endif // INX_H
*.pro.user
*.*~
~*.*
/***
Pix Copyright (C) 2018 Camilo Higuita
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
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, see <http://www.gnu.org/licenses/>.
***/
#include "kde.h"
#include <KService>
#include <KMimeTypeTrader>
#include <KToolInvocation>
#include <KLocalizedString>
#include <QDebug>