Fixed Xcode build. When hiding fullscreen window first exit fullscreen.

This commit is contained in:
John Preston 2016-06-16 18:17:39 +03:00
parent fd91893b51
commit 8e78cfed85
11 changed files with 551 additions and 1498 deletions

View File

@ -276,7 +276,7 @@ bool hideWindowNoQuit() {
if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) {
return w->minimizeToTray();
} else if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
w->hide();
w->closeWithoutDestroy();
w->updateIsActive(Global::OfflineBlurTimeout());
w->updateGlobalMenu();
return true;

View File

@ -417,7 +417,9 @@ void MainWindow::onInactiveTimer() {
inactivePress(false);
}
void MainWindow::stateChanged(Qt::WindowState state) {
void MainWindow::onStateChanged(Qt::WindowState state) {
stateChangedHook(state);
psUserActionDone();
updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout());
@ -1069,7 +1071,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
case QEvent::WindowStateChange:
if (obj == this) {
Qt::WindowState state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized : ((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized : ((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
stateChanged(state);
onStateChanged(state);
}
break;
@ -1107,7 +1109,7 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *e) {
bool MainWindow::minimizeToTray() {
if (App::quitting() || !psHasTrayIcon()) return false;
hide();
closeWithoutDestroy();
if (cPlatform() == dbipWindows && trayIcon && !cSeenTrayTooltip()) {
trayIcon->showMessage(str_const_toString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
cSetSeenTrayTooltip(true);

View File

@ -249,9 +249,7 @@ public:
PeerData *ui_getPeerForMouseAction();
public slots:
void updateIsActive(int timeout = 0);
void stateChanged(Qt::WindowState state);
void checkHistoryActivation();
@ -289,7 +287,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);
@ -297,6 +294,9 @@ signals:
void imageLoaded();
private slots:
void onStateChanged(Qt::WindowState state);
private:
QPixmap grabInner();

View File

@ -75,7 +75,7 @@ public:
void psNotifyShown(NotifyWindow *w);
void psPlatformNotify(HistoryItem *item, int32 fwdCount);
bool eventFilter(QObject *obj, QEvent *evt);
bool eventFilter(QObject *obj, QEvent *evt) override;
void psUpdateCounter();
@ -85,10 +85,11 @@ public:
virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;
void closeWithoutDestroy() override;
~MainWindow();
public slots:
void psUpdateDelegate();
void psSavePosition(Qt::WindowState state = Qt::WindowActive);
void psShowTrayMenu();
@ -101,9 +102,12 @@ public slots:
void psMacDelete();
void psMacSelectAll();
protected:
private slots:
void onHideAfterFullScreen();
protected:
void stateChangedHook(Qt::WindowState state) override;
void psNotIdle() const;
QImage psTrayIcon(bool selected = false) const;
bool psHasTrayIcon() const {
return trayIcon;
@ -112,8 +116,8 @@ protected:
void psMacUpdateMenu();
bool posInited;
QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
QSystemTrayIcon *trayIcon = nullptr;
QMenu *trayIconMenu = nullptr;
QImage icon256, iconbig256;
QIcon wndIcon;
@ -126,14 +130,27 @@ protected:
QTimer psUpdatedPositionTimer;
private:
struct PrivateData;
std_::unique_ptr<PrivateData> _private;
MacPrivate _private;
mutable bool psIdle;
mutable QTimer psIdleTimer;
QTimer _hideAfterFullScreenTimer;
QMenuBar psMainMenu;
QAction *psLogout, *psUndo, *psRedo, *psCut, *psCopy, *psPaste, *psDelete, *psSelectAll, *psContacts, *psAddContact, *psNewGroup, *psNewChannel, *psShowTelegram;
QAction *psLogout = nullptr;
QAction *psUndo = nullptr;
QAction *psRedo = nullptr;
QAction *psCut = nullptr;
QAction *psCopy = nullptr;
QAction *psPaste = nullptr;
QAction *psDelete = nullptr;
QAction *psSelectAll = nullptr;
QAction *psContacts = nullptr;
QAction *psAddContact = nullptr;
QAction *psNewGroup = nullptr;
QAction *psNewChannel = nullptr;
QAction *psShowTelegram = nullptr;
};

File diff suppressed because it is too large Load Diff

View File

@ -31,9 +31,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
namespace {
QStringList _initLogs;
bool frameless = true;
bool finished = true;
class _PsEventFilter : public QAbstractNativeEventFilter {
public:
_PsEventFilter() {
@ -50,430 +47,6 @@ namespace {
};
void MacPrivate::activeSpaceChanged() {
if (App::wnd()) {
App::wnd()->notifyActivateAll();
}
}
void MacPrivate::darkModeChanged() {
Notify::unreadCounterUpdated();
}
void MacPrivate::notifyClicked(unsigned long long peer, int msgid) {
History *history = App::history(PeerId(peer));
App::wnd()->showFromTray();
if (App::passcoded()) {
App::wnd()->setInnerFocus();
App::wnd()->notifyClear();
} else {
App::wnd()->hideSettings();
bool tomsg = !history->peer->isUser() && (msgid > 0);
if (tomsg) {
HistoryItem *item = App::histItemById(peerToChannel(PeerId(peer)), MsgId(msgid));
if (!item || !item->mentionsMe()) {
tomsg = false;
}
}
Ui::showPeerHistory(history, tomsg ? msgid : ShowAtUnreadMsgId);
App::wnd()->notifyClear(history);
}
}
void MacPrivate::notifyReplied(unsigned long long peer, int msgid, const char *str) {
History *history = App::history(PeerId(peer));
MainWidget::MessageToSend message;
message.history = history;
message.textWithTags = { QString::fromUtf8(str), TextWithTags::Tags() };
message.replyTo = (msgid > 0 && !history->peer->isUser()) ? msgid : 0;
message.silent = false;
message.clearDraft = false;
App::main()->sendMessage(message);
}
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/icon256.png")), iconbig256(qsl(":/gui/art/iconbig256.png")), wndIcon(QPixmap::fromImage(iconbig256, Qt::ColorOnly)),
psLogout(0), psUndo(0), psRedo(0), psCut(0), psCopy(0), psPaste(0), psDelete(0), psSelectAll(0), psContacts(0), psAddContact(0), psNewGroup(0), psNewChannel(0), psShowTelegram(0) {
QImage tray(qsl(":/gui/art/osxtray.png"));
trayImg = tray.copy(0, cRetina() ? 0 : tray.width() / 2, tray.width() / (cRetina() ? 2 : 4), tray.width() / (cRetina() ? 2 : 4));
trayImgSel = tray.copy(tray.width() / (cRetina() ? 2 : 4), cRetina() ? 0 : tray.width() / 2, tray.width() / (cRetina() ? 2 : 4), tray.width() / (cRetina() ? 2 : 4));
}
QImage PsMainWindow::psTrayIcon(bool selected) const {
return selected ? trayImgSel : trayImg;
}
void PsMainWindow::psShowTrayMenu() {
}
void PsMainWindow::psRefreshTaskbarIcon() {
}
void PsMainWindow::psTrayMenuUpdated() {
}
void PsMainWindow::psSetupTrayIcon() {
if (!trayIcon) {
trayIcon = new QSystemTrayIcon(this);
QIcon icon(QPixmap::fromImage(psTrayIcon(), Qt::ColorOnly));
icon.addPixmap(QPixmap::fromImage(psTrayIcon(true), Qt::ColorOnly), QIcon::Selected);
trayIcon->setIcon(icon);
trayIcon->setToolTip(str_const_toString(AppName));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
App::wnd()->updateTrayMenu();
}
psUpdateCounter();
trayIcon->show();
}
void PsMainWindow::psUpdateWorkmode() {
psSetupTrayIcon();
if (cWorkMode() == dbiwmWindowOnly) {
if (trayIcon) {
trayIcon->setContextMenu(0);
delete trayIcon;
}
trayIcon = 0;
}
psUpdateDelegate();
setWindowIcon(wndIcon);
}
void _placeCounter(QImage &img, int size, int count, style::color bg, style::color color) {
if (!count) return;
QPainter p(&img);
QString cnt = (count < 100) ? QString("%1").arg(count) : QString("..%1").arg(count % 100, 2, 10, QChar('0'));
int32 cntSize = cnt.size();
p.setBrush(bg->b);
p.setPen(Qt::NoPen);
p.setRenderHint(QPainter::Antialiasing);
int32 fontSize, skip;
if (size == 22) {
skip = 1;
fontSize = 8;
} else {
skip = 2;
fontSize = 16;
}
style::font f(fontSize, 0, 0);
int32 w = f->width(cnt), d, r;
if (size == 22) {
d = (cntSize < 2) ? 3 : 2;
r = (cntSize < 2) ? 6 : 5;
} else {
d = (cntSize < 2) ? 6 : 5;
r = (cntSize < 2) ? 9 : 11;
}
p.drawRoundedRect(QRect(size - w - d * 2 - skip, size - f->height - skip, w + d * 2, f->height), r, r);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.setFont(f->f);
p.setPen(color->p);
p.drawText(size - w - d - skip, size - f->height + f->ascent - skip, cnt);
}
void PsMainWindow::psUpdateCounter() {
int32 counter = App::histories().unreadBadge();
setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
setWindowIcon(wndIcon);
QString cnt = (counter < 1000) ? QString("%1").arg(counter) : QString("..%1").arg(counter % 100, 2, 10, QChar('0'));
_private.setWindowBadge(counter ? cnt : QString());
if (trayIcon) {
bool muted = App::histories().unreadOnlyMuted();
bool dm = objc_darkMode();
style::color bg = muted ? st::counterMuteBG : st::counterBG;
QIcon icon;
QImage img(psTrayIcon(dm)), imgsel(psTrayIcon(true));
img.detach();
imgsel.detach();
int32 size = cRetina() ? 44 : 22;
_placeCounter(img, size, counter, bg, (dm && muted) ? st::counterMacInvColor : st::counterColor);
_placeCounter(imgsel, size, counter, st::white, st::counterMacInvColor);
icon.addPixmap(QPixmap::fromImage(img, Qt::ColorOnly));
icon.addPixmap(QPixmap::fromImage(imgsel, Qt::ColorOnly), QIcon::Selected);
trayIcon->setIcon(icon);
}
}
void PsMainWindow::psUpdateDelegate() {
_private.updateDelegate();
}
void PsMainWindow::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);
if (pos.w && pos.h) {
QList<QScreen*> screens = Application::screens();
for (QList<QScreen*>::const_iterator i = screens.cbegin(), e = screens.cend(); i != e; ++i) {
QByteArray name = (*i)->name().toUtf8();
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 (pos.w > w) pos.w = w;
if (pos.h > h) pos.h = h;
pos.x += screen.x();
pos.y += screen.y();
if (pos.x < screen.x() + screen.width() - 10 && pos.y < screen.y() + screen.height() - 10) {
geom = QRect(pos.x, pos.y, pos.w, pos.h);
}
}
break;
}
}
if (pos.y < 0) pos.y = 0;
maximized = pos.maximized;
}
setGeometry(geom);
}
void PsMainWindow::psInitFrameless() {
psUpdatedPositionTimer.setSingleShot(true);
connect(&psUpdatedPositionTimer, SIGNAL(timeout()), this, SLOT(psSavePosition()));
if (frameless) {
//setWindowFlags(Qt::FramelessWindowHint);
}
}
void PsMainWindow::psSavePosition(Qt::WindowState state) {
if (state == Qt::WindowActive) state = windowHandle()->windowState();
if (state == Qt::WindowMinimized || !posInited) return;
TWindowPos pos(cWindowPos()), curPos = pos;
if (state == Qt::WindowMaximized) {
curPos.maximized = 1;
} else {
QRect r(geometry());
curPos.x = r.x();
curPos.y = r.y();
curPos.w = r.width();
curPos.h = r.height();
curPos.maximized = 0;
}
int px = curPos.x + curPos.w / 2, py = curPos.y + curPos.h / 2, d = 0;
QScreen *chosen = 0;
QList<QScreen*> screens = Application::screens();
for (QList<QScreen*>::const_iterator i = screens.cbegin(), e = screens.cend(); i != e; ++i) {
int dx = (*i)->geometry().x() + (*i)->geometry().width() / 2 - px; if (dx < 0) dx = -dx;
int dy = (*i)->geometry().y() + (*i)->geometry().height() / 2 - py; if (dy < 0) dy = -dy;
if (!chosen || dx + dy < d) {
d = dx + dy;
chosen = *i;
}
}
if (chosen) {
curPos.x -= chosen->geometry().x();
curPos.y -= chosen->geometry().y();
QByteArray name = chosen->name().toUtf8();
curPos.moncrc = hashCrc32(name.constData(), name.size());
}
if (curPos.w >= st::wndMinWidth && curPos.h >= st::wndMinHeight) {
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();
}
}
}
void PsMainWindow::psUpdatedPosition() {
psUpdatedPositionTimer.start(SaveWindowPositionTimeout);
}
void PsMainWindow::psFirstShow() {
finished = false;
psUpdateMargins();
bool showShadows = true;
show();
_private.enableShadow(winId());
if (cWindowPos().maximized) {
setWindowState(Qt::WindowMaximized);
}
if ((cLaunchMode() == LaunchModeAutoStart && cStartMinimized()) || cStartInTray()) {
setWindowState(Qt::WindowMinimized);
if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) {
hide();
} else {
show();
}
showShadows = false;
} else {
show();
}
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);
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);
QMenu *file = psMainMenu.addMenu(lang(lng_mac_menu_file));
psLogout = file->addAction(lang(lng_mac_menu_logout), App::wnd(), SLOT(onLogout()));
QMenu *edit = psMainMenu.addMenu(lang(lng_mac_menu_edit));
psUndo = edit->addAction(lang(lng_mac_menu_undo), this, SLOT(psMacUndo()), QKeySequence::Undo);
psRedo = edit->addAction(lang(lng_mac_menu_redo), this, SLOT(psMacRedo()), QKeySequence::Redo);
edit->addSeparator();
psCut = edit->addAction(lang(lng_mac_menu_cut), this, SLOT(psMacCut()), QKeySequence::Cut);
psCopy = edit->addAction(lang(lng_mac_menu_copy), this, SLOT(psMacCopy()), QKeySequence::Copy);
psPaste = edit->addAction(lang(lng_mac_menu_paste), this, SLOT(psMacPaste()), QKeySequence::Paste);
psDelete = edit->addAction(lang(lng_mac_menu_delete), this, SLOT(psMacDelete()), QKeySequence(Qt::ControlModifier | Qt::Key_Backspace));
edit->addSeparator();
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()));
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()));
psNewChannel = window->addAction(lang(lng_mac_menu_new_channel), App::wnd(), SLOT(onShowNewChannel()));
window->addSeparator();
psShowTelegram = window->addAction(lang(lng_mac_menu_show), App::wnd(), SLOT(showFromTray()));
psMacUpdateMenu();
}
namespace {
void _sendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
QWidget *focused = QApplication::focusWidget();
if (qobject_cast<QLineEdit*>(focused) || qobject_cast<FlatTextarea*>(focused) || qobject_cast<HistoryInner*>(focused)) {
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers));
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers));
}
}
void _forceDisabled(QAction *action, bool disabled) {
if (action->isEnabled()) {
if (disabled) action->setDisabled(true);
} else if (!disabled) {
action->setDisabled(false);
}
}
}
void PsMainWindow::psMacUndo() {
_sendKeySequence(Qt::Key_Z, Qt::ControlModifier);
}
void PsMainWindow::psMacRedo() {
_sendKeySequence(Qt::Key_Z, Qt::ControlModifier | Qt::ShiftModifier);
}
void PsMainWindow::psMacCut() {
_sendKeySequence(Qt::Key_X, Qt::ControlModifier);
}
void PsMainWindow::psMacCopy() {
_sendKeySequence(Qt::Key_C, Qt::ControlModifier);
}
void PsMainWindow::psMacPaste() {
_sendKeySequence(Qt::Key_V, Qt::ControlModifier);
}
void PsMainWindow::psMacDelete() {
_sendKeySequence(Qt::Key_Delete);
}
void PsMainWindow::psMacSelectAll() {
_sendKeySequence(Qt::Key_A, Qt::ControlModifier);
}
bool PsMainWindow::psHandleTitle() {
return false;
}
void PsMainWindow::psInitSysMenu() {
}
void PsMainWindow::psUpdateSysMenu(Qt::WindowState state) {
}
void PsMainWindow::psUpdateMargins() {
}
void PsMainWindow::psMacUpdateMenu() {
if (!posInited) return;
QWidget *focused = QApplication::focusWidget();
bool isLogged = !!App::self(), canUndo = false, canRedo = false, canCut = false, canCopy = false, canPaste = false, canDelete = false, canSelectAll = false;
if (QLineEdit *edit = qobject_cast<QLineEdit*>(focused)) {
canCut = canCopy = canDelete = edit->hasSelectedText();
canSelectAll = !edit->text().isEmpty();
canUndo = edit->isUndoAvailable();
canRedo = edit->isRedoAvailable();
canPaste = !Application::clipboard()->text().isEmpty();
} else if (FlatTextarea *edit = qobject_cast<FlatTextarea*>(focused)) {
canCut = canCopy = canDelete = edit->textCursor().hasSelection();
canSelectAll = !edit->isEmpty();
canUndo = edit->isUndoAvailable();
canRedo = edit->isRedoAvailable();
canPaste = !Application::clipboard()->text().isEmpty();
} else if (HistoryInner *list = qobject_cast<HistoryInner*>(focused)) {
canCopy = list->canCopySelected();
canDelete = list->canDeleteSelected();
}
_forceDisabled(psLogout, !isLogged && !App::passcoded());
_forceDisabled(psUndo, !canUndo);
_forceDisabled(psRedo, !canRedo);
_forceDisabled(psCut, !canCut);
_forceDisabled(psCopy, !canCopy);
_forceDisabled(psPaste, !canPaste);
_forceDisabled(psDelete, !canDelete);
_forceDisabled(psSelectAll, !canSelectAll);
_forceDisabled(psContacts, !isLogged || App::passcoded());
_forceDisabled(psAddContact, !isLogged || App::passcoded());
_forceDisabled(psNewGroup, !isLogged || App::passcoded());
_forceDisabled(psNewChannel, !isLogged || App::passcoded());
_forceDisabled(psShowTelegram, App::wnd()->isActive(false));
}
void PsMainWindow::psFlash() {
_private.startBounce();
}
PsMainWindow::~PsMainWindow() {
finished = true;
}
void PsMainWindow::psClearNotifies(PeerId peerId) {
_private.clearNotifies(peerId);
}
void PsMainWindow::psActivateNotify(NotifyWindow *w) {
objc_activateWnd(w->winId());
}
bool PsMainWindow::psFilterNativeEvent(void *event) {
return _private.filterNativeEvent(event);
}
namespace {
QRect _monitorRect;
uint64 _monitorLastGot = 0;
@ -496,34 +69,6 @@ void psBringToBack(QWidget *w) {
objc_bringToBack(w->winId());
}
void PsMainWindow::psNotifyShown(NotifyWindow *w) {
w->hide();
objc_holdOnTop(w->winId());
w->show();
psShowOverAll(w, false);
}
void PsMainWindow::psPlatformNotify(HistoryItem *item, int32 fwdCount) {
QString title = (!App::passcoded() && cNotifyView() <= dbinvShowName) ? item->history()->peer->name : qsl("Telegram Desktop");
QString subtitle = (!App::passcoded() && cNotifyView() <= dbinvShowName) ? item->notificationHeader() : QString();
QPixmap pix = (!App::passcoded() && cNotifyView() <= dbinvShowName) ? item->history()->peer->genUserpic(st::notifyMacPhotoSize) : QPixmap();
QString msg = (!App::passcoded() && cNotifyView() <= dbinvShowPreview) ? (fwdCount < 2 ? item->notificationText() : lng_forward_messages(lt_count, fwdCount)) : lang(lng_notification_preview);
bool withReply = !App::passcoded() && (cNotifyView() <= dbinvShowPreview) && item->history()->peer->canWrite();
_private.showNotify(item->history()->peer->id, item->id, pix, title, subtitle, msg, withReply);
}
bool PsMainWindow::eventFilter(QObject *obj, QEvent *evt) {
QEvent::Type t = evt->type();
if (t == QEvent::FocusIn || t == QEvent::FocusOut) {
if (qobject_cast<QLineEdit*>(obj) || qobject_cast<FlatTextarea*>(obj) || qobject_cast<HistoryInner*>(obj)) {
psMacUpdateMenu();
}
}
return QMainWindow::eventFilter(obj, evt);
}
QAbstractNativeEventFilter *psNativeEventFilter() {
delete _psEventFilter;
_psEventFilter = new _PsEventFilter();

View File

@ -255,7 +255,7 @@ void objc_holdOnTop(WId winId) {
bool objc_darkMode() {
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
id style = [dict objectForKey:QNSString(strStyleOfInterface()).s()];
BOOL darkModeOn = ( style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] );
BOOL darkModeOn = (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);
return darkModeOn ? true : false;
}

View File

@ -166,15 +166,6 @@ public:
ScrollArea(QWidget *parent, const style::flatScroll &st = st::scrollDef, bool handleTouch = true);
bool viewportEvent(QEvent *e);
void touchEvent(QTouchEvent *e);
bool eventFilter(QObject *obj, QEvent *e);
void resizeEvent(QResizeEvent *e);
void moveEvent(QMoveEvent *e);
void keyPressEvent(QKeyEvent *e);
int scrollWidth() const;
int scrollHeight() const;
int scrollLeftMax() const;
@ -190,13 +181,22 @@ public:
void updateColors(const style::color &bar, const style::color &bg, const style::color &barOver, const style::color &bgOver);
bool focusNextPrevChild(bool next);
bool focusNextPrevChild(bool next) override;
void setMovingByScrollBar(bool movingByScrollBar);
bool viewportEvent(QEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
~ScrollArea();
protected:
bool eventFilter(QObject *obj, QEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void moveEvent(QMoveEvent *e) override;
void touchEvent(QTouchEvent *e);
void enterEventHook(QEvent *e);
void leaveEventHook(QEvent *e);
@ -223,7 +223,7 @@ signals:
protected:
void scrollContentsBy(int dx, int dy);
void scrollContentsBy(int dx, int dy) override;
private:

View File

@ -26,10 +26,13 @@ class MainWindow : public QMainWindow {
public:
MainWindow();
virtual void closeWithoutDestroy();
virtual ~MainWindow();
protected:
virtual void closeWithoutDestroy();
virtual void stateChangedHook(Qt::WindowState state) {
}
};

View File

@ -181,6 +181,9 @@
07DE92AA1AA4928200A18F6F /* moc_autolockbox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07DE92A91AA4928200A18F6F /* moc_autolockbox.cpp */; };
07DE92AD1AA4928B00A18F6F /* moc_passcodebox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07DE92AB1AA4928B00A18F6F /* moc_passcodebox.cpp */; };
07DE92AE1AA4928B00A18F6F /* moc_passcodewidget.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07DE92AC1AA4928B00A18F6F /* moc_passcodewidget.cpp */; };
07E1B1911D12DB3F00722BC7 /* main_window_mac.mm in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07E1B1901D12DB3F00722BC7 /* main_window_mac.mm */; };
07E1B1931D12DED700722BC7 /* moc_main_window_mac.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07E1B1921D12DED700722BC7 /* moc_main_window_mac.cpp */; };
07E1B1961D12DFD200722BC7 /* main_window.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07E1B1941D12DFD200722BC7 /* main_window.cpp */; };
07E373941CBBC11000934F77 /* peer_avatar_button.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 07E373921CBBC11000934F77 /* peer_avatar_button.cpp */; };
0CB7DE9A54CC9BF86FB7B5CA /* facade.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 6D50D70712776D7ED3B00E5C /* facade.cpp */; settings = {ATTRIBUTES = (); }; };
0F7872E39EA570249D420912 /* moc_introwidget.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = A37C7E516201B0264A4CDA38 /* moc_introwidget.cpp */; settings = {ATTRIBUTES = (); }; };
@ -631,6 +634,26 @@
07DE92A91AA4928200A18F6F /* moc_autolockbox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_autolockbox.cpp; path = GeneratedFiles/Debug/moc_autolockbox.cpp; sourceTree = SOURCE_ROOT; };
07DE92AB1AA4928B00A18F6F /* moc_passcodebox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_passcodebox.cpp; path = GeneratedFiles/Debug/moc_passcodebox.cpp; sourceTree = SOURCE_ROOT; };
07DE92AC1AA4928B00A18F6F /* moc_passcodewidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_passcodewidget.cpp; path = GeneratedFiles/Debug/moc_passcodewidget.cpp; sourceTree = SOURCE_ROOT; };
07E1B1781D12DAF100722BC7 /* platform_main_window.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform_main_window.h; path = SourceFiles/platform/platform_main_window.h; sourceTree = SOURCE_ROOT; };
07E1B1791D12DB0700722BC7 /* main_window_win.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_window_win.cpp; path = SourceFiles/platform/win/main_window_win.cpp; sourceTree = SOURCE_ROOT; };
07E1B17A1D12DB0700722BC7 /* main_window_win.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_window_win.h; path = SourceFiles/platform/win/main_window_win.h; sourceTree = SOURCE_ROOT; };
07E1B17B1D12DB0700722BC7 /* windows_app_user_model_id.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = windows_app_user_model_id.cpp; path = SourceFiles/platform/win/windows_app_user_model_id.cpp; sourceTree = SOURCE_ROOT; };
07E1B17C1D12DB0700722BC7 /* windows_app_user_model_id.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = windows_app_user_model_id.h; path = SourceFiles/platform/win/windows_app_user_model_id.h; sourceTree = SOURCE_ROOT; };
07E1B17D1D12DB0700722BC7 /* windows_dlls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = windows_dlls.cpp; path = SourceFiles/platform/win/windows_dlls.cpp; sourceTree = SOURCE_ROOT; };
07E1B17E1D12DB0700722BC7 /* windows_dlls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = windows_dlls.h; path = SourceFiles/platform/win/windows_dlls.h; sourceTree = SOURCE_ROOT; };
07E1B17F1D12DB0700722BC7 /* windows_event_filter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = windows_event_filter.cpp; path = SourceFiles/platform/win/windows_event_filter.cpp; sourceTree = SOURCE_ROOT; };
07E1B1801D12DB0700722BC7 /* windows_event_filter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = windows_event_filter.h; path = SourceFiles/platform/win/windows_event_filter.h; sourceTree = SOURCE_ROOT; };
07E1B1811D12DB0700722BC7 /* windows_toasts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = windows_toasts.cpp; path = SourceFiles/platform/win/windows_toasts.cpp; sourceTree = SOURCE_ROOT; };
07E1B1821D12DB0700722BC7 /* windows_toasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = windows_toasts.h; path = SourceFiles/platform/win/windows_toasts.h; sourceTree = SOURCE_ROOT; };
07E1B1891D12DB2900722BC7 /* main_window_winrt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_window_winrt.cpp; path = SourceFiles/platform/winrt/main_window_winrt.cpp; sourceTree = SOURCE_ROOT; };
07E1B18A1D12DB2900722BC7 /* main_window_winrt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_window_winrt.h; path = SourceFiles/platform/winrt/main_window_winrt.h; sourceTree = SOURCE_ROOT; };
07E1B18C1D12DB3500722BC7 /* main_window_linux.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_window_linux.cpp; path = SourceFiles/platform/linux/main_window_linux.cpp; sourceTree = SOURCE_ROOT; };
07E1B18D1D12DB3500722BC7 /* main_window_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_window_linux.h; path = SourceFiles/platform/linux/main_window_linux.h; sourceTree = SOURCE_ROOT; };
07E1B18F1D12DB3F00722BC7 /* main_window_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_window_mac.h; path = SourceFiles/platform/mac/main_window_mac.h; sourceTree = SOURCE_ROOT; };
07E1B1901D12DB3F00722BC7 /* main_window_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = main_window_mac.mm; path = SourceFiles/platform/mac/main_window_mac.mm; sourceTree = SOURCE_ROOT; };
07E1B1921D12DED700722BC7 /* moc_main_window_mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_main_window_mac.cpp; path = GeneratedFiles/Debug/moc_main_window_mac.cpp; sourceTree = SOURCE_ROOT; };
07E1B1941D12DFD200722BC7 /* main_window.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_window.cpp; path = SourceFiles/window/main_window.cpp; sourceTree = SOURCE_ROOT; };
07E1B1951D12DFD200722BC7 /* main_window.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_window.h; path = SourceFiles/window/main_window.h; sourceTree = SOURCE_ROOT; };
07E373921CBBC11000934F77 /* peer_avatar_button.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = peer_avatar_button.cpp; path = SourceFiles/ui/buttons/peer_avatar_button.cpp; sourceTree = SOURCE_ROOT; };
07E373931CBBC11000934F77 /* peer_avatar_button.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = peer_avatar_button.h; path = SourceFiles/ui/buttons/peer_avatar_button.h; sourceTree = SOURCE_ROOT; };
08A7682548FB7E671FF03822 /* boxshadow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = boxshadow.cpp; path = SourceFiles/ui/boxshadow.cpp; sourceTree = "<absolute>"; };
@ -1076,6 +1099,8 @@
076B1C581CBFC8DF002C0BC2 /* window */ = {
isa = PBXGroup;
children = (
07E1B1941D12DFD200722BC7 /* main_window.cpp */,
07E1B1951D12DFD200722BC7 /* main_window.h */,
0716C97B1D058F2400797B22 /* section_memento.h */,
0716C97C1D058F2400797B22 /* section_widget.cpp */,
0716C97D1D058F2400797B22 /* section_widget.h */,
@ -1176,6 +1201,62 @@
name = toast;
sourceTree = "<group>";
};
07E1B1731D12DAC000722BC7 /* platform */ = {
isa = PBXGroup;
children = (
07E1B1751D12DACB00722BC7 /* linux */,
07E1B1761D12DAD100722BC7 /* mac */,
07E1B1771D12DAD700722BC7 /* win */,
07E1B1881D12DB1500722BC7 /* winrt */,
07E1B1781D12DAF100722BC7 /* platform_main_window.h */,
);
name = platform;
sourceTree = "<group>";
};
07E1B1751D12DACB00722BC7 /* linux */ = {
isa = PBXGroup;
children = (
07E1B18C1D12DB3500722BC7 /* main_window_linux.cpp */,
07E1B18D1D12DB3500722BC7 /* main_window_linux.h */,
);
name = linux;
sourceTree = "<group>";
};
07E1B1761D12DAD100722BC7 /* mac */ = {
isa = PBXGroup;
children = (
07E1B18F1D12DB3F00722BC7 /* main_window_mac.h */,
07E1B1901D12DB3F00722BC7 /* main_window_mac.mm */,
);
name = mac;
sourceTree = "<group>";
};
07E1B1771D12DAD700722BC7 /* win */ = {
isa = PBXGroup;
children = (
07E1B1791D12DB0700722BC7 /* main_window_win.cpp */,
07E1B17A1D12DB0700722BC7 /* main_window_win.h */,
07E1B17B1D12DB0700722BC7 /* windows_app_user_model_id.cpp */,
07E1B17C1D12DB0700722BC7 /* windows_app_user_model_id.h */,
07E1B17D1D12DB0700722BC7 /* windows_dlls.cpp */,
07E1B17E1D12DB0700722BC7 /* windows_dlls.h */,
07E1B17F1D12DB0700722BC7 /* windows_event_filter.cpp */,
07E1B1801D12DB0700722BC7 /* windows_event_filter.h */,
07E1B1811D12DB0700722BC7 /* windows_toasts.cpp */,
07E1B1821D12DB0700722BC7 /* windows_toasts.h */,
);
name = win;
sourceTree = "<group>";
};
07E1B1881D12DB1500722BC7 /* winrt */ = {
isa = PBXGroup;
children = (
07E1B1891D12DB2900722BC7 /* main_window_winrt.cpp */,
07E1B18A1D12DB2900722BC7 /* main_window_winrt.h */,
);
name = winrt;
sourceTree = "<group>";
};
07E373901CBBBFDE00934F77 /* buttons */ = {
isa = PBXGroup;
children = (
@ -1316,6 +1397,7 @@
5E35A03E5F2C51353EBCBF00 /* intro */,
1A6AA22F4A758C4B5F5138FB /* mtproto */,
076B1C5C1CBFC97D002C0BC2 /* overview */,
07E1B1731D12DAC000722BC7 /* platform */,
0716C92C1D05898D00797B22 /* profile */,
0702E99F1CB8D290007A7495 /* serialize */,
579DA7AEF5751DF4988869A0 /* ui */,
@ -1453,6 +1535,7 @@
1FE45A67215BEA2434F588E8 /* moc_layerwidget.cpp */,
1D7899ACAA9F973CADFA34C1 /* moc_localimageloader.cpp */,
07BE85111A20961F008ACB9F /* moc_localstorage.cpp */,
07E1B1921D12DED700722BC7 /* moc_main_window_mac.cpp */,
3A220FD1AE5AD9FE3DC073A4 /* moc_mainwidget.cpp */,
6B46A0EE3C3B9D3B5A24946E /* moc_mainwindow.cpp */,
07A6933419927B160099CB9F /* moc_mediaview.cpp */,
@ -1835,6 +1918,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
07E1B1911D12DB3F00722BC7 /* main_window_mac.mm in Compile Sources */,
1299DDAE203A7EDFED9F5D6B /* main.cpp in Compile Sources */,
D87463318C8E5211C8C8670A /* stdafx.cpp in Compile Sources */,
7BEFA1D273AD62772AA33D73 /* app.cpp in Compile Sources */,
@ -1872,6 +1956,7 @@
0716C97A1D058C8600797B22 /* moc_report_box.cpp in Compile Sources */,
077A4AF81CA41C38002188D2 /* connection_auto.cpp in Compile Sources */,
4078D5D614EB3ECF7F1848C7 /* basic_types.cpp in Compile Sources */,
07E1B1931D12DED700722BC7 /* moc_main_window_mac.cpp in Compile Sources */,
68FFEB7CA30BF0149161B809 /* mainwindow.cpp in Compile Sources */,
0716C9831D05931400797B22 /* moc_section_widget.cpp in Compile Sources */,
0CB7DE9A54CC9BF86FB7B5CA /* facade.cpp in Compile Sources */,
@ -2045,6 +2130,7 @@
074968D01A44D14C00394F46 /* languagebox.cpp in Compile Sources */,
077A4AF91CA41C38002188D2 /* connection_http.cpp in Compile Sources */,
07BE85121A20961F008ACB9F /* moc_localstorage.cpp in Compile Sources */,
07E1B1961D12DFD200722BC7 /* main_window.cpp in Compile Sources */,
07AF95F41AFD03B90060B057 /* qrc_telegram_emojis.cpp in Compile Sources */,
07C759721B1F7E2800662169 /* moc_autoupdater.cpp in Compile Sources */,
0716C9601D058C6600797B22 /* style_profile.cpp in Compile Sources */,

View File

@ -95,6 +95,7 @@ compilers: GeneratedFiles/qrc_telegram.cpp\
GeneratedFiles/Debug/moc_layerwidget.cpp\
GeneratedFiles/Debug/moc_localimageloader.cpp\
GeneratedFiles/Debug/moc_localstorage.cpp\
GeneratedFiles/Debug/moc_main_window_mac.cpp\
GeneratedFiles/Debug/moc_mainwidget.cpp\
GeneratedFiles/Debug/moc_mainwindow.cpp\
GeneratedFiles/Debug/moc_mediaview.cpp\
@ -114,7 +115,6 @@ compilers: GeneratedFiles/qrc_telegram.cpp\
GeneratedFiles/Debug/moc_profile_settings_widget.cpp\
GeneratedFiles/Debug/moc_profile_shared_media_widget.cpp\
GeneratedFiles/Debug/moc_profile_widget.cpp\
GeneratedFiles/Debug/moc_pspecific_mac.cpp\
GeneratedFiles/Debug/moc_report_box.cpp\
GeneratedFiles/Debug/moc_scrollarea.cpp\
GeneratedFiles/Debug/moc_section_widget.cpp\
@ -232,6 +232,7 @@ compiler_moc_header_make_all: GeneratedFiles/Debug/moc_aboutbox.cpp\
GeneratedFiles/Debug/moc_layerwidget.cpp\
GeneratedFiles/Debug/moc_localimageloader.cpp\
GeneratedFiles/Debug/moc_localstorage.cpp\
GeneratedFiles/Debug/moc_main_window_mac.cpp\
GeneratedFiles/Debug/moc_mainwidget.cpp\
GeneratedFiles/Debug/moc_mainwindow.cpp\
GeneratedFiles/Debug/moc_mediaview.cpp\
@ -251,7 +252,6 @@ compiler_moc_header_make_all: GeneratedFiles/Debug/moc_aboutbox.cpp\
GeneratedFiles/Debug/moc_profile_settings_widget.cpp\
GeneratedFiles/Debug/moc_profile_shared_media_widget.cpp\
GeneratedFiles/Debug/moc_profile_widget.cpp\
GeneratedFiles/Debug/moc_pspecific_mac.cpp\
GeneratedFiles/Debug/moc_report_box.cpp\
GeneratedFiles/Debug/moc_scrollarea.cpp\
GeneratedFiles/Debug/moc_section_widget.cpp\
@ -312,6 +312,7 @@ compiler_moc_header_clean:
GeneratedFiles/Debug/moc_layerwidget.cpp\
GeneratedFiles/Debug/moc_localimageloader.cpp\
GeneratedFiles/Debug/moc_localstorage.cpp\
GeneratedFiles/Debug/moc_main_window_mac.cpp\
GeneratedFiles/Debug/moc_mainwidget.cpp\
GeneratedFiles/Debug/moc_mainwindow.cpp\
GeneratedFiles/Debug/moc_mediaview.cpp\
@ -331,7 +332,6 @@ compiler_moc_header_clean:
GeneratedFiles/Debug/moc_profile_settings_widget.cpp\
GeneratedFiles/Debug/moc_profile_shared_media_widget.cpp\
GeneratedFiles/Debug/moc_profile_widget.cpp\
GeneratedFiles/Debug/moc_pspecific_mac.cpp\
GeneratedFiles/Debug/moc_report_box.cpp\
GeneratedFiles/Debug/moc_scrollarea.cpp\
GeneratedFiles/Debug/moc_section_widget.cpp\
@ -483,6 +483,9 @@ GeneratedFiles/Debug/moc_localimageloader.cpp: SourceFiles/localimageloader.h
GeneratedFiles/Debug/moc_localstorage.cpp: SourceFiles/localstorage.h
$(MOC_FILE) SourceFiles/localstorage.h -o GeneratedFiles/Debug/moc_localstorage.cpp
GeneratedFiles/Debug/moc_main_window_mac.cpp: SourceFiles/platform/mac/main_window_mac.h
$(MOC_FILE) SourceFiles/platform/mac/main_window_mac.h -o GeneratedFiles/Debug/moc_main_window_mac.cpp
GeneratedFiles/Debug/moc_mainwidget.cpp: SourceFiles/mainwidget.h
$(MOC_FILE) SourceFiles/mainwidget.h -o GeneratedFiles/Debug/moc_mainwidget.cpp
@ -540,9 +543,6 @@ GeneratedFiles/Debug/moc_profile_shared_media_widget.cpp: SourceFiles/profile/pr
GeneratedFiles/Debug/moc_profile_widget.cpp: SourceFiles/profile/profile_widget.h
$(MOC_FILE) SourceFiles/profile/profile_widget.h -o GeneratedFiles/Debug/moc_profile_widget.cpp
GeneratedFiles/Debug/moc_pspecific_mac.cpp: SourceFiles/pspecific_mac.h
$(MOC_FILE) SourceFiles/pspecific_mac.h -o GeneratedFiles/Debug/moc_pspecific_mac.cpp
GeneratedFiles/Debug/moc_report_box.cpp: SourceFiles/boxes/report_box.h
$(MOC_FILE) SourceFiles/boxes/report_box.h -o GeneratedFiles/Debug/moc_report_box.cpp