mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added the update download button for linux/mac (updates don't work tho
so it doesn't show)
This commit is contained in:
parent
59332270b5
commit
3d7926cac1
4 changed files with 102 additions and 70 deletions
|
@ -12,6 +12,8 @@ void initUpdateButton(RippleEffectButton &button, std::unique_ptr<UpdatePromptDi
|
|||
|
||||
// show update prompt when clicking the button
|
||||
QObject::connect(&button, &RippleEffectButton::clicked, [&button, &handle] {
|
||||
(void)(handle);
|
||||
|
||||
auto dialog = new UpdatePromptDialog();
|
||||
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
||||
dialog->move(button.mapToGlobal(QPoint(int(-100 * button.getScale()), button.height())));
|
||||
|
@ -26,8 +28,10 @@ void initUpdateButton(RippleEffectButton &button, std::unique_ptr<UpdatePromptDi
|
|||
}
|
||||
});
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
handle.reset(dialog);
|
||||
dialog->closing.connect([&handle] { handle.release(); });
|
||||
#endif
|
||||
});
|
||||
|
||||
// update image when state changes
|
||||
|
|
|
@ -304,8 +304,6 @@ void Notebook::resizeEvent(QResizeEvent *)
|
|||
|
||||
void Notebook::performLayout(bool animated)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
int xStart = int(2 * this->getScale());
|
||||
|
||||
int x = xStart, y = 0;
|
||||
|
@ -409,8 +407,6 @@ NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
|||
SplitNotebook::SplitNotebook(Window *parent)
|
||||
: Notebook(parent)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->connect(this->getAddButton(), &NotebookButton::clicked,
|
||||
[this]() { QTimer::singleShot(80, this, [this] { this->addPage(true); }); });
|
||||
|
||||
|
@ -429,13 +425,10 @@ void SplitNotebook::addCustomButtons()
|
|||
settingsBtn->setVisible(!getApp()->settings->hidePreferencesButton.getValue());
|
||||
|
||||
getApp()->settings->hidePreferencesButton.connect(
|
||||
[this, settingsBtn](bool hide, auto) {
|
||||
settingsBtn->setVisible(!hide);
|
||||
this->performLayout(true);
|
||||
},
|
||||
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },
|
||||
this->uniqueConnections);
|
||||
|
||||
settingsBtn->icon = NotebookButton::IconSettings;
|
||||
settingsBtn->setIcon(NotebookButton::Settings);
|
||||
|
||||
QObject::connect(settingsBtn, &NotebookButton::clicked,
|
||||
[] { getApp()->windows->showSettingsDialog(); });
|
||||
|
@ -444,13 +437,9 @@ void SplitNotebook::addCustomButtons()
|
|||
auto userBtn = this->addCustomButton();
|
||||
userBtn->setVisible(!getApp()->settings->hideUserButton.getValue());
|
||||
getApp()->settings->hideUserButton.connect(
|
||||
[this, userBtn](bool hide, auto) {
|
||||
userBtn->setVisible(!hide);
|
||||
this->performLayout(true);
|
||||
},
|
||||
this->uniqueConnections);
|
||||
[userBtn](bool hide, auto) { userBtn->setVisible(!hide); }, this->uniqueConnections);
|
||||
|
||||
userBtn->icon = NotebookButton::IconUser;
|
||||
userBtn->setIcon(NotebookButton::User);
|
||||
QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] {
|
||||
getApp()->windows->showAccountSelectPopup(this->mapToGlobal(userBtn->rect().bottomRight()));
|
||||
});
|
||||
|
|
|
@ -13,18 +13,31 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
NotebookButton::NotebookButton(BaseWidget *parent)
|
||||
NotebookButton::NotebookButton(Notebook *parent)
|
||||
: RippleEffectButton(parent)
|
||||
, parent_(parent)
|
||||
{
|
||||
this->setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void NotebookButton::setIcon(Icon icon)
|
||||
{
|
||||
this->icon_ = icon;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
NotebookButton::Icon NotebookButton::getIcon() const
|
||||
{
|
||||
return this->icon_;
|
||||
}
|
||||
|
||||
void NotebookButton::themeRefreshEvent()
|
||||
{
|
||||
this->setMouseEffectColor(this->themeManager->tabs.regular.text);
|
||||
}
|
||||
|
||||
void NotebookButton::paintEvent(QPaintEvent *)
|
||||
void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
|
@ -43,7 +56,8 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
|
||||
float h = height(), w = width();
|
||||
|
||||
if (icon == IconPlus) {
|
||||
switch (icon_) {
|
||||
case Plus: {
|
||||
painter.setPen([&] {
|
||||
QColor tmp = foreground;
|
||||
if (!this->mouseOver_) {
|
||||
|
@ -54,11 +68,15 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
QRect rect = this->rect();
|
||||
int s = h * 4 / 9;
|
||||
|
||||
painter.drawLine(rect.left() + rect.width() / 2 - (s / 2), rect.top() + rect.height() / 2,
|
||||
painter.drawLine(
|
||||
rect.left() + rect.width() / 2 - (s / 2), rect.top() + rect.height() / 2,
|
||||
rect.left() + rect.width() / 2 + (s / 2), rect.top() + rect.height() / 2);
|
||||
painter.drawLine(rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 - (s / 2),
|
||||
painter.drawLine(
|
||||
rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 - (s / 2),
|
||||
rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 + (s / 2));
|
||||
} else if (icon == IconUser) {
|
||||
} break;
|
||||
|
||||
case User: {
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
|
||||
|
@ -75,8 +93,9 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
|
||||
painter.setBrush(foreground);
|
||||
painter.drawEllipse(2.5 * a, 1.5 * a, 3 * a + 1, 3 * a);
|
||||
} else // IconSettings
|
||||
{
|
||||
} break;
|
||||
|
||||
case Settings: {
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
|
||||
|
@ -87,16 +106,20 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
|||
|
||||
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));
|
||||
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);
|
||||
} break;
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
fancyPaint(painter);
|
||||
RippleEffectButton::paintEvent(event);
|
||||
}
|
||||
|
||||
void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
@ -157,4 +180,14 @@ void NotebookButton::dropEvent(QDropEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void NotebookButton::hideEvent(QHideEvent *)
|
||||
{
|
||||
this->parent_->performLayout();
|
||||
}
|
||||
|
||||
void NotebookButton::showEvent(QShowEvent *)
|
||||
{
|
||||
this->parent_->performLayout();
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -6,18 +6,19 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
class Notebook;
|
||||
|
||||
class NotebookButton : public RippleEffectButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const int IconPlus = 0;
|
||||
static const int IconUser = 1;
|
||||
static const int IconSettings = 2;
|
||||
enum Icon { None, Plus, User, Settings };
|
||||
|
||||
int icon = 0;
|
||||
explicit NotebookButton(Notebook *parent);
|
||||
|
||||
NotebookButton(BaseWidget *parent);
|
||||
void setIcon(Icon icon_);
|
||||
Icon getIcon() const;
|
||||
|
||||
protected:
|
||||
virtual void themeRefreshEvent() override;
|
||||
|
@ -27,11 +28,16 @@ protected:
|
|||
virtual void dragLeaveEvent(QDragLeaveEvent *) override;
|
||||
virtual void dropEvent(QDropEvent *) override;
|
||||
|
||||
virtual void hideEvent(QHideEvent *) override;
|
||||
virtual void showEvent(QShowEvent *) override;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
Notebook *parent_ = nullptr;
|
||||
QPoint mousePos_;
|
||||
Icon icon_ = None;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue