Removed blue window title, new small title used only in Windows.
|
@ -34,17 +34,6 @@ emojiPadding: 0px;
|
|||
|
||||
lineWidth: 1px;
|
||||
|
||||
wndMinWidth: 380px;
|
||||
|
||||
adaptiveNormalWidth: 640px;
|
||||
adaptiveWideWidth: 1366px;
|
||||
|
||||
wndMinHeight: 480px;
|
||||
wndDefWidth: 800px;
|
||||
wndDefHeight: 600px;
|
||||
wndShadow: icon {{ "window_shadow", windowShadowFg }};
|
||||
wndShadowShift: 1px;
|
||||
|
||||
labelDefFlat: flatLabel {
|
||||
font: font(fsize);
|
||||
width: 0px;
|
||||
|
@ -277,20 +266,11 @@ boxScroll: flatScroll(solidScroll) {
|
|||
boxScrollSkip: 6px;
|
||||
boxScrollShadowBg: #00000012;
|
||||
|
||||
titleHeight: 39px;
|
||||
titleFont: font(17px);
|
||||
titlePos: point(44px, 29px);
|
||||
titleMenuOffset: 36px;
|
||||
|
||||
titleRed: #ee4928;
|
||||
titleGray: #777777;
|
||||
titleGreen: #41a903;
|
||||
|
||||
titleStatusFg: #999999;
|
||||
titleStatusActiveFg: #0080c0;
|
||||
titleTypingFg: #0080c0;
|
||||
|
||||
statusFont: font(fsize);
|
||||
statusFg: #999999;
|
||||
statusFgActive: #0080c0;
|
||||
statusFgTyping: statusFgActive;
|
||||
|
||||
versionColor: #777777;
|
||||
|
||||
shadowColor: #00000018;
|
||||
|
@ -302,63 +282,11 @@ slideFadeOutBg: #0000003c;
|
|||
slideShadow: icon {{ "slide_shadow", #000000 }};
|
||||
slideFunction: transition(easeOutCirc);
|
||||
|
||||
titleButtonFg: #c4d8e9;
|
||||
titleButtonActiveFg: #ffffff;
|
||||
titleButtonDuration: 150;
|
||||
sysBtnDelta: 6px;
|
||||
sysUpd: sysButton {
|
||||
size: size(31px, 39px);
|
||||
icon: icon {{ "title_button_update", titleBg }};
|
||||
color: titleButtonFg;
|
||||
overColor: titleButtonActiveFg;
|
||||
duration: titleButtonDuration;
|
||||
}
|
||||
updateBlinkDuration: 500;
|
||||
sysMin: sysButton(sysUpd) {
|
||||
icon: icon {{ "title_button_minimize", titleBg }};
|
||||
}
|
||||
sysMax: sysButton(sysUpd) {
|
||||
icon: icon {{ "title_button_maximize", titleBg }};
|
||||
}
|
||||
sysRes: sysButton(sysUpd) {
|
||||
icon: icon {{ "title_button_restore", titleBg }};
|
||||
}
|
||||
sysCls: sysButton(sysUpd) {
|
||||
icon: icon {{ "title_button_close", titleBg }};
|
||||
}
|
||||
sysLock: sysButton(sysUpd) {
|
||||
icon: icon {{ "title_button_lock", titleBg }};
|
||||
}
|
||||
sysUnlock: sysButton(sysUpd) {
|
||||
icon: icon {{ "title_button_unlock", titleBg }};
|
||||
}
|
||||
|
||||
btnYesColor: #0080c0;
|
||||
btnYesHover: #0073ad;
|
||||
btnNoColor: #8b8b8b;
|
||||
btnNoHover: #777777;
|
||||
|
||||
titleTextButton: flatButton {
|
||||
color: #d4e3ef;
|
||||
overColor: #ffffff;
|
||||
downColor: #ffffff;
|
||||
bgColor: transparent;
|
||||
overBgColor: transparent;
|
||||
downBgColor: transparent;
|
||||
|
||||
width: -14px;
|
||||
height: 39px;
|
||||
|
||||
textTop: 10px;
|
||||
overTextTop: 10px;
|
||||
downTextTop: 11px;
|
||||
|
||||
font: font(fsize);
|
||||
overFont: font(fsize);
|
||||
duration: 150;
|
||||
cursor: cursor(default);
|
||||
}
|
||||
|
||||
linkCropLimit: 360px;
|
||||
linkFont: normalFont;
|
||||
linkOverFont: font(fsize underline);
|
||||
|
@ -919,8 +847,8 @@ confirmCompressedSkip: 10px;
|
|||
profileMaxWidth: 410px;
|
||||
profilePadding: margins(28px, 30px, 28px, 0px);
|
||||
|
||||
profileOnlineFg: titleStatusActiveFg;
|
||||
profileOfflineFg: titleStatusFg;
|
||||
profileOnlineFg: statusFgActive;
|
||||
profileOfflineFg: statusFg;
|
||||
|
||||
membersPadding: margins(0px, 10px, 0px, 10px);
|
||||
|
||||
|
@ -1064,17 +992,6 @@ medviewSaveMsgHiding: 2500;
|
|||
medviewSaveMsgFg: #ffffff;
|
||||
medviewSaveMsg: #000000b2;
|
||||
|
||||
// Mac specific
|
||||
|
||||
macAccessoryWidth: 450.;
|
||||
macAccessoryHeight: 90.;
|
||||
macEnableFilterAdd: 2;
|
||||
macEnableFilterTop: 5;
|
||||
macSelectorTop: 6;
|
||||
macAlwaysThisAppTop: 4;
|
||||
macAppHintTop: 8;
|
||||
macCautionIconSize: 16;
|
||||
|
||||
radialSize: size(50px, 50px);
|
||||
radialLine: 3px;
|
||||
radialDuration: 350;
|
||||
|
@ -1191,9 +1108,9 @@ infoButton: PeerAvatarButton {
|
|||
profileTopBarBackIconFg: #0290d7;
|
||||
profileTopBarBackIcon: icon {{ "title_previous", profileTopBarBackIconFg }};
|
||||
|
||||
historyReplyCancelIcon: icon {{ "box_button_close", historyReplyBg }};
|
||||
boxSearchCancelIcon: icon {{ "box_button_close", boxSearchBg }};
|
||||
settingsFixedBarCloseIcon: icon {{ "box_button_close", settingsFixedBarBg }};
|
||||
historyReplyCancelIcon: icon {{ "box_button_close-invert", historyReplyBg }};
|
||||
boxSearchCancelIcon: icon {{ "box_button_close-invert", boxSearchBg }};
|
||||
settingsFixedBarCloseIcon: icon {{ "box_button_close-invert", settingsFixedBarBg }};
|
||||
|
||||
notifyFadeRight: icon {{ "fade_horizontal_right", notificationBg }};
|
||||
|
||||
|
|
|
@ -38,14 +38,6 @@ linkButton {
|
|||
overFont: font;
|
||||
}
|
||||
|
||||
sysButton {
|
||||
size: size;
|
||||
icon: icon;
|
||||
color: color;
|
||||
overColor: color;
|
||||
duration: int;
|
||||
}
|
||||
|
||||
flatButton {
|
||||
color: color;
|
||||
overColor: color;
|
||||
|
|
|
@ -29,11 +29,18 @@ windowSubTextFgOver: #7c99b2; // gray over light blue: fallback for subtext over
|
|||
windowActiveTextFg: #1485c2; // online blue: fallback for active color
|
||||
windowShadowFg: #000000; // black: fallback for shadow color
|
||||
|
||||
titleBg: #6389a8;
|
||||
|
||||
imageBg: #000000;
|
||||
imageBgTransparent: #ffffff;
|
||||
|
||||
// custom title bar for Windows
|
||||
titleBg: #f3f3f3;
|
||||
titleShadow: #00000003;
|
||||
titleButtonFg: #ababab;
|
||||
titleButtonBgOver: #e5e5e5;
|
||||
titleButtonFgOver: #9a9a9a;
|
||||
titleButtonCloseBgOver: #e81123;
|
||||
titleButtonCloseFgOver: #ffffff;
|
||||
|
||||
// tray icon
|
||||
trayCounterBg: #f23c34;
|
||||
trayCounterBgMute: #888888;
|
||||
|
@ -56,11 +63,6 @@ lightButtonBgOver: #f2f7fa | lightButtonBg;
|
|||
lightButtonFg: #2b99d5;
|
||||
lightButtonFgOver: lightButtonFg;
|
||||
|
||||
// window title
|
||||
titleCounterBg: trayCounterBg;
|
||||
titleCounterBgMute: trayCounterBgMute;
|
||||
titleCounterFg: trayCounterFg;
|
||||
|
||||
// layers
|
||||
layerBg: #0000007f;
|
||||
|
||||
|
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 122 B |
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 160 B |
Before Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 701 B |
|
@ -29,9 +29,15 @@ windowOverBg: #edf2f5;
|
|||
windowSubTextFgOver: #7c99b2;
|
||||
windowActiveTextFg: #1485c2;
|
||||
windowShadowFg: #000000;
|
||||
titleBg: #6389a8;
|
||||
imageBg: #000000;
|
||||
imageBgTransparent: #ffffff;
|
||||
titleBg: #f3f3f3;
|
||||
titleShadow: #00000003;
|
||||
titleButtonFg: #ababab;
|
||||
titleButtonBgOver: #e5e5e5;
|
||||
titleButtonFgOver: #9a9a9a;
|
||||
titleButtonCloseBgOver: #e81123;
|
||||
titleButtonCloseFgOver: #ffffff;
|
||||
trayCounterBg: #f23c34;
|
||||
trayCounterBgMute: #888888;
|
||||
trayCounterFg: #ffffff;
|
||||
|
@ -49,9 +55,6 @@ lightButtonBg: windowBg;
|
|||
lightButtonBgOver: #f2f7fa; // lightButtonBg;
|
||||
lightButtonFg: #2b99d5;
|
||||
lightButtonFgOver: lightButtonFg;
|
||||
titleCounterBg: trayCounterBg;
|
||||
titleCounterBgMute: trayCounterBgMute;
|
||||
titleCounterFg: trayCounterFg;
|
||||
layerBg: #0000007f;
|
||||
boxBg: windowBg;
|
||||
boxTextFg: windowTextFg;
|
||||
|
|
|
@ -214,7 +214,6 @@ namespace {
|
|||
clearStorageImages();
|
||||
if (auto w = wnd()) {
|
||||
w->updateConnectingStatus();
|
||||
w->getTitle()->updateControlsVisibility();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ boxBlueClose: MaskButton(defaultMaskButton) {
|
|||
iconBg: #c8e1f0;
|
||||
iconBgOver: #ffffff;
|
||||
|
||||
icon: icon {{ "box_button_close", boxBlueTitleBg }};
|
||||
icon: icon {{ "box_button_close-invert", boxBlueTitleBg }};
|
||||
}
|
||||
|
||||
confirmInviteTitle: flatLabel(labelDefFlat) {
|
||||
|
@ -198,7 +198,7 @@ notificationsBoxMonitorTop: 63px;
|
|||
notificationsBoxMonitor: icon {{ "monitor", notificationsBoxMonitorFg }};
|
||||
notificationsBoxScreenTop: 10px;
|
||||
notificationsBoxScreenSize: size(280px, 160px);
|
||||
notificationsBoxScreenBg: titleBg;
|
||||
notificationsBoxScreenBg: #6389a8;
|
||||
notificationsBoxCountLabelTop: 80px;
|
||||
notificationsBoxCountTop: 30px;
|
||||
|
||||
|
|
|
@ -405,7 +405,6 @@ void PasscodeBox::onSave(bool force) {
|
|||
cSetPasscodeBadTries(0);
|
||||
Local::setPasscode(pwd.toUtf8());
|
||||
App::wnd()->checkAutoLock();
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,4 +394,25 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class lambda_slot_wrap : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lambda_slot_wrap(QObject *parent, lambda_unique<void()> lambda) : QObject(parent), _lambda(std_::move(lambda)) {
|
||||
}
|
||||
|
||||
public slots:
|
||||
void action() {
|
||||
_lambda();
|
||||
}
|
||||
|
||||
private:
|
||||
lambda_unique<void()> _lambda;
|
||||
|
||||
};
|
||||
|
||||
inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda_unique<void()> lambda) {
|
||||
return new lambda_slot_wrap(parent, std_::move(lambda));
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
|
|
@ -38,7 +38,7 @@ inline bool skipWhitespaces(const char *&from, const char *end) {
|
|||
return (from != end);
|
||||
}
|
||||
|
||||
inline QByteArray readName(const char *&from, const char *end) {
|
||||
inline QLatin1String readName(const char *&from, const char *end) {
|
||||
t_assert(from <= end);
|
||||
auto start = from;
|
||||
while (from != end && (
|
||||
|
@ -48,7 +48,7 @@ inline QByteArray readName(const char *&from, const char *end) {
|
|||
(*from == '_'))) {
|
||||
++from;
|
||||
}
|
||||
return QByteArray::fromRawData(start, from - start);
|
||||
return QLatin1String(start, from - start);
|
||||
}
|
||||
|
||||
} // namespace parse
|
||||
|
|
|
@ -36,6 +36,8 @@ historyToDownPaddingTop: 10px;
|
|||
historyToDownBadgeFont: semiboldFont;
|
||||
historyToDownBadgeSize: 22px;
|
||||
|
||||
historyToDownShownAfter: 480px;
|
||||
|
||||
historyEmptyDog: icon {{ "history_empty_dog", #ffffff }};
|
||||
historyEmptySize: 128px;
|
||||
|
||||
|
|
|
@ -2701,7 +2701,6 @@ HistoryHider::HistoryHider(MainWidget *parent, const QString &url, const QString
|
|||
void HistoryHider::init() {
|
||||
connect(&_send, SIGNAL(clicked()), this, SLOT(forward()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(startHide()));
|
||||
connect(App::wnd()->getTitle(), SIGNAL(hiderClicked()), this, SLOT(startHide()));
|
||||
|
||||
_chooseWidth = st::forwardFont->width(lang(_botAndQuery.isEmpty() ? lng_forward_choose : lng_inline_switch_choose));
|
||||
|
||||
|
@ -2720,7 +2719,6 @@ void HistoryHider::step_appearance(float64 ms, bool timer) {
|
|||
} else {
|
||||
a_opacity.update(dt, anim::linear);
|
||||
}
|
||||
App::wnd()->getTitle()->setHideLevel(a_opacity.current());
|
||||
if (timer) update();
|
||||
}
|
||||
|
||||
|
@ -2746,7 +2744,7 @@ void HistoryHider::paintEvent(QPaintEvent *e) {
|
|||
_toText.drawElided(p, _box.left() + st::boxPadding.left(), _box.top() + st::boxPadding.top(), _toTextWidth + 2);
|
||||
} else {
|
||||
int32 w = st::forwardMargins.left() + _chooseWidth + st::forwardMargins.right(), h = st::forwardMargins.top() + st::forwardFont->height + st::forwardMargins.bottom();
|
||||
App::roundRect(p, (width() - w) / 2, (height() - st::titleHeight - h) / 2, w, h, st::forwardBg, ForwardCorners);
|
||||
App::roundRect(p, (width() - w) / 2, (height() - h) / 2, w, h, st::forwardBg, ForwardCorners);
|
||||
|
||||
p.setPen(st::forwardFg);
|
||||
p.drawText(_box, lang(_botAndQuery.isEmpty() ? lng_forward_choose : lng_inline_switch_choose), QTextOption(style::al_center));
|
||||
|
@ -2835,7 +2833,7 @@ void HistoryHider::resizeEvent(QResizeEvent *e) {
|
|||
_send.hide();
|
||||
_cancel.hide();
|
||||
}
|
||||
_box = QRect((width() - w) / 2, (height() - st::titleHeight - h) / 2, w, h);
|
||||
_box = QRect((width() - w) / 2, (height() - h) / 2, w, h);
|
||||
_send.moveToRight(width() - (_box.x() + _box.width()) + st::boxButtonPadding.right(), _box.y() + h - st::boxButtonPadding.bottom() - _send.height());
|
||||
_cancel.moveToRight(width() - (_box.x() + _box.width()) + st::boxButtonPadding.right() + _send.width() + st::boxButtonPadding.left(), _send.y());
|
||||
}
|
||||
|
@ -2909,7 +2907,6 @@ bool HistoryHider::wasOffered() const {
|
|||
|
||||
HistoryHider::~HistoryHider() {
|
||||
if (_sendPath) cSetSendPaths(QStringList());
|
||||
if (App::wnd()) App::wnd()->getTitle()->setHideLevel(0);
|
||||
parent()->noHider(this);
|
||||
}
|
||||
|
||||
|
@ -6269,10 +6266,10 @@ void HistoryWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth) {
|
|||
QRect rectForName(st::topBarArrowPadding.right() + increaseLeft, st::topBarArrowPadding.top(), width() - decreaseWidth - st::topBarArrowPadding.left() - st::topBarArrowPadding.right(), st::msgNameFont->height);
|
||||
p.setFont(st::dialogsTextFont);
|
||||
if (_history->typing.isEmpty() && _history->sendActions.isEmpty()) {
|
||||
p.setPen(_titlePeerTextOnline ? st::titleStatusActiveFg : st::titleStatusFg);
|
||||
p.setPen(_titlePeerTextOnline ? st::statusFgActive : st::statusFg);
|
||||
p.drawText(rectForName.x(), st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height + st::dialogsTextFont->ascent, _titlePeerText);
|
||||
} else {
|
||||
p.setPen(st::titleTypingFg);
|
||||
p.setPen(st::statusFgTyping);
|
||||
_history->typingText.drawElided(p, rectForName.x(), st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height, rectForName.width());
|
||||
}
|
||||
|
||||
|
@ -7394,7 +7391,7 @@ void HistoryWidget::updateToEndVisibility() {
|
|||
if (!_history->loadedAtBottom() || _replyReturn) {
|
||||
return true;
|
||||
}
|
||||
if (_scroll.scrollTop() + st::wndMinHeight < _scroll.scrollTopMax()) {
|
||||
if (_scroll.scrollTop() + st::historyToDownShownAfter < _scroll.scrollTopMax()) {
|
||||
return true;
|
||||
}
|
||||
if (haveUnreadBelowBottom(_history) || haveUnreadBelowBottom(_migrated)) {
|
||||
|
|
|
@ -40,8 +40,6 @@ IntroWidget::IntroWidget(QWidget *parent) : TWidget(parent)
|
|||
, _a_stage(animation(this, &IntroWidget::step_stage))
|
||||
, _a_show(animation(this, &IntroWidget::step_show))
|
||||
, _back(this, new Ui::IconButton(this, st::introBackButton), base::lambda_unique<void()>(), st::introSlideDuration) {
|
||||
setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));
|
||||
|
||||
_back->entity()->setClickedCallback([this] { onBack(); });
|
||||
_back->hideFast();
|
||||
|
||||
|
@ -52,8 +50,6 @@ IntroWidget::IntroWidget(QWidget *parent) : TWidget(parent)
|
|||
_stepHistory.push_back(new IntroStart(this));
|
||||
_back->raise();
|
||||
|
||||
connect(parent, SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&)));
|
||||
|
||||
show();
|
||||
setFocus();
|
||||
|
||||
|
@ -76,10 +72,6 @@ void IntroWidget::onChangeLang() {
|
|||
App::restart();
|
||||
}
|
||||
|
||||
void IntroWidget::onParentResize(const QSize &newSize) {
|
||||
resize(newSize);
|
||||
}
|
||||
|
||||
void IntroWidget::onStepSubmit() {
|
||||
step()->onSubmit();
|
||||
}
|
||||
|
@ -339,8 +331,8 @@ bool IntroWidget::codeByTelegram() const {
|
|||
}
|
||||
|
||||
void IntroWidget::resizeEvent(QResizeEvent *e) {
|
||||
QRect r(innerRect());
|
||||
for (IntroStep *step : _stepHistory) {
|
||||
auto r = innerRect();
|
||||
for (auto step : _stepHistory) {
|
||||
step->setGeometry(r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ public:
|
|||
public slots:
|
||||
void onStepSubmit();
|
||||
void onBack();
|
||||
void onParentResize(const QSize &newSize);
|
||||
void onChangeLang();
|
||||
|
||||
signals:
|
||||
|
|
|
@ -294,8 +294,7 @@ void LayerStackWidget::showLayer(LayerWidget *l) {
|
|||
void LayerStackWidget::showSpecialLayer(LayerWidget *l) {
|
||||
clearLayers();
|
||||
if (_specialLayer) {
|
||||
_specialLayer->hide();
|
||||
_specialLayer->deleteLater();
|
||||
_specialLayer.destroyDelayed();
|
||||
}
|
||||
_specialLayer = l;
|
||||
activateLayer(l);
|
||||
|
|
|
@ -26,6 +26,8 @@ class LayerWidget : public TWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using TWidget::TWidget;
|
||||
|
||||
virtual void parentResized() = 0;
|
||||
virtual void showDone() {
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ StackItemSection::StackItemSection(std_::unique_ptr<Window::SectionMemento> &&me
|
|||
StackItemSection::~StackItemSection() {
|
||||
}
|
||||
|
||||
MainWidget::MainWidget(MainWindow *window) : TWidget(window)
|
||||
MainWidget::MainWidget(QWidget *parent) : TWidget(parent)
|
||||
, _a_show(animation(this, &MainWidget::step_show))
|
||||
, _dialogsWidth(st::dialogsWidthMin)
|
||||
, _sideShadow(this, st::shadowColor)
|
||||
|
@ -78,13 +78,10 @@ MainWidget::MainWidget(MainWindow *window) : TWidget(window)
|
|||
, _playerPanel(this, Media::Player::Panel::Layout::Full)
|
||||
, _mediaType(this, st::historyAttachDropdownMenu)
|
||||
, _api(new ApiWrap(this)) {
|
||||
setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));
|
||||
|
||||
MTP::setGlobalDoneHandler(rpcDone(&MainWidget::updateReceived));
|
||||
_ptsWaiter.setRequesting(true);
|
||||
updateScrollColors();
|
||||
|
||||
connect(App::wnd(), SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&)));
|
||||
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
|
||||
connect(_history, SIGNAL(cancelled()), _dialogs, SLOT(activate()));
|
||||
connect(this, SIGNAL(peerPhotoChanged(PeerData*)), this, SIGNAL(dialogsUpdated()));
|
||||
|
@ -156,7 +153,6 @@ MainWidget::MainWidget(MainWindow *window) : TWidget(window)
|
|||
} else {
|
||||
_history->show();
|
||||
}
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
_topBar->hide();
|
||||
|
||||
orderWidgets();
|
||||
|
@ -614,7 +610,6 @@ void MainWidget::noHider(HistoryHider *destroyed) {
|
|||
_history->showAnimated(Window::SlideDirection::FromRight, animationParams);
|
||||
}
|
||||
}
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
} else {
|
||||
if (_forwardConfirm) {
|
||||
_forwardConfirm->deleteLater();
|
||||
|
@ -651,7 +646,6 @@ void MainWidget::hiderLayer(HistoryHider *h) {
|
|||
resizeEvent(0);
|
||||
_dialogs->showAnimated(Window::SlideDirection::FromLeft, animationParams);
|
||||
}
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
} else {
|
||||
_hider->show();
|
||||
resizeEvent(0);
|
||||
|
@ -1588,6 +1582,9 @@ void MainWidget::handleAudioUpdate(const AudioMsgId &audioId) {
|
|||
if (!_playerUsingPanel && !_player && Media::Player::exists()) {
|
||||
createPlayer();
|
||||
}
|
||||
} else if (_player && _player->isHidden() && !_playerUsingPanel) {
|
||||
_player.destroyDelayed();
|
||||
_playerVolume.destroyDelayed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1632,8 +1629,12 @@ void MainWidget::switchToFixedPlayer() {
|
|||
}
|
||||
|
||||
void MainWidget::closeBothPlayers() {
|
||||
if (_playerUsingPanel) {
|
||||
_playerUsingPanel = false;
|
||||
_player.destroyDelayed();
|
||||
} else {
|
||||
_player->slideUp();
|
||||
}
|
||||
_playerVolume.destroyDelayed();
|
||||
|
||||
if (Media::Player::exists()) {
|
||||
|
@ -1651,7 +1652,7 @@ void MainWidget::closeBothPlayers() {
|
|||
|
||||
void MainWidget::createPlayer() {
|
||||
_player.create(this, [this] { playerHeightUpdated(); });
|
||||
_player->entity()->setCloseCallback([this] { switchToPanelPlayer(); });
|
||||
_player->entity()->setCloseCallback([this] { closeBothPlayers(); });
|
||||
_playerVolume.create(this);
|
||||
_player->entity()->volumeWidgetCreated(_playerVolume);
|
||||
orderWidgets();
|
||||
|
@ -1660,10 +1661,12 @@ void MainWidget::createPlayer() {
|
|||
_player->hide();
|
||||
} else {
|
||||
_player->hideFast();
|
||||
if (_player) {
|
||||
_player->slideDown();
|
||||
_playerHeight = _contentScrollAddToY = _player->contentHeight();
|
||||
updateControlsGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
Shortcuts::enableMediaShortcuts();
|
||||
}
|
||||
|
@ -1675,10 +1678,14 @@ void MainWidget::playerHeightUpdated() {
|
|||
_playerHeight = playerHeight;
|
||||
updateControlsGeometry();
|
||||
}
|
||||
if (_playerUsingPanel && !_playerHeight && _player->isHidden()) {
|
||||
if (!_playerHeight && _player->isHidden()) {
|
||||
AudioMsgId playing;
|
||||
auto playbackState = audioPlayer()->currentState(&playing, AudioMsgId::Type::Song);
|
||||
if (playing && (playbackState.state & AudioPlayerStoppedMask)) {
|
||||
_playerVolume.destroyDelayed();
|
||||
_player.destroyDelayed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::documentLoadProgress(FileLoader *loader) {
|
||||
|
@ -1768,10 +1775,6 @@ void MainWidget::mediaMarkRead(const HistoryItemsMap &items) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWidget::onParentResize(const QSize &newSize) {
|
||||
resize(newSize);
|
||||
}
|
||||
|
||||
void MainWidget::updateOnlineDisplay() {
|
||||
if (this != App::main()) return;
|
||||
_history->updateOnlineDisplay();
|
||||
|
@ -2216,7 +2219,6 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show
|
|||
_dialogs->update();
|
||||
}
|
||||
topBar()->showAll();
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
}
|
||||
|
||||
PeerData *MainWidget::ui_getPeerForMouseAction() {
|
||||
|
@ -2337,8 +2339,6 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
|
|||
if (Adaptive::OneColumn()) _dialogs->hide();
|
||||
|
||||
orderWidgets();
|
||||
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
}
|
||||
|
||||
void MainWidget::showWideSection(const Window::SectionMemento &memento) {
|
||||
|
@ -2465,8 +2465,6 @@ void MainWidget::showWideSectionAnimated(const Window::SectionMemento *memento,
|
|||
if (Adaptive::OneColumn()) _dialogs->hide();
|
||||
|
||||
orderWidgets();
|
||||
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
}
|
||||
|
||||
bool MainWidget::stackIsEmpty() const {
|
||||
|
@ -3412,7 +3410,6 @@ void MainWidget::getDifference() {
|
|||
|
||||
_getDifferenceTimeByPts = 0;
|
||||
|
||||
LOG(("Getting difference! no updates timer: %1, remains: %2").arg(noUpdatesTimer.isActive() ? 1 : 0).arg(noUpdatesTimer.remainingTime()));
|
||||
if (requestingDifference()) return;
|
||||
|
||||
_bySeqUpdates.clear();
|
||||
|
@ -3421,7 +3418,6 @@ void MainWidget::getDifference() {
|
|||
noUpdatesTimer.stop();
|
||||
_getDifferenceTimeAfterFail = 0;
|
||||
|
||||
LOG(("Getting difference for %1, %2").arg(_ptsWaiter.current()).arg(updDate));
|
||||
_ptsWaiter.setRequesting(true);
|
||||
MTP::send(MTPupdates_GetDifference(MTP_int(_ptsWaiter.current()), MTP_int(updDate), MTP_int(updQts)), rpcDone(&MainWidget::gotDifference), rpcFail(&MainWidget::failDifference));
|
||||
}
|
||||
|
@ -3433,14 +3429,12 @@ void MainWidget::getChannelDifference(ChannelData *channel, GetChannelDifference
|
|||
_channelGetDifferenceTimeByPts.remove(channel);
|
||||
}
|
||||
|
||||
LOG(("Getting channel difference!"));
|
||||
if (!channel->ptsInited() || channel->ptsRequesting()) return;
|
||||
|
||||
if (from != GetChannelDifferenceFromFail) {
|
||||
_channelGetDifferenceTimeAfterFail.remove(channel);
|
||||
}
|
||||
|
||||
LOG(("Getting channel difference for %1").arg(channel->pts()));
|
||||
channel->ptsSetRequesting(true);
|
||||
|
||||
auto filter = MTP_channelMessagesFilterEmpty();
|
||||
|
@ -3456,7 +3450,6 @@ void MainWidget::start(const MTPUser &user) {
|
|||
if (MTP::authedId() != uid) {
|
||||
MTP::setAuthedId(uid);
|
||||
Local::writeMtpData();
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
}
|
||||
|
||||
Local::readSavedPeers();
|
||||
|
|
|
@ -139,7 +139,7 @@ class MainWidget : public TWidget, public RPCSender, private base::Subscriber {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWidget(MainWindow *window);
|
||||
MainWidget(QWidget *parent);
|
||||
|
||||
bool needBackButton();
|
||||
|
||||
|
@ -426,7 +426,6 @@ public slots:
|
|||
|
||||
void dialogsCancelled();
|
||||
|
||||
void onParentResize(const QSize &newSize);
|
||||
void getDifference();
|
||||
void onGetDifferenceTimeByPts();
|
||||
void onGetDifferenceTimeAfterFail();
|
||||
|
|
|
@ -23,13 +23,13 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
|
||||
#include "dialogs/dialogs_layout.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "core/zlib_help.h"
|
||||
#include "lang.h"
|
||||
#include "shortcuts.h"
|
||||
#include "application.h"
|
||||
#include "pspecific.h"
|
||||
#include "title.h"
|
||||
#include "passcodewidget.h"
|
||||
#include "intro/introwidget.h"
|
||||
#include "mainwidget.h"
|
||||
|
@ -44,11 +44,12 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "apiwrap.h"
|
||||
#include "settings/settings_widget.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "platform/platform_window_title.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_theme.h"
|
||||
#include "window/window_theme_warning.h"
|
||||
|
||||
ConnectingWidget::ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect) : QWidget(parent)
|
||||
ConnectingWidget::ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect) : TWidget(parent)
|
||||
, _shadow(st::boxShadow)
|
||||
, _reconnect(this, QString()) {
|
||||
set(text, reconnect);
|
||||
|
@ -85,7 +86,7 @@ void ConnectingWidget::onReconnect() {
|
|||
MTP::restart();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow() {
|
||||
MainWindow::MainWindow() : Platform::MainWindow(), _body(this) {
|
||||
icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
icon64 = icon256.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
|
@ -107,12 +108,10 @@ MainWindow::MainWindow() {
|
|||
if (objectName().isEmpty()) {
|
||||
setObjectName(qsl("MainWindow"));
|
||||
}
|
||||
resize(st::wndDefWidth, st::wndDefHeight);
|
||||
resize(st::windowDefWidth, st::windowDefHeight);
|
||||
|
||||
setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
centralwidget = new QWidget(this);
|
||||
centralwidget->setObjectName(qsl("centralwidget"));
|
||||
setCentralWidget(centralwidget);
|
||||
setCentralWidget(_body);
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
|
@ -170,6 +169,8 @@ void MainWindow::init() {
|
|||
psInitFrameless();
|
||||
setWindowIcon(wndIcon);
|
||||
|
||||
_title = Platform::CreateTitleWidget(this);
|
||||
|
||||
Application::instance()->installEventFilter(this);
|
||||
connect(windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(onStateChanged(Qt::WindowState)));
|
||||
connect(windowHandle(), SIGNAL(activeChanged()), this, SLOT(onWindowActiveChanged()), Qt::QueuedConnection);
|
||||
|
@ -178,8 +179,8 @@ void MainWindow::init() {
|
|||
p.setColor(QPalette::Window, st::windowBg->c);
|
||||
setPalette(p);
|
||||
|
||||
title = new TitleWidget(this);
|
||||
|
||||
setMinimumWidth(st::windowMinWidth);
|
||||
setMinimumHeight(st::windowMinHeight);
|
||||
psInitSize();
|
||||
}
|
||||
|
||||
|
@ -224,38 +225,28 @@ QWidget *MainWindow::filedialogParent() {
|
|||
|
||||
void MainWindow::clearWidgets() {
|
||||
Ui::hideLayer(true);
|
||||
if (_passcode) {
|
||||
_passcode->hide();
|
||||
_passcode->deleteLater();
|
||||
_passcode = 0;
|
||||
}
|
||||
if (main) {
|
||||
delete main;
|
||||
main = nullptr;
|
||||
}
|
||||
if (intro) {
|
||||
intro->stop_show();
|
||||
intro->hide();
|
||||
intro->deleteLater();
|
||||
intro->rpcClear();
|
||||
intro = 0;
|
||||
_passcode.destroyDelayed();
|
||||
_main.destroy();
|
||||
if (_intro) {
|
||||
_intro->stop_show();
|
||||
_intro->rpcClear();
|
||||
_intro.destroyDelayed();
|
||||
}
|
||||
if (_mediaView) {
|
||||
hideMediaview();
|
||||
_mediaView->rpcClear();
|
||||
}
|
||||
title->updateControlsVisibility();
|
||||
updateGlobalMenu();
|
||||
}
|
||||
|
||||
QPixmap MainWindow::grabInner() {
|
||||
QPixmap result;
|
||||
if (settings) {
|
||||
result = myGrab(settings);
|
||||
} else if (intro) {
|
||||
result = myGrab(intro);
|
||||
} else if (main) {
|
||||
result = myGrab(main);
|
||||
if (_settings) {
|
||||
result = myGrab(_settings);
|
||||
} else if (_intro) {
|
||||
result = myGrab(_intro);
|
||||
} else if (_main) {
|
||||
result = myGrab(_main);
|
||||
} else if (_passcode) {
|
||||
result = myGrab(_passcode);
|
||||
}
|
||||
|
@ -268,20 +259,17 @@ void MainWindow::clearPasscode() {
|
|||
QPixmap bg = grabInner();
|
||||
|
||||
_passcode->stop_show();
|
||||
_passcode->hide();
|
||||
_passcode->deleteLater();
|
||||
_passcode = 0;
|
||||
if (intro) {
|
||||
intro->animShow(bg, true);
|
||||
_passcode.destroyDelayed();
|
||||
if (_intro) {
|
||||
_intro->animShow(bg, true);
|
||||
} else {
|
||||
main->animShow(bg, true);
|
||||
_main->animShow(bg, true);
|
||||
}
|
||||
notifyUpdateAll();
|
||||
title->updateControlsVisibility();
|
||||
updateGlobalMenu();
|
||||
|
||||
if (auto main = App::main()) {
|
||||
main->checkStartUrl();
|
||||
if (_main) {
|
||||
_main->checkStartUrl();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,16 +278,16 @@ void MainWindow::setupPasscode(bool anim) {
|
|||
|
||||
if (_passcode) {
|
||||
_passcode->stop_show();
|
||||
_passcode->hide();
|
||||
_passcode->deleteLater();
|
||||
_passcode.destroyDelayed();
|
||||
}
|
||||
_passcode = new PasscodeWidget(this);
|
||||
_passcode->move(0, st::titleHeight);
|
||||
if (main) main->hide();
|
||||
if (settings) {
|
||||
settings->deleteLater();
|
||||
_passcode.create(_body);
|
||||
updateControlsGeometry();
|
||||
|
||||
if (_main) _main->hide();
|
||||
if (_settings) {
|
||||
_settings.destroyDelayed();
|
||||
}
|
||||
if (intro) intro->hide();
|
||||
if (_intro) _intro->hide();
|
||||
if (anim) {
|
||||
_passcode->animShow(bg);
|
||||
} else {
|
||||
|
@ -307,7 +295,6 @@ void MainWindow::setupPasscode(bool anim) {
|
|||
}
|
||||
_shouldLockAt = 0;
|
||||
notifyUpdateAll();
|
||||
title->updateControlsVisibility();
|
||||
updateGlobalMenu();
|
||||
}
|
||||
|
||||
|
@ -335,7 +322,7 @@ void MainWindow::checkAutoLock() {
|
|||
void MainWindow::setupIntro(bool anim) {
|
||||
cSetContactsReceived(false);
|
||||
cSetDialogsReceived(false);
|
||||
if (intro && !intro->isHidden() && !main) return;
|
||||
if (_intro && !_intro->isHidden() && !_main) return;
|
||||
|
||||
if (_mediaView) {
|
||||
_mediaView->clearData();
|
||||
|
@ -345,10 +332,11 @@ void MainWindow::setupIntro(bool anim) {
|
|||
QPixmap bg = anim ? grabInner() : QPixmap();
|
||||
|
||||
clearWidgets();
|
||||
intro = new IntroWidget(this);
|
||||
intro->move(0, st::titleHeight);
|
||||
_intro.create(_body);
|
||||
updateControlsGeometry();
|
||||
|
||||
if (anim) {
|
||||
intro->animShow(bg);
|
||||
_intro->animShow(bg);
|
||||
}
|
||||
|
||||
fixOrder();
|
||||
|
@ -363,13 +351,13 @@ void MainWindow::setupIntro(bool anim) {
|
|||
}
|
||||
|
||||
void MainWindow::serviceNotification(const QString &msg, const MTPMessageMedia &media, bool force) {
|
||||
History *h = (main && App::userLoaded(ServiceUserId)) ? App::history(ServiceUserId) : 0;
|
||||
History *h = (_main && App::userLoaded(ServiceUserId)) ? App::history(ServiceUserId) : 0;
|
||||
if (!h || (!force && h->isEmpty())) {
|
||||
_delayedServiceMsgs.push_back(DelayedServiceMsg(msg, media));
|
||||
return sendServiceHistoryRequest();
|
||||
}
|
||||
|
||||
main->serviceNotification(msg, media);
|
||||
_main->serviceNotification(msg, media);
|
||||
}
|
||||
|
||||
void MainWindow::showDelayedServiceMsgs() {
|
||||
|
@ -381,32 +369,32 @@ void MainWindow::showDelayedServiceMsgs() {
|
|||
}
|
||||
|
||||
void MainWindow::sendServiceHistoryRequest() {
|
||||
if (!main || !main->started() || _delayedServiceMsgs.isEmpty() || _serviceHistoryRequest) return;
|
||||
if (!_main || !_main->started() || _delayedServiceMsgs.isEmpty() || _serviceHistoryRequest) return;
|
||||
|
||||
UserData *user = App::userLoaded(ServiceUserId);
|
||||
if (!user) {
|
||||
MTPDuser::Flags userFlags = MTPDuser::Flag::f_first_name | MTPDuser::Flag::f_phone | MTPDuser::Flag::f_status | MTPDuser::Flag::f_verified;
|
||||
user = App::feedUsers(MTP_vector<MTPUser>(1, MTP_user(MTP_flags(userFlags), MTP_int(ServiceUserId), MTPlong(), MTP_string("Telegram"), MTPstring(), MTPstring(), MTP_string("42777"), MTP_userProfilePhotoEmpty(), MTP_userStatusRecently(), MTPint(), MTPstring(), MTPstring())));
|
||||
}
|
||||
_serviceHistoryRequest = MTP::send(MTPmessages_GetHistory(user->input, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), main->rpcDone(&MainWidget::serviceHistoryDone), main->rpcFail(&MainWidget::serviceHistoryFail));
|
||||
_serviceHistoryRequest = MTP::send(MTPmessages_GetHistory(user->input, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), _main->rpcDone(&MainWidget::serviceHistoryDone), _main->rpcFail(&MainWidget::serviceHistoryFail));
|
||||
}
|
||||
|
||||
void MainWindow::setupMain(bool anim, const MTPUser *self) {
|
||||
QPixmap bg = anim ? grabInner() : QPixmap();
|
||||
clearWidgets();
|
||||
main = new MainWidget(this);
|
||||
main->move(0, st::titleHeight);
|
||||
_main.create(_body);
|
||||
updateControlsGeometry();
|
||||
|
||||
if (anim) {
|
||||
main->animShow(bg);
|
||||
_main->animShow(bg);
|
||||
} else {
|
||||
main->activate();
|
||||
_main->activate();
|
||||
}
|
||||
if (self) {
|
||||
main->start(*self);
|
||||
_main->start(*self);
|
||||
} else {
|
||||
MTP::send(MTPusers_GetUsers(MTP_vector<MTPInputUser>(1, MTP_inputUserSelf())), main->rpcDone(&MainWidget::startFull));
|
||||
MTP::send(MTPusers_GetUsers(MTP_vector<MTPInputUser>(1, MTP_inputUserSelf())), _main->rpcDone(&MainWidget::startFull));
|
||||
}
|
||||
title->updateControlsVisibility();
|
||||
|
||||
fixOrder();
|
||||
|
||||
|
@ -416,7 +404,6 @@ void MainWindow::setupMain(bool anim, const MTPUser *self) {
|
|||
void MainWindow::updateUnreadCounter() {
|
||||
if (!Global::started() || App::quitting()) return;
|
||||
|
||||
title->updateCounter();
|
||||
psUpdateCounter();
|
||||
}
|
||||
|
||||
|
@ -425,22 +412,22 @@ void MainWindow::showSettings() {
|
|||
|
||||
if (isHidden()) showFromTray();
|
||||
|
||||
if (settings) {
|
||||
if (_settings) {
|
||||
Ui::hideSettingsAndLayer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!layerBg) {
|
||||
layerBg = new LayerStackWidget(this);
|
||||
if (!_layerBg) {
|
||||
_layerBg.create(_body);
|
||||
}
|
||||
settings = new Settings::Widget();
|
||||
connect(settings, SIGNAL(destroyed(QObject*)), this, SLOT(onSettingsDestroyed(QObject*)));
|
||||
layerBg->showSpecialLayer(settings);
|
||||
_settings.create(this);
|
||||
connect(_settings, SIGNAL(destroyed(QObject*)), this, SLOT(onSettingsDestroyed(QObject*)));
|
||||
_layerBg->showSpecialLayer(_settings);
|
||||
}
|
||||
|
||||
void MainWindow::ui_hideSettingsAndLayer(ShowLayerOptions options) {
|
||||
if (layerBg) {
|
||||
layerBg->onClose();
|
||||
if (_layerBg) {
|
||||
_layerBg->onClose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,7 +441,7 @@ void MainWindow::mtpStateChanged(int32 dc, int32 state) {
|
|||
void MainWindow::updateConnectingStatus() {
|
||||
int32 state = MTP::dcstate();
|
||||
if (state == MTP::ConnectingState || state == MTP::DisconnectedState || (state < 0 && state > -600)) {
|
||||
if (main || getms() > 5000 || _connecting) {
|
||||
if (_main || getms() > 5000 || _connecting) {
|
||||
showConnecting(lang(lng_connecting));
|
||||
}
|
||||
} else if (state < 0) {
|
||||
|
@ -466,11 +453,11 @@ void MainWindow::updateConnectingStatus() {
|
|||
}
|
||||
|
||||
IntroWidget *MainWindow::introWidget() {
|
||||
return intro;
|
||||
return _intro;
|
||||
}
|
||||
|
||||
MainWidget *MainWindow::mainWidget() {
|
||||
return main;
|
||||
return _main;
|
||||
}
|
||||
|
||||
PasscodeWidget *MainWindow::passcodeWidget() {
|
||||
|
@ -504,31 +491,29 @@ void MainWindow::showDocument(DocumentData *doc, HistoryItem *item) {
|
|||
|
||||
void MainWindow::ui_showLayer(LayerWidget *box, ShowLayerOptions options) {
|
||||
if (box) {
|
||||
if (!layerBg) {
|
||||
layerBg = new LayerStackWidget(this);
|
||||
if (!_layerBg) {
|
||||
_layerBg.create(_body);
|
||||
}
|
||||
if (options.testFlag(KeepOtherLayers)) {
|
||||
if (options.testFlag(ShowAfterOtherLayers)) {
|
||||
layerBg->prependLayer(box);
|
||||
_layerBg->prependLayer(box);
|
||||
} else {
|
||||
layerBg->appendLayer(box);
|
||||
_layerBg->appendLayer(box);
|
||||
}
|
||||
} else {
|
||||
layerBg->showLayer(box);
|
||||
_layerBg->showLayer(box);
|
||||
}
|
||||
if (options.testFlag(ForceFastShowLayer)) {
|
||||
layerBg->showFast();
|
||||
_layerBg->showFast();
|
||||
}
|
||||
} else {
|
||||
if (layerBg) {
|
||||
if (settings) {
|
||||
layerBg->onCloseLayers();
|
||||
if (_layerBg) {
|
||||
if (_settings) {
|
||||
_layerBg->onCloseLayers();
|
||||
} else {
|
||||
layerBg->onClose();
|
||||
_layerBg->onClose();
|
||||
if (options.testFlag(ForceFastShowLayer)) {
|
||||
layerBg->hide();
|
||||
layerBg->deleteLater();
|
||||
layerBg = nullptr;
|
||||
_layerBg.destroyDelayed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -537,7 +522,7 @@ void MainWindow::ui_showLayer(LayerWidget *box, ShowLayerOptions options) {
|
|||
}
|
||||
|
||||
bool MainWindow::ui_isLayerShown() {
|
||||
return !!layerBg;
|
||||
return _layerBg != nullptr;
|
||||
}
|
||||
|
||||
bool MainWindow::ui_isMediaViewShown() {
|
||||
|
@ -547,7 +532,7 @@ bool MainWindow::ui_isMediaViewShown() {
|
|||
void MainWindow::ui_showMediaPreview(DocumentData *document) {
|
||||
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) return;
|
||||
if (!_mediaPreview) {
|
||||
_mediaPreview = std_::make_unique<MediaPreviewWidget>(this);
|
||||
_mediaPreview.create(_body);
|
||||
updateControlsGeometry();
|
||||
}
|
||||
if (_mediaPreview->isHidden()) {
|
||||
|
@ -559,7 +544,7 @@ void MainWindow::ui_showMediaPreview(DocumentData *document) {
|
|||
void MainWindow::ui_showMediaPreview(PhotoData *photo) {
|
||||
if (!photo) return;
|
||||
if (!_mediaPreview) {
|
||||
_mediaPreview = std_::make_unique<MediaPreviewWidget>(this);
|
||||
_mediaPreview.create(_body);
|
||||
updateControlsGeometry();
|
||||
}
|
||||
if (_mediaPreview->isHidden()) {
|
||||
|
@ -576,8 +561,8 @@ void MainWindow::ui_hideMediaPreview() {
|
|||
PeerData *MainWindow::ui_getPeerForMouseAction() {
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
return _mediaView->ui_getPeerForMouseAction();
|
||||
} else if (main) {
|
||||
return main->ui_getPeerForMouseAction();
|
||||
} else if (_main) {
|
||||
return _main->ui_getPeerForMouseAction();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -586,8 +571,7 @@ void MainWindow::showConnecting(const QString &text, const QString &reconnect) {
|
|||
if (_connecting) {
|
||||
_connecting->set(text, reconnect);
|
||||
} else {
|
||||
_connecting.create(this, text, reconnect);
|
||||
_connecting->show();
|
||||
_connecting.create(_body, text, reconnect);
|
||||
updateControlsGeometry();
|
||||
fixOrder();
|
||||
}
|
||||
|
@ -602,33 +586,31 @@ void MainWindow::hideConnecting() {
|
|||
void MainWindow::themeUpdated(const Window::Theme::BackgroundUpdate &data) {
|
||||
using Type = Window::Theme::BackgroundUpdate::Type;
|
||||
if (data.type == Type::TestingTheme) {
|
||||
if (_title) _title->update();
|
||||
if (!_testingThemeWarning) {
|
||||
_testingThemeWarning.create(this);
|
||||
_testingThemeWarning.create(_body);
|
||||
_testingThemeWarning->setGeometry(rect());
|
||||
_testingThemeWarning->setHiddenCallback([this] { _testingThemeWarning.destroyDelayed(); });
|
||||
}
|
||||
_testingThemeWarning->showAnimated();
|
||||
} else if (data.type == Type::RevertingTheme || data.type == Type::ApplyingTheme) {
|
||||
if (_title) _title->update();
|
||||
_testingThemeWarning->hideAnimated();
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::doWeReadServerHistory() const {
|
||||
return isActive(false) && main && !Ui::isLayerShown() && main->doWeReadServerHistory();
|
||||
return isActive(false) && _main && !Ui::isLayerShown() && _main->doWeReadServerHistory();
|
||||
}
|
||||
|
||||
void MainWindow::checkHistoryActivation() {
|
||||
if (main && MTP::authedId() && doWeReadServerHistory()) {
|
||||
main->markActiveHistoryAsRead();
|
||||
if (_main && MTP::authedId() && doWeReadServerHistory()) {
|
||||
_main->markActiveHistoryAsRead();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::layerHidden() {
|
||||
if (layerBg) {
|
||||
layerBg->hide();
|
||||
layerBg->deleteLater();
|
||||
}
|
||||
layerBg = nullptr;
|
||||
_layerBg.destroyDelayed();
|
||||
hideMediaview();
|
||||
setInnerFocus();
|
||||
}
|
||||
|
@ -658,85 +640,61 @@ void MainWindow::hideMediaview() {
|
|||
}
|
||||
|
||||
bool MainWindow::contentOverlapped(const QRect &globalRect) {
|
||||
if (main && main->contentOverlapped(globalRect)) return true;
|
||||
if (layerBg && layerBg->contentOverlapped(globalRect)) return true;
|
||||
if (_main && _main->contentOverlapped(globalRect)) return true;
|
||||
if (_layerBg && _layerBg->contentOverlapped(globalRect)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::setInnerFocus() {
|
||||
if (_testingThemeWarning) {
|
||||
_testingThemeWarning->setFocus();
|
||||
} else if (layerBg && layerBg->canSetFocus()) {
|
||||
layerBg->setInnerFocus();
|
||||
} else if (_layerBg && _layerBg->canSetFocus()) {
|
||||
_layerBg->setInnerFocus();
|
||||
} else if (_passcode) {
|
||||
_passcode->setInnerFocus();
|
||||
} else if (settings) {
|
||||
settings->setInnerFocus();
|
||||
} else if (main) {
|
||||
main->setInnerFocus();
|
||||
} else if (_settings) {
|
||||
_settings->setInnerFocus();
|
||||
} else if (_main) {
|
||||
_main->setInnerFocus();
|
||||
}
|
||||
}
|
||||
|
||||
QRect MainWindow::clientRect() const {
|
||||
return QRect(0, st::titleHeight, width(), height() - st::titleHeight);
|
||||
}
|
||||
|
||||
QRect MainWindow::photoRect() const {
|
||||
if (settings) {
|
||||
return settings->geometry();
|
||||
} else if (main) {
|
||||
QRect r(main->historyRect());
|
||||
r.moveLeft(r.left() + main->x());
|
||||
r.moveTop(r.top() + main->y());
|
||||
return r;
|
||||
}
|
||||
return QRect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void MainWindow::wStartDrag(QMouseEvent *e) {
|
||||
dragStart = e->globalPos() - frameGeometry().topLeft();
|
||||
dragging = true;
|
||||
}
|
||||
|
||||
void MainWindow::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
HitTestType MainWindow::hitTest(const QPoint &p) const {
|
||||
Window::HitTestResult MainWindow::hitTest(const QPoint &p) const {
|
||||
int x(p.x()), y(p.y()), w(width()), h(height());
|
||||
|
||||
const int32 raw = psResizeRowWidth();
|
||||
if (!windowState().testFlag(Qt::WindowMaximized)) {
|
||||
if (y < raw) {
|
||||
if (x < raw) {
|
||||
return HitTestType::TopLeft;
|
||||
return Window::HitTestResult::TopLeft;
|
||||
} else if (x > w - raw - 1) {
|
||||
return HitTestType::TopRight;
|
||||
return Window::HitTestResult::TopRight;
|
||||
}
|
||||
return HitTestType::Top;
|
||||
return Window::HitTestResult::Top;
|
||||
} else if (y > h - raw - 1) {
|
||||
if (x < raw) {
|
||||
return HitTestType::BottomLeft;
|
||||
return Window::HitTestResult::BottomLeft;
|
||||
} else if (x > w - raw - 1) {
|
||||
return HitTestType::BottomRight;
|
||||
return Window::HitTestResult::BottomRight;
|
||||
}
|
||||
return HitTestType::Bottom;
|
||||
return Window::HitTestResult::Bottom;
|
||||
} else if (x < raw) {
|
||||
return HitTestType::Left;
|
||||
return Window::HitTestResult::Left;
|
||||
} else if (x > w - raw - 1) {
|
||||
return HitTestType::Right;
|
||||
return Window::HitTestResult::Right;
|
||||
}
|
||||
}
|
||||
auto titleTest = title->hitTest(p - title->geometry().topLeft());
|
||||
if (titleTest != HitTestType::None) {
|
||||
auto titleTest = _title ? _title->hitTest(p - _title->geometry().topLeft()) : Window::HitTestResult::None;
|
||||
if (titleTest != Window::HitTestResult::None) {
|
||||
return titleTest;
|
||||
} else if (x >= 0 && y >= 0 && x < w && y < h) {
|
||||
return HitTestType::Client;
|
||||
return Window::HitTestResult::Client;
|
||||
}
|
||||
return HitTestType::None;
|
||||
return Window::HitTestResult::None;
|
||||
}
|
||||
|
||||
QRect MainWindow::iconRect() const {
|
||||
return title->iconRect();
|
||||
return _title ? _title->iconRect() : QRect();
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
||||
|
@ -749,9 +707,9 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
|||
break;
|
||||
|
||||
case QEvent::MouseMove:
|
||||
if (main && main->isIdle()) {
|
||||
if (_main && _main->isIdle()) {
|
||||
psUserActionDone();
|
||||
main->checkIdleFinish();
|
||||
_main->checkIdleFinish();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -781,8 +739,8 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
|||
QString url = static_cast<QFileOpenEvent*>(e)->url().toEncoded().trimmed();
|
||||
if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
||||
cSetStartUrl(url.mid(0, 8192));
|
||||
if (auto main = App::main()) {
|
||||
main->checkStartUrl();
|
||||
if (_main) {
|
||||
_main->checkStartUrl();
|
||||
}
|
||||
}
|
||||
activate();
|
||||
|
@ -807,26 +765,6 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
|||
return Platform::MainWindow::eventFilter(obj, e);
|
||||
}
|
||||
|
||||
void MainWindow::mouseMoveEvent(QMouseEvent *e) {
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
if (dragging) {
|
||||
if (windowState().testFlag(Qt::WindowMaximized)) {
|
||||
setWindowState(windowState() & ~Qt::WindowMaximized);
|
||||
|
||||
dragStart = e->globalPos() - frameGeometry().topLeft();
|
||||
} else {
|
||||
move(e->globalPos() - dragStart);
|
||||
}
|
||||
}
|
||||
} else if (dragging) {
|
||||
dragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mouseReleaseEvent(QMouseEvent *e) {
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
bool MainWindow::minimizeToTray() {
|
||||
if (App::quitting() || !psHasTrayIcon()) return false;
|
||||
|
||||
|
@ -883,25 +821,25 @@ void MainWindow::updateTrayMenu(bool force) {
|
|||
void MainWindow::onShowAddContact() {
|
||||
if (isHidden()) showFromTray();
|
||||
|
||||
if (main) main->showAddContact();
|
||||
if (_main) _main->showAddContact();
|
||||
}
|
||||
|
||||
void MainWindow::onShowNewGroup() {
|
||||
if (isHidden()) showFromTray();
|
||||
|
||||
if (main) Ui::showLayer(new GroupInfoBox(CreatingGroupGroup, false), KeepOtherLayers);
|
||||
if (_main) Ui::showLayer(new GroupInfoBox(CreatingGroupGroup, false), KeepOtherLayers);
|
||||
}
|
||||
|
||||
void MainWindow::onShowNewChannel() {
|
||||
if (isHidden()) showFromTray();
|
||||
|
||||
if (main) Ui::showLayer(new GroupInfoBox(CreatingGroupChannel, false), KeepOtherLayers);
|
||||
if (_main) Ui::showLayer(new GroupInfoBox(CreatingGroupChannel, false), KeepOtherLayers);
|
||||
}
|
||||
|
||||
void MainWindow::onLogout() {
|
||||
if (isHidden()) showFromTray();
|
||||
|
||||
ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout), lang(lng_settings_logout), st::attentionBoxButton);
|
||||
auto box = new ConfirmBox(lang(lng_sure_logout), lang(lng_settings_logout), st::attentionBoxButton);
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onLogoutSure()));
|
||||
Ui::showLayer(box);
|
||||
}
|
||||
|
@ -930,46 +868,46 @@ void MainWindow::activate() {
|
|||
activateWindow();
|
||||
updateIsActive(Global::OnlineFocusTimeout());
|
||||
if (wasHidden) {
|
||||
if (main) {
|
||||
main->windowShown();
|
||||
if (_main) {
|
||||
_main->windowShown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::noIntro(IntroWidget *was) {
|
||||
if (was == intro) {
|
||||
intro = nullptr;
|
||||
if (was == _intro) {
|
||||
_intro = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSettingsDestroyed(QObject *was) {
|
||||
if (was == settings) {
|
||||
settings = nullptr;
|
||||
if (was == _settings) {
|
||||
_settings = nullptr;
|
||||
}
|
||||
checkHistoryActivation();
|
||||
}
|
||||
|
||||
void MainWindow::noMain(MainWidget *was) {
|
||||
if (was == main) {
|
||||
main = 0;
|
||||
if (was == _main) {
|
||||
_main = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::noLayerStack(LayerStackWidget *was) {
|
||||
if (was == layerBg) {
|
||||
layerBg = nullptr;
|
||||
if (was == _layerBg) {
|
||||
_layerBg = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::layerFinishedHide(LayerStackWidget *was) {
|
||||
if (was == layerBg) {
|
||||
if (was == _layerBg) {
|
||||
QTimer::singleShot(0, this, SLOT(layerHidden()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::fixOrder() {
|
||||
title->raise();
|
||||
if (layerBg) layerBg->raise();
|
||||
if (_title) _title->raise();
|
||||
if (_layerBg) _layerBg->raise();
|
||||
if (_mediaPreview) _mediaPreview->raise();
|
||||
if (_connecting) _connecting->raise();
|
||||
if (_testingThemeWarning) _testingThemeWarning->raise();
|
||||
|
@ -1041,12 +979,8 @@ void MainWindow::closeEvent(QCloseEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
TitleWidget *MainWindow::getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *e) {
|
||||
if (!title) return;
|
||||
if (!_title) return;
|
||||
|
||||
Adaptive::Layout layout = Adaptive::OneColumnLayout;
|
||||
if (width() > st::adaptiveWideWidth) {
|
||||
|
@ -1058,16 +992,25 @@ void MainWindow::resizeEvent(QResizeEvent *e) {
|
|||
Global::SetAdaptiveLayout(layout);
|
||||
Adaptive::Changed().notify(true);
|
||||
}
|
||||
|
||||
auto bodyTop = 0;
|
||||
if (_title) {
|
||||
_title->setGeometry(0, bodyTop, width(), st::titleHeight);
|
||||
bodyTop += _title->height();
|
||||
}
|
||||
_body->setGeometry(0, bodyTop, width(), height() - bodyTop);
|
||||
updateControlsGeometry();
|
||||
emit resized(QSize(width(), height() - st::titleHeight));
|
||||
}
|
||||
|
||||
void MainWindow::updateControlsGeometry() {
|
||||
title->setGeometry(0, 0, width(), st::titleHeight);
|
||||
if (layerBg) layerBg->resize(width(), height());
|
||||
if (_mediaPreview) _mediaPreview->setGeometry(0, title->height(), width(), height() - title->height());
|
||||
if (_connecting) _connecting->setGeometry(0, height() - _connecting->height(), _connecting->width(), _connecting->height());
|
||||
if (_testingThemeWarning) _testingThemeWarning->setGeometry(rect());
|
||||
auto body = _body->rect();
|
||||
if (_passcode) _passcode->setGeometry(body);
|
||||
if (_main) _main->setGeometry(body);
|
||||
if (_intro) _intro->setGeometry(body);
|
||||
if (_layerBg) _layerBg->setGeometry(body);
|
||||
if (_mediaPreview) _mediaPreview->setGeometry(body);
|
||||
if (_connecting) _connecting->moveToLeft(0, body.height() - _connecting->height());
|
||||
if (_testingThemeWarning) _testingThemeWarning->setGeometry(body);
|
||||
}
|
||||
|
||||
MainWindow::TempDirState MainWindow::tempDirState() {
|
||||
|
@ -1156,8 +1099,8 @@ void MainWindow::notifySchedule(History *history, HistoryItem *item) {
|
|||
|
||||
int delay = item->Has<HistoryMessageForwarded>() ? 500 : 100, t = unixtime();
|
||||
uint64 ms = getms(true);
|
||||
bool isOnline = main->lastWasOnline(), otherNotOld = ((cOtherOnline() * uint64(1000)) + Global::OnlineCloudTimeout() > t * uint64(1000));
|
||||
bool otherLaterThanMe = (cOtherOnline() * uint64(1000) + (ms - main->lastSetOnline()) > t * uint64(1000));
|
||||
bool isOnline = _main->lastWasOnline(), otherNotOld = ((cOtherOnline() * uint64(1000)) + Global::OnlineCloudTimeout() > t * uint64(1000));
|
||||
bool otherLaterThanMe = (cOtherOnline() * uint64(1000) + (ms - _main->lastSetOnline()) > t * uint64(1000));
|
||||
if (!isOnline && otherNotOld && otherLaterThanMe) {
|
||||
delay = Global::NotifyCloudDelay();
|
||||
} else if (cOtherOnline() >= t) {
|
||||
|
@ -1528,13 +1471,13 @@ void MainWindow::sendPaths() {
|
|||
if (App::passcoded()) return;
|
||||
hideMediaview();
|
||||
Ui::hideSettingsAndLayer();
|
||||
if (main) {
|
||||
main->activate();
|
||||
if (_main) {
|
||||
_main->activate();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mediaOverviewUpdated(PeerData *peer, MediaOverviewType type) {
|
||||
if (main) main->mediaOverviewUpdated(peer, type);
|
||||
if (_main) _main->mediaOverviewUpdated(peer, type);
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
_mediaView->mediaOverviewUpdated(peer, type);
|
||||
}
|
||||
|
@ -1552,7 +1495,7 @@ void MainWindow::documentUpdated(DocumentData *doc) {
|
|||
}
|
||||
|
||||
void MainWindow::changingMsgId(HistoryItem *row, MsgId newId) {
|
||||
if (main) main->changingMsgId(row, newId);
|
||||
if (_main) _main->changingMsgId(row, newId);
|
||||
if (!_mediaView || _mediaView->isHidden()) return;
|
||||
_mediaView->changingMsgId(row, newId);
|
||||
}
|
||||
|
@ -1565,7 +1508,7 @@ bool MainWindow::isActive(bool cached) const {
|
|||
void MainWindow::updateIsActive(int timeout) {
|
||||
if (timeout) return _isActiveTimer.start(timeout);
|
||||
_isActive = isActive(false);
|
||||
if (main) main->updateOnline();
|
||||
if (_main) _main->updateOnline();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
@ -1578,9 +1521,9 @@ MainWindow::~MainWindow() {
|
|||
delete _mediaView;
|
||||
delete trayIcon;
|
||||
delete trayIconMenu;
|
||||
delete intro;
|
||||
delete main;
|
||||
delete settings;
|
||||
delete _intro;
|
||||
delete _main;
|
||||
delete _settings;
|
||||
}
|
||||
|
||||
PreLaunchWindow *PreLaunchWindowInstance = 0;
|
||||
|
@ -2000,11 +1943,11 @@ void LastCrashedWindow::addReportFieldPart(const QLatin1String &name, const QLat
|
|||
void LastCrashedWindow::onSendReport() {
|
||||
if (_checkReply) {
|
||||
_checkReply->deleteLater();
|
||||
_checkReply = 0;
|
||||
_checkReply = nullptr;
|
||||
}
|
||||
if (_sendReply) {
|
||||
_sendReply->deleteLater();
|
||||
_sendReply = 0;
|
||||
_sendReply = nullptr;
|
||||
}
|
||||
App::setProxySettings(_sendManager);
|
||||
|
||||
|
@ -2034,7 +1977,7 @@ void LastCrashedWindow::onCheckingFinished() {
|
|||
|
||||
QByteArray result = _checkReply->readAll().trimmed();
|
||||
_checkReply->deleteLater();
|
||||
_checkReply = 0;
|
||||
_checkReply = nullptr;
|
||||
|
||||
LOG(("Crash report check for sending done, result: %1").arg(QString::fromUtf8(result)));
|
||||
|
||||
|
@ -2057,7 +2000,7 @@ void LastCrashedWindow::onCheckingFinished() {
|
|||
return;
|
||||
}
|
||||
|
||||
QHttpMultiPart *multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
auto multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
|
||||
addReportFieldPart(qstr("platform"), qstr("Platform:"), multipart);
|
||||
addReportFieldPart(qstr("version"), qstr("Version:"), multipart);
|
||||
|
@ -2454,11 +2397,11 @@ void LastCrashedWindow::onSendingError(QNetworkReply::NetworkError e) {
|
|||
_sendingState = SendingFail;
|
||||
if (_checkReply) {
|
||||
_checkReply->deleteLater();
|
||||
_checkReply = 0;
|
||||
_checkReply = nullptr;
|
||||
}
|
||||
if (_sendReply) {
|
||||
_sendReply->deleteLater();
|
||||
_sendReply = 0;
|
||||
_sendReply = nullptr;
|
||||
}
|
||||
updateControls();
|
||||
}
|
||||
|
@ -2469,7 +2412,7 @@ void LastCrashedWindow::onSendingFinished() {
|
|||
LOG(("Crash report sending done, result: %1").arg(QString::fromUtf8(result)));
|
||||
|
||||
_sendReply->deleteLater();
|
||||
_sendReply = 0;
|
||||
_sendReply = nullptr;
|
||||
_pleaseSendReport.setText(qsl("Thank you for your report!"));
|
||||
_sendingState = SendingDone;
|
||||
updateControls();
|
||||
|
|
|
@ -20,14 +20,13 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "title.h"
|
||||
#include "pspecific.h"
|
||||
#include "ui/effects/rect_shadow.h"
|
||||
#include "platform/platform_main_window.h"
|
||||
#include "window/window_title.h"
|
||||
#include "core/single_timer.h"
|
||||
|
||||
class MediaView;
|
||||
class TitleWidget;
|
||||
class PasscodeWidget;
|
||||
class IntroWidget;
|
||||
class MainWidget;
|
||||
|
@ -49,13 +48,15 @@ class WarningWidget;
|
|||
} // namespace Theme
|
||||
} // namespace Window
|
||||
|
||||
class ConnectingWidget : public QWidget {
|
||||
class ConnectingWidget : public TWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect);
|
||||
void set(const QString &text, const QString &reconnect);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
public slots:
|
||||
void onReconnect();
|
||||
|
@ -82,20 +83,9 @@ public:
|
|||
|
||||
QWidget *filedialogParent();
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *evt);
|
||||
|
||||
void inactivePress(bool inactive);
|
||||
bool inactivePress() const;
|
||||
|
||||
void wStartDrag(QMouseEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void closeEvent(QCloseEvent *e);
|
||||
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
void setupPasscode(bool anim);
|
||||
void clearPasscode();
|
||||
void checkAutoLockIn(int msec);
|
||||
|
@ -107,14 +97,9 @@ public:
|
|||
|
||||
void mtpStateChanged(int32 dc, int32 state);
|
||||
|
||||
TitleWidget *getTitle();
|
||||
|
||||
HitTestType hitTest(const QPoint &p) const;
|
||||
Window::HitTestResult hitTest(const QPoint &p) const;
|
||||
QRect iconRect() const;
|
||||
|
||||
QRect clientRect() const;
|
||||
QRect photoRect() const;
|
||||
|
||||
IntroWidget *introWidget();
|
||||
MainWidget *mainWidget();
|
||||
PasscodeWidget *passcodeWidget();
|
||||
|
@ -184,6 +169,11 @@ public:
|
|||
void ui_hideMediaPreview();
|
||||
PeerData *ui_getPeerForMouseAction();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *o, QEvent *e) override;
|
||||
void closeEvent(QCloseEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
public slots:
|
||||
void updateIsActive(int timeout = 0);
|
||||
|
||||
|
@ -220,7 +210,6 @@ public slots:
|
|||
void app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button);
|
||||
|
||||
signals:
|
||||
void resized(const QSize &size);
|
||||
void tempDirCleared(int task);
|
||||
void tempDirClearFailed(int task);
|
||||
void newAuthorization();
|
||||
|
@ -250,13 +239,14 @@ private:
|
|||
QVector<DelayedServiceMsg> _delayedServiceMsgs;
|
||||
mtpRequestId _serviceHistoryRequest = 0;
|
||||
|
||||
TitleWidget *title = nullptr;
|
||||
PasscodeWidget *_passcode = nullptr;
|
||||
IntroWidget *intro = nullptr;
|
||||
MainWidget *main = nullptr;
|
||||
ChildWidget<Settings::Widget> settings = { nullptr };
|
||||
ChildWidget<LayerStackWidget> layerBg = { nullptr };
|
||||
std_::unique_ptr<MediaPreviewWidget> _mediaPreview;
|
||||
Window::TitleWidget *_title = nullptr;
|
||||
ChildWidget<TWidget> _body;
|
||||
ChildWidget<PasscodeWidget> _passcode = { nullptr };
|
||||
ChildWidget<IntroWidget> _intro = { nullptr };
|
||||
ChildWidget<MainWidget> _main = { nullptr };
|
||||
ChildWidget<Settings::Widget> _settings = { nullptr };
|
||||
ChildWidget<LayerStackWidget> _layerBg = { nullptr };
|
||||
ChildWidget<MediaPreviewWidget> _mediaPreview = { nullptr };
|
||||
|
||||
QTimer _isActiveTimer;
|
||||
bool _isActive = false;
|
||||
|
@ -268,9 +258,6 @@ private:
|
|||
|
||||
void clearWidgets();
|
||||
|
||||
bool dragging = false;
|
||||
QPoint dragStart;
|
||||
|
||||
bool _inactivePress = false;
|
||||
QTimer _inactiveTimer;
|
||||
|
||||
|
|
|
@ -144,22 +144,8 @@ mediaPlayerPlayback: FilledSlider {
|
|||
duration: 150;
|
||||
}
|
||||
|
||||
mediaPlayerTitleButtonSize: size(titleHeight, titleHeight);
|
||||
mediaPlayerTitleButtonInner: size(25px, 25px);
|
||||
mediaPlayerTitleButtonInnerBg: #49708f;
|
||||
mediaPlayerButtonTransformDuration: 200;
|
||||
|
||||
mediaPlayerTitleButton: MediaPlayerButton {
|
||||
playPosition: point(10px, 7px);
|
||||
playOuter: size(29px, 25px);
|
||||
pausePosition: point(8px, 8px);
|
||||
pauseOuter: size(25px, 25px);
|
||||
pauseStroke: 3px;
|
||||
cancelPosition: point(8px, 8px);
|
||||
cancelOuter: size(25px, 25px);
|
||||
cancelStroke: 2px;
|
||||
}
|
||||
|
||||
mediaPlayerPanelButton: MediaPlayerButton {
|
||||
playPosition: point(3px, 0px);
|
||||
playOuter: size(22px, 18px);
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
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 "media/player/media_player_title_button.h"
|
||||
|
||||
#include "media/player/media_player_button.h"
|
||||
#include "media/media_audio.h"
|
||||
#include "media/player/media_player_instance.h"
|
||||
#include "shortcuts.h"
|
||||
|
||||
namespace Media {
|
||||
namespace Player {
|
||||
|
||||
using State = PlayButtonLayout::State;
|
||||
|
||||
TitleButton::TitleButton(QWidget *parent) : Button(parent)
|
||||
, _layout(std_::make_unique<PlayButtonLayout>(st::mediaPlayerTitleButton, [this] { update(); })) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
resize(st::mediaPlayerTitleButtonSize);
|
||||
|
||||
setClickedCallback([this]() {
|
||||
if (exists()) {
|
||||
instance()->playPauseCancelClicked();
|
||||
}
|
||||
});
|
||||
|
||||
if (exists()) {
|
||||
subscribe(instance()->updatedNotifier(), [this](const UpdatedEvent &e) {
|
||||
updatePauseState();
|
||||
});
|
||||
updatePauseState();
|
||||
_layout->finishTransform();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleButton::updatePauseState() {
|
||||
AudioMsgId playing;
|
||||
auto playbackState = audioPlayer()->currentState(&playing, AudioMsgId::Type::Song);
|
||||
auto stopped = ((playbackState.state & AudioPlayerStoppedMask) || playbackState.state == AudioPlayerFinishing);
|
||||
auto showPause = !stopped && (playbackState.state == AudioPlayerPlaying || playbackState.state == AudioPlayerResuming || playbackState.state == AudioPlayerStarting);
|
||||
if (exists() && instance()->isSeeking()) {
|
||||
showPause = true;
|
||||
}
|
||||
auto state = [audio = playing.audio(), showPause] {
|
||||
if (audio && audio->loading()) {
|
||||
return State::Cancel;
|
||||
} else if (showPause) {
|
||||
return State::Pause;
|
||||
}
|
||||
return State::Play;
|
||||
};
|
||||
_layout->setState(state());
|
||||
}
|
||||
|
||||
void TitleButton::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
p.fillRect(rect(), st::titleBg);
|
||||
|
||||
p.setBrush(st::mediaPlayerTitleButtonInnerBg);
|
||||
p.setPen(Qt::NoPen);
|
||||
|
||||
p.setRenderHint(QPainter::HighQualityAntialiasing, true);
|
||||
p.drawEllipse((width() - st::mediaPlayerTitleButtonInner.width()) / 2, (height() - st::mediaPlayerTitleButtonInner.height()) / 2, st::mediaPlayerTitleButtonInner.width(), st::mediaPlayerTitleButtonInner.height());
|
||||
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
|
||||
|
||||
paintIcon(p);
|
||||
}
|
||||
|
||||
void TitleButton::onStateChanged(int oldState, ButtonStateChangeSource source) {
|
||||
if ((oldState & StateOver) != (_state & StateOver)) {
|
||||
auto over = (_state & StateOver);
|
||||
_iconFg.start([this] { update(); }, over ? st::titleButtonFg->c : st::titleButtonActiveFg->c, over ? st::titleButtonActiveFg->c : st::titleButtonFg->c, st::titleButtonDuration);
|
||||
}
|
||||
}
|
||||
|
||||
void TitleButton::paintIcon(Painter &p) {
|
||||
auto over = (_state & StateOver);
|
||||
auto icon = _iconFg.current(getms(), over ? st::titleButtonActiveFg->c : st::titleButtonFg->c);
|
||||
|
||||
auto left = (width() - st::mediaPlayerTitleButtonInner.width()) / 2;
|
||||
auto top = (height() - st::mediaPlayerTitleButtonInner.height()) / 2;
|
||||
p.translate(left, top);
|
||||
|
||||
_layout->paint(p, icon);
|
||||
}
|
||||
|
||||
void TitleButton::enterEvent(QEvent *e) {
|
||||
if (exists()) {
|
||||
instance()->titleButtonOver().notify(true, true);
|
||||
}
|
||||
return Button::enterEvent(e);
|
||||
}
|
||||
|
||||
void TitleButton::leaveEvent(QEvent *e) {
|
||||
if (exists()) {
|
||||
instance()->titleButtonOver().notify(false, true);
|
||||
}
|
||||
return Button::leaveEvent(e);
|
||||
}
|
||||
|
||||
TitleButton::~TitleButton() = default;
|
||||
|
||||
} // namespace Player
|
||||
} // namespace Media
|
|
@ -82,7 +82,7 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
|
|||
, _playback(new Ui::FilledSlider(this, st::mediaPlayerPlayback)) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
setMouseTracking(true);
|
||||
resize(st::wndMinWidth, st::mediaPlayerHeight + st::lineWidth);
|
||||
resize(width(), st::mediaPlayerHeight + st::lineWidth);
|
||||
|
||||
_nameLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
_timeLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
|
||||
#include "styles/style_overview.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "boxes/addcontactbox.h"
|
||||
#include "boxes/confirmbox.h"
|
||||
#include "boxes/photocropbox.h"
|
||||
|
@ -56,13 +57,13 @@ OverviewInner::OverviewInner(OverviewWidget *overview, ScrollArea *scroll, PeerD
|
|||
, _search(this, st::dlgFilter, lang(lng_dlg_filter))
|
||||
, _cancelSearch(this, st::dialogsCancelSearch)
|
||||
, _itemsToBeLoaded(LinksOverviewPerPage * 2)
|
||||
, _width(st::wndMinWidth) {
|
||||
, _width(st::windowMinWidth) {
|
||||
subscribe(FileDownload::ImageLoaded(), [this] { update(); });
|
||||
subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
|
||||
itemRemoved(item);
|
||||
});
|
||||
|
||||
resize(_width, st::wndMinHeight);
|
||||
resize(_width, st::windowMinHeight);
|
||||
|
||||
App::contextItem(0);
|
||||
|
||||
|
|
|
@ -33,9 +33,6 @@ PasscodeWidget::PasscodeWidget(QWidget *parent) : TWidget(parent)
|
|||
, _passcode(this, st::passcodeInput)
|
||||
, _submit(this, lang(lng_passcode_submit), st::passcodeSubmit)
|
||||
, _logout(this, lang(lng_passcode_logout)) {
|
||||
setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));
|
||||
connect(App::wnd(), SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&)));
|
||||
|
||||
_passcode.setEchoMode(QLineEdit::Password);
|
||||
connect(&_submit, SIGNAL(clicked()), this, SLOT(onSubmit()));
|
||||
|
||||
|
@ -48,10 +45,6 @@ PasscodeWidget::PasscodeWidget(QWidget *parent) : TWidget(parent)
|
|||
_passcode.setFocus();
|
||||
}
|
||||
|
||||
void PasscodeWidget::onParentResize(const QSize &newSize) {
|
||||
resize(newSize);
|
||||
}
|
||||
|
||||
void PasscodeWidget::onSubmit() {
|
||||
if (_passcode.text().isEmpty()) {
|
||||
_passcode.notaBene();
|
||||
|
|
|
@ -24,13 +24,8 @@ class PasscodeWidget : public TWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
PasscodeWidget(QWidget *parent);
|
||||
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void setInnerFocus();
|
||||
|
||||
void animShow(const QPixmap &bgAnimCache, bool back = false);
|
||||
|
@ -39,15 +34,18 @@ public:
|
|||
|
||||
~PasscodeWidget();
|
||||
|
||||
public slots:
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
void onParentResize(const QSize &newSize);
|
||||
public slots:
|
||||
void onError();
|
||||
void onChanged();
|
||||
void onSubmit();
|
||||
|
||||
private:
|
||||
|
||||
void showAll();
|
||||
void hideAll();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "stdafx.h"
|
||||
#include "platform/linux/main_window_linux.h"
|
||||
|
||||
#include "styles/style_window.h"
|
||||
#include "platform/linux/linux_libs.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "mainwindow.h"
|
||||
|
@ -205,9 +206,6 @@ void MainWindow::psStatusIconCheck() {
|
|||
void MainWindow::psShowTrayMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::psRefreshTaskbarIcon() {
|
||||
}
|
||||
|
||||
void MainWindow::psTrayMenuUpdated() {
|
||||
if (noQtTrayIcon && (useAppIndicator || useStatusIcon)) {
|
||||
const QList<QAction*> &actions = trayIconMenu->actions();
|
||||
|
@ -434,13 +432,10 @@ void MainWindow::LibsLoaded() {
|
|||
}
|
||||
|
||||
void MainWindow::psInitSize() {
|
||||
setMinimumWidth(st::wndMinWidth);
|
||||
setMinimumHeight(st::wndMinHeight);
|
||||
|
||||
TWindowPos pos(cWindowPos());
|
||||
QRect avail(QDesktopWidget().availableGeometry());
|
||||
bool maximized = false;
|
||||
QRect geom(avail.x() + (avail.width() - st::wndDefWidth) / 2, avail.y() + (avail.height() - st::wndDefHeight) / 2, st::wndDefWidth, st::wndDefHeight);
|
||||
QRect geom(avail.x() + (avail.width() - st::windowDefWidth) / 2, avail.y() + (avail.height() - st::windowDefHeight) / 2, st::windowDefWidth, st::windowDefHeight);
|
||||
if (pos.w && pos.h) {
|
||||
QList<QScreen*> screens = Application::screens();
|
||||
for (QList<QScreen*>::const_iterator i = screens.cbegin(), e = screens.cend(); i != e; ++i) {
|
||||
|
@ -448,7 +443,7 @@ void MainWindow::psInitSize() {
|
|||
if (pos.moncrc == hashCrc32(name.constData(), name.size())) {
|
||||
QRect screen((*i)->geometry());
|
||||
int32 w = screen.width(), h = screen.height();
|
||||
if (w >= st::wndMinWidth && h >= st::wndMinHeight) {
|
||||
if (w >= st::windowMinWidth && h >= st::windowMinHeight) {
|
||||
if (pos.w > w) pos.w = w;
|
||||
if (pos.h > h) pos.h = h;
|
||||
pos.x += screen.x();
|
||||
|
@ -649,10 +644,6 @@ void MainWindow::psFirstShow() {
|
|||
posInited = true;
|
||||
}
|
||||
|
||||
bool MainWindow::psHandleTitle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::psInitSysMenu() {
|
||||
}
|
||||
|
||||
|
|
|
@ -43,14 +43,13 @@ public:
|
|||
void psUpdateMargins();
|
||||
void psUpdatedPosition();
|
||||
|
||||
bool psHandleTitle();
|
||||
|
||||
void psFlash();
|
||||
void psNotifySettingGot();
|
||||
|
||||
void psUpdateWorkmode();
|
||||
|
||||
void psRefreshTaskbarIcon();
|
||||
void psRefreshTaskbarIcon() {
|
||||
}
|
||||
|
||||
bool psPosInited() const {
|
||||
return posInited;
|
||||
|
|
|
@ -27,19 +27,6 @@ namespace Notifications {
|
|||
|
||||
inline void defaultNotificationShown(QWidget *widget) {
|
||||
}
|
||||
inline bool skipAudio() {
|
||||
return false;
|
||||
}
|
||||
inline bool skipToast() {
|
||||
return false;
|
||||
}
|
||||
|
||||
class Manager;
|
||||
|
||||
void start();
|
||||
Manager *manager();
|
||||
bool supported();
|
||||
void finish();
|
||||
|
||||
class Manager : public Window::Notifications::NativeManager {
|
||||
public:
|
||||
|
|
|
@ -51,13 +51,12 @@ public:
|
|||
void psUpdateMargins();
|
||||
void psUpdatedPosition();
|
||||
|
||||
bool psHandleTitle();
|
||||
|
||||
void psFlash();
|
||||
|
||||
void psUpdateWorkmode();
|
||||
|
||||
void psRefreshTaskbarIcon();
|
||||
void psRefreshTaskbarIcon() {
|
||||
}
|
||||
|
||||
bool psPosInited() const {
|
||||
return posInited;
|
||||
|
|
|
@ -18,6 +18,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "stdafx.h"
|
||||
#include "platform/mac/main_window_mac.h"
|
||||
|
||||
#include "styles/style_window.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "application.h"
|
||||
|
@ -25,6 +26,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "localstorage.h"
|
||||
#include "window/notifications_manager_default.h"
|
||||
#include "platform/mac/notifications_manager_mac.h"
|
||||
#include "boxes/contactsbox.h"
|
||||
#include "boxes/aboutbox.h"
|
||||
|
||||
#include "lang.h"
|
||||
|
||||
|
@ -90,9 +93,6 @@ QImage MainWindow::psTrayIcon(bool selected) const {
|
|||
void MainWindow::psShowTrayMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::psRefreshTaskbarIcon() {
|
||||
}
|
||||
|
||||
void MainWindow::psTrayMenuUpdated() {
|
||||
}
|
||||
|
||||
|
@ -191,13 +191,10 @@ void MainWindow::psUpdateCounter() {
|
|||
}
|
||||
|
||||
void MainWindow::psInitSize() {
|
||||
setMinimumWidth(st::wndMinWidth);
|
||||
setMinimumHeight(st::wndMinHeight);
|
||||
|
||||
TWindowPos pos(cWindowPos());
|
||||
QRect avail(QDesktopWidget().availableGeometry());
|
||||
bool maximized = false;
|
||||
QRect geom(avail.x() + (avail.width() - st::wndDefWidth) / 2, avail.y() + (avail.height() - st::wndDefHeight) / 2, st::wndDefWidth, st::wndDefHeight);
|
||||
QRect geom(avail.x() + (avail.width() - st::windowDefWidth) / 2, avail.y() + (avail.height() - st::windowDefHeight) / 2, st::windowDefWidth, st::windowDefHeight);
|
||||
if (pos.w && pos.h) {
|
||||
QList<QScreen*> screens = Application::screens();
|
||||
for (QList<QScreen*>::const_iterator i = screens.cbegin(), e = screens.cend(); i != e; ++i) {
|
||||
|
@ -205,7 +202,7 @@ void MainWindow::psInitSize() {
|
|||
if (pos.moncrc == hashCrc32(name.constData(), name.size())) {
|
||||
QRect screen((*i)->geometry());
|
||||
int32 w = screen.width(), h = screen.height();
|
||||
if (w >= st::wndMinWidth && h >= st::wndMinHeight) {
|
||||
if (w >= st::windowMinWidth && h >= st::windowMinHeight) {
|
||||
if (pos.w > w) pos.w = w;
|
||||
if (pos.h > h) pos.h = h;
|
||||
pos.x += screen.x();
|
||||
|
@ -302,8 +299,14 @@ void MainWindow::psFirstShow() {
|
|||
posInited = true;
|
||||
|
||||
// init global menu
|
||||
QMenu *main = psMainMenu.addMenu(qsl("Telegram"));
|
||||
main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram")), App::wnd()->getTitle(), SLOT(onAbout()))->setMenuRole(QAction::AboutQtRole);
|
||||
auto main = psMainMenu.addMenu(qsl("Telegram"));
|
||||
auto about = main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram")));
|
||||
connect(about, SIGNAL(triggered()), base::lambda_slot(about, [] {
|
||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||
Ui::showLayer(new AboutBox());
|
||||
}), SLOT(action()));
|
||||
about->setMenuRole(QAction::AboutQtRole);
|
||||
|
||||
main->addSeparator();
|
||||
QAction *prefs = main->addAction(lang(lng_mac_menu_preferences), App::wnd(), SLOT(showSettings()), QKeySequence(Qt::ControlModifier | Qt::Key_Comma));
|
||||
prefs->setMenuRole(QAction::PreferencesRole);
|
||||
|
@ -323,7 +326,13 @@ void MainWindow::psFirstShow() {
|
|||
psSelectAll = edit->addAction(lang(lng_mac_menu_select_all), this, SLOT(psMacSelectAll()), QKeySequence::SelectAll);
|
||||
|
||||
QMenu *window = psMainMenu.addMenu(lang(lng_mac_menu_window));
|
||||
psContacts = window->addAction(lang(lng_mac_menu_contacts), App::wnd()->getTitle(), SLOT(onContacts()));
|
||||
psContacts = window->addAction(lang(lng_mac_menu_contacts));
|
||||
connect(psContacts, SIGNAL(triggered()), base::lambda_slot(psContacts, [] {
|
||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||
|
||||
if (!App::self()) return;
|
||||
Ui::showLayer(new ContactsBox());
|
||||
}, SLOT(action()));
|
||||
psAddContact = window->addAction(lang(lng_mac_menu_add_contact), App::wnd(), SLOT(onShowAddContact()));
|
||||
window->addSeparator();
|
||||
psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup()));
|
||||
|
@ -379,10 +388,6 @@ void MainWindow::psMacSelectAll() {
|
|||
_sendKeySequence(Qt::Key_A, Qt::ControlModifier);
|
||||
}
|
||||
|
||||
bool MainWindow::psHandleTitle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::psInitSysMenu() {
|
||||
}
|
||||
|
||||
|
|
|
@ -25,20 +25,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
namespace Platform {
|
||||
namespace Notifications {
|
||||
|
||||
void defaultNotificationShown(QWidget *widget);
|
||||
inline bool skipAudio() {
|
||||
return false;
|
||||
}
|
||||
inline bool skipToast() {
|
||||
return false;
|
||||
}
|
||||
|
||||
class Manager;
|
||||
|
||||
void start();
|
||||
Manager *manager();
|
||||
void finish();
|
||||
|
||||
class Manager : public Window::Notifications::NativeManager {
|
||||
public:
|
||||
Manager();
|
||||
|
|
|
@ -22,20 +22,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
|
||||
#include "ui/filedialog.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
namespace Platform {
|
||||
namespace FileDialog {
|
||||
inline bool Supported() {
|
||||
return false;
|
||||
}
|
||||
inline bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, ::FileDialog::internal::Type type, QString startFile) {
|
||||
return false;
|
||||
}
|
||||
} // namespace FileDialog
|
||||
} // namespace Platform
|
||||
#elif defined Q_OS_LINUX // Q_OS_MAC
|
||||
#if defined Q_OS_LINUX
|
||||
#include "platform/linux/file_dialog_linux.h"
|
||||
#elif defined Q_OS_WINRT // Q_OS_MAC || Q_OS_LINUX
|
||||
#else // Q_OS_LINUX
|
||||
namespace Platform {
|
||||
namespace FileDialog {
|
||||
inline bool Supported() {
|
||||
|
@ -46,15 +35,4 @@ inline bool Get(QStringList &files, QByteArray &remoteContent, const QString &ca
|
|||
}
|
||||
} // namespace FileDialog
|
||||
} // namespace Platform
|
||||
#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT
|
||||
namespace Platform {
|
||||
namespace FileDialog {
|
||||
inline bool Supported() {
|
||||
return false;
|
||||
}
|
||||
inline bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, ::FileDialog::internal::Type type, QString startFile) {
|
||||
return false;
|
||||
}
|
||||
} // namespace FileDialog
|
||||
} // namespace Platform
|
||||
#endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN
|
||||
#endif // else for Q_OS_LINUX
|
||||
|
|
|
@ -20,6 +20,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
// Platform module must define a Platform::Notifications::Manager class.
|
||||
// It should be Window::Notifications::Manager or its derivative.
|
||||
#ifdef Q_OS_MAC
|
||||
#include "platform/mac/notifications_manager_mac.h"
|
||||
#elif defined Q_OS_LINUX // Q_OS_MAC
|
||||
|
@ -29,3 +31,19 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT
|
||||
#include "platform/win/notifications_manager_win.h"
|
||||
#endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN
|
||||
|
||||
// Platform-independent API.
|
||||
namespace Platform {
|
||||
namespace Notifications {
|
||||
|
||||
void defaultNotificationShown(QWidget *widget);
|
||||
bool skipAudio();
|
||||
bool skipToast();
|
||||
|
||||
void start();
|
||||
Manager *manager();
|
||||
bool supported();
|
||||
void finish();
|
||||
|
||||
} // namespace Notifications
|
||||
} // namespace Platform
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include "window/window_title.h"
|
||||
|
||||
#if defined Q_OS_WIN
|
||||
#include "platform/win/window_title_win.h"
|
||||
#else // Q_OS_WIN
|
||||
namespace Platform {
|
||||
|
||||
inline Window::TitleWidget *CreateTitleWidget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
#endif // else for Q_OS_WIN
|
|
@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "stdafx.h"
|
||||
#include "platform/win/main_window_win.h"
|
||||
|
||||
#include "styles/style_window.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "platform/win/windows_dlls.h"
|
||||
#include "window/notifications_manager.h"
|
||||
|
@ -140,13 +141,13 @@ public:
|
|||
}
|
||||
|
||||
bool init(QColor c) {
|
||||
_fullsize = st::wndShadow.width();
|
||||
_shift = st::wndShadowShift;
|
||||
_fullsize = st::windowShadow.width();
|
||||
_shift = st::windowShadowShift;
|
||||
QImage cornersImage(_fullsize, _fullsize, QImage::Format_ARGB32_Premultiplied);
|
||||
{
|
||||
Painter p(&cornersImage);
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
st::wndShadow.paint(p, 0, 0, _fullsize);
|
||||
st::windowShadow.paint(p, 0, 0, _fullsize);
|
||||
}
|
||||
if (rtl()) cornersImage = cornersImage.mirrored(true, false);
|
||||
|
||||
|
@ -191,9 +192,9 @@ public:
|
|||
|
||||
QRect avail(Sandbox::availableGeometry());
|
||||
max_w = avail.width();
|
||||
if (max_w < st::wndMinWidth) max_w = st::wndMinWidth;
|
||||
accumulate_max(max_w, st::windowMinWidth);
|
||||
max_h = avail.height();
|
||||
if (max_h < st::wndMinHeight) max_h = st::wndMinHeight;
|
||||
accumulate_max(max_h, st::windowMinHeight);
|
||||
|
||||
HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0);
|
||||
HWND hwnd = App::wnd() ? App::wnd()->psHwnd() : 0;
|
||||
|
@ -645,7 +646,7 @@ void MainWindow::psShowTrayMenu() {
|
|||
|
||||
void MainWindow::psRefreshTaskbarIcon() {
|
||||
QWidget *w = new QWidget(this);
|
||||
w->setWindowFlags(::operator|(Qt::Tool, Qt::FramelessWindowHint));
|
||||
w->setWindowFlags(static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint);
|
||||
w->setGeometry(x() + 1, y() + 1, 1, 1);
|
||||
QPalette p(w->palette());
|
||||
p.setColor(QPalette::Background, st::titleBg->c);
|
||||
|
@ -776,20 +777,17 @@ BOOL CALLBACK _monitorEnumProc(
|
|||
} // namespace
|
||||
|
||||
void MainWindow::psInitSize() {
|
||||
setMinimumWidth(st::wndMinWidth);
|
||||
setMinimumHeight(st::wndMinHeight);
|
||||
|
||||
TWindowPos pos(cWindowPos());
|
||||
QRect avail(Sandbox::availableGeometry());
|
||||
bool maximized = false;
|
||||
QRect geom(avail.x() + (avail.width() - st::wndDefWidth) / 2, avail.y() + (avail.height() - st::wndDefHeight) / 2, st::wndDefWidth, st::wndDefHeight);
|
||||
QRect geom(avail.x() + (avail.width() - st::windowDefWidth) / 2, avail.y() + (avail.height() - st::windowDefHeight) / 2, st::windowDefWidth, st::windowDefHeight);
|
||||
if (pos.w && pos.h) {
|
||||
if (pos.y < 0) pos.y = 0;
|
||||
enumMonitor = 0;
|
||||
EnumDisplayMonitors(0, 0, &_monitorEnumProc, pos.moncrc);
|
||||
if (enumMonitor) {
|
||||
int32 w = enumMonitorWork.right - enumMonitorWork.left, h = enumMonitorWork.bottom - enumMonitorWork.top;
|
||||
if (w >= st::wndMinWidth && h >= st::wndMinHeight) {
|
||||
if (w >= st::windowMinWidth && h >= st::windowMinHeight) {
|
||||
if (pos.w > w) pos.w = w;
|
||||
if (pos.h > h) pos.h = h;
|
||||
pos.x += enumMonitorWork.left;
|
||||
|
@ -853,7 +851,7 @@ void MainWindow::psSavePosition(Qt::WindowState state) {
|
|||
curPos.moncrc = hashCrc32(info.szDevice, sizeof(info.szDevice));
|
||||
}
|
||||
|
||||
if (curPos.w >= st::wndMinWidth && curPos.h >= st::wndMinHeight) {
|
||||
if (curPos.w >= st::windowMinWidth && curPos.h >= st::windowMinHeight) {
|
||||
if (curPos.x != pos.x || curPos.y != pos.y || curPos.w != pos.w || curPos.h != pos.h || curPos.moncrc != pos.moncrc || curPos.maximized != pos.maximized) {
|
||||
cSetWindowPos(curPos);
|
||||
Local::writeSettings();
|
||||
|
@ -902,10 +900,6 @@ void MainWindow::psFirstShow() {
|
|||
}
|
||||
}
|
||||
|
||||
bool MainWindow::psHandleTitle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::psInitSysMenu() {
|
||||
Qt::WindowStates states = windowState();
|
||||
ps_menu = GetSystemMenu(ps_hWnd, FALSE);
|
||||
|
|
|
@ -50,8 +50,6 @@ public:
|
|||
void psUpdateMargins();
|
||||
void psUpdatedPosition();
|
||||
|
||||
bool psHandleTitle();
|
||||
|
||||
void psFlash();
|
||||
void psNotifySettingGot();
|
||||
|
||||
|
|
|
@ -27,15 +27,6 @@ namespace Notifications {
|
|||
|
||||
inline void defaultNotificationShown(QWidget *widget) {
|
||||
}
|
||||
bool skipAudio();
|
||||
bool skipToast();
|
||||
|
||||
class Manager;
|
||||
|
||||
void start();
|
||||
Manager *manager();
|
||||
bool supported();
|
||||
void finish();
|
||||
|
||||
class Manager : public Window::Notifications::NativeManager {
|
||||
public:
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
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 "platform/win/window_title_win.h"
|
||||
|
||||
#include "ui/buttons/icon_button.h"
|
||||
#include "styles/style_window.h"
|
||||
|
||||
namespace Platform {
|
||||
|
||||
TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent)
|
||||
, _minimize(this, st::titleButtonMinimize)
|
||||
, _maximizeRestore(this, st::titleButtonMaximize)
|
||||
, _close(this, st::titleButtonClose)
|
||||
, _maximized(parent->window()->windowState() & Qt::WindowMaximized) {
|
||||
_minimize->setClickedCallback([this]() {
|
||||
window()->setWindowState(Qt::WindowMinimized);
|
||||
_minimize->clearState();
|
||||
});
|
||||
_maximizeRestore->setClickedCallback([this]() {
|
||||
window()->setWindowState(_maximized ? Qt::WindowNoState : Qt::WindowMaximized);
|
||||
_maximizeRestore->clearState();
|
||||
});
|
||||
_close->setClickedCallback([this]() {
|
||||
window()->close();
|
||||
_close->clearState();
|
||||
});
|
||||
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
updateMaximizeRestoreButton();
|
||||
|
||||
onWindowStateChanged();
|
||||
|
||||
connect(parent->window()->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(onWindowStateChanged(Qt::WindowState)));
|
||||
}
|
||||
|
||||
void TitleWidget::paintEvent(QPaintEvent *e) {
|
||||
Painter(this).fillRect(rect(), st::titleBg);
|
||||
}
|
||||
|
||||
void TitleWidget::updateControlsPosition() {
|
||||
auto right = 0;
|
||||
_close->moveToRight(right, 0); right += _close->width();
|
||||
_maximizeRestore->moveToRight(right, 0); right += _maximizeRestore->width();
|
||||
_minimize->moveToRight(right, 0);
|
||||
}
|
||||
|
||||
void TitleWidget::resizeEvent(QResizeEvent *e) {
|
||||
updateControlsPosition();
|
||||
}
|
||||
|
||||
void TitleWidget::updateControlsVisibility() {
|
||||
updateControlsPosition();
|
||||
update();
|
||||
}
|
||||
|
||||
void TitleWidget::onWindowStateChanged(Qt::WindowState state) {
|
||||
if (state == Qt::WindowMinimized) return;
|
||||
|
||||
auto maximized = (state == Qt::WindowMaximized);
|
||||
if (_maximized != maximized) {
|
||||
_maximized = maximized;
|
||||
updateMaximizeRestoreButton();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::updateMaximizeRestoreButton() {
|
||||
if (_maximized) {
|
||||
_maximizeRestore->setIcon(&st::titleButtonRestoreIcon, &st::titleButtonRestoreIconOver);
|
||||
} else {
|
||||
_maximizeRestore->setIcon(nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Window::HitTestResult TitleWidget::hitTest(const QPoint &p) const {
|
||||
if (false
|
||||
|| (_minimize->geometry().contains(p))
|
||||
|| (_maximizeRestore->geometry().contains(p))
|
||||
|| (_close->geometry().contains(p))
|
||||
) {
|
||||
return Window::HitTestResult::SysButton;
|
||||
} else if (rect().contains(p)) {
|
||||
return Window::HitTestResult::Caption;
|
||||
}
|
||||
return Window::HitTestResult::None;
|
||||
}
|
||||
|
||||
} // namespace Platform
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include "window/window_title.h"
|
||||
|
||||
namespace Ui {
|
||||
class IconButton;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Platform {
|
||||
|
||||
class TitleWidget : public Window::TitleWidget, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TitleWidget(QWidget *parent);
|
||||
|
||||
Window::HitTestResult hitTest(const QPoint &p) const override;
|
||||
|
||||
public slots:
|
||||
void onWindowStateChanged(Qt::WindowState state = Qt::WindowNoState);
|
||||
void updateControlsVisibility();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
void updateMaximizeRestoreButton();
|
||||
void updateControlsPosition();
|
||||
|
||||
ChildWidget<Ui::IconButton> _minimize;
|
||||
ChildWidget<Ui::IconButton> _maximizeRestore;
|
||||
ChildWidget<Ui::IconButton> _close;
|
||||
|
||||
bool _maximized = false;
|
||||
|
||||
};
|
||||
|
||||
inline Window::TitleWidget *CreateTitleWidget(QWidget *parent) {
|
||||
return new TitleWidget(parent);
|
||||
}
|
||||
|
||||
} // namespace Platform
|
|
@ -183,19 +183,19 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
GetWindowRect(hWnd, &r);
|
||||
auto res = App::wnd()->hitTest(QPoint(p.x - r.left + App::wnd()->deltaLeft(), p.y - r.top + App::wnd()->deltaTop()));
|
||||
switch (res) {
|
||||
case HitTestType::Client:
|
||||
case HitTestType::SysButton: *result = HTCLIENT; break;
|
||||
case HitTestType::Icon: *result = HTCAPTION; break;
|
||||
case HitTestType::Caption: *result = HTCAPTION; break;
|
||||
case HitTestType::Top: *result = HTTOP; break;
|
||||
case HitTestType::TopRight: *result = HTTOPRIGHT; break;
|
||||
case HitTestType::Right: *result = HTRIGHT; break;
|
||||
case HitTestType::BottomRight: *result = HTBOTTOMRIGHT; break;
|
||||
case HitTestType::Bottom: *result = HTBOTTOM; break;
|
||||
case HitTestType::BottomLeft: *result = HTBOTTOMLEFT; break;
|
||||
case HitTestType::Left: *result = HTLEFT; break;
|
||||
case HitTestType::TopLeft: *result = HTTOPLEFT; break;
|
||||
case HitTestType::None:
|
||||
case Window::HitTestResult::Client:
|
||||
case Window::HitTestResult::SysButton: *result = HTCLIENT; break;
|
||||
case Window::HitTestResult::Icon: *result = HTCAPTION; break;
|
||||
case Window::HitTestResult::Caption: *result = HTCAPTION; break;
|
||||
case Window::HitTestResult::Top: *result = HTTOP; break;
|
||||
case Window::HitTestResult::TopRight: *result = HTTOPRIGHT; break;
|
||||
case Window::HitTestResult::Right: *result = HTRIGHT; break;
|
||||
case Window::HitTestResult::BottomRight: *result = HTBOTTOMRIGHT; break;
|
||||
case Window::HitTestResult::Bottom: *result = HTBOTTOM; break;
|
||||
case Window::HitTestResult::BottomLeft: *result = HTBOTTOMLEFT; break;
|
||||
case Window::HitTestResult::Left: *result = HTLEFT; break;
|
||||
case Window::HitTestResult::TopLeft: *result = HTTOPLEFT; break;
|
||||
case Window::HitTestResult::None:
|
||||
default: *result = HTTRANSPARENT; break;
|
||||
};
|
||||
} return true;
|
||||
|
@ -210,7 +210,7 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
GetWindowRect(hWnd, &r);
|
||||
auto res = App::wnd()->hitTest(QPoint(p.x - r.left + App::wnd()->deltaLeft(), p.y - r.top + App::wnd()->deltaTop()));
|
||||
switch (res) {
|
||||
case HitTestType::Icon:
|
||||
case Window::HitTestResult::Icon:
|
||||
if (menuHidden && getms() < menuHidden + 10) {
|
||||
menuHidden = 0;
|
||||
if (getms() < menuShown + GetDoubleClickTime()) {
|
||||
|
@ -236,7 +236,7 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
GetWindowRect(hWnd, &r);
|
||||
auto res = App::wnd()->hitTest(QPoint(p.x - r.left + App::wnd()->deltaLeft(), p.y - r.top + App::wnd()->deltaTop()));
|
||||
switch (res) {
|
||||
case HitTestType::Icon: App::wnd()->close(); return true;
|
||||
case Window::HitTestResult::Icon: App::wnd()->close(); return true;
|
||||
};
|
||||
} return false;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "profile/profile_cover.h"
|
||||
|
||||
#include "styles/style_profile.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "profile/profile_cover_drop_area.h"
|
||||
#include "profile/profile_userpic_button.h"
|
||||
#include "ui/buttons/round_button.h"
|
||||
|
@ -112,7 +113,7 @@ void CoverWidget::onCancelPhotoUpload() {
|
|||
|
||||
int CoverWidget::countPhotoLeft(int newWidth) const {
|
||||
int result = st::profilePhotoLeftMin;
|
||||
result += (newWidth - st::wndMinWidth) / 2;
|
||||
result += (newWidth - st::windowMinWidth) / 2;
|
||||
return qMin(result, st::profilePhotoLeftMax);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "profile/profile_inner_widget.h"
|
||||
|
||||
#include "styles/style_profile.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "profile/profile_cover.h"
|
||||
#include "profile/profile_info_widget.h"
|
||||
#include "profile/profile_settings_widget.h"
|
||||
|
@ -132,7 +133,7 @@ int InnerWidget::countBlocksHeight(BlockSide countSide) const {
|
|||
|
||||
int InnerWidget::countBlocksLeft(int newWidth) const {
|
||||
int result = st::profileBlockLeftMin;
|
||||
result += (newWidth - st::wndMinWidth) / 2;
|
||||
result += (newWidth - st::windowMinWidth) / 2;
|
||||
return qMin(result, st::profileBlockLeftMax);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include "sysbuttons.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "pspecific_mac.h"
|
||||
#elif defined Q_OS_LINUX // Q_OS_MAC
|
||||
|
|
|
@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "localstorage.h"
|
||||
#include "media/player/media_player_instance.h"
|
||||
#include "platform/mac/mac_utilities.h"
|
||||
|
||||
#include "styles/style_window.h"
|
||||
#include "lang.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
|
|
@ -85,7 +85,6 @@ void ScaleWidget::setScale(DBIScale newScale) {
|
|||
|
||||
cSetConfigScale(newScale);
|
||||
Local::writeSettings();
|
||||
App::wnd()->getTitle()->updateControlsVisibility();
|
||||
if (newScale == dbisAuto && !_auto->checked()) {
|
||||
_auto->setChecked(true);
|
||||
} else if (newScale != dbisAuto && _auto->checked()) {
|
||||
|
|
|
@ -24,6 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
#include "settings/settings_inner_widget.h"
|
||||
#include "settings/settings_fixed_bar.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "ui/widgets/shadow.h"
|
||||
#include "ui/scrollarea.h"
|
||||
|
@ -123,7 +124,7 @@ void codesFeedString(const QString &text) {
|
|||
|
||||
} // namespace
|
||||
|
||||
Widget::Widget() : LayerWidget()
|
||||
Widget::Widget(QWidget *parent) : LayerWidget(parent)
|
||||
, _scroll(this, st::setScroll)
|
||||
, _inner(this)
|
||||
, _fixedBar(this)
|
||||
|
@ -147,18 +148,18 @@ void Widget::parentResized() {
|
|||
if (windowWidth <= st::settingsMaxWidth) {
|
||||
newWidth = windowWidth;
|
||||
newContentLeft = st::settingsMinPadding;
|
||||
if (windowWidth > st::wndMinWidth) {
|
||||
// Width changes from st::wndMinWidth to st::settingsMaxWidth.
|
||||
if (windowWidth > st::windowMinWidth) {
|
||||
// Width changes from st::windowMinWidth to st::settingsMaxWidth.
|
||||
// Padding changes from st::settingsMinPadding to st::settingsMaxPadding.
|
||||
newContentLeft += ((newWidth - st::wndMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::wndMinWidth);
|
||||
newContentLeft += ((newWidth - st::windowMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::windowMinWidth);
|
||||
}
|
||||
} 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.
|
||||
if (windowWidth > st::windowMinWidth) {
|
||||
// Width changes from st::windowMinWidth to st::settingsMaxWidth.
|
||||
// Padding changes from st::settingsMinPadding to st::settingsMaxPadding.
|
||||
newContentLeft += ((newWidth - st::wndMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::wndMinWidth);
|
||||
newContentLeft += ((newWidth - st::windowMinWidth) * (st::settingsMaxPadding - st::settingsMinPadding)) / (st::settingsMaxWidth - st::windowMinWidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class Widget : public LayerWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Widget();
|
||||
Widget(QWidget *parent);
|
||||
|
||||
void parentResized() override;
|
||||
void showDone() override;
|
||||
|
|
|
@ -981,11 +981,11 @@ void DocumentOpenClickHandler::doOpen(DocumentData *data, HistoryItem *context,
|
|||
auto &location = data->location(true);
|
||||
if (auto applyTheme = data->name.endsWith(qstr(".tdesktop-theme"))) {
|
||||
if (!location.isEmpty() && location.accessEnable()) {
|
||||
if (Window::Theme::Apply(location.name())) {
|
||||
location.accessDisable();
|
||||
return;
|
||||
if (!Window::Theme::Apply(location.name())) {
|
||||
// show error?
|
||||
}
|
||||
location.accessDisable();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!location.isEmpty() || (!data->data().isEmpty() && (playVoice || playMusic || playVideo || playAnimation))) {
|
||||
|
@ -1290,11 +1290,11 @@ void DocumentData::performActionOnLoad() {
|
|||
bool playAnimation = isAnimation() && (_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen) && showImage && item && item->getMedia();
|
||||
if (auto applyTheme = name.endsWith(qstr(".tdesktop-theme"))) {
|
||||
if (!loc.isEmpty() && loc.accessEnable()) {
|
||||
if (Window::Theme::Apply(loc.name())) {
|
||||
loc.accessDisable();
|
||||
return;
|
||||
if (!Window::Theme::Apply(loc.name())) {
|
||||
// show error?
|
||||
}
|
||||
loc.accessDisable();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (playVoice) {
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
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 "sysbuttons.h"
|
||||
|
||||
#include "lang.h"
|
||||
#include "shortcuts.h"
|
||||
#include "application.h"
|
||||
#include "autoupdater.h"
|
||||
|
||||
SysBtn::SysBtn(QWidget *parent, const style::sysButton &st, const QString &text) : Button(parent)
|
||||
, _st(&st)
|
||||
, a_color(_st->color->c)
|
||||
, _a_color(animation(this, &SysBtn::step_color))
|
||||
, _text(text) {
|
||||
int32 w = _st->size.width() + (_text.isEmpty() ? 0 : ((_st->size.width() - _st->icon.width()) / 2 + st::titleTextButton.font->width(_text)));
|
||||
resize(w, _st->size.height());
|
||||
setCursor(style::cur_default);
|
||||
}
|
||||
|
||||
void SysBtn::setText(const QString &text) {
|
||||
_text = text;
|
||||
int32 w = _st->size.width() + (_text.isEmpty() ? 0 : ((_st->size.width() - _st->icon.width()) / 2 + st::titleTextButton.font->width(_text)));
|
||||
resize(w, _st->size.height());
|
||||
}
|
||||
|
||||
void SysBtn::setOverLevel(float64 level) {
|
||||
_overLevel = level;
|
||||
update();
|
||||
}
|
||||
|
||||
void SysBtn::onStateChanged(int oldState, ButtonStateChangeSource source) {
|
||||
a_color.start((_state & StateOver ? _st->overColor : _st->color)->c);
|
||||
|
||||
if (source == ButtonByUser || source == ButtonByPress) {
|
||||
_a_color.stop();
|
||||
a_color.finish();
|
||||
update();
|
||||
} else {
|
||||
_a_color.start();
|
||||
}
|
||||
}
|
||||
|
||||
void SysBtn::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
int x = width() - ((_st->size.width() + _st->icon.width()) / 2), y = (height() - _st->icon.height()) / 2;
|
||||
QColor c = a_color.current();
|
||||
if (_overLevel > 0) {
|
||||
if (_overLevel >= 1) {
|
||||
c = _st->overColor->c;
|
||||
} else {
|
||||
c.setRedF(c.redF() * (1 - _overLevel) + _st->overColor->c.redF() * _overLevel);
|
||||
c.setGreenF(c.greenF() * (1 - _overLevel) + _st->overColor->c.greenF() * _overLevel);
|
||||
c.setBlueF(c.blueF() * (1 - _overLevel) + _st->overColor->c.blueF() * _overLevel);
|
||||
}
|
||||
}
|
||||
p.fillRect(x, y, _st->icon.width(), _st->icon.height(), c);
|
||||
_st->icon.paint(p, x, y, width());
|
||||
|
||||
if (!_text.isEmpty()) {
|
||||
p.setFont(st::titleTextButton.font->f);
|
||||
p.setPen(c);
|
||||
p.drawText((_st->size.width() - _st->icon.width()) / 2, st::titleTextButton.textTop + st::titleTextButton.font->ascent, _text);
|
||||
}
|
||||
}
|
||||
|
||||
void SysBtn::setSysBtnStyle(const style::sysButton &st) {
|
||||
_st = &st;
|
||||
update();
|
||||
}
|
||||
|
||||
HitTestType SysBtn::hitTest(const QPoint &p) const {
|
||||
int x(p.x()), y(p.y()), w(width()), h(height());
|
||||
if (x >= 0 && y >= 0 && x < w && y < h && isVisible()) {
|
||||
return HitTestType::SysButton;
|
||||
}
|
||||
return HitTestType::None;
|
||||
}
|
||||
|
||||
void SysBtn::step_color(float64 ms, bool timer) {
|
||||
float64 dt = ms / _st->duration;
|
||||
if (dt >= 1) {
|
||||
_a_color.stop();
|
||||
a_color.finish();
|
||||
} else {
|
||||
a_color.update(dt, anim::linear);
|
||||
}
|
||||
if (timer) update();
|
||||
}
|
||||
|
||||
MinimizeBtn::MinimizeBtn(QWidget *parent) : SysBtn(parent, st::sysMin) {
|
||||
setClickedCallback([this]() {
|
||||
window()->setWindowState(Qt::WindowMinimized);
|
||||
});
|
||||
}
|
||||
|
||||
MaximizeBtn::MaximizeBtn(QWidget *parent) : SysBtn(parent, st::sysMax) {
|
||||
setClickedCallback([this]() {
|
||||
window()->setWindowState(Qt::WindowMaximized);
|
||||
});
|
||||
}
|
||||
|
||||
RestoreBtn::RestoreBtn(QWidget *parent) : SysBtn(parent, st::sysRes) {
|
||||
setClickedCallback([this]() {
|
||||
window()->setWindowState(Qt::WindowNoState);
|
||||
});
|
||||
}
|
||||
|
||||
CloseBtn::CloseBtn(QWidget *parent) : SysBtn(parent, st::sysCls) {
|
||||
setClickedCallback([this]() {
|
||||
window()->close();
|
||||
});
|
||||
}
|
||||
|
||||
UpdateBtn::UpdateBtn(QWidget *parent) : SysBtn(parent, st::sysUpd, lang(lng_menu_update)) {
|
||||
setClickedCallback([]() {
|
||||
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
||||
checkReadyUpdate();
|
||||
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
|
||||
App::restart();
|
||||
});
|
||||
}
|
||||
|
||||
LockBtn::LockBtn(QWidget *parent) : SysBtn(parent, st::sysLock) {
|
||||
setClickedCallback([] {
|
||||
Shortcuts::launch(qsl("lock_telegram"));
|
||||
});
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include "ui/animation.h"
|
||||
#include "ui/button.h"
|
||||
|
||||
enum class HitTestType {
|
||||
None = 0,
|
||||
Client,
|
||||
SysButton,
|
||||
Icon,
|
||||
Caption,
|
||||
Top,
|
||||
TopRight,
|
||||
Right,
|
||||
BottomRight,
|
||||
Bottom,
|
||||
BottomLeft,
|
||||
Left,
|
||||
TopLeft,
|
||||
};
|
||||
|
||||
class SysBtn : public Button {
|
||||
public:
|
||||
SysBtn(QWidget *parent, const style::sysButton &st, const QString &text = QString());
|
||||
|
||||
void setText(const QString &text);
|
||||
void setSysBtnStyle(const style::sysButton &st);
|
||||
|
||||
HitTestType hitTest(const QPoint &p) const;
|
||||
|
||||
void setOverLevel(float64 level);
|
||||
|
||||
void step_color(float64 ms, bool timer);
|
||||
|
||||
protected:
|
||||
void onStateChanged(int oldState, ButtonStateChangeSource source) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
const style::sysButton *_st;
|
||||
anim::cvalue a_color;
|
||||
Animation _a_color;
|
||||
|
||||
float64 _overLevel = 0.;
|
||||
QString _text;
|
||||
|
||||
};
|
||||
|
||||
class MinimizeBtn : public SysBtn {
|
||||
public:
|
||||
MinimizeBtn(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
class MaximizeBtn : public SysBtn {
|
||||
public:
|
||||
MaximizeBtn(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
class RestoreBtn : public SysBtn {
|
||||
public:
|
||||
RestoreBtn(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
class CloseBtn : public SysBtn {
|
||||
public:
|
||||
CloseBtn(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
class UpdateBtn : public SysBtn {
|
||||
public:
|
||||
UpdateBtn(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
class LockBtn : public SysBtn {
|
||||
public:
|
||||
LockBtn(QWidget *parent);
|
||||
|
||||
};
|
|
@ -1,427 +0,0 @@
|
|||
/*
|
||||
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 "title.h"
|
||||
|
||||
#include "lang.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "application.h"
|
||||
#include "boxes/contactsbox.h"
|
||||
#include "boxes/aboutbox.h"
|
||||
#include "media/media_audio.h"
|
||||
#include "media/player/media_player_title_button.h"
|
||||
#include "media/player/media_player_panel.h"
|
||||
#include "media/player/media_player_instance.h"
|
||||
#include "styles/style_window.h"
|
||||
|
||||
class TitleWidget::Hider : public TWidget {
|
||||
public:
|
||||
Hider(QWidget *parent);
|
||||
|
||||
using ClickedCallback = base::lambda_unique<void()>;
|
||||
void setClickedCallback(ClickedCallback &&callback) {
|
||||
_callback = std_::move(callback);
|
||||
}
|
||||
void setLevel(float64 level);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
private:
|
||||
ClickedCallback _callback;
|
||||
float64 _level = 0;
|
||||
|
||||
};
|
||||
|
||||
TitleWidget::Hider::Hider(QWidget *parent) : TWidget(parent) {
|
||||
}
|
||||
|
||||
void TitleWidget::Hider::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
p.setOpacity(_level);
|
||||
p.fillRect(App::main()->dlgsWidth(), 0, width() - App::main()->dlgsWidth(), height(), st::layerBg);
|
||||
}
|
||||
|
||||
void TitleWidget::Hider::mousePressEvent(QMouseEvent *e) {
|
||||
if (e->button() == Qt::LeftButton && _callback) {
|
||||
_callback();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::Hider::setLevel(float64 level) {
|
||||
_level = level;
|
||||
update();
|
||||
}
|
||||
|
||||
TitleWidget::TitleWidget(QWidget *parent) : TWidget(parent)
|
||||
, _cancel(this, lang(lng_cancel), st::titleTextButton)
|
||||
, _settings(this, lang(lng_menu_settings), st::titleTextButton)
|
||||
, _contacts(this, lang(lng_menu_contacts), st::titleTextButton)
|
||||
, _about(this, lang(lng_menu_about), st::titleTextButton)
|
||||
, _lock(this)
|
||||
, _update(this)
|
||||
, _minimize(this)
|
||||
, _maximize(this)
|
||||
, _restore(this)
|
||||
, _close(this)
|
||||
, _a_update(animation(this, &TitleWidget::step_update))
|
||||
, lastMaximized(!(parent->windowState() & Qt::WindowMaximized)) {
|
||||
setGeometry(0, 0, parent->width(), st::titleHeight);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
onWindowStateChanged();
|
||||
updateControlsVisibility();
|
||||
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SIGNAL(hiderClicked()));
|
||||
connect(&_settings, SIGNAL(clicked()), parent, SLOT(showSettings()));
|
||||
connect(&_contacts, SIGNAL(clicked()), this, SLOT(onContacts()));
|
||||
connect(&_about, SIGNAL(clicked()), this, SLOT(onAbout()));
|
||||
connect(parent->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(onWindowStateChanged(Qt::WindowState)));
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
||||
Sandbox::connect(SIGNAL(updateReady()), this, SLOT(updateControlsVisibility()));
|
||||
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
|
||||
|
||||
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
|
||||
if (Media::Player::exists()) {
|
||||
subscribe(Media::Player::instance()->usePanelPlayer(), [this](bool usePanel) {
|
||||
updatePlayerButton(usePanel);
|
||||
});
|
||||
}
|
||||
|
||||
if (cPlatform() != dbipWindows) {
|
||||
_minimize.hide();
|
||||
_maximize.hide();
|
||||
_restore.hide();
|
||||
_close.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
p.fillRect(rect(), st::titleBg);
|
||||
if (!_cancel.isHidden()) {
|
||||
p.setPen(st::titleTextButton.color);
|
||||
p.setFont(st::titleTextButton.font);
|
||||
bool inlineSwitchChoose = (App::main() && App::main()->selectingPeerForInlineSwitch());
|
||||
auto chooseText = lang(inlineSwitchChoose ? lng_inline_switch_choose : lng_forward_choose);
|
||||
p.drawText(st::titleMenuOffset - st::titleTextButton.width / 2, st::titleTextButton.textTop + st::titleTextButton.font->ascent, chooseText);
|
||||
}
|
||||
st::titleIcon.paint(p, st::titleIconPosition, width());
|
||||
if (Adaptive::OneColumn() && !_counter.isNull() && App::main()) {
|
||||
p.drawPixmap(st::titleCounterPosition, _counter);
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::step_update(float64 ms, bool timer) {
|
||||
float64 phase = sin(M_PI_2 * (ms / st::updateBlinkDuration));
|
||||
if (phase < 0) phase = -phase;
|
||||
_update.setOverLevel(phase);
|
||||
}
|
||||
|
||||
void TitleWidget::setHideLevel(float64 level) {
|
||||
if (level != hideLevel) {
|
||||
hideLevel = level;
|
||||
if (hideLevel) {
|
||||
if (!_hider) {
|
||||
_hider.create(this);
|
||||
_hider->setGeometry(rect());
|
||||
_hider->setClickedCallback([this]() { emit hiderClicked(); });
|
||||
_hider->setVisible(!Adaptive::OneColumn());
|
||||
}
|
||||
_hider->setLevel(hideLevel);
|
||||
} else {
|
||||
if (_hider) {
|
||||
_hider.destroyDelayed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::onContacts() {
|
||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||
|
||||
if (!App::self()) return;
|
||||
Ui::showLayer(new ContactsBox());
|
||||
}
|
||||
|
||||
void TitleWidget::onAbout() {
|
||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||
Ui::showLayer(new AboutBox());
|
||||
}
|
||||
|
||||
void TitleWidget::updatePlayerButton(bool usePanel) {
|
||||
if (usePanel && !_player) {
|
||||
_player.create(this);
|
||||
} else if (!usePanel && _player) {
|
||||
_player.destroyDelayed();
|
||||
}
|
||||
updateControlsVisibility();
|
||||
}
|
||||
|
||||
void TitleWidget::updateControlsPosition() {
|
||||
QPoint p(width() - ((cPlatform() == dbipWindows && lastMaximized) ? 0 : st::sysBtnDelta), 0);
|
||||
|
||||
if (!_update.isHidden()) {
|
||||
p.setX(p.x() - _update.width());
|
||||
_update.move(p);
|
||||
if (!_lock.isHidden()) {
|
||||
p.setX(p.x() - _lock.width());
|
||||
_lock.move(p);
|
||||
p.setX(p.x() + _lock.width());
|
||||
}
|
||||
p.setX(p.x() + _update.width());
|
||||
}
|
||||
_cancel.move(p.x() - _cancel.width(), 0);
|
||||
|
||||
if (cPlatform() == dbipWindows) {
|
||||
p.setX(p.x() - _close.width());
|
||||
_close.move(p);
|
||||
|
||||
p.setX(p.x() - _maximize.width());
|
||||
_restore.move(p); _maximize.move(p);
|
||||
|
||||
p.setX(p.x() - _minimize.width());
|
||||
_minimize.move(p);
|
||||
}
|
||||
if (_update.isHidden() && !_lock.isHidden()) {
|
||||
p.setX(p.x() - _lock.width());
|
||||
_lock.move(p);
|
||||
}
|
||||
if (_player) {
|
||||
p.setX(p.x() - _player->width());
|
||||
_player->move(p);
|
||||
}
|
||||
|
||||
_settings.move(st::titleMenuOffset, 0);
|
||||
if (_contacts.isHidden()) {
|
||||
_about.move(_settings.x() + _settings.width(), 0);
|
||||
} else {
|
||||
_contacts.move(_settings.x() + _settings.width(), 0);
|
||||
_about.move(_contacts.x() + _contacts.width(), 0);
|
||||
}
|
||||
|
||||
if (_hider) {
|
||||
_hider->resize(size());
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::resizeEvent(QResizeEvent *e) {
|
||||
updateControlsPosition();
|
||||
}
|
||||
|
||||
void TitleWidget::updateControlsVisibility() {
|
||||
auto passcoded = App::passcoded();
|
||||
auto authed = (App::main() != nullptr);
|
||||
auto selecting = authed && App::main()->selectingPeer();
|
||||
auto oneColumnSelecting = (Adaptive::OneColumn() && selecting && !passcoded);
|
||||
|
||||
_cancel.setVisible(oneColumnSelecting);
|
||||
|
||||
updateRestartButtonVisibility();
|
||||
updateMenuButtonsVisibility();
|
||||
updateSystemButtonsVisibility();
|
||||
|
||||
updateControlsPosition();
|
||||
update();
|
||||
}
|
||||
|
||||
void TitleWidget::updateRestartButtonVisibility() {
|
||||
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
||||
bool updateReady = (Sandbox::updatingState() == Application::UpdatingReady);
|
||||
#else // !TDESKTOP_DISABLE_AUTOUPDATE
|
||||
bool updateReady = false;
|
||||
#endif // else for !TDESKTOP_DISABLE_AUTOUPDATE
|
||||
auto scaleRestarting = cEvalScale(cConfigScale()) != cEvalScale(cRealScale());
|
||||
|
||||
auto updateVisible = _cancel.isHidden() && (updateReady || scaleRestarting);
|
||||
if (updateVisible) {
|
||||
_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
|
||||
_update.show();
|
||||
_a_update.start();
|
||||
} else {
|
||||
_update.hide();
|
||||
_a_update.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::updateMenuButtonsVisibility() {
|
||||
if (_cancel.isHidden()) {
|
||||
if (App::passcoded()) {
|
||||
_settings.hide();
|
||||
_contacts.hide();
|
||||
_about.hide();
|
||||
_lock.setSysBtnStyle(st::sysUnlock);
|
||||
} else {
|
||||
_lock.setSysBtnStyle(st::sysLock);
|
||||
_settings.show();
|
||||
_contacts.setVisible(App::main() != nullptr);
|
||||
_about.show();
|
||||
}
|
||||
} else {
|
||||
_settings.hide();
|
||||
_contacts.hide();
|
||||
_about.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::updateSystemButtonsVisibility() {
|
||||
if (_cancel.isHidden()) {
|
||||
_lock.setVisible(Global::LocalPasscode());
|
||||
if (_player) {
|
||||
_player->show();
|
||||
}
|
||||
} else {
|
||||
_lock.hide();
|
||||
if (_player) {
|
||||
_player->hide();
|
||||
}
|
||||
}
|
||||
if (_update.isHidden() && _cancel.isHidden() && cPlatform() == dbipWindows) {
|
||||
_minimize.show();
|
||||
maximizedChanged(lastMaximized, true);
|
||||
_close.show();
|
||||
} else {
|
||||
_minimize.hide();
|
||||
_restore.hide();
|
||||
_maximize.hide();
|
||||
_close.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::updateAdaptiveLayout() {
|
||||
updateControlsVisibility();
|
||||
if (Adaptive::OneColumn()) {
|
||||
updateCounter();
|
||||
}
|
||||
if (_hider) {
|
||||
_hider->setVisible(!Adaptive::OneColumn());
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::updateCounter() {
|
||||
if (!Adaptive::OneColumn() || !MTP::authedId()) return;
|
||||
|
||||
int32 counter = App::histories().unreadBadge();
|
||||
bool muted = App::histories().unreadOnlyMuted();
|
||||
|
||||
if (counter > 0) {
|
||||
int32 size = cRetina() ? -32 : -16;
|
||||
switch (cScale()) {
|
||||
case dbisOneAndQuarter: size = -20; break;
|
||||
case dbisOneAndHalf: size = -24; break;
|
||||
case dbisTwo: size = -32; break;
|
||||
}
|
||||
auto &bg = (muted ? st::titleCounterBgMute : st::titleCounterBg);
|
||||
auto &fg = st::titleCounterFg;
|
||||
_counter = App::pixmapFromImageInPlace(App::wnd()->iconWithCounter(size, counter, bg, fg, false));
|
||||
_counter.setDevicePixelRatio(cRetinaFactor());
|
||||
update(QRect(st::titleCounterPosition, _counter.size() / cIntRetinaFactor()));
|
||||
} else {
|
||||
if (!_counter.isNull()) {
|
||||
update(QRect(st::titleCounterPosition, _counter.size() / cIntRetinaFactor()));
|
||||
_counter = QPixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::mousePressEvent(QMouseEvent *e) {
|
||||
if (auto wnd = App::wnd()) {
|
||||
if (wnd->psHandleTitle()) return;
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
wnd->wStartDrag(e);
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
if (auto wnd = App::wnd()) {
|
||||
if (wnd->psHandleTitle()) return;
|
||||
Qt::WindowStates s(wnd->windowState());
|
||||
if (s.testFlag(Qt::WindowMaximized)) {
|
||||
wnd->setWindowState(s & ~Qt::WindowMaximized);
|
||||
} else {
|
||||
wnd->setWindowState(s | Qt::WindowMaximized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TitleWidget::onWindowStateChanged(Qt::WindowState state) {
|
||||
if (state == Qt::WindowMinimized) return;
|
||||
maximizedChanged(state == Qt::WindowMaximized);
|
||||
}
|
||||
|
||||
void TitleWidget::maximizedChanged(bool maximized, bool force) {
|
||||
if (lastMaximized == maximized && !force) return;
|
||||
|
||||
lastMaximized = maximized;
|
||||
|
||||
if (cPlatform() != dbipWindows || !_update.isHidden()) return;
|
||||
if (maximized) {
|
||||
_maximize.clearState();
|
||||
} else {
|
||||
_restore.clearState();
|
||||
}
|
||||
|
||||
_maximize.setVisible(!maximized);
|
||||
_restore.setVisible(maximized);
|
||||
|
||||
updateControlsPosition();
|
||||
}
|
||||
|
||||
HitTestType TitleWidget::hitTest(const QPoint &p) {
|
||||
if (App::wnd() && Ui::isLayerShown()) return HitTestType::None;
|
||||
|
||||
int x(p.x()), y(p.y()), w(width()), h(height());
|
||||
if (!Adaptive::OneColumn() && _hider && x >= App::main()->dlgsWidth()) return HitTestType::None;
|
||||
|
||||
if (x >= st::titleIconPosition.x() && y >= st::titleIconPosition.y() && x < st::titleIconPosition.x() + st::titleIcon.width() && y < st::titleIconPosition.y() + st::titleIcon.height()) {
|
||||
return HitTestType::Icon;
|
||||
} else if (false
|
||||
|| (_player && _player->geometry().contains(p))
|
||||
|| (_lock.hitTest(p - _lock.geometry().topLeft()) == HitTestType::SysButton && _lock.isVisible())
|
||||
|| (_update.hitTest(p - _update.geometry().topLeft()) == HitTestType::SysButton && _update.isVisible())
|
||||
|| (_minimize.hitTest(p - _minimize.geometry().topLeft()) == HitTestType::SysButton)
|
||||
|| (_maximize.hitTest(p - _maximize.geometry().topLeft()) == HitTestType::SysButton)
|
||||
|| (_restore.hitTest(p - _restore.geometry().topLeft()) == HitTestType::SysButton)
|
||||
|| (_close.hitTest(p - _close.geometry().topLeft()) == HitTestType::SysButton)
|
||||
) {
|
||||
return HitTestType::SysButton;
|
||||
} else if (x >= 0 && x < w && y >= 0 && y < h) {
|
||||
if (false
|
||||
|| (!_cancel.isHidden() && _cancel.geometry().contains(x, y))
|
||||
|| (!_settings.isHidden() && _settings.geometry().contains(x, y))
|
||||
|| (!_contacts.isHidden() && _contacts.geometry().contains(x, y))
|
||||
|| (!_about.isHidden() && _about.geometry().contains(x, y))
|
||||
) {
|
||||
return HitTestType::Client;
|
||||
}
|
||||
return HitTestType::Caption;
|
||||
}
|
||||
return HitTestType::None;
|
||||
}
|
||||
|
||||
QRect TitleWidget::iconRect() const {
|
||||
return myrtlrect(QRect(st::titleIconPosition, st::titleIcon.size()));
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include "sysbuttons.h"
|
||||
|
||||
class MainWindow;
|
||||
namespace Media {
|
||||
namespace Player {
|
||||
class TitleButton;
|
||||
} // namespace Player
|
||||
} // namespace Media
|
||||
class AudioMsgId;
|
||||
|
||||
class TitleWidget : public TWidget, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TitleWidget(QWidget *parent);
|
||||
|
||||
void updateCounter();
|
||||
|
||||
void maximizedChanged(bool maximized, bool force = false);
|
||||
|
||||
HitTestType hitTest(const QPoint &p);
|
||||
QRect iconRect() const;
|
||||
|
||||
void setHideLevel(float64 level);
|
||||
|
||||
void step_update(float64 ms, bool timer);
|
||||
|
||||
public slots:
|
||||
void onWindowStateChanged(Qt::WindowState state = Qt::WindowNoState);
|
||||
void updateControlsVisibility();
|
||||
void onContacts();
|
||||
void onAbout();
|
||||
|
||||
signals:
|
||||
void hiderClicked();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
|
||||
private:
|
||||
void updatePlayerButton(bool usePanel);
|
||||
void updateAdaptiveLayout();
|
||||
void updateRestartButtonVisibility();
|
||||
void updateMenuButtonsVisibility();
|
||||
void updateSystemButtonsVisibility();
|
||||
void updateControlsPosition();
|
||||
|
||||
style::color statusColor;
|
||||
|
||||
class Hider;
|
||||
float64 hideLevel = 0;
|
||||
ChildWidget<Hider> _hider = { nullptr };
|
||||
|
||||
float64 _lastUpdateMs;
|
||||
|
||||
FlatButton _cancel, _settings, _contacts, _about;
|
||||
|
||||
ChildWidget<Media::Player::TitleButton> _player = { nullptr };
|
||||
LockBtn _lock;
|
||||
UpdateBtn _update;
|
||||
MinimizeBtn _minimize;
|
||||
MaximizeBtn _maximize;
|
||||
RestoreBtn _restore;
|
||||
CloseBtn _close;
|
||||
|
||||
Animation _a_update;
|
||||
|
||||
bool lastMaximized;
|
||||
|
||||
QPixmap _counter;
|
||||
|
||||
};
|
|
@ -22,12 +22,15 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
using "basic.style";
|
||||
using "ui/widgets/widgets.style";
|
||||
|
||||
titleIconPosition: point(9px, 9px);
|
||||
titleIcon: icon {
|
||||
{ "title_icon_bg", #49708f },
|
||||
{ "title_icon", #ffffff, point(4px, 4px) }
|
||||
};
|
||||
titleCounterPosition: point(17px, 17px);
|
||||
windowMinWidth: 380px;
|
||||
windowMinHeight: 480px;
|
||||
windowDefWidth: 800px;
|
||||
windowDefHeight: 600px;
|
||||
windowShadow: icon {{ "window_shadow", windowShadowFg }};
|
||||
windowShadowShift: 1px;
|
||||
|
||||
adaptiveNormalWidth: 640px;
|
||||
adaptiveWideWidth: 1366px;
|
||||
|
||||
notifyBorder: #f1f1f1;
|
||||
notifyBorderWidth: 1px;
|
||||
|
@ -78,3 +81,50 @@ notifySendReply: IconButton {
|
|||
iconPosition: point(0px, 0px);
|
||||
iconPositionDown: point(0px, 1px);
|
||||
}
|
||||
|
||||
titleHeight: 21px;
|
||||
titleButtonMinimize: IconButton {
|
||||
width: 24px;
|
||||
height: 21px;
|
||||
|
||||
icon: icon {{ "title_button_minimize", titleButtonFg, point(4px, 4px) }};
|
||||
iconOver: icon {
|
||||
{ size(24px, 21px), titleButtonBgOver },
|
||||
{ "title_button_minimize", titleButtonFgOver, point(4px, 4px) },
|
||||
};
|
||||
|
||||
iconPosition: point(0px, 0px);
|
||||
iconPositionDown: point(0px, 0px);
|
||||
}
|
||||
titleButtonMaximize: IconButton(titleButtonMinimize) {
|
||||
icon: icon {{ "title_button_maximize", titleButtonFg, point(4px, 4px) }};
|
||||
iconOver: icon {
|
||||
{ size(24px, 21px), titleButtonBgOver },
|
||||
{ "title_button_maximize", titleButtonFgOver, point(4px, 4px) },
|
||||
};
|
||||
}
|
||||
titleButtonRestoreIcon: icon {{ "title_button_restore", titleButtonFg, point(4px, 4px) }};
|
||||
titleButtonRestoreIconOver: icon {
|
||||
{ size(24px, 21px), titleButtonBgOver },
|
||||
{ "title_button_restore", titleButtonFgOver, point(4px, 4px) },
|
||||
};
|
||||
titleButtonClose: IconButton(titleButtonMinimize) {
|
||||
width: 25px;
|
||||
|
||||
icon: icon {{ "title_button_close", titleButtonFg, point(5px, 4px) }};
|
||||
iconOver: icon {
|
||||
{ size(25px, 21px), titleButtonCloseBgOver },
|
||||
{ "title_button_close", titleButtonCloseFgOver, point(5px, 4px) },
|
||||
};
|
||||
}
|
||||
|
||||
// Mac specific
|
||||
|
||||
macAccessoryWidth: 450.;
|
||||
macAccessoryHeight: 90.;
|
||||
macEnableFilterAdd: 2;
|
||||
macEnableFilterTop: 5;
|
||||
macSelectorTop: 6;
|
||||
macAlwaysThisAppTop: 4;
|
||||
macAppHintTop: 8;
|
||||
macCautionIconSize: 16;
|
||||
|
|
|
@ -82,14 +82,14 @@ inline uchar readHexUchar(char char1, char char2, bool &error) {
|
|||
return ((readHexUchar(char1, error) & 0x0F) << 4) | (readHexUchar(char2, error) & 0x0F);
|
||||
}
|
||||
|
||||
bool readNameAndValue(const char *&from, const char *end, QByteArray *outName, QByteArray *outValue) {
|
||||
bool readNameAndValue(const char *&from, const char *end, QLatin1String *outName, QLatin1String *outValue) {
|
||||
using base::parse::skipWhitespaces;
|
||||
using base::parse::readName;
|
||||
|
||||
if (!skipWhitespaces(from, end)) return true;
|
||||
|
||||
*outName = readName(from, end);
|
||||
if (outName->isEmpty()) {
|
||||
if (outName->size() == 0) {
|
||||
LOG(("Error: Could not read name in the color scheme."));
|
||||
return false;
|
||||
}
|
||||
|
@ -108,11 +108,11 @@ bool readNameAndValue(const char *&from, const char *end, QByteArray *outName, Q
|
|||
auto valueStart = from;
|
||||
if (*from == '#') ++from;
|
||||
|
||||
if (readName(from, end).isEmpty()) {
|
||||
if (readName(from, end).size() == 0) {
|
||||
LOG(("Error: Expected a color value in #rrggbb or #rrggbbaa format in the color scheme."));
|
||||
return false;
|
||||
}
|
||||
*outValue = QByteArray::fromRawData(valueStart, from - valueStart);
|
||||
*outValue = QLatin1String(valueStart, from - valueStart);
|
||||
|
||||
if (!skipWhitespaces(from, end)) {
|
||||
LOG(("Error: Unexpected end of the color scheme."));
|
||||
|
@ -126,47 +126,66 @@ bool readNameAndValue(const char *&from, const char *end, QByteArray *outName, Q
|
|||
return true;
|
||||
}
|
||||
|
||||
enum class SetResult {
|
||||
Ok,
|
||||
Bad,
|
||||
NotFound,
|
||||
};
|
||||
SetResult setColorSchemeValue(QLatin1String name, QLatin1String value, Instance *out) {
|
||||
auto found = false;
|
||||
auto size = value.size();
|
||||
auto data = value.data();
|
||||
if (data[0] == '#' && (size == 7 || size == 9)) {
|
||||
auto error = false;
|
||||
auto r = readHexUchar(data[1], data[2], error);
|
||||
auto g = readHexUchar(data[3], data[4], error);
|
||||
auto b = readHexUchar(data[5], data[6], error);
|
||||
auto a = (size == 9) ? readHexUchar(data[7], data[8], error) : uchar(255);
|
||||
if (error) {
|
||||
LOG(("Error: Expected a color value in #rrggbb or #rrggbbaa format in the color scheme (while applying '%1: %2')").arg(QLatin1String(name)).arg(QLatin1String(value)));
|
||||
return SetResult::Bad;
|
||||
} else if (out) {
|
||||
found = out->palette.setColor(name, r, g, b, a);
|
||||
} else {
|
||||
found = style::main_palette::setColor(name, r, g, b, a);
|
||||
}
|
||||
} else {
|
||||
if (out) {
|
||||
found = out->palette.setColor(name, value);
|
||||
} else {
|
||||
found = style::main_palette::setColor(name, value);
|
||||
}
|
||||
}
|
||||
return found ? SetResult::Ok : SetResult::NotFound;
|
||||
}
|
||||
|
||||
bool loadColorScheme(const QByteArray &content, Instance *out = nullptr) {
|
||||
if (content.size() > kThemeSchemeSizeLimit) {
|
||||
LOG(("Error: color scheme file too large (should be less than 1 MB, got %2)").arg(content.size()));
|
||||
return false;
|
||||
}
|
||||
|
||||
QMap<QLatin1String, QLatin1String> unsupported;
|
||||
auto data = base::parse::stripComments(content);
|
||||
auto from = data.constData(), end = from + data.size();
|
||||
while (from != end) {
|
||||
QByteArray name, value;
|
||||
QLatin1String name, value;
|
||||
if (!readNameAndValue(from, end, &name, &value)) {
|
||||
return false;
|
||||
}
|
||||
if (name.isEmpty()) { // End of content reached.
|
||||
if (name.size() == 0) { // End of content reached.
|
||||
return true;
|
||||
}
|
||||
|
||||
auto size = value.size();
|
||||
auto error = false;
|
||||
if (value[0] == '#' && (size == 7 || size == 9)) {
|
||||
auto r = readHexUchar(value[1], value[2], error);
|
||||
auto g = readHexUchar(value[3], value[4], error);
|
||||
auto b = readHexUchar(value[5], value[6], error);
|
||||
auto a = (size == 9) ? readHexUchar(value[7], value[8], error) : uchar(255);
|
||||
if (!error) {
|
||||
if (out) {
|
||||
error = !out->palette.setColor(QLatin1String(name), r, g, b, a);
|
||||
} else {
|
||||
error = !style::main_palette::setColor(QLatin1String(name), r, g, b, a);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (out) {
|
||||
error = !out->palette.setColor(QLatin1String(name), QLatin1String(value));
|
||||
} else {
|
||||
error = !style::main_palette::setColor(QLatin1String(name), QLatin1String(value));
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
LOG(("Error: Expected a color value in #rrggbb or #rrggbbaa format in the color scheme (while applying '%1: %2')").arg(QLatin1String(name)).arg(QLatin1String(value)));
|
||||
// Find the named value in the already read unsupported list.
|
||||
value = unsupported.value(value, value);
|
||||
|
||||
auto result = setColorSchemeValue(name, value, out);
|
||||
if (result == SetResult::Bad) {
|
||||
return false;
|
||||
} else if (result == SetResult::NotFound) {
|
||||
LOG(("Warning: unexpected name or value in the color scheme (while applying '%1: %2')").arg(name).arg(value));
|
||||
unsupported.insert(name, value);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -20,35 +20,34 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/button.h"
|
||||
namespace Window {
|
||||
|
||||
namespace Media {
|
||||
namespace Player {
|
||||
enum class HitTestResult {
|
||||
None = 0,
|
||||
Client,
|
||||
SysButton,
|
||||
Icon,
|
||||
Caption,
|
||||
Top,
|
||||
TopRight,
|
||||
Right,
|
||||
BottomRight,
|
||||
Bottom,
|
||||
BottomLeft,
|
||||
Left,
|
||||
TopLeft,
|
||||
};
|
||||
|
||||
class PlayButtonLayout;
|
||||
|
||||
class TitleButton : public Button, private base::Subscriber {
|
||||
class TitleWidget : public TWidget {
|
||||
public:
|
||||
TitleButton(QWidget *parent);
|
||||
|
||||
void updatePauseState();
|
||||
|
||||
~TitleButton();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void enterEvent(QEvent *e) override;
|
||||
void leaveEvent(QEvent *e) override;
|
||||
|
||||
void onStateChanged(int oldState, ButtonStateChangeSource source) override;
|
||||
|
||||
private:
|
||||
void paintIcon(Painter &p);
|
||||
|
||||
std_::unique_ptr<PlayButtonLayout> _layout;
|
||||
ColorAnimation _iconFg;
|
||||
using TWidget::TWidget;
|
||||
virtual HitTestResult hitTest(const QPoint &p) const {
|
||||
return HitTestResult::None;
|
||||
}
|
||||
virtual QRect iconRect() const {
|
||||
return QRect();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Clip
|
||||
} // namespace Media
|
||||
} // namespace Window
|
|
@ -151,10 +151,6 @@
|
|||
'<(src_loc)/shortcuts.h',
|
||||
'<(src_loc)/structs.cpp',
|
||||
'<(src_loc)/structs.h',
|
||||
'<(src_loc)/sysbuttons.cpp',
|
||||
'<(src_loc)/sysbuttons.h',
|
||||
'<(src_loc)/title.cpp',
|
||||
'<(src_loc)/title.h',
|
||||
'<(src_loc)/mainwindow.cpp',
|
||||
'<(src_loc)/mainwindow.h',
|
||||
'<(src_loc)/boxes/aboutbox.cpp',
|
||||
|
@ -288,8 +284,6 @@
|
|||
'<(src_loc)/media/player/media_player_list.h',
|
||||
'<(src_loc)/media/player/media_player_panel.cpp',
|
||||
'<(src_loc)/media/player/media_player_panel.h',
|
||||
'<(src_loc)/media/player/media_player_title_button.cpp',
|
||||
'<(src_loc)/media/player/media_player_title_button.h',
|
||||
'<(src_loc)/media/player/media_player_volume_controller.cpp',
|
||||
'<(src_loc)/media/player/media_player_volume_controller.h',
|
||||
'<(src_loc)/media/player/media_player_widget.cpp',
|
||||
|
@ -348,6 +342,7 @@
|
|||
'<(src_loc)/mtproto/session.h',
|
||||
'<(src_loc)/overview/overview_layout.cpp',
|
||||
'<(src_loc)/overview/overview_layout.h',
|
||||
'<(src_loc)/pspecific.h',
|
||||
'<(src_loc)/pspecific_win.cpp',
|
||||
'<(src_loc)/pspecific_win.h',
|
||||
'<(src_loc)/pspecific_mac.cpp',
|
||||
|
@ -378,6 +373,8 @@
|
|||
'<(src_loc)/platform/win/main_window_win.h',
|
||||
'<(src_loc)/platform/win/notifications_manager_win.cpp',
|
||||
'<(src_loc)/platform/win/notifications_manager_win.h',
|
||||
'<(src_loc)/platform/win/window_title_win.cpp',
|
||||
'<(src_loc)/platform/win/window_title_win.h',
|
||||
'<(src_loc)/platform/win/windows_app_user_model_id.cpp',
|
||||
'<(src_loc)/platform/win/windows_app_user_model_id.h',
|
||||
'<(src_loc)/platform/win/windows_dlls.cpp',
|
||||
|
@ -387,6 +384,7 @@
|
|||
'<(src_loc)/platform/platform_file_dialog.h',
|
||||
'<(src_loc)/platform/platform_main_window.h',
|
||||
'<(src_loc)/platform/platform_notifications_manager.h',
|
||||
'<(src_loc)/platform/platform_window_title.h',
|
||||
'<(src_loc)/profile/profile_actions_widget.cpp',
|
||||
'<(src_loc)/profile/profile_actions_widget.h',
|
||||
'<(src_loc)/profile/profile_block_widget.cpp',
|
||||
|
@ -561,6 +559,7 @@
|
|||
'<(src_loc)/window/window_theme.h',
|
||||
'<(src_loc)/window/window_theme_warning.cpp',
|
||||
'<(src_loc)/window/window_theme_warning.h',
|
||||
'<(src_loc)/window/window_title.h',
|
||||
|
||||
'<(sp_media_key_tap_loc)/SPMediaKeyTap.m',
|
||||
'<(sp_media_key_tap_loc)/SPMediaKeyTap.h',
|
||||
|
|