summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-25 15:02:09 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-25 15:02:09 (GMT)
commitac2ea04e516fa7818cb7b4dbe7dd2619cec9fbda (patch)
treec832f0c4e66f3774a8cdb96ac74f9d94d44a007f
parentb6b251cb8b36be434cf878a916c15019fd65b6f0 (diff)
downloadQt-ac2ea04e516fa7818cb7b4dbe7dd2619cec9fbda.zip
Qt-ac2ea04e516fa7818cb7b4dbe7dd2619cec9fbda.tar.gz
Qt-ac2ea04e516fa7818cb7b4dbe7dd2619cec9fbda.tar.bz2
Some refactoring of windows specific code + a private class of animations
-rw-r--r--src/corelib/animation/qabstractanimation.cpp26
-rw-r--r--src/corelib/animation/qabstractanimation_p.h24
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp31
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp7
-rw-r--r--src/corelib/tools/qbytearray.cpp2
-rw-r--r--src/corelib/tools/qlocale.cpp4
-rw-r--r--src/gui/kernel/qapplication_win.cpp42
-rw-r--r--src/gui/kernel/qwindowdefs_win.h2
8 files changed, 56 insertions, 82 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 94a94d1..16307e6 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -188,32 +188,6 @@ void QUnifiedTimer::updateRecentlyStartedAnimations()
animationsToStart.clear();
}
-/*
- defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
-*/
-void QUnifiedTimer::setTimingInterval(int interval)
-{
- timingInterval = interval;
- if (animationTimer.isActive()) {
- //we changed the timing interval
- animationTimer.start(timingInterval, this);
- }
-}
-
-/*
- this allows to have a consistent timer interval at each tick from the timer
- not taking the real time that passed into account.
-*/
-void QUnifiedTimer::setConsistentTiming(bool b)
-{
- consistentTiming = b;
-}
-
-int QUnifiedTimer::elapsedTime() const
-{
- return lastTick;
-}
-
void QUnifiedTimer::timerEvent(QTimerEvent *event)
{
//this is simply the time we last received a tick
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index e64554c..7a4bfcf 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -101,21 +101,35 @@ private:
};
-class Q_CORE_EXPORT QUnifiedTimer : public QObject
+class QUnifiedTimer : public QObject
{
private:
QUnifiedTimer();
public:
- static QUnifiedTimer *instance();
+ //XXX this is needed by dui
+ static Q_CORE_EXPORT QUnifiedTimer *instance();
void registerAnimation(QAbstractAnimation *animation);
void unregisterAnimation(QAbstractAnimation *animation);
- void setTimingInterval(int interval);
- void setConsistentTiming(bool consistent);
+ //defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
+ void setTimingInterval(int interval)
+ {
+ timingInterval = interval;
+ if (animationTimer.isActive()) {
+ //we changed the timing interval
+ animationTimer.start(timingInterval, this);
+ }
+ }
+
+ /*
+ this allows to have a consistent timer interval at each tick from the timer
+ not taking the real time that passed into account.
+ */
+ void setConsistentTiming(bool consistent) { consistentTiming = consistent; }
- int elapsedTime() const;
+ int elapsedTime() const { return lastTick; }
protected:
void timerEvent(QTimerEvent *);
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 7ab91c9..9868c23 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -51,12 +51,11 @@
QT_BEGIN_NAMESPACE
-// ############### DON'T EXPORT HERE!!!
-Q_CORE_EXPORT char appFileName[MAX_PATH+1]; // application file name
-Q_CORE_EXPORT char theAppName[MAX_PATH+1]; // application name
-Q_CORE_EXPORT HINSTANCE appInst = 0; // handle to app instance
-Q_CORE_EXPORT HINSTANCE appPrevInst = 0; // handle to prev app instance
-Q_CORE_EXPORT int appCmdShow = 0;
+char appFileName[MAX_PATH+1]; // application file name
+char theAppName[MAX_PATH+1]; // application name
+HINSTANCE appInst = 0; // handle to app instance
+HINSTANCE appPrevInst = 0; // handle to prev app instance
+int appCmdShow = 0;
bool usingWinMain = false; // whether the qWinMain() is used or not
Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle
@@ -69,6 +68,12 @@ Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app
return appPrevInst;
}
+Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command
+{
+ return appCmdShow;
+}
+
+
void set_winapp_name()
{
static bool already_set = false;
@@ -89,6 +94,14 @@ void set_winapp_name()
int l = qstrlen(theAppName);
if ((l > 4) && !qstricmp(theAppName + l - 4, ".exe"))
theAppName[l-4] = '\0'; // drop .exe extension
+
+ if (appInst == 0) {
+ QT_WA({
+ appInst = GetModuleHandle(0);
+ }, {
+ appInst = GetModuleHandleA(0);
+ });
+ }
}
}
@@ -173,14 +186,14 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
// Create command line
- set_winapp_name();
-
argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc);
// Get Windows parameters
appInst = instance;
appPrevInst = prevInstance;
appCmdShow = cmdShow;
+
+ set_winapp_name();
}
/*!
@@ -618,7 +631,7 @@ QString valueCheck(uint actual, ...)
#ifdef Q_CC_BOR
-Q_CORE_EXPORT QString decodeMSG(const MSG& msg)
+QString decodeMSG(const MSG& msg)
{
return QString::fromLatin1("THis is not supported on Borland");
}
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index c4061f4..2dd5534 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -396,13 +396,6 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
{ return PostMessageA(hWnd, msg, wParam, lParam); });
}
-Q_CORE_EXPORT bool winGetMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
- UINT wMsgFilterMax)
-{
- QT_WA({ return GetMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax); } ,
- { return GetMessageA(msg, hWnd, wMsgFilterMin, wMsgFilterMax); });
-}
-
// This function is called by a workerthread
void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_PTR user, DWORD_PTR /*reserved*/, DWORD_PTR /*reserved*/)
{
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 6aa35f3..49dd52d 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -579,7 +579,7 @@ static inline char qToLower(char c)
return c;
}
-Q_CORE_EXPORT QByteArray::Data QByteArray::shared_null = {Q_BASIC_ATOMIC_INITIALIZER(1),
+QByteArray::Data QByteArray::shared_null = {Q_BASIC_ATOMIC_INITIALIZER(1),
0, 0, shared_null.array, {0} };
QByteArray::Data QByteArray::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
0, 0, shared_empty.array, {0} };
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 23c6ffb..248137a 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -120,7 +120,7 @@ static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt,
Q_CORE_EXPORT char *qdtoa(double d, int mode, int ndigits, int *decpt,
int *sign, char **rve, char **digits_str);
Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
-Q_CORE_EXPORT qlonglong qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok);
+static qlonglong qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok);
static qulonglong qstrtoull(const char *nptr, const char **endptr, register int base, bool *ok);
/******************************************************************************
@@ -4671,7 +4671,7 @@ static qulonglong qstrtoull(const char *nptr, const char **endptr, register int
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
-Q_CORE_EXPORT qlonglong qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok)
+static qlonglong qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok)
{
register const char *s;
register qulonglong acc;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 6237657..77625de 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -376,11 +376,6 @@ QRgb qt_colorref2qrgb(COLORREF col)
Internal variables and functions
*****************************************************************************/
-extern Q_CORE_EXPORT char theAppName[];
-extern Q_CORE_EXPORT char appFileName[];
-extern Q_CORE_EXPORT HINSTANCE appInst; // handle to app instance
-extern Q_CORE_EXPORT HINSTANCE appPrevInst; // handle to prev app instance
-extern Q_CORE_EXPORT int appCmdShow; // main window show command
static HWND curWin = 0; // current window
static HDC displayDC = 0; // display device context
@@ -752,20 +747,11 @@ void qt_init(QApplicationPrivate *priv, int)
priv->argc = j;
}
- // Get the application name/instance if qWinMain() was not invoked
#ifndef Q_WS_WINCE
// No message boxes but important ones
SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
#endif
- if (appInst == 0) {
- QT_WA({
- appInst = GetModuleHandle(0);
- }, {
- appInst = GetModuleHandleA(0);
- });
- }
-
#ifndef Q_WS_WINCE
// Initialize OLE/COM
// S_OK means success and S_FALSE means that it has already
@@ -790,7 +776,7 @@ void qt_init(QApplicationPrivate *priv, int)
#ifndef QT_NO_CURSOR
QCursorData::initialize();
#endif
- qApp->setObjectName(QLatin1String(theAppName));
+ qApp->setObjectName(priv->appName());
#if !defined(Q_WS_WINCE)
// default font
@@ -888,12 +874,6 @@ void qt_cleanup()
Platform specific global and internal functions
*****************************************************************************/
-Q_GUI_EXPORT int qWinAppCmdShow() // get main window show command
-{
- return appCmdShow;
-}
-
-
Q_GUI_EXPORT HDC qt_win_display_dc() // get display DC
{
Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());
@@ -989,11 +969,11 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (classExists == -1) {
QT_WA({
WNDCLASS wcinfo;
- classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo);
+ classExists = GetClassInfo(qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
}, {
WNDCLASSA wcinfo;
- classExists = GetClassInfoA((HINSTANCE)qWinAppInst(), cname.toLatin1(), &wcinfo);
+ classExists = GetClassInfoA(qWinAppInst(), cname.toLatin1(), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
});
}
@@ -1013,9 +993,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
+ wc.hInstance = qWinAppInst();
if (icon) {
- wc.hIcon = LoadIcon(appInst, L"IDI_ICON1");
+ wc.hIcon = LoadIcon(qWinAppInst(), L"IDI_ICON1");
if (!wc.hIcon)
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
} else {
@@ -1032,9 +1012,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
+ wc.hInstance = qWinAppInst();
if (icon) {
- wc.hIcon = LoadIconA(appInst, (char*)"IDI_ICON1");
+ wc.hIcon = LoadIconA(qWinAppInst(), (char*)"IDI_ICON1");
if (!wc.hIcon)
wc.hIcon = LoadIconA(0, (char*)IDI_APPLICATION);
} else {
@@ -1053,9 +1033,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = (HINSTANCE)qWinAppInst();
+ wc.hInstance = qWinAppInst();
if (icon) {
- wc.hIcon = LoadIcon(appInst, L"IDI_ICON1");
+ wc.hIcon = LoadIcon(qWinAppInst(), L"IDI_ICON1");
// if (!wc.hIcon)
// wc.hIcon = LoadIcon(0, IDI_APPLICATION);
} else {
@@ -1089,9 +1069,9 @@ static void unregWinClasses()
QHash<QString, int>::ConstIterator it = hash->constBegin();
while (it != hash->constEnd()) {
QT_WA({
- UnregisterClass((TCHAR*)it.key().utf16(), (HINSTANCE)qWinAppInst());
+ UnregisterClass((TCHAR*)it.key().utf16(), qWinAppInst());
} , {
- UnregisterClassA(it.key().toLatin1(), (HINSTANCE)qWinAppInst());
+ UnregisterClassA(it.key().toLatin1(), qWinAppInst());
});
++it;
}
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h
index 3899c23..a24afd4 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/gui/kernel/qwindowdefs_win.h
@@ -122,7 +122,7 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT HINSTANCE qWinAppInst();
Q_CORE_EXPORT HINSTANCE qWinAppPrevInst();
-Q_GUI_EXPORT int qWinAppCmdShow();
+Q_CORE_EXPORT int qWinAppCmdShow();
Q_GUI_EXPORT HDC qt_win_display_dc();
QT_END_NAMESPACE