summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-05-27 16:56:06 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-05-27 16:56:06 (GMT)
commitf734da2aac362a72d246d8c2a61ab6ef04fb6bd9 (patch)
tree01d9a987902b8cf88bc8ffb109699d7e5cbf45db /src
parentf96614f608d080b89fde95118f0eb35443b671ea (diff)
parentdf4a095019638356520728f88ac4d919e654dcdd (diff)
downloadQt-f734da2aac362a72d246d8c2a61ab6ef04fb6bd9.zip
Qt-f734da2aac362a72d246d8c2a61ab6ef04fb6bd9.tar.gz
Qt-f734da2aac362a72d246d8c2a61ab6ef04fb6bd9.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp24
-rw-r--r--src/gui/kernel/qapplication_s60.cpp10
-rw-r--r--src/gui/kernel/qdesktopwidget_s60.cpp63
-rw-r--r--src/gui/styles/qs60style.cpp27
-rw-r--r--src/gui/styles/qs60style_p.h20
-rw-r--r--src/gui/styles/qs60style_simulated.cpp19
-rw-r--r--src/gui/styles/qs60style_symbian.cpp34
7 files changed, 118 insertions, 79 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index ce38b73..6aa3b56 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -54,7 +54,7 @@
#include <stdio.h>
#include <stdlib.h>
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED) && !defined(Q_OS_SYMBIAN)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED)
# include <sys/times.h>
#endif
@@ -65,7 +65,7 @@ Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false;
/*****************************************************************************
UNIX signal handling
*****************************************************************************/
-#if !defined(Q_OS_SYMBIAN)
+
static sig_atomic_t signal_received;
static sig_atomic_t signals_fired[NSIG];
@@ -74,7 +74,7 @@ static void signalHandler(int sig)
signals_fired[sig] = 1;
signal_received = 1;
}
-#endif
+
static void initThreadPipeFD(int fd)
{
@@ -134,7 +134,6 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
int nsel;
do {
-#if !defined(Q_OS_SYMBIAN)
if (mainThread) {
while (signal_received) {
signal_received = 0;
@@ -146,7 +145,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
}
}
}
-#endif
+
// Process timers and socket notifiers - the common UNIX stuff
int highest = 0;
if (! (flags & QEventLoop::ExcludeSocketNotifiers) && (sn_highest >= 0)) {
@@ -258,7 +257,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
QTimerInfoList::QTimerInfoList()
{
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_SYMBIAN)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0)
useMonotonicTimers = false;
# if (_POSIX_MONOTONIC_CLOCK == 0)
@@ -299,7 +298,7 @@ timeval QTimerInfoList::updateCurrentTime()
return currentTime;
}
-#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED)) && !defined(Q_OS_SYMBIAN)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED)
/*
Returns true if the real time clock has changed by more than 10%
@@ -375,11 +374,7 @@ void QTimerInfoList::repairTimersIfNeeded()
void QTimerInfoList::getTime(timeval &t)
{
timespec ts;
-#if !defined(Q_OS_SYMBIAN)
clock_gettime(CLOCK_MONOTONIC, &ts);
-#else
- clock_gettime(CLOCK_REALTIME, &ts);
-#endif
t.tv_sec = ts.tv_sec;
t.tv_usec = ts.tv_nsec / 1000;
}
@@ -944,7 +939,7 @@ void QEventDispatcherUNIX::flush()
-#if !defined(Q_OS_SYMBIAN)
+
void QCoreApplication::watchUnixSignal(int sig, bool watch)
{
if (sig < NSIG) {
@@ -958,10 +953,5 @@ void QCoreApplication::watchUnixSignal(int sig, bool watch)
sigaction(sig, &sa, 0);
}
}
-#else
-void QCoreApplication::watchUnixSignal(int, bool)
-{
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index dd51fcd..5b2c1fb 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -14,6 +14,7 @@
#include "qevent.h"
#include "qeventdispatcher_s60_p.h"
#include "qwidget.h"
+#include "qdesktopwidget.h"
#include "private/qbackingstore_p.h"
#include "qt_s60_p.h"
#include "private/qevent_p.h"
@@ -49,6 +50,8 @@ static bool appNoGrab = false; // Grabbing enabled
Q_GUI_EXPORT QS60Data *qt_s60Data = 0;
extern bool qt_sendSpontaneousEvent(QObject*,QEvent*);
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
+
QWidget *qt_button_down = 0; // widget got last button-down
bool qt_nograb() // application no-grab option
@@ -988,6 +991,13 @@ int QApplication::s60ProcessEvent(TWsEvent *event)
case EEventScreenDeviceChanged:
if (S60)
S60->updateScreenSize();
+ if (qt_desktopWidget) {
+ QSize oldSize = qt_desktopWidget->size();
+ qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels);
+ qt_desktopWidget->data->crect.setHeight(S60->screenHeightInPixels);
+ QResizeEvent e(qt_desktopWidget->size(), oldSize);
+ QApplication::sendEvent(qt_desktopWidget, &e);
+ }
return 0; // Propagate to CONE
case EEventWindowVisibilityChanged:
if (controlInMap) {
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp
index 029892e..d57d289 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/gui/kernel/qdesktopwidget_s60.cpp
@@ -32,34 +32,58 @@ public:
static int screenCount;
static int primaryScreen;
+
+ static QVector<QRect> *rects;
+ static QVector<QRect> *workrects;
+
+ static int refcount;
};
int QDesktopWidgetPrivate::screenCount = 1;
int QDesktopWidgetPrivate::primaryScreen = 0;
+QVector<QRect> *QDesktopWidgetPrivate::rects = 0;
+QVector<QRect> *QDesktopWidgetPrivate::workrects = 0;
+int QDesktopWidgetPrivate::refcount = 0;
QDesktopWidgetPrivate::QDesktopWidgetPrivate()
{
+ ++refcount;
}
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
{
+ if (!--refcount)
+ cleanup();
}
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
- TInt screenCount=0;
- TInt result=0;
+ int screenCount=0;
+
+ if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
+ QDesktopWidgetPrivate::screenCount = screenCount;
+ else
+ QDesktopWidgetPrivate::screenCount = 0;
- result = HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount);
- QDesktopWidgetPrivate::screenCount = screenCount;
- if( result != KErrNone)
- {
- // ### What to do if no screens found?
- }
+ rects = new QVector<QRect>();
+ workrects = new QVector<QRect>();
+
+ rects->resize(QDesktopWidgetPrivate::screenCount);
+ workrects->resize(QDesktopWidgetPrivate::screenCount);
+
+ // ### TODO: Implement proper multi-display support
+ rects->resize(1);
+ rects->replace(0, that->rect());
+ workrects->resize(1);
+ workrects->replace(0, that->rect());
}
void QDesktopWidgetPrivate::cleanup()
{
+ delete rects;
+ rects = 0;
+ delete workrects;
+ workrects = 0;
}
@@ -120,6 +144,29 @@ int QDesktopWidget::screenNumber(const QPoint &point) const
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
+ Q_D(QDesktopWidget);
+ QVector<QRect> oldrects;
+ oldrects = *d->rects;
+ QVector<QRect> oldworkrects;
+ oldworkrects = *d->workrects;
+ int oldscreencount = d->screenCount;
+
+ QDesktopWidgetPrivate::cleanup();
+ QDesktopWidgetPrivate::init(this);
+
+ for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) {
+ QRect oldrect = oldrects[i];
+ QRect newrect = d->rects->at(i);
+ if (oldrect != newrect)
+ emit resized(i);
+ }
+
+ for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) {
+ QRect oldrect = oldworkrects[j];
+ QRect newrect = d->workrects->at(j);
+ if (oldrect != newrect)
+ emit workAreaResized(j);
+ }
}
QT_END_NAMESPACE
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 071b60a..5f7c083 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -95,7 +95,8 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = {
const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0];
#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-bool QS60StylePrivate::m_backgroundValid = false;
+// theme background texture
+QPixmap *QS60StylePrivate::m_background = 0;
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = {
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter},
@@ -352,25 +353,25 @@ QFont QS60StylePrivate::s60Font(
void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason)
{
- switch(reason){
+ switch(reason){
case CC_LayoutChange:
// when layout changes, the colors remain in cache, but graphics and fonts can change
m_mappedFontsCache.clear();
- m_backgroundValid = false;
+ deleteBackground();
QPixmapCache::clear();
break;
case CC_ThemeChange:
m_colorCache.clear();
QPixmapCache::clear();
- m_backgroundValid = false;
+ deleteBackground();
case CC_UndefinedChange:
default:
m_colorCache.clear();
m_mappedFontsCache.clear();
QPixmapCache::clear();
- m_backgroundValid = false;
+ deleteBackground();
break;
- }
+ }
}
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use
@@ -561,6 +562,14 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
app->setPalette(applicationPalette);
}
+void QS60StylePrivate::deleteBackground()
+{
+ if (QS60StylePrivate::m_background) {
+ delete QS60StylePrivate::m_background;
+ QS60StylePrivate::m_background = 0;
+ }
+}
+
int QS60StylePrivate::focusRectPenWidth()
{
return pixelMetric(QS60Style::PM_DefaultFrameWidth);
@@ -1314,16 +1323,14 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
(listView->selectionMode() == QAbstractItemView::SingleSelection ||
listView->selectionMode() == QAbstractItemView::NoSelection);
QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
- if (voptAdj.state & QStyle::State_Selected &&
- !singleSelection) {
+ if (voptAdj.state & QStyle::State_Selected && !singleSelection) {
QStyleOptionViewItemV4 option(voptAdj);
option.rect = selectionRect;
// Draw selection mark.
drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget);
if ( textRect.right() > selectionRect.left() )
textRect.setRight(selectionRect.left());
- }
- else if (singleSelection &&
+ } else if (singleSelection &&
voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) {
// draw the check mark
if (selectionRect.isValid()) {
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index ba7dca3..bedff58 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -331,13 +331,13 @@ public:
SF_StateDisabled = 0x0020,
SF_ColorSkinned = 0x0040,
};
-
+
enum CacheClearReason {
CC_UndefinedChange = 0,
CC_LayoutChange,
CC_ThemeChange
};
-
+
Q_DECLARE_FLAGS(SkinElementFlags, SkinElementFlag)
// draws skin element
@@ -373,8 +373,10 @@ public:
int pointSize = -1) const;
// clears all style caches (fonts, colors, pixmaps)
void clearCaches(CacheClearReason reason = CC_UndefinedChange);
- // returns themed background texture
- static QPixmap backgroundTexture();
+
+ // themed main background oprations
+ void setBackgroundTexture(QApplication *application) const;
+ static void deleteBackground();
static bool isTouchSupported();
static bool isToolBarBackground();
@@ -383,7 +385,6 @@ public:
QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const;
void setThemePalette(QApplication *application) const;
void setThemePalette(QWidget *widget) const;
- void setBackgroundTexture(QApplication *application) const;
static int focusRectPenWidth();
@@ -411,6 +412,8 @@ public:
static QPixmap frame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
+ static QPixmap backgroundTexture();
+
private:
static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter,
const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
@@ -424,9 +427,9 @@ private:
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
-
+
static void refreshUI();
-
+
static QSize partSize(QS60StyleEnums::SkinParts part,
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
@@ -436,7 +439,8 @@ private:
static QSize screenSize();
- static bool m_backgroundValid;
+ // Contains background texture.
+ static QPixmap *m_background;
const static SkinElementFlags KDefaultSkinElementFlags;
};
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp
index 65336ae..3edc874 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/gui/styles/qs60style_simulated.cpp
@@ -193,24 +193,15 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
QPixmap QS60StylePrivate::backgroundTexture()
{
- static QPixmap result;
- // Poor mans caching. + Making sure that there is always only one background image in memory at a time
-
-/*
- TODO: 1) Hold the background QPixmap as pointer in a static class member.
- Also add a deleteBackground() function and call that in ~QS60StylePrivate()
- 2) Don't cache the background at all as soon as we have native pixmap support
-*/
-
- if (!m_backgroundValid) {
- result = QPixmap();
+ if (!m_background) {
const QSize size = QApplication::activeWindow()?QApplication::activeWindow()->size():QSize(100, 100);
- result = part(QS60StyleEnums::SP_QsnBgScreen, size);
- m_backgroundValid = true;
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size);
+ m_background = new QPixmap(background);
}
- return result;
+ return *m_background;
}
+
bool QS60StylePrivate::isTouchSupported()
{
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp
index 3fc4c8c..f860842 100644
--- a/src/gui/styles/qs60style_symbian.cpp
+++ b/src/gui/styles/qs60style_symbian.cpp
@@ -583,26 +583,6 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask
return QPixmap::fromImage(iconImage);
}
-QPixmap QS60StylePrivate::backgroundTexture()
-{
- static QPixmap result;
- // Poor mans caching. + Making sure that there is always only one background image in memory at a time
-
-/*
- TODO: 1) Hold the background QPixmap as pointer in a static class member.
- Also add a deleteBackground() function and call that in ~QS60StylePrivate()
- 2) Don't cache the background at all as soon as we have native pixmap support
-*/
-
- if (!m_backgroundValid) {
- result = QPixmap();
- result = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
- m_backgroundValid = true;
- }
- return result;
-}
-
bool QS60StylePrivate::isTouchSupported()
{
return bool(AknLayoutUtils::PenEnabled());
@@ -975,7 +955,7 @@ void QS60StylePrivate::setActiveLayout()
break;
}
}
-
+
//not found, lets try without mirroring info
if (activeLayoutIndex==-1){
for (int i=0; i<m_numberOfLayouts; i++) {
@@ -1011,7 +991,7 @@ QS60StylePrivate::QS60StylePrivate()
QS60StylePrivate::~QS60StylePrivate()
{
- m_backgroundValid = false;
+ deleteBackground();
}
void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
@@ -1183,6 +1163,16 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin
return result;
}
+QPixmap QS60StylePrivate::backgroundTexture()
+{
+ if (!m_background) {
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
+ QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
+ m_background = new QPixmap(background);
+ }
+ return *m_background;
+}
+
// If the public SDK returns compressed images, please let us also uncompress those!
void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap)
{