mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
fixed os x mouse input, window icon, qt os x build-from-source
This commit is contained in:
parent
84226635b2
commit
85285d9862
@ -1755,7 +1755,7 @@ void History::clear(bool leaveItems) {
|
||||
_overview[i].clear();
|
||||
_overviewIds[i].clear();
|
||||
}
|
||||
if (App::wnd()) App::wnd()->mediaOverviewUpdated(peer);
|
||||
if (App::wnd() && !App::quiting()) App::wnd()->mediaOverviewUpdated(peer);
|
||||
for (Parent::const_iterator i = cbegin(), e = cend(); i != e; ++i) {
|
||||
if (leaveItems) {
|
||||
(*i)->clear(true);
|
||||
|
@ -95,7 +95,10 @@ namespace MTP {
|
||||
void initdc(int32 dc);
|
||||
template <typename TRequest>
|
||||
inline mtpRequestId send(const TRequest &request, RPCResponseHandler callbacks = RPCResponseHandler(), int32 dc = 0, uint64 msCanWait = 0, mtpRequestId after = 0) {
|
||||
return _mtp_internal::getSession(dc)->send(request, callbacks, msCanWait, _mtp_internal::getLayer(), !dc, after);
|
||||
MTProtoSessionPtr session = _mtp_internal::getSession(dc);
|
||||
if (!session) return 0;
|
||||
|
||||
return session->send(request, callbacks, msCanWait, _mtp_internal::getLayer(), !dc, after);
|
||||
}
|
||||
template <typename TRequest>
|
||||
inline mtpRequestId send(const TRequest &request, RPCDoneHandlerPtr onDone, RPCFailHandlerPtr onFail = RPCFailHandlerPtr(), int32 dc = 0, uint64 msCanWait = 0, mtpRequestId after = 0) {
|
||||
|
@ -46,7 +46,7 @@ namespace {
|
||||
mtpFileLoader::mtpFileLoader(int32 dc, const int64 &volume, int32 local, const int64 &secret, int32 size) : prev(0), next(0),
|
||||
priority(0), inQueue(false), complete(false), skippedBytes(0), nextRequestOffset(0), lastComplete(false),
|
||||
dc(dc), locationType(0), volume(volume), local(local), secret(secret),
|
||||
id(0), access(0), size(size), type(MTP_storage_fileUnknown()) {
|
||||
id(0), access(0), fileIsOpen(false), size(size), type(MTP_storage_fileUnknown()) {
|
||||
LoaderQueues::iterator i = queues.find(dc);
|
||||
if (i == queues.cend()) {
|
||||
i = queues.insert(dc, mtpFileLoaderQueue());
|
||||
@ -57,7 +57,7 @@ id(0), access(0), size(size), type(MTP_storage_fileUnknown()) {
|
||||
mtpFileLoader::mtpFileLoader(int32 dc, const uint64 &id, const uint64 &access, mtpTypeId locType, const QString &to, int32 size) : prev(0), next(0),
|
||||
priority(0), inQueue(false), complete(false), skippedBytes(0), nextRequestOffset(0), lastComplete(false),
|
||||
dc(dc), locationType(locType),
|
||||
id(id), access(access), file(to), duplicateInData(false), size(size), type(MTP_storage_fileUnknown()) {
|
||||
id(id), access(access), file(to), fname(to), fileIsOpen(false), duplicateInData(false), size(size), type(MTP_storage_fileUnknown()) {
|
||||
LoaderQueues::iterator i = queues.find(MTP::dld[0] + dc);
|
||||
if (i == queues.cend()) {
|
||||
i = queues.insert(MTP::dld[0] + dc, mtpFileLoaderQueue());
|
||||
@ -68,7 +68,7 @@ id(id), access(access), file(to), duplicateInData(false), size(size), type(MTP_s
|
||||
mtpFileLoader::mtpFileLoader(int32 dc, const uint64 &id, const uint64 &access, mtpTypeId locType, const QString &to, int32 size, bool todata) : prev(0), next(0),
|
||||
priority(0), inQueue(false), complete(false), skippedBytes(0), nextRequestOffset(0), lastComplete(false),
|
||||
dc(dc), locationType(locType),
|
||||
id(id), access(access), file(to), duplicateInData(todata), size(size), type(MTP_storage_fileUnknown()) {
|
||||
id(id), access(access), file(to), fname(to), fileIsOpen(false), duplicateInData(todata), size(size), type(MTP_storage_fileUnknown()) {
|
||||
LoaderQueues::iterator i = queues.find(MTP::dld[0] + dc);
|
||||
if (i == queues.cend()) {
|
||||
i = queues.insert(MTP::dld[0] + dc, mtpFileLoaderQueue());
|
||||
@ -77,7 +77,7 @@ id(id), access(access), file(to), duplicateInData(todata), size(size), type(MTP_
|
||||
}
|
||||
|
||||
QString mtpFileLoader::fileName() const {
|
||||
return file.fileName();
|
||||
return fname;
|
||||
}
|
||||
|
||||
bool mtpFileLoader::done() const {
|
||||
@ -99,16 +99,16 @@ float64 mtpFileLoader::currentProgress() const {
|
||||
}
|
||||
|
||||
int32 mtpFileLoader::currentOffset(bool includeSkipped) const {
|
||||
return (file.isOpen() ? file.size() : data.size()) - (includeSkipped ? 0 : skippedBytes);
|
||||
return (fileIsOpen ? file.size() : data.size()) - (includeSkipped ? 0 : skippedBytes);
|
||||
}
|
||||
|
||||
int32 mtpFileLoader::fullSize() const {
|
||||
return size;
|
||||
}
|
||||
|
||||
void mtpFileLoader::setFileName(const QString &fname) {
|
||||
if (duplicateInData && file.fileName().isEmpty()) {
|
||||
file.setFileName(fname);
|
||||
void mtpFileLoader::setFileName(const QString &fileName) {
|
||||
if (duplicateInData && fname.isEmpty()) {
|
||||
file.setFileName(fname = fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,13 +132,14 @@ void mtpFileLoader::finishFail() {
|
||||
cancelRequests();
|
||||
type = MTP_storage_fileUnknown();
|
||||
complete = true;
|
||||
if (file.isOpen()) {
|
||||
if (fileIsOpen) {
|
||||
file.close();
|
||||
fileIsOpen = false;
|
||||
file.remove();
|
||||
}
|
||||
data = QByteArray();
|
||||
emit failed(this, started);
|
||||
file.setFileName(QString());
|
||||
file.setFileName(fname = QString());
|
||||
loadNext();
|
||||
}
|
||||
|
||||
@ -198,7 +199,7 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||
const MTPDupload_file &d(result.c_upload_file());
|
||||
const string &bytes(d.vbytes.c_string().v);
|
||||
if (bytes.size()) {
|
||||
if (file.isOpen()) {
|
||||
if (fileIsOpen) {
|
||||
int64 fsize = file.size();
|
||||
if (offset < fsize) {
|
||||
skippedBytes -= bytes.size();
|
||||
@ -230,8 +231,9 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||
lastComplete = true;
|
||||
}
|
||||
if (requests.isEmpty() && (lastComplete || (size && nextRequestOffset >= size))) {
|
||||
if (duplicateInData && !file.fileName().isEmpty()) {
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
if (!fname.isEmpty() && duplicateInData) {
|
||||
if (!fileIsOpen) fileIsOpen = file.open(QIODevice::WriteOnly);
|
||||
if (!fileIsOpen) {
|
||||
return finishFail();
|
||||
}
|
||||
if (file.write(data) != qint64(data.size())) {
|
||||
@ -240,8 +242,9 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||
}
|
||||
type = d.vtype;
|
||||
complete = true;
|
||||
if (file.isOpen()) {
|
||||
if (fileIsOpen) {
|
||||
file.close();
|
||||
fileIsOpen = false;
|
||||
psPostprocessFile(QFileInfo(file).absoluteFilePath());
|
||||
}
|
||||
removeFromQueue();
|
||||
@ -286,8 +289,9 @@ void mtpFileLoader::pause() {
|
||||
void mtpFileLoader::start(bool loadFirst, bool prior) {
|
||||
if (complete) return;
|
||||
|
||||
if (!file.fileName().isEmpty() && !duplicateInData) {
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
if (!fname.isEmpty() && !duplicateInData && !fileIsOpen) {
|
||||
fileIsOpen = file.open(QIODevice::WriteOnly);
|
||||
if (!fileIsOpen) {
|
||||
finishFail();
|
||||
return;
|
||||
}
|
||||
@ -385,8 +389,9 @@ void mtpFileLoader::cancel() {
|
||||
cancelRequests();
|
||||
type = MTP_storage_fileUnknown();
|
||||
complete = true;
|
||||
if (file.isOpen()) {
|
||||
if (fileIsOpen) {
|
||||
file.close();
|
||||
fileIsOpen = false;
|
||||
file.remove();
|
||||
}
|
||||
data = QByteArray();
|
||||
|
@ -89,6 +89,8 @@ private:
|
||||
uint64 id; // for other locations
|
||||
uint64 access;
|
||||
QFile file;
|
||||
QString fname;
|
||||
bool fileIsOpen;
|
||||
bool duplicateInData;
|
||||
|
||||
QByteArray data;
|
||||
|
@ -553,10 +553,14 @@ QPixmap OverviewInner::genPix(PhotoData *photo, int32 size) {
|
||||
if (!photo->full->loaded() && !photo->medium->loaded()) {
|
||||
img = imageBlur(img);
|
||||
}
|
||||
if (img.width() > img.height()) {
|
||||
img = img.scaled(img.width() * size / img.height(), size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
if (img.width() == img.height()) {
|
||||
if (img.width() != size) {
|
||||
img = img.scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
}
|
||||
} else if (img.width() > img.height()) {
|
||||
img = img.copy((img.width() - img.height()) / 2, 0, img.height(), img.height()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
} else {
|
||||
img = img.scaled(size, img.height() * size / img.width(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
}
|
||||
img.setDevicePixelRatio(cRetinaFactor());
|
||||
photo->forget();
|
||||
@ -625,26 +629,13 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
|
||||
it->vsize = _vsize;
|
||||
it->pix = genPix(photo, _vsize);
|
||||
}
|
||||
QPixmap &pix(it->pix);
|
||||
QPoint pos(int32(i * w + st::overviewPhotoSkip), _addToY + row * (_vsize + st::overviewPhotoSkip) + st::overviewPhotoSkip);
|
||||
int32 w = pix.width(), h = pix.height(), size;
|
||||
if (w == h) {
|
||||
p.drawPixmap(pos, pix);
|
||||
size = w;
|
||||
} else if (w > h) {
|
||||
p.drawPixmap(pos, pix, QRect((w - h) / 2, 0, h, h));
|
||||
size = h;
|
||||
} else {
|
||||
p.drawPixmap(pos, pix, QRect(0, (h - w) / 2, w, w));
|
||||
size = w;
|
||||
}
|
||||
size /= cIntRetinaFactor();
|
||||
|
||||
p.drawPixmap(pos, it->pix);
|
||||
if (!quality) {
|
||||
uint64 dt = itemAnimations().animate(item, getms());
|
||||
int32 cnt = int32(st::photoLoaderCnt), period = int32(st::photoLoaderPeriod), t = dt % period, delta = int32(st::photoLoaderDelta);
|
||||
|
||||
int32 x = pos.x() + (size - st::overviewLoader.width()) / 2, y = pos.y() + (size - st::overviewLoader.height()) / 2;
|
||||
int32 x = pos.x() + (_vsize - st::overviewLoader.width()) / 2, y = pos.y() + (_vsize - st::overviewLoader.height()) / 2;
|
||||
p.fillRect(x, y, st::overviewLoader.width(), st::overviewLoader.height(), st::photoLoaderBg->b);
|
||||
x += (st::overviewLoader.width() - cnt * st::overviewLoaderPoint.width() - (cnt - 1) * st::overviewLoaderSkip) / 2;
|
||||
y += (st::overviewLoader.height() - st::overviewLoaderPoint.height()) / 2;
|
||||
@ -671,7 +662,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
}
|
||||
if (sel == FullItemSel) {
|
||||
p.fillRect(QRect(pos.x(), pos.y(), size, size), st::msgInSelectOverlay->b);
|
||||
p.fillRect(QRect(pos.x(), pos.y(), _vsize, _vsize), st::msgInSelectOverlay->b);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace {
|
||||
};
|
||||
|
||||
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
|
||||
posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")) {
|
||||
posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")), wndIcon(QPixmap::fromImage(icon256)) {
|
||||
connect(&psIdleTimer, SIGNAL(timeout()), this, SLOT(psIdleTimeout()));
|
||||
psIdleTimer.setSingleShot(false);
|
||||
}
|
||||
@ -115,6 +115,8 @@ void PsMainWindow::psUpdateWorkmode() {
|
||||
}
|
||||
|
||||
void PsMainWindow::psUpdateCounter() {
|
||||
setWindowIcon(myIcon);
|
||||
|
||||
int32 counter = App::histories().unreadFull;
|
||||
|
||||
setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
|
||||
|
@ -88,6 +88,7 @@ protected:
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QMenu *trayIconMenu;
|
||||
QImage icon256;
|
||||
QIcon wndIcon;
|
||||
|
||||
virtual void setupTrayIcon() = 0;
|
||||
virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;
|
||||
|
@ -64,7 +64,7 @@ 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")) {
|
||||
posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")), wndIcon(QPixmap(qsl(":/gui/art/iconbig128.png"))) {
|
||||
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));
|
||||
@ -141,6 +141,7 @@ void PsMainWindow::psUpdateWorkmode() {
|
||||
}
|
||||
trayIcon = 0;
|
||||
}
|
||||
setWindowIcon(wndIcon);
|
||||
}
|
||||
|
||||
void _placeCounter(QImage &img, int size, int count, style::color bg, style::color color) {
|
||||
@ -182,6 +183,7 @@ void PsMainWindow::psUpdateCounter() {
|
||||
int32 counter = App::histories().unreadFull;
|
||||
|
||||
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());
|
||||
|
@ -99,6 +99,7 @@ protected:
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QMenu *trayIconMenu;
|
||||
QImage icon256;
|
||||
QIcon wndIcon;
|
||||
|
||||
QImage trayImg, trayImgSel;
|
||||
|
||||
|
@ -860,7 +860,7 @@ namespace {
|
||||
|
||||
};
|
||||
|
||||
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent), ps_hWnd(0), ps_menu(0), icon256(qsl(":/gui/art/iconround256.png")),
|
||||
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent), ps_hWnd(0), ps_menu(0), icon256(qsl(":/gui/art/iconround256.png")), wndIcon(QPixmap::fromImage(icon256)),
|
||||
ps_iconBig(0), ps_iconSmall(0), ps_iconOverlay(0), trayIcon(0), trayIconMenu(0), posInited(false), ps_tbHider_hWnd(createTaskbarHider()), psIdle(false) {
|
||||
tbCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
|
||||
connect(&psIdleTimer, SIGNAL(timeout()), this, SLOT(psIdleTimeout()));
|
||||
|
@ -87,6 +87,7 @@ protected:
|
||||
QSystemTrayIcon *trayIcon;
|
||||
ContextMenu *trayIconMenu;
|
||||
QImage icon256;
|
||||
QIcon wndIcon;
|
||||
|
||||
virtual void setupTrayIcon() = 0;
|
||||
virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;
|
||||
|
@ -18,6 +18,7 @@
|
||||
<file>art/emoji_200x.png</file>
|
||||
<file>art/blank.gif</file>
|
||||
<file>art/iconround256.png</file>
|
||||
<file>art/iconbig128.png</file>
|
||||
<file>art/fonts/DejaVuSans.ttf</file>
|
||||
<file>art/osxtray.png</file>
|
||||
</qresource>
|
||||
|
@ -337,7 +337,7 @@ NotifyWindow::~NotifyWindow() {
|
||||
|
||||
Window::Window(QWidget *parent) : PsMainWindow(parent),
|
||||
intro(0), main(0), settings(0), layerBG(0), _topWidget(0),
|
||||
_connecting(0), _tempDeleter(0), _tempDeleterThread(0), myIcon(QPixmap::fromImage(icon256)), dragging(false), _inactivePress(false), _mediaView(0) {
|
||||
_connecting(0), _tempDeleter(0), _tempDeleterThread(0), dragging(false), _inactivePress(false), _mediaView(0) {
|
||||
|
||||
icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
@ -380,7 +380,7 @@ void Window::onInactiveTimer() {
|
||||
|
||||
void Window::init() {
|
||||
psInitFrameless();
|
||||
setWindowIcon(myIcon);
|
||||
setWindowIcon(wndIcon);
|
||||
|
||||
App::app()->installEventFilter(this);
|
||||
connect(windowHandle(), SIGNAL(activeChanged()), this, SLOT(checkHistoryActivation()));
|
||||
@ -875,7 +875,6 @@ void Window::noTopWidget(QWidget *w) {
|
||||
void Window::showFromTray(QSystemTrayIcon::ActivationReason reason) {
|
||||
if (reason != QSystemTrayIcon::Context) {
|
||||
activate();
|
||||
setWindowIcon(myIcon);
|
||||
psUpdateCounter();
|
||||
if (App::main()) App::main()->setOnline(windowState());
|
||||
QTimer::singleShot(1, this, SLOT(updateTrayMenu()));
|
||||
|
@ -281,8 +281,6 @@ private:
|
||||
|
||||
void clearWidgets();
|
||||
|
||||
QIcon myIcon;
|
||||
|
||||
bool dragging;
|
||||
QPoint dragStart;
|
||||
|
||||
|
@ -167,7 +167,7 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
if (!self.window.delegate)
|
||||
return; // Already detached, pending NSAppKitDefined event
|
||||
|
||||
if (pw && pw->frameStrutEventsEnabled() && pw->m_synchedWindowState != Qt::WindowMinimized && isMouseEvent(theEvent)) {
|
||||
if (pw && pw->frameStrutEventsEnabled() && pw->m_synchedWindowState != Qt::WindowMinimized && pw->m_isExposed && isMouseEvent(theEvent)) {
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
NSRect windowFrame = [self.window legacyConvertRectFromScreen:[self.window frame]];
|
||||
NSRect contentFrame = [[self.window contentView] frame];
|
||||
@ -903,6 +903,14 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
|
||||
[m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
|
||||
}
|
||||
|
||||
qreal _win_devicePixelRatio() {
|
||||
qreal result = 1.0;
|
||||
foreach (QScreen *screen, QGuiApplication::screens()) {
|
||||
result = qMax(result, screen->devicePixelRatio());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void QCocoaWindow::setWindowIcon(const QIcon &icon)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
@ -918,7 +926,8 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
|
||||
if (icon.isNull()) {
|
||||
[iconButton setImage:nil];
|
||||
} else {
|
||||
QPixmap pixmap = icon.pixmap(QSize(22, 22));
|
||||
CGFloat hgt = 16. * _win_devicePixelRatio();
|
||||
QPixmap pixmap = icon.pixmap(QSize(hgt, hgt));
|
||||
NSImage *image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
|
||||
[iconButton setImage:image];
|
||||
[image release];
|
||||
|
Loading…
Reference in New Issue
Block a user