Removed blue window title, new small title used only in Windows.

This commit is contained in:
John Preston
2016-11-04 11:23:50 +03:00
parent 1ecd6866c7
commit 0cbb0014db
72 changed files with 726 additions and 1583 deletions
+56 -6
View File
@@ -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;
+48 -29
View File
@@ -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;
@@ -0,0 +1,53 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
namespace Window {
enum class HitTestResult {
None = 0,
Client,
SysButton,
Icon,
Caption,
Top,
TopRight,
Right,
BottomRight,
Bottom,
BottomLeft,
Left,
TopLeft,
};
class TitleWidget : public TWidget {
public:
using TWidget::TWidget;
virtual HitTestResult hitTest(const QPoint &p) const {
return HitTestResult::None;
}
virtual QRect iconRect() const {
return QRect();
}
};
} // namespace Window