summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-08-09 16:41:42 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-08-09 16:41:42 -0500
commit403cd53c4e6f6b35bf9881c44efb9f41f5c65b57 (patch)
tree4faf9f3cd1f22f3c41bc5581db938c79b88b99a9 /src
parentd24053184c51974368634902f1c0e862c811098b (diff)
downloadqt3-403cd53c4e6f6b35bf9881c44efb9f41f5c65b57.tar.gz
qt3-403cd53c4e6f6b35bf9881c44efb9f41f5c65b57.zip
Extend style API further and clean up example themes
Diffstat (limited to 'src')
-rw-r--r--src/kernel/qstyle.cpp66
-rw-r--r--src/kernel/qstyle.h24
-rw-r--r--src/styles/qcommonstyle.cpp12
3 files changed, 90 insertions, 12 deletions
diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp
index 1d085f3..55aba9e 100644
--- a/src/kernel/qstyle.cpp
+++ b/src/kernel/qstyle.cpp
@@ -403,6 +403,7 @@ QStyle::QStyle()
m_eventHandlerInstallationHook = NULL;
m_eventHandlerRemovalHook = NULL;
m_widgetActionRequestHook = NULL;
+ m_applicationActionRequestHook = NULL;
conditionalAcceleratorsEnabled = false;
d = new QStylePrivate;
}
@@ -526,8 +527,7 @@ void QStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags, voi
\sa unPolish()
*/
void QStyle::polish( QApplication *app ) {
- QStyleControlElementData ceData;
- ceData.widgetObjectTypes = getObjectTypeListForObject(app);
+ QStyleControlElementData ceData = populateControlElementDataFromApplication(app, QStyleOption());
applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app);
}
@@ -539,8 +539,7 @@ void QStyle::polish( QApplication *app ) {
\sa polish()
*/
void QStyle::unPolish( QApplication *app ) {
- QStyleControlElementData ceData;
- ceData.widgetObjectTypes = getObjectTypeListForObject(app);
+ QStyleControlElementData ceData = populateControlElementDataFromApplication(app, QStyleOption());
applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app);
}
@@ -2217,6 +2216,12 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen
else if (request == WAR_DisableMouseTracking) {
widget->setMouseTracking(FALSE);
}
+ else if (request == WAR_SetAutoMask) {
+ widget->setAutoMask(TRUE);
+ }
+ else if (request == WAR_UnSetAutoMask) {
+ widget->setAutoMask(FALSE);
+ }
else if (request == WAR_SetCheckable) {
QPopupMenu *pm = dynamic_cast<QPopupMenu*>(widget);
if (pm) {
@@ -2253,6 +2258,9 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen
else if (request == WAR_SetBackgroundMode) {
widget->setBackgroundMode((Qt::BackgroundMode)requestData.metric1);
}
+ else if (request == WAR_SetBackgroundOrigin) {
+ widget->setBackgroundOrigin((QWidget::BackgroundOrigin)requestData.metric1);
+ }
else if (request == WAR_SetFont) {
widget->setFont(requestData.font);
}
@@ -2289,11 +2297,45 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen
return true;
}
-void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) {
- // RAJA FIXME
- // Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the QWindowsStyle::styleHint overridden method
- // Additionally, the common styleHint code in TDE (that controls popupmenu settings and such via configuration files) needs to be modified to add a config option for this new style hint
+/*!
+ \fn void QStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook );
+
+ Sets a callback function \a hook which will be called whenever a new application action request
+ is made via the QStyle::installObjectEventHandler method. The callback function must
+ use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ).
+
+ \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler )
+*/
+void QStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ) {
+ m_applicationActionRequestHook = hook;
+}
+
+/*!
+ \fn bool applicationActionRequestHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request );
+ Handles application action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing.
+*/
+bool QStyle::applicationActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData ) {
+ bool cbret = false;
+ if (m_applicationActionRequestHook) {
+ cbret = (*m_applicationActionRequestHook)(ceData, elementFlags, source, request, requestData);
+ }
+ if (!cbret) {
+ if (ceData.widgetObjectTypes.contains("QApplication")) {
+ QApplication* application = reinterpret_cast<QApplication*>(source);
+ if (request == AAR_SetPalette) {
+ application->setPalette(requestData.palette, requestData.bool1, requestData.cstr);
+ }
+ else if (request == AAR_SetFont) {
+ application->setFont(requestData.font, requestData.bool1, requestData.cstr);
+ }
+ return true;
+ }
+ }
+ return true;
+}
+
+void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) {
if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) {
QWidget *widget = dynamic_cast<QWidget*>(o);
if (widget) {
@@ -2337,12 +2379,16 @@ QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(int param1, int par
metric2 = param2;
}
-QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPalette param) {
+QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPalette param, bool informWidgets, const char* className) {
palette = param;
+ bool1 = informWidgets;
+ cstr = className;
}
-QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QFont param) {
+QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QFont param, bool informWidgets, const char* className) {
font = param;
+ bool1 = informWidgets;
+ cstr = className;
}
QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QRect param) {
diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h
index c99fb78..2d76d09 100644
--- a/src/kernel/qstyle.h
+++ b/src/kernel/qstyle.h
@@ -257,18 +257,24 @@ class Q_EXPORT QStyleWidgetActionRequestData {
public:
QStyleWidgetActionRequestData();
QStyleWidgetActionRequestData(int metric1, int metric2=0);
- QStyleWidgetActionRequestData(QPalette palette);
- QStyleWidgetActionRequestData(QFont font);
+ QStyleWidgetActionRequestData(QPalette palette, bool informWidgets = FALSE, const char* className = 0);
+ QStyleWidgetActionRequestData(QFont font, bool informWidgets = FALSE, const char* className = 0);
QStyleWidgetActionRequestData(QRect rect);
~QStyleWidgetActionRequestData();
public:
+ bool bool1;
+ bool bool2;
int metric1;
int metric2;
QPalette palette;
QFont font;
QRect rect;
+ const char * cstr;
+ QString string;
};
+typedef QStyleWidgetActionRequestData QStyleApplicationActionRequestData;
+
class Q_EXPORT QStyle: public QObject
{
Q_OBJECT
@@ -1077,6 +1083,8 @@ public:
WAR_RepaintRect,
WAR_EnableMouseTracking,
WAR_DisableMouseTracking,
+ WAR_SetAutoMask,
+ WAR_UnSetAutoMask,
WAR_SetCheckable,
WAR_UnSetCheckable,
WAR_FrameSetStyle,
@@ -1084,6 +1092,7 @@ public:
WAR_SetLayoutMargin,
WAR_SetPalette,
WAR_SetBackgroundMode,
+ WAR_SetBackgroundOrigin,
WAR_SetFont,
WAR_RepaintAllAccelerators
};
@@ -1092,6 +1101,15 @@ public:
void setWidgetActionRequestHook( WidgetActionRequestHook );
virtual bool widgetActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData = QStyleWidgetActionRequestData() );
+ enum ApplicationActionRequest {
+ AAR_SetPalette,
+ AAR_SetFont
+ };
+
+ typedef bool (*ApplicationActionRequestHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData);
+ void setApplicationActionRequestHook( ApplicationActionRequestHook );
+ virtual bool applicationActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData = QStyleApplicationActionRequestData() );
+
// Old 2.x QStyle API
#ifndef QT_NO_COMPAT
@@ -1131,6 +1149,7 @@ private:
EventHandlerInstallationHook m_eventHandlerInstallationHook;
EventHandlerRemovalHook m_eventHandlerRemovalHook;
WidgetActionRequestHook m_widgetActionRequestHook;
+ ApplicationActionRequestHook m_applicationActionRequestHook;
ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap;
ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap;
ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap;
@@ -1141,6 +1160,7 @@ inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a
// inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; }
Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true);
+Q_EXPORT QStyleControlElementData populateControlElementDataFromApplication(const QApplication* app, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStringList getObjectTypeListForObject(const QObject* object);
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp
index b81018e..fe25502 100644
--- a/src/styles/qcommonstyle.cpp
+++ b/src/styles/qcommonstyle.cpp
@@ -556,6 +556,18 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
return ceData;
}
+QStyleControlElementData populateControlElementDataFromApplication(const QApplication* app, const QStyleOption&, bool) {
+ QStyleControlElementData ceData;
+
+ if (app) {
+ ceData.widgetObjectTypes = getObjectTypeListForObject(app);
+ ceData.palette = app->palette();
+ ceData.font = app->font();
+ }
+
+ return ceData;
+}
+
/*! \reimp */
void QCommonStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,