From 75b41c49bb194b7e6e7a73ed7ec62205c87a0514 Mon Sep 17 00:00:00 2001 From: Toni Date: Sun, 2 Nov 2025 15:49:34 +0100 Subject: [PATCH] new vault dialog --- CMakeLists.txt | 2 +- src/main.cc | 8 ++------ src/mainwindow.cc | 21 +++++++++++++++++++++ src/mainwindow.h | 14 ++++++++++++++ src/mainwindow.ui | 35 +++++++++++++---------------------- 5 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 src/mainwindow.cc create mode 100644 src/mainwindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 760158b..7c72278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_AUTOUIC ON) qt6_wrap_ui(UI_HEADERS src/mainwindow.ui) -add_executable(${PROJECT_NAME} src/main.cc ${UI_HEADERS}) +add_executable(${PROJECT_NAME} src/main.cc src/mainwindow.cc ${UI_HEADERS}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/main.cc b/src/main.cc index 8f0257c..6bd0704 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,14 +1,10 @@ -#include "ui_mainwindow.h" +#include "mainwindow.h" #include -#include int main(int argc, char *argv[]) { QApplication app(argc, argv); - QMainWindow window; - Ui::MainWindow ui; - ui.setupUi(&window); - + MainWindow window; window.show(); return QApplication::exec(); diff --git a/src/mainwindow.cc b/src/mainwindow.cc new file mode 100644 index 0000000..30b7dc0 --- /dev/null +++ b/src/mainwindow.cc @@ -0,0 +1,21 @@ +#include "mainwindow.h" +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) { + ui->setupUi(this); + + connect(ui->actionNew, &QAction::triggered, this, [this]() { + QString path = QFileDialog::getSaveFileName(this, "Choose vault location", + QDir::currentPath(), + "Dull Vaults (*.dull)"); + if (path.isEmpty()) { + return; + } + + std::ofstream file(path.toStdString(), std::ios::binary); + file.write("TEST", 4); + }); +} diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..eb858d3 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,14 @@ +#pragma once + +#include "ui_mainwindow.h" +#include + +class MainWindow : public QMainWindow { + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + +private: + Ui::MainWindow *ui; +}; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 31550f0..1acf7e6 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -13,28 +13,7 @@ MainWindow - - - - - 60 - 90 - 681 - 311 - - - - - 72 - true - true - - - - Hello, World! - - - + @@ -44,7 +23,19 @@ 30 + + + Vault + + + + + + + New + +