From 17a90d8dde55c5f0adc230c1a78da3dd2f8af995 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Thu, 21 Jan 2021 21:30:50 +1100 Subject: new-tab button: add preference --- src/widgets/browsertabbar.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/widgets/browsertabbar.cpp') 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 @@ -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); } } -- cgit v1.2.3