bit of ux

This commit is contained in:
2025-11-04 21:21:03 +01:00
parent 4ddab5afeb
commit 30ca8b6262
5 changed files with 37 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ depends=('qt6-base' 'botan')
makedepends=('cmake')
source=("${url}/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('SKIP')
DEBUGPKG=()
options=('!debug')
build() {
cd "${pkgname}-${pkgver}"

View File

@@ -25,7 +25,7 @@ sudo pacman -S base-devel
makepkg -si
```
### Windows / MSYS2
### Windows (MSYS2)
```
pacman -S --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-qt6-base mingw-w64-x86_64-qt6-tools mingw-w64-x86_64-libbotan

View File

@@ -1,3 +1,4 @@
// TODO: actual fs
#include "mainwindow.h"
#include <QDesktopServices>
#include <QDragEnterEvent>
@@ -38,6 +39,9 @@ MainWindow::MainWindow(QWidget *parent)
return;
}
ui->statusbar->showMessage("Creating the vault...");
QCoreApplication::processEvents();
static Botan::AutoSeeded_RNG rng;
auto salt_sv = rng.random_vec(16);
std::vector<u8> salt(salt_sv.begin(), salt_sv.end());
@@ -51,6 +55,8 @@ MainWindow::MainWindow(QWidget *parent)
m_vault =
std::make_unique<Vault>(path.toStdString(), password.toStdString());
reload_fs_tree();
ui->statusbar->clearMessage();
});
connect(ui->actionOpen, &QAction::triggered, this, [this]() {
@@ -63,12 +69,20 @@ MainWindow::MainWindow(QWidget *parent)
QString password = QInputDialog::getText(
this, "Unlock the vault", "Enter vault password", QLineEdit::Password);
if (password.isEmpty()) {
return;
}
// TODO: check if password valid
ui->statusbar->showMessage("Opening the vault...");
QCoreApplication::processEvents();
m_vault =
std::make_unique<Vault>(path.toStdString(), password.toStdString());
reload_fs_tree();
ui->statusbar->clearMessage();
});
connect(
@@ -95,16 +109,20 @@ MainWindow::MainWindow(QWidget *parent)
}
reload_fs_tree();
ui->statusbar->showMessage("Added " + QString::number(paths.size()) +
" files");
});
}
void MainWindow::reload_fs_tree() {
setWindowTitle(QString::fromStdString(m_vault->path()) + " - dull");
ui->menuFiles->setEnabled(true);
ui->fsTreeWidget->clear();
auto headers = m_vault->read_file_headers();
for (const auto &header : headers) {
auto *item = new QTreeWidgetItem(ui->fsTreeWidget);
item->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon));
item->setText(0, QString::fromStdString(header.name));
item->setText(1, QString::number(header.content_ciphertext_size));
}
@@ -136,6 +154,8 @@ void MainWindow::extract_file(const std::string &filename) {
std::ofstream file(path.toStdString(), std::ios::binary);
file.write(content->data(), static_cast<i64>(content->size()));
ui->statusbar->showMessage("Extracted to " + path);
} else {
qWarning() << "File to extract not found";
}
@@ -166,6 +186,7 @@ void MainWindow::edit_file(const std::string &filename) {
m_vault->update_file(filename, new_content);
reload_fs_tree();
ui->statusbar->showMessage("File updated");
// QTemporaryDir gets deleted when it goes out of scope
} else {
qWarning() << "File to edit not found";
@@ -240,6 +261,8 @@ void MainWindow::dropEvent(QDropEvent *event) {
m_vault->create_file(path_to_filename(u.toLocalFile().toStdString()),
content);
}
ui->statusbar->showMessage(
"Added " + QString::number(event->mimeData()->urls().size()) + " files");
reload_fs_tree();
event->acceptProposedAction();

View File

@@ -40,6 +40,7 @@
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
@@ -69,16 +70,25 @@
<addaction name="menuFiles"/>
</widget>
<action name="actionNew">
<property name="icon">
<iconset theme="document-new"/>
</property>
<property name="text">
<string>New</string>
</property>
</action>
<action name="actionOpen">
<property name="icon">
<iconset theme="document-open"/>
</property>
<property name="text">
<string>Open</string>
</property>
</action>
<action name="actionAddFiles">
<property name="icon">
<iconset theme="list-add"/>
</property>
<property name="text">
<string>Add</string>
</property>

View File

@@ -28,6 +28,8 @@ public:
void delete_file(const std::string &name);
void update_file(const std::string &name, const std::string &content);
const std::string &path() const { return m_path; }
private:
std::string m_path;
std::fstream m_file;