chore: use DrawnButton instead of NotebookButton (#6371)
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
#include "singletons/StreamerMode.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "widgets/buttons/DrawnButton.hpp"
|
||||
#include "widgets/buttons/InitUpdateButton.hpp"
|
||||
#include "widgets/buttons/NotebookButton.hpp"
|
||||
#include "widgets/buttons/PixmapButton.hpp"
|
||||
#include "widgets/buttons/SvgButton.hpp"
|
||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
@@ -38,9 +38,35 @@ namespace chatterino {
|
||||
|
||||
Notebook::Notebook(QWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
, addButton_(new NotebookButton(NotebookButton::Type::Plus, this))
|
||||
, addButton_(new DrawnButton(DrawnButton::Symbol::Plus,
|
||||
{
|
||||
.padding = 6,
|
||||
.thickness = 1,
|
||||
},
|
||||
this))
|
||||
{
|
||||
this->addButton_->setHidden(true);
|
||||
this->addButton_->enableDrops({"chatterino/split"});
|
||||
|
||||
QObject::connect(
|
||||
this->addButton_, &Button::dropEvent, this, [this](QDropEvent *event) {
|
||||
auto *draggedSplit = dynamic_cast<Split *>(event->source());
|
||||
if (!draggedSplit)
|
||||
{
|
||||
qCDebug(chatterinoWidget) << "Dropped something that wasn't a "
|
||||
"split onto a notebook button";
|
||||
return;
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
auto *page = new SplitContainer(this);
|
||||
auto *tab = this->addPage(page);
|
||||
page->setTab(tab);
|
||||
|
||||
draggedSplit->setParent(page);
|
||||
page->insertSplit(draggedSplit);
|
||||
});
|
||||
|
||||
this->lockNotebookLayoutAction_ = new QAction("Lock Tab Layout", this);
|
||||
|
||||
@@ -673,6 +699,8 @@ void Notebook::setShowAddButton(bool value)
|
||||
this->showAddButton_ = value;
|
||||
|
||||
this->addButton_->setHidden(!value);
|
||||
|
||||
this->refresh();
|
||||
}
|
||||
|
||||
void Notebook::resizeAddButton()
|
||||
@@ -1157,11 +1185,6 @@ void Notebook::addNotebookActionsToMenu(QMenu *menu)
|
||||
menu->addAction(this->toggleTopMostAction_);
|
||||
}
|
||||
|
||||
NotebookButton *Notebook::getAddButton()
|
||||
{
|
||||
return this->addButton_;
|
||||
}
|
||||
|
||||
NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
||||
{
|
||||
for (auto &it : this->items_)
|
||||
@@ -1222,7 +1245,7 @@ bool Notebook::shouldShowTab(const NotebookTab *tab) const
|
||||
SplitNotebook::SplitNotebook(Window *parent)
|
||||
: Notebook(parent)
|
||||
{
|
||||
this->connect(this->getAddButton(), &NotebookButton::leftClicked, [this]() {
|
||||
QObject::connect(this->addButton_, &Button::leftClicked, [this]() {
|
||||
QTimer::singleShot(80, this, [this] {
|
||||
this->addPage(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user