Version 0.10.14 alpha: using $XDG_DATA_HOME in Linux.

If there is no app data in ~/.TelegramDesktop (like in
fresh installs) we use $XDG_DATA_HOME/TelegramDesktop.
This commit is contained in:
John Preston 2016-10-18 13:32:33 +03:00
parent fc7c5d0ab3
commit ba4dcc42dc
13 changed files with 382 additions and 364 deletions

View file

@ -1291,7 +1291,7 @@ textRectMargins: margins(-2px, -1px, -2px, -1px);
taMsgField: flatTextarea(taDefFlat) {
font: msgFont;
}
maxFieldHeight: 220px;
maxFieldHeight: 224px;
// historyMinHeight: 56px;
reportSpamHide: flatButton(btnDefFlat) {

View file

@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,13,0
PRODUCTVERSION 0,10,13,0
FILEVERSION 0,10,14,0
PRODUCTVERSION 0,10,14,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.10.13.0"
VALUE "FileVersion", "0.10.14.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.13.0"
VALUE "ProductVersion", "0.10.14.0"
END
END
BLOCK "VarFileInfo"

View file

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,13,0
PRODUCTVERSION 0,10,13,0
FILEVERSION 0,10,14,0
PRODUCTVERSION 0,10,14,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -43,10 +43,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Updater"
VALUE "FileVersion", "0.10.13.0"
VALUE "FileVersion", "0.10.14.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.13.0"
VALUE "ProductVersion", "0.10.14.0"
END
END
BLOCK "VarFileInfo"

View file

@ -1086,8 +1086,8 @@ void AppClass::checkMapVersion() {
if (Local::oldMapVersion() < AppVersion) {
if (Local::oldMapVersion()) {
QString versionFeatures;
if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10012) {
versionFeatures = QString::fromUtf8("Windows and Linux:\n\xe2\x80\x94 Quick reply from notifications\n\xe2\x80\x94 Hide all notifications button added\n\xe2\x80\x94 Change notifications location and maximum count\n\nLinux:\n\xe2\x80\x94 You can enable native notifications in Settings");
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");
} else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10005) {
versionFeatures = langNewVersionText();
} else {

View file

@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#define BETA_VERSION_MACRO (0ULL)
constexpr int AppVersion = 10013;
constexpr str_const AppVersionStr = "0.10.13";
constexpr int AppVersion = 10014;
constexpr str_const AppVersionStr = "0.10.14";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View file

@ -3275,8 +3275,7 @@ void HistoryWidget::onTextChange() {
}
if (updateCmdStartShown()) {
updateControlsVisibility();
resizeEvent(0);
update();
updateControlsGeometry();
}
_saveCloudDraftTimer.stop();
@ -3597,7 +3596,7 @@ void HistoryWidget::notify_userIsBotChanged(UserData *user) {
_list->notifyIsBotChanged();
_list->updateBotInfo();
updateControlsVisibility();
resizeEvent(0);
updateControlsGeometry();
}
}
@ -4117,8 +4116,7 @@ void HistoryWidget::applyCloudDraft(History *history) {
applyDraft();
updateControlsVisibility();
resizeEvent(nullptr);
update();
updateControlsGeometry();
}
}
@ -5313,7 +5311,7 @@ void HistoryWidget::onBotStart() {
}
}
updateControlsVisibility();
resizeEvent(0);
updateControlsGeometry();
}
void HistoryWidget::onJoinChannel() {
@ -6918,7 +6916,7 @@ void HistoryWidget::peerMessagesUpdated(PeerId peer) {
if (!upd && !unblock && !botStart && !joinChannel) upd = (_muteUnmute.isHidden() == muteUnmute);
if (upd) {
updateControlsVisibility();
resizeEvent(0);
updateControlsGeometry();
}
}
}
@ -7006,6 +7004,10 @@ void HistoryWidget::notify_handlePendingHistoryUpdate() {
}
void HistoryWidget::resizeEvent(QResizeEvent *e) {
updateControlsGeometry();
}
void HistoryWidget::updateControlsGeometry() {
_reportSpamPanel.resize(width(), _reportSpamPanel.height());
moveFieldControls();
@ -8041,8 +8043,7 @@ void HistoryWidget::cancelEdit() {
void HistoryWidget::cancelForwarding() {
updateControlsVisibility();
resizeEvent(0);
update();
updateControlsGeometry();
}
void HistoryWidget::onFieldBarCancel() {
@ -8243,11 +8244,10 @@ void HistoryWidget::onFullPeerUpdated(PeerData *data) {
}
if (updateCmdStartShown()) {
updateControlsVisibility();
resizeEvent(0);
update();
updateControlsGeometry();
} else if (!_scroll.isHidden() && _unblock.isHidden() == isBlocked()) {
updateControlsVisibility();
resizeEvent(0);
updateControlsGeometry();
}
}
@ -8293,8 +8293,7 @@ void HistoryWidget::peerUpdated(PeerData *data) {
}
updateControlsVisibility();
if (resize) {
resizeEvent(0);
update();
updateControlsGeometry();
}
}
App::main()->updateOnlineDisplay();
@ -8479,8 +8478,7 @@ void HistoryWidget::updateForwarding(bool force) {
if (readyToForward()) {
updateControlsVisibility();
} else {
resizeEvent(0);
update();
updateControlsGeometry();
}
}

View file

@ -55,17 +55,6 @@ public:
void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages);
void messagesReceivedDown(PeerData *peer, const QVector<MTPMessage> &messages);
bool event(QEvent *e) override; // calls touchEvent when necessary
void touchEvent(QTouchEvent *e);
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false);
TextWithEntities getSelectedText() const;
@ -122,6 +111,18 @@ public:
protected:
bool focusNextPrevChild(bool next) override;
bool event(QEvent *e) override; // calls touchEvent when necessary
void touchEvent(QTouchEvent *e);
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
public slots:
void onUpdateSelected();
void onParentGeometryChanged();
@ -331,22 +332,20 @@ class ReportSpamPanel : public TWidget {
Q_OBJECT
public:
ReportSpamPanel(HistoryWidget *parent);
void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *e);
void setReported(bool reported, PeerData *onPeer);
signals:
void hideClicked();
void reportClicked();
void clearClicked();
private:
protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
private:
FlatButton _report, _hide;
LinkButton _clear;
@ -358,13 +357,6 @@ class BotKeyboard : public TWidget, public AbstractTooltipShower, public ClickHa
public:
BotKeyboard();
void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
bool moderateKeyActivate(int index);
// With force=true the markup is updated even if it is
@ -397,6 +389,13 @@ public:
protected:
int resizeGetHeight(int newWidth) override;
void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
private:
void updateSelected();
@ -537,18 +536,10 @@ public:
void windowShown();
bool doWeReadServerHistory() const;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void leaveToChildEvent(QEvent *e, QWidget *child) override;
void dragEnterEvent(QDragEnterEvent *e) override;
void dragLeaveEvent(QDragLeaveEvent *e) override;
void leaveEvent(QEvent *e) override;
void dropEvent(QDropEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void leaveToChildEvent(QEvent *e, QWidget *child) override;
void contextMenuEvent(QContextMenuEvent *e) override;
void updateTopBarSelection();
@ -596,6 +587,7 @@ public:
void cancelShareContact();
void updateControlsVisibility();
void updateControlsGeometry();
void updateOnlineDisplay();
void updateOnlineDisplayTimer();
@ -694,7 +686,7 @@ public:
void grabStart() override {
_inGrab = true;
resizeEvent(0);
updateControlsGeometry();
}
void grapWithoutTopBarShadow();
void grabFinish() override;
@ -727,6 +719,16 @@ public:
~HistoryWidget();
protected:
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void leaveEvent(QEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override;
signals:
void cancelled();
void historyShown(History *history, MsgId atMsgId);

View file

@ -28,6 +28,7 @@ int main(int argc, char *argv[]) {
#ifndef Q_OS_MAC // Retina display support is working fine, others are not.
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
#endif // Q_OS_MAC
QCoreApplication::setApplicationName(qsl("TelegramDesktop"));
settingsParseArgs(argc, argv);
if (cLaunchMode() == LaunchModeFixPrevious) {

View file

@ -2724,7 +2724,7 @@ void MainWidget::showAll() {
_wideSection->show();
} else if (_history->peer()) {
_history->show();
_history->resizeEvent(0);
_history->updateControlsGeometry();
} else {
_dialogs->show();
_history->hide();
@ -2754,7 +2754,7 @@ void MainWidget::showAll() {
_wideSection->show();
} else {
_history->show();
_history->resizeEvent(0);
_history->updateControlsGeometry();
}
if (_wideSection) {
_topBar->hide();
@ -3551,7 +3551,7 @@ void MainWidget::openPeerByName(const QString &username, MsgId msgId, const QStr
peer->asUser()->botInfo->startToken = startToken;
if (peer == _history->peer()) {
_history->updateControlsVisibility();
_history->resizeEvent(0);
_history->updateControlsGeometry();
}
}
Ui::showPeerHistoryAsync(peer->id, msgId, Ui::ShowWay::Forward);
@ -3636,7 +3636,7 @@ void MainWidget::usernameResolveDone(QPair<MsgId, QString> msgIdAndStartToken, c
peer->asUser()->botInfo->startToken = startToken;
if (peer == _history->peer()) {
_history->updateControlsVisibility();
_history->resizeEvent(0);
_history->updateControlsGeometry();
}
}
Ui::showPeerHistory(peer->id, msgId, Ui::ShowWay::Forward);

View file

@ -37,6 +37,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
using namespace Platform;
namespace {
QByteArray escapeShell(const QByteArray &str) {
QByteArray result;
const char *b = str.constData(), *e = str.constEnd();
@ -62,23 +63,19 @@ namespace {
class _PsEventFilter : public QAbstractNativeEventFilter {
public:
_PsEventFilter() {
}
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
auto wnd = App::wnd();
if (!wnd) return false;
//auto wnd = App::wnd();
//if (!wnd) return false;
return false;
}
};
_PsEventFilter *_psEventFilter = 0;
};
_PsEventFilter *_psEventFilter = nullptr;
namespace {
QRect _monitorRect;
uint64 _monitorLastGot = 0;
}
} // namespace
QRect psDesktopRect() {
uint64 tnow = getms();
@ -279,8 +276,10 @@ void psDeleteDir(const QString &dir) {
}
namespace {
uint64 _lastUserAction = 0;
}
} // namespace
void psUserActionDone() {
_lastUserAction = getms(true);
@ -309,15 +308,27 @@ QString psCurrentLanguage() {
}
namespace {
QString _psHomeDir() {
QString getHomeDir() {
struct passwd *pw = getpwuid(getuid());
return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (QFile::decodeName(pw->pw_dir) + '/') : QString();
}
}
} // namespace
QString psAppDataPath() {
QString home(_psHomeDir());
return home.isEmpty() ? QString() : (home + qsl(".TelegramDesktop/"));
// Previously we used ~/.TelegramDesktop, so look there first.
// If we find data there, we should still use it.
auto home = getHomeDir();
if (!home.isEmpty()) {
auto oldPath = home + qsl(".TelegramDesktop/");
auto oldSettingsBase = oldPath + qsl("tdata/settings");
if (QFile(oldSettingsBase + '0').exists() || QFile(oldSettingsBase + '1').exists()) {
return oldPath;
}
}
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/';
}
QString psDownloadPath() {
@ -410,6 +421,7 @@ void finish() {
} // namespace Platform
namespace {
bool _psRunCommand(const QByteArray &command) {
int result = system(command.constData());
if (result) {
@ -419,11 +431,12 @@ namespace {
DEBUG_LOG(("App Info: command succeeded, command (in utf8): %1").arg(command.constData()));
return true;
}
}
} // namespace
void psRegisterCustomScheme() {
#ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME
QString home(_psHomeDir());
auto home = getHomeDir();
if (home.isEmpty() || cBetaVersion()) return; // don't update desktop file for beta version
#ifndef TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION

View file

@ -228,12 +228,18 @@ void FlatInput::focusOutEvent(QFocusEvent *e) {
}
void FlatInput::resizeEvent(QResizeEvent *e) {
updatePlaceholderText();
return QLineEdit::resizeEvent(e);
}
void FlatInput::updatePlaceholderText() {
int32 availw = width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1;
if (_st.font->width(_fullph) > availw) {
_ph = _st.font->elided(_fullph, availw);
} else {
_ph = _fullph;
}
update();
}
void FlatInput::contextMenuEvent(QContextMenuEvent *e) {
@ -279,8 +285,7 @@ void FlatInput::step_appearance(float64 ms, bool timer) {
void FlatInput::setPlaceholder(const QString &ph) {
_fullph = ph;
resizeEvent(0);
update();
updatePlaceholderText();
}
void FlatInput::setPlaceholderFast(bool fast) {
@ -2200,10 +2205,15 @@ void MaskedInputField::focusOutEvent(QFocusEvent *e) {
}
void MaskedInputField::resizeEvent(QResizeEvent *e) {
_placeholder = _st.font->elided(_placeholderFull, width() - _textMargins.left() - _textMargins.right() - _st.placeholderMargins.left() - _st.placeholderMargins.right() - 1);
updatePlaceholderText();
QLineEdit::resizeEvent(e);
}
void MaskedInputField::updatePlaceholderText() {
_placeholder = _st.font->elided(_placeholderFull, width() - _textMargins.left() - _textMargins.right() - _st.placeholderMargins.left() - _st.placeholderMargins.right() - 1);
update();
}
void MaskedInputField::contextMenuEvent(QContextMenuEvent *e) {
if (QMenu *menu = createStandardContextMenu()) {
(new PopupMenu(menu))->popup(e->globalPos());
@ -2267,8 +2277,7 @@ void MaskedInputField::step_border(float64 ms, bool timer) {
bool MaskedInputField::setPlaceholder(const QString &placeholder) {
if (_placeholderFull != placeholder) {
_placeholderFull = placeholder;
resizeEvent(0);
update();
updatePlaceholderText();
return true;
}
return false;

View file

@ -27,18 +27,8 @@ class FlatInput : public QLineEdit {
T_WIDGET
public:
FlatInput(QWidget *parent, const style::flatInput &st, const QString &ph = QString(), const QString &val = QString());
bool event(QEvent *e) override;
void touchEvent(QTouchEvent *e);
void paintEvent(QPaintEvent *e) override;
void focusInEvent(QFocusEvent *e) override;
void focusOutEvent(QFocusEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override;
void notaBene();
void setPlaceholder(const QString &ph);
@ -62,14 +52,12 @@ public:
void setTextMargins(const QMargins &mrg);
public slots:
void onTextChange(const QString &text);
void onTextEdited();
void onTouchTimer();
signals:
void changed();
void cancelled();
void submitted(bool ctrlShiftEnter);
@ -84,6 +72,15 @@ protected:
return QLineEdit::leaveEvent(e);
}
bool event(QEvent *e) override;
void touchEvent(QTouchEvent *e);
void paintEvent(QPaintEvent *e) override;
void focusInEvent(QFocusEvent *e) override;
void focusOutEvent(QFocusEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override;
virtual void correctValue(const QString &was, QString &now);
style::font phFont() {
@ -93,6 +90,7 @@ protected:
void phPrepare(Painter &p);
private:
void updatePlaceholderText();
QString _oldtext, _ph, _fullph;
bool _fastph;
@ -515,7 +513,6 @@ class MaskedInputField : public QLineEdit {
T_WIDGET
public:
MaskedInputField(QWidget *parent, const style::InputField &st, const QString &placeholder = QString(), const QString &val = QString());
bool event(QEvent *e) override;
@ -556,7 +553,6 @@ public:
}
public slots:
void onTextChange(const QString &text);
void onCursorPositionChanged(int oldPosition, int position);
@ -565,7 +561,6 @@ public slots:
void onTouchTimer();
signals:
void changed();
void cancelled();
void submitted(bool ctrlShiftEnter);
@ -595,8 +590,8 @@ protected:
const style::InputField &_st;
private:
void startBorderAnimation();
void updatePlaceholderText();
int32 _maxLength;

View file

@ -1,6 +1,6 @@
AppVersion 10013
AppVersion 10014
AppVersionStrMajor 0.10
AppVersionStrSmall 0.10.13
AppVersionStr 0.10.13
AppVersionStrSmall 0.10.14
AppVersionStr 0.10.14
AlphaChannel 1
BetaVersion 0