fixed online display, fixed reading messages on idle

This commit is contained in:
John Preston 2014-06-20 11:06:21 +04:00
parent d68aeb1b49
commit e0a364dd0f
14 changed files with 77 additions and 31 deletions

View File

@ -1225,7 +1225,9 @@ namespace App {
textlnkDown(TextLinkPtr()); textlnkDown(TextLinkPtr());
if (completely) { if (completely) {
LOG(("Deleting sound.."));
delete newMsgSound; delete newMsgSound;
LOG(("Sound deleted!"));
newMsgSound = 0; newMsgSound = 0;
delete ::sprite; delete ::sprite;

View File

@ -736,6 +736,7 @@ DialogsWidget::DialogsWidget(MainWidget *parent) : QWidget(parent)
_filter.show(); _filter.show();
_filter.move(st::dlgPaddingHor, st::dlgFilterPadding); _filter.move(st::dlgPaddingHor, st::dlgFilterPadding);
_filter.setFocusPolicy(Qt::StrongFocus); _filter.setFocusPolicy(Qt::StrongFocus);
_filter.customUpDown(true);
_addContact.hide(); _addContact.hide();
_newGroup.show(); _newGroup.show();
_newGroup.move(width() - _newGroup.width() - st::dlgPaddingHor, 0); _newGroup.move(width() - _newGroup.width() - st::dlgPaddingHor, 0);

View File

@ -41,7 +41,7 @@ namespace {
FlatInputStyle _flatInputStyle; FlatInputStyle _flatInputStyle;
} }
FlatInput::FlatInput(QWidget *parent, const style::flatInput &st, const QString &pholder, const QString &v) : QLineEdit(v, parent), _oldtext(v), _kev(0), _phVisible(!v.length()), FlatInput::FlatInput(QWidget *parent, const style::flatInput &st, const QString &pholder, const QString &v) : QLineEdit(v, parent), _oldtext(v), _kev(0), _customUpDown(false), _phVisible(!v.length()),
a_phLeft(_phVisible ? 0 : st.phShift), a_phAlpha(_phVisible ? 1 : 0), a_phColor(st.phColor->c), a_phLeft(_phVisible ? 0 : st.phShift), a_phAlpha(_phVisible ? 1 : 0), a_phColor(st.phColor->c),
a_borderColor(st.borderColor->c), a_bgColor(st.bgColor->c), _notingBene(0), _st(st) { a_borderColor(st.borderColor->c), a_bgColor(st.bgColor->c), _notingBene(0), _st(st) {
resize(_st.width, _st.height); resize(_st.width, _st.height);
@ -67,6 +67,10 @@ FlatInput::FlatInput(QWidget *parent, const style::flatInput &st, const QString
connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer())); connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
} }
void FlatInput::customUpDown(bool custom) {
_customUpDown = custom;
}
void FlatInput::onTouchTimer() { void FlatInput::onTouchTimer() {
_touchRightButton = true; _touchRightButton = true;
} }
@ -231,7 +235,12 @@ void FlatInput::correctValue(QKeyEvent *e, const QString &was) {
void FlatInput::keyPressEvent(QKeyEvent *e) { void FlatInput::keyPressEvent(QKeyEvent *e) {
QString was(text()); QString was(text());
_kev = e; _kev = e;
QLineEdit::keyPressEvent(e); if (_customUpDown && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
e->ignore();
} else {
QLineEdit::keyPressEvent(e);
}
if (was == text()) { // call correct manually if (was == text()) { // call correct manually
correctValue(_kev, was); correctValue(_kev, was);
_oldtext = text(); _oldtext = text();

View File

@ -47,6 +47,8 @@ public:
QSize sizeHint() const; QSize sizeHint() const;
QSize minimumSizeHint() const; QSize minimumSizeHint() const;
void customUpDown(bool isCustom);
public slots: public slots:
void onTextChange(const QString &text); void onTextChange(const QString &text);
@ -71,6 +73,8 @@ private:
QString _ph, _oldtext; QString _ph, _oldtext;
QKeyEvent *_kev; QKeyEvent *_kev;
bool _customUpDown;
bool _phVisible; bool _phVisible;
anim::ivalue a_phLeft; anim::ivalue a_phLeft;
anim::fvalue a_phAlpha; anim::fvalue a_phAlpha;

View File

@ -1979,6 +1979,8 @@ void HistoryWidget::onSend() {
MTP::send(MTPmessages_SendMessage(histInputPeer, msgText, MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentDataReceived, randomId)); MTP::send(MTPmessages_SendMessage(histInputPeer, msgText, MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentDataReceived, randomId));
_field.setPlainText(""); _field.setPlainText("");
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
} }
_field.setFocus(); _field.setFocus();
} }

View File

@ -45,8 +45,13 @@ int main(int argc, char *argv[]) {
DEBUG_LOG(("Application Info: ideal thread count: %1, using %2 connections per session").arg(QThread::idealThreadCount()).arg(cConnectionsInSession())); DEBUG_LOG(("Application Info: ideal thread count: %1, using %2 connections per session").arg(QThread::idealThreadCount()).arg(cConnectionsInSession()));
Application app(argc, argv); int result = 0;
int result = App::quiting() ? 0 : app.exec(); {
Application app(argc, argv);
if (!App::quiting()) {
result = app.exec();
}
}
psFinish(); psFinish();

View File

@ -272,7 +272,6 @@ MainWidget::MainWidget(Window *window) : QWidget(window), failedObjId(0), _dialo
connect(this, SIGNAL(peerPhotoChanged(PeerData *)), this, SIGNAL(dialogsUpdated())); connect(this, SIGNAL(peerPhotoChanged(PeerData *)), this, SIGNAL(dialogsUpdated()));
connect(&noUpdatesTimer, SIGNAL(timeout()), this, SLOT(getDifference())); connect(&noUpdatesTimer, SIGNAL(timeout()), this, SLOT(getDifference()));
connect(&onlineTimer, SIGNAL(timeout()), this, SLOT(setOnline())); connect(&onlineTimer, SIGNAL(timeout()), this, SLOT(setOnline()));
connect(window->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(mainStateChanged(Qt::WindowState)));
connect(&onlineUpdater, SIGNAL(timeout()), this, SLOT(updateOnlineDisplay())); connect(&onlineUpdater, SIGNAL(timeout()), this, SLOT(updateOnlineDisplay()));
connect(this, SIGNAL(peerUpdated(PeerData*)), &history, SLOT(peerUpdated(PeerData*))); connect(this, SIGNAL(peerUpdated(PeerData*)), &history, SLOT(peerUpdated(PeerData*)));
connect(&_topBar, SIGNAL(clicked()), this, SLOT(onTopBarClick())); connect(&_topBar, SIGNAL(clicked()), this, SLOT(onTopBarClick()));

View File

@ -119,25 +119,30 @@ void MacPrivate::notifyReplied(unsigned long long peer, const char *str) {
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent), PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")) { posInited(false), trayIcon(0), trayIconMenu(0), icon256(qsl(":/gui/art/iconround256.png")) {
//tbCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation);
icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation);
connect(&psIdleTimer, SIGNAL(timeout()), this, SLOT(psIdleTimeout())); connect(&psIdleTimer, SIGNAL(timeout()), this, SLOT(psIdleTimeout()));
psIdleTimer.setSingleShot(false); psIdleTimer.setSingleShot(false);
connect(&notifyWaitTimer, SIGNAL(timeout()), this, SLOT(psNotifyFire())); connect(&notifyWaitTimer, SIGNAL(timeout()), this, SLOT(psNotifyFire()));
notifyWaitTimer.setSingleShot(true); notifyWaitTimer.setSingleShot(true);
} }
void PsMainWindow::psNotIdle() const {
psIdleTimer.stop();
if (psIdle) {
psIdle = false;
if (App::main()) App::main()->setOnline();
if (App::wnd()) App::wnd()->checkHistoryActivation();
}
}
void PsMainWindow::psIdleTimeout() { void PsMainWindow::psIdleTimeout() {
int64 idleTime = objc_idleTime(); int64 idleTime = objc_idleTime();
if (idleTime >= 0) { if (idleTime >= 0) {
if (idleTime <= IdleMsecs) { if (idleTime <= IdleMsecs) {
psIdle = false; psNotIdle();
psIdleTimer.stop();
if (App::main()) App::main()->setOnline();
} }
} } else { // error
psNotIdle();
}
} }
bool PsMainWindow::psIsOnline(int state) const { bool PsMainWindow::psIsOnline(int state) const {
@ -157,16 +162,17 @@ bool PsMainWindow::psIsOnline(int state) const {
} }
return false; return false;
} else { } else {
psIdle = false; psNotIdle();
psIdleTimer.stop();
} }
} } else { // error
psNotIdle();
}
return true; return true;
} }
bool PsMainWindow::psIsActive(int state) const { bool PsMainWindow::psIsActive(int state) const {
if (state < 0) state = this->windowState(); if (state < 0) state = this->windowState();
return isActiveWindow() && isVisible() && !(state & Qt::WindowMinimized); return isActiveWindow() && isVisible() && !(state & Qt::WindowMinimized) && !psIdle;
} }
void PsMainWindow::psRefreshTaskbarIcon() { void PsMainWindow::psRefreshTaskbarIcon() {

View File

@ -151,10 +151,12 @@ public slots:
protected: protected:
void psNotIdle() const;
bool posInited; bool posInited;
QSystemTrayIcon *trayIcon; QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu; QMenu *trayIconMenu;
QImage icon16, icon32, icon256; QImage icon256;
virtual void setupTrayIcon() { virtual void setupTrayIcon() {
} }

View File

@ -872,6 +872,15 @@ PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent), ps_hWnd(0), p
notifyWaitTimer.setSingleShot(true); notifyWaitTimer.setSingleShot(true);
} }
void PsMainWindow::psNotIdle() const {
psIdleTimer.stop();
if (psIdle) {
psIdle = false;
if (App::main()) App::main()->setOnline();
if (App::wnd()) App::wnd()->checkHistoryActivation();
}
}
void PsMainWindow::psIdleTimeout() { void PsMainWindow::psIdleTimeout() {
LASTINPUTINFO lii; LASTINPUTINFO lii;
lii.cbSize = sizeof(LASTINPUTINFO); lii.cbSize = sizeof(LASTINPUTINFO);
@ -879,15 +888,15 @@ void PsMainWindow::psIdleTimeout() {
if (res) { if (res) {
uint64 ticks = GetTickCount(); uint64 ticks = GetTickCount();
if (lii.dwTime >= ticks - IdleMsecs) { if (lii.dwTime >= ticks - IdleMsecs) {
psIdle = false; psNotIdle();
psIdleTimer.stop();
if (App::main()) App::main()->setOnline();
} }
} else { // error {
psNotIdle();
} }
} }
bool PsMainWindow::psIsActive() const { bool PsMainWindow::psIsActive() const {
return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized); return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized) && !psIdle;
} }
bool PsMainWindow::psIsOnline(int windowState) const { bool PsMainWindow::psIsOnline(int windowState) const {
@ -909,9 +918,10 @@ bool PsMainWindow::psIsOnline(int windowState) const {
} }
return false; return false;
} else { } else {
psIdle = false; psNotIdle();
psIdleTimer.stop();
} }
} else { // error
psNotIdle();
} }
return true; return true;
} }

View File

@ -136,6 +136,8 @@ public slots:
protected: protected:
void psNotIdle() const;
bool posInited; bool posInited;
QSystemTrayIcon *trayIcon; QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu; QMenu *trayIconMenu;

View File

@ -444,6 +444,12 @@ QRect Window::iconRect() const {
bool Window::eventFilter(QObject *obj, QEvent *evt) { bool Window::eventFilter(QObject *obj, QEvent *evt) {
if (obj == App::app() && (evt->type() == QEvent::ApplicationActivate)) { if (obj == App::app() && (evt->type() == QEvent::ApplicationActivate)) {
QTimer::singleShot(1, this, SLOT(checkHistoryActivation())); QTimer::singleShot(1, this, SLOT(checkHistoryActivation()));
} else if (obj == this && evt->type() == QEvent::WindowStateChange) {
Qt::WindowState state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized : ((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized : ((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
psStateChanged(state);
if (App::main()) {
App::main()->mainStateChanged(state);
}
} }
return PsMainWindow::eventFilter(obj, evt); return PsMainWindow::eventFilter(obj, evt);
} }

View File

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.5.2</string> <string>0.5.4</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>NOTE</key> <key>NOTE</key>

View File

@ -1458,8 +1458,9 @@
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.5.4;
DYLIB_COMPATIBILITY_VERSION = 0.5; DYLIB_COMPATIBILITY_VERSION = 0.5;
DYLIB_CURRENT_VERSION = 0.5.1; DYLIB_CURRENT_VERSION = 0.5.4;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = fast; GCC_OPTIMIZATION_LEVEL = fast;
@ -1576,9 +1577,10 @@
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.5.4;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 0.5; DYLIB_COMPATIBILITY_VERSION = 0.5;
DYLIB_CURRENT_VERSION = 0.5.1; DYLIB_CURRENT_VERSION = 0.5.4;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -1693,8 +1695,6 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.5.2;
DYLIB_CURRENT_VERSION = 0.5.2;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO; GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO;
GCC_OPTIMIZATION_LEVEL = fast; GCC_OPTIMIZATION_LEVEL = fast;
@ -1714,9 +1714,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.5.2;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_CURRENT_VERSION = 0.5.2;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO; GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;