Implemented a custom function to blink a window. On Windows XP the native FlashWindowEx() function doesn't work with caption-less windows.

This commit is contained in:
LoRd_MuldeR 2011-05-03 20:17:33 +02:00
parent 5ce0c7b82e
commit 6a6ac5396d
6 changed files with 83 additions and 5 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_MINOR_LO 2
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 10 #define VER_LAMEXP_PATCH 10
#define VER_LAMEXP_BUILD 476 #define VER_LAMEXP_BUILD 480
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tools versions // Tools versions

View File

@ -103,7 +103,6 @@ void DropBox::changeEvent(QEvent *e)
} }
} }
void DropBox::showEvent(QShowEvent *event) void DropBox::showEvent(QShowEvent *event)
{ {
QRect screenGeometry = QApplication::desktop()->availableGeometry(); QRect screenGeometry = QApplication::desktop()->availableGeometry();
@ -122,8 +121,12 @@ void DropBox::showEvent(QShowEvent *event)
QTimer::singleShot(333, this, SLOT(showToolTip())); QTimer::singleShot(333, this, SLOT(showToolTip()));
} }
if(m_moving)
{
QApplication::restoreOverrideCursor();
m_moving = false; m_moving = false;
} }
}
void DropBox::keyPressEvent(QKeyEvent *event) void DropBox::keyPressEvent(QKeyEvent *event)
{ {
@ -213,3 +216,20 @@ void DropBox::showToolTip(void)
{ {
QToolTip::showText(dropBoxLabel->mapToGlobal(dropBoxLabel->pos()), dropBoxLabel->toolTip()); QToolTip::showText(dropBoxLabel->mapToGlobal(dropBoxLabel->pos()), dropBoxLabel->toolTip());
} }
bool DropBox::event(QEvent *event)
{
switch(event->type())
{
case QEvent::Leave:
case QEvent::WindowDeactivate:
if(m_moving)
{
QApplication::restoreOverrideCursor();
m_moving = false;
}
break;
}
return QDialog::event(event);
}

View File

@ -61,6 +61,7 @@ protected:
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
bool event(QEvent *event);
public slots: public slots:
void modelChanged(void); void modelChanged(void);

View File

@ -71,7 +71,6 @@
#define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; } #define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; }
#define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, COLOR); WIDGET->setPalette(_palette); } #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, COLOR); WIDGET->setPalette(_palette); }
#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
#define FLASH_WINDOW(WND) { FLASHWINFO flashInfo; memset(&flashInfo, 0, sizeof(FLASHWINFO)); flashInfo.cbSize = sizeof(FLASHWINFO); flashInfo.dwFlags = FLASHW_ALL; flashInfo.uCount = 12; flashInfo.dwTimeout = 125; flashInfo.hwnd = WND->winId(); FlashWindowEx(&flashInfo); }
#define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL) #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
#define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); CMD; if(__dropBoxVisible) m_dropBox->show(); } #define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); CMD; if(__dropBoxVisible) m_dropBox->show(); }
@ -2474,7 +2473,7 @@ void MainWindow::showDropBoxWidgetActionTriggered(bool checked)
m_dropBox->show(); m_dropBox->show();
} }
FLASH_WINDOW(m_dropBox); lamexp_blink_window(m_dropBox);
} }
/* /*

View File

@ -41,6 +41,8 @@
#include <QRegExp> #include <QRegExp>
#include <QResource> #include <QResource>
#include <QTranslator> #include <QTranslator>
#include <QEventLoop>
#include <QTimer>
//LameXP includes //LameXP includes
#include "Resource.h" #include "Resource.h"
@ -1380,6 +1382,9 @@ __int64 lamexp_free_diskspace(const QString &path)
} }
} }
/*
* Shutdown the computer
*/
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown) bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown)
{ {
HANDLE hToken = NULL; HANDLE hToken = NULL;
@ -1404,6 +1409,57 @@ bool lamexp_shutdown_computer(const QString &message, const unsigned long timeou
return false; return false;
} }
/*
* Make a window blink (to draw user's attention)
*/
void lamexp_blink_window(QWidget *poWindow, unsigned int count, unsigned int delay)
{
static QMutex blinkMutex;
const double maxOpac = 1.0;
const double minOpac = 0.3;
const double delOpac = 0.1;
if(!blinkMutex.tryLock())
{
qWarning("Blinking is already in progress, skipping!");
return;
}
try
{
const int steps = static_cast<int>(ceil(maxOpac - minOpac) / delOpac);
const int sleep = static_cast<int>(floor(static_cast<double>(delay) / static_cast<double>(steps)));
const double opacity = poWindow->windowOpacity();
for(unsigned int i = 0; i < count; i++)
{
for(double x = maxOpac; x >= minOpac; x -= delOpac)
{
poWindow->setWindowOpacity(x);
QApplication::processEvents();
Sleep(sleep);
}
for(double x = minOpac; x <= maxOpac; x += delOpac)
{
poWindow->setWindowOpacity(x);
QApplication::processEvents();
Sleep(sleep);
}
}
poWindow->setWindowOpacity(opacity);
QApplication::processEvents();
blinkMutex.unlock();
}
catch (...)
{
blinkMutex.unlock();
qWarning("Exception error while blinking!");
}
}
/* /*
* Finalization function (final clean-up) * Finalization function (final clean-up)
*/ */

View File

@ -36,6 +36,7 @@
class QString; class QString;
class QStringList; class QStringList;
class QDate; class QDate;
class QWidget;
class LockedFile; class LockedFile;
enum QtMsgType; enum QtMsgType;
@ -115,6 +116,7 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id);
__int64 lamexp_free_diskspace(const QString &path); __int64 lamexp_free_diskspace(const QString &path);
bool lamexp_remove_file(const QString &filename); bool lamexp_remove_file(const QString &filename);
bool lamexp_themes_enabled(void); bool lamexp_themes_enabled(void);
void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150);
//Debug-only functions //Debug-only functions
SIZE_T lamexp_dbg_private_bytes(void); SIZE_T lamexp_dbg_private_bytes(void);