aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2021-01-21 21:30:50 +1100
committerFelix Queißner <felix@ib-queissner.de>2021-01-21 13:49:54 +0100
commit17a90d8dde55c5f0adc230c1a78da3dd2f8af995 (patch)
tree6773b5090e669535b7279cefee75f6d231ca4fac /src
parent2091b038ef2a23a85d30d056307b3c405c416256 (diff)
downloadkristall-17a90d8dde55c5f0adc230c1a78da3dd2f8af995.tar.gz
new-tab button: add preference
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/settingsdialog.cpp6
-rw-r--r--src/dialogs/settingsdialog.hpp2
-rw-r--r--src/dialogs/settingsdialog.ui23
-rw-r--r--src/kristall.hpp1
-rw-r--r--src/main.cpp2
-rw-r--r--src/mainwindow.cpp4
-rw-r--r--src/widgets/browsertabbar.cpp22
-rw-r--r--src/widgets/browsertabbar.hpp4
8 files changed, 48 insertions, 16 deletions
diff --git a/src/dialogs/settingsdialog.cpp b/src/dialogs/settingsdialog.cpp
index 0925578..229a728 100644
--- a/src/dialogs/settingsdialog.cpp
+++ b/src/dialogs/settingsdialog.cpp
@@ -250,6 +250,7 @@ void SettingsDialog::setOptions(const GenericSettings &options)
this->ui->network_timeout->setValue(this->current_options.network_timeout);
this->ui->enable_home_btn->setChecked(this->current_options.enable_home_btn);
+ this->ui->enable_newtab_btn->setChecked(this->current_options.enable_newtab_btn);
this->ui->cache_limit->setValue(this->current_options.cache_limit);
this->ui->cache_threshold->setValue(this->current_options.cache_threshold);
@@ -678,6 +679,11 @@ void SettingsDialog::on_enable_home_btn_clicked(bool checked)
this->current_options.enable_home_btn = checked;
}
+void SettingsDialog::on_enable_newtab_btn_clicked(bool checked)
+{
+ this->current_options.enable_newtab_btn = checked;
+}
+
void SettingsDialog::on_cache_limit_valueChanged(int limit)
{
this->current_options.cache_limit = limit;
diff --git a/src/dialogs/settingsdialog.hpp b/src/dialogs/settingsdialog.hpp
index dac7a10..6638583 100644
--- a/src/dialogs/settingsdialog.hpp
+++ b/src/dialogs/settingsdialog.hpp
@@ -132,6 +132,8 @@ private slots:
void on_enable_home_btn_clicked(bool arg1);
+ void on_enable_newtab_btn_clicked(bool arg1);
+
void on_cache_limit_valueChanged(int limit);
void on_cache_threshold_valueChanged(int thres);
diff --git a/src/dialogs/settingsdialog.ui b/src/dialogs/settingsdialog.ui
index 2eb04da..9678166 100644
--- a/src/dialogs/settingsdialog.ui
+++ b/src/dialogs/settingsdialog.ui
@@ -365,13 +365,23 @@
</widget>
</item>
<item row="13" column="1">
- <widget class="QCheckBox" name="enable_home_btn">
- <property name="text">
- <string>Home</string>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_99">
+ <item>
+ <widget class="QCheckBox" name="enable_home_btn">
+ <property name="text">
+ <string>Home</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enable_newtab_btn">
+ <property name="text">
+ <string>New tab</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
-
<item row="14" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
@@ -1075,6 +1085,7 @@
<tabstop>redirection_mode</tabstop>
<tabstop>network_timeout</tabstop>
<tabstop>enable_home_btn</tabstop>
+ <tabstop>enable_newtab_btn</tabstop>
<tabstop>bg_change_color</tabstop>
<tabstop>style_preview</tabstop>
<tabstop>std_change_font</tabstop>
diff --git a/src/kristall.hpp b/src/kristall.hpp
index 8df86a6..67e468c 100644
--- a/src/kristall.hpp
+++ b/src/kristall.hpp
@@ -71,6 +71,7 @@ struct GenericSettings
// Additional toolbar items
bool enable_home_btn = false;
+ bool enable_newtab_btn = true;
// In-memory caching
int cache_limit = 1000;
diff --git a/src/main.cpp b/src/main.cpp
index 19326e2..a20cba4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -368,6 +368,7 @@ void GenericSettings::load(QSettings &settings)
redirection_policy = RedirectionWarning(settings.value("redirection_policy ", WarnOnHostChange).toInt());
enable_home_btn = settings.value("enable_home_btn", false).toBool();
+ enable_newtab_btn = settings.value("enable_newtab_btn", true).toBool();
cache_limit = settings.value("cache_limit", 1000).toInt();
cache_threshold = settings.value("cache_threshold", 125).toInt();
@@ -402,6 +403,7 @@ void GenericSettings::save(QSettings &settings) const
settings.setValue("redirection_policy", int(redirection_policy));
settings.setValue("network_timeout", network_timeout);
settings.setValue("enable_home_btn", enable_home_btn);
+ settings.setValue("enable_newtab_btn", enable_newtab_btn);
settings.setValue("cache_limit", cache_limit);
settings.setValue("cache_threshold", cache_threshold);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 1d9dfb0..d1f27d7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -402,6 +402,10 @@ void MainWindow::on_actionSettings_triggered()
// Re-render the currently-open tab if we have one.
BrowserTab * tab = this->curTab();
if (tab) tab->rerenderPage();
+
+ // Update new-tab button visibility.
+ this->ui->browser_tabs->tab_bar->new_tab_btn
+ ->setVisible(kristall::options.enable_newtab_btn);
}
void MainWindow::on_actionNew_Tab_triggered()
diff --git a/src/widgets/browsertabbar.cpp b/src/widgets/browsertabbar.cpp
index 97fc1a1..541ee96 100644
--- a/src/widgets/browsertabbar.cpp
+++ b/src/widgets/browsertabbar.cpp
@@ -1,4 +1,5 @@
#include "browsertabbar.hpp"
+#include "kristall.hpp"
#include <QMouseEvent>
@@ -9,10 +10,10 @@ static const int NEWTAB_BTN_SIZE = 22,
BrowserTabBar::BrowserTabBar(QWidget *parent) :
QTabBar(parent)
{
- newTabBtn = new QPushButton("+", this);
- newTabBtn->setFixedSize(NEWTAB_BTN_SIZE, NEWTAB_BTN_SIZE);
- connect(newTabBtn, &QPushButton::clicked, this, &BrowserTabBar::on_newTabClicked);
- this->newTabBtn->setVisible(true);
+ new_tab_btn = new QPushButton("+", this);
+ new_tab_btn->setFixedSize(NEWTAB_BTN_SIZE, NEWTAB_BTN_SIZE);
+ connect(new_tab_btn, &QPushButton::clicked, this, &BrowserTabBar::on_newTabClicked);
+ this->new_tab_btn->setVisible(kristall::options.enable_newtab_btn);
}
void BrowserTabBar::mouseReleaseEvent(QMouseEvent *event)
@@ -26,6 +27,11 @@ void BrowserTabBar::mouseReleaseEvent(QMouseEvent *event)
void BrowserTabBar::moveNewTabButton()
{
+ if (!kristall::options.enable_newtab_btn)
+ {
+ return;
+ }
+
// Find width of all tabs
int size = 0;
for (int i = 0; i < this->count(); ++i)
@@ -36,13 +42,13 @@ void BrowserTabBar::moveNewTabButton()
int w = this->width();
if ((size + NEWTAB_BTN_SIZE + NEWTAB_BTN_PAD_X) > w)
{
- this->newTabBtn->setVisible(false);
- //this->newTabBtn->move(w - 54, h + 22 / 4);
+ this->new_tab_btn->setVisible(false);
+ //this->new_tab_btn->move(w - 54, h + 22 / 4);
}
else
{
- this->newTabBtn->setVisible(true);
- this->newTabBtn->move(size + NEWTAB_BTN_PAD_X,
+ this->new_tab_btn->setVisible(true);
+ this->new_tab_btn->move(size + NEWTAB_BTN_PAD_X,
h + NEWTAB_BTN_SIZE / 4);
}
}
diff --git a/src/widgets/browsertabbar.hpp b/src/widgets/browsertabbar.hpp
index 674089b..b5b074b 100644
--- a/src/widgets/browsertabbar.hpp
+++ b/src/widgets/browsertabbar.hpp
@@ -22,8 +22,8 @@ signals:
private:
void moveNewTabButton();
-private:
- QPushButton *newTabBtn;
+public:
+ QPushButton *new_tab_btn;
};
#endif // BROWSERTABS_HPP