diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt
index f5a7cb395..1083e0e97 100644
--- a/Telegram/Resources/style.txt
+++ b/Telegram/Resources/style.txt
@@ -1439,6 +1439,12 @@ emojiPanDuration: 200;
emojiPanHover: #f0f0f0;
emojiPanRound: 2px;
+medviewNavBarWidth: 200px;
+medviewTopSkip: 50px;
+medviewBottomSkip: 50px;
+medviewLightOpacity: 0.75;
+medviewMinWidth: 600;
+
// Mac specific
macAccessoryHeight: 90;
diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp
index e4c639bca..5359f24d7 100644
--- a/Telegram/SourceFiles/app.cpp
+++ b/Telegram/SourceFiles/app.cpp
@@ -1859,7 +1859,7 @@ namespace App {
setQuiting();
if (wnd()) {
- wnd()->notifyClearFast();
+ wnd()->quit();
}
if (app()) {
app()->quit();
diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp
new file mode 100644
index 000000000..0adeab69a
--- /dev/null
+++ b/Telegram/SourceFiles/mediaview.cpp
@@ -0,0 +1,100 @@
+/*
+This file is part of Telegram Desktop,
+an unofficial desktop 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.
+
+Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
+Copyright (c) 2014 John Preston, https://tdesktop.com
+*/
+#include "stdafx.h"
+#include "lang.h"
+
+#include "mediaview.h"
+#include "window.h"
+
+MediaView::MediaView() : QWidget(App::wnd()),
+_photo(0), _maxWidth(0), _maxHeight(0), _x(0), _y(0), _w(0) {
+ setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint);
+ moveToScreen();
+ setAttribute(Qt::WA_PaintOnScreen, true);
+ setAttribute(Qt::WA_NoSystemBackground, true);
+ setAttribute(Qt::WA_TranslucentBackground, true);
+ hide();
+}
+
+void MediaView::moveToScreen() {
+ QPoint wndCenter(App::wnd()->x() + App::wnd()->width() / 2, App::wnd()->y() + App::wnd()->height() / 2);
+ QRect geom = QDesktopWidget().screenGeometry(wndCenter);
+ if (geom != geometry()) {
+ setGeometry(geom);
+ }
+ _maxWidth = width() - 2 * st::medviewNavBarWidth;
+ _maxHeight = height() - st::medviewTopSkip - st::medviewBottomSkip;
+}
+
+void MediaView::showPhoto(PhotoData *photo, const QRect &opaque) {
+ _photo = photo;
+ _opaqueRect = opaque;
+ _photo->full->load();
+ _w = photo->full->width();
+ int h = photo->full->height();
+ switch (cScale()) {
+ case dbisOneAndQuarter: _w = qRound(float64(_w) * 1.25 - 0.01); h = qRound(float64(h) * 1.25 - 0.01); break;
+ case dbisOneAndHalf: _w = qRound(float64(_w) * 1.5 - 0.01); h = qRound(float64(h) * 1.5 - 0.01); break;
+ case dbisTwo: _w *= 2; h *= 2; break;
+ }
+ if (_w > _maxWidth) {
+ h = qRound(h * _maxWidth / float64(_w));
+ _w = _maxWidth;
+ }
+ if (h > _maxHeight) {
+ _w = qRound(_w * _maxHeight / float64(h));
+ h = _maxHeight;
+ }
+ _x = (width() - _w) / 2;
+ _y = (height() - h) / 2;
+ if (isHidden()) {
+ moveToScreen();
+ bool wm = testAttribute(Qt::WA_Mapped), wv = testAttribute(Qt::WA_WState_Visible);
+ if (!wm) setAttribute(Qt::WA_Mapped, true);
+ if (!wv) setAttribute(Qt::WA_WState_Visible, true);
+ update();
+ QEvent e(QEvent::UpdateRequest);
+ event(&e);
+ if (!wm) setAttribute(Qt::WA_Mapped, false);
+ if (!wv) setAttribute(Qt::WA_WState_Visible, false);
+ show();
+ }
+ update();
+}
+
+void MediaView::paintEvent(QPaintEvent *e) {
+ QPainter p(this);
+ p.setOpacity(st::medviewLightOpacity);
+ p.fillRect(QRect(0, 0, st::medviewNavBarWidth, height()), st::black->b);
+ p.fillRect(QRect(width() - st::medviewNavBarWidth, 0, st::medviewNavBarWidth, height()), st::black->b);
+ p.fillRect(QRect(st::medviewNavBarWidth, 0, width() - 2 * st::medviewNavBarWidth, height()), st::black->b);
+ p.setOpacity(1);
+ p.drawPixmap(_x, _y, (_photo->full->loaded() ? _photo->full : _photo->thumb)->pixNoCache(_w, 0, true));
+}
+
+void MediaView::keyPressEvent(QKeyEvent *e) {
+ if (e->key() == Qt::Key_Escape) {
+ App::wnd()->layerHidden();
+ }
+}
+
+void MediaView::mousePressEvent(QMouseEvent *e) {
+ if (e->button() == Qt::LeftButton) {
+ App::wnd()->layerHidden();
+ }
+}
diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h
new file mode 100644
index 000000000..d55da3f5e
--- /dev/null
+++ b/Telegram/SourceFiles/mediaview.h
@@ -0,0 +1,43 @@
+/*
+This file is part of Telegram Desktop,
+an unofficial desktop 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.
+
+Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
+Copyright (c) 2014 John Preston, https://tdesktop.com
+*/
+#pragma once
+
+class MediaView : public QWidget {
+ Q_OBJECT
+
+public:
+
+ MediaView();
+
+ void paintEvent(QPaintEvent *e);
+
+ void keyPressEvent(QKeyEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+
+ void showPhoto(PhotoData *photo, const QRect &opaque);
+ void moveToScreen();
+
+private:
+
+ QTimer _timer;
+ PhotoData *_photo;
+ QRect _opaqueRect;
+
+ int32 _maxWidth, _maxHeight, _x, _y, _w;
+
+};
diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp
index 0e9920f9b..eb3c4840e 100644
--- a/Telegram/SourceFiles/window.cpp
+++ b/Telegram/SourceFiles/window.cpp
@@ -29,6 +29,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "layerwidget.h"
#include "settingswidget.h"
+#include "mediaview.h"
+
ConnectingWidget::ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect) : QWidget(parent), _shadow(st::boxShadow), _reconnect(this, QString()) {
set(text, reconnect);
connect(&_reconnect, SIGNAL(clicked()), this, SLOT(onReconnect()));
@@ -334,7 +336,7 @@ NotifyWindow::~NotifyWindow() {
}
Window::Window(QWidget *parent) : PsMainWindow(parent),
- intro(0), main(0), settings(0), layer(0), layerBG(0), _topWidget(0),
+ intro(0), main(0), settings(0), layer(0), layerBG(0), _topWidget(0), _mediaView(0),
_connecting(0), _tempDeleter(0), _tempDeleterThread(0), myIcon(QPixmap::fromImage(icon256)), dragging(false), _inactivePress(false) {
if (objectName().isEmpty())
@@ -450,6 +452,8 @@ void Window::setupMain(bool anim) {
fixOrder();
updateTitleStatus();
+
+ _mediaView = new MediaView();
}
void Window::showSettings() {
@@ -549,7 +553,10 @@ void Window::showPhoto(const PhotoLink *lnk, HistoryItem *item) {
void Window::showPhoto(PhotoData *photo, HistoryItem *item) {
layerHidden();
- layer = new LayerWidget(this, photo, item);
+ _mediaView->showPhoto(photo, QRect());
+ _mediaView->activateWindow();
+ _mediaView->setFocus();
+// layer = new LayerWidget(this, photo, item);
}
PhotoData *Window::photoShown() {
@@ -624,6 +631,7 @@ void Window::layerHidden() {
layer = 0;
if (layerBG) layerBG->deleteLater();
layerBG = 0;
+ if (_mediaView) _mediaView->hide();
if (main) main->setInnerFocus();
}
@@ -920,6 +928,12 @@ void Window::onTempDirClearFailed() {
emit tempDirClearFailed();
}
+void Window::quit() {
+ delete _mediaView;
+ _mediaView = 0;
+ notifyClearFast();
+}
+
void Window::notifySchedule(History *history, MsgId msgId) {
if (App::quiting() || !history->currentNotification()) return;
@@ -1192,6 +1206,7 @@ void Window::notifyUpdateAllPhotos() {
(*i)->updatePeerPhoto();
}
}
+ if (_mediaView) _mediaView->update();
}
void Window::notifyUpdateAll() {
@@ -1233,6 +1248,7 @@ Window::~Window() {
delete _tempDeleter;
delete _tempDeleterThread;
delete _connecting;
+ delete _mediaView;
delete trayIcon;
delete trayIconMenu;
delete intro;
diff --git a/Telegram/SourceFiles/window.h b/Telegram/SourceFiles/window.h
index 838379a43..c7b10bd5e 100644
--- a/Telegram/SourceFiles/window.h
+++ b/Telegram/SourceFiles/window.h
@@ -22,6 +22,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "pspecific.h"
#include "gui/boxshadow.h"
+class MediaView;
class TitleWidget;
class IntroWidget;
class MainWidget;
@@ -209,6 +210,8 @@ public:
TempDirState tempDirState();
void tempDirDelete();
+ void quit();
+
void notifySettingGot();
void notifySchedule(History *history, MsgId msgId);
void notifyClear(History *history = 0);
@@ -299,7 +302,7 @@ private:
NotifyWindows notifyWindows;
-
+ MediaView *_mediaView;
};
#endif // MAINWINDOW_H
diff --git a/Telegram/Telegram.vcxproj b/Telegram/Telegram.vcxproj
index 7b732cb62..c0f64e007 100644
--- a/Telegram/Telegram.vcxproj
+++ b/Telegram/Telegram.vcxproj
@@ -262,6 +262,10 @@
true
true
+
+ true
+ true
+
true
true
@@ -450,6 +454,10 @@
true
true
+
+ true
+ true
+
true
true
@@ -647,6 +655,10 @@
true
true
+
+ true
+ true
+
true
true
@@ -768,6 +780,7 @@
+
@@ -1385,6 +1398,20 @@
$(QTDIR)\bin\moc.exe;%(FullPath)
$(QTDIR)\bin\moc.exe;%(FullPath)
+
+ $(QTDIR)\bin\moc.exe;%(FullPath)
+ Moc%27ing mediaview.h...
+ .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
+ "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mediaview.h" -DCUSTOM_API_ID -DUNICODE -D_WITH_DEBUG -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\OpenSSL-Win32\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.3.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.3.1\QtGui"
+ $(QTDIR)\bin\moc.exe;%(FullPath)
+ Moc%27ing mediaview.h...
+ .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
+ "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mediaview.h" -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\OpenSSL-Win32\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.3.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.3.1\QtGui"
+ $(QTDIR)\bin\moc.exe;%(FullPath)
+ Moc%27ing mediaview.h...
+ .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
+ "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mediaview.h" -DUNICODE -D_WITH_DEBUG -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\OpenSSL-Win32\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.3.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.3.1\QtGui"
+
Moc%27ing mtpFileLoader.h...
diff --git a/Telegram/Telegram.vcxproj.filters b/Telegram/Telegram.vcxproj.filters
index 474a8dde1..b3a681c53 100644
--- a/Telegram/Telegram.vcxproj.filters
+++ b/Telegram/Telegram.vcxproj.filters
@@ -668,6 +668,18 @@
Generated Files\Release
+
+ Source Files
+
+
+ Generated Files\Deploy
+
+
+ Generated Files\Debug
+
+
+ Generated Files\Release
+
@@ -906,6 +918,9 @@
gui
+
+ Source Files
+