mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added basic download icon to the window frame
This commit is contained in:
parent
3303de18cd
commit
335cbf8758
|
@ -225,7 +225,8 @@ SOURCES += \
|
|||
src/singletons/Theme.cpp \
|
||||
src/controllers/moderationactions/ModerationActionModel.cpp \
|
||||
src/widgets/settingspages/LookPage.cpp \
|
||||
src/widgets/settingspages/FeelPage.cpp
|
||||
src/widgets/settingspages/FeelPage.cpp \
|
||||
src/widgets/dialogs/UpdatePromptDialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/Application.hpp \
|
||||
|
@ -398,7 +399,8 @@ HEADERS += \
|
|||
src/common/Singleton.hpp \
|
||||
src/controllers/moderationactions/ModerationActionModel.hpp \
|
||||
src/widgets/settingspages/LookPage.hpp \
|
||||
src/widgets/settingspages/FeelPage.hpp
|
||||
src/widgets/settingspages/FeelPage.hpp \
|
||||
src/widgets/dialogs/UpdatePromptDialog.hpp
|
||||
|
||||
RESOURCES += \
|
||||
resources/resources.qrc \
|
||||
|
|
BIN
resources/images/download_update.png
Normal file
BIN
resources/images/download_update.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 344 B |
|
@ -72,6 +72,7 @@
|
|||
<file>contributors.txt</file>
|
||||
<file>avatars/fourtf.png</file>
|
||||
<file>avatars/pajlada.png</file>
|
||||
<file>images/download_update.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/qt/etc">
|
||||
<file>qt.conf</file>
|
||||
|
|
|
@ -318,8 +318,8 @@ void BaseWindow::mouseMoveEvent(QMouseEvent *event)
|
|||
BaseWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void BaseWindow::addTitleBarButton(const TitleBarButton::Style &style,
|
||||
std::function<void()> onClicked)
|
||||
TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButton::Style &style,
|
||||
std::function<void()> onClicked)
|
||||
{
|
||||
TitleBarButton *button = new TitleBarButton;
|
||||
button->setScaleIndependantSize(30, 30);
|
||||
|
@ -329,6 +329,8 @@ void BaseWindow::addTitleBarButton(const TitleBarButton::Style &style,
|
|||
button->setButtonStyle(style);
|
||||
|
||||
QObject::connect(button, &TitleBarButton::clicked, this, [onClicked] { onClicked(); });
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
RippleEffectLabel *BaseWindow::addTitleBarLabel(std::function<void()> onClicked)
|
||||
|
|
|
@ -36,7 +36,8 @@ public:
|
|||
|
||||
QWidget *getLayoutContainer();
|
||||
bool hasCustomWindowFrame();
|
||||
void addTitleBarButton(const TitleBarButton::Style &style, std::function<void()> onClicked);
|
||||
TitleBarButton *addTitleBarButton(const TitleBarButton::Style &style,
|
||||
std::function<void()> onClicked);
|
||||
RippleEffectLabel *addTitleBarLabel(std::function<void()> onClicked);
|
||||
|
||||
void setStayInScreenRect(bool value);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "widgets/AccountSwitchPopupWidget.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
#include "widgets/dialogs/UpdatePromptDialog.hpp"
|
||||
#include "widgets/dialogs/WelcomeDialog.hpp"
|
||||
#include "widgets/helper/Shortcut.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
@ -52,10 +53,23 @@ Window::Window(WindowType _type)
|
|||
});
|
||||
|
||||
if (this->hasCustomWindowFrame() && _type == Window::Main) {
|
||||
// settings
|
||||
this->addTitleBarButton(TitleBarButton::Settings, [app] {
|
||||
app->windows->showSettingsDialog(); //
|
||||
});
|
||||
|
||||
// updates
|
||||
auto update = this->addTitleBarButton(TitleBarButton::None, [] {});
|
||||
update->setPixmap(QPixmap(":/images/download_update.png"));
|
||||
QObject::connect(update, &TitleBarButton::clicked, this, [this, update] {
|
||||
auto dialog = new UpdatePromptDialog();
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->move(update->mapToGlobal(QPoint(-100 * this->getScale(), update->height())));
|
||||
dialog->show();
|
||||
dialog->raise();
|
||||
});
|
||||
|
||||
// account
|
||||
this->userLabel = this->addTitleBarLabel([this, app] {
|
||||
app->windows->showAccountSelectPopup(
|
||||
this->userLabel->mapToGlobal(this->userLabel->rect().bottomLeft())); //
|
||||
|
|
30
src/widgets/dialogs/UpdatePromptDialog.cpp
Normal file
30
src/widgets/dialogs/UpdatePromptDialog.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "UpdatePromptDialog.hpp"
|
||||
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "widgets/Label.hpp"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
UpdatePromptDialog::UpdatePromptDialog()
|
||||
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::TopMost |
|
||||
BaseWindow::EnableCustomFrame))
|
||||
{
|
||||
auto layout = LayoutCreator<UpdatePromptDialog>(this).setLayoutType<QVBoxLayout>();
|
||||
|
||||
layout.emplace<Label>("An update is available!");
|
||||
layout.emplace<Label>("Do you want to download and install it?");
|
||||
layout.emplace<Label>("This doesn't work yet!");
|
||||
|
||||
auto buttons = layout.emplace<QDialogButtonBox>();
|
||||
auto install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
|
||||
auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
|
||||
|
||||
QObject::connect(install, &QPushButton::clicked, this, [this] { this->close(); });
|
||||
QObject::connect(dismiss, &QPushButton::clicked, this, [this] { this->close(); });
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
19
src/widgets/dialogs/UpdatePromptDialog.hpp
Normal file
19
src/widgets/dialogs/UpdatePromptDialog.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "widgets/BaseWindow.hpp"
|
||||
#include "widgets/Label.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class UpdatePromptDialog : public BaseWindow
|
||||
{
|
||||
public:
|
||||
UpdatePromptDialog();
|
||||
|
||||
private:
|
||||
struct {
|
||||
Label *label;
|
||||
} ui_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -20,7 +20,7 @@ void TitleBarButton::setButtonStyle(Style _style)
|
|||
this->update();
|
||||
}
|
||||
|
||||
void TitleBarButton::paintEvent(QPaintEvent *)
|
||||
void TitleBarButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
|
@ -115,9 +115,11 @@ void TitleBarButton::paintEvent(QPaintEvent *)
|
|||
painter.restore();
|
||||
break;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
|
||||
this->fancyPaint(painter);
|
||||
RippleEffectButton::paintEvent(event);
|
||||
// this->fancyPaint(painter);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -7,7 +7,15 @@ namespace chatterino {
|
|||
class TitleBarButton : public RippleEffectButton
|
||||
{
|
||||
public:
|
||||
enum Style { Minimize = 1, Maximize = 2, Unmaximize = 4, Close = 8, User = 16, Settings = 32 };
|
||||
enum Style {
|
||||
None = 0,
|
||||
Minimize = 1,
|
||||
Maximize = 2,
|
||||
Unmaximize = 4,
|
||||
Close = 8,
|
||||
User = 16,
|
||||
Settings = 32
|
||||
};
|
||||
|
||||
TitleBarButton();
|
||||
|
||||
|
|
Loading…
Reference in a new issue