~mrp/aerodramus

cc0cc76637ef360835a80500cff434777edb32ff — Mark Penner 7 months ago 91f8301
try kxmlgui
7 files changed, 64 insertions(+), 162 deletions(-)

M CMakeLists.txt
M src/CMakeLists.txt
A src/MainWindow.cpp
A src/MainWindow.h
M src/main.cpp
D src/qml/AudioFile.qml
D src/qml/main.qml
M CMakeLists.txt => CMakeLists.txt +4 -8
@@ 16,7 16,6 @@ find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

include(ECMAddTests)
include(ECMFindQmlModule)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)


@@ 29,16 28,13 @@ kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)

find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
    Core
    Quick
    QuickControls2
    QuickDialogs2
    Charts
    Widgets
)

find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS
    Kirigami2
    I18n
    CoreAddons
    XmlGui
)

find_library(LIBSNDFILE REQUIRED


@@ 46,10 42,10 @@ find_library(LIBSNDFILE REQUIRED
    PATHS /usr/lib/x86_64-linux-gnu/
)

ecm_find_qmlmodule(org.kde.kirigami)

add_subdirectory(src)
if (BUILD_TESTING)
    find_package(Qt6 ${QT_MIN_VERSION} NO_MODULE COMPONENTS Test)
    add_subdirectory(autotests)
endif()

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

M src/CMakeLists.txt => src/CMakeLists.txt +5 -14
@@ 3,15 3,7 @@

add_executable(aerodramus-gui
    main.cpp
)
qt_add_qml_module(aerodramus-gui URI mrp.aerodramus NO_RESOURCE_TARGET_PATH
    QML_FILES
        qml/main.qml
        qml/AudioFile.qml
    SOURCES
        app.cpp
        audiofile.cpp
        filelistmodel.cpp
    MainWindow.cpp
)

add_library(aerodramus STATIC


@@ 24,10 16,9 @@ target_link_libraries(aerodramus PRIVATE
target_link_libraries(aerodramus-gui PRIVATE
    aerodramus
    Qt::Core
    Qt::Quick
    Qt::QuickControls2
    Qt::QuickDialogs2
    Qt::Charts
    KF6::Kirigami2
    Qt::Widgets
    KF6::I18n
    KF6::CoreAddons
    KF6::XmlGui
)
set_target_properties(aerodramus-gui PROPERTIES OUTPUT_NAME "aerodramus")

A src/MainWindow.cpp => src/MainWindow.cpp +12 -0
@@ 0,0 1,12 @@
// SPDX-FileCopyrightText: 2023 Mark Penner <mrpenner@mailbox.org>
// SPDX-License-Identifier: GPL-3.0-or-later

#include "MainWindow.h"

MainWindow::MainWindow(QWidget *parent)
    : KXmlGuiWindow(parent)
{
    centralWidget = new QWidget();
    setCentralWidget(centralWidget);
    setupGUI();
}

A src/MainWindow.h => src/MainWindow.h +18 -0
@@ 0,0 1,18 @@
// SPDX-FileCopyrightText: 2023 Mark Penner <mrpenner@mailbox.org>
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <KXmlGuiWindow>

class MainWindow : public KXmlGuiWindow
{
public:
    explicit MainWindow(QWidget *parent = nullptr);

private:
    QWidget *centralWidget;
};

#endif // MAINWINDOW_H

M src/main.cpp => src/main.cpp +25 -13
@@ 1,30 1,42 @@
// SPDX-FileCopyrightText: 2023 Mark Penner <mrpenner@mailbox.org>
// SPDX-License-Identifier: GPL-3.0-or-later

#include "MainWindow.h"
#include <KAboutData>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QCommandLineParser>
#include <QUrl>
#include <QtQml>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    KLocalizedString::setApplicationDomain("markpenner.space");
    QCoreApplication::setApplicationName(QStringLiteral("Aerodramus"));
    KLocalizedString::setApplicationDomain("aerodramus");

    QQmlApplicationEngine engine;
    engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
    engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
    KAboutData aboutData(QStringLiteral("aerodramus"),
                         i18n("Aerodramus 0.0.1"),
                         QStringLiteral("0.0.1"),
                         i18n("Acoustics analysis tools"),
                         KAboutLicense::GPL_V3,
                         i18n("(c) 2023"),
                         i18n("A collection of tools for analyzing room acoustics"),
                         QStringLiteral("https://codeberg.org/mrp/aerodramus"),
                         QStringLiteral("mrpenner@mailbox.org"));
    aboutData.addAuthor(i18n("Mark Penner"),
                        i18n("Developer"),
                        QStringLiteral("mrpenner@mailbox.org"),
                        QStringLiteral("https://markpenner.space"),
                        QStringLiteral(""));
    KAboutData::setApplicationData(aboutData);

    if (engine.rootObjects().isEmpty()) {
        return -1;
    }
    QCommandLineParser parser;
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    QObject *root = engine.rootObjects().first();

    QObject::connect(root, SIGNAL(quitSignal()), &app, SLOT(quit()), Qt::QueuedConnection);
    MainWindow *window = new MainWindow();
    window->show();

    return app.exec();
}

D src/qml/AudioFile.qml => src/qml/AudioFile.qml +0 -48
@@ 1,48 0,0 @@
// SPDX-FileCopyrightText: 2023 Mark Penner <mrpenner@mailbox.org>
// SPDX-License-Identifier: GPL-3.0-or-later

import QtCharts
import QtQuick
import org.kde.kirigami as Kirigami

import mrp.aerodramus

Kirigami.Page {

    property alias fileUrl: aFile.fileUrl
    property alias name: aFile.name

    ChartView {
        id: chart
        title: "Line"
        antialiasing: true
        anchors.fill: parent

        ValueAxis {
            id: xAxis
            min: 0
            max: 20
        }
        ValueAxis {
            id: yAxis
            min: 0
            max: 20000
        }
        LineSeries {
            id: series1
            name: "Wave"
            axisX: xAxis
            axisY: yAxis
        }

        AudioFile {
            id: aFile
            waveSeries: series1
        }
    }

    Component.onCompleted: {
        console.log("graphing ", name);
        aFile.graphData();
    }
}

D src/qml/main.qml => src/qml/main.qml +0 -79
@@ 1,79 0,0 @@
// SPDX-FileCopyrightText: 2023 Mark Penner <mrpenner@mailbox.org>
// SPDX-License-Identifier: GPL-3.0-or-later

import QtCore
import QtQuick
import QtQuick.Controls as QQC
import QtQuick.Dialogs
import QtQuick.Layouts
import org.kde.kirigami as Kirigami

import mrp.aerodramus

Kirigami.ApplicationWindow {
    id: root
    property Kirigami.Page mainPage
    title: i18nc("@title:window", "Aerodramus")
    visible: true
    minimumHeight: 600
    minimumWidth: 800
    signal quitSignal()

    Kirigami.Action {
        id: quitAction
        text: i18n("Quit")
        icon.name: "application-exit"
        shortcut: StandardKey.Quit
        onTriggered: root.quitSignal()
    }
    Kirigami.Action {
        id: openAction
        text: i18n("Open...")
        icon.name: "document-new"
        shortcut: StandardKey.Open
        onTriggered: openDialog.open()
    }

    FileDialog {
        id: openDialog
        fileMode: FileDialog.OpenFile
        currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
        onAccepted: openFilePage(selectedFile)
    }

    globalDrawer: Kirigami.GlobalDrawer {
        isMenu: true
        actions: [
            openAction,
            quitAction
        ]
    }

    pageStack.initialPage: navPage
    Kirigami.ScrollablePage {
        id: navPage
        ListView {
            id: listView
            Kirigami.PlaceholderMessage {
                anchors.centerIn: parent
                width: parent.width - (Kirigami.Units.largeSpacing * 4)
                visible: listView.count === 0
                text: i18n("No views yet")
                helpfulAction: openAction
            }
            model: App.fileListModel
            delegate: QQC.Label{
                required property string name
                text: name
            }
        }
    }
    function openFilePage(fileUrl) {
        if (pageStack.depth >= 2) {
            pageStack.currentIndex = 1;
            pageStack.pop();
        }
        root.mainPage = pageStack.push("qrc:/qml/AudioFile.qml", {fileUrl: fileUrl});
        App.appendFile(root.mainPage.name);
    }
}