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) { taMsgField: flatTextarea(taDefFlat) {
font: msgFont; font: msgFont;
} }
maxFieldHeight: 220px; maxFieldHeight: 224px;
// historyMinHeight: 56px; // historyMinHeight: 56px;
reportSpamHide: flatButton(btnDefFlat) { reportSpamHide: flatButton(btnDefFlat) {

View File

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

View File

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

View File

@ -1086,8 +1086,8 @@ void AppClass::checkMapVersion() {
if (Local::oldMapVersion() < AppVersion) { if (Local::oldMapVersion() < AppVersion) {
if (Local::oldMapVersion()) { if (Local::oldMapVersion()) {
QString versionFeatures; QString versionFeatures;
if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10012) { if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10014) {
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"); 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) { } else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 10005) {
versionFeatures = langNewVersionText(); versionFeatures = langNewVersionText();
} else { } else {

View File

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

View File

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

View File

@ -55,17 +55,6 @@ public:
void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages); void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages);
void messagesReceivedDown(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); void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false);
TextWithEntities getSelectedText() const; TextWithEntities getSelectedText() const;
@ -122,6 +111,18 @@ public:
protected: protected:
bool focusNextPrevChild(bool next) override; 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: public slots:
void onUpdateSelected(); void onUpdateSelected();
void onParentGeometryChanged(); void onParentGeometryChanged();
@ -331,22 +332,20 @@ class ReportSpamPanel : public TWidget {
Q_OBJECT Q_OBJECT
public: public:
ReportSpamPanel(HistoryWidget *parent); ReportSpamPanel(HistoryWidget *parent);
void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *e);
void setReported(bool reported, PeerData *onPeer); void setReported(bool reported, PeerData *onPeer);
signals: signals:
void hideClicked(); void hideClicked();
void reportClicked(); void reportClicked();
void clearClicked(); void clearClicked();
private: protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
private:
FlatButton _report, _hide; FlatButton _report, _hide;
LinkButton _clear; LinkButton _clear;
@ -358,13 +357,6 @@ class BotKeyboard : public TWidget, public AbstractTooltipShower, public ClickHa
public: public:
BotKeyboard(); 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); bool moderateKeyActivate(int index);
// With force=true the markup is updated even if it is // With force=true the markup is updated even if it is
@ -397,6 +389,13 @@ public:
protected: protected:
int resizeGetHeight(int newWidth) override; 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: private:
void updateSelected(); void updateSelected();
@ -537,18 +536,10 @@ public:
void windowShown(); void windowShown();
bool doWeReadServerHistory() const; bool doWeReadServerHistory() const;
void resizeEvent(QResizeEvent *e) override; void leaveToChildEvent(QEvent *e, QWidget *child) override;
void keyPressEvent(QKeyEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void dragEnterEvent(QDragEnterEvent *e) override; void dragEnterEvent(QDragEnterEvent *e) override;
void dragLeaveEvent(QDragLeaveEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override;
void leaveEvent(QEvent *e) override;
void dropEvent(QDropEvent *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(); void updateTopBarSelection();
@ -596,6 +587,7 @@ public:
void cancelShareContact(); void cancelShareContact();
void updateControlsVisibility(); void updateControlsVisibility();
void updateControlsGeometry();
void updateOnlineDisplay(); void updateOnlineDisplay();
void updateOnlineDisplayTimer(); void updateOnlineDisplayTimer();
@ -694,7 +686,7 @@ public:
void grabStart() override { void grabStart() override {
_inGrab = true; _inGrab = true;
resizeEvent(0); updateControlsGeometry();
} }
void grapWithoutTopBarShadow(); void grapWithoutTopBarShadow();
void grabFinish() override; void grabFinish() override;
@ -727,6 +719,16 @@ public:
~HistoryWidget(); ~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: signals:
void cancelled(); void cancelled();
void historyShown(History *history, MsgId atMsgId); 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. #ifndef Q_OS_MAC // Retina display support is working fine, others are not.
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
#endif // Q_OS_MAC #endif // Q_OS_MAC
QCoreApplication::setApplicationName(qsl("TelegramDesktop"));
settingsParseArgs(argc, argv); settingsParseArgs(argc, argv);
if (cLaunchMode() == LaunchModeFixPrevious) { if (cLaunchMode() == LaunchModeFixPrevious) {

View File

@ -2724,7 +2724,7 @@ void MainWidget::showAll() {
_wideSection->show(); _wideSection->show();
} else if (_history->peer()) { } else if (_history->peer()) {
_history->show(); _history->show();
_history->resizeEvent(0); _history->updateControlsGeometry();
} else { } else {
_dialogs->show(); _dialogs->show();
_history->hide(); _history->hide();
@ -2754,7 +2754,7 @@ void MainWidget::showAll() {
_wideSection->show(); _wideSection->show();
} else { } else {
_history->show(); _history->show();
_history->resizeEvent(0); _history->updateControlsGeometry();
} }
if (_wideSection) { if (_wideSection) {
_topBar->hide(); _topBar->hide();
@ -3551,7 +3551,7 @@ void MainWidget::openPeerByName(const QString &username, MsgId msgId, const QStr
peer->asUser()->botInfo->startToken = startToken; peer->asUser()->botInfo->startToken = startToken;
if (peer == _history->peer()) { if (peer == _history->peer()) {
_history->updateControlsVisibility(); _history->updateControlsVisibility();
_history->resizeEvent(0); _history->updateControlsGeometry();
} }
} }
Ui::showPeerHistoryAsync(peer->id, msgId, Ui::ShowWay::Forward); 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; peer->asUser()->botInfo->startToken = startToken;
if (peer == _history->peer()) { if (peer == _history->peer()) {
_history->updateControlsVisibility(); _history->updateControlsVisibility();
_history->resizeEvent(0); _history->updateControlsGeometry();
} }
} }
Ui::showPeerHistory(peer->id, msgId, Ui::ShowWay::Forward); 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; using namespace Platform;
namespace { namespace {
QByteArray escapeShell(const QByteArray &str) { QByteArray escapeShell(const QByteArray &str) {
QByteArray result; QByteArray result;
const char *b = str.constData(), *e = str.constEnd(); const char *b = str.constData(), *e = str.constEnd();
@ -62,23 +63,19 @@ namespace {
class _PsEventFilter : public QAbstractNativeEventFilter { class _PsEventFilter : public QAbstractNativeEventFilter {
public: public:
_PsEventFilter() {
}
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) { bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
auto wnd = App::wnd(); //auto wnd = App::wnd();
if (!wnd) return false; //if (!wnd) return false;
return false; return false;
} }
}; };
_PsEventFilter *_psEventFilter = 0; _PsEventFilter *_psEventFilter = nullptr;
};
namespace {
QRect _monitorRect; QRect _monitorRect;
uint64 _monitorLastGot = 0; uint64 _monitorLastGot = 0;
}
} // namespace
QRect psDesktopRect() { QRect psDesktopRect() {
uint64 tnow = getms(); uint64 tnow = getms();
@ -279,8 +276,10 @@ void psDeleteDir(const QString &dir) {
} }
namespace { namespace {
uint64 _lastUserAction = 0; uint64 _lastUserAction = 0;
}
} // namespace
void psUserActionDone() { void psUserActionDone() {
_lastUserAction = getms(true); _lastUserAction = getms(true);
@ -309,15 +308,27 @@ QString psCurrentLanguage() {
} }
namespace { namespace {
QString _psHomeDir() {
QString getHomeDir() {
struct passwd *pw = getpwuid(getuid()); struct passwd *pw = getpwuid(getuid());
return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (QFile::decodeName(pw->pw_dir) + '/') : QString(); return (pw && pw->pw_dir && strlen(pw->pw_dir)) ? (QFile::decodeName(pw->pw_dir) + '/') : QString();
} }
}
} // namespace
QString psAppDataPath() { QString psAppDataPath() {
QString home(_psHomeDir()); // Previously we used ~/.TelegramDesktop, so look there first.
return home.isEmpty() ? QString() : (home + qsl(".TelegramDesktop/")); // 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() { QString psDownloadPath() {
@ -410,6 +421,7 @@ void finish() {
} // namespace Platform } // namespace Platform
namespace { namespace {
bool _psRunCommand(const QByteArray &command) { bool _psRunCommand(const QByteArray &command) {
int result = system(command.constData()); int result = system(command.constData());
if (result) { if (result) {
@ -419,11 +431,12 @@ namespace {
DEBUG_LOG(("App Info: command succeeded, command (in utf8): %1").arg(command.constData())); DEBUG_LOG(("App Info: command succeeded, command (in utf8): %1").arg(command.constData()));
return true; return true;
} }
}
} // namespace
void psRegisterCustomScheme() { void psRegisterCustomScheme() {
#ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME #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 if (home.isEmpty() || cBetaVersion()) return; // don't update desktop file for beta version
#ifndef TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION #ifndef TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION

View File

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

View File

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

View File

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