~mrp/aerodramus

ee2287893affb54903f6cd5f83dd9685d4552d10 — Mark Penner 6 months ago cc0cc76
add skeleton openFile action
4 files changed, 45 insertions(+), 1 deletions(-)

M src/CMakeLists.txt
M src/MainWindow.cpp
M src/MainWindow.h
A src/aerodramusui.rc
M src/CMakeLists.txt => src/CMakeLists.txt +3 -0
@@ 22,3 22,6 @@ target_link_libraries(aerodramus-gui PRIVATE
    KF6::XmlGui
)
set_target_properties(aerodramus-gui PROPERTIES OUTPUT_NAME "aerodramus")

install(TARGETS aerodramus-gui ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES aerodramusui.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/aerodramus)

M src/MainWindow.cpp => src/MainWindow.cpp +24 -1
@@ 3,10 3,33 @@

#include "MainWindow.h"

#include <KActionCollection>
#include <KLocalizedString>
#include <KStandardAction>
#include <QAction>
#include <QApplication>
#include <QFileDialog>

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

    setupActions();
    setupGUI(Default, QStringLiteral("aerodramusui.rc"));
}

void MainWindow::setupActions()
{
    KStandardAction::open(this, &MainWindow::openFile, actionCollection());
    KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection());
}

void MainWindow::openFile()
{
    const QString fileNameFromDialog =
        QFileDialog::getOpenFileName(this, i18n("Open File"), QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0]);

    qDebug() << "opening " << fileNameFromDialog;
}

M src/MainWindow.h => src/MainWindow.h +5 -0
@@ 8,11 8,16 @@

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

private:
    QWidget *centralWidget;
    void setupActions();

private Q_SLOTS:
    void openFile();
};

#endif // MAINWINDOW_H

A src/aerodramusui.rc => src/aerodramusui.rc +13 -0
@@ 0,0 1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<gui name="texteditor"
     version="1"
     xmlns="http://www.kde.org/standards/kxmlgui/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
                         http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd">
  <MenuBar>
  </MenuBar>

  <ToolBar name="mainToolBar" >
  </ToolBar>
</gui>