Skip to content

Commit

Permalink
Version 0.10.15 alpha: crash fix in new player, close button added.
Browse files Browse the repository at this point in the history
Also some grammar improvements and pinned message bar hiding fixed.
  • Loading branch information
john-preston committed Oct 18, 2016
1 parent b33b59b commit 48a20f0
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org

"lng_new_version_wrap" = "Telegram Desktop was updated to version {version}\n\n{changes}\n\nFull version history is available here:\n{link}";
"lng_new_version_minor" = "— Bug fixes and other minor improvements";
"lng_new_version_text" = "— New audio player design\n\nWindows and Linux:\n— Quick reply from notifications\n— Hide all notifications button added\n— Change notifications location and maximum count\n\nWindows 10:\n— Respecting quite hours for the notifications\n\nLinux:\n— You can enable native notifications in Settings";
"lng_new_version_text" = "— New audio player design\n\nWindows and Linux:\n— Quick reply from notifications\n— Hide all notifications button added\n— Change notifications location and maximum count\n\nWindows 10:\n— Respecting quiet hours for the notifications\n\nLinux:\n— You can enable native notifications in Settings";

"lng_menu_insert_unicode" = "Insert Unicode control character";

Expand Down
8 changes: 4 additions & 4 deletions Telegram/Resources/winrc/Telegram.rc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,14,0
PRODUCTVERSION 0,10,14,0
FILEVERSION 0,10,15,0
PRODUCTVERSION 0,10,15,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.10.14.0"
VALUE "FileVersion", "0.10.15.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.14.0"
VALUE "ProductVersion", "0.10.15.0"
END
END
BLOCK "VarFileInfo"
Expand Down
8 changes: 4 additions & 4 deletions Telegram/Resources/winrc/Updater.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,14,0
PRODUCTVERSION 0,10,14,0
FILEVERSION 0,10,15,0
PRODUCTVERSION 0,10,15,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -43,10 +43,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Updater"
VALUE "FileVersion", "0.10.14.0"
VALUE "FileVersion", "0.10.15.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.14.0"
VALUE "ProductVersion", "0.10.15.0"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ void AppClass::checkMapVersion() {
if (Local::oldMapVersion()) {
QString versionFeatures;
if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10014) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 New audio player design\n\xe2\x80\x94 Moved to Qt library version 5.6.2\n\nWindows 10:\n\xe2\x80\x94 Respecting quite hours for the notifications");
versionFeatures = QString::fromUtf8("\xe2\x80\x94 New audio player design\n\xe2\x80\x94 Moved to Qt library version 5.6.2\n\nWindows 10:\n\xe2\x80\x94 Respecting quiet hours for the notifications");
} else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10005) {
versionFeatures = langNewVersionText();
} else {
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/core/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org

#define BETA_VERSION_MACRO (0ULL)

constexpr int AppVersion = 10014;
constexpr str_const AppVersionStr = "0.10.14";
constexpr int AppVersion = 10015;
constexpr str_const AppVersionStr = "0.10.15";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
13 changes: 8 additions & 5 deletions Telegram/SourceFiles/historywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4190,7 +4190,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
_history->showAtMsgId = _showAtMsgId;

destroyUnreadBar();
if (_pinnedBar) destroyPinnedBar();
destroyPinnedBar();
_history = _migrated = nullptr;
updateBotKeyboard();
}
Expand Down Expand Up @@ -7560,6 +7560,11 @@ HistoryWidget::PinnedBar::PinnedBar(MsgId msgId, HistoryWidget *parent)
, shadow(parent, st::shadowColor) {
}

HistoryWidget::PinnedBar::~PinnedBar() {
cancel.destroyDelayed();
shadow.destroyDelayed();
}

void HistoryWidget::updatePinnedBar(bool force) {
if (!_pinnedBar) {
return;
Expand Down Expand Up @@ -7603,7 +7608,7 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
}
if (pinnedMsgId) {
if (!_pinnedBar) {
_pinnedBar = new PinnedBar(pinnedMsgId, this);
_pinnedBar = std_::make_unique<PinnedBar>(pinnedMsgId, this);
if (_a_show.animating()) {
_pinnedBar->cancel->hide();
_pinnedBar->shadow->hide();
Expand Down Expand Up @@ -7650,8 +7655,7 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
}

void HistoryWidget::destroyPinnedBar() {
delete _pinnedBar;
_pinnedBar = nullptr;
_pinnedBar.reset();
_inPinnedMsg = false;
}

Expand Down Expand Up @@ -8881,6 +8885,5 @@ bool HistoryWidget::touchScroll(const QPoint &delta) {
}

HistoryWidget::~HistoryWidget() {
delete base::take(_pinnedBar);
delete base::take(_list);
}
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/historywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,14 +886,15 @@ private slots:

struct PinnedBar {
PinnedBar(MsgId msgId, HistoryWidget *parent);
~PinnedBar();

MsgId msgId = 0;
HistoryItem *msg = nullptr;
Text text;
ChildWidget<IconedButton> cancel;
ChildWidget<Ui::PlainShadow> shadow;
};
PinnedBar *_pinnedBar = nullptr;
std_::unique_ptr<PinnedBar> _pinnedBar;
void updatePinnedBar(bool force = false);
bool pinnedMsgVisibilityUpdated();
void destroyPinnedBar();
Expand Down
23 changes: 21 additions & 2 deletions Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ MainWidget::MainWidget(MainWindow *window) : TWidget(window)

if (Media::Player::exists()) {
_playerPanel->setPinCallback([this] { switchToFixedPlayer(); });
_playerPanel->setCloseCallback([this] { closeBothPlayers(); });
subscribe(Media::Player::instance()->titleButtonOver(), [this](bool over) {
if (over) {
_playerPanel->showFromOther();
Expand Down Expand Up @@ -1578,8 +1579,10 @@ void MainWidget::handleAudioUpdate(const AudioMsgId &audioId) {
}

if (playing == audioId && audioId.type() == AudioMsgId::Type::Song) {
if (!_playerUsingPanel && !_player && Media::Player::exists()) {
createPlayer();
if (!(playbackState.state & AudioPlayerStoppedMask) && playbackState.state != AudioPlayerFinishing) {
if (!_playerUsingPanel && !_player && Media::Player::exists()) {
createPlayer();
}
}
}

Expand Down Expand Up @@ -1623,6 +1626,22 @@ void MainWidget::switchToFixedPlayer() {
_playerPanel->hideIgnoringEnterEvents();
}

void MainWidget::closeBothPlayers() {
_playerUsingPanel = false;
_player.destroyDelayed();
_playerVolume.destroyDelayed();

if (Media::Player::exists()) {
Media::Player::instance()->usePanelPlayer().notify(false, true);
}
_playerPanel->hideIgnoringEnterEvents();
_playerPlaylist->hideIgnoringEnterEvents();

if (Media::Player::exists()) {
Media::Player::instance()->stop();
}
}

void MainWidget::createPlayer() {
_player.create(this, [this] { playerHeightUpdated(); });
_player->entity()->setCloseCallback([this] { switchToPanelPlayer(); });
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/mainwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ public slots:
void createPlayer();
void switchToPanelPlayer();
void switchToFixedPlayer();
void closeBothPlayers();
void playerHeightUpdated();

void sendReadRequest(PeerData *peer, MsgId upTo);
Expand Down
20 changes: 10 additions & 10 deletions Telegram/SourceFiles/media/player/media_player.style
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ mediaPlayerPreviousDisabledIcon: icon {
};
mediaPlayerClose: IconButton(mediaPlayerRepeatButton) {
width: 37px;
icon: icon {
{ "player_close", #c8c8c8, point(10px, 12px) },
};
icon: icon {{ "player_close", #c8c8c8, point(10px, 12px) }};
}
mediaPlayerPlayback: FilledSlider {
fullWidth: 6px;
Expand Down Expand Up @@ -190,25 +188,27 @@ mediaPlayerPanelMarginBottom: 10px;
mediaPlayerPanelWidth: 344px;
mediaPlayerCoverHeight: 102px;

mediaPlayerPanelClose: IconButton(mediaPlayerClose) {
width: 43px;
height: 28px;
icon: icon {{ "player_close", #c8c8c8, point(16px, 14px) }};
}

mediaPlayerPanelNextButton: IconButton(mediaPlayerRepeatButton) {
width: 37px;
icon: icon {
{ "player_panel_next", mediaPlayerActiveFg, point(10px, 10px) },
};
icon: icon {{ "player_panel_next", mediaPlayerActiveFg, point(10px, 10px) }};
}
mediaPlayerPanelNextDisabledIcon: icon {
{ "player_panel_next", mediaPlayerInactiveFg, point(10px, 10px) },
};
mediaPlayerPanelPreviousButton: IconButton(mediaPlayerPanelNextButton) {
icon: icon {
{ "player_panel_previous", mediaPlayerActiveFg, point(10px, 10px) },
};
icon: icon {{ "player_panel_previous", mediaPlayerActiveFg, point(10px, 10px) }};
}
mediaPlayerPanelPreviousDisabledIcon: icon {
{ "player_panel_previous", mediaPlayerInactiveFg, point(10px, 10px) },
};

mediaPlayerPanelPadding: 18px;
mediaPlayerPanelPadding: 16px;
mediaPlayerPanelNameTop: 24px;
mediaPlayerPanelPlayLeft: 9px;
mediaPlayerPanelPlaySkip: 7px;
Expand Down
32 changes: 31 additions & 1 deletion Telegram/SourceFiles/media/player/media_player_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void CoverWidget::PlayButton::paintEvent(QPaintEvent *e) {
CoverWidget::CoverWidget(QWidget *parent) : TWidget(parent)
, _nameLabel(this, st::mediaPlayerName)
, _timeLabel(this, st::mediaPlayerTime)
, _close(this, st::mediaPlayerPanelClose)
, _playback(new Ui::MediaSlider(this, st::mediaPlayerPanelPlayback))
, _playPause(this)
, _volumeToggle(this, st::mediaPlayerVolumeToggle)
Expand All @@ -82,6 +83,11 @@ CoverWidget::CoverWidget(QWidget *parent) : TWidget(parent)
setAttribute(Qt::WA_OpaquePaintEvent);
resize(width(), st::mediaPlayerCoverHeight);

_close->hide();
_nameLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
_timeLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
setMouseTracking(true);

_playback->setChangeProgressCallback([this](float64 value) {
handleSeekProgress(value);
});
Expand Down Expand Up @@ -128,10 +134,14 @@ CoverWidget::CoverWidget(QWidget *parent) : TWidget(parent)
}
}

void CoverWidget::setPinCallback(PinCallback &&callback) {
void CoverWidget::setPinCallback(ButtonCallback &&callback) {
_pinPlayer->setClickedCallback(std_::move(callback));
}

void CoverWidget::setCloseCallback(ButtonCallback &&callback) {
_close->setClickedCallback(std_::move(callback));
}

void CoverWidget::handleSeekProgress(float64 progress) {
if (!_lastDurationMs) return;

Expand Down Expand Up @@ -167,6 +177,7 @@ void CoverWidget::resizeEvent(QResizeEvent *e) {
widthForName -= _timeLabel->width() + 2 * st::normalFont->spacew;
_nameLabel->resizeToWidth(widthForName);
updateLabelPositions();
_close->moveToRight(0, 0);

int skip = (st::mediaPlayerPanelPlayback.seekSize.width() / 2);
int length = (width() - 2 * st::mediaPlayerPanelPadding + st::mediaPlayerPanelPlayback.seekSize.width());
Expand All @@ -187,6 +198,25 @@ void CoverWidget::paintEvent(QPaintEvent *e) {
p.fillRect(e->rect(), st::windowBg);
}

void CoverWidget::mouseMoveEvent(QMouseEvent *e) {
auto closeAreaLeft = st::mediaPlayerPanelPadding + _nameLabel->width();
auto closeAreaHeight = _nameLabel->y() + _nameLabel->height();
auto closeArea = myrtlrect(closeAreaLeft, 0, width() - closeAreaLeft, closeAreaHeight);
auto closeVisible = closeArea.contains(e->pos());
setCloseVisible(closeVisible);
}

void CoverWidget::leaveEvent(QEvent *e) {
setCloseVisible(false);
}

void CoverWidget::setCloseVisible(bool visible) {
if (visible == _close->isHidden()) {
_close->setVisible(visible);
_timeLabel->setVisible(!visible);
}
}

void CoverWidget::updatePlayPrevNextPositions() {
auto left = st::mediaPlayerPanelPlayLeft;
auto top = st::mediaPlayerPanelPlayTop;
Expand Down
9 changes: 7 additions & 2 deletions Telegram/SourceFiles/media/player/media_player_cover.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ class CoverWidget : public TWidget, private base::Subscriber {
public:
CoverWidget(QWidget *parent);

using PinCallback = base::lambda_unique<void()>;
void setPinCallback(PinCallback &&callback);
using ButtonCallback = base::lambda_unique<void()>;
void setPinCallback(ButtonCallback &&callback);
void setCloseCallback(ButtonCallback &&callback);

protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override;

private:
void setCloseVisible(bool visible);
void handleSeekProgress(float64 progress);
void handleSeekFinished(float64 progress);

Expand All @@ -75,6 +79,7 @@ class CoverWidget : public TWidget, private base::Subscriber {
class PlayButton;
ChildWidget<FlatLabel> _nameLabel;
ChildWidget<Ui::LabelSimple> _timeLabel;
ChildWidget<Ui::IconButton> _close;
ChildWidget<Clip::Playback> _playback;
ChildWidget<Ui::IconButton> _previousTrack = { nullptr };
ChildWidget<PlayButton> _playPause;
Expand Down
12 changes: 10 additions & 2 deletions Telegram/SourceFiles/media/player/media_player_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ void Panel::ensureCreated() {
if (_layout == Layout::Full) {
_cover.create(this);
setPinCallback(std_::move(_pinCallback));
setCloseCallback(std_::move(_closeCallback));

_scrollShadow.create(this, st::mediaPlayerScrollShadow);
}
Expand Down Expand Up @@ -254,10 +255,17 @@ void Panel::performDestroy() {
}
}

void Panel::setPinCallback(PinCallback &&callback) {
void Panel::setPinCallback(ButtonCallback &&callback) {
_pinCallback = std_::move(callback);
if (_cover) {
_cover->setPinCallback(PinCallback(_pinCallback));
_cover->setPinCallback(ButtonCallback(_pinCallback));
}
}

void Panel::setCloseCallback(ButtonCallback &&callback) {
_closeCallback = std_::move(callback);
if (_cover) {
_cover->setCloseCallback(ButtonCallback(_closeCallback));
}
}

Expand Down
7 changes: 4 additions & 3 deletions Telegram/SourceFiles/media/player/media_player_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class Panel : public TWidget {
void showFromOther();
void hideFromOther();

using PinCallback = base::lambda_wrap<void()>;
void setPinCallback(PinCallback &&callback);
using ButtonCallback = base::lambda_wrap<void()>;
void setPinCallback(ButtonCallback &&callback);
void setCloseCallback(ButtonCallback &&callback);

void ui_repaintHistoryItem(const HistoryItem *item);

Expand Down Expand Up @@ -107,7 +108,7 @@ private slots:
QTimer _hideTimer, _showTimer;

Ui::RectShadow _shadow;
PinCallback _pinCallback;
ButtonCallback _pinCallback, _closeCallback;
ChildWidget<CoverWidget> _cover = { nullptr };
ChildWidget<ScrollArea> _scroll;
ChildWidget<Ui::GradientShadow> _scrollShadow = { nullptr };
Expand Down
Loading

0 comments on commit 48a20f0

Please sign in to comment.