diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b85d14..290f972 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,52 +1,55 @@ project(index) cmake_minimum_required(VERSION 3.0) find_package(ECM 1.7.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH}) -find_package(MauiKit REQUIRED) +#find_package(MauiKit REQUIRED) find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Qml Quick Sql Svg QuickControls2 Widgets) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMInstallIcons) include(FeatureSummary) include(ECMAddAppIcon) set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) add_executable(index src/assets.qrc src/main.cpp src/index.cpp src/qml.qrc - src/kde/notify.cpp +# src/kde/notify.cpp ) - + if (ANDROID) find_package(Qt5 REQUIRED COMPONENTS AndroidExtras) - target_link_libraries(vvave Qt5::AndroidExtras) + target_link_libraries(index Qt5::AndroidExtras) kde_source_files_enable_exceptions(index src/index.cpp) -else() - find_package(KF5 ${KF5_VERSION} REQUIRED COMPONENTS I18n Notifications Config KIO Service Attica) +else() +# find_package(KF5 ${KF5_VERSION} REQUIRED COMPONENTS I18n Notifications Config KIO Service Attica) find_package(Qt5 REQUIRED COMPONENTS WebEngine) - target_link_libraries(index KF5::ConfigCore KF5::Notifications KF5::KIOCore KF5::I18n KF5::Service KF5::Attica) +# target_link_libraries(index KF5::ConfigCore KF5::Notifications KF5::KIOCore KF5::I18n KF5::Service KF5::Attica) endif() if (TARGET create-apk-index) set_target_properties(create-apk-index PROPERTIES ANDROID_APK_DIR "${MAUIKIT_ANDROID_DIR}") endif() -target_link_libraries(index MauiKit Qt5::Sql Qt5::Qml Qt5::Widgets Qt5::Svg) +target_link_libraries(index Qt5::Sql Qt5::Qml Qt5::Widgets Qt5::Svg) install(TARGETS index ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES org.kde.index.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) #TODO: port to ecm_install_icons() install(FILES src/assets/index.svg DESTINATION ${KDE_INSTALL_ICONDIR}/hicolor/scalable/apps) # install(FILES org.kde.index.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/index.cpp b/src/index.cpp index de1c537..1d94682 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -1,26 +1,25 @@ #include "index.h" #include #include #include #if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)) #include "kde/notify.h" #endif Index::Index(QObject *parent) : QObject(parent) {} /* to be called to launch index with opening different paths */ void Index::openPaths(const QStringList &paths) { - QStringList urls; - for(auto path : paths) + emit this->openPath(std::accumulate(paths.constBegin(), paths.constEnd(), QStringList(), [](QStringList &list, const QString &path) -> QStringList { - QFileInfo file(path); + const QFileInfo file(path); if(file.isDir()) - urls << path; + list << path; else - urls << file.dir().absolutePath(); - } + list << file.dir().absolutePath(); - emit this->openPath(urls); + return list; + })); } diff --git a/src/main.cpp b/src/main.cpp index e8960c0..542ec37 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,94 +1,85 @@ #include #include #include #include #include #include #include #include "index.h" #include "inx.h" #ifdef Q_OS_ANDROID #include #include #else #include #endif #ifdef STATIC_KIRIGAMI #include "./../3rdparty/kirigami/src/kirigamiplugin.h" #endif -#ifdef STATIC_MAUIKIT -#include "./../mauikit/src/mauikit.h" -#include "tagging.h" -#include "fm.h" -#else -#include "MauiKit/tagging.h" -#include "MauiKit/fm.h" -#endif - int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #ifdef Q_OS_ANDROID QGuiApplication app(argc, argv); #else QApplication app(argc, argv); #endif app.setApplicationName(INX::app); app.setApplicationVersion(INX::version); app.setApplicationDisplayName(INX::app); app.setOrganizationName("org.maui.index"); app.setWindowIcon(QIcon(":/index.png")); QCommandLineParser parser; parser.setApplicationDescription(INX::description); const QCommandLineOption versionOption = parser.addVersionOption(); parser.addOption(versionOption); parser.process(app); const QStringList args = parser.positionalArguments(); QStringList paths; if(!args.isEmpty()) paths = args; Index index; QQmlApplicationEngine engine; QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, [&]() { if(!paths.isEmpty()) index.openPaths(paths); }); auto context = engine.rootContext(); context->setContextProperty("inx", &index); #ifdef STATIC_KIRIGAMI KirigamiPlugin::getInstance().registerTypes(); #endif #ifdef STATIC_MAUIKIT MauiKit::getInstance().registerTypes(); #endif #ifndef Q_OS_ANDROID // QStringList importPathList = engine.importPathList(); // importPathList.prepend(QCoreApplication::applicationDirPath() + "/kde/qmltermwidget"); // engine.setImportPathList(importPathList); // QQuickStyle::setStyle("material"); #endif // QQuickStyle::setStyle("Material"); engine.load(QUrl(QLatin1String("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); } diff --git a/src/widgets/views/Browser.qml b/src/widgets/views/Browser.qml index e41258a..1594e31 100644 --- a/src/widgets/views/Browser.qml +++ b/src/widgets/views/Browser.qml @@ -1,132 +1,131 @@ import QtQuick 2.9 -import QtQuick.Controls 2.2 +import QtQuick.Controls 2.13 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.0 as Kirigami import org.kde.mauikit 1.0 as Maui //import FMH 1.0 -ColumnLayout +SplitView { id: control - spacing: 0 + orientation: Qt.Vertical property alias browser : browser - property bool terminalVisible : false - // property alias terminal : terminalLoader.item + property bool terminalVisible : true + property alias terminal : terminalLoader.item Maui.FileBrowser { id: browser - Layout.fillWidth: true - Layout.fillHeight: true - Layout.margins: 0 + SplitView.fillWidth: true + SplitView.fillHeight: true headBar.visible: true headBar.drawBorder: true headBar.plegable: false menu:[ - MenuItem - { - visible: !isMobile - text: qsTr("Show terminal") - checkable: true - checked: terminalVisible - onTriggered: - { - terminalVisible = !terminalVisible - Maui.FM.setDirConf(browser.currentPath+"/.directory", "MAUIFM", "ShowTerminal", terminalVisible) - } - }/*, - -// Maui.MenuItem +// MenuItem // { +// visible: !isMobile +// text: qsTr("Show terminal") // checkable: true -// checked: placesSidebar.isCollapsed -// text: qsTr("Compact mode") -// onTriggered: placesSidebar.isCollapsed = !placesSidebar.isCollapsed -// }*/ +// checked: terminalVisible +// onTriggered: +// { +// terminalVisible = !terminalVisible +// Maui.FM.setDirConf(browser.currentPath+"/.directory", "MAUIFM", "ShowTerminal", terminalVisible) +// } +// } ] + headBar.rightContent: ToolButton + { + icon.name: "akonadiconsole" + onClicked: control.terminalVisible = !control.terminalVisible + checked : control.terminalVisible + checkable: false + } + onNewBookmark: { for(var index in paths) placesSidebar.list.addPlace(paths[index]) } onCurrentPathChanged: { - if(!isAndroid) - terminalVisible = Maui.FM.dirConf(currentPath+"/.directory")["showterminal"] === "true" ? true : false +// if(!isAndroid) +// terminalVisible = Maui.FM.dirConf(currentPath+"/.directory")["showterminal"] === "true" ? true : false - // if(terminalVisible && !isMobile) - // terminal.session.sendText("cd " + currentPath + "\n") + if(terminalVisible && !isMobile) + terminal.session.sendText("cd '" + currentPath + "'\n") for(var i = 0; i < placesSidebar.count; i++) if(currentPath === placesSidebar.list.get(i).path) placesSidebar.currentIndex = i } - anchors.top: parent.top - anchors.bottom: terminalVisible ? handle.top : parent.bottom - onItemClicked: openItem(index) onItemDoubleClicked: { var item = list.get(index) console.log(item.mime) if(Maui.FM.isDir(item.path) || item.mime === "inode/directory") browser.openFolder(item.path) else browser.openFile(item.path) } } - Rectangle - { - id: handle - visible: true - - Layout.fillWidth: true - height: 5 - color: "transparent" +// Rectangle +// { +// id: handle +// visible: true - Kirigami.Separator - { - visible: terminalLoader.visible - - anchors - { - bottom: parent.bottom - right: parent.right - left: parent.left - } - } +// Layout.fillWidth: true +// height: 5 +// color: "transparent" - MouseArea - { - visible: terminalLoader.visible +// Kirigami.Separator +// { +// visible: terminalLoader.visible - anchors.fill: parent - drag.target: parent - drag.axis: Drag.YAxis - drag.smoothed: true - cursorShape: Qt.SizeVerCursor - } - } +// anchors +// { +// bottom: parent.bottom +// right: parent.right +// left: parent.left +// } +// } + +// MouseArea +// { +// visible: terminalLoader.visible + +// anchors.fill: parent +// drag.target: parent +// drag.axis: Drag.YAxis +// drag.smoothed: true +// cursorShape: Qt.SizeVerCursor +// } +// } + +// handle: Rectangle +// { +// color: "yellow" +// } Loader { id: terminalLoader - visible: false + visible: terminalVisible focus: true - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignBottom - Layout.minimumHeight: 100 - Layout.maximumHeight: control.height * 0.3 - anchors.bottom: parent.bottom - anchors.top: handle.bottom - // source: !isMobile ? "Terminal.qml" : undefined + SplitView.fillWidth: true + SplitView.fillHeight: true + SplitView.minimumHeight: 100 + SplitView.maximumHeight: 500 + SplitView.preferredHeight : 200 + source: !isMobile ? "Terminal.qml" : undefined } }