From cbc17bd39f4ef245183e5a54509ff3fbd4125ca6 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sat, 6 Jun 2020 21:45:41 +0200 Subject: Fixes bug in outline generation, adds application icon to mainwindow, adds more README, adds save settings on closing settings dialog. --- README.md | 34 +++++++++++++++++++++++++++++++++- browsertab.cpp | 3 ++- documentoutlinemodel.cpp | 33 ++++++++++++++++++++++++--------- documentoutlinemodel.hpp | 4 +++- icons.qrc | 1 + icons/kristall.svg | 13 +++++++++++++ mainwindow.cpp | 8 ++++++-- mainwindow.hpp | 2 ++ mainwindow.ui | 4 ++++ 9 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 icons/kristall.svg diff --git a/README.md b/README.md index 0158600..3e1b697 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A high-quality visual cross-platform gemini browser. - `text/markdown` - `text/*` - `image/*` -- Outline generation +- [Outline generation](https://mq32.de/public/d3cdeb38c55ce8100a631bbf761e7bc17b6806bb.png) - Favourite Sites - Tabbed interface - Survives [ConMans torture suite](gemini://gemini.conman.org/test/torture/) @@ -24,6 +24,38 @@ A high-quality visual cross-platform gemini browser. - Windows - FreeBSD - NetBSD + - OpenBSD + +## Screenshots + +### Generates Outlines + +![Outline Generation](https://mq32.de/public/d3cdeb38c55ce8100a631bbf761e7bc17b6806bb.png) + +### Fully Customizable Site Theme + +![Site Theme](https://mq32.de/public/7123e22a58969448c27b24df8510f4d56921bf23.png) + +## Build Instructions + +### Requirements + +- Latest Qt5 version with `widgets` and `network` modules + +### Build + +The usual Qt5 build process: + +```sh +mkdir build +cd build +qmake ../kristall.pro +make +``` + +Notes for OpenBSD: +- It seems like Qt wants `libzstd.so.3.1` instead of `libzstd.so.3.2`. Just symlink that file into the build directory +- Use `make` and not `gmake` to build the project. ## TODO - [ ] Survive full torture suite diff --git a/browsertab.cpp b/browsertab.cpp index dd8b3a7..6543c86 100644 --- a/browsertab.cpp +++ b/browsertab.cpp @@ -130,6 +130,8 @@ void BrowserTab::on_menu_button_clicked() if(dialog.exec() == QDialog::Accepted) { mainWindow->current_style = dialog.geminiStyle(); + + mainWindow->saveSettings(); } }); @@ -361,7 +363,6 @@ void BrowserTab::setErrorMessage(const QString &msg) void BrowserTab::pushToHistory(const QUrl &url) { - qDebug() << "push to history" << this->current_history_index << url; this->current_history_index = this->history.pushUrl(this->current_history_index, url); this->updateUI(); } diff --git a/documentoutlinemodel.cpp b/documentoutlinemodel.cpp index b44ceff..a47dafa 100644 --- a/documentoutlinemodel.cpp +++ b/documentoutlinemodel.cpp @@ -22,8 +22,8 @@ void DocumentOutlineModel::beginBuild() root = Node { nullptr, "", - 0, - QVector { }, + 0, 0, + QList { }, }; } @@ -32,8 +32,8 @@ void DocumentOutlineModel::appendH1(const QString &title) root.children.append(Node { &root, title, - 1, - QVector { }, + 1, 0, + QList { }, }); } @@ -43,16 +43,16 @@ void DocumentOutlineModel::appendH2(const QString &title) root.children.append(Node { &root, "", - 1, - QVector { }, + 1, 0, + QList { }, }); } auto & parent = root.children.last(); parent.children.append(Node { &parent, title, - 2, - QVector { }, + 2, parent.children.size() - 1, + QList { }, }); } @@ -63,6 +63,21 @@ void DocumentOutlineModel::appendH3(const QString &title) void DocumentOutlineModel::endBuild() { + for(auto const & h1 : this->root.children) + { + assert(h1.depth == 1); + assert(h1.parent == &this->root); + for(auto const & h2 : h1.children) + { + assert(h2.depth == 2); + assert(h2.parent == &h1); + for(auto const & h3 : h2.children) + { + assert(h3.depth == 3); + assert(h3.parent == &h2); + } + } + } endResetModel(); } @@ -97,7 +112,7 @@ QModelIndex DocumentOutlineModel::parent(const QModelIndex &child) const return QModelIndex(); return createIndex( - parent - parent->parent->children.data(), + parent->index, 0, reinterpret_cast(parent)); } diff --git a/documentoutlinemodel.hpp b/documentoutlinemodel.hpp index e10163b..2161c42 100644 --- a/documentoutlinemodel.hpp +++ b/documentoutlinemodel.hpp @@ -2,6 +2,7 @@ #define DOCUMENTOUTLINEMODEL_HPP #include +#include class DocumentOutlineModel : public QAbstractItemModel @@ -39,7 +40,8 @@ private: Node * parent; QString title; int depth = 0; - QVector children; + int index = 0; + QList children; }; Node root; diff --git a/icons.qrc b/icons.qrc index 9987a28..5b6b051 100644 --- a/icons.qrc +++ b/icons.qrc @@ -9,5 +9,6 @@ icons/close.svg icons/format-font.svg icons/palette.svg + icons/kristall.svg diff --git a/icons/kristall.svg b/icons/kristall.svg new file mode 100644 index 0000000..60be0f6 --- /dev/null +++ b/icons/kristall.svg @@ -0,0 +1,13 @@ + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 0010dba..3682891 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -41,8 +41,7 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { - this->favourites.save(settings); - this->current_style.save(settings); + this->saveSettings(); delete ui; } @@ -82,6 +81,11 @@ void MainWindow::setUrlPreview(const QUrl &url) } } +void MainWindow::saveSettings() +{ + this->favourites.save(settings); + this->current_style.save(settings); +} void MainWindow::on_browser_tabs_currentChanged(int index) { diff --git a/mainwindow.hpp b/mainwindow.hpp index 2e5d954..648f643 100644 --- a/mainwindow.hpp +++ b/mainwindow.hpp @@ -28,6 +28,8 @@ public: void setUrlPreview(QUrl const & url); + void saveSettings(); + public: FavouriteCollection favourites; diff --git a/mainwindow.ui b/mainwindow.ui index 652857a..04e6940 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -13,6 +13,10 @@ Kristall Browser + + + :/icons/kristall.svg:/icons/kristall.svg + QTabWidget::Rounded -- cgit v1.2.3