classic fourtf commit
|
@ -30,7 +30,11 @@ SOURCES += main.cpp\
|
|||
notebooktab.cpp \
|
||||
notebookpage.cpp \
|
||||
notebookbutton.cpp \
|
||||
colorscheme.cpp
|
||||
colorscheme.cpp \
|
||||
chatwidgetheader.cpp \
|
||||
chatwidgetinput.cpp \
|
||||
chatwidgetview.cpp \
|
||||
notebookpagedroppreview.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
chatwidget.h \
|
||||
|
@ -38,6 +42,13 @@ HEADERS += mainwindow.h \
|
|||
notebooktab.h \
|
||||
notebookpage.h \
|
||||
notebookbutton.h \
|
||||
colorscheme.h
|
||||
colorscheme.h \
|
||||
chatwidgetheader.h \
|
||||
chatwidgetinput.h \
|
||||
chatwidgetview.h \
|
||||
notebookpagedroppreview.h
|
||||
|
||||
FORMS +=
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
|
|
@ -2,25 +2,42 @@
|
|||
#include "QPainter"
|
||||
#include "QFont"
|
||||
#include "QFontDatabase"
|
||||
#include "QVBoxLayout"
|
||||
#include "colorscheme.h"
|
||||
|
||||
ChatWidget::ChatWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
vbox(this)
|
||||
{
|
||||
QFont font("Segoe UI", 15, QFont::Normal, false);
|
||||
this->font = font;
|
||||
vbox.setSpacing(0);
|
||||
vbox.setMargin(1);
|
||||
|
||||
vbox.addWidget(&header);
|
||||
vbox.addWidget(&view);
|
||||
vbox.addWidget(&input);
|
||||
|
||||
// QFont font("Segoe UI", 15, QFont::Normal, false);
|
||||
// this->font = font;
|
||||
}
|
||||
|
||||
ChatWidget::~ChatWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ChatWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter (this);
|
||||
QColor color (255, 0, 0);
|
||||
|
||||
painter.setBrush(color);
|
||||
painter.setPen(color);
|
||||
painter.fillRect(rect(), ColorScheme::getInstance().ChatBackground);
|
||||
|
||||
painter.setFont(this->font);
|
||||
painter.drawRect(5, 10, 10, 5);
|
||||
// QColor color (255, 0, 0);
|
||||
|
||||
QString text = "test text";
|
||||
painter.drawText(20, 20, text);
|
||||
// painter.setPen(color);
|
||||
|
||||
// painter.setFont(this->font);
|
||||
// painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||
|
||||
// QString text = "test text";
|
||||
// painter.drawText(20, 20, text);
|
||||
}
|
||||
|
|
11
chatwidget.h
|
@ -2,20 +2,29 @@
|
|||
#define CHATWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "QVBoxLayout"
|
||||
#include "QFont"
|
||||
#include "chatwidgetheader.h"
|
||||
#include "chatwidgetview.h"
|
||||
#include "chatwidgetinput.h"
|
||||
|
||||
class ChatWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatWidget(QWidget *parent = 0);
|
||||
~ChatWidget();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QFont font;
|
||||
QVBoxLayout vbox;
|
||||
ChatWidgetHeader header;
|
||||
ChatWidgetView view;
|
||||
ChatWidgetInput input;
|
||||
};
|
||||
|
||||
#endif // CHATWIDGET_H
|
||||
|
|
72
chatwidgetheader.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
#include "chatwidgetheader.h"
|
||||
#include "QPainter"
|
||||
#include "colorscheme.h"
|
||||
#include "chatwidget.h"
|
||||
#include "notebookpage.h"
|
||||
#include "QDrag"
|
||||
#include "QMimeData"
|
||||
#include "QByteArray"
|
||||
|
||||
ChatWidgetHeader::ChatWidgetHeader()
|
||||
: QWidget()
|
||||
{
|
||||
setFixedHeight(32);
|
||||
}
|
||||
|
||||
void ChatWidgetHeader::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(rect(), ColorScheme::getInstance().ChatHeaderBackground);
|
||||
painter.setPen(ColorScheme::getInstance().ChatHeaderBorder);
|
||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||
}
|
||||
|
||||
void ChatWidgetHeader::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
dragging = true;
|
||||
|
||||
dragStart = event->pos();
|
||||
}
|
||||
|
||||
void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
if (std::abs(dragStart.x() - event->pos().x()) > 12 ||
|
||||
std::abs(dragStart.y() - event->pos().y()) > 12)
|
||||
{
|
||||
auto chatWidget = getChatWidget();
|
||||
auto page = static_cast<NotebookPage*>(chatWidget->parentWidget());
|
||||
|
||||
if (page != NULL)
|
||||
{
|
||||
NotebookPage::isDraggingSplit = true;
|
||||
NotebookPage::draggingSplit = chatWidget;
|
||||
|
||||
auto originalLocation = page->removeFromLayout(chatWidget);
|
||||
|
||||
QDrag *drag = new QDrag(chatWidget);
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
|
||||
mimeData->setData("chatterino/split", "xD");
|
||||
|
||||
drag->setMimeData(mimeData);
|
||||
|
||||
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
|
||||
|
||||
if (dropAction == Qt::IgnoreAction)
|
||||
{
|
||||
page->addToLayout(chatWidget, originalLocation);
|
||||
}
|
||||
|
||||
NotebookPage::isDraggingSplit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChatWidget* ChatWidgetHeader::getChatWidget()
|
||||
{
|
||||
return static_cast<ChatWidget*>(parentWidget());
|
||||
}
|
29
chatwidgetheader.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef CHATWIDGETHEADER_H
|
||||
#define CHATWIDGETHEADER_H
|
||||
|
||||
#include "QWidget"
|
||||
#include "QPaintEvent"
|
||||
#include "QPoint"
|
||||
#include "QMouseEvent"
|
||||
|
||||
class ChatWidget;
|
||||
|
||||
class ChatWidgetHeader : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatWidgetHeader();
|
||||
ChatWidget* getChatWidget();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
QPoint dragStart;
|
||||
bool dragging = false;
|
||||
};
|
||||
|
||||
#endif // CHATWIDGETHEADER_H
|
17
chatwidgetinput.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "chatwidgetinput.h"
|
||||
#include "colorscheme.h"
|
||||
#include "QPainter"
|
||||
|
||||
ChatWidgetInput::ChatWidgetInput()
|
||||
{
|
||||
setFixedHeight(38);
|
||||
}
|
||||
|
||||
void ChatWidgetInput::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(rect(), ColorScheme::getInstance().ChatInputBackground);
|
||||
painter.setPen(ColorScheme::getInstance().ChatInputBorder);
|
||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||
}
|
18
chatwidgetinput.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef CHATWIDGETINPUT_H
|
||||
#define CHATWIDGETINPUT_H
|
||||
|
||||
#include "QWidget"
|
||||
#include "QPaintEvent"
|
||||
|
||||
class ChatWidgetInput : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatWidgetInput();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
};
|
||||
|
||||
#endif // CHATWIDGETINPUT_H
|
7
chatwidgetview.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "chatwidgetview.h"
|
||||
|
||||
ChatWidgetView::ChatWidgetView()
|
||||
: QWidget()
|
||||
{
|
||||
|
||||
}
|
14
chatwidgetview.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef CHATVIEW_H
|
||||
#define CHATVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ChatWidgetView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatWidgetView();
|
||||
};
|
||||
|
||||
#endif // CHATVIEW_H
|
|
@ -9,12 +9,31 @@ void ColorScheme::setColors(float hue, float multiplyer)
|
|||
|
||||
auto isLightTheme = IsLightTheme;
|
||||
|
||||
auto getColor = [isLightTheme, multiplyer] (qreal h, qreal s, qreal l) -> QColor
|
||||
auto getColor = [isLightTheme, multiplyer] (qreal h, qreal s, qreal l, qreal a = 1.0)
|
||||
{
|
||||
return QColor::fromHslF(h, s, (((l - 0.5) * multiplyer) + 0.5));
|
||||
return QColor::fromHslF(h, s, (((l - 0.5) * multiplyer) + 0.5), a);
|
||||
};
|
||||
|
||||
DropPreviewBackground = getColor(hue, 0.5, 0.5, 0.3);
|
||||
|
||||
TextCaret = IsLightTheme ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
||||
|
||||
// ChatBorder = IsLightTheme ? QColor()
|
||||
// tab
|
||||
TabPanelBackground = QColor(255, 255, 255);
|
||||
TabBackground = QColor(255, 255, 255);
|
||||
TabHoverBackground = getColor(hue, 0, 0.05);
|
||||
TabSelectedBackground = getColor(hue, 0.5, 0.5);
|
||||
TabHighlightedBackground = getColor(hue, 0.5, 0.2);
|
||||
TabNewMessageBackground = QBrush(getColor(hue, 0.5, 0.2), Qt::DiagCrossPattern);
|
||||
TabText = QColor(0, 0, 0);
|
||||
TabHoverText = QColor(0, 0, 0);
|
||||
TabSelectedText = QColor(255, 255, 255);
|
||||
TabHighlightedText = QColor(0, 0, 0);
|
||||
|
||||
// Chat
|
||||
ChatBackground = getColor(0, 0.1, 1);
|
||||
ChatHeaderBackground = getColor(0, 0.1, 0.9);
|
||||
ChatHeaderBorder = getColor(0, 0.1, 0.85);
|
||||
ChatInputBackground = getColor(0, 0.1, 0.95);
|
||||
ChatInputBorder = getColor(0, 0.1, 0.9);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
#define COLORSCHEME_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QBrush>
|
||||
|
||||
class ColorScheme
|
||||
{
|
||||
public:
|
||||
bool IsLightTheme;
|
||||
|
||||
QColor DropPreviewBackground;
|
||||
|
||||
QColor TooltipBackground;
|
||||
QColor TooltipText;
|
||||
QColor ChatSeperator;
|
||||
|
@ -15,9 +18,13 @@ public:
|
|||
QColor ChatBackgroundHighlighted;
|
||||
QColor ChatBackgroundResub;
|
||||
QColor ChatBackgroundWhisper;
|
||||
QColor ChatInputOuter;
|
||||
QColor ChatInputInner;
|
||||
|
||||
QColor ChatHeaderBorder;
|
||||
QColor ChatHeaderBackground;
|
||||
|
||||
QColor ChatInputBackground;
|
||||
QColor ChatInputBorder;
|
||||
|
||||
QColor ChatMessageSeperatorBorder;
|
||||
QColor ChatMessageSeperatorBorderInner;
|
||||
QColor ChatBorder;
|
||||
|
@ -32,12 +39,13 @@ public:
|
|||
QColor ScrollbarThumb;
|
||||
QColor ScrollbarThumbSelected;
|
||||
QColor ScrollbarArrow;
|
||||
QColor TabPanelBG;
|
||||
QColor TabBG;
|
||||
QColor TabHoverBG;
|
||||
QColor TabSelectedBG;
|
||||
QColor TabHighlightedBG;
|
||||
QColor TabNewMessageBG;
|
||||
|
||||
QColor TabPanelBackground;
|
||||
QColor TabBackground;
|
||||
QColor TabHoverBackground;
|
||||
QColor TabSelectedBackground;
|
||||
QColor TabHighlightedBackground;
|
||||
QBrush TabNewMessageBackground;
|
||||
QColor TabText;
|
||||
QColor TabHoverText;
|
||||
QColor TabSelectedText;
|
||||
|
|
BIN
images/AppearanceEditorPart_16x.png
Normal file
After Width: | Height: | Size: 347 B |
BIN
images/BrowserLink_16x.png
Normal file
After Width: | Height: | Size: 680 B |
BIN
images/CopyLongTextToClipboard_16x.png
Normal file
After Width: | Height: | Size: 403 B |
BIN
images/CustomActionEditor_16x.png
Normal file
After Width: | Height: | Size: 368 B |
BIN
images/Emoji_Color_1F60A_19.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
images/Filter_16x.png
Normal file
After Width: | Height: | Size: 280 B |
BIN
images/Message_16xLG.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
images/cheer1.png
Normal file
After Width: | Height: | Size: 255 B |
BIN
images/cheer100.png
Normal file
After Width: | Height: | Size: 360 B |
BIN
images/cheer1000.png
Normal file
After Width: | Height: | Size: 351 B |
BIN
images/cheer10000.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
images/cheer100000.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
images/cheer5000.png
Normal file
After Width: | Height: | Size: 362 B |
BIN
images/format_Bold_16xLG.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
images/settings.png
Normal file
After Width: | Height: | Size: 274 B |
BIN
images/tool_moreCollapser_off16.png
Normal file
After Width: | Height: | Size: 292 B |
BIN
images/twitchprime_bg.png
Normal file
After Width: | Height: | Size: 116 B |
2
main.cpp
|
@ -6,7 +6,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
//ColorScheme::makeScheme(0, -0.8);
|
||||
ColorScheme::getInstance().setColors(0, -0.8);
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <QPalette>
|
||||
#include "mainwindow.h"
|
||||
#include "chatwidget.h"
|
||||
#include "notebook.h"
|
||||
#include "colorscheme.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -11,6 +13,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
this->notebook.addPage();
|
||||
this->notebook.addPage();
|
||||
this->notebook.addPage();
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, ColorScheme::getInstance().TabPanelBackground);
|
||||
setPalette(palette);
|
||||
|
||||
resize(1280, 800);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
|
17
notebook.cpp
|
@ -6,6 +6,7 @@
|
|||
#include "notebookpage.h"
|
||||
#include "notebookbutton.h"
|
||||
#include "QFormLayout"
|
||||
#include "colorscheme.h"
|
||||
|
||||
Notebook::Notebook(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
@ -24,7 +25,7 @@ Notebook::Notebook(QWidget *parent)
|
|||
NotebookPage* Notebook::addPage()
|
||||
{
|
||||
auto tab = new NotebookTab(this);
|
||||
auto page = new NotebookPage(tab);
|
||||
auto page = new NotebookPage(this, tab);
|
||||
|
||||
if (pages.count() == 0)
|
||||
{
|
||||
|
@ -38,18 +39,20 @@ NotebookPage* Notebook::addPage()
|
|||
|
||||
void Notebook::select(NotebookPage* page)
|
||||
{
|
||||
if (selected != nullptr)
|
||||
{
|
||||
selected->setParent(nullptr);
|
||||
selected->tab->setSelected(false);
|
||||
}
|
||||
if (page == selected) return;
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->setParent(this);
|
||||
page->setHidden(false);
|
||||
page->tab->setSelected(true);
|
||||
}
|
||||
|
||||
if (selected != nullptr)
|
||||
{
|
||||
selected->setHidden(true);
|
||||
selected->tab->setSelected(false);
|
||||
}
|
||||
|
||||
selected = page;
|
||||
|
||||
performLayout();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "notebookbutton.h"
|
||||
#include "QPainter"
|
||||
#include "QPainterPath"
|
||||
#include "colorscheme.h"
|
||||
|
||||
NotebookButton::NotebookButton(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
@ -14,22 +16,25 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
QColor background;
|
||||
QColor foreground;
|
||||
|
||||
auto colorScheme = ColorScheme::getInstance();
|
||||
|
||||
if (mouseDown)
|
||||
{
|
||||
foreground = QColor(0, 0, 0);
|
||||
background = QColor(255, 255, 255);
|
||||
background = colorScheme.TabSelectedBackground;
|
||||
foreground = colorScheme.TabSelectedText;
|
||||
}
|
||||
else if (mouseOver)
|
||||
{
|
||||
foreground = QColor(255, 255, 255);
|
||||
background = QColor(0, 0, 0);
|
||||
background = colorScheme.TabHoverBackground;
|
||||
foreground = colorScheme.TabSelectedBackground;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreground = QColor(0, 0, 0);
|
||||
background = QColor(255, 255, 255);
|
||||
background = colorScheme.TabPanelBackground;
|
||||
foreground = colorScheme.TabSelectedBackground;
|
||||
}
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.fillRect(this->rect(), background);
|
||||
|
||||
float h = this->height(), w = this->width();
|
||||
|
@ -41,11 +46,43 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
}
|
||||
else if (icon == IconUser)
|
||||
{
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
|
||||
auto a = w/8;
|
||||
QPainterPath path;
|
||||
|
||||
path.arcMoveTo(a, 4 * a, 6 * a, 6 * a, 0);
|
||||
path.arcTo(a, 4 * a, 6 * a, 6 * a, 0, 180);
|
||||
|
||||
painter.fillPath(path, foreground);
|
||||
|
||||
painter.setBrush(background);
|
||||
painter.drawEllipse(2*a, 1*a, 4*a, 4*a);
|
||||
|
||||
painter.setBrush(foreground);
|
||||
painter.drawEllipse(2.5*a, 1.5*a, 3*a + 1, 3*a);
|
||||
}
|
||||
else // IconSettings
|
||||
{
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
|
||||
auto a = w/8;
|
||||
QPainterPath path;
|
||||
|
||||
path.arcMoveTo(a, a, 6*a, 6*a, 0 - (360 / 32.0));
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
path.arcTo(a, a, 6*a, 6*a, i * (360 / 8.0) - (360 / 32.0), (360 / 32.0));
|
||||
path.arcTo(2*a, 2*a, 4*a, 4*a, i * (360 / 8.0) + (360 / 32.0), (360 / 32.0));
|
||||
}
|
||||
|
||||
painter.fillPath(path, foreground);
|
||||
|
||||
painter.setBrush(background);
|
||||
painter.drawEllipse(3*a, 3*a, 2*a, 2*a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ class NotebookButton : public QWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
static const int IconPlus = 0;
|
||||
static const int IconUser = 0;
|
||||
static const int IconSettings = 0;
|
||||
static const int IconUser = 1;
|
||||
static const int IconSettings = 2;
|
||||
|
||||
int icon = 0;
|
||||
|
||||
|
|
188
notebookpage.cpp
|
@ -1,20 +1,200 @@
|
|||
#include "QWidget"
|
||||
#include "QPainter"
|
||||
#include "QHBoxLayout"
|
||||
#include "QVBoxLayout"
|
||||
#include "QMimeData"
|
||||
#include "notebookpage.h"
|
||||
#include "notebooktab.h"
|
||||
#include "colorscheme.h"
|
||||
#include "chatwidget.h"
|
||||
|
||||
NotebookPage::NotebookPage(NotebookTab *tab)
|
||||
bool NotebookPage::isDraggingSplit = false;
|
||||
ChatWidget* NotebookPage::draggingSplit = NULL;
|
||||
std::pair<int, int> NotebookPage::dropPosition = std::pair<int, int>(-1, -1);
|
||||
|
||||
NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
|
||||
: QWidget(parent),
|
||||
parentbox(this),
|
||||
preview(this)
|
||||
{
|
||||
this->tab = tab;
|
||||
tab->page = this;
|
||||
|
||||
setHidden(true);
|
||||
setAcceptDrops(true);
|
||||
|
||||
parentbox.addSpacing(2);
|
||||
parentbox.addLayout(&hbox);
|
||||
parentbox.setMargin(0);
|
||||
|
||||
hbox.setSpacing(1);
|
||||
hbox.setMargin(0);
|
||||
|
||||
QVBoxLayout* vbox = new QVBoxLayout();
|
||||
vbox->addWidget(new ChatWidget());
|
||||
vbox->addWidget(new ChatWidget());
|
||||
vbox->addWidget(new ChatWidget());
|
||||
|
||||
hbox.addLayout(vbox);
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addWidget(new ChatWidget());
|
||||
|
||||
hbox.addLayout(vbox);
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addWidget(new ChatWidget());
|
||||
vbox->addWidget(new ChatWidget());
|
||||
|
||||
hbox.addLayout(vbox);
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
vbox->addWidget(new ChatWidget());
|
||||
vbox->addWidget(new ChatWidget());
|
||||
|
||||
hbox.addLayout(vbox);
|
||||
}
|
||||
|
||||
std::pair<int, int> NotebookPage::removeFromLayout(ChatWidget *widget)
|
||||
{
|
||||
for (int i = 0; i < hbox.count(); ++i)
|
||||
{
|
||||
auto vbox = static_cast<QVBoxLayout*>(hbox.itemAt(i));
|
||||
|
||||
for (int j = 0; j < vbox->count(); ++j)
|
||||
{
|
||||
if (vbox->itemAt(j)->widget() != widget) continue;
|
||||
|
||||
widget->setParent(NULL);
|
||||
|
||||
bool isLastItem = vbox->count() == 0;
|
||||
|
||||
if (isLastItem)
|
||||
{
|
||||
hbox.removeItem(vbox);
|
||||
|
||||
delete vbox;
|
||||
}
|
||||
|
||||
return std::pair<int, int>(i, isLastItem ? -1 : j);;
|
||||
}
|
||||
}
|
||||
|
||||
return std::pair<int, int>(-1, -1);
|
||||
}
|
||||
|
||||
void NotebookPage::addToLayout(ChatWidget *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1))
|
||||
{
|
||||
// add vbox at the end
|
||||
if (position.first < 0 || position.first >= hbox.count())
|
||||
{
|
||||
auto vbox = new QVBoxLayout();
|
||||
vbox->addWidget(widget);
|
||||
|
||||
hbox.addLayout(vbox);
|
||||
return;
|
||||
}
|
||||
|
||||
// insert vbox
|
||||
if (position.second == -1)
|
||||
{
|
||||
auto vbox = new QVBoxLayout();
|
||||
vbox->addWidget(widget);
|
||||
|
||||
hbox.insertLayout(position.first, vbox);
|
||||
return;
|
||||
}
|
||||
|
||||
// add to existing vbox
|
||||
auto vbox = static_cast<QVBoxLayout*>(hbox.itemAt(position.first));
|
||||
|
||||
vbox->insertWidget(std::max(0, std::min(vbox->count(), position.second)), widget);
|
||||
}
|
||||
|
||||
void NotebookPage::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("chatterino/split")) return;
|
||||
|
||||
if (isDraggingSplit)
|
||||
{
|
||||
dropRegions.clear();
|
||||
|
||||
for (int i = 0; i < hbox.count() + 1; ++i)
|
||||
{
|
||||
dropRegions.push_back(DropRegion(QRect(((i*4 - 1) * width() / hbox.count()) / 4, 0, width()/hbox.count()/2, height()), std::pair<int, int>(i, -1)));
|
||||
}
|
||||
|
||||
for (int i = 0; i < hbox.count(); ++i)
|
||||
{
|
||||
auto vbox = static_cast<QVBoxLayout*>(hbox.itemAt(i));
|
||||
|
||||
for (int j = 0; j < vbox->count() + 1; ++j)
|
||||
{
|
||||
dropRegions.push_back(DropRegion(QRect(i*width()/hbox.count(), ((j*2 - 1) * height() / vbox->count()) / 2, width()/hbox.count(), height()/vbox->count()), std::pair<int, int>(i, j)));
|
||||
}
|
||||
}
|
||||
|
||||
setPreviewRect(event->pos());
|
||||
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void NotebookPage::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
setPreviewRect(event->pos());
|
||||
}
|
||||
|
||||
void NotebookPage::setPreviewRect(QPoint mousePos)
|
||||
{
|
||||
for (DropRegion region : dropRegions)
|
||||
{
|
||||
if (region.rect.contains(mousePos))
|
||||
{
|
||||
preview.move(region.rect.x(), region.rect.y());
|
||||
preview.resize(region.rect.width(), region.rect.height());
|
||||
preview.show();
|
||||
preview.raise();
|
||||
|
||||
dropPosition = region.position;
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
preview.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NotebookPage::dragLeaveEvent(QDragLeaveEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NotebookPage::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (isDraggingSplit)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
|
||||
NotebookPage::draggingSplit->setParent(this);
|
||||
|
||||
addToLayout(NotebookPage::draggingSplit, dropPosition);
|
||||
}
|
||||
|
||||
preview.hide();
|
||||
}
|
||||
|
||||
void NotebookPage::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.setPen(QColor(255, 0, 0));
|
||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||
// painter.fillRect(rect(), ColorScheme::getInstance().ChatBackground);
|
||||
|
||||
painter.drawText(8, 8, QString::number(tab->x()));
|
||||
// painter.fillRect(0, 0, width(), 2, ColorScheme::getInstance().TabSelectedBackground);
|
||||
|
||||
painter.fillRect(rect(), ColorScheme::getInstance().TabSelectedBackground);
|
||||
|
||||
painter.fillRect(0, 0, width(), 2, ColorScheme::getInstance().TabSelectedBackground);
|
||||
}
|
||||
|
|
|
@ -2,19 +2,59 @@
|
|||
#define NOTEBOOKPAGE_H
|
||||
|
||||
#include "QWidget"
|
||||
#include "QRect"
|
||||
#include "QVector"
|
||||
#include "QHBoxLayout"
|
||||
#include "QVBoxLayout"
|
||||
#include "QDragEnterEvent"
|
||||
#include "notebookpage.h"
|
||||
#include "notebooktab.h"
|
||||
#include "chatwidget.h"
|
||||
#include "notebookpagedroppreview.h"
|
||||
|
||||
class NotebookPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NotebookPage(NotebookTab *tab);
|
||||
NotebookPage(QWidget *parent, NotebookTab *tab);
|
||||
NotebookTab* tab;
|
||||
QVBoxLayout parentbox;
|
||||
QHBoxLayout hbox;
|
||||
|
||||
std::pair<int, int> removeFromLayout(ChatWidget* widget);
|
||||
void addToLayout(ChatWidget* widget, std::pair<int, int> position);
|
||||
|
||||
static bool isDraggingSplit;
|
||||
static ChatWidget* draggingSplit;
|
||||
static std::pair<int, int> dropPosition;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
|
||||
void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
|
||||
void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
|
||||
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
struct DropRegion
|
||||
{
|
||||
QRect rect;
|
||||
std::pair<int, int> position;
|
||||
|
||||
DropRegion(QRect rect, std::pair<int, int> position)
|
||||
{
|
||||
this->rect = rect;
|
||||
this->position = position;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<DropRegion> dropRegions;
|
||||
|
||||
NotebookPageDropPreview preview;
|
||||
|
||||
private:
|
||||
void setPreviewRect(QPoint mousePos);
|
||||
};
|
||||
|
||||
#endif // NOTEBOOKPAGE_H
|
||||
|
|
16
notebookpagedroppreview.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include "notebookpagedroppreview.h"
|
||||
#include "QPainter"
|
||||
#include "colorscheme.h"
|
||||
|
||||
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent = 0)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(rect(), ColorScheme::getInstance().DropPreviewBackground);
|
||||
}
|
15
notebookpagedroppreview.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef NOTEBOOKPAGEDROPPREVIEW_H
|
||||
#define NOTEBOOKPAGEDROPPREVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class NotebookPageDropPreview : public QWidget
|
||||
{
|
||||
public:
|
||||
NotebookPageDropPreview(QWidget *parent);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
};
|
||||
|
||||
#endif // NOTEBOOKPAGEDROPPREVIEW_H
|
|
@ -1,6 +1,7 @@
|
|||
#include <QPainter>
|
||||
#include "notebook.h"
|
||||
#include "notebooktab.h"
|
||||
#include "QPainter"
|
||||
#include "colorscheme.h"
|
||||
|
||||
NotebookTab::NotebookTab(Notebook *notebook)
|
||||
: QWidget(notebook)
|
||||
|
@ -9,6 +10,19 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||
text = "<no title>";
|
||||
|
||||
calcSize();
|
||||
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
int NotebookTab::getHighlightStyle()
|
||||
{
|
||||
return highlightStyle;
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightStyle(int style)
|
||||
{
|
||||
highlightStyle = style;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void NotebookTab::setSelected(bool value)
|
||||
|
@ -31,35 +45,35 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
|||
{
|
||||
QPainter painter(this);
|
||||
|
||||
QColor bg = QColor(255, 255, 255), fg = QColor(0, 0, 0);
|
||||
QColor fg = QColor(0, 0, 0);
|
||||
|
||||
// if (selected)
|
||||
// {
|
||||
// bg = App.ColorScheme.TabSelectedBG;
|
||||
// text = App.ColorScheme.TabSelectedText;
|
||||
// }
|
||||
// else if (mouseOver)
|
||||
// {
|
||||
// bg = App.ColorScheme.TabHoverBG;
|
||||
// text = App.ColorScheme.TabHoverText;
|
||||
// }
|
||||
// else if ()
|
||||
// {
|
||||
// bg = App.ColorScheme.TabHighlightedBG;
|
||||
// text = App.ColorScheme.TabHighlightedText;
|
||||
// }
|
||||
// else if ()
|
||||
// {
|
||||
// bg = App.ColorScheme.TabNewMessageBG;
|
||||
// text = App.ColorScheme.TabHighlightedText;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// bg = App.ColorScheme.TabBG;
|
||||
// text = App.ColorScheme.TabText;
|
||||
// }
|
||||
auto colorScheme = ColorScheme::getInstance();
|
||||
|
||||
painter.fillRect(rect(), bg);
|
||||
if (selected)
|
||||
{
|
||||
painter.fillRect(rect(), colorScheme.TabSelectedBackground);
|
||||
fg = colorScheme.TabSelectedText;
|
||||
}
|
||||
else if (mouseOver)
|
||||
{
|
||||
painter.fillRect(rect(), colorScheme.TabHoverBackground);
|
||||
fg = colorScheme.TabHoverText;
|
||||
}
|
||||
else if (highlightStyle == HighlightHighlighted)
|
||||
{
|
||||
painter.fillRect(rect(), colorScheme.TabHighlightedBackground);
|
||||
fg = colorScheme.TabHighlightedText;
|
||||
}
|
||||
else if (highlightStyle == HighlightNewMessage)
|
||||
{
|
||||
painter.fillRect(rect(), colorScheme.TabNewMessageBackground);
|
||||
fg = colorScheme.TabHighlightedText;
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.fillRect(rect(), colorScheme.TabBackground);
|
||||
fg = colorScheme.TabText;
|
||||
}
|
||||
|
||||
painter.setPen(fg);
|
||||
painter.drawText(4, (height() + fontMetrics().height()) / 2, text);
|
||||
|
@ -70,6 +84,8 @@ void NotebookTab::mousePressEvent(QMouseEvent *)
|
|||
mouseDown = true;
|
||||
|
||||
repaint();
|
||||
|
||||
notebook->select(page);
|
||||
}
|
||||
|
||||
void NotebookTab::mouseReleaseEvent(QMouseEvent *)
|
||||
|
@ -77,8 +93,6 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *)
|
|||
mouseDown = false;
|
||||
|
||||
repaint();
|
||||
|
||||
notebook->select(page);
|
||||
}
|
||||
|
||||
void NotebookTab::enterEvent(QEvent *)
|
||||
|
@ -94,3 +108,8 @@ void NotebookTab::leaveEvent(QEvent *)
|
|||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void NotebookTab::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
notebook->select(page);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,13 @@ public:
|
|||
bool getSelected();
|
||||
void setSelected(bool value);
|
||||
|
||||
int getHighlightStyle();
|
||||
void setHighlightStyle(int style);
|
||||
|
||||
static const int HighlightNone = 0;
|
||||
static const int HighlightHighlighted = 1;
|
||||
static const int HighlightNewMessage = 2;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -29,12 +36,15 @@ protected:
|
|||
void enterEvent(QEvent *) Q_DECL_OVERRIDE;
|
||||
void leaveEvent(QEvent *) Q_DECL_OVERRIDE;
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Notebook *notebook;
|
||||
bool selected = false;
|
||||
|
||||
bool mouseOver = false;
|
||||
bool mouseDown = false;
|
||||
int highlightStyle;
|
||||
};
|
||||
|
||||
#endif // NOTEBOOKTAB_H
|
||||
|
|
21
resources.qrc
Normal file
|
@ -0,0 +1,21 @@
|
|||
<RCC>
|
||||
<qresource prefix="/images">
|
||||
<file>images/AppearanceEditorPart_16x.png</file>
|
||||
<file>images/BrowserLink_16x.png</file>
|
||||
<file>images/cheer1.png</file>
|
||||
<file>images/cheer100.png</file>
|
||||
<file>images/cheer1000.png</file>
|
||||
<file>images/cheer5000.png</file>
|
||||
<file>images/cheer10000.png</file>
|
||||
<file>images/cheer100000.png</file>
|
||||
<file>images/CopyLongTextToClipboard_16x.png</file>
|
||||
<file>images/CustomActionEditor_16x.png</file>
|
||||
<file>images/Emoji_Color_1F60A_19.png</file>
|
||||
<file>images/Filter_16x.png</file>
|
||||
<file>images/format_Bold_16xLG.png</file>
|
||||
<file>images/Message_16xLG.png</file>
|
||||
<file>images/settings.png</file>
|
||||
<file>images/tool_moreCollapser_off16.png</file>
|
||||
<file>images/twitchprime_bg.png</file>
|
||||
</qresource>
|
||||
</RCC>
|