bit of ux
This commit is contained in:
2
PKGBUILD
2
PKGBUILD
@@ -8,7 +8,7 @@ depends=('qt6-base' 'botan')
|
|||||||
makedepends=('cmake')
|
makedepends=('cmake')
|
||||||
source=("${url}/archive/refs/tags/${pkgver}.tar.gz")
|
source=("${url}/archive/refs/tags/${pkgver}.tar.gz")
|
||||||
sha256sums=('SKIP')
|
sha256sums=('SKIP')
|
||||||
DEBUGPKG=()
|
options=('!debug')
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd "${pkgname}-${pkgver}"
|
cd "${pkgname}-${pkgver}"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ sudo pacman -S base-devel
|
|||||||
makepkg -si
|
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
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// TODO: actual fs
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
@@ -38,6 +39,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->statusbar->showMessage("Creating the vault...");
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
static Botan::AutoSeeded_RNG rng;
|
static Botan::AutoSeeded_RNG rng;
|
||||||
auto salt_sv = rng.random_vec(16);
|
auto salt_sv = rng.random_vec(16);
|
||||||
std::vector<u8> salt(salt_sv.begin(), salt_sv.end());
|
std::vector<u8> salt(salt_sv.begin(), salt_sv.end());
|
||||||
@@ -51,6 +55,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
m_vault =
|
m_vault =
|
||||||
std::make_unique<Vault>(path.toStdString(), password.toStdString());
|
std::make_unique<Vault>(path.toStdString(), password.toStdString());
|
||||||
reload_fs_tree();
|
reload_fs_tree();
|
||||||
|
|
||||||
|
ui->statusbar->clearMessage();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->actionOpen, &QAction::triggered, this, [this]() {
|
connect(ui->actionOpen, &QAction::triggered, this, [this]() {
|
||||||
@@ -63,12 +69,20 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
QString password = QInputDialog::getText(
|
QString password = QInputDialog::getText(
|
||||||
this, "Unlock the vault", "Enter vault password", QLineEdit::Password);
|
this, "Unlock the vault", "Enter vault password", QLineEdit::Password);
|
||||||
|
if (password.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: check if password valid
|
// TODO: check if password valid
|
||||||
|
|
||||||
|
ui->statusbar->showMessage("Opening the vault...");
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
m_vault =
|
m_vault =
|
||||||
std::make_unique<Vault>(path.toStdString(), password.toStdString());
|
std::make_unique<Vault>(path.toStdString(), password.toStdString());
|
||||||
reload_fs_tree();
|
reload_fs_tree();
|
||||||
|
|
||||||
|
ui->statusbar->clearMessage();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
@@ -95,16 +109,20 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
reload_fs_tree();
|
reload_fs_tree();
|
||||||
|
ui->statusbar->showMessage("Added " + QString::number(paths.size()) +
|
||||||
|
" files");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::reload_fs_tree() {
|
void MainWindow::reload_fs_tree() {
|
||||||
|
setWindowTitle(QString::fromStdString(m_vault->path()) + " - dull");
|
||||||
ui->menuFiles->setEnabled(true);
|
ui->menuFiles->setEnabled(true);
|
||||||
ui->fsTreeWidget->clear();
|
ui->fsTreeWidget->clear();
|
||||||
|
|
||||||
auto headers = m_vault->read_file_headers();
|
auto headers = m_vault->read_file_headers();
|
||||||
for (const auto &header : headers) {
|
for (const auto &header : headers) {
|
||||||
auto *item = new QTreeWidgetItem(ui->fsTreeWidget);
|
auto *item = new QTreeWidgetItem(ui->fsTreeWidget);
|
||||||
|
item->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon));
|
||||||
item->setText(0, QString::fromStdString(header.name));
|
item->setText(0, QString::fromStdString(header.name));
|
||||||
item->setText(1, QString::number(header.content_ciphertext_size));
|
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);
|
std::ofstream file(path.toStdString(), std::ios::binary);
|
||||||
file.write(content->data(), static_cast<i64>(content->size()));
|
file.write(content->data(), static_cast<i64>(content->size()));
|
||||||
|
|
||||||
|
ui->statusbar->showMessage("Extracted to " + path);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "File to extract not found";
|
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);
|
m_vault->update_file(filename, new_content);
|
||||||
reload_fs_tree();
|
reload_fs_tree();
|
||||||
|
|
||||||
|
ui->statusbar->showMessage("File updated");
|
||||||
// QTemporaryDir gets deleted when it goes out of scope
|
// QTemporaryDir gets deleted when it goes out of scope
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "File to edit not found";
|
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()),
|
m_vault->create_file(path_to_filename(u.toLocalFile().toStdString()),
|
||||||
content);
|
content);
|
||||||
}
|
}
|
||||||
|
ui->statusbar->showMessage(
|
||||||
|
"Added " + QString::number(event->mimeData()->urls().size()) + " files");
|
||||||
reload_fs_tree();
|
reload_fs_tree();
|
||||||
|
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
@@ -69,16 +70,25 @@
|
|||||||
<addaction name="menuFiles"/>
|
<addaction name="menuFiles"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionNew">
|
<action name="actionNew">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-new"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>New</string>
|
<string>New</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-open"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open</string>
|
<string>Open</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAddFiles">
|
<action name="actionAddFiles">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="list-add"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public:
|
|||||||
void delete_file(const std::string &name);
|
void delete_file(const std::string &name);
|
||||||
void update_file(const std::string &name, const std::string &content);
|
void update_file(const std::string &name, const std::string &content);
|
||||||
|
|
||||||
|
const std::string &path() const { return m_path; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
std::fstream m_file;
|
std::fstream m_file;
|
||||||
|
|||||||
Reference in New Issue
Block a user