summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-08-10 06:56:35 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-08-10 06:56:35 (GMT)
commitf61ec84fc296c6f70011e30788ee511d6b6a18c6 (patch)
tree54b3b81ac83570e65dc9b44b6756005f6ba1efde /src/gui/kernel
parentcc0a411e5e874aa224c26298a109973cb15ea291 (diff)
parentd13418effc5f00474541ae513a30c9a42c2a1cb3 (diff)
downloadQt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.zip
Qt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.tar.gz
Qt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.tar.bz2
Merge commit 'qt/master-stable'
Conflicts: src/corelib/kernel/qobject.cpp src/corelib/tools/qsharedpointer_impl.h src/gui/widgets/qdatetimeedit.cpp src/gui/widgets/qlinecontrol.cpp src/gui/widgets/qlineedit.cpp tests/auto/qcssparser/qcssparser.pro tests/auto/qicoimageformat/tst_qicoimageformat.cpp tests/auto/qmultiscreen/qmultiscreen.pro tests/auto/qresourceengine/qresourceengine.pro tests/auto/qresourceengine/tst_qresourceengine.cpp tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication_p.h15
-rw-r--r--src/gui/kernel/qapplication_win.cpp13
-rw-r--r--src/gui/kernel/qapplication_x11.cpp202
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm54
-rw-r--r--src/gui/kernel/qdesktopwidget_x11.cpp26
-rw-r--r--src/gui/kernel/qevent_p.h10
-rw-r--r--src/gui/kernel/qgesture.cpp50
-rw-r--r--src/gui/kernel/qgesture.h2
-rw-r--r--src/gui/kernel/qkde.cpp159
-rw-r--r--src/gui/kernel/qkde_p.h76
-rw-r--r--src/gui/kernel/qstandardgestures.cpp74
-rw-r--r--src/gui/kernel/qt_x11_p.h3
-rw-r--r--src/gui/kernel/qwidget.cpp24
-rw-r--r--src/gui/kernel/qwidget_mac.mm6
-rw-r--r--src/gui/kernel/qwidget_p.h1
-rw-r--r--src/gui/kernel/qwidget_win.cpp56
17 files changed, 502 insertions, 275 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 1766ecd..531c283 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -121,7 +121,8 @@ unix:x11 {
INCLUDEPATH += ../3rdparty/xorg
HEADERS += \
kernel/qx11embed_x11.h \
- kernel/qx11info_x11.h
+ kernel/qx11info_x11.h \
+ kernel/qkde_p.h
SOURCES += \
kernel/qapplication_x11.cpp \
@@ -135,7 +136,8 @@ unix:x11 {
kernel/qwidgetcreate_x11.cpp \
kernel/qx11embed_x11.cpp \
kernel/qx11info_x11.cpp \
- kernel/qkeymapper_x11.cpp
+ kernel/qkeymapper_x11.cpp \
+ kernel/qkde.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 0cd93b9..dc8ea6c 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -235,6 +235,8 @@ typedef struct tagGESTUREINFO
# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
+# define GC_ZOOM 0x00000001
+
typedef struct tagGESTURECONFIG
{
DWORD dwID;
@@ -248,11 +250,12 @@ typedef struct tagGESTURECONFIG
class QPanGesture;
class QPinchGesture;
-struct StandardGestures
+struct QStandardGestures
{
QPanGesture *pan;
QPinchGesture *pinch;
- StandardGestures() : pan(0), pinch(0) { }
+
+ QStandardGestures() : pan(0), pinch(0) { }
};
@@ -282,7 +285,6 @@ public:
#if defined(Q_WS_X11)
#ifndef QT_NO_SETTINGS
- static QString kdeHome();
static QString x11_desktop_style();
static bool x11_apply_settings();
#endif
@@ -519,6 +521,9 @@ public:
QTouchEvent::DeviceType deviceType,
const QList<QTouchEvent::TouchPoint> &touchPoints);
+ typedef QMap<QWidget*, QStandardGestures> WidgetStandardGesturesMap;
+ WidgetStandardGesturesMap widgetGestures;
+
#if defined(Q_WS_WIN)
static PtrRegisterTouchWindow RegisterTouchWindow;
static PtrGetTouchInputInfo GetTouchInputInfo;
@@ -528,10 +533,6 @@ public:
QList<QTouchEvent::TouchPoint> appAllTouchPoints;
bool translateTouchEvent(const MSG &msg);
- typedef QMap<QWidget*, StandardGestures> WidgetStandardGesturesMap;
- WidgetStandardGesturesMap widgetGestures;
- ulong lastGestureId;
-
PtrGetGestureInfo GetGestureInfo;
PtrGetGestureExtraArgs GetGestureExtraArgs;
PtrCloseGestureInfoHandle CloseGestureInfoHandle;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 2bded5c..bdee6ec 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -815,8 +815,6 @@ void qt_init(QApplicationPrivate *priv, int)
ptrSetProcessDPIAware();
#endif
- priv->lastGestureId = 0;
-
priv->GetGestureInfo =
(PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
"GetGestureInfo");
@@ -3718,13 +3716,8 @@ bool QETWidget::translateCloseEvent(const MSG &)
bool QETWidget::translateGestureEvent(const MSG &msg)
{
GESTUREINFO gi;
+ memset(&gi, 0, sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
- gi.dwFlags = 0;
- gi.ptsLocation.x = 0;
- gi.ptsLocation.y = 0;
- gi.dwID = 0;
- gi.dwInstanceID = 0;
- gi.dwSequenceID = 0;
QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
@@ -3747,7 +3740,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
event.gestureType = QNativeGestureEvent::GestureEnd;
break;
case GID_ZOOM:
- event.gestureType = QNativeGestureEvent::Pinch;
+ event.gestureType = QNativeGestureEvent::Zoom;
break;
case GID_PAN:
event.gestureType = QNativeGestureEvent::Pan;
@@ -3758,6 +3751,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
default:
break;
}
+ qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
if (event.gestureType != QNativeGestureEvent::None)
qt_sendSpontaneousEvent(widget, &event);
} else {
@@ -3765,7 +3759,6 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
if (dwErr > 0)
qWarning() << "translateGestureEvent: error = " << dwErr;
}
- qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
return true;
}
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 4016563..32e7e3c 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -83,6 +83,7 @@
#include "qtimer.h"
#include "qlibrary.h"
#include <private/qgraphicssystemfactory_p.h>
+#include "qkde_p.h"
#if !defined (QT_NO_TABLET)
extern "C" {
@@ -813,33 +814,6 @@ Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps()
PropModeReplace, (unsigned char *)stamp.data(), stamp.size());
}
-static int kdeSessionVersion()
-{
- static int kdeVersion = 0;
- if (!kdeVersion)
- kdeVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
- return kdeVersion;
-}
-
-/*! \internal
- Gets the current KDE 3 or 4 home path
-*/
-QString QApplicationPrivate::kdeHome()
-{
- static QString kdeHomePath;
- if (kdeHomePath.isEmpty()) {
- kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
- if (kdeHomePath.isEmpty()) {
- QDir homeDir(QDir::homePath());
- QString kdeConfDir(QLatin1String("/.kde"));
- if (4 == kdeSessionVersion() && homeDir.exists(QLatin1String(".kde4")))
- kdeConfDir = QLatin1String("/.kde4");
- kdeHomePath = QDir::homePath() + kdeConfDir;
- }
- }
- return kdeHomePath;
-}
-
/*! \internal
apply the settings to the application
*/
@@ -905,8 +879,8 @@ bool QApplicationPrivate::x11_apply_settings()
QFont font(QApplication::font());
QString fontDescription;
// Override Qt font if KDE4 settings can be used
- if (4 == kdeSessionVersion()) {
- QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+ if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) {
+ QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
fontDescription = kdeSettings.value(QLatin1String("font")).toString();
if (fontDescription.isEmpty()) {
// KDE stores fonts without quotes
@@ -936,7 +910,6 @@ bool QApplicationPrivate::x11_apply_settings()
// read new QStyle
QString stylename = settings.value(QLatin1String("style")).toString();
-
if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && X11->use_xrender) {
stylename = x11_desktop_style();
}
@@ -1094,22 +1067,6 @@ static void qt_set_input_encoding()
XFree((char *)data);
}
-// Reads a KDE color setting
-static QColor kdeColor(const QString &key, const QSettings &kdeSettings)
-{
- QVariant variant = kdeSettings.value(key);
- if (variant.isValid()) {
- QStringList values = variant.toStringList();
- if (values.size() == 3) {
- int r = values[0].toInt();
- int g = values[1].toInt();
- int b = values[2].toInt();
- return QColor(r, g, b);
- }
- }
- return QColor();
-}
-
// set font, foreground and background from x11 resources. The
// arguments may override the resource settings.
static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
@@ -1276,9 +1233,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
QApplicationPrivate::setSystemFont(fnt);
}
+ // QGtkStyle sets it's own system palette
+ bool gtkStyle = QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle");
bool kdeColors = (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE);
-
- if (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty())) {// set app colors
+ if (!gtkStyle && (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty()))) {// set app colors
bool allowX11ColorNames = QColor::allowX11ColorNames();
QColor::setAllowX11ColorNames(true);
@@ -1314,45 +1272,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
bright_mode = true;
}
- if (kdeColors) {
- const QSettings theKdeSettings(
- QApplicationPrivate::kdeHome()
- + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-
- // Setup KDE palette
- QColor color;
- color = kdeColor(QLatin1String("buttonBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- btn = color;
-
- color = kdeColor(QLatin1String("background"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- bg = color;
-
- color = kdeColor(QLatin1String("foreground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/ForegroundNormal"), theKdeSettings);
- if (color.isValid()) {
- fg = color;
- }
-
- color = kdeColor(QLatin1String("windowForeground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal"), theKdeSettings);
- if (color.isValid())
- wfg = color;
-
- color = kdeColor(QLatin1String("windowBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- base = color;
- }
-
QPalette pal(fg, btn, btn.lighter(125), btn.darker(130), btn.darker(120), wfg.isValid() ? wfg : fg, Qt::white, base, bg);
QColor disabled((fg.red() + btn.red()) / 2,
(fg.green() + btn.green())/ 2,
@@ -1365,50 +1284,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
highlight = QColor(selectBackground);
highlightText = QColor(selectForeground);
}
- // Use KDE3 or KDE4 color settings if present
- if (kdeColors) {
- const QSettings theKdeSettings(
- QApplicationPrivate::kdeHome()
- + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-
- QColor color = kdeColor(QLatin1String("selectBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- highlight = color;
-
- color = kdeColor(QLatin1String("selectForeground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal"), theKdeSettings);
- if (color.isValid())
- highlightText = color;
-
- color = kdeColor(QLatin1String("alternateBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::AlternateBase, color);
- else
- pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110));
-
- color = kdeColor(QLatin1String("buttonForeground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::ButtonText, color);
-
- color = kdeColor(QLatin1String("linkColor"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/ForegroundLink"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::Link, color);
-
- color = kdeColor(QLatin1String("visitedLinkColor"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/ForegroundVisited"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::LinkVisited, color);
- }
if (highlight.isValid() && highlightText.isValid()) {
pal.setColor(QPalette::Highlight, highlight);
@@ -1431,10 +1306,9 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
}
- // QGtkStyle sets it's own system palette
- if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
- QApplicationPrivate::setSystemPalette(pal);
- }
+ if (kdeColors)
+ pal = QKde::kdePalette().resolve(pal);
+ QApplicationPrivate::setSystemPalette(pal);
QColor::setAllowX11ColorNames(allowX11ColorNames);
}
@@ -2315,6 +2189,7 @@ void qt_init(QApplicationPrivate *priv, int,
X11->compositingManagerRunning = XGetSelectionOwner(X11->display,
ATOM(_NET_WM_CM_S0));
X11->desktopEnvironment = DE_UNKNOWN;
+ X11->desktopVersion = 0;
// See if the current window manager is using the freedesktop.org spec to give its name
Window windowManagerWindow = XNone;
@@ -2390,6 +2265,9 @@ void qt_init(QApplicationPrivate *priv, int,
XFree((char *)data);
}
+ if (X11->desktopEnvironment == DE_KDE)
+ X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
+
qt_set_input_encoding();
qt_set_x11_resources(appFont, appFGCol, appBGCol, appBTNCol);
@@ -2657,44 +2535,30 @@ void qt_init(QApplicationPrivate *priv, int,
QString QApplicationPrivate::x11_desktop_style()
{
QString stylename;
- QStringList availableStyles = QStyleFactory::keys();
- // Override Qt style if KDE4 settings can be used
- if (4 == kdeSessionVersion()) {
- QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
- QString kde4Style = kdeSettings.value(QLatin1String("widgetStyle"),
- QLatin1String("Oxygen")).toString();
- foreach (const QString &style, availableStyles) {
- if (style.toLower() == kde4Style.toLower())
- stylename = kde4Style;
- }
- // Set QGtkStyle for GNOME
- } else if (X11->desktopEnvironment == DE_GNOME) {
+ switch(X11->desktopEnvironment) {
+ case DE_KDE:
+ stylename = QKde::kdeStyle();
+ break;
+ case DE_GNOME: {
+ QStringList availableStyles = QStyleFactory::keys();
+ // Set QGtkStyle for GNOME if available
QString gtkStyleKey = QString::fromLatin1("GTK+");
- if (availableStyles.contains(gtkStyleKey))
+ if (availableStyles.contains(gtkStyleKey)) {
stylename = gtkStyleKey;
- }
-
- if (stylename.isEmpty()) {
- switch(X11->desktopEnvironment) {
- case DE_KDE:
- if (X11->use_xrender)
- stylename = QLatin1String("plastique");
- else
- stylename = QLatin1String("windows");
- break;
- case DE_GNOME:
- if (X11->use_xrender)
- stylename = QLatin1String("cleanlooks");
- else
- stylename = QLatin1String("windows");
- break;
- case DE_CDE:
- stylename = QLatin1String("cde");
- break;
- default:
- // Don't do anything
break;
}
+ if (X11->use_xrender)
+ stylename = QLatin1String("cleanlooks");
+ else
+ stylename = QLatin1String("windows");
+ break;
+ }
+ case DE_CDE:
+ stylename = QLatin1String("cde");
+ break;
+ default:
+ // Don't do anything
+ break;
}
return stylename;
}
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 1d352cb..8c6f394 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -50,6 +50,7 @@
#include <private/qdnd_p.h>
#include <private/qmacinputcontext_p.h>
#include <private/qmultitouch_mac_p.h>
+#include <private/qevent_p.h>
#include <qscrollarea.h>
#include <qhash.h>
@@ -868,32 +869,65 @@ extern "C" {
- (void)magnifyWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "magnifyWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Zoom;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.percentage = [event magnification];
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)rotateWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "rotateWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Rotate;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.percentage = [event rotation];
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)swipeWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "swipeWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Swipe;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]);
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)beginGestureWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "beginGestureWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)endGestureWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "endGestureWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qApp->sendEvent(qwidget, &qNGEvent);
}
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp
index 5bc4c0c..ad47709 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/gui/kernel/qdesktopwidget_x11.cpp
@@ -285,26 +285,36 @@ const QRect QDesktopWidget::availableGeometry(int screen) const
if (d->workareas[screen].isValid())
return d->workareas[screen];
- if ((d->screenCount == 1 || !isVirtualDesktop())
- && X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+ if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+ int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen;
+
Atom ret;
int format, e;
unsigned char *data = 0;
unsigned long nitems, after;
e = XGetWindowProperty(X11->display,
- QX11Info::appRootWindow(screen),
- ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
- &ret, &format, &nitems, &after, &data);
+ QX11Info::appRootWindow(x11Screen),
+ ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
+ &ret, &format, &nitems, &after, &data);
+ QRect workArea;
if (e == Success && ret == XA_CARDINAL &&
format == 32 && nitems == 4) {
long *workarea = (long *) data;
- d->workareas[screen].setRect(workarea[0], workarea[1],
- workarea[2], workarea[3]);
+ workArea = QRect(workarea[0], workarea[1], workarea[2], workarea[3]);
} else {
- d->workareas[screen] = screenGeometry(screen);
+ workArea = screenGeometry(screen);
+ }
+
+ if (isVirtualDesktop()) {
+ // intersect the workarea (which spawns all Xinerama screens) with the rect for the
+ // requested screen
+ workArea &= screenGeometry(screen);
}
+
+ d->workareas[screen] = workArea;
+
if (data)
XFree(data);
} else {
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 92c4fc1..b21b35c 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -127,11 +127,13 @@ public:
GestureBegin,
GestureEnd,
Pan,
- Pinch
+ Zoom,
+ Rotate,
+ Swipe
};
QNativeGestureEvent()
- : QEvent(QEvent::NativeGesture), gestureType(None)
+ : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0), direction(0, 0)
#ifdef Q_WS_WIN
, sequenceId(0)
#endif
@@ -139,8 +141,10 @@ public:
}
Type gestureType;
-#ifdef Q_WS_WIN
+ float percentage;
QPoint position;
+ QSize direction;
+#ifdef Q_WS_WIN
ulong sequenceId;
#endif
};
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 32ac4f8..38e8851 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -97,7 +97,7 @@ private:
This is a base class, to create a custom gesture type, you should subclass
it and implement its pure virtual functions.
- \sa QPanGesture, QTapAndHoldGesture
+ \sa QPanGesture
*/
/*! \fn bool QGesture::filterEvent(QEvent *event)
@@ -197,11 +197,44 @@ Qt::GestureState QGesture::state() const
}
/*!
- Sets this gesture's recognition state to \a state.
+ Sets this gesture's recognition state to \a state and emits appropriate
+ signals.
+
+ This functions emits the signals according to the old state and the new
+ \a state, and it should be called after all the internal properties have been
+ initialized.
+
+ \sa started, triggered, finished, cancelled
*/
-void QGesture::setState(Qt::GestureState state)
+void QGesture::updateState(Qt::GestureState state)
{
- d_func()->state = state;
+ Q_D(QGesture);
+ if (d->state == state) {
+ if (state == Qt::GestureUpdated)
+ emit triggered();
+ return;
+ }
+ const Qt::GestureState oldState = d->state;
+ d->state = state;
+ if (state != Qt::NoGesture && oldState > state) {
+ // comparing the state as ints: state should only be changed from
+ // started to (optionally) updated and to finished.
+ qWarning("QGesture::updateState: incorrect new state");
+ return;
+ }
+ if (oldState == Qt::NoGesture)
+ emit started();
+ if (state == Qt::GestureUpdated)
+ emit triggered();
+ else if (state == Qt::GestureFinished)
+ emit finished();
+ else if (state == Qt::NoGesture)
+ emit cancelled();
+
+ if (state == Qt::GestureFinished) {
+ // gesture is finished, so we reset the internal state.
+ d->state = Qt::NoGesture;
+ }
}
/*!
@@ -238,14 +271,13 @@ QGraphicsItem* QGesture::graphicsItem() const
Resets the internal state of the gesture. This function might be called by
the filterEvent() implementation in a derived class, or by the user to
- cancel a gesture. The base class implementation emits the cancelled()
- signal if the state() of the gesture wasn't empty.
+ cancel a gesture. The base class implementation calls
+ updateState(Qt::NoGesture) which emits the cancelled()
+ signal if the state() of the gesture indicated it was active.
*/
void QGesture::reset()
{
- if (state() != Qt::NoGesture)
- emit cancelled();
- setState(Qt::NoGesture);
+ updateState(Qt::NoGesture);
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index 0735160..7da37c4 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -81,7 +81,7 @@ protected:
QGesture(QGesturePrivate &dd, QObject *parent);
bool eventFilter(QObject*, QEvent*);
- void setState(Qt::GestureState state);
+ void updateState(Qt::GestureState state);
Q_SIGNALS:
void started();
diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp
new file mode 100644
index 0000000..96ff21e
--- /dev/null
+++ b/src/gui/kernel/qkde.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qkde_p.h"
+#include <QtCore/QLibrary>
+#include <QtCore/QDir>
+#include <QtCore/qdebug.h>
+#include <QtCore/QSettings>
+#include "QtGui/qstylefactory.h"
+#include "qt_x11_p.h"
+
+#if defined(Q_WS_X11)
+
+QT_BEGIN_NAMESPACE
+
+/*! \internal
+Gets the current KDE home path
+like "/home/troll/.kde"
+*/
+QString QKde::kdeHome()
+{
+ static QString kdeHomePath;
+ if (kdeHomePath.isEmpty()) {
+ kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
+ if (kdeHomePath.isEmpty()) {
+ QDir homeDir(QDir::homePath());
+ QString kdeConfDir(QLatin1String("/.kde"));
+ if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
+ kdeConfDir = QLatin1String("/.kde4");
+ kdeHomePath = QDir::homePath() + kdeConfDir;
+ }
+ }
+ return kdeHomePath;
+}
+
+/*!\internal
+ Reads the color from the config, and store it in the palette with the given color role if found
+ */
+static bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QSettings &kdeSettings, const QString &kde4Key, const QString &kde3Key = QString())
+{
+ QVariant variant = kdeSettings.value(kde4Key);
+ if (!variant.isValid())
+ QVariant variant = kdeSettings.value(kde3Key);
+ if (variant.isValid()) {
+ QStringList values = variant.toStringList();
+ if (values.size() == 3) {
+ int r = values[0].toInt();
+ int g = values[1].toInt();
+ int b = values[2].toInt();
+ pal->setBrush(role, QColor(r, g, b));
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/*!\internal
+ Returns the KDE palette
+*/
+QPalette QKde::kdePalette()
+{
+ const QSettings theKdeSettings(QKde::kdeHome() +
+ QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+ QPalette pal;
+
+ // Setup KDE palette
+ kdeColor(&pal, QPalette::Button, theKdeSettings, QLatin1String("Colors:Button/BackgroundNormal"), QLatin1String("buttonBackground"));
+ kdeColor(&pal, QPalette::Window, theKdeSettings, QLatin1String("Colors:Window/BackgroundNormal"), QLatin1String("background"));
+ kdeColor(&pal, QPalette::Text, theKdeSettings, QLatin1String("Colors:View/ForegroundNormal"), QLatin1String("foreground"));
+ kdeColor(&pal, QPalette::WindowText, theKdeSettings, QLatin1String("Colors:Window/ForegroundNormal"), QLatin1String("windowForeground"));
+ kdeColor(&pal, QPalette::Base, theKdeSettings, QLatin1String("Colors:View/BackgroundNormal"), QLatin1String("windowBackground"));
+ kdeColor(&pal, QPalette::Highlight, theKdeSettings, QLatin1String("Colors:Selection/BackgroundNormal"), QLatin1String("selectBackground"));
+ kdeColor(&pal, QPalette::HighlightedText, theKdeSettings, QLatin1String("Colors:Selection/ForegroundNormal"), QLatin1String("selectForeground"));
+ kdeColor(&pal, QPalette::AlternateBase, theKdeSettings, QLatin1String("Colors:View/BackgroundAlternate"), QLatin1String("alternateBackground"));
+ kdeColor(&pal, QPalette::ButtonText, theKdeSettings, QLatin1String("Colors:Button/ForegroundNormal"), QLatin1String("buttonForeground"));
+ kdeColor(&pal, QPalette::Link, theKdeSettings, QLatin1String("Colors:View/ForegroundLink"), QLatin1String("linkColor"));
+ kdeColor(&pal, QPalette::LinkVisited, theKdeSettings, QLatin1String("Colors:View/ForegroundVisited"), QLatin1String("visitedLinkColor"));
+ //## TODO tooltip color
+
+ return pal;
+}
+
+/*!\internal
+ Returns the name of the QStyle to use.
+ (read from the kde config if needed)
+*/
+QString QKde::kdeStyle()
+{
+ if (X11->desktopVersion >= 4) {
+ QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+ QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString();
+
+ QStringList availableStyles = QStyleFactory::keys();
+ if(availableStyles.contains(style, Qt::CaseInsensitive))
+ return style;
+ }
+
+ if (X11->use_xrender)
+ return QLatin1String("plastique");
+ else
+ return QLatin1String("windows");
+
+ return QString();
+}
+
+/*!\internal
+ placeholder to load icon from kde.
+ to be implemented
+ */
+QIcon QKde::kdeIcon(const QString &name)
+{
+ //###todo
+ return QIcon();
+}
+
+QT_END_NAMESPACE
+
+#endif //Q_WS_X11
+
diff --git a/src/gui/kernel/qkde_p.h b/src/gui/kernel/qkde_p.h
new file mode 100644
index 0000000..ac760bd
--- /dev/null
+++ b/src/gui/kernel/qkde_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKDE_H
+#define QKDE_H
+
+#include <QtCore/qglobal.h>
+#include <QtGui/QPalette>
+#include <QtGui/QIcon>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#if defined(Q_WS_X11)
+
+
+QT_BEGIN_NAMESPACE
+
+// This namespace contains helper function to help KDE integration
+namespace QKde {
+ QString kdeHome();
+ QString kdeStyle();
+ QPalette kdePalette();
+ QIcon kdeIcon(const QString &name);
+}
+
+
+QT_END_NAMESPACE
+
+#endif // Q_WS_X11
+#endif // QKDE_H
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 4753416..7078dbf 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -46,11 +46,12 @@
#include <qscrollbar.h>
#include <private/qapplication_p.h>
#include <private/qevent_p.h>
+#include <private/qwidget_p.h>
QT_BEGIN_NAMESPACE
#ifdef Q_WS_WIN
-QApplicationPrivate* getQApplicationPrivateInternal();
+QWidgetPrivate *qt_widget_private(QWidget *widget);
#endif
/*!
@@ -71,32 +72,38 @@ QApplicationPrivate* getQApplicationPrivateInternal();
QPanGesture::QPanGesture(QWidget *parent)
: QGesture(*new QPanGesturePrivate, parent)
{
-#ifdef Q_WS_WIN
if (parent) {
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
qAppPriv->widgetGestures[parent].pan = this;
- }
+#ifdef Q_WS_WIN
+ qt_widget_private(parent)->winSetupGestures();
#endif
+ }
}
/*! \internal */
bool QPanGesture::event(QEvent *event)
{
-#ifdef Q_WS_WIN
- QApplicationPrivate* getQApplicationPrivateInternal();
switch (event->type()) {
case QEvent::ParentAboutToChange:
- if (QWidget *w = qobject_cast<QWidget*>(parent()))
- getQApplicationPrivateInternal()->widgetGestures[w].pan = 0;
+ if (QWidget *w = qobject_cast<QWidget*>(parent())) {
+ QApplicationPrivate::instance()->widgetGestures[w].pan = 0;
+#ifdef Q_WS_WIN
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
break;
case QEvent::ParentChange:
- if (QWidget *w = qobject_cast<QWidget*>(parent()))
- getQApplicationPrivateInternal()->widgetGestures[w].pan = this;
+ if (QWidget *w = qobject_cast<QWidget*>(parent())) {
+ QApplicationPrivate::instance()->widgetGestures[w].pan = this;
+#ifdef Q_WS_WIN
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
break;
default:
break;
}
-#endif
#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
Q_D(QPanGesture);
@@ -106,9 +113,7 @@ bool QPanGesture::event(QEvent *event)
killTimer(d->panFinishedTimer);
d->panFinishedTimer = 0;
d->lastOffset = QSize(0, 0);
- setState(Qt::GestureFinished);
- emit triggered();
- setState(Qt::NoGesture);
+ updateState(Qt::GestureFinished);
}
}
#endif
@@ -119,38 +124,37 @@ bool QPanGesture::event(QEvent *event)
bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
{
#ifdef Q_WS_WIN
+ Q_D(QPanGesture);
if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
QApplicationPrivate::WidgetStandardGesturesMap::iterator it;
it = qAppPriv->widgetGestures.find(static_cast<QWidget*>(receiver));
if (it == qAppPriv->widgetGestures.end())
return false;
QPanGesture *gesture = it.value().pan;
- if (!gesture)
+ if (this != gesture)
return false;
- Qt::GestureState nextState = state();
+ Qt::GestureState nextState = Qt::NoGesture;
switch(ev->gestureType) {
case QNativeGestureEvent::GestureBegin:
// next we might receive the first gesture update event, so we
// prepare for it.
- setState(Qt::GestureStarted);
+ d->state = Qt::NoGesture;
return false;
case QNativeGestureEvent::Pan:
nextState = Qt::GestureUpdated;
+ event->accept();
break;
case QNativeGestureEvent::GestureEnd:
- if (state() != QNativeGestureEvent::Pan)
+ if (state() == Qt::NoGesture)
return false; // some other gesture has ended
- setState(Qt::GestureFinished);
nextState = Qt::GestureFinished;
break;
default:
return false;
}
- QPanGesturePrivate *d = gesture->d_func();
- if (state() == Qt::GestureStarted) {
- d->lastPosition = ev->position;
+ if (state() == Qt::NoGesture) {
d->lastOffset = d->totalOffset = QSize();
} else {
d->lastOffset = QSize(ev->position.x() - d->lastPosition.x(),
@@ -158,14 +162,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
d->totalOffset += d->lastOffset;
}
d->lastPosition = ev->position;
-
- if (state() == Qt::GestureStarted)
- emit gesture->started();
- emit gesture->triggered();
- if (state() == Qt::GestureFinished)
- emit gesture->finished();
- event->accept();
- gesture->setState(nextState);
+ gesture->updateState(nextState);
return true;
}
#endif
@@ -185,7 +182,6 @@ bool QPanGesture::filterEvent(QEvent *event)
d->lastOffset = d->totalOffset = QSize();
} else if (event->type() == QEvent::TouchEnd) {
if (state() != Qt::NoGesture) {
- setState(Qt::GestureFinished);
if (!ev->touchPoints().isEmpty()) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
const QPoint pos = p.pos().toPoint();
@@ -194,10 +190,8 @@ bool QPanGesture::filterEvent(QEvent *event)
d->lastOffset = QSize(pos.x() - lastPos.x(), pos.y() - lastPos.y());
d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y());
}
- emit triggered();
- emit finished();
+ updateState(Qt::GestureFinished);
}
- setState(Qt::NoGesture);
reset();
} else if (event->type() == QEvent::TouchUpdate) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
@@ -208,11 +202,7 @@ bool QPanGesture::filterEvent(QEvent *event)
d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y());
if (d->totalOffset.width() > 10 || d->totalOffset.height() > 10 ||
d->totalOffset.width() < -10 || d->totalOffset.height() < -10) {
- if (state() == Qt::NoGesture)
- setState(Qt::GestureStarted);
- else
- setState(Qt::GestureUpdated);
- emit triggered();
+ updateState(Qt::GestureUpdated);
}
}
#ifdef Q_OS_MAC
@@ -231,16 +221,14 @@ bool QPanGesture::filterEvent(QEvent *event)
d->lastOffset = wev->orientation() == Qt::Horizontal ? QSize(offset, 0) : QSize(0, offset);
if (state() == Qt::NoGesture) {
- setState(Qt::GestureStarted);
d->totalOffset = d->lastOffset;
} else {
- setState(Qt::GestureUpdated);
d->totalOffset += d->lastOffset;
}
killTimer(d->panFinishedTimer);
d->panFinishedTimer = startTimer(200);
- emit triggered();
+ updateState(Qt::GestureUpdated);
#endif
return true;
}
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 1ac51e0..44652d3 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -515,7 +515,8 @@ struct QX11Data
char *startupId;
- DesktopEnvironment desktopEnvironment;
+ DesktopEnvironment desktopEnvironment : 8;
+ uint desktopVersion : 8; /* Used only for KDE */
/* Warning: if you modify this list, modify the names of atoms in qapplication_x11.cpp as well! */
enum X11Atom {
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index a8157d5..b0564bd 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -3573,27 +3573,27 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh)
}
}
#endif
+ int mw = minw, mh = minh;
+ if (mw == QWIDGETSIZE_MAX)
+ mw = 0;
+ if (mh == QWIDGETSIZE_MAX)
+ mh = 0;
if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) {
qWarning("QWidget::setMinimumSize: (%s/%s) "
"The largest allowed size is (%d,%d)",
q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
QWIDGETSIZE_MAX);
- minw = qMin<int>(minw, QWIDGETSIZE_MAX);
- minh = qMin<int>(minh, QWIDGETSIZE_MAX);
+ minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX);
+ minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX);
}
if (minw < 0 || minh < 0) {
qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) "
"are not possible",
q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh);
- minw = qMax(minw, 0);
- minh = qMax(minh, 0);
+ minw = mw = qMax(minw, 0);
+ minh = mh = qMax(minh, 0);
}
createExtra();
- int mw = minw, mh = minh;
- if (mw == QWIDGETSIZE_MAX)
- mw = 0;
- if (mh == QWIDGETSIZE_MAX)
- mh = 0;
if (extra->minw == mw && extra->minh == mh)
return false;
extra->minw = mw;
@@ -8120,10 +8120,12 @@ void QWidget::changeEvent(QEvent * event)
case QEvent::FontChange:
case QEvent::StyleChange: {
+ Q_D(QWidget);
update();
updateGeometry();
+ if (d->layout)
+ d->layout->invalidate();
#ifdef Q_WS_QWS
- Q_D(QWidget);
if (isWindow())
d->data.fstrut_dirty = true;
#endif
@@ -11287,8 +11289,6 @@ Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
}
-
-
#ifndef QT_NO_GRAPHICSVIEW
/*!
\since 4.5
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 070110d..6e4d069 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3180,6 +3180,12 @@ void QWidgetPrivate::show_sys()
#ifndef QT_MAC_USE_COCOA
SizeWindow(window, q->width(), q->height(), true);
#endif
+
+#ifdef QT_MAC_USE_COCOA
+ // Make sure that we end up sending a repaint event to
+ // the widget if the window has been visible one before:
+ [qt_mac_get_contentview_for(window) setNeedsDisplay:YES];
+#endif
if(qt_mac_is_macsheet(q)) {
qt_event_request_showsheet(q);
} else if(qt_mac_is_macdrawer(q)) {
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 1122154..f4cd61a 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -577,6 +577,7 @@ public:
#endif
void grabMouseWhileInWindow();
void registerTouchWindow();
+ void winSetupGestures();
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
// This is new stuff
uint needWindowChange : 1;
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index d5ce40b..49254ef 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -56,6 +56,10 @@
#include "private/qbackingstore_p.h"
#include "private/qwindowsurface_raster_p.h"
+#include "qscrollbar.h"
+#include "qabstractscrollarea.h"
+#include <private/qabstractscrollarea_p.h>
+
#include <qdebug.h>
#include <private/qapplication_p.h>
@@ -2053,6 +2057,58 @@ void QWidgetPrivate::registerTouchWindow()
QApplicationPrivate::RegisterTouchWindow(q->effectiveWinId(), 0);
}
+void QWidgetPrivate::winSetupGestures()
+{
+ Q_Q(QWidget);
+ if (!q)
+ return;
+ extern QApplicationPrivate* getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ bool needh = false;
+ bool needv = false;
+ bool singleFingerPanEnabled = false;
+ QStandardGestures gestures = qAppPriv->widgetGestures[q];
+ WId winid = 0;
+
+ if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q)) {
+ winid = asa->viewport()->winId();
+ QScrollBar *hbar = asa->horizontalScrollBar();
+ QScrollBar *vbar = asa->verticalScrollBar();
+ Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy();
+ Qt::ScrollBarPolicy vbarpolicy = asa->verticalScrollBarPolicy();
+ needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
+ || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
+ needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
+ || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
+ singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
+ } else {
+ winid = q->winId();
+ }
+ if (qAppPriv->SetGestureConfig) {
+ GESTURECONFIG gc[2];
+ gc[0].dwID = GID_PAN;
+ if (gestures.pan || needh || needv) {
+ gc[0].dwWant = GC_PAN;
+ gc[0].dwBlock = 0;
+ if (needv && singleFingerPanEnabled)
+ gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+ if (needh && singleFingerPanEnabled)
+ gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+ } else {
+ gc[0].dwWant = 0;
+ gc[0].dwBlock = GC_PAN;
+ }
+
+ gc[1].dwID = GID_ZOOM;
+ if (gestures.pinch) {
+ gc[1].dwWant = GC_ZOOM;
+ gc[1].dwBlock = 0;
+ }
+ Q_ASSERT(winid);
+ qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
+ }
+}
+
QT_END_NAMESPACE
#ifdef Q_WS_WINCE