diff --git a/Telegram/Resources/lang.txt b/Telegram/Resources/lang.txt
index 62d0187bc..4b5e00eca 100644
--- a/Telegram/Resources/lang.txt
+++ b/Telegram/Resources/lang.txt
@@ -237,6 +237,7 @@ lng_connection_save: "Save";
 lng_settings_reset: "Reset other sessions";
 lng_settings_reset_done: "Sessions reset done";
 lng_settings_logout: "Log Out";
+lng_sure_logout: "Are you sure you want to log out?";
 
 lng_settings_need_restart: "You need to restart for applying
 some of the new settings. Restart now?";
@@ -477,5 +478,21 @@ lng_mac_always_open_with: "Always Open With";
 lng_mac_this_app_can_open: "This application can open \"{file}\".";
 lng_mac_not_known_app: "It's not known if this application can open \"{file}\".";
 
-// Keys finished
+lng_mac_menu_about: "About Telegram";
+lng_mac_menu_preferences: "Preferences...";
+lng_mac_menu_file: "File";
+lng_mac_menu_logout: "Log Out";
+lng_mac_menu_edit: "Edit";
+lng_mac_menu_undo: "Undo";
+lng_mac_menu_redo: "Redo";
+lng_mac_menu_cut: "Cut";
+lng_mac_menu_copy: "Copy";
+lng_mac_menu_paste: "Paste";
+lng_mac_menu_delete: "Delete";
+lng_mac_menu_select_all: "Select All";
+lng_mac_menu_window: "Window";
+lng_mac_menu_contacts: "Contacts";
+lng_mac_menu_new_group: "New Group";
+lng_mac_menu_show: "Show Telegram";
 
+// Keys finished
diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt
index 92dabf00f..b57cb36ae 100644
--- a/Telegram/Resources/style.txt
+++ b/Telegram/Resources/style.txt
@@ -29,7 +29,7 @@ emojiPadding: 0px;
 counterBG: #f23c34;
 counterMuteBG: #888;
 counterColor: #fff;
-counterMacInvColor: #045fd5;
+counterMacInvColor: #ffffff01;
 
 lineWidth: 1px;
 
diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp
index b5032836c..9db1120c5 100644
--- a/Telegram/SourceFiles/app.cpp
+++ b/Telegram/SourceFiles/app.cpp
@@ -309,7 +309,10 @@ namespace App {
 				data->contact = -1;
 				status = &d.vstatus;
 
-				::self = data;
+				if (::self != data) {
+					::self = data;
+					if (App::wnd()) App::wnd()->updateGlobalMenu();
+				}
 			} break;
 			case mtpc_userContact: {
 				const MTPDuserContact &d(user.c_userContact());
@@ -1278,6 +1281,7 @@ namespace App {
 		lastPhotos.clear();
 		lastPhotosMap.clear();
 		::self = 0;
+		if (App::wnd()) App::wnd()->updateGlobalMenu();
 	}
 /* // don't delete history without deleting its' peerdata
 	void deleteHistory(const PeerId &peer) {
diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h
index 98dce7aa0..05266a421 100644
--- a/Telegram/SourceFiles/application.h
+++ b/Telegram/SourceFiles/application.h
@@ -139,5 +139,5 @@ private:
 	PsUpdateDownloader *updateDownloader;
 
 	QTimer writeUserConfigTimer;
-	
+
 };
diff --git a/Telegram/SourceFiles/gui/flatinput.cpp b/Telegram/SourceFiles/gui/flatinput.cpp
index 90fbe6067..455931ca1 100644
--- a/Telegram/SourceFiles/gui/flatinput.cpp
+++ b/Telegram/SourceFiles/gui/flatinput.cpp
@@ -19,6 +19,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
 #include "style.h"
 
 #include "flatinput.h"
+#include "window.h"
 
 namespace {
 	class FlatInputStyle : public QCommonStyle {
@@ -57,6 +58,7 @@ FlatInput::FlatInput(QWidget *parent, const style::flatInput &st, const QString
 
 	connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(onTextChange(const QString &)));
 	connect(this, SIGNAL(textEdited(const QString &)), this, SLOT(onTextEdited()));
+	if (App::wnd()) connect(this, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
 
 	setStyle(&_flatInputStyle);
 	setTextMargins(0, 0, 0, 0);
@@ -262,10 +264,12 @@ void FlatInput::onTextEdited() {
 	_oldtext = text();
 	if (was != _oldtext) emit changed();
 	updatePlaceholder();
+	if (App::wnd()) App::wnd()->updateGlobalMenu();
 }
 
 void FlatInput::onTextChange(const QString &text) {
 	_oldtext = text;
+	if (App::wnd()) App::wnd()->updateGlobalMenu();
 }
 
 void FlatInput::notaBene() {
diff --git a/Telegram/SourceFiles/gui/flattextarea.cpp b/Telegram/SourceFiles/gui/flattextarea.cpp
index 718beb9e7..b179c3033 100644
--- a/Telegram/SourceFiles/gui/flattextarea.cpp
+++ b/Telegram/SourceFiles/gui/flattextarea.cpp
@@ -19,11 +19,12 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
 #include "style.h"
 
 #include "flattextarea.h"
+#include "window.h"
 
 FlatTextarea::FlatTextarea(QWidget *parent, const style::flatTextarea &st, const QString &pholder, const QString &v) : QTextEdit(v, parent),
 	_ph(pholder), _oldtext(v), _phVisible(!v.length()),
     a_phLeft(_phVisible ? 0 : st.phShift), a_phAlpha(_phVisible ? 1 : 0), a_phColor(st.phColor->c),
-    _st(st), _fakeMargin(0),
+    _st(st), _undoAvailable(false), _redoAvailable(false), _fakeMargin(0),
     _touchPress(false), _touchRightButton(false), _touchMove(false), _replacingEmojis(false) {
 	setAcceptRichText(false);
 	resize(_st.width, _st.font->height);
@@ -58,6 +59,9 @@ FlatTextarea::FlatTextarea(QWidget *parent, const style::flatTextarea &st, const
 
 	connect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(onDocumentContentsChange(int, int, int)));
 	connect(document(), SIGNAL(contentsChanged()), this, SLOT(onDocumentContentsChanged()));
+	connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
+	connect(this, SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
+	if (App::wnd()) connect(this, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
 }
 
 void FlatTextarea::onTouchTimer() {
@@ -268,6 +272,14 @@ bool FlatTextarea::hasText() const {
 	return (from.next() != till);
 }
 
+bool FlatTextarea::isUndoAvailable() const {
+	return _undoAvailable;
+}
+
+bool FlatTextarea::isRedoAvailable() const {
+	return _redoAvailable;
+}
+
 void FlatTextarea::insertEmoji(EmojiPtr emoji, QTextCursor c) {
 	c.removeSelectedText();
 
@@ -398,6 +410,17 @@ void FlatTextarea::onDocumentContentsChanged() {
 		emit changed();
 	}
 	updatePlaceholder();
+	if (App::wnd()) App::wnd()->updateGlobalMenu();
+}
+
+void FlatTextarea::onUndoAvailable(bool avail) {
+	_undoAvailable = avail;
+	if (App::wnd()) App::wnd()->updateGlobalMenu();
+}
+
+void FlatTextarea::onRedoAvailable(bool avail) {
+	_redoAvailable = avail;
+	if (App::wnd()) App::wnd()->updateGlobalMenu();
 }
 
 bool FlatTextarea::animStep(float64 ms) {
diff --git a/Telegram/SourceFiles/gui/flattextarea.h b/Telegram/SourceFiles/gui/flattextarea.h
index 78a7370dc..52992a4a9 100644
--- a/Telegram/SourceFiles/gui/flattextarea.h
+++ b/Telegram/SourceFiles/gui/flattextarea.h
@@ -51,6 +51,9 @@ public:
 	QString getText(int32 start = 0, int32 end = -1) const;
 	bool hasText() const;
 
+	bool isUndoAvailable() const;
+	bool isRedoAvailable() const;
+
 public slots:
 
 	void onTouchTimer();
@@ -58,6 +61,9 @@ public slots:
 	void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
 	void onDocumentContentsChanged();
 
+	void onUndoAvailable(bool avail);
+	void onRedoAvailable(bool avail);
+
 signals:
 
 	void changed();
@@ -82,6 +88,8 @@ private:
 	anim::cvalue a_phColor;
 	style::flatTextarea _st;
 
+	bool _undoAvailable, _redoAvailable;
+
 	int32 _fakeMargin;
 
 	QTimer _touchTimer;
diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp
index f6bda8f1d..587cc8859 100644
--- a/Telegram/SourceFiles/historywidget.cpp
+++ b/Telegram/SourceFiles/historywidget.cpp
@@ -976,6 +976,14 @@ HistoryItem *HistoryList::nextItem(HistoryItem *item) {
 	return 0;
 }
 
+bool HistoryList::canCopySelected() const {
+	return !_selected.isEmpty();
+}
+
+bool HistoryList::canDeleteSelected() const {
+	return !_selected.isEmpty() && (_selected.cbegin().value() == FullItemSel);
+}
+
 void HistoryList::getSelectionState(int32 &selectedForForward, int32 &selectedForDelete) const {
 	selectedForForward = selectedForDelete = 0;
 	for (SelectedItems::const_iterator i = _selected.cbegin(), e = _selected.cend(); i != e; ++i) {
diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h
index 1833c6244..58c9f3d14 100644
--- a/Telegram/SourceFiles/historywidget.h
+++ b/Telegram/SourceFiles/historywidget.h
@@ -68,6 +68,9 @@ public:
 
 	void updateMsg(const HistoryItem *msg);
 
+	bool canCopySelected() const;
+	bool canDeleteSelected() const;
+
 	void getSelectionState(int32 &selectedForForward, int32 &selectedForDelete) const;
 	void clearSelectedItems(bool onlyTextSelection = false);
 	void fillSelectedItems(SelectedItemSet &sel, bool forDelete = true);
diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp
index 4a54c42f2..084f3e4d0 100644
--- a/Telegram/SourceFiles/mainwidget.cpp
+++ b/Telegram/SourceFiles/mainwidget.cpp
@@ -766,12 +766,15 @@ void MainWidget::peerUsernameChanged(PeerData *peer) {
 
 void MainWidget::checkLastUpdate(bool afterSleep) {
 	uint64 n = getms(true);
-	LOG(("Checking last update!.. last update %1, now %2, noUpdatesTimer %3, remains %4").arg(_lastUpdateTime).arg(n).arg(noUpdatesTimer.isActive() ? 1 : 0).arg(noUpdatesTimer.remainingTime()));
 	if (_lastUpdateTime && n > _lastUpdateTime + (afterSleep ? NoUpdatesAfterSleepTimeout : NoUpdatesTimeout)) {
 		getDifference();
 	}
 }
 
+void MainWidget::showNewGroup() {
+	dialogs.onNewGroup();
+}
+
 void MainWidget::photosLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req) {
 	OverviewsPreload::iterator it;
 	MediaOverviewType type = OverviewCount;
diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h
index 72a417d89..11ec68232 100644
--- a/Telegram/SourceFiles/mainwidget.h
+++ b/Telegram/SourceFiles/mainwidget.h
@@ -285,6 +285,7 @@ public:
 	void peerUsernameChanged(PeerData *peer);
 
 	void checkLastUpdate(bool afterSleep);
+	void showNewGroup();
 
 	~MainWidget();
 
diff --git a/Telegram/SourceFiles/pspecific_mac.cpp b/Telegram/SourceFiles/pspecific_mac.cpp
index f9565882c..542f3d06e 100644
--- a/Telegram/SourceFiles/pspecific_mac.cpp
+++ b/Telegram/SourceFiles/pspecific_mac.cpp
@@ -21,6 +21,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
 #include "lang.h"
 #include "application.h"
 #include "mainwidget.h"
+#include "historywidget.h"
 
 namespace {
 	bool frameless = true;
@@ -48,6 +49,12 @@ void MacPrivate::activeSpaceChanged() {
     }
 }
 
+void MacPrivate::darkModeChanged() {
+	if (App::wnd()) {
+		App::wnd()->psUpdateCounter();
+	}
+}
+
 void MacPrivate::notifyClicked(unsigned long long peer) {
     History *history = App::history(PeerId(peer));
 
@@ -64,7 +71,8 @@ void MacPrivate::notifyReplied(unsigned long long peer, const char *str) {
 }
 
 PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
-posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")), wndIcon(QPixmap(qsl(":/gui/art/iconbig128.png"))) {
+posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")), wndIcon(QPixmap(qsl(":/gui/art/iconbig128.png"))),
+psLogout(0), psUndo(0), psRedo(0), psCut(0), psCopy(0), psPaste(0), psDelete(0), psSelectAll(0), psContacts(0), psNewGroup(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));
@@ -189,13 +197,14 @@ void PsMainWindow::psUpdateCounter() {
     _private.setWindowBadge(counter ? cnt : QString());
 
 	if (trayIcon) {
-		style::color bg = (App::histories().unreadMuted < counter) ? st::counterBG : st::counterMuteBG;
+		bool dm = objc_darkMode(), important = (App::histories().unreadMuted < counter);
+		style::color bg = important ? st::counterBG : st::counterMuteBG;
 		QIcon icon;
-		QImage img(psTrayIcon()), imgsel(psTrayIcon(true));
+		QImage img(psTrayIcon(dm)), imgsel(psTrayIcon(true));
 		img.detach();
 		imgsel.detach();
 		int32 size = cRetina() ? 44 : 22;
-		_placeCounter(img, size, counter, bg, st::counterColor);
+		_placeCounter(img, size, counter, bg, (dm && !important) ? st::counterMacInvColor : st::counterColor);
 		_placeCounter(imgsel, size, counter, st::white, st::counterMacInvColor);
 		icon.addPixmap(QPixmap::fromImage(img));
 		icon.addPixmap(QPixmap::fromImage(imgsel), QIcon::Selected);
@@ -337,6 +346,81 @@ void PsMainWindow::psFirstShow() {
 		show();
 	}
 	posInited = true;
+
+	// init global menu
+	QMenu *main = psMainMenu.addMenu(qsl("Telegram"));
+	main->addAction(lang(lng_mac_menu_about), App::wnd()->getTitle(), SLOT(onAbout()))->setMenuRole(QAction::AboutQtRole);
+	main->addSeparator();
+	QAction *prefs = main->addAction(lang(lng_mac_menu_preferences), App::wnd(), SLOT(showSettings()));
+	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()));
+	window->addSeparator();
+	psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup()));
+	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<HistoryList*>(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() {
@@ -352,6 +436,40 @@ 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 = !App::app()->clipboard()->text().isEmpty();
+	} else if (FlatTextarea *edit = qobject_cast<FlatTextarea*>(focused)) {
+		canCut = canCopy = canDelete = edit->textCursor().hasSelection();
+		canSelectAll = edit->hasText();
+		canUndo = edit->isUndoAvailable();
+		canRedo = edit->isRedoAvailable();
+		canPaste = !App::app()->clipboard()->text().isEmpty();
+	} else if (HistoryList *list = qobject_cast<HistoryList*>(focused)) {
+		canCopy = list->canCopySelected();
+		canDelete = list->canDeleteSelected();
+	}
+	_forceDisabled(psLogout, !isLogged);
+	_forceDisabled(psUndo, !canUndo);
+	_forceDisabled(psRedo, !canRedo);
+	_forceDisabled(psCut, !canCut);
+	_forceDisabled(psCopy, !canCopy);
+	_forceDisabled(psPaste, !canPaste);
+	_forceDisabled(psDelete, !canDelete);
+	_forceDisabled(psSelectAll, !canSelectAll);
+	_forceDisabled(psContacts, !isLogged);
+	_forceDisabled(psNewGroup, !isLogged);
+	_forceDisabled(psShowTelegram, psIsActive());
+}
+
 void PsMainWindow::psFlash() {
     _private.startBounce();
 }
@@ -404,6 +522,16 @@ void PsMainWindow::psPlatformNotify(HistoryItem *item) {
 	_private.showNotify(item->history()->peer->id, title, subtitle, msg, (cNotifyView() <= dbinvShowPreview));
 }
 
+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<HistoryList*>(obj)) {
+			psMacUpdateMenu();
+		}
+	}
+	return QMainWindow::eventFilter(obj, evt);
+}
+
 PsApplication::PsApplication(int &argc, char **argv) : QApplication(argc, argv) {
 }
 
diff --git a/Telegram/SourceFiles/pspecific_mac.h b/Telegram/SourceFiles/pspecific_mac.h
index cb8e971a0..4c6c8104d 100644
--- a/Telegram/SourceFiles/pspecific_mac.h
+++ b/Telegram/SourceFiles/pspecific_mac.h
@@ -33,6 +33,7 @@ class MacPrivate : public PsMacWindowPrivate {
 public:
     
     void activeSpaceChanged();
+	void darkModeChanged();
     void notifyClicked(unsigned long long peer);
     void notifyReplied(unsigned long long peer, const char *str);
     
@@ -79,6 +80,8 @@ public:
 	void psNotifyShown(NotifyWindow *w);
 	void psPlatformNotify(HistoryItem *item);
 
+	bool eventFilter(QObject *obj, QEvent *evt);
+
 	~PsMainWindow();
 
 public slots:
@@ -90,11 +93,21 @@ public slots:
 	void psIdleTimeout();
 	void psShowTrayMenu();
 
+	void psMacUndo();
+	void psMacRedo();
+	void psMacCut();
+	void psMacCopy();
+	void psMacPaste();
+	void psMacDelete();
+	void psMacSelectAll();
+
 protected:
 
 	void psNotIdle() const;
 	QImage psTrayIcon(bool selected = false) const;
 
+	void psMacUpdateMenu();
+
 	bool posInited;
     QSystemTrayIcon *trayIcon;
     QMenu *trayIconMenu;
@@ -114,6 +127,10 @@ private:
 
 	mutable bool psIdle;
 	mutable QTimer psIdleTimer;
+
+	QMenuBar psMainMenu;
+	QAction *psLogout, *psUndo, *psRedo, *psCut, *psCopy, *psPaste, *psDelete, *psSelectAll, *psContacts, *psNewGroup, *psShowTelegram;
+
 };
 
 
diff --git a/Telegram/SourceFiles/pspecific_mac_p.h b/Telegram/SourceFiles/pspecific_mac_p.h
index 9ff3dd6d0..0f3733c30 100644
--- a/Telegram/SourceFiles/pspecific_mac_p.h
+++ b/Telegram/SourceFiles/pspecific_mac_p.h
@@ -36,6 +36,8 @@ public:
         
     virtual void activeSpaceChanged() {
     }
+	virtual void darkModeChanged() {
+	}
     virtual void notifyClicked(unsigned long long peer) {
     }
     virtual void notifyReplied(unsigned long long peer, const char *str) {
@@ -48,6 +50,7 @@ public:
 };
 
 void objc_holdOnTop(WId winId);
+bool objc_darkMode();
 void objc_showOverAll(WId winId, bool canFocus = true);
 void objc_bringToBack(WId winId);
 void objc_activateWnd(WId winId);
diff --git a/Telegram/SourceFiles/pspecific_mac_p.mm b/Telegram/SourceFiles/pspecific_mac_p.mm
index 649807e11..e51ded13a 100644
--- a/Telegram/SourceFiles/pspecific_mac_p.mm
+++ b/Telegram/SourceFiles/pspecific_mac_p.mm
@@ -85,6 +85,7 @@ QNSString objc_lang(LangKey key) {
 
 - (id) init:(PsMacWindowPrivate *)aWnd;
 - (void) activeSpaceDidChange:(NSNotification *)aNotification;
+- (void) darkModeChanged:(NSNotification *)aNotification;
 
 @end
 
@@ -145,6 +146,10 @@ public:
     wnd->activeSpaceChanged();
 }
 
+- (void) darkModeChanged:(NSNotification *)aNotification {
+	wnd->darkModeChanged();
+}
+
 @end
 
 @implementation NotifyHandler {
@@ -180,6 +185,7 @@ public:
 
 PsMacWindowPrivate::PsMacWindowPrivate() : data(new PsMacWindowData(this)) {
     [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:data->observerHelper selector:@selector(activeSpaceDidChange:) name:NSWorkspaceActiveSpaceDidChangeNotification object:nil];
+	[[NSDistributedNotificationCenter defaultCenter] addObserver:data->observerHelper selector:@selector(darkModeChanged:) name:@"AppleInterfaceThemeChangedNotification" object:nil];
 }
 
 void PsMacWindowPrivate::setWindowBadge(const QString &str) {
@@ -200,6 +206,13 @@ void objc_holdOnTop(WId winId) {
     [wnd setHidesOnDeactivate:NO];
 }
 
+bool objc_darkMode() {
+	NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
+	id style = [dict objectForKey:@"AppleInterfaceStyle"];
+	BOOL darkModeOn = ( style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] );
+	return darkModeOn ? true : false;
+}
+
 void objc_showOverAll(WId winId, bool canFocus) {
     NSWindow *wnd = [reinterpret_cast<NSView *>(winId) window];
 	[wnd setLevel:NSPopUpMenuWindowLevel];
diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp
index 9b182286a..119f11604 100644
--- a/Telegram/SourceFiles/settingswidget.cpp
+++ b/Telegram/SourceFiles/settingswidget.cpp
@@ -239,7 +239,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
 	// advanced
 	connect(&_connectionType, SIGNAL(clicked()), this, SLOT(onConnectionType()));
 	connect(&_resetSessions, SIGNAL(clicked()), this, SLOT(onResetSessions()));
-	connect(&_logOut, SIGNAL(clicked()), this, SLOT(onLogout()));
+	connect(&_logOut, SIGNAL(clicked()), App::wnd(), SLOT(onLogout()));
 
 	_connectionTypeText = lang(lng_connection_type) + ' ';
 	_connectionTypeWidth = st::linkFont->m.width(_connectionTypeText);
@@ -823,10 +823,6 @@ void SettingsInner::onUpdatePhoto() {
 	App::wnd()->showLayer(box);
 }
 
-void SettingsInner::onLogout() {
-	App::logOut();
-}
-
 void SettingsInner::onResetSessions() {
 	MTP::send(MTPauth_ResetAuthorizations(), rpcDone(&SettingsInner::doneResetSessions));
 }
diff --git a/Telegram/SourceFiles/settingswidget.h b/Telegram/SourceFiles/settingswidget.h
index 2b335c2d7..be325756d 100644
--- a/Telegram/SourceFiles/settingswidget.h
+++ b/Telegram/SourceFiles/settingswidget.h
@@ -133,7 +133,6 @@ public slots:
 	void onUpdateReady();
 	void onUpdateFailed();
 
-	void onLogout();
 	void onResetSessions();
 
 	void onPhotoUpdateDone(PeerId peer);
diff --git a/Telegram/SourceFiles/title.cpp b/Telegram/SourceFiles/title.cpp
index 57dae478f..fc84224df 100644
--- a/Telegram/SourceFiles/title.cpp
+++ b/Telegram/SourceFiles/title.cpp
@@ -117,11 +117,14 @@ void TitleWidget::setHideLevel(float64 level) {
 }
 
 void TitleWidget::onContacts() {
+	if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
+
 	if (!App::self()) return;
 	App::wnd()->showLayer(new ContactsBox());
 }
 
 void TitleWidget::onAbout() {
+	if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
 	App::wnd()->showLayer(new AboutBox());
 }
 
diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp
index fb78629c0..6adc30ebf 100644
--- a/Telegram/SourceFiles/window.cpp
+++ b/Telegram/SourceFiles/window.cpp
@@ -28,6 +28,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
 #include "mainwidget.h"
 #include "layerwidget.h"
 #include "settingswidget.h"
+#include "boxes/confirmbox.h"
 
 #include "mediaview.h"
 
@@ -480,6 +481,8 @@ void Window::setupMain(bool anim) {
 }
 
 void Window::showSettings() {
+	if (isHidden()) showFromTray();
+
 	App::wnd()->hideLayer();
 	if (settings) {
 		return hideSettings();
@@ -770,6 +773,7 @@ bool Window::minimizeToTray() {
 	}
 	if (App::main()) App::main()->setOnline(windowState());
 	updateTrayMenu();
+	updateGlobalMenu();
 	return true;
 }
 
@@ -813,6 +817,30 @@ void Window::updateTrayMenu(bool force) {
 #endif
 }
 
+void Window::onShowNewGroup() {
+	if (isHidden()) showFromTray();
+
+	if (main) main->showNewGroup();
+}
+
+void Window::onLogout() {
+	if (isHidden()) showFromTray();
+
+	ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout));
+	connect(box, SIGNAL(confirmed()), this, SLOT(onLogoutSure()));
+	App::wnd()->showLayer(box);
+}
+
+void Window::onLogoutSure() {
+	App::logOut();
+}
+
+void Window::updateGlobalMenu() {
+#ifdef Q_OS_MAC
+	psMacUpdateMenu();
+#endif
+}
+
 void Window::quitFromTray() {
 	App::quit();
 }
@@ -878,6 +906,7 @@ void Window::showFromTray(QSystemTrayIcon::ActivationReason reason) {
 		psUpdateCounter();
 		if (App::main()) App::main()->setOnline(windowState());
 		QTimer::singleShot(1, this, SLOT(updateTrayMenu()));
+		QTimer::singleShot(1, this, SLOT(updateGlobalMenu()));
 	}
 }
 
diff --git a/Telegram/SourceFiles/window.h b/Telegram/SourceFiles/window.h
index 15b2ea0b5..97e28baf0 100644
--- a/Telegram/SourceFiles/window.h
+++ b/Telegram/SourceFiles/window.h
@@ -249,6 +249,11 @@ public slots:
 	void notifyFire();
 	void updateTrayMenu(bool force = false);
 
+	void onShowNewGroup();
+	void onLogout();
+	void onLogoutSure();
+	void updateGlobalMenu(); // for OS X top menu
+
 signals:
 
 	void resized(const QSize &size);