From 1290d28b1a2798e1902a5fb91ddf634a2517b045 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 18 Apr 2018 18:55:49 +0200 Subject: [PATCH] added custom window frame title --- src/widgets/basewindow.cpp | 23 ++++++++++++++++------- src/widgets/emotepopup.cpp | 2 ++ src/widgets/helper/notebooktab.cpp | 4 +++- src/widgets/selectchanneldialog.cpp | 2 ++ src/widgets/window.cpp | 2 ++ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 5a63a3ac3..635ad107f 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -19,6 +19,7 @@ #include #include #pragma comment(lib, "Dwmapi.lib") +#pragma comment(lib, "Gdi32.lib") #include #include @@ -70,11 +71,14 @@ void BaseWindow::init() layout->addLayout(buttonLayout); // title - // QLabel *title = new QLabel(" Chatterino"); - QLabel *title = new QLabel(""); - QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); + QLabel *title = new QLabel(" Chatterino"); + QObject::connect(this, &QWidget::windowTitleChanged, + [title](const QString &text) { title->setText(" " + text); }); + + QSizePolicy policy(QSizePolicy::Ignored, QSizePolicy::Preferred); policy.setHorizontalStretch(1); - title->setBaseSize(0, 0); + // title->setBaseSize(0, 0); + title->setScaledContents(true); title->setSizePolicy(policy); buttonLayout->addWidget(title); this->ui.titleLabel = title; @@ -106,7 +110,7 @@ void BaseWindow::init() this->ui.buttons.push_back(_maxButton); this->ui.buttons.push_back(_exitButton); - buttonLayout->addStretch(1); + // buttonLayout->addStretch(1); buttonLayout->addWidget(_minButton); buttonLayout->addWidget(_maxButton); buttonLayout->addWidget(_exitButton); @@ -167,6 +171,11 @@ void BaseWindow::themeRefreshEvent() palette.setColor(QPalette::Foreground, this->themeManager.window.text); this->setPalette(palette); + QPalette palette_title; + palette_title.setColor(QPalette::Foreground, + this->themeManager.isLightTheme() ? "#333" : "#ccc"); + this->ui.titleLabel->setPalette(palette_title); + for (RippleEffectButton *button : this->ui.buttons) { button->setMouseEffectColor(this->themeManager.window.text); } @@ -185,7 +194,7 @@ void BaseWindow::addTitleBarButton(const TitleBarButton::Style &style, button->setScaleIndependantSize(30, 30); this->ui.buttons.push_back(button); - this->ui.titlebarBox->insertWidget(2, button); + this->ui.titlebarBox->insertWidget(1, button); button->setButtonStyle(style); QObject::connect(button, &TitleBarButton::clicked, this, [onClicked] { onClicked(); }); @@ -197,7 +206,7 @@ RippleEffectLabel *BaseWindow::addTitleBarLabel(std::function onClicked) button->setScaleIndependantHeight(30); this->ui.buttons.push_back(button); - this->ui.titlebarBox->insertWidget(2, button); + this->ui.titlebarBox->insertWidget(1, button); QObject::connect(button, &RippleEffectLabel::clicked, this, [onClicked] { onClicked(); }); diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index 09fb1d533..134923d9d 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -48,6 +48,8 @@ EmotePopup::EmotePopup(singletons::ThemeManager &themeManager) void EmotePopup::loadChannel(ChannelPtr _channel) { + this->setWindowTitle("Emotes from " + _channel->name); + TwitchChannel *channel = dynamic_cast(_channel.get()); if (channel == nullptr) { diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 1674dfa82..ff60ce22b 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -342,7 +342,9 @@ void NotebookTab2::leaveEvent(QEvent *) void NotebookTab2::dragEnterEvent(QDragEnterEvent *) { - this->notebook->select(this->page); + if (this->notebook->getAllowUserTabManagement()) { + this->notebook->select(this->page); + } } void NotebookTab2::mouseMoveEvent(QMouseEvent *event) diff --git a/src/widgets/selectchanneldialog.cpp b/src/widgets/selectchanneldialog.cpp index b4a045d3d..fe9f320c3 100644 --- a/src/widgets/selectchanneldialog.cpp +++ b/src/widgets/selectchanneldialog.cpp @@ -19,6 +19,8 @@ SelectChannelDialog::SelectChannelDialog() : BaseWindow((QWidget *)nullptr, true) , selectedChannel(Channel::getEmpty()) { + this->setWindowTitle("Select a channel to join"); + this->tabFilter.dialog = this; util::LayoutCreator layoutWidget(this->getLayoutContainer()); diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 31aff5a61..ce6f3b7ff 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -100,6 +100,8 @@ Window::Window(singletons::ThemeManager &_themeManager, WindowType _type) // static int index = 0; // ircManager.addFakeMessage(cheerMessages[index++ % cheerMessages.size()]); // }); + + this->setWindowTitle("Chatterino 2 Development Build"); } Window::WindowType Window::getType()