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());
if (completely) {
LOG(("Deleting sound.."));
delete newMsgSound;
LOG(("Sound deleted!"));
newMsgSound = 0;
delete ::sprite;

View File

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

View File

@ -41,7 +41,7 @@ namespace {
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_borderColor(st.borderColor->c), a_bgColor(st.bgColor->c), _notingBene(0), _st(st) {
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()));
}
void FlatInput::customUpDown(bool custom) {
_customUpDown = custom;
}
void FlatInput::onTouchTimer() {
_touchRightButton = true;
}
@ -231,7 +235,12 @@ void FlatInput::correctValue(QKeyEvent *e, const QString &was) {
void FlatInput::keyPressEvent(QKeyEvent *e) {
QString was(text());
_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
correctValue(_kev, was);
_oldtext = text();

View File

@ -47,6 +47,8 @@ public:
QSize sizeHint() const;
QSize minimumSizeHint() const;
void customUpDown(bool isCustom);
public slots:
void onTextChange(const QString &text);
@ -71,6 +73,8 @@ private:
QString _ph, _oldtext;
QKeyEvent *_kev;
bool _customUpDown;
bool _phVisible;
anim::ivalue a_phLeft;
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));
_field.setPlainText("");
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
}
_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()));
Application app(argc, argv);
int result = App::quiting() ? 0 : app.exec();
int result = 0;
{
Application app(argc, argv);
if (!App::quiting()) {
result = app.exec();
}
}
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(&noUpdatesTimer, SIGNAL(timeout()), this, SLOT(getDifference()));
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(this, SIGNAL(peerUpdated(PeerData*)), &history, SLOT(peerUpdated(PeerData*)));
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),
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()));
psIdleTimer.setSingleShot(false);
connect(&notifyWaitTimer, SIGNAL(timeout()), this, SLOT(psNotifyFire()));
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() {
int64 idleTime = objc_idleTime();
if (idleTime >= 0) {
if (idleTime <= IdleMsecs) {
psIdle = false;
psIdleTimer.stop();
if (App::main()) App::main()->setOnline();
psNotIdle();
}
}
} else { // error
psNotIdle();
}
}
bool PsMainWindow::psIsOnline(int state) const {
@ -157,16 +162,17 @@ bool PsMainWindow::psIsOnline(int state) const {
}
return false;
} else {
psIdle = false;
psIdleTimer.stop();
psNotIdle();
}
}
} else { // error
psNotIdle();
}
return true;
}
bool PsMainWindow::psIsActive(int state) const {
if (state < 0) state = this->windowState();
return isActiveWindow() && isVisible() && !(state & Qt::WindowMinimized);
return isActiveWindow() && isVisible() && !(state & Qt::WindowMinimized) && !psIdle;
}
void PsMainWindow::psRefreshTaskbarIcon() {

View File

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

View File

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

View File

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

View File

@ -444,6 +444,12 @@ QRect Window::iconRect() const {
bool Window::eventFilter(QObject *obj, QEvent *evt) {
if (obj == App::app() && (evt->type() == QEvent::ApplicationActivate)) {
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);
}

View File

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

View File

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