2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-06-26 16:41:20 +02: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>
|
2018-01-10 01:59:55 +01:00
|
|
|
#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;
|
2017-07-23 14:16:13 +02:00
|
|
|
|
2018-04-18 09:12:29 +02:00
|
|
|
class Notebook2 : public BaseWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Notebook2(QWidget *parent);
|
|
|
|
|
|
|
|
NotebookTab2 *addPage(QWidget *page, bool select = false);
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void scaleChangedEvent(float scale) override;
|
|
|
|
virtual void resizeEvent(QResizeEvent *) override;
|
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Item {
|
|
|
|
NotebookTab2 *tab;
|
|
|
|
QWidget *page;
|
|
|
|
};
|
|
|
|
|
|
|
|
QList<Item> items;
|
|
|
|
QWidget *selectedPage = nullptr;
|
|
|
|
|
|
|
|
NotebookButton addButton;
|
|
|
|
|
|
|
|
bool allowUserTabManagement = false;
|
|
|
|
bool showAddButton = false;
|
|
|
|
int lineY = 20;
|
|
|
|
|
|
|
|
void performLayout(bool animate = true);
|
|
|
|
|
|
|
|
NotebookTab2 *getTabFromPage(QWidget *page);
|
|
|
|
};
|
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
class Notebook : public BaseWidget
|
2016-12-29 17:31:07 +01:00
|
|
|
{
|
2017-01-11 18:52:09 +01:00
|
|
|
Q_OBJECT
|
2016-12-29 17:31:07 +01:00
|
|
|
|
|
|
|
public:
|
2018-04-06 23:31:34 +02:00
|
|
|
explicit Notebook(Window *parent, bool _showButtons);
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2018-04-06 23:31:34 +02:00
|
|
|
SplitContainer *addNewPage(bool select = false);
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
void removePage(SplitContainer *page);
|
2018-01-06 20:58:56 +01:00
|
|
|
void removeCurrentPage();
|
2017-11-12 17:21:50 +01:00
|
|
|
void select(SplitContainer *page);
|
2018-01-11 20:16:25 +01:00
|
|
|
void selectIndex(int index);
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2018-04-10 15:59:53 +02:00
|
|
|
SplitContainer *getOrAddSelectedPage();
|
|
|
|
SplitContainer *getSelectedPage();
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-01-26 05:26:21 +01:00
|
|
|
void performLayout(bool animate = true);
|
2016-12-30 18:00:25 +01:00
|
|
|
|
2017-12-14 00:25:06 +01:00
|
|
|
int tabCount();
|
2018-01-22 21:31:45 +01:00
|
|
|
SplitContainer *tabAt(QPoint point, int &index, int maxWidth = 2000000000);
|
2018-04-06 23:31:34 +02:00
|
|
|
SplitContainer *tabAt(int index);
|
2017-11-12 17:21:50 +01:00
|
|
|
void rearrangePage(SplitContainer *page, int index);
|
2017-01-22 12:46:35 +01:00
|
|
|
|
2017-08-13 15:24:41 +02:00
|
|
|
void nextTab();
|
|
|
|
void previousTab();
|
|
|
|
|
2016-12-30 12:20:26 +01:00
|
|
|
protected:
|
2018-01-25 20:49:49 +01:00
|
|
|
void scaleChangedEvent(float scale);
|
2016-12-30 12:20:26 +01:00
|
|
|
void resizeEvent(QResizeEvent *);
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-01-01 18:43:52 +01:00
|
|
|
void settingsButtonMouseReleased(QMouseEvent *event);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void settingsButtonClicked();
|
2017-01-22 05:58:23 +01:00
|
|
|
void usersButtonClicked();
|
|
|
|
void addPageButtonClicked();
|
2017-01-01 18:43:52 +01:00
|
|
|
|
2017-07-23 14:16:13 +02:00
|
|
|
private:
|
2018-01-15 01:35:35 +01:00
|
|
|
Window *parentWindow;
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
QList<SplitContainer *> pages;
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
NotebookButton addButton;
|
|
|
|
NotebookButton settingsButton;
|
|
|
|
NotebookButton userButton;
|
2016-12-30 12:20:26 +01:00
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
SplitContainer *selectedPage = nullptr;
|
|
|
|
|
|
|
|
bool showButtons;
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2018-01-10 01:59:55 +01:00
|
|
|
QMessageBox closeConfirmDialog;
|
2016-12-29 17:31:07 +01:00
|
|
|
};
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|