mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added settings for modifying tabs
This commit is contained in:
parent
43cf7620ae
commit
5390272279
|
@ -48,6 +48,8 @@ Settings::Settings()
|
|||
, inlineWhispers(this->settingsItems, "inlineWhispers", true)
|
||||
, windowTopMost(this->settingsItems, "windowTopMost", false)
|
||||
, hideTabX(this->settingsItems, "hideTabX", false)
|
||||
, hidePreferencesButton(this->settingsItems, "hidePreferencesButton", false)
|
||||
, hideUserButton(this->settingsItems, "hideUserButton", false)
|
||||
{
|
||||
this->showTimestamps.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
|
|
|
@ -108,6 +108,8 @@ public:
|
|||
Setting<bool> inlineWhispers;
|
||||
Setting<bool> windowTopMost;
|
||||
Setting<bool> hideTabX;
|
||||
Setting<bool> hidePreferencesButton;
|
||||
Setting<bool> hideUserButton;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -39,6 +39,11 @@ Notebook::Notebook(QWidget *parent)
|
|||
this->userButton.icon = NotebookButton::IconUser;
|
||||
|
||||
this->addButton.resize(24, 24);
|
||||
|
||||
Settings::getInstance().hidePreferencesButton.valueChanged.connect(
|
||||
[this](const bool &) { this->performLayout(); });
|
||||
Settings::getInstance().hideUserButton.valueChanged.connect(
|
||||
[this](const bool &) { this->performLayout(); });
|
||||
}
|
||||
|
||||
NotebookPage *
|
||||
|
@ -140,7 +145,21 @@ Notebook::rearrangePage(NotebookPage *page, int index)
|
|||
void
|
||||
Notebook::performLayout(bool animated)
|
||||
{
|
||||
int x = 48, y = 0;
|
||||
int x = 0, y = 0;
|
||||
|
||||
if (Settings::getInstance().hidePreferencesButton.get()) {
|
||||
settingsButton.hide();
|
||||
} else {
|
||||
settingsButton.show();
|
||||
x += 24;
|
||||
}
|
||||
if (Settings::getInstance().hideUserButton.get()) {
|
||||
userButton.hide();
|
||||
} else {
|
||||
userButton.show();
|
||||
x += 24;
|
||||
}
|
||||
|
||||
int tabHeight = 16;
|
||||
bool first = true;
|
||||
|
||||
|
|
|
@ -76,8 +76,9 @@ NotebookPage::removeFromLayout(ChatWidget *widget)
|
|||
}
|
||||
|
||||
void
|
||||
NotebookPage::addToLayout(ChatWidget *widget, std::pair<int, int> position =
|
||||
std::pair<int, int>(-1, -1))
|
||||
NotebookPage::addToLayout(
|
||||
ChatWidget *widget,
|
||||
std::pair<int, int> position = std::pair<int, int>(-1, -1))
|
||||
{
|
||||
this->chatWidgets.push_back(widget);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QVector>
|
||||
#include <QWidget>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
|
|
@ -27,25 +27,16 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||
|
||||
posAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||
|
||||
/* XXX(pajlada): Fix this
|
||||
QObject::connect(&Settings::getInstance().getHideTabX(),
|
||||
&BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
*/
|
||||
|
||||
// Settings::getInstance().hideTabX.valueChanged.connect(
|
||||
// boost::bind(&NotebookTab::hideTabXChanged, this));
|
||||
this->hideXConnection =
|
||||
Settings::getInstance().hideTabX.valueChanged.connect(
|
||||
boost::bind(&NotebookTab::hideTabXChanged, this, _1));
|
||||
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
NotebookTab::~NotebookTab()
|
||||
{
|
||||
/* XXX(pajlada): Fix this
|
||||
QObject::disconnect(&Settings::getInstance().getHideTabX(),
|
||||
&BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
*/
|
||||
this->hideXConnection.disconnect();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -56,13 +47,15 @@ NotebookTab::calcSize()
|
|||
} else {
|
||||
this->resize(this->fontMetrics().width(this->title) + 8 + 24, 24);
|
||||
}
|
||||
|
||||
if (this->parent() != nullptr) {
|
||||
((Notebook *)this->parent())->performLayout(true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::moveAnimated(QPoint pos, bool animated)
|
||||
{
|
||||
// move(pos);
|
||||
|
||||
posAnimationDesired = pos;
|
||||
|
||||
if ((this->window() != NULL && !this->window()->isVisible()) || !animated ||
|
||||
|
@ -151,7 +144,8 @@ NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
|||
{
|
||||
this->mouseDown = false;
|
||||
|
||||
if (this->mouseDownX && this->getXRect().contains(event->pos())) {
|
||||
if (!Settings::getInstance().hideTabX.get() && this->mouseDownX &&
|
||||
this->getXRect().contains(event->pos())) {
|
||||
this->mouseDownX = false;
|
||||
|
||||
this->notebook->removePage(this->page);
|
||||
|
@ -188,7 +182,7 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
|||
bool overX = this->getXRect().contains(event->pos());
|
||||
|
||||
if (overX != this->mouseOverX) {
|
||||
this->mouseOverX = overX;
|
||||
this->mouseOverX = overX && !Settings::getInstance().hideTabX.get();
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <QPropertyAnimation>
|
||||
#include <QWidget>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
#include <boost/signals2/connection.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
@ -76,6 +78,13 @@ public:
|
|||
return QRect(posAnimationDesired, this->size());
|
||||
}
|
||||
|
||||
void
|
||||
hideTabXChanged(bool)
|
||||
{
|
||||
calcSize();
|
||||
update();
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
|
@ -89,6 +98,8 @@ protected:
|
|||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
boost::signals2::connection hideXConnection;
|
||||
|
||||
QPropertyAnimation posAnimation;
|
||||
bool posAnimated;
|
||||
QPoint posAnimationDesired;
|
||||
|
@ -111,14 +122,6 @@ private:
|
|||
return QRect(this->width() - 20, 4, 16, 16);
|
||||
}
|
||||
|
||||
private slots:
|
||||
void
|
||||
hideTabXChanged(bool)
|
||||
{
|
||||
calcSize();
|
||||
update();
|
||||
}
|
||||
|
||||
public:
|
||||
void load(const boost::property_tree::ptree &tree);
|
||||
boost::property_tree::ptree save();
|
||||
|
|
|
@ -76,10 +76,19 @@ SettingsDialog::addTabs()
|
|||
auto combo = new QComboBox();
|
||||
auto slider = new QSlider(Qt::Horizontal);
|
||||
auto font = new QPushButton("select");
|
||||
auto compactTabs = createCheckbox("Hide tab X", settings.hideTabX);
|
||||
auto hidePreferencesButton =
|
||||
createCheckbox("Hide preferences button (ctrl+p to show)",
|
||||
settings.hidePreferencesButton);
|
||||
auto hideUserButton =
|
||||
createCheckbox("Hide user button", settings.hideUserButton);
|
||||
|
||||
form->addRow("Theme:", combo);
|
||||
form->addRow("Theme color:", slider);
|
||||
form->addRow("Font:", font);
|
||||
form->addRow("", compactTabs);
|
||||
form->addRow("", hidePreferencesButton);
|
||||
form->addRow("", hideUserButton);
|
||||
|
||||
// theme
|
||||
combo->addItem("White");
|
||||
|
|
Loading…
Reference in a new issue