2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Custom title bar for macOS 10.10+ improved, colors in palette now.

This commit is contained in:
John Preston
2016-11-09 11:34:38 +03:00
parent 494254496e
commit 8ff3779c9a
13 changed files with 116 additions and 34 deletions

View File

@@ -30,7 +30,8 @@ namespace Window {
MainWindow::MainWindow() : QWidget()
, _positionUpdatedTimer(this)
, _body(this) {
, _body(this)
, _titleText(qsl("Telegram")) {
subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) {
using Type = Theme::BackgroundUpdate::Type;
if (data.type == Type::TestingTheme || data.type == Type::RevertingTheme || data.type == Type::ApplyingTheme) {
@@ -39,6 +40,7 @@ MainWindow::MainWindow() : QWidget()
}
}
});
subscribe(Global::RefUnreadCounterUpdate(), [this] { updateUnreadCounter(); });
}
void MainWindow::init() {
@@ -105,11 +107,16 @@ void MainWindow::positionUpdated() {
_positionUpdatedTimer->start(SaveWindowPositionTimeout);
}
void MainWindow::setTitleVisibility(bool visible) {
bool MainWindow::titleVisible() const {
return _title && !_title->isHidden();
}
void MainWindow::setTitleVisible(bool visible) {
if (_title && (_title->isHidden() == visible)) {
_title->setVisible(visible);
updateControlsGeometry();
}
titleVisibilityChangedHook();
}
int32 MainWindow::screenNameChecksum(const QString &name) const {
@@ -134,6 +141,15 @@ void MainWindow::updateControlsGeometry() {
_body->setGeometry(0, bodyTop, width(), height() - bodyTop);
}
void MainWindow::updateUnreadCounter() {
if (!Global::started() || App::quitting()) return;
auto counter = App::histories().unreadBadge();
_titleText = (counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram");
unreadCounterChangedHook();
}
void MainWindow::savePosition(Qt::WindowState state) {
if (state == Qt::WindowActive) state = windowHandle()->windowState();
if (state == Qt::WindowMinimized || !positionInited()) return;