2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 15:05:56 +00:00

almost all boxes done

This commit is contained in:
John Preston
2015-10-11 10:37:24 +02:00
parent 13f6eedcb2
commit 542d9435d8
52 changed files with 2775 additions and 2495 deletions

View File

@@ -34,6 +34,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
#include "settingswidget.h"
#include "boxes/confirmbox.h"
#include "boxes/contactsbox.h"
#include "boxes/addcontactbox.h"
#include "mediaview.h"
#include "localstorage.h"
@@ -357,7 +358,7 @@ NotifyWindow::~NotifyWindow() {
}
Window::Window(QWidget *parent) : PsMainWindow(parent), _serviceHistoryRequest(0), title(0),
_passcode(0), intro(0), main(0), settings(0), layerBG(0), _isActive(false), _topWidget(0),
_passcode(0), intro(0), main(0), settings(0), layerBg(0), _isActive(false),
_connecting(0), _clearManager(0), dragging(false), _inactivePress(false), _shouldLockAt(0), _mediaView(0) {
icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation);
@@ -389,7 +390,6 @@ _connecting(0), _clearManager(0), dragging(false), _inactivePress(false), _shoul
connect(&_autoLockTimer, SIGNAL(timeout()), this, SLOT(checkAutoLock()));
connect(this, SIGNAL(imageLoaded()), this, SLOT(update()));
connect(this, SIGNAL(imageLoaded()), this, SLOT(notifyUpdateAllPhotos()));
setAttribute(Qt::WA_NoSystemBackground);
@@ -776,17 +776,17 @@ void Window::showDocument(DocumentData *doc, HistoryItem *item) {
void Window::showLayer(LayeredWidget *w, bool forceFast) {
bool fast = forceFast || layerShown();
hideLayer(true);
layerBG = new BackgroundWidget(this, w);
layerBg = new BackgroundWidget(this, w);
if (fast) {
layerBG->showFast();
layerBg->showFast();
}
}
void Window::replaceLayer(LayeredWidget *w) {
if (layerBG) {
layerBG->replaceInner(w);
if (layerBg) {
layerBg->replaceInner(w);
} else {
layerBG = new BackgroundWidget(this, w);
layerBg = new BackgroundWidget(this, w);
}
}
@@ -815,26 +815,26 @@ void Window::hideConnecting() {
}
void Window::hideLayer(bool fast) {
if (layerBG) {
layerBG->onClose();
if (layerBg) {
layerBg->onClose();
if (fast) {
layerBG->hide();
layerBG->deleteLater();
layerBG = 0;
layerBg->hide();
layerBg->deleteLater();
layerBg = 0;
}
}
hideMediaview();
}
bool Window::hideInnerLayer() {
if (layerBG) {
return layerBG->onInnerClose();
if (layerBg) {
return layerBg->onInnerClose();
}
return true;
}
bool Window::layerShown() {
return !!layerBG || !!_topWidget;
return !!layerBg;
}
bool Window::historyIsActive() const {
@@ -849,11 +849,11 @@ void Window::checkHistoryActivation() {
}
void Window::layerHidden() {
if (layerBG) {
layerBG->hide();
layerBG->deleteLater();
if (layerBg) {
layerBg->hide();
layerBg->deleteLater();
}
layerBG = 0;
layerBg = 0;
hideMediaview();
setInnerFocus();
}
@@ -871,13 +871,13 @@ void Window::hideMediaview() {
bool Window::contentOverlapped(const QRect &globalRect) {
if (main && main->contentOverlapped(globalRect)) return true;
if (layerBG && layerBG->contentOverlapped(globalRect)) return true;
if (layerBg && layerBg->contentOverlapped(globalRect)) return true;
return false;
}
void Window::setInnerFocus() {
if (layerBG && layerBG->canSetFocus()) {
layerBG->setInnerFocus();
if (layerBg && layerBg->canSetFocus()) {
layerBg->setInnerFocus();
} else if (_passcode) {
_passcode->setInnerFocus();
} else if (settings) {
@@ -1063,7 +1063,7 @@ void Window::onShowNewChannel() {
void Window::onLogout() {
if (isHidden()) showFromTray();
ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout), lang(lng_box_logout), st::attentionBoxButton);
ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout), lang(lng_settings_logout), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onLogoutSure()));
App::wnd()->showLayer(box);
}
@@ -1116,34 +1116,23 @@ void Window::noMain(MainWidget *was) {
}
void Window::noBox(BackgroundWidget *was) {
if (was == layerBG) {
layerBG = 0;
if (was == layerBg) {
layerBg = 0;
}
}
void Window::layerFinishedHide(BackgroundWidget *was) {
if (was == layerBG) {
if (was == layerBg) {
QTimer::singleShot(0, this, SLOT(layerHidden()));
}
}
void Window::fixOrder() {
title->raise();
if (layerBG) layerBG->raise();
if (_topWidget) _topWidget->raise();
if (layerBg) layerBg->raise();
if (_connecting) _connecting->raise();
}
void Window::topWidget(QWidget *w) {
_topWidget = w;
}
void Window::noTopWidget(QWidget *w) {
if (_topWidget == w) {
_topWidget = 0;
}
}
void Window::showFromTray(QSystemTrayIcon::ActivationReason reason) {
if (reason != QSystemTrayIcon::Context) {
QTimer::singleShot(1, this, SLOT(updateTrayMenu()));
@@ -1168,7 +1157,7 @@ void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) {
}
void Window::closeEvent(QCloseEvent *e) {
if (MTP::authedId() && minimizeToTray()) {
if (MTP::authedId() && !App::app()->isSavingSession() && minimizeToTray()) {
e->ignore();
} else {
App::quit();
@@ -1188,7 +1177,7 @@ void Window::resizeEvent(QResizeEvent *e) {
updateWideMode();
}
title->setGeometry(0, 0, width(), st::titleHeight);
if (layerBG) layerBG->resize(width(), height());
if (layerBg) layerBg->resize(width(), height());
if (_connecting) _connecting->setGeometry(0, height() - _connecting->height(), _connecting->width(), _connecting->height());
emit resized(QSize(width(), height() - st::titleHeight));
}
@@ -1198,7 +1187,7 @@ void Window::updateWideMode() {
if (main) main->updateWideMode();
if (settings) settings->updateWideMode();
if (intro) intro->updateWideMode();
if (layerBG) layerBG->updateWideMode();
if (layerBg) layerBg->updateWideMode();
}
bool Window::needBackButton() {