Started a special LayerWidget: Settings::Widget.

Also added some missing calls to parent event handlers in boxes.
This commit is contained in:
John Preston 2016-08-17 18:14:08 +03:00
parent 4a6e669a53
commit 90678d411f
48 changed files with 540 additions and 177 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

View File

@ -170,13 +170,6 @@ namespace App {
return nullptr;
}
SettingsWidget *settings() {
if (auto w = wnd()) {
return w->settingsWidget();
}
return nullptr;
}
bool passcoded() {
if (auto w = wnd()) {
return w->passcodeWidget();

View File

@ -46,7 +46,6 @@ namespace App {
AppClass *app();
MainWindow *wnd();
MainWidget *main();
SettingsWidget *settings();
bool passcoded();
FileUploader *uploader();
ApiWrap *api();

View File

@ -62,6 +62,7 @@ void AboutBox::resizeEvent(QResizeEvent *e) {
_text2.moveToLeft(st::boxPadding.left(), _text1.y() + _text1.height() + st::aboutSkip);
_text3.moveToLeft(st::boxPadding.left(), _text2.y() + _text2.height() + st::aboutSkip);
_done.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _done.height());
AbstractBox::resizeEvent(e);
}
void AboutBox::onVersion() {

View File

@ -103,6 +103,7 @@ void AbstractBox::resizeEvent(QResizeEvent *e) {
_blueShadow->moveToLeft(0, st::boxTitleHeight);
_blueShadow->resize(width(), st::boxBlueShadow.pxHeight());
}
LayerWidget::resizeEvent(e);
}
void AbstractBox::parentResized() {

View File

@ -135,6 +135,7 @@ void AddContactBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_retry.moveToRight(st::boxButtonPadding.right(), _save.y());
_cancel.moveToRight(st::boxButtonPadding.right() + (_retry.isHidden() ? _save.width() : _retry.width()) + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void AddContactBox::onSubmit() {
@ -308,6 +309,7 @@ void NewGroupBox::resizeEvent(QResizeEvent *e) {
_next.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _next.width() + st::boxButtonPadding.left(), _next.y());
AbstractBox::resizeEvent(e);
}
void NewGroupBox::onNext() {
@ -400,6 +402,7 @@ void GroupInfoBox::resizeEvent(QResizeEvent *e) {
_next.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _next.width() + st::boxButtonPadding.left(), _next.y());
AbstractBox::resizeEvent(e);
}
void GroupInfoBox::mouseMoveEvent(QMouseEvent *e) {
@ -707,6 +710,7 @@ void SetupChannelBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_skip.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void SetupChannelBox::mouseMoveEvent(QMouseEvent *e) {
@ -1045,6 +1049,7 @@ void EditNameTitleBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void EditNameTitleBox::onSave() {
@ -1238,6 +1243,7 @@ void EditChannelBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void EditChannelBox::onSave() {
@ -1427,6 +1433,7 @@ void RevokePublicLinkBox::paintEvent(QPaintEvent *e) {
void RevokePublicLinkBox::resizeEvent(QResizeEvent *e) {
_aboutRevoke->moveToLeft(st::boxPadding.left(), st::boxPadding.top());
_cancel->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _cancel->height());
AbstractBox::resizeEvent(e);
}
void RevokePublicLinkBox::paintChat(Painter &p, const ChatRow &row, bool selected, bool pressed) const {

View File

@ -196,7 +196,9 @@ void BackgroundBox::onBackgroundChosen(int index) {
if (index >= 0 && index < App::cServerBackgrounds().size()) {
const App::WallPaper &paper(App::cServerBackgrounds().at(index));
if (App::main()) App::main()->setChatBackground(paper);
if (App::settings()) App::settings()->needBackgroundUpdate(!paper.id);
if (_updateCallback) {
_updateCallback(!paper.id);
}
}
onClose();
}

View File

@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once
#include "abstractbox.h"
#include "core/lambda_wrap.h"
class BackgroundInner : public QWidget, public RPCSender {
Q_OBJECT
@ -53,6 +54,11 @@ class BackgroundBox : public ItemListBox {
public:
BackgroundBox();
// When background is chosen this callback is called with "bool isTiled" arg.
void setUpdateCallback(base::lambda_unique<void(bool)> &&updateCallback) {
_updateCallback = std::move(updateCallback);
}
public slots:
void onBackgroundChosen(int index);
@ -61,5 +67,6 @@ protected:
private:
BackgroundInner _inner;
base::lambda_unique<void(bool)> _updateCallback;
};

View File

@ -172,6 +172,7 @@ void ConfirmBox::paintEvent(QPaintEvent *e) {
void ConfirmBox::resizeEvent(QResizeEvent *e) {
_confirm.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _confirm.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _confirm.width() + st::boxButtonPadding.left(), _confirm.y());
AbstractBox::resizeEvent(e);
}
SharePhoneConfirmBox::SharePhoneConfirmBox(PeerData *recipient)
@ -281,6 +282,7 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
void MaxInviteBox::resizeEvent(QResizeEvent *e) {
_close.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _close.height());
_invitationLink = myrtlrect(st::boxPadding.left(), st::boxPadding.top() + _textHeight + st::boxTextFont->height, width() - st::boxPadding.left() - st::boxPadding.right(), 2 * st::boxTextFont->height);
AbstractBox::resizeEvent(e);
}
ConvertToSupergroupBox::ConvertToSupergroupBox(ChatData *chat) : AbstractBox(st::boxWideWidth)
@ -374,6 +376,7 @@ void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) {
void ConvertToSupergroupBox::resizeEvent(QResizeEvent *e) {
_convert.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _convert.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _convert.width() + st::boxButtonPadding.left(), _convert.y());
AbstractBox::resizeEvent(e);
}
PinMessageBox::PinMessageBox(ChannelData *channel, MsgId msgId) : AbstractBox(st::boxWidth)
@ -395,6 +398,7 @@ void PinMessageBox::resizeEvent(QResizeEvent *e) {
_notify.moveToLeft(st::boxPadding.left(), _text.y() + _text.height() + st::boxMediumSkip);
_pin.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _pin.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _pin.width() + st::boxButtonPadding.left(), _pin.y());
AbstractBox::resizeEvent(e);
}
void PinMessageBox::onPin() {
@ -453,6 +457,7 @@ void RichDeleteMessageBox::resizeEvent(QResizeEvent *e) {
_deleteAll.moveToLeft(st::boxPadding.left(), _reportSpam.y() + _reportSpam.height() + st::boxLittleSkip);
_delete.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _delete.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _delete.width() + st::boxButtonPadding.left(), _delete.y());
AbstractBox::resizeEvent(e);
}
void RichDeleteMessageBox::onDelete() {
@ -562,6 +567,7 @@ void ConfirmInviteBox::resizeEvent(QResizeEvent *e) {
_status->move((width() - _status->width()) / 2, st::confirmInviteStatusTop);
_join->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _join->height());
_cancel->moveToRight(st::boxButtonPadding.right() + _join->width() + st::boxButtonPadding.left(), _join->y());
AbstractBox::resizeEvent(e);
}
void ConfirmInviteBox::paintEvent(QPaintEvent *e) {

View File

@ -121,6 +121,8 @@ void ConnectionBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void ConnectionBox::onChange() {
@ -264,6 +266,8 @@ void AutoDownloadBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void AutoDownloadBox::onSave() {

View File

@ -709,9 +709,8 @@ void ContactsInner::chooseParticipant() {
connect(box, SIGNAL(confirmed()), this, SLOT(onAddBot()));
Ui::showLayer(box, KeepOtherLayers);
} else {
App::wnd()->hideSettings(true);
Ui::hideSettingsAndLayer(true);
App::main()->choosePeer(peer->id, ShowAtUnreadMsgId);
Ui::hideLayer();
}
}
}

View File

@ -27,6 +27,25 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/filedialog.h"
#include "pspecific.h"
namespace internal {
namespace {
void StartCallback() {
}
void FinishCallback() {
}
Notify::SimpleObservedEventRegistrator<DownloadPathUpdateHandler> creator(StartCallback, FinishCallback);
} // namespace
Notify::ConnectionId plainRegisterObserver(DownloadPathUpdateHandler &&handler) {
return creator.registerObserver(std_::forward<DownloadPathUpdateHandler>(handler));
}
} // namespace interanl
DownloadPathBox::DownloadPathBox() : AbstractBox()
, _path(cDownloadPath())
, _pathBookmark(cDownloadPathBookmark())
@ -90,6 +109,7 @@ void DownloadPathBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
AbstractBox::resizeEvent(e);
}
void DownloadPathBox::onChange() {
@ -132,6 +152,7 @@ void DownloadPathBox::onSave() {
cSetDownloadPath(_default.checked() ? QString() : (_temp.checked() ? qsl("tmp") : _path));
cSetDownloadPathBookmark((_default.checked() || _temp.checked()) ? QByteArray() : _pathBookmark);
Local::writeUserSettings();
internal::creator.notify(DownloadPathUpdate());
onClose();
}

View File

@ -21,6 +21,22 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once
#include "abstractbox.h"
#include "core/observer.h"
// Just a notification that cDownloadPath() has changed.
struct DownloadPathUpdate {
};
namespace internal {
using DownloadPathUpdateHandler = Function<void, const DownloadPathUpdate&>;
Notify::ConnectionId plainRegisterObserver(DownloadPathUpdateHandler &&handler);
} // namespace internal
template <typename ObserverType>
void registerDownloadPathObserver(ObserverType *observer, void (ObserverType::*handler)(const DownloadPathUpdate &)) {
auto connection = internal::plainRegisterObserver(func(observer, handler));
Notify::observerRegistered(observer, connection);
}
class DownloadPathBox : public AbstractBox {
Q_OBJECT

View File

@ -258,6 +258,7 @@ void PhotoCropBox::paintEvent(QPaintEvent *e) {
void PhotoCropBox::resizeEvent(QResizeEvent *e) {
_done.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _done.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _done.width() + st::boxButtonPadding.left(), _done.y());
AbstractBox::resizeEvent(e);
}
void PhotoCropBox::onSend() {

View File

@ -292,6 +292,7 @@ void PhotoSendBox::resizeEvent(QResizeEvent *e) {
_caption.resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _caption.height());
_caption.moveToLeft(st::boxPhotoPadding.left(), _send.y() - st::boxButtonPadding.top() - _caption.height());
_compressed.moveToLeft(st::boxPhotoPadding.left(), st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + st::boxPhotoCompressedPadding.top());
AbstractBox::resizeEvent(e);
}
void PhotoSendBox::closePressed() {
@ -617,6 +618,7 @@ void EditCaptionBox::resizeEvent(QResizeEvent *e) {
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
_field->resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _field->height());
_field->moveToLeft(st::boxPhotoPadding.left(), _save.y() - st::boxButtonPadding.top() - st::normalFont->height - _field->height());
AbstractBox::resizeEvent(e);
}
void EditCaptionBox::showAll() {

View File

@ -66,6 +66,7 @@ void ReportBox::resizeEvent(QResizeEvent *e) {
_report->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _report->height());
_cancel->moveToRight(st::boxButtonPadding.right() + _report->width() + st::boxButtonPadding.left(), _report->y());
AbstractBox::resizeEvent(e);
}
void ReportBox::onChange() {

View File

@ -885,7 +885,8 @@ enum ShowLayerOption {
AnimatedShowLayer = 0x00,
ForceFastShowLayer = 0x04,
};
typedef QFlags<ShowLayerOption> ShowLayerOptions;
Q_DECLARE_FLAGS(ShowLayerOptions, ShowLayerOption);
Q_DECLARE_OPERATORS_FOR_FLAGS(ShowLayerOptions);
static int32 FullArcLength = 360 * 16;
static int32 QuarterArcLength = (FullArcLength / 4);

View File

@ -81,7 +81,7 @@ template <typename Flags, typename Handler>
class ObservedEventRegistrator : public internal::BaseObservedEventRegistrator {
public:
ObservedEventRegistrator(StartObservedEventCallback startCallback,
FinishObservedEventCallback finishCallback) : internal::BaseObservedEventRegistrator(reinterpret_cast<void*>(this),
FinishObservedEventCallback finishCallback) : internal::BaseObservedEventRegistrator(static_cast<void*>(this),
ObservedEventRegistrator<Flags, Handler>::start,
ObservedEventRegistrator<Flags, Handler>::finish,
ObservedEventRegistrator<Flags, Handler>::unregister)
@ -113,21 +113,21 @@ public:
private:
using Self = ObservedEventRegistrator<Flags, Handler>;
static void start(void *vthat) {
Self *that = reinterpret_cast<Self*>(vthat);
Self *that = static_cast<Self*>(vthat);
t_assert(!that->started());
if (that->_startCallback) that->_startCallback();
that->_list = new internal::ObserversList<Flags, Handler>();
}
static void finish(void *vthat) {
Self *that = reinterpret_cast<Self*>(vthat);
Self *that = static_cast<Self*>(vthat);
if (that->_finishCallback) that->_finishCallback();
delete that->_list;
that->_list = nullptr;
}
static void unregister(void *vthat, int connectionIndex) {
Self *that = reinterpret_cast<Self*>(vthat);
Self *that = static_cast<Self*>(vthat);
t_assert(that->started());

View File

@ -208,7 +208,11 @@ void showLayer(LayerWidget *box, ShowLayerOptions options) {
}
void hideLayer(bool fast) {
if (auto w = App::wnd()) w->ui_showLayer(0, ShowLayerOptions(CloseOtherLayers) | (fast ? ForceFastShowLayer : AnimatedShowLayer));
if (auto w = App::wnd()) w->ui_showLayer(0, CloseOtherLayers | (fast ? ForceFastShowLayer : AnimatedShowLayer));
}
void hideSettingsAndLayer(bool fast) {
if (auto w = App::wnd()) w->ui_hideSettingsAndLayer(fast ? ForceFastShowLayer : AnimatedShowLayer);
}
bool isLayerShown() {

View File

@ -58,6 +58,7 @@ void hideMediaPreview();
void showLayer(LayerWidget *box, ShowLayerOptions options = CloseOtherLayers);
void hideLayer(bool fast = false);
void hideSettingsAndLayer(bool fast = false);
bool isLayerShown();
bool isMediaViewShown();
bool isInlineItemBeingChosen();

View File

@ -6318,7 +6318,7 @@ void HistoryWidget::topBarClick() {
}
}
void HistoryWidget::updateOnlineDisplay(int32 x, int32 w) {
void HistoryWidget::updateOnlineDisplay() {
if (!_history) return;
QString text;

View File

@ -589,7 +589,7 @@ public:
void cancelShareContact();
void updateControlsVisibility();
void updateOnlineDisplay(int32 x, int32 w);
void updateOnlineDisplay();
void updateOnlineDisplayTimer();
void onShareContact(const PeerId &peer, UserData *contact);

View File

@ -107,6 +107,16 @@ void LayerStackWidget::mousePressEvent(QMouseEvent *e) {
onClose();
}
void LayerStackWidget::onCloseLayers() {
if (_specialLayer) {
clearLayers();
fixOrder();
if (App::wnd()) App::wnd()->setInnerFocus();
} else {
onClose();
}
}
void LayerStackWidget::onClose() {
startHide();
}

View File

@ -31,16 +31,15 @@ public:
}
void setInnerFocus();
void mousePressEvent(QMouseEvent *e) {
e->accept();
}
bool overlaps(const QRect &globalRect) {
if (isHidden() || !testAttribute(Qt::WA_OpaquePaintEvent)) return false;
return rect().contains(QRect(mapFromGlobal(globalRect.topLeft()), globalRect.size()));
}
protected:
void mousePressEvent(QMouseEvent *e) override {
e->accept();
}
void resizeEvent(QResizeEvent *e) override {
emit resized();
}
@ -74,6 +73,7 @@ public:
bool contentOverlapped(const QRect &globalRect);
void onCloseLayers();
void onClose();
~LayerStackWidget();

View File

@ -1510,11 +1510,7 @@ void MainWidget::loadFailed(mtpFileLoader *loader, bool started, const char *ret
void MainWidget::onDownloadPathSettings() {
cSetDownloadPath(QString());
cSetDownloadPathBookmark(QByteArray());
DownloadPathBox *box = new DownloadPathBox();
if (App::wnd() && App::wnd()->settingsWidget()) {
connect(box, SIGNAL(closed(LayerWidget*)), App::wnd()->settingsWidget(), SLOT(onDownloadPathEdited()));
}
Ui::showLayer(box);
Ui::showLayer(new DownloadPathBox());
}
void MainWidget::onSharePhoneWithBot(PeerData *recipient) {
@ -1686,8 +1682,7 @@ void MainWidget::onParentResize(const QSize &newSize) {
void MainWidget::updateOnlineDisplay() {
if (this != App::main()) return;
_history->updateOnlineDisplay(_history->x(), width() - _history->x() - st::sysBtnDelta * 2 - st::sysCls.img.pxWidth() - st::sysRes.img.pxWidth() - st::sysMin.img.pxWidth());
if (App::wnd()->settingsWidget()) App::wnd()->settingsWidget()->updateOnlineDisplay();
_history->updateOnlineDisplay();
}
void MainWidget::onSendFileConfirm(const FileLoadResultPtr &file, bool ctrlShiftEnter) {
@ -2046,7 +2041,7 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show
PeerData *wasActivePeer = activePeer();
Ui::hideLayer();
Ui::hideSettingsAndLayer();
if (_hider) {
_hider->startHide();
_hider = nullptr;
@ -2195,7 +2190,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
peer = peer->migrateTo();
}
App::wnd()->hideSettings();
Ui::hideSettingsAndLayer();
if (_overview && _overview->peer() == peer) {
if (_overview->type() != type) {
_overview->switchType(type);
@ -2248,7 +2243,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
}
void MainWidget::showWideSection(const Window::SectionMemento &memento) {
App::wnd()->hideSettings();
Ui::hideSettingsAndLayer();
if (_wideSection && _wideSection->showInternal(&memento)) {
return;
}

View File

@ -41,6 +41,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "mediaview.h"
#include "localstorage.h"
#include "apiwrap.h"
#include "settings/settings_widget.h"
ConnectingWidget::ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect) : QWidget(parent), _shadow(st::boxShadow), _reconnect(this, QString()) {
set(text, reconnect);
@ -299,7 +300,6 @@ void NotifyWindow::mousePressEvent(QMouseEvent *e) {
App::wnd()->setInnerFocus();
App::wnd()->notifyClear();
} else {
App::wnd()->hideSettings();
Ui::showPeerHistory(peer, msgId);
}
e->ignore();
@ -486,13 +486,6 @@ void MainWindow::clearWidgets() {
_passcode->deleteLater();
_passcode = 0;
}
if (settings) {
settings->stop_show();
settings->hide();
settings->deleteLater();
settings->rpcClear();
settings = 0;
}
if (main) {
delete main;
main = nullptr;
@ -537,8 +530,6 @@ void MainWindow::clearPasscode() {
_passcode = 0;
if (intro) {
intro->animShow(bg, true);
} else if (settings) {
settings->animShow(bg, true);
} else {
main->animShow(bg, true);
}
@ -558,7 +549,9 @@ void MainWindow::setupPasscode(bool anim) {
_passcode = new PasscodeWidget(this);
_passcode->move(0, st::titleHeight);
if (main) main->hide();
if (settings) settings->hide();
if (settings) {
settings->deleteLater();
}
if (intro) intro->hide();
if (anim) {
_passcode->animShow(bg);
@ -684,63 +677,29 @@ void MainWindow::showSettings() {
if (isHidden()) showFromTray();
Ui::hideLayer();
if (settings) {
return hideSettings();
Ui::hideSettingsAndLayer();
return;
}
QPixmap bg = grabInner();
if (intro) {
intro->stop_show();
intro->hide();
} else if (main) {
main->animStop_show();
main->hide();
if (!layerBg) {
layerBg = new LayerStackWidget(this);
}
settings = new SettingsWidget(this);
settings->animShow(bg);
title->updateBackButton();
fixOrder();
settings = new Settings::Widget();
connect(settings, SIGNAL(destroyed(QObject*)), this, SLOT(onSettingsDestroyed(QObject*)));
layerBg->showSpecialLayer(settings);
}
void MainWindow::hideSettings(bool fast) {
if (!settings || _passcode) return;
if (fast) {
settings->stop_show();
settings->hide();
settings->deleteLater();
settings->rpcClear();
settings = 0;
if (intro) {
intro->show();
} else {
main->show();
}
} else {
QPixmap bg = grabInner();
settings->stop_show();
settings->hide();
settings->deleteLater();
settings->rpcClear();
settings = 0;
if (intro) {
intro->animShow(bg, true);
} else {
main->animShow(bg, true);
}
void MainWindow::ui_hideSettingsAndLayer(ShowLayerOptions options) {
if (layerBg) {
layerBg->onClose();
}
title->updateBackButton();
fixOrder();
}
void MainWindow::mtpStateChanged(int32 dc, int32 state) {
if (dc == MTP::maindc()) {
updateTitleStatus();
if (settings) settings->updateConnectionType();
// if (settings) settings->updateConnectionType(); TODO
}
}
@ -766,10 +725,6 @@ MainWidget *MainWindow::mainWidget() {
return main;
}
SettingsWidget *MainWindow::settingsWidget() {
return settings;
}
PasscodeWidget *MainWindow::passcodeWidget() {
return _passcode;
}
@ -818,11 +773,15 @@ void MainWindow::ui_showLayer(LayerWidget *box, ShowLayerOptions options) {
}
} else {
if (layerBg) {
layerBg->onClose();
if (options.testFlag(ForceFastShowLayer)) {
layerBg->hide();
layerBg->deleteLater();
layerBg = nullptr;
if (settings) {
layerBg->onCloseLayers();
} else {
layerBg->onClose();
if (options.testFlag(ForceFastShowLayer)) {
layerBg->hide();
layerBg->deleteLater();
layerBg = nullptr;
}
}
}
hideMediaview();
@ -1218,9 +1177,9 @@ void MainWindow::noIntro(IntroWidget *was) {
}
}
void MainWindow::noSettings(SettingsWidget *was) {
void MainWindow::onSettingsDestroyed(QObject *was) {
if (was == settings) {
settings = 0;
settings = nullptr;
}
checkHistoryActivation();
}
@ -1281,7 +1240,7 @@ void MainWindow::toggleDisplayNotifyFromTray() {
}
cSetDesktopNotify(!cDesktopNotify());
if (settings) {
settings->updateDisplayNotify();
// settings->updateDisplayNotify(); TODO
} else {
if (!cDesktopNotify()) {
notifyClear();
@ -1330,15 +1289,10 @@ void MainWindow::resizeEvent(QResizeEvent *e) {
void MainWindow::updateAdaptiveLayout() {
title->updateAdaptiveLayout();
if (main) main->updateAdaptiveLayout();
if (settings) settings->updateAdaptiveLayout();
if (intro) intro->updateAdaptiveLayout();
if (layerBg) layerBg->updateAdaptiveLayout();
}
bool MainWindow::needBackButton() {
return !!settings;
}
MainWindow::TempDirState MainWindow::tempDirState() {
if (_clearManager && _clearManager->hasTask(Local::ClearManagerDownloads)) {
return TempDirRemoving;
@ -1883,13 +1837,9 @@ QImage MainWindow::iconWithCounter(int size, int count, style::color bg, bool sm
void MainWindow::sendPaths() {
if (App::passcoded()) return;
hideMediaview();
if (settings) {
hideSettings();
} else {
Ui::hideLayer();
if (main) {
main->activate();
}
Ui::hideSettingsAndLayer();
if (main) {
main->activate();
}
}

View File

@ -30,12 +30,14 @@ class TitleWidget;
class PasscodeWidget;
class IntroWidget;
class MainWidget;
class SettingsWidget;
class LayerStackWidget;
class LayerWidget;
namespace Local {
class ClearManager;
} // namespace Local
namespace Settings {
class Widget;
} // namespace Settings
class ConnectingWidget : public QWidget {
Q_OBJECT
@ -150,7 +152,6 @@ public:
void resizeEvent(QResizeEvent *e);
void updateAdaptiveLayout();
bool needBackButton();
void setupPasscode(bool anim);
void clearPasscode();
@ -173,7 +174,6 @@ public:
IntroWidget *introWidget();
MainWidget *mainWidget();
SettingsWidget *settingsWidget();
PasscodeWidget *passcodeWidget();
void showConnecting(const QString &text, const QString &reconnect = QString());
@ -190,7 +190,6 @@ public:
void activate();
void noIntro(IntroWidget *was);
void noSettings(SettingsWidget *was);
void noMain(MainWidget *was);
void noLayerStack(LayerStackWidget *was);
void layerFinishedHide(LayerStackWidget *was);
@ -241,6 +240,7 @@ public:
}
void ui_showLayer(LayerWidget *box, ShowLayerOptions options);
void ui_hideSettingsAndLayer(ShowLayerOptions options);
bool ui_isLayerShown();
bool ui_isMediaViewShown();
void ui_showMediaPreview(DocumentData *document);
@ -256,7 +256,6 @@ public slots:
void checkAutoLock();
void showSettings();
void hideSettings(bool fast = false);
void layerHidden();
void setInnerFocus();
void updateTitleStatus();
@ -298,6 +297,7 @@ signals:
private slots:
void onStateChanged(Qt::WindowState state);
void onSettingsDestroyed(QObject *was);
private:
@ -316,7 +316,7 @@ private:
PasscodeWidget *_passcode = nullptr;
IntroWidget *intro = nullptr;
MainWidget *main = nullptr;
SettingsWidget *settings = nullptr;
ChildWidget<Settings::Widget> settings = { nullptr };
ChildWidget<LayerStackWidget> layerBg = { nullptr };
std_::unique_ptr<MediaPreviewWidget> _mediaPreview;

View File

@ -53,6 +53,7 @@ ObservedEventRegistrator<PeerUpdate::Flags, PeerUpdateHandler> creator(StartCall
namespace internal {
ConnectionId plainRegisterPeerObserver(PeerUpdate::Flags events, PeerUpdateHandler &&handler) {
constexpr auto tmp = sizeof(PeerUpdate);
return creator.registerObserver(events, std_::forward<PeerUpdateHandler>(handler));
}

View File

@ -53,7 +53,6 @@ void MacPrivate::notifyClicked(unsigned long long peer, int msgid) {
App::wnd()->setInnerFocus();
App::wnd()->notifyClear();
} else {
App::wnd()->hideSettings();
bool tomsg = !history->peer->isUser() && (msgid > 0);
if (tomsg) {
HistoryItem *item = App::histItemById(peerToChannel(PeerId(peer)), MsgId(msgid));

View File

@ -331,7 +331,6 @@ public:
App::wnd()->setInnerFocus();
App::wnd()->notifyClear();
} else {
App::wnd()->hideSettings();
bool tomsg = !history->peer->isUser() && (_msgId > 0);
if (tomsg) {
HistoryItem *item = App::histItemById(peerToChannel(_peerId), _msgId);

View File

@ -84,7 +84,7 @@ void InnerWidget::setVisibleTopBottom(int visibleTop, int visibleBottom) {
decreaseAdditionalHeight(notDisplayedAtBottom);
}
for_const (auto blockData, _blocks) {
for_const (auto &blockData, _blocks) {
int blockY = blockData.block->y();
blockData.block->setVisibleTopBottom(visibleTop - blockY, visibleBottom - blockY);
}

View File

@ -105,8 +105,7 @@ void Widget::resizeEvent(QResizeEvent *e) {
QSize scrollSize(width(), height() - _fixedBar->height());
if (_scroll->size() != scrollSize) {
_scroll->resize(scrollSize);
// _inner->resizeToWidth(scrollSize.width(), _scroll->height());
_inner->resizeToWidth(scrollSize.width(), _scroll->height() * 2); // testing
_inner->resizeToWidth(scrollSize.width(), _scroll->height());
}
_fixedBar->setHideShareContactButton(_inner->shareContactButtonShown());

View File

@ -21,3 +21,32 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
using "basic.style";
using "basic_types.style";
settingsMaxWidth: 520px;
settingsMaxPadding: 48px;
settingsMinPadding: 32px;
settingsMargin: 48px;
settingsFixedBarHeight: 52px;
settingsFixedBarFont: font(14px semibold);
settingsFixedBarFg: windowTextFg;
settingsFixedBarTextLeft: 20px;
settingsFixedBarTextTop: 16px;
settingsFixedBarClose: IconButton {
width: settingsFixedBarHeight;
height: settingsFixedBarHeight;
opacity: 0.31;
overOpacity: 0.5;
icon: icon {
{ "settings_close", #000000, point(0px, 0px) },
};
iconPosition: point(20px, 20px);
downIconPosition: point(20px, 20px);
duration: 200;
}
settingsFixedBarShadowBg1: #00000021;
settingsFixedBarShadowBg2: #0000000b;
settingsPhotoLeft: -8px;

View File

@ -0,0 +1,54 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#include "stdafx.h"
#include "settings/settings_fixed_bar.h"
#include "styles/style_settings.h"
#include "ui/buttons/icon_button.h"
#include "mainwindow.h"
#include "lang.h"
namespace Settings {
FixedBar::FixedBar(QWidget *parent) : TWidget(parent)
, _close(this, st::settingsFixedBarClose) {
_close->setClickedCallback([]() {
Ui::hideSettingsAndLayer();
});
}
void FixedBar::resizeToWidth(int newWidth) {
resize(newWidth, st::settingsFixedBarHeight);
}
void FixedBar::resizeEvent(QResizeEvent *e) {
_close->moveToRight(0, 0);
}
void FixedBar::paintEvent(QPaintEvent *e) {
Painter p(this);
p.setFont(st::settingsFixedBarFont);
p.setPen(st::windowTextFg);
p.drawTextLeft(st::settingsFixedBarTextLeft, st::settingsFixedBarTextTop, width(), lang(lng_menu_settings));
}
} // namespace Settings

View File

@ -0,0 +1,44 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
namespace Ui {
class IconButton;
} // namespace Ui
namespace Settings {
class FixedBar : public TWidget {
public:
FixedBar(QWidget *parent);
void resizeToWidth(int newWidth);
protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
private:
ChildWidget<Ui::IconButton> _close;
};
} // namespace Settings

View File

@ -0,0 +1,60 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#include "stdafx.h"
#include "settings/settings_inner_widget.h"
namespace Settings {
InnerWidget::InnerWidget(QWidget *parent) : TWidget(parent)
{
}
void InnerWidget::resizeToWidth(int newWidth, int contentLeft) {
int newHeight = resizeGetHeight(newWidth, contentLeft);
resize(newWidth, newHeight);
}
int InnerWidget::resizeGetHeight(int newWidth, int contentLeft) {
int result = 0;
//if (_cover) {
// result += _cover->height();
//}
//for_const (auto blockData, _blocks) {
// if (blockData->isHidden()) {
// continue;
// }
// result += blockData->height();
//}
return result;
}
void InnerWidget::setVisibleTopBottom(int visibleTop, int visibleBottom) {
_visibleTop = visibleTop;
_visibleBottom = visibleBottom;
//for_const (auto blockData, _blocks) {
// int blockY = blockData->y();
// blockData->setVisibleTopBottom(visibleTop - blockY, visibleBottom - blockY);
//}
}
} // namespace Settings

View File

@ -0,0 +1,50 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
namespace Settings {
class CoverWidget;
class BlockWidget;
class InnerWidget : public TWidget {
public:
InnerWidget(QWidget *parent);
// Count new height for width=newWidth and resize to it.
void resizeToWidth(int newWidth, int contentLeft);
// Updates the area that is visible inside the scroll container.
void setVisibleTopBottom(int visibleTop, int visibleBottom);
private:
// Resizes content and counts natural widget height for the desired width.
int resizeGetHeight(int newWidth, int contentLeft);
ChildWidget<CoverWidget> _cover = { nullptr };
QList<BlockWidget*> _blocks;
int _visibleTop = 0;
int _visibleBottom = 0;
};
} // namespace Settings

View File

@ -21,6 +21,92 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "stdafx.h"
#include "settings/settings_widget.h"
#include "settings/settings_inner_widget.h"
#include "settings/settings_fixed_bar.h"
#include "styles/style_settings.h"
#include "ui/scrollarea.h"
#include "mainwindow.h"
namespace Settings {
Widget::Widget() : LayerWidget()
, _scroll(this, st::setScroll)
, _inner(this)
, _fixedBar(this)
, _fixedBarShadow1(this, st::settingsFixedBarShadowBg1)
, _fixedBarShadow2(this, st::settingsFixedBarShadowBg2) {
_scroll->setOwnedWidget(_inner);
setAttribute(Qt::WA_OpaquePaintEvent);
_fixedBar->move(0, 0);
_fixedBarShadow1->move(0, _fixedBar->y() + st::settingsFixedBarHeight);
_fixedBarShadow2->move(0, _fixedBarShadow1->y() + st::lineWidth);
}
void Widget::parentResized() {
int windowWidth = App::wnd()->width();
int newWidth = st::settingsMaxWidth;
int newContentLeft = st::settingsMaxPadding;
if (windowWidth <= st::settingsMaxWidth) {
newWidth = windowWidth;
newContentLeft = st::settingsMinPadding;
if (windowWidth > st::wndMinWidth) {
// Width changes from st::wndMinWidth to st::settingsMaxWidth.
// Padding changes from st::settingsMinPadding to st::settingsMaxPadding.
newContentLeft += ((newWidth - st::wndMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::wndMinWidth);
}
} else if (windowWidth < st::settingsMaxWidth + 2 * st::settingsMargin) {
newWidth = windowWidth - 2 * st::settingsMargin;
newContentLeft = st::settingsMinPadding;
if (windowWidth > st::wndMinWidth) {
// Width changes from st::wndMinWidth to st::settingsMaxWidth.
// Padding changes from st::settingsMinPadding to st::settingsMaxPadding.
newContentLeft += ((newWidth - st::wndMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::wndMinWidth);
}
}
// Widget height depends on InnerWidget height, so we
// resize it here, not in the resizeEvent() handler.
_inner->resizeToWidth(newWidth, newContentLeft);
int windowHeight = App::wnd()->height();
int maxHeight = st::settingsFixedBarHeight + _inner->height();
int newHeight = maxHeight;
if (newHeight > windowHeight || newWidth >= windowWidth) {
newHeight = windowHeight;
}
if (_contentLeft != newContentLeft) {
_contentLeft = newContentLeft;
}
setGeometry((App::wnd()->width() - newWidth) / 2, (App::wnd()->height() - newHeight) / 2, newWidth, newHeight);
update();
}
void Widget::paintEvent(QPaintEvent *e) {
Painter p(this);
p.fillRect(rect(), st::windowBg);
}
void Widget::resizeEvent(QResizeEvent *e) {
if (!width() || !height()) {
return;
}
_fixedBar->resizeToWidth(width());
_fixedBarShadow1->resize(width(), st::lineWidth);
_fixedBarShadow2->resize(width(), st::lineWidth);
QSize scrollSize(width(), height() - _fixedBar->height());
if (_scroll->size() != scrollSize) {
_scroll->resize(scrollSize);
}
if (!_scroll->isHidden()) {
int scrollTop = _scroll->scrollTop();
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
}
}
} // namespace Settings

View File

@ -20,6 +20,31 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "layerwidget.h"
namespace Settings {
class InnerWidget;
class FixedBar;
class Widget : public LayerWidget {
public:
Widget();
void parentResized() override;
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:
ChildWidget<ScrollArea> _scroll;
ChildWidget<InnerWidget> _inner;
ChildWidget<FixedBar> _fixedBar;
ChildWidget<PlainShadow> _fixedBarShadow1, _fixedBarShadow2;
int _contentLeft = 0;
};
} // namespace Settings

View File

@ -208,6 +208,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
, _logOut(this, lang(lng_settings_logout), st::btnRedLink)
, _supportGetRequest(0) {
Notify::registerPeerObserver(Notify::PeerUpdate::Flag::UsernameChanged, this, &SettingsInner::notifyPeerUpdated);
registerDownloadPathObserver(this, &SettingsInner::notifyDownloadPathUpdated);
App::clearMousedItems();
@ -367,6 +368,19 @@ void SettingsInner::notifyPeerUpdated(const Notify::PeerUpdate &update) {
}
}
void SettingsInner::notifyDownloadPathUpdated(const DownloadPathUpdate &update) {
QString path;
if (cDownloadPath().isEmpty()) {
path = lang(lng_download_path_default);
} else if (cDownloadPath() == qsl("tmp")) {
path = lang(lng_download_path_temp);
} else {
path = st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::setVersionLeft - _downloadPathWidth);
}
_downloadPathEdit.setText(path);
showAll();
}
void SettingsInner::peerUpdated(PeerData *data) {
if (self() && data == self()) {
if (self()->photoId && self()->photoId != UnknownPeerPhotoId) {
@ -1208,10 +1222,9 @@ void SettingsInner::supportGot(const MTPhelp_Support &support) {
if (!App::main()) return;
if (support.type() == mtpc_help_support) {
const auto &d(support.c_help_support());
auto &d = support.c_help_support();
UserData *u = App::feedUsers(MTP_vector<MTPUser>(1, d.vuser));
Ui::showPeerHistory(u, ShowAtUnreadMsgId);
App::wnd()->hideSettings();
}
}
@ -1637,6 +1650,10 @@ void SettingsInner::onCtrlEnterSend() {
void SettingsInner::onBackFromGallery() {
BackgroundBox *box = new BackgroundBox();
box->setUpdateCallback([this, weak_this = weakThis()](bool tile) {
if (!weak_this) return;
needBackgroundUpdate(tile);
});
Ui::showLayer(box);
}
@ -1774,22 +1791,7 @@ void SettingsInner::onDontAskDownloadPath() {
}
void SettingsInner::onDownloadPathEdit() {
DownloadPathBox *box = new DownloadPathBox();
connect(box, SIGNAL(closed(LayerWidget*)), this, SLOT(onDownloadPathEdited()));
Ui::showLayer(box);
}
void SettingsInner::onDownloadPathEdited() {
QString path;
if (cDownloadPath().isEmpty()) {
path = lang(lng_download_path_default);
} else if (cDownloadPath() == qsl("tmp")) {
path = lang(lng_download_path_temp);
} else {
path = st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::setVersionLeft - _downloadPathWidth);
}
_downloadPathEdit.setText(path);
showAll();
Ui::showLayer(new DownloadPathBox());
}
void SettingsInner::onDownloadPathClear() {
@ -2063,5 +2065,4 @@ void SettingsWidget::needBackgroundUpdate(bool tile) {
}
SettingsWidget::~SettingsWidget() {
if (App::wnd()) App::wnd()->noSettings(this);
}

View File

@ -24,6 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/flatcheckbox.h"
#include "sysbuttons.h"
#include "core/observer.h"
#include "boxes/downloadpathbox.h"
class MainWindow;
@ -151,7 +152,6 @@ public slots:
void onDontAskDownloadPath();
void onDownloadPathEdit();
void onDownloadPathEdited();
void onDownloadPathClear();
void onDownloadPathClearSure();
void onTempDirCleared(int task);
@ -194,6 +194,7 @@ private slots:
private:
void notifyPeerUpdated(const Notify::PeerUpdate &update);
void notifyDownloadPathUpdated(const DownloadPathUpdate &update);
void saveError(const QString &str = QString());

View File

@ -52,7 +52,6 @@ TitleWidget::TitleWidget(MainWindow *window) : TWidget(window)
, wnd(window)
, hideLevel(0)
, hider(0)
, _back(this, st::titleBackButton, lang(lng_menu_back))
, _cancel(this, lang(lng_cancel), st::titleTextButton)
, _settings(this, lang(lng_menu_settings), st::titleTextButton)
, _contacts(this, lang(lng_menu_contacts), st::titleTextButton)
@ -64,14 +63,12 @@ TitleWidget::TitleWidget(MainWindow *window) : TWidget(window)
, _restore(this, window)
, _close(this, window)
, _a_update(animation(this, &TitleWidget::step_update))
, lastMaximized(!(window->windowState() & Qt::WindowMaximized))
{
, lastMaximized(!(window->windowState() & Qt::WindowMaximized)) {
setGeometry(0, 0, wnd->width(), st::titleHeight);
setAttribute(Qt::WA_OpaquePaintEvent);
_lock.hide();
_update.hide();
_cancel.hide();
_back.hide();
if (
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
Sandbox::updatingState() == Application::UpdatingReady ||
@ -82,7 +79,6 @@ TitleWidget::TitleWidget(MainWindow *window) : TWidget(window)
}
onWindowStateChanged();
connect(&_back, SIGNAL(clicked()), window, SLOT(hideSettings()));
connect(&_cancel, SIGNAL(clicked()), this, SIGNAL(hiderClicked()));
connect(&_settings, SIGNAL(clicked()), window, SLOT(showSettings()));
connect(&_contacts, SIGNAL(clicked()), this, SLOT(onContacts()));
@ -193,9 +189,7 @@ void TitleWidget::resizeEvent(QResizeEvent *e) {
}
_settings.move(st::titleMenuOffset, 0);
_back.move(st::titleMenuOffset, 0);
_back.resize((_minimize.isHidden() ? (_update.isHidden() ? width() : _update.x()) : _minimize.x()) - st::titleMenuOffset, _back.height());
if (MTP::authedId() && _back.isHidden() && _cancel.isHidden() && !App::passcoded()) {
if (MTP::authedId() && _cancel.isHidden() && !App::passcoded()) {
if (_contacts.isHidden()) _contacts.show();
_contacts.move(_settings.x() + _settings.width(), 0);
_about.move(_contacts.x() + _contacts.width(), 0);
@ -210,7 +204,6 @@ void TitleWidget::resizeEvent(QResizeEvent *e) {
void TitleWidget::updateBackButton() {
if (App::passcoded()) {
if (!_cancel.isHidden()) _cancel.hide();
if (!_back.isHidden()) _back.hide();
if (!_settings.isHidden()) _settings.hide();
if (!_contacts.isHidden()) _contacts.hide();
if (!_about.isHidden()) _about.hide();
@ -219,7 +212,6 @@ void TitleWidget::updateBackButton() {
_lock.setSysBtnStyle(st::sysLock);
if (Adaptive::OneColumn() && App::main() && App::main()->selectingPeer()) {
_cancel.show();
if (!_back.isHidden()) _back.hide();
if (!_settings.isHidden()) _settings.hide();
if (!_contacts.isHidden()) _contacts.hide();
if (!_about.isHidden()) _about.hide();
@ -227,19 +219,10 @@ void TitleWidget::updateBackButton() {
if (!_cancel.isHidden()) _cancel.hide();
bool authed = (MTP::authedId() > 0);
if (Adaptive::OneColumn()) {
if (App::wnd()->needBackButton()) {
if (_back.isHidden()) _back.show();
if (!_settings.isHidden()) _settings.hide();
if (!_contacts.isHidden()) _contacts.hide();
if (!_about.isHidden()) _about.hide();
} else {
if (!_back.isHidden()) _back.hide();
if (_settings.isHidden()) _settings.show();
if (authed && _contacts.isHidden()) _contacts.show();
if (_about.isHidden()) _about.show();
}
if (_settings.isHidden()) _settings.show();
if (authed && _contacts.isHidden()) _contacts.show();
if (_about.isHidden()) _about.show();
} else {
if (!_back.isHidden()) _back.hide();
if (_settings.isHidden()) _settings.show();
if (authed && _contacts.isHidden()) _contacts.show();
if (_about.isHidden()) _about.show();
@ -393,7 +376,6 @@ HitTestType TitleWidget::hitTest(const QPoint &p) {
return HitTestSysButton;
} else if (x >= 0 && x < w && y >= 0 && y < h) {
if (false
|| (!_back.isHidden() && _back.geometry().contains(x, y))
|| (!_cancel.isHidden() && _cancel.geometry().contains(x, y))
|| (!_settings.isHidden() && _settings.geometry().contains(x, y))
|| (!_contacts.isHidden() && _contacts.geometry().contains(x, y))

View File

@ -87,7 +87,6 @@ private:
float64 _lastUpdateMs;
MaskedButton _back;
FlatButton _cancel, _settings, _contacts, _about;
LockBtn _lock;

View File

@ -74,6 +74,9 @@ void Button::mouseReleaseEvent(QMouseEvent *e) {
onStateChanged(oldState, ButtonByPress);
if (oldState & StateOver) {
_modifiers = e->modifiers();
if (_clickedCallback) {
_clickedCallback();
}
emit clicked();
} else {
leaveEvent(e);

View File

@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include <QtWidgets/QWidget>
#include "ui/twidget.h"
#include "core/lambda_wrap.h"
typedef enum {
ButtonByUser = 0x00, // by clearState() call
@ -42,17 +43,10 @@ public:
StateDisabled = 0x04,
};
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
Qt::KeyboardModifiers clickModifiers() const {
return _modifiers;
}
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
void clearState();
int getState() const;
@ -64,8 +58,18 @@ public:
void setAcceptBoth(bool acceptBoth = true);
signals:
void setClickedCallback(base::lambda_unique<void()> &&callback) {
_clickedCallback = std_::move(callback);
}
protected:
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
signals:
void clicked();
void stateChanged(int oldState, ButtonStateChangeSource source);
@ -77,4 +81,6 @@ protected:
int _state;
bool _acceptBoth;
base::lambda_unique<void()> _clickedCallback;
};

View File

@ -373,7 +373,7 @@ bool processQuery() {
} break;
}
// No one know what happened during filedialogGet*() call in the event loop.
// No one knows what happened during filedialogGet*() call in the event loop.
if (!creator.started() || !Global::started()) return false;
creator.notify(update);

View File

@ -331,6 +331,10 @@
'<(src_loc)/serialize/serialize_common.h',
'<(src_loc)/serialize/serialize_document.cpp',
'<(src_loc)/serialize/serialize_document.h',
'<(src_loc)/settings/settings_fixed_bar.cpp',
'<(src_loc)/settings/settings_fixed_bar.h',
'<(src_loc)/settings/settings_inner_widget.cpp',
'<(src_loc)/settings/settings_inner_widget.h',
'<(src_loc)/settings/settings_widget.cpp',
'<(src_loc)/settings/settings_widget.h',
'<(src_loc)/ui/buttons/history_down_button.cpp',