diff --git a/chatterino.pro b/chatterino.pro index dd764331..ebe0a296 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -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 diff --git a/chatwidget.cpp b/chatwidget.cpp index 6f36e4b8..3d308d4b 100644 --- a/chatwidget.cpp +++ b/chatwidget.cpp @@ -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); } diff --git a/chatwidget.h b/chatwidget.h index 382dd50e..f53e7e7b 100644 --- a/chatwidget.h +++ b/chatwidget.h @@ -2,20 +2,29 @@ #define CHATWIDGET_H #include - +#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 diff --git a/chatwidgetheader.cpp b/chatwidgetheader.cpp new file mode 100644 index 00000000..6d32676e --- /dev/null +++ b/chatwidgetheader.cpp @@ -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(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(parentWidget()); +} diff --git a/chatwidgetheader.h b/chatwidgetheader.h new file mode 100644 index 00000000..d9dc5b76 --- /dev/null +++ b/chatwidgetheader.h @@ -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 diff --git a/chatwidgetinput.cpp b/chatwidgetinput.cpp new file mode 100644 index 00000000..3923c013 --- /dev/null +++ b/chatwidgetinput.cpp @@ -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); +} diff --git a/chatwidgetinput.h b/chatwidgetinput.h new file mode 100644 index 00000000..621baa70 --- /dev/null +++ b/chatwidgetinput.h @@ -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 diff --git a/chatwidgetview.cpp b/chatwidgetview.cpp new file mode 100644 index 00000000..e874276c --- /dev/null +++ b/chatwidgetview.cpp @@ -0,0 +1,7 @@ +#include "chatwidgetview.h" + +ChatWidgetView::ChatWidgetView() + : QWidget() +{ + +} diff --git a/chatwidgetview.h b/chatwidgetview.h new file mode 100644 index 00000000..b270c499 --- /dev/null +++ b/chatwidgetview.h @@ -0,0 +1,14 @@ +#ifndef CHATVIEW_H +#define CHATVIEW_H + +#include + +class ChatWidgetView : public QWidget +{ + Q_OBJECT + +public: + ChatWidgetView(); +}; + +#endif // CHATVIEW_H diff --git a/colorscheme.cpp b/colorscheme.cpp index aee91a01..fa4ff7f4 100644 --- a/colorscheme.cpp +++ b/colorscheme.cpp @@ -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); } diff --git a/colorscheme.h b/colorscheme.h index 6114c3c6..d828399f 100644 --- a/colorscheme.h +++ b/colorscheme.h @@ -2,12 +2,15 @@ #define COLORSCHEME_H #include +#include 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; diff --git a/images/AppearanceEditorPart_16x.png b/images/AppearanceEditorPart_16x.png new file mode 100644 index 00000000..86c59f7f Binary files /dev/null and b/images/AppearanceEditorPart_16x.png differ diff --git a/images/BrowserLink_16x.png b/images/BrowserLink_16x.png new file mode 100644 index 00000000..bafb9d4e Binary files /dev/null and b/images/BrowserLink_16x.png differ diff --git a/images/CopyLongTextToClipboard_16x.png b/images/CopyLongTextToClipboard_16x.png new file mode 100644 index 00000000..774ee97f Binary files /dev/null and b/images/CopyLongTextToClipboard_16x.png differ diff --git a/images/CustomActionEditor_16x.png b/images/CustomActionEditor_16x.png new file mode 100644 index 00000000..b7b68a21 Binary files /dev/null and b/images/CustomActionEditor_16x.png differ diff --git a/images/Emoji_Color_1F60A_19.png b/images/Emoji_Color_1F60A_19.png new file mode 100644 index 00000000..81d296bf Binary files /dev/null and b/images/Emoji_Color_1F60A_19.png differ diff --git a/images/Filter_16x.png b/images/Filter_16x.png new file mode 100644 index 00000000..f946e63c Binary files /dev/null and b/images/Filter_16x.png differ diff --git a/images/Message_16xLG.png b/images/Message_16xLG.png new file mode 100644 index 00000000..7d06b199 Binary files /dev/null and b/images/Message_16xLG.png differ diff --git a/images/cheer1.png b/images/cheer1.png new file mode 100644 index 00000000..f1ed9fd2 Binary files /dev/null and b/images/cheer1.png differ diff --git a/images/cheer100.png b/images/cheer100.png new file mode 100644 index 00000000..30199804 Binary files /dev/null and b/images/cheer100.png differ diff --git a/images/cheer1000.png b/images/cheer1000.png new file mode 100644 index 00000000..d6c0ed04 Binary files /dev/null and b/images/cheer1000.png differ diff --git a/images/cheer10000.png b/images/cheer10000.png new file mode 100644 index 00000000..3e3eb428 Binary files /dev/null and b/images/cheer10000.png differ diff --git a/images/cheer100000.png b/images/cheer100000.png new file mode 100644 index 00000000..c20e956b Binary files /dev/null and b/images/cheer100000.png differ diff --git a/images/cheer5000.png b/images/cheer5000.png new file mode 100644 index 00000000..89a7a401 Binary files /dev/null and b/images/cheer5000.png differ diff --git a/images/format_Bold_16xLG.png b/images/format_Bold_16xLG.png new file mode 100644 index 00000000..e636bb0d Binary files /dev/null and b/images/format_Bold_16xLG.png differ diff --git a/images/settings.png b/images/settings.png new file mode 100644 index 00000000..f6542bd4 Binary files /dev/null and b/images/settings.png differ diff --git a/images/tool_moreCollapser_off16.png b/images/tool_moreCollapser_off16.png new file mode 100644 index 00000000..7c74540d Binary files /dev/null and b/images/tool_moreCollapser_off16.png differ diff --git a/images/twitchprime_bg.png b/images/twitchprime_bg.png new file mode 100644 index 00000000..4038afb0 Binary files /dev/null and b/images/twitchprime_bg.png differ diff --git a/main.cpp b/main.cpp index cfd323bb..5a8fc32b 100644 --- a/main.cpp +++ b/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(); diff --git a/mainwindow.cpp b/mainwindow.cpp index d10c783f..6bf3986f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,8 @@ +#include #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() diff --git a/notebook.cpp b/notebook.cpp index 94e4d6e0..85932165 100644 --- a/notebook.cpp +++ b/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(); diff --git a/notebookbutton.cpp b/notebookbutton.cpp index 687fa404..8d67e829 100644 --- a/notebookbutton.cpp +++ b/notebookbutton.cpp @@ -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); } } diff --git a/notebookbutton.h b/notebookbutton.h index 44b5047f..caacd3c1 100644 --- a/notebookbutton.h +++ b/notebookbutton.h @@ -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; diff --git a/notebookpage.cpp b/notebookpage.cpp index 54522a37..4ca1ca94 100644 --- a/notebookpage.cpp +++ b/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 NotebookPage::dropPosition = std::pair(-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 NotebookPage::removeFromLayout(ChatWidget *widget) +{ + for (int i = 0; i < hbox.count(); ++i) + { + auto vbox = static_cast(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(i, isLastItem ? -1 : j);; + } + } + + return std::pair(-1, -1); +} + +void NotebookPage::addToLayout(ChatWidget *widget, std::pair position = std::pair(-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(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(i, -1))); + } + + for (int i = 0; i < hbox.count(); ++i) + { + auto vbox = static_cast(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(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); } diff --git a/notebookpage.h b/notebookpage.h index 44a2eb9e..c69d499b 100644 --- a/notebookpage.h +++ b/notebookpage.h @@ -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 removeFromLayout(ChatWidget* widget); + void addToLayout(ChatWidget* widget, std::pair position); + + static bool isDraggingSplit; + static ChatWidget* draggingSplit; + static std::pair 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 position; + + DropRegion(QRect rect, std::pair position) + { + this->rect = rect; + this->position = position; + } + }; + + std::vector dropRegions; + + NotebookPageDropPreview preview; + +private: + void setPreviewRect(QPoint mousePos); }; #endif // NOTEBOOKPAGE_H diff --git a/notebookpagedroppreview.cpp b/notebookpagedroppreview.cpp new file mode 100644 index 00000000..ef696e84 --- /dev/null +++ b/notebookpagedroppreview.cpp @@ -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); +} diff --git a/notebookpagedroppreview.h b/notebookpagedroppreview.h new file mode 100644 index 00000000..5318d980 --- /dev/null +++ b/notebookpagedroppreview.h @@ -0,0 +1,15 @@ +#ifndef NOTEBOOKPAGEDROPPREVIEW_H +#define NOTEBOOKPAGEDROPPREVIEW_H + +#include + +class NotebookPageDropPreview : public QWidget +{ +public: + NotebookPageDropPreview(QWidget *parent); + +protected: + void paintEvent(QPaintEvent *); +}; + +#endif // NOTEBOOKPAGEDROPPREVIEW_H diff --git a/notebooktab.cpp b/notebooktab.cpp index e9240197..d43e04e4 100644 --- a/notebooktab.cpp +++ b/notebooktab.cpp @@ -1,6 +1,7 @@ +#include #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 = ""; 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); +} diff --git a/notebooktab.h b/notebooktab.h index c916d407..56285c3d 100644 --- a/notebooktab.h +++ b/notebooktab.h @@ -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 diff --git a/resources.qrc b/resources.qrc new file mode 100644 index 00000000..f9524c74 --- /dev/null +++ b/resources.qrc @@ -0,0 +1,21 @@ + + + images/AppearanceEditorPart_16x.png + images/BrowserLink_16x.png + images/cheer1.png + images/cheer100.png + images/cheer1000.png + images/cheer5000.png + images/cheer10000.png + images/cheer100000.png + images/CopyLongTextToClipboard_16x.png + images/CustomActionEditor_16x.png + images/Emoji_Color_1F60A_19.png + images/Filter_16x.png + images/format_Bold_16xLG.png + images/Message_16xLG.png + images/settings.png + images/tool_moreCollapser_off16.png + images/twitchprime_bg.png + +