aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-05 00:33:24 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-05 00:33:24 +0200
commitc0d62ee7beaa0a800e8fbc6edf2d0086ffd3e448 (patch)
tree4b27e6e131c18ce6a14d592bcee0b73f7a23b5b8
parent30d8beca2757159b5103be3f231cd3ef03d4f1bb (diff)
downloadkristall-c0d62ee7beaa0a800e8fbc6edf2d0086ffd3e448.tar.gz
Cleans up UI a bit, adds document margin, adds view enable/disable, adds shitty default style sheet.
-rw-r--r--browsertab.cpp53
-rw-r--r--browsertab.hpp2
-rw-r--r--browsertab.ui51
-rw-r--r--mainwindow.cpp4
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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Start surfin!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; color:#d69545;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;margin:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;10px;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;-qt-block-indent:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;0;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;background-color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;black;&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;*/&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;white;&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;*/&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;red;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;green;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;h3&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;blue;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;span&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;lime;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;color:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;magenta;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;ul&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;-qt-list-indent:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;1;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;type:&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#bec0c2;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;square;&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; color:#d69545;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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()