added basic download icon to the window frame

This commit is contained in:
fourtf 2018-07-04 20:42:51 +02:00
parent 3303de18cd
commit 335cbf8758
10 changed files with 87 additions and 8 deletions

View file

@ -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 \

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

View file

@ -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>

View 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)

View file

@ -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);

View file

@ -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())); //

View 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

View 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

View file

@ -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

View file

@ -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();