worked on the UpdatePromptDialog

This commit is contained in:
fourtf
2018-07-05 11:42:40 +02:00
parent f02a89690e
commit f2238729f1
10 changed files with 161 additions and 35 deletions
+50 -21
View File
@@ -6,6 +6,7 @@
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/Updates.hpp"
#include "singletons/WindowManager.hpp"
#include "widgets/AccountSwitchPopupWidget.hpp"
#include "widgets/Notebook.hpp"
@@ -53,27 +54,7 @@ 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->setActionOnFocusLoss(BaseWindow::Delete);
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())); //
});
this->addCustomTitlebarButtons();
}
if (_type == Window::Main) {
@@ -194,6 +175,54 @@ Window::Window(WindowType _type)
this->notebook.setShowAddButton(true);
}
void Window::addCustomTitlebarButtons()
{
// settings
this->addTitleBarButton(TitleBarButton::Settings, [] {
getApp()->windows->showSettingsDialog(); //
});
// updates
auto update = this->addTitleBarButton(TitleBarButton::None, [] {});
update->hide();
QObject::connect(update, &TitleBarButton::clicked, this, [this, update] {
auto dialog = new UpdatePromptDialog();
dialog->setActionOnFocusLoss(BaseWindow::Delete);
dialog->move(update->mapToGlobal(QPoint(int(-100 * this->getScale()), update->height())));
dialog->show();
dialog->raise();
dialog->buttonClicked.connect([update](auto button) {
switch (button) {
case UpdatePromptDialog::Dismiss: {
update->hide();
} break;
}
});
this->updateDialogHandle_.reset(dialog);
dialog->closing.connect([this] { this->updateDialogHandle_.release(); });
});
auto updateChange = [update](auto) {
update->setVisible(Updates::getInstance().shouldShowUpdateButton());
auto imageUrl = Updates::getInstance().isError() ? ":/images/download_update_error.png"
: ":/images/download_update.png";
update->setPixmap(QPixmap(imageUrl));
};
updateChange(Updates::getInstance().getStatus());
this->signalHolder.managedConnect(Updates::getInstance().statusUpdated,
[updateChange](auto status) { updateChange(status); });
// account
this->userLabel = this->addTitleBarLabel([this] {
getApp()->windows->showAccountSelectPopup(
this->userLabel->mapToGlobal(this->userLabel->rect().bottomLeft())); //
});
}
Window::WindowType Window::getType()
{
return this->type;