added settings for modifying tabs

This commit is contained in:
fourtf
2017-02-02 02:46:33 +01:00
parent 43cf7620ae
commit 5390272279
8 changed files with 59 additions and 28 deletions
+2
View File
@@ -48,6 +48,8 @@ Settings::Settings()
, inlineWhispers(this->settingsItems, "inlineWhispers", true) , inlineWhispers(this->settingsItems, "inlineWhispers", true)
, windowTopMost(this->settingsItems, "windowTopMost", false) , windowTopMost(this->settingsItems, "windowTopMost", false)
, hideTabX(this->settingsItems, "hideTabX", false) , hideTabX(this->settingsItems, "hideTabX", false)
, hidePreferencesButton(this->settingsItems, "hidePreferencesButton", false)
, hideUserButton(this->settingsItems, "hideUserButton", false)
{ {
this->showTimestamps.valueChanged.connect( this->showTimestamps.valueChanged.connect(
[this](const auto &) { this->updateWordTypeMask(); }); [this](const auto &) { this->updateWordTypeMask(); });
+2
View File
@@ -108,6 +108,8 @@ public:
Setting<bool> inlineWhispers; Setting<bool> inlineWhispers;
Setting<bool> windowTopMost; Setting<bool> windowTopMost;
Setting<bool> hideTabX; Setting<bool> hideTabX;
Setting<bool> hidePreferencesButton;
Setting<bool> hideUserButton;
}; };
} // namespace chatterino } // namespace chatterino
+20 -1
View File
@@ -39,6 +39,11 @@ Notebook::Notebook(QWidget *parent)
this->userButton.icon = NotebookButton::IconUser; this->userButton.icon = NotebookButton::IconUser;
this->addButton.resize(24, 24); 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 * NotebookPage *
@@ -140,7 +145,21 @@ Notebook::rearrangePage(NotebookPage *page, int index)
void void
Notebook::performLayout(bool animated) 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; int tabHeight = 16;
bool first = true; bool first = true;
+3 -2
View File
@@ -76,8 +76,9 @@ NotebookPage::removeFromLayout(ChatWidget *widget)
} }
void void
NotebookPage::addToLayout(ChatWidget *widget, std::pair<int, int> position = NotebookPage::addToLayout(
std::pair<int, int>(-1, -1)) ChatWidget *widget,
std::pair<int, int> position = std::pair<int, int>(-1, -1))
{ {
this->chatWidgets.push_back(widget); this->chatWidgets.push_back(widget);
+1
View File
@@ -13,6 +13,7 @@
#include <QVector> #include <QVector>
#include <QWidget> #include <QWidget>
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree.hpp>
#include <boost/signals2.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
+11 -17
View File
@@ -27,25 +27,16 @@ NotebookTab::NotebookTab(Notebook *notebook)
posAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic)); posAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
/* XXX(pajlada): Fix this this->hideXConnection =
QObject::connect(&Settings::getInstance().getHideTabX(), Settings::getInstance().hideTabX.valueChanged.connect(
&BoolSetting::valueChanged, this, boost::bind(&NotebookTab::hideTabXChanged, this, _1));
&NotebookTab::hideTabXChanged);
*/
// Settings::getInstance().hideTabX.valueChanged.connect(
// boost::bind(&NotebookTab::hideTabXChanged, this));
this->setMouseTracking(true); this->setMouseTracking(true);
} }
NotebookTab::~NotebookTab() NotebookTab::~NotebookTab()
{ {
/* XXX(pajlada): Fix this this->hideXConnection.disconnect();
QObject::disconnect(&Settings::getInstance().getHideTabX(),
&BoolSetting::valueChanged, this,
&NotebookTab::hideTabXChanged);
*/
} }
void void
@@ -56,13 +47,15 @@ NotebookTab::calcSize()
} else { } else {
this->resize(this->fontMetrics().width(this->title) + 8 + 24, 24); this->resize(this->fontMetrics().width(this->title) + 8 + 24, 24);
} }
if (this->parent() != nullptr) {
((Notebook *)this->parent())->performLayout(true);
}
} }
void void
NotebookTab::moveAnimated(QPoint pos, bool animated) NotebookTab::moveAnimated(QPoint pos, bool animated)
{ {
// move(pos);
posAnimationDesired = pos; posAnimationDesired = pos;
if ((this->window() != NULL && !this->window()->isVisible()) || !animated || if ((this->window() != NULL && !this->window()->isVisible()) || !animated ||
@@ -151,7 +144,8 @@ NotebookTab::mouseReleaseEvent(QMouseEvent *event)
{ {
this->mouseDown = false; 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->mouseDownX = false;
this->notebook->removePage(this->page); this->notebook->removePage(this->page);
@@ -188,7 +182,7 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
bool overX = this->getXRect().contains(event->pos()); bool overX = this->getXRect().contains(event->pos());
if (overX != this->mouseOverX) { if (overX != this->mouseOverX) {
this->mouseOverX = overX; this->mouseOverX = overX && !Settings::getInstance().hideTabX.get();
this->update(); this->update();
} }
+11 -8
View File
@@ -4,6 +4,8 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QWidget> #include <QWidget>
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree.hpp>
#include <boost/signals2.hpp>
#include <boost/signals2/connection.hpp>
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
@@ -76,6 +78,13 @@ public:
return QRect(posAnimationDesired, this->size()); return QRect(posAnimationDesired, this->size());
} }
void
hideTabXChanged(bool)
{
calcSize();
update();
}
protected: protected:
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
@@ -89,6 +98,8 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
private: private:
boost::signals2::connection hideXConnection;
QPropertyAnimation posAnimation; QPropertyAnimation posAnimation;
bool posAnimated; bool posAnimated;
QPoint posAnimationDesired; QPoint posAnimationDesired;
@@ -111,14 +122,6 @@ private:
return QRect(this->width() - 20, 4, 16, 16); return QRect(this->width() - 20, 4, 16, 16);
} }
private slots:
void
hideTabXChanged(bool)
{
calcSize();
update();
}
public: public:
void load(const boost::property_tree::ptree &tree); void load(const boost::property_tree::ptree &tree);
boost::property_tree::ptree save(); boost::property_tree::ptree save();
+9
View File
@@ -76,10 +76,19 @@ SettingsDialog::addTabs()
auto combo = new QComboBox(); auto combo = new QComboBox();
auto slider = new QSlider(Qt::Horizontal); auto slider = new QSlider(Qt::Horizontal);
auto font = new QPushButton("select"); 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:", combo);
form->addRow("Theme color:", slider); form->addRow("Theme color:", slider);
form->addRow("Font:", font); form->addRow("Font:", font);
form->addRow("", compactTabs);
form->addRow("", hidePreferencesButton);
form->addRow("", hideUserButton);
// theme // theme
combo->addItem("White"); combo->addItem("White");