mirror-chatterino2/src/widgets/notebook.hpp

86 lines
1.9 KiB
C++
Raw Normal View History

#pragma once
2016-12-29 17:31:07 +01:00
#include "widgets/basewidget.hpp"
2017-11-12 17:21:50 +01:00
#include "widgets/helper/notebookbutton.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/splitcontainer.hpp"
2016-12-29 17:31:07 +01:00
2017-01-18 04:52:47 +01:00
#include <QList>
#include <QMessageBox>
2017-01-18 04:52:47 +01:00
#include <QWidget>
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace widgets {
2017-01-18 21:30:23 +01:00
2017-11-12 17:21:50 +01:00
class Window;
2018-04-18 09:12:29 +02:00
class Notebook2 : public BaseWidget
{
Q_OBJECT
public:
explicit Notebook2(QWidget *parent);
NotebookTab2 *addPage(QWidget *page, QString title = QString(), bool select = false);
2018-04-18 09:12:29 +02:00
void removePage(QWidget *page);
void removeCurrentPage();
int indexOf(QWidget *page) const;
void select(QWidget *page);
void selectIndex(int index);
void selectNextTab();
void selectPreviousTab();
int getPageCount() const;
2018-05-23 04:22:17 +02:00
QWidget *getPageAt(int index) const;
2018-04-18 09:12:29 +02:00
int getSelectedIndex() const;
QWidget *getSelectedPage() const;
QWidget *tabAt(QPoint point, int &index, int maxWidth = 2000000000);
void rearrangePage(QWidget *page, int index);
bool getAllowUserTabManagement() const;
void setAllowUserTabManagement(bool value);
bool getShowAddButton() const;
void setShowAddButton(bool value);
2018-05-23 04:22:17 +02:00
void performLayout(bool animate = true);
2018-04-18 09:12:29 +02:00
protected:
virtual void scaleChangedEvent(float scale) override;
virtual void resizeEvent(QResizeEvent *) override;
virtual void paintEvent(QPaintEvent *) override;
2018-05-23 04:22:17 +02:00
NotebookButton *getAddButton();
2018-04-18 09:12:29 +02:00
private:
struct Item {
NotebookTab2 *tab;
QWidget *page;
};
QList<Item> items;
QWidget *selectedPage = nullptr;
NotebookButton addButton;
bool allowUserTabManagement = false;
bool showAddButton = false;
int lineY = 20;
NotebookTab2 *getTabFromPage(QWidget *page);
};
2018-05-23 04:22:17 +02:00
class SplitNotebook : public Notebook2
2016-12-29 17:31:07 +01:00
{
public:
2018-05-23 04:22:17 +02:00
SplitNotebook(QWidget *parent);
2018-05-23 04:22:17 +02:00
SplitContainer *addPage(bool select = false);
2018-04-10 15:59:53 +02:00
SplitContainer *getOrAddSelectedPage();
2016-12-29 17:31:07 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace widgets
} // namespace chatterino