aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-06 20:57:56 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-06 20:57:56 +0200
commiteb283439a68dfb70a075205859d891dca831626b (patch)
treeb54923af31c8e05e804b36860ef9bb968f1aee99
parent304bed8a1f567e7ba247d19ecbeeecd40833db04 (diff)
downloadkristall-eb283439a68dfb70a075205859d891dca831626b.tar.gz
Improves navigation with hotkeys, adds sane default theme, adds page margin settings.
-rw-r--r--README.md8
-rw-r--r--browsertab.cpp27
-rw-r--r--browsertab.hpp4
-rw-r--r--geminirenderer.cpp59
-rw-r--r--mainwindow.cpp18
-rw-r--r--mainwindow.hpp4
-rw-r--r--settingsdialog.cpp8
-rw-r--r--settingsdialog.hpp2
-rw-r--r--settingsdialog.ui24
-rw-r--r--tabbrowsinghistory.cpp18
-rw-r--r--tabbrowsinghistory.hpp4
11 files changed, 136 insertions, 40 deletions
diff --git a/README.md b/README.md
index ad6fbcc..0158600 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ A high-quality visual cross-platform gemini browser.
- Color Themes
- Custom color theme
- Automatic light/dark theme based on the host name
+- Navigation history
- Crossplatform supports
- Linux
- Windows
@@ -30,11 +31,10 @@ A high-quality visual cross-platform gemini browser.
- [ ] Correctly parse charset (0013, 0014)
- [ ] Correctly parse other params (0015)
- [ ] Correctly parse undefined params (0016)
-- [ ] Add history navigation
- - [ ] "also, being able to click and load a url from the history pane"
- - [ ] "Couldn't you just have an array of URLs? And when they go forward, you slice the array up to the that point and add the new url to the end"
- [ ] Recognize home directories with /~home and such and add "substyles"
- [ ] Add favicon support
- [ ] Add auto-generated "favicons"
- [ ] Check if the site follows this guideline: `#<ICON> Title` where `<ICON>` is a unicode emoji
- - [ ] Opt-In: Regularly check for `domain/favicon.ico` \ No newline at end of file
+ - [ ] Opt-In: Regularly check for `domain/favicon.ico`
+- [ ] Theming
+ - [ ] Fix default theme when not found.
diff --git a/browsertab.cpp b/browsertab.cpp
index dc374c1..dd8b3a7 100644
--- a/browsertab.cpp
+++ b/browsertab.cpp
@@ -94,6 +94,16 @@ void BrowserTab::navigateBack(QModelIndex history_index)
}
}
+void BrowserTab::navOneBackback()
+{
+ navigateBack(history.oneBackward(current_history_index));
+}
+
+void BrowserTab::navOneForward()
+{
+ navigateBack(history.oneForward(current_history_index));
+}
+
void BrowserTab::on_menu_button_clicked()
{
QMenu menu;
@@ -130,7 +140,13 @@ void BrowserTab::on_menu_button_clicked()
void BrowserTab::on_url_bar_returnPressed()
{
- this->navigateTo(this->ui->url_bar->text(), PushImmediate);
+ QUrl url { this->ui->url_bar->text() };
+
+ if(url.scheme().isEmpty()) {
+ url = QUrl { "gemini://" + this->ui->url_bar->text() };
+ }
+
+ this->navigateTo(url, PushImmediate);
}
void BrowserTab::on_refresh_button_clicked()
@@ -391,21 +407,20 @@ void BrowserTab::on_stop_button_clicked()
gemini_client.cancelRequest();
}
-
void BrowserTab::on_back_button_clicked()
{
- navigateBack(current_history_index.sibling(-1, 0));
+ navOneBackback();
}
void BrowserTab::on_forward_button_clicked()
{
- navigateBack(current_history_index.sibling(1, 0));
+ navOneForward();
}
void BrowserTab::updateUI()
{
- this->ui->back_button->setEnabled(current_history_index.sibling(-1, 0).isValid());
- this->ui->forward_button->setEnabled(current_history_index.sibling(1, 0).isValid());
+ this->ui->back_button->setEnabled(history.oneBackward(current_history_index).isValid());
+ this->ui->forward_button->setEnabled(history.oneForward(current_history_index).isValid());
this->ui->refresh_button->setVisible(this->successfully_loaded);
this->ui->stop_button->setVisible(not this->successfully_loaded);
diff --git a/browsertab.hpp b/browsertab.hpp
index 3bbcd31..7e05995 100644
--- a/browsertab.hpp
+++ b/browsertab.hpp
@@ -35,6 +35,10 @@ public:
void navigateBack(QModelIndex history_index);
+ void navOneBackback();
+
+ void navOneForward();
+
signals:
void titleChanged(QString const & title);
void locationChanged(QUrl const & url);
diff --git a/geminirenderer.cpp b/geminirenderer.cpp
index 5adeedb..51565e2 100644
--- a/geminirenderer.cpp
+++ b/geminirenderer.cpp
@@ -27,15 +27,15 @@ GeminiStyle::GeminiStyle() : theme(Fixed),
h2_font(),
h3_font(),
preformatted_font(),
- background_color(0xFF, 0xFF, 0xFF),
+ background_color("#edefff"),
standard_color(0x00, 0x00, 0x00),
preformatted_color(0x00, 0x00, 0x00),
- h1_color(0xFF, 0x00, 0x00),
- h2_color(0x00, 0x80, 0x00),
- h3_color(0x80, 0xFF, 0x00),
- internal_link_color(0x00, 0x80, 0x0FF),
- external_link_color(0x00, 0x00, 0xFF),
- cross_scheme_link_color(0x80, 0x00, 0xFF),
+ h1_color("#022f90"),
+ h2_color("#022f90"),
+ h3_color("#022f90"),
+ internal_link_color("#0e8fff"),
+ external_link_color("#0e8fff"),
+ cross_scheme_link_color("#0960a7"),
internal_link_prefix("→ "),
external_link_prefix("⇒ "),
margin(55.0)
@@ -93,27 +93,30 @@ bool GeminiStyle::load(QSettings &settings)
{
settings.beginGroup("Theme");
- standard_font.fromString(settings.value("standard_font").toString());
- h1_font.fromString(settings.value("h1_font").toString());
- h2_font.fromString(settings.value("h2_font").toString());
- h3_font.fromString(settings.value("h3_font").toString());
- preformatted_font.fromString(settings.value("preformatted_font").toString());
-
- background_color = QColor(settings.value("background_color").toString());
- standard_color = QColor(settings.value("standard_color").toString());
- preformatted_color = QColor(settings.value("preformatted_color").toString());
- h1_color = QColor(settings.value("h1_color").toString());
- h2_color = QColor(settings.value("h2_color").toString());
- h3_color = QColor(settings.value("h3_color").toString());
- internal_link_color = QColor(settings.value("internal_link_color").toString());
- external_link_color = QColor(settings.value("external_link_color").toString());
- cross_scheme_link_color = QColor(settings.value("cross_scheme_link_color").toString());
-
- internal_link_prefix = settings.value("internal_link_prefix").toString();
- external_link_prefix = settings.value("external_link_prefix").toString();
-
- margin = settings.value("margins").toDouble();
- theme = Theme(settings.value("theme").toInt());
+ if(settings.contains("standard_color"))
+ {
+ standard_font.fromString(settings.value("standard_font").toString());
+ h1_font.fromString(settings.value("h1_font").toString());
+ h2_font.fromString(settings.value("h2_font").toString());
+ h3_font.fromString(settings.value("h3_font").toString());
+ preformatted_font.fromString(settings.value("preformatted_font").toString());
+
+ background_color = QColor(settings.value("background_color").toString());
+ standard_color = QColor(settings.value("standard_color").toString());
+ preformatted_color = QColor(settings.value("preformatted_color").toString());
+ h1_color = QColor(settings.value("h1_color").toString());
+ h2_color = QColor(settings.value("h2_color").toString());
+ h3_color = QColor(settings.value("h3_color").toString());
+ internal_link_color = QColor(settings.value("internal_link_color").toString());
+ external_link_color = QColor(settings.value("external_link_color").toString());
+ cross_scheme_link_color = QColor(settings.value("cross_scheme_link_color").toString());
+
+ internal_link_prefix = settings.value("internal_link_prefix").toString();
+ external_link_prefix = settings.value("external_link_prefix").toString();
+
+ margin = settings.value("margins").toDouble();
+ theme = Theme(settings.value("theme").toInt());
+ }
settings.endGroup();
return true;
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 4cab251..0010dba 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -35,6 +35,8 @@ MainWindow::MainWindow(QWidget *parent) :
add_shortcut("Ctrl+T", &MainWindow::on_new_tab);
add_shortcut("Ctrl+W", &MainWindow::on_close_tab);
add_shortcut("F5", &MainWindow::on_refresh);
+ add_shortcut("Alt+Left", &MainWindow::on_nav_back);
+ add_shortcut("Alt+Right", &MainWindow::on_nav_forward);
}
MainWindow::~MainWindow()
@@ -161,3 +163,19 @@ void MainWindow::on_close_tab()
delete tab;
}
}
+
+void MainWindow::on_nav_back()
+{
+ BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget());
+ if(tab != nullptr) {
+ tab->navOneBackback();
+ }
+}
+
+void MainWindow::on_nav_forward()
+{
+ BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget());
+ if(tab != nullptr) {
+ tab->navOneForward();
+ }
+}
diff --git a/mainwindow.hpp b/mainwindow.hpp
index 78ead7e..2e5d954 100644
--- a/mainwindow.hpp
+++ b/mainwindow.hpp
@@ -50,6 +50,10 @@ private slots:
void on_close_tab();
+ void on_nav_back();
+
+ void on_nav_forward();
+
public:
QSettings settings;
GeminiStyle current_style;
diff --git a/settingsdialog.cpp b/settingsdialog.cpp
index e100c91..2078e7c 100644
--- a/settingsdialog.cpp
+++ b/settingsdialog.cpp
@@ -54,6 +54,8 @@ void SettingsDialog::setGeminiStyle(const GeminiStyle &style)
this->ui->auto_theme->setCurrentIndex(this->current_style.theme);
+ this->ui->page_margin->setValue(this->current_style.margin);
+
auto setFontAndColor = [this](QLabel * label, QFont font, QColor color)
{
label->setText(formatFont(font));
@@ -245,3 +247,9 @@ void SettingsDialog::on_preview_url_textChanged(const QString &arg1)
{
this->reloadStylePreview();
}
+
+void SettingsDialog::on_page_margin_valueChanged(double value)
+{
+ this->current_style.margin = value;
+ this->reloadStylePreview();
+}
diff --git a/settingsdialog.hpp b/settingsdialog.hpp
index c86b737..5f56961 100644
--- a/settingsdialog.hpp
+++ b/settingsdialog.hpp
@@ -60,6 +60,8 @@ private slots:
void on_preview_url_textChanged(const QString &arg1);
+ void on_page_margin_valueChanged(double arg1);
+
private:
void reloadStylePreview();
diff --git a/settingsdialog.ui b/settingsdialog.ui
index e3953fc..d30b049 100644
--- a/settingsdialog.ui
+++ b/settingsdialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
- <height>480</height>
+ <height>520</height>
</rect>
</property>
<property name="windowTitle">
@@ -34,7 +34,7 @@
<item>
<widget class="QLabel" name="bg_preview">
<property name="text">
- <string> </string>
+ <string/>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
@@ -416,6 +416,26 @@
<item row="11" column="1">
<widget class="QComboBox" name="auto_theme"/>
</item>
+ <item row="12" column="0">
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Page Margin</string>
+ </property>
+ </widget>
+ </item>
+ <item row="12" column="1">
+ <widget class="QDoubleSpinBox" name="page_margin">
+ <property name="suffix">
+ <string> px</string>
+ </property>
+ <property name="decimals">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <double>350.000000000000000</double>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
diff --git a/tabbrowsinghistory.cpp b/tabbrowsinghistory.cpp
index 289d529..435bca7 100644
--- a/tabbrowsinghistory.cpp
+++ b/tabbrowsinghistory.cpp
@@ -41,6 +41,24 @@ QUrl TabBrowsingHistory::get(const QModelIndex &index) const
return history.at(index.row());
}
+QModelIndex TabBrowsingHistory::oneForward(QModelIndex index) const
+{
+ if(not index.isValid())
+ return QModelIndex{};
+ if(index.row() >= history.size() - 1)
+ return QModelIndex{};
+ return createIndex(index.row() + 1, index.column());
+}
+
+QModelIndex TabBrowsingHistory::oneBackward(QModelIndex index) const
+{
+ if(not index.isValid())
+ return QModelIndex{};
+ if(index.row() == 0)
+ return QModelIndex{};
+ return createIndex(index.row() - 1, index.column());
+}
+
int TabBrowsingHistory::rowCount(const QModelIndex &parent) const
{
return history.size();
diff --git a/tabbrowsinghistory.hpp b/tabbrowsinghistory.hpp
index b15a701..4305218 100644
--- a/tabbrowsinghistory.hpp
+++ b/tabbrowsinghistory.hpp
@@ -20,6 +20,10 @@ public:
QUrl get(QModelIndex const & index) const;
+ QModelIndex oneForward(QModelIndex index) const;
+
+ QModelIndex oneBackward(QModelIndex index) const;
+
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;