diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-05 00:33:24 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-05 00:33:24 +0200 |
| commit | c0d62ee7beaa0a800e8fbc6edf2d0086ffd3e448 (patch) | |
| tree | 4b27e6e131c18ce6a14d592bcee0b73f7a23b5b8 | |
| parent | 30d8beca2757159b5103be3f231cd3ef03d4f1bb (diff) | |
| download | kristall-c0d62ee7beaa0a800e8fbc6edf2d0086ffd3e448.tar.gz | |
Cleans up UI a bit, adds document margin, adds view enable/disable, adds shitty default style sheet.
| -rw-r--r-- | browsertab.cpp | 53 | ||||
| -rw-r--r-- | browsertab.hpp | 2 | ||||
| -rw-r--r-- | browsertab.ui | 51 | ||||
| -rw-r--r-- | mainwindow.cpp | 4 |
4 files changed, 109 insertions, 1 deletions
diff --git a/browsertab.cpp b/browsertab.cpp index ebeb0a3..48c2593 100644 --- a/browsertab.cpp +++ b/browsertab.cpp @@ -6,6 +6,7 @@ #include <QMenu> #include <QMessageBox> #include <QInputDialog> +#include <QDockWidget> BrowserTab::BrowserTab(MainWindow * mainWindow) : QWidget(nullptr), @@ -26,6 +27,30 @@ BrowserTab::BrowserTab(MainWindow * mainWindow) : connect(&gemini_client, &GeminiClient::certificateRejected, this, &BrowserTab::on_certificateRejected); this->updateUI(); + + this->ui->textBrowser->document()->setDocumentMargin(55.0); + this->ui->textBrowser->document()->setDefaultStyleSheet( + R"css( +h1 { + color: red; +} +h2 { + color: green; +} +h3 { + color: blue; +} +span { + color: lime; +} +a { + color: magenta; +} +ul { + -qt-list-indent: 1; + type: square; +} + )css"); } BrowserTab::~BrowserTab() @@ -58,7 +83,23 @@ void BrowserTab::navigateTo(const QUrl &url) void BrowserTab::on_menu_button_clicked() { QMenu menu; - connect(menu.addAction("Add Tab"), &QAction::triggered, mainWindow, &MainWindow::addEmptyTab); + connect(menu.addAction("Open Empty Tab"), &QAction::triggered, mainWindow, &MainWindow::addEmptyTab); + + QMenu * view_menu = menu.addMenu("View"); + { + QList<QDockWidget *> dockWidgets = mainWindow->findChildren<QDockWidget *>(); + + for(QDockWidget * dock : dockWidgets) + { + QAction * act = view_menu ->addAction(dock->windowTitle()); + act->setCheckable(true); + act->setChecked(dock->isVisible()); + + connect(act, QOverload<bool>::of(&QAction::triggered), dock, &QDockWidget::setVisible); + } + } + + connect(menu.addAction("Quit"), &QAction::triggered, &QApplication::quit); menu.exec(QCursor::pos()); } @@ -99,6 +140,8 @@ void BrowserTab::on_gemini_complete(const QByteArray &data, const QString &mime) { qDebug() << "Loaded" << data.length() << "bytes of type" << mime; + bool enable_styles = false; + if(mime.startsWith("text/gemini")) { auto html = translateGeminiToHtml(data, this->outline); @@ -118,6 +161,7 @@ void BrowserTab::on_gemini_complete(const QByteArray &data, const QString &mime) else { this->ui->textBrowser->setText(QString("Unsupported Mime: %1").arg(mime)); } + this->successfully_loaded = true; this->updateUI(); } @@ -438,3 +482,10 @@ QByteArray BrowserTab::translateGeminiToHtml(const QByteArray &input, DocumentOu return result; } + +#include <QTextBlock> + +void BrowserTab::on_textEdit_textChanged() +{ + this->ui->textBrowser->document()->setDefaultStyleSheet(this->ui->textEdit->toPlainText()); +} diff --git a/browsertab.hpp b/browsertab.hpp index 79bf9c8..7ac3a40 100644 --- a/browsertab.hpp +++ b/browsertab.hpp @@ -71,6 +71,8 @@ private slots: void on_textBrowser_highlighted(const QUrl &arg1); + void on_textEdit_textChanged(); + private: void setErrorMessage(QString const & msg); diff --git a/browsertab.ui b/browsertab.ui index cbd79fe..11a85d8 100644 --- a/browsertab.ui +++ b/browsertab.ui @@ -130,14 +130,65 @@ <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QTextBrowser" name="textBrowser"> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="autoFormatting"> + <set>QTextEdit::AutoNone</set> + </property> <property name="readOnly"> <bool>true</bool> </property> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Start surfin!</p></body></html></string> + </property> + <property name="tabStopWidth"> + <number>40</number> + </property> <property name="openLinks"> <bool>false</bool> </property> </widget> </item> + <item> + <widget class="QTextEdit" name="textEdit"> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#d69545;">body</span><span style=" color:#bec0c2;"> </span><span style=" color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">margin:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">10px;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">-qt-block-indent:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">0;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">/*</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">background-color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">black;</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">*/</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">/*</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">white;</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">*/</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">h1</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">red;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">h2</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">green;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">h3</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">blue;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">span</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">lime;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">a</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">color:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">magenta;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">ul</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">{</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">-qt-list-indent:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">1;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">type:</span><span style=" font-family:'monospace'; color:#bec0c2;"> </span><span style=" font-family:'monospace'; color:#d69545;">square;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace'; color:#d69545;">}</span></p></body></html></string> + </property> + </widget> + </item> </layout> </item> </layout> diff --git a/mainwindow.cpp b/mainwindow.cpp index 75cdeba..7707a2d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,6 +16,10 @@ MainWindow::MainWindow(QWidget *parent) this->favourites.load("./favourites.db"); ui->favourites_view->setModel(&favourites); + + this->ui->history_window->setVisible(false); + this->ui->clientcert_window->setVisible(false); + this->ui->bookmarks_window->setVisible(false); } MainWindow::~MainWindow() |
