new wide layout, build script and some bugs fixed

This commit is contained in:
John Preston 2016-02-09 19:05:08 +03:00
parent 001f2e1fe7
commit 7b855a661a
10 changed files with 87 additions and 65 deletions

View File

@ -124,10 +124,10 @@ for /f ^"usebackq^ eol^=^
:symbolslinedone
FOR /F "tokens=1,2,3,4* delims= " %%i in ("%SymbolsHashLine%") do set "SymbolsHash=%%l"
echo Copying %BinaryName%.sym to %DropboxSymbolsPath%\%BinaryName%\%SymbolsHash%
if not exist %DropboxSymbolsPath%\%BinaryName% mkdir %DropboxSymbolsPath%\%BinaryName%
if not exist %DropboxSymbolsPath%\%BinaryName%\%SymbolsHash% mkdir %DropboxSymbolsPath%\%BinaryName%\%SymbolsHash%
xcopy %ReleasePath%\%BinaryName%.sym %DropboxSymbolsPath%\%BinaryName%\%SymbolsHash%\
echo Copying %BinaryName%.sym to %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash%
if not exist %DropboxSymbolsPath%\%BinaryName%.pdb mkdir %DropboxSymbolsPath%\%BinaryName%.pdb
if not exist %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash% mkdir %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash%
xcopy %ReleasePath%\%BinaryName%.sym %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash%\
echo Done!
if not exist %ReleasePath%\deploy mkdir %ReleasePath%\deploy

View File

@ -53,7 +53,6 @@ color8: #ce671b; // orange
wndMinWidth: 380px;
adaptiveNormalWidth: 640px;
adaptiveWideWidth: 1120px;
wndMinHeight: 480px;
wndDefWidth: 800px;

View File

@ -425,7 +425,6 @@ void ClipReader::stop() {
}
void ClipReader::error() {
_private = 0;
_state = ClipError;
}

View File

@ -2924,11 +2924,7 @@ void HistoryItem::setId(MsgId newId) {
}
bool HistoryItem::displayFromPhoto() const {
return Adaptive::Wide() || (!out() && !history()->peer->isUser() && !fromChannel());
}
bool HistoryItem::shiftFromPhoto() const {
return Adaptive::Wide() && !out() && !history()->peer->isUser() && !fromChannel();
return (Adaptive::Wide() || (!out() && !history()->peer->isUser())) && !fromChannel();
}
void HistoryItem::clipCallback(ClipReaderNotification notification) {
@ -6217,31 +6213,25 @@ void HistoryMessage::initDimensions() {
}
void HistoryMessage::countPositionAndSize(int32 &left, int32 &width) const {
int32 maxwidth = qMin(int(st::msgMaxWidth), _maxw), hwidth = _history->width, hmaxwidth = st::historyMaxWidth + (Adaptive::Wide() ? (2 * st::msgPhotoSkip) : 0);
int32 maxwidth = qMin(int(st::msgMaxWidth), _maxw), hwidth = _history->width, hmaxwidth = st::historyMaxWidth;
if (_media && _media->currentWidth() < maxwidth) {
maxwidth = qMax(_media->currentWidth(), qMin(maxwidth, plainMaxWidth()));
}
left = 0;
if (hwidth > hmaxwidth) {
left = (hwidth - hmaxwidth) / 2;
if (Adaptive::Wide()) {
hwidth = hmaxwidth;
}
left += (!fromChannel() && out()) ? st::msgMargin.right() : st::msgMargin.left();
left += (!fromChannel() && out() && !Adaptive::Wide()) ? st::msgMargin.right() : st::msgMargin.left();
if (displayFromPhoto()) {
if (!fromChannel() && out()) {
left -= st::msgPhotoSkip;
} else {
left += st::msgPhotoSkip;
if (shiftFromPhoto()) {
left += st::msgPhotoSkip;
}
}
left += st::msgPhotoSkip;
} else if (!Adaptive::Wide() && !out() && !fromChannel() && st::msgPhotoSkip - (hmaxwidth - hwidth) > 0) {
left += st::msgPhotoSkip - (hmaxwidth - hwidth);
}
width = hwidth - st::msgMargin.left() - st::msgMargin.right();
if (width > maxwidth) {
if (!fromChannel() && out()) {
if (!fromChannel() && out() && !Adaptive::Wide()) {
left += width - maxwidth;
}
width = maxwidth;
@ -6495,7 +6485,7 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
}
if (displayFromPhoto()) {
int32 photoleft = left + ((!fromChannel() && out()) ? (width + (st::msgPhotoSkip - st::msgPhotoSize)) : (-st::msgPhotoSkip));
int32 photoleft = left + ((!fromChannel() && out() && !Adaptive::Wide()) ? (width + (st::msgPhotoSkip - st::msgPhotoSize)) : (-st::msgPhotoSkip));
p.drawPixmap(photoleft, _height - st::msgMargin.bottom() - st::msgPhotoSize, _from->photo->pixRounded(st::msgPhotoSize));
}
if (width < 1) return;
@ -6663,7 +6653,7 @@ void HistoryMessage::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32
int32 left = 0, width = 0;
countPositionAndSize(left, width);
if (displayFromPhoto()) {
int32 photoleft = left + ((!fromChannel() && out()) ? (width + (st::msgPhotoSkip - st::msgPhotoSize)) : (-st::msgPhotoSkip));
int32 photoleft = left + ((!fromChannel() && out() && !Adaptive::Wide()) ? (width + (st::msgPhotoSkip - st::msgPhotoSize)) : (-st::msgPhotoSkip));
if (x >= photoleft && x < photoleft + st::msgPhotoSize && y >= _height - st::msgMargin.bottom() - st::msgPhotoSize && y < _height - st::msgMargin.bottom()) {
lnk = _from->lnk;
return;
@ -6928,7 +6918,7 @@ void HistoryForwarded::getState(TextLinkPtr &lnk, HistoryCursorState &state, int
int32 left = 0, width = 0;
countPositionAndSize(left, width);
if (displayFromPhoto()) {
int32 photoleft = left + ((!fromChannel() && out()) ? (width + (st::msgPhotoSkip - st::msgPhotoSize)) : (-st::msgPhotoSkip));
int32 photoleft = left + ((!fromChannel() && out() && !Adaptive::Wide()) ? (width + (st::msgPhotoSkip - st::msgPhotoSize)) : (-st::msgPhotoSkip));
if (x >= photoleft && x < photoleft + st::msgPhotoSize) {
return HistoryMessage::getState(lnk, state, x, y);
}
@ -7488,6 +7478,11 @@ void HistoryServiceMsg::initDimensions() {
if (_media) _media->initDimensions(this);
}
void HistoryServiceMsg::countPositionAndSize(int32 &left, int32 &width) const {
left = st::msgServiceMargin.left();
width = qMin(_history->width, int(st::msgMaxWidth + 2 * st::msgPhotoSkip)) - st::msgServiceMargin.left() - st::msgServiceMargin.left();
}
QString HistoryServiceMsg::selectedText(uint32 selection) const {
uint16 selectedFrom = (selection == FullSelection) ? 0 : (selection >> 16) & 0xFFFF;
uint16 selectedTo = (selection == FullSelection) ? 0xFFFF : (selection & 0xFFFF);
@ -7528,7 +7523,8 @@ void HistoryServiceMsg::draw(Painter &p, const QRect &r, uint32 selection, uint6
textstyleSet(&st::serviceTextStyle);
int32 left = st::msgServiceMargin.left(), width = _history->width - st::msgServiceMargin.left() - st::msgServiceMargin.left(), height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
int32 left = 0, width = 0, height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
countPositionAndSize(left, width);
if (width < 1) return;
if (_media) {
@ -7581,7 +7577,8 @@ int32 HistoryServiceMsg::resize(int32 width) {
}
bool HistoryServiceMsg::hasPoint(int32 x, int32 y) const {
int32 left = st::msgServiceMargin.left(), width = _history->width - st::msgServiceMargin.left() - st::msgServiceMargin.left(), height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
int32 left = 0, width = 0, height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
countPositionAndSize(left, width);
if (width < 1) return false;
if (_media) {
@ -7594,7 +7591,8 @@ void HistoryServiceMsg::getState(TextLinkPtr &lnk, HistoryCursorState &state, in
lnk = TextLinkPtr();
state = HistoryDefaultCursorState;
int32 left = st::msgServiceMargin.left(), width = _history->width - st::msgServiceMargin.left() - st::msgServiceMargin.left(), height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
int32 left = 0, width = 0, height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
countPositionAndSize(left, width);
if (width < 1) return;
if (_media) {
@ -7617,7 +7615,8 @@ void HistoryServiceMsg::getSymbol(uint16 &symbol, bool &after, bool &upon, int32
after = false;
upon = false;
int32 left = st::msgServiceMargin.left(), width = _history->width - st::msgServiceMargin.left() - st::msgServiceMargin.left(), height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
int32 left = 0, width = 0, height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
countPositionAndSize(left, width);
if (width < 1) return;
if (_media) {
@ -7682,7 +7681,8 @@ void HistoryGroup::getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x
lnk = TextLinkPtr();
state = HistoryDefaultCursorState;
int32 left = st::msgServiceMargin.left(), width = _history->width - st::msgServiceMargin.left() - st::msgServiceMargin.left(), height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
int32 left = 0, width = 0, height = _height - st::msgServiceMargin.top() - st::msgServiceMargin.bottom(); // two small margins
countPositionAndSize(left, width);
if (width < 1) return;
QRect trect(QRect(left, st::msgServiceMargin.top(), width, height).marginsAdded(-st::msgServicePadding));

View File

@ -1021,7 +1021,6 @@ public:
return (!out() || fromChannel()) && !history()->peer->isUser();
}
bool displayFromPhoto() const;
bool shiftFromPhoto() const;
void clipCallback(ClipReaderNotification notification);
@ -2249,6 +2248,8 @@ public:
void initDimensions();
void countPositionAndSize(int32 &left, int32 &width) const;
void draw(Painter &p, const QRect &r, uint32 selection, uint64 ms) const;
int32 resize(int32 width);
bool hasPoint(int32 x, int32 y) const;

View File

@ -606,7 +606,7 @@ void _moveOldDataFiles(const QString &wasDir) {
namespace SignalHandlers {
QByteArray CrashDumpPath;
QString CrashDumpPath;
FILE *CrashDumpFile = 0;
int CrashDumpFileNo = 0;
char LaunchedDateTimeStr[32] = { 0 };
@ -930,8 +930,12 @@ namespace SignalHandlers {
}
Status start() {
CrashDumpPath = QFile::encodeName(cWorkingDir() + qsl("tdata/working"));
if (FILE *f = fopen(CrashDumpPath.constData(), "rb")) {
CrashDumpPath = cWorkingDir() + qsl("tdata/working");
#ifdef Q_OS_WIN
if (FILE *f = _wfopen(CrashDumpPath.toStdWString().c_str(), L"rb")) {
#else
if (FILE *f = fopen(QFile::encodeName(CrashDumpPath).constData(), "rb")) {
#endif
QByteArray lastdump;
char buffer[64 * 1024] = { 0 };
int32 read = 0;
@ -942,7 +946,7 @@ namespace SignalHandlers {
Sandbox::SetLastCrashDump(lastdump);
LOG(("Opened '%1' for reading, the previous Telegram Desktop launch was not finished properly :( Crash log size: %2").arg(QString::fromUtf8(CrashDumpPath)).arg(lastdump.size()));
LOG(("Opened '%1' for reading, the previous Telegram Desktop launch was not finished properly :( Crash log size: %2").arg(CrashDumpPath).arg(lastdump.size()));
return LastCrashed;
}
@ -954,7 +958,11 @@ namespace SignalHandlers {
return Started;
}
CrashDumpFile = fopen(CrashDumpPath.constData(), "wb");
#ifdef Q_OS_WIN
CrashDumpFile = _wfopen(CrashDumpPath.toStdWString().c_str(), L"wb");
#else
CrashDumpFile = fopen(QFile::encodeName(CrashDumpPath).constData(), "wb");
#endif
if (CrashDumpFile) {
CrashDumpFileNo = fileno(CrashDumpFile);
if (SetSignalHandlers) {
@ -981,7 +989,7 @@ namespace SignalHandlers {
return Started;
}
LOG(("FATAL: Could not open '%1' for writing!").arg(QString::fromUtf8(CrashDumpPath)));
LOG(("FATAL: Could not open '%1' for writing!").arg(CrashDumpPath));
return CantOpen;
}
@ -990,7 +998,11 @@ namespace SignalHandlers {
FinishBreakpad();
if (CrashDumpFile) {
fclose(CrashDumpFile);
unlink(CrashDumpPath.constData());
#ifdef Q_OS_WIN
_wunlink(CrashDumpPath.toStdWString().c_str());
#else
unlink(CrashDumpPath.toUtf8().constData());
#endif
}
}

View File

@ -2810,7 +2810,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
history.setGeometry(0, _playerHeight + tbh, _dialogsWidth, height() - _playerHeight - tbh);
if (_hider) _hider->setGeometry(0, 0, _dialogsWidth, height());
} else {
_dialogsWidth = snap<int>((width() * 5) / 14, st::dlgMinWidth, st::dlgMaxWidth);
_dialogsWidth = chatsListWidth(width());
dialogs.resize(_dialogsWidth, height());
dialogs.moveToLeft(0, 0);
_player.resize(width() - _dialogsWidth, _player.height());

View File

@ -179,6 +179,10 @@ public:
}
};
inline int chatsListWidth(int windowWidth) {
return snap<int>((windowWidth * 5) / 14, st::dlgMinWidth, st::dlgMaxWidth);
}
class StickerPreviewWidget;
class MainWidget : public TWidget, public RPCSender {

View File

@ -1229,10 +1229,12 @@ void Window::resizeEvent(QResizeEvent *e) {
if (!title) return;
Adaptive::Layout layout = Adaptive::OneColumnLayout;
if (width() >= st::adaptiveWideWidth) {
layout = Adaptive::WideLayout;
} else if (width() >= st::adaptiveNormalWidth) {
layout = Adaptive::NormalLayout;
if (width() >= st::adaptiveNormalWidth) {
if (width() - chatsListWidth(width()) >= st::historyMaxWidth) {
layout = Adaptive::WideLayout;
} else {
layout = Adaptive::NormalLayout;
}
}
if (layout != Global::AdaptiveLayout()) {
Global::SetAdaptiveLayout(layout);
@ -1501,7 +1503,6 @@ void Window::notifyShowNext(NotifyWindow *remove) {
uint64 next = 0;
HistoryItem *notifyItem = 0;
History *notifyHistory = 0;
NotifyWaiters::iterator notifyWaiter = notifyWaiters.end();
for (NotifyWaiters::iterator i = notifyWaiters.begin(); i != notifyWaiters.end();) {
History *history = i.key();
if (history->currentNotification() && history->currentNotification()->id != i.value().msg) {
@ -1509,7 +1510,6 @@ void Window::notifyShowNext(NotifyWindow *remove) {
if (j == notifyWhenMaps.end()) {
history->clearNotifications();
i = notifyWaiters.erase(i);
notifyWaiter = notifyHistory ? notifyWaiters.find(notifyHistory) : notifyWaiters.end();
continue;
}
do {
@ -1525,7 +1525,6 @@ void Window::notifyShowNext(NotifyWindow *remove) {
if (!history->currentNotification()) {
notifyWhenMaps.remove(history);
i = notifyWaiters.erase(i);
notifyWaiter = notifyHistory ? notifyWaiters.find(notifyHistory) : notifyWaiters.end();
continue;
}
uint64 when = i.value().when;
@ -1533,7 +1532,6 @@ void Window::notifyShowNext(NotifyWindow *remove) {
next = when;
notifyItem = history->currentNotification();
notifyHistory = history;
notifyWaiter = i;
}
++i;
}
@ -1567,8 +1565,7 @@ void Window::notifyShowNext(NotifyWindow *remove) {
NotifyWhenMap::const_iterator k = j.value().constFind(history->currentNotification()->id);
if (k != j.value().cend()) {
nextNotify = history->currentNotification();
notifyWaiter.value().msg = k.key();
notifyWaiter.value().when = k.value();
notifyWaiters.insert(notifyHistory, NotifyWaiter(k.key(), k.value(), 0));
break;
}
history->skipNotification();
@ -1599,7 +1596,7 @@ void Window::notifyShowNext(NotifyWindow *remove) {
}
if (!history->hasNotification()) {
if (notifyWaiter != notifyWaiters.cend()) notifyWaiters.erase(notifyWaiter);
notifyWaiters.remove(history);
notifyWhenMaps.remove(history);
continue;
}
@ -2195,7 +2192,7 @@ void LastCrashedWindow::onSendReport() {
App::setProxySettings(_sendManager);
QString apiid = getReportField(qstr("apiid"), qstr("ApiId:")), version = getReportField(qstr("version"), qstr("Version:"));
_checkReply = _sendManager.get(QNetworkRequest(qsl("https://tdesktop.com/crash.php?act=query_report&apiid=%1&version=%2").arg(apiid).arg(version)));
_checkReply = _sendManager.get(QNetworkRequest(qsl("https://tdesktop.com/crash.php?act=query_report&apiid=%1&version=%2&dmp=%3").arg(apiid).arg(version).arg(minidumpFileName().isEmpty() ? 0 : 1)));
connect(_checkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onSendingError(QNetworkReply::NetworkError)));
connect(_checkReply, SIGNAL(finished()), this, SLOT(onCheckingFinished()));
@ -2291,6 +2288,15 @@ namespace {
}
QString LastCrashedWindow::minidumpFileName() {
QFileInfo dmpFile(_minidumpFull);
if (dmpFile.exists() && dmpFile.size() > 0 && dmpFile.size() < 20 * 1024 * 1024 &&
QRegularExpression(qsl("^[a-zA-Z0-9\\-]{1,64}\\.dmp$")).match(dmpFile.fileName()).hasMatch()) {
return dmpFile.fileName();
}
return QString();
}
void LastCrashedWindow::onCheckingFinished() {
if (!_checkReply || _sendReply) return;
@ -2300,9 +2306,9 @@ void LastCrashedWindow::onCheckingFinished() {
LOG(("Crash report check for sending done, result: %1").arg(QString::fromUtf8(result)));
if (result == "Many") {
_pleaseSendReport.setText(qsl("Too many crash reports at this moment :("));
_sendingState = SendingTooMany;
if (result == "Old") {
_pleaseSendReport.setText(qsl("This report is about some old version of Telegram Desktop."));
_sendingState = SendingTooOld;
updateControls();
return;
} else if (result == "Unofficial") {
@ -2311,10 +2317,11 @@ void LastCrashedWindow::onCheckingFinished() {
updateControls();
return;
} else if (result != "Report") {
_pleaseSendReport.setText(qsl("This report is about some old version of Telegram Desktop."));
_pleaseSendReport.setText(qsl("Response: %1").arg(QString::fromLatin1(result)));
_sendingState = SendingTooOld;
_pleaseSendReport.setText(qsl("Thank you for your report!"));
_sendingState = SendingDone;
updateControls();
SignalHandlers::restart();
return;
}
@ -2329,15 +2336,14 @@ void LastCrashedWindow::onCheckingFinished() {
reportPart.setBody(Sandbox::LastCrashDump());
multipart->append(reportPart);
QFileInfo dmpFile(_minidumpFull);
if (dmpFile.exists() && dmpFile.size() > 0 && dmpFile.size() < 20 * 1024 * 1024 &&
QRegularExpression(qsl("^[a-zA-Z0-9\\-]{1,64}\\.dmp$")).match(dmpFile.fileName()).hasMatch()) {
QString dmpName = minidumpFileName();
if (!dmpName.isEmpty()) {
QFile file(_minidumpFull);
if (file.open(QIODevice::ReadOnly)) {
QByteArray minidump = file.readAll();
file.close();
QString zipName = dmpFile.fileName().replace(qstr(".dmp"), qstr(".zip"));
QString zipName = QString(dmpName).replace(qstr(".dmp"), qstr(".zip"));
zByteArray minidumpZip;
bool failed = false;
@ -2353,8 +2359,8 @@ void LastCrashedWindow::onCheckingFinished() {
if (zipFile zf = zipOpen2(0, APPEND_STATUS_CREATE, 0, &zfuncs)) {
zip_fileinfo zfi = { { 0, 0, 0, 0, 0, 0 }, 0, 0, 0 };
std::wstring fileName = dmpFile.fileName().toStdWString();
if (zipOpenNewFileInZip(zf, std::string(fileName.begin(), fileName.end()).c_str(), &zfi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION) != ZIP_OK) {
QByteArray dmpNameUtf = dmpName.toUtf8();
if (zipOpenNewFileInZip(zf, dmpNameUtf.constData(), &zfi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION) != ZIP_OK) {
failed = true;
} else if (zipWriteInFileInZip(zf, minidump.constData(), minidump.size()) != 0) {
failed = true;

View File

@ -453,6 +453,7 @@ protected:
private:
QString minidumpFileName();
void updateControls();
QString _host, _username, _password;