Skip to content

Commit

Permalink
Version 1.0.5: new audio code + reorder pinned chats.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 31, 2017
1 parent 6df0591 commit 33d2ec0
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 26 deletions.
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 1,0,4,0
PRODUCTVERSION 1,0,4,0
FILEVERSION 1,0,5,0
PRODUCTVERSION 1,0,5,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "1.0.5.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "1.0.5.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 1,0,4,0
PRODUCTVERSION 1,0,4,0
FILEVERSION 1,0,5,0
PRODUCTVERSION 1,0,5,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", "1.0.4.0"
VALUE "FileVersion", "1.0.5.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "1.0.5.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 @@ -1071,7 +1071,7 @@ void AppClass::checkMapVersion() {
QString versionFeatures;
if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000004) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 Click and drag to reorder pinned chats.");
} else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000002) {
} else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000005) {
versionFeatures = langNewVersionText();
} else {
versionFeatures = lang(lng_new_version_minor).trimmed();
Expand Down
6 changes: 3 additions & 3 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-2017 John Preston, https://desktop.telegram.org

#define BETA_VERSION_MACRO (0ULL)

constexpr int AppVersion = 1000004;
constexpr str_const AppVersionStr = "1.0.4";
constexpr bool AppAlphaVersion = true;
constexpr int AppVersion = 1000005;
constexpr str_const AppVersionStr = "1.0.5";
constexpr bool AppAlphaVersion = false;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
22 changes: 15 additions & 7 deletions Telegram/SourceFiles/history/history_media_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,7 @@ HistoryDocument::HistoryDocument(HistoryItem *parent, DocumentData *document, co
, _data(document) {
createComponents(!caption.isEmpty());
if (auto named = Get<HistoryDocumentNamed>()) {
named->_name = documentName(_data);
named->_namew = st::semiboldFont->width(named->_name);
fillNamedFromData(named);
}

setDocumentLinks(_data);
Expand All @@ -948,8 +947,7 @@ HistoryDocument::HistoryDocument(HistoryItem *parent, const HistoryDocument &oth
named->_name = othernamed->_name;
named->_namew = othernamed->_namew;
} else {
named->_name = documentName(_data);
named->_namew = st::semiboldFont->width(named->_name);
fillNamedFromData(named);
}
}

Expand All @@ -968,7 +966,11 @@ void HistoryDocument::createComponents(bool caption) {
mask |= HistoryDocumentVoice::Bit();
} else {
mask |= HistoryDocumentNamed::Bit();
if (!_data->song() && !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height()) {
if (!_data->song()
&& !documentIsExecutableName(_data->name)
&& !_data->thumb->isNull()
&& _data->thumb->width()
&& _data->thumb->height()) {
mask |= HistoryDocumentThumbed::Bit();
}
}
Expand All @@ -982,6 +984,11 @@ void HistoryDocument::createComponents(bool caption) {
}
}

void HistoryDocument::fillNamedFromData(HistoryDocumentNamed *named) {
auto name = named->_name = documentName(_data);
named->_namew = st::semiboldFont->width(name);
}

void HistoryDocument::initDimensions() {
auto captioned = Get<HistoryDocumentCaptioned>();
if (captioned && captioned->_caption.hasSkipBlock()) {
Expand Down Expand Up @@ -1202,6 +1209,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
icon->paintInCenter(p, inner);
}
auto namewidth = _width - nameleft - nameright;
auto statuswidth = namewidth;

if (auto voice = Get<HistoryDocumentVoice>()) {
const VoiceWaveform *wf = nullptr;
Expand Down Expand Up @@ -1267,7 +1275,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
p.setFont(st::semiboldFont);
p.setPen(outbg ? st::historyFileNameOutFg : st::historyFileNameInFg);
if (namewidth < named->_namew) {
p.drawTextLeft(nameleft, nametop, _width, st::semiboldFont->elided(named->_name, namewidth));
p.drawTextLeft(nameleft, nametop, _width, st::semiboldFont->elided(named->_name, namewidth, Qt::ElideMiddle));
} else {
p.drawTextLeft(nameleft, nametop, _width, named->_name, named->_namew);
}
Expand All @@ -1280,7 +1288,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,

if (_parent->isMediaUnread()) {
int32 w = st::normalFont->width(_statusText);
if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= namewidth) {
if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= statuswidth) {
p.setPen(Qt::NoPen);
p.setBrush(outbg ? (selected ? st::msgFileOutBgSelected : st::msgFileOutBg) : (selected ? st::msgFileInBgSelected : st::msgFileInBg));

Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/history/history_media_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ class HistoryDocument : public HistoryFileMedia, public RuntimeComposer {

private:
void createComponents(bool caption);
void fillNamedFromData(HistoryDocumentNamed *named);

void setStatusSize(int32 newSize, qint64 realDuration = 0) const;
bool updateStatusText() const; // returns showPause
Expand Down
28 changes: 26 additions & 2 deletions Telegram/SourceFiles/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ QString formatPlayedText(qint64 played, qint64 duration) {
}

QString documentName(DocumentData *document) {
SongData *song = document->song();
auto song = document->song();
if (!song || (song->title.isEmpty() && song->performer.isEmpty())) {
return document->name.isEmpty() ? qsl("Unknown File") : document->name;
}
Expand Down Expand Up @@ -264,7 +264,7 @@ mka mks mcf m2p ps ts m2ts ifo aaf avchd cam dat dsh dvr-ms m1v fla flr sol wrap
wtv 8svx 16svx iff aiff aif aifc au bwf cdda raw wav flac la pac m4a ape ofr ofs off rka \
shn tak tta wv brstm dts dtshd dtsma ast amr mp3 spx gsm aac mpc vqf ra ots swa vox voc \
dwd smp aup cust mid mus sib sid ly gym vgm psf nsf mod ptb s3m xm it mt2 minipsf psflib \
2sf dsf gsf psf2 qsf ssf usf rmj spc niff mxl xml txm ym jam mp1 mscz \
2sf dsf gsf psf2 qsf ssf usf rmj spc niff mxl xml txm ym jam mp1 mscz\
").split(' ');
return result.release();
})());
Expand All @@ -273,3 +273,27 @@ dwd smp aup cust mid mus sib sid ly gym vgm psf nsf mod ptb s3m xm it mt2 minips
auto parts = info.fileName().split('.', QString::SkipEmptyParts);
return !parts.isEmpty() && (validMediaTypes->indexOf(parts.back().toLower()) >= 0);
}

bool documentIsExecutableName(const QString &filename) {
static StaticNeverFreedPointer<QList<QString>> executableTypes(([] {
std_::unique_ptr<QList<QString>> result = std_::make_unique<QList<QString>>();
#ifdef Q_OS_MAC
*result = qsl("\
action app bin command csh osx workflow\
").split(' ');
#elif defined Q_OS_LINUX // Q_OS_MAC
*result = qsl("\
bin csh ksh out run\
").split(' ');
#elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX
*result = qsl("\
bat bin cmd com cpl exe gadget inf ins inx isu job jse lnk msc msi \
msp mst paf pif ps1 reg rgs sct shb shs u3p vb vbe vbs vbscript ws wsf\
").split(' ');
#endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WINRT || Q_OS_WIN
return result.release();
})());

auto lastDotIndex = filename.lastIndexOf('.');
return (lastDotIndex >= 0) && (executableTypes->indexOf(filename.mid(lastDotIndex + 1).toLower()) >= 0);
}
1 change: 1 addition & 0 deletions Telegram/SourceFiles/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ style::color documentOverColor(int colorIndex);
style::color documentSelectedColor(int colorIndex);
RoundCorners documentCorners(int colorIndex);
bool documentIsValidMediaFile(const QString &filepath);
bool documentIsExecutableName(const QString &filename);

class PaintContextBase {
public:
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/overview/overview_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class Document : public RadialProgressItem {
int32 _thumbw, _colorIndex;

bool withThumb() const {
return !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height();
return !_data->song() && !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height() && !documentIsExecutableName(_data->name);
}
bool updateStatusText();

Expand Down
8 changes: 4 additions & 4 deletions Telegram/build/version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AppVersion 1000004
AppVersion 1000005
AppVersionStrMajor 1.0
AppVersionStrSmall 1.0.4
AppVersionStr 1.0.4
AlphaChannel 1
AppVersionStrSmall 1.0.5
AppVersionStr 1.0.5
AlphaChannel 0
BetaVersion 0

0 comments on commit 33d2ec0

Please sign in to comment.