From 8f79ab354956119810490a18a1471141025a6db2 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 13 Oct 2012 19:15:17 +0100 Subject: [PATCH 001/114] Fix QComboBox icon testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The icons used were always null -- the files used to create them were not present. So 1) add back the files used for the test (qtlogo.png, copied from src/widgets/dialogs/images/qtlogo-64.png, and qtlogoinverted.png, its copy rotated by 180°); 2) use QFINDTESTDATA to get the paths to the files. Change-Id: I26f094079e037116e49e2a95345c2dea7496eecb Reviewed-by: Marc Mutz Reviewed-by: Rohan McGovern --- tests/auto/widgets/widgets/qcombobox/qtlogo.png | Bin 0 -> 2991 bytes .../widgets/widgets/qcombobox/qtlogoinverted.png | Bin 0 -> 2827 bytes .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 6 ++++-- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 tests/auto/widgets/widgets/qcombobox/qtlogo.png create mode 100644 tests/auto/widgets/widgets/qcombobox/qtlogoinverted.png diff --git a/tests/auto/widgets/widgets/qcombobox/qtlogo.png b/tests/auto/widgets/widgets/qcombobox/qtlogo.png new file mode 100644 index 0000000000000000000000000000000000000000..4f68e162de4295f123c6979c0f6f422031bc5603 GIT binary patch literal 2991 zcmV;g3sCflP)I)Ph5`~Z$3?K;!c>xKSkdTDDcJJQj zxu<_@5{Y~7X2af%ar(_L!#Tfi&-vXi=bU@a@BA)9DaBZD7Q3tf3IVJJFxzNi;%5{% zT*+yc7?X)Hnam7j7>4j((#!Koi^$VzNm9yXiGEtXxvpo-4!%b)V+r6acHInMJAfDf zaAn&tXQ2}gr!lAwydENZS*4Hnl2%cmCqz*xmnFKld~;oUsLtzwfC4y+UC#pe{ct&b znhi@=$LP{A=T(T;L;88Ia!wGGT1li8vZU-iw5hH|mkxr2rU1@j*L47P50@QIBZ_Z} zhsA0Lt3y1eC|(a4;JiwkC@3dIfmX^A-FIkH?a6TTrz(K6*kuM#3m|8>Zuy#6OwF){ z!-t?C3JPW2WRUYJ?E~dTG28t zEkxLZd*%HQp(Q|gm-E6iS{%^TJ+gW>4C7UZj@4-Jtg3q zGXgTFOvCL(x8n9C>tMIoM>woFfY$z#sPC>qS?l}YWp6lK856n-FxXG<<>&n{!-^Ll z-HL1TR;%(HmT1hHvKX_bEXJCgd+}-W>)6-)1}MfpoaqT&1#tJvDEXilvC(!Me&GP( zoWboK>}Dr!nfVZ=$L3-Cv8N!&oIi;IJOAAUqmjY6cWcqlccGu_#-XzxqN=^*vVGQV z4Ui>@(og!pFb3>-?){)2{!+|IDZ&F+Jp%^*JI;YV8KR&dd)idkOm-wkW+FFnKGLIe zR9Xrix(QJCH4Ao-;GP?9Kz5S0Q_UAnV#D@FP}zJ))t;AhHCAP>^Q-Uf6afJ9bLZ&e z@DOwnz{?UeRFZ_Wq+fct-Zzb5BE%YQ*H`DpTQjO`Gy?HS zW(Yh%N%bB-es1D?wA5Je?#rE6nff3qU)qIt{`7_)FC!)wi_+I1Ke-TDartmsW5?xx z$gjcfP6+^zcSW`)rpvSG924FEpXxb!6fx*DQW>FW3l_t3W zHk+@B_TDy4&UerDmx9O?#sEu*chZl52wxK&ecJgB7NdHMKv8`EOcrf7CjAJoT79pv z&b|(9j>Z%qvTy#IG=_krh>(a7qKAQ@!y4do{zAX{fd&BL?J27D0_WRBM%vX!NFUb~ zqIY8>WC7xme8-8y^;MdjjF?>2`raPj+aoJo{UFuUb2LQn#zx2jq-NM)FaVX+>SuZY zh_NNAMrwL{eEWxj>{+V6tMC45%>J1GJJ4VdvH)fagQQd|+=C+a)%b_DhLI8NKMMMW zMnK`LrG7RFiiYkZ!-bK$?;^pTdKq4S3tfVusV?6ferx|*nweqUgCGBEn(B zioBJ6{I-E6ctqdv*F3b)b`5s>_Z>AI03eAJeHUdIh~1A92>J++=@X#r>tmXnWtlf) zs&o2C`NUBVB$49r_4mVJjr8Lm?>IQ}|Hz@7#OC%!KVDL#3+t}jh!k--epk2^kF9uN zT)yiffFsg~zF##fE#Xxeuut0hF@V575*zdMX(V!2D$~kR*aTpSufQ(La}fmswPI9>o4L z?~KcDU9ZQJQY|Q05Q*c5+wstg4`SOdgOATsP?Vqj2s`Vxs@kWfTX5YS321Bi2J2o} zgQ9|^$e&gKuhfV7?kcqO)k2|U+&=4`ATe{U16G>>JNABt3w<|X`y;O*#vVAT)8THx zo7I2Csf*PCd3J{pIeB&f92(etXsF#6vcF+Tk;$47fwXB>w4OSRWsesjH$4Zxx$$8X z<`(&J`?w3(^2K@(C2&k3TnJl|l+|Xym3emLFSKCK7ghMh^AD@?Vk44}8Kb@v)D;@J zH(}2bb3_>t8*jq-jscu(JE6*1nRQpV-GD69Givn{k|vin%?425)sk0K?Q>I#uwltI ztjf9@SH#Z?iw}}SRZ~(XL;zP-1PlgXcUh_GTxS>qauVj@w!B|siEFLy{S%pj$h1_= zHX#B;#Trqtz=`u6gZR~p4^BjvqtMwd)|79qQw=RmSgP!d0tZrER=o4^e(b2wJ~ZhK zssIDM@?RF-LJ#g;lTRHyZX<{IGMbGFJ^>{<$-1b}Mn zSy2GiO$3f5-Td%_O7wGCqWdeh)P?tAUnd0f^|)*197kpLOnaQyL%MlhIV}pxF-fFf l$TBUd*j)GheCwhU{s(GVj(9uH$k+e?002ovPDHLkV1nRJn8W}8 literal 0 HcmV?d00001 diff --git a/tests/auto/widgets/widgets/qcombobox/qtlogoinverted.png b/tests/auto/widgets/widgets/qcombobox/qtlogoinverted.png new file mode 100644 index 0000000000000000000000000000000000000000..61efb2f001999cf95c7d2e28b06725df18b29ee4 GIT binary patch literal 2827 zcmV+m3-t7fP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L0093000931orORe00007bV*G`2iyt` z5i>EVqZ-8k01AsqL_t(|+U1*ja8%VD$G`X7*WP>gkxjB8FCY){+=T!k8j}zd3=iwG zWvC;?nbvA`rX8nFEsm5&XDYTT?H|^*=(IWtQW<=VkH#34w~DbyAV3TOvU!j|-r4MC z?>_GKkBz~w_pU*9lTAJU?Cd$edmf+rJHK;&zjH1X2m~;lQ`sh~$S_nD%TYISJXxsI zk!(>Du477 z2O5t%I{;KUs_mzz4S=$ZR*qq)r7TA+<#jYD5S1^@sU25^U?+WzsCa?B(Rw47zB zn>n78@H&z!NF=#%fh5oo80Z9(9>5a-ZipIyvW-?k(^MJDjSVzUkVs15d`YAkDi&s! zYA3!EfW=#Er7TBPu^hRM7pQzuq*Ds!OA-?s1HGy=ApjMdZ8n36e%5Ga7U>PNRJcHz zek1*^0G2;J@3n&Y;+m_m!2dS@s-Bwna#o(OCQ^+po_!~-OJ4!AkOUngp|QOYpEiDq zBh80#>`VhPb96|{(8UIT#anC@1x3=jNH&(8Fb}zj3&;MKWZ!_2>>B_)g596&#Qjff zK+4P!ELmyRFjBp=cKi(I>ho#R%3D+H*d1% zOXg2sNX+z0BD9<8jZF4u>D=^Y4|IedX6FxP(s@!3~pV#6p8}a&yGwT z0G6dHqS4ry-lM2J`wF%leh6Q7?pKw$uj=Oj1+<@cPaOb;p|Yag@P}u2spc1^&qZpA z3H`l3IEVaG0{~R?ZE(xLN%W6gR4x1Gqt9a1jU_mK#DlLIT#(($<%aRc55lgpP)ZcT!w3o_};3+#?D;{djO{00a=gXHAE&VdrnLzp+|XCVy5g z0KhTm8_QcUXB{k3dWh^ZZ#{{c1OLUG0s%Qz5tp3pc;(nuC;|01e9OYyV6jN(>hQoh z?4Nu9Pw)K|{(R_RbaMOf>Q`HEaX2*MoRgLp48l1scW{16Wr&!BUUI5Ecm|LtL z%fH|_hXXBdYI~Fmg3eS&i#+)N6xs!I0t1!{s&dEBxlmO#S^xlEIT&o!b8$#F<%Y=Z zZTJu)PCpW7aA4T+Q{#BoA;N9CAMf+})aWmKIr| zC_qQ6dujnpB;_U+tLC3=Yaa!mz7=U5(AI+M3rYY0eHVSP55O!Wspb#6f^(P`)OU@& zu1?K5XT$}!(6ZYf+W=Ua2TRm)3;8x$M{8`zM=If--U-wgE`2QM1hFQ9uYl zG?1l0YLU?Yd~6ja8u=WE7Ma0+#WX+B>zdwcnaJ2d%hf{V00faei^7y_D zKyd%yk(Jm5;Pj|_ZF-$4Xb64Uoo8q^Y~5aO@YS;{6}te2H{wn0$-ge}}<) z`cwh%JcHq3FFYOv0!v?&2DEm!M+`vJouTd_^}~-@sX>QkpkLjiGw}(Ub$0e#m_7jZ zo!G0IKR?$RbZIZCTf(e(n`WI|{g;9Oq)D~``_AvdsY^#7aYl%&5v4O%g#mQw^CR0Pg<7I-EIo33vR&f*;?X48ViN?m84ET|Z8)s%RB>-Q(!J=nXnX^f%wW z_SJ-wZO75s+*Z2=Zm;UU*cTo8RBF6~#rFX!z2J zj+S8gExA8Me&Qkx|3JnYAJu}PDP$K2u?L{$Xbk`$DTNF1?cZs9KD2R)VBa72p?cd6 zo(#8}MzZuJPEYaS9EC)i%G1yu?MY%_s{g zE6u4uX-@b{Da{v~@Y36FLo(8^M(~9AnlzwounCRbb?6#yf!pUo^Z5(lcmk6-lxqM1 zJpaYxIHqwmCS2-s^kCKcyATK{SbB^3njN5sX+T{^E$TXI$Nt}SuO+O!>>I&9K3|XJ zIqR@8=U&wv;+5&6h8jHh%p>qZM%A4OFvQW3RNClYmsit-nlmqB|M@*woN*TlEG5W@ zD}=*@OhK>1z)7;%Nf z%UdUG14f+6c6+m%=XE4k5J|FRphbqIrqve{{XHRZh7%J8aA0%8`vAr~n9&cSN*Rt? z%5hW)uOs<_NT)~!TF-K^2gc_OjJu;04!|{kH(0U7wt!`+DwdqnzWi~qrz0kn<3YX2ukwf!+I z`Iz~3xO|f}jbW)397oDIo|>x@=?qaKW>HU1XtU;Y_;Kur1NP>z!4ClVnWNhNX1M2K z{_FAbP1Zz)rB<>mDd%)lkxoZ4bs`-f2n1-KH$eG(0bf_UXW(?b)9&{LdPj|24S++A d>TkbG_djjab_mN7%i;h4002ovPDHLkV1l2LD98W+ literal 0 HcmV?d00001 diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 6dfb362c83..6016a19ff2 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1282,6 +1282,8 @@ void tst_QComboBox::textpixmapdata_data() QStringList text; IconList icon; VariantList variant; + QString qtlogoPath = QFINDTESTDATA("qtlogo.png"); + QString qtlogoinvertedPath = QFINDTESTDATA("qtlogoinverted.png"); { text.clear(); icon.clear(); variant.clear(); @@ -1293,7 +1295,7 @@ void tst_QComboBox::textpixmapdata_data() { text.clear(); icon.clear(); variant.clear(); text << QString() << QString(); - icon << QIcon(QPixmap("qtlogo.png")) << QIcon(QPixmap("qtlogoinverted.png")); + icon << QIcon(QPixmap(qtlogoPath)) << QIcon(QPixmap(qtlogoinvertedPath)); variant << QVariant() << QVariant(); QTest::newRow("just icons") << text << icon << variant; } @@ -1307,7 +1309,7 @@ void tst_QComboBox::textpixmapdata_data() { text.clear(); icon.clear(); variant.clear(); text << "foo" << "bar"; - icon << QIcon(QPixmap("qtlogo.png")) << QIcon(QPixmap("qtlogoinverted.png")); + icon << QIcon(QPixmap(qtlogoPath)) << QIcon(QPixmap(qtlogoinvertedPath)); variant << 12 << "bingo"; QTest::newRow("text, icons and user data") << text << icon << variant; } From b3e2c69cc2de4fdf3fd19fbe11517459aa61aa17 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 11 Oct 2012 23:19:50 +0200 Subject: [PATCH 002/114] Review of documentation. Documentation has been updated, changes apply to Qt5 as well as Qt4. Change-Id: I692869971bafffabbb9c323dc031f6d984c1adb9 Reviewed-by: Stephen Kelly Reviewed-by: Frederik Gladhorn --- src/corelib/doc/snippets/pointer/pointer.cpp | 3 ++- src/corelib/kernel/qpointer.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/corelib/doc/snippets/pointer/pointer.cpp b/src/corelib/doc/snippets/pointer/pointer.cpp index 31b4959651..503f2dfccd 100644 --- a/src/corelib/doc/snippets/pointer/pointer.cpp +++ b/src/corelib/doc/snippets/pointer/pointer.cpp @@ -53,7 +53,8 @@ int main(int argc, char *argv[]) //! [1] if (label) -//! [1] //! [2] +//! [1] +//! [2] label->show(); //! [2] return 0; diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp index 48710bb70c..b774b36592 100644 --- a/src/corelib/kernel/qpointer.cpp +++ b/src/corelib/kernel/qpointer.cpp @@ -123,7 +123,7 @@ /*! \fn QPointer::QPointer(T* p) - Constructs a guarded pointer that points to same object that \a p + Constructs a guarded pointer that points to the same object that \a p points to. */ @@ -273,3 +273,11 @@ \a p2 are not pointing to the same object, otherwise returns false. */ +/*! + \fn QPointer qPointerFromVariant(const QVariant &variant) + + \internal + + Returns a guarded pointer that points to the same object that + \a variant holds. +*/ From c6cc55c9feeb9f97e888822b8665f2abe54d6dcc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 15 Oct 2012 16:19:02 +0200 Subject: [PATCH 003/114] Windows: Document WinAPI usage for the various compilers. Change-Id: I139c6546cb84a1fa93920a501cd15eb11fdadbb8 Reviewed-by: Miikka Heikkinen --- .../platforms/windows/qwindowsintegration.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 1f26ec5bab..12e7d7b5db 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -187,6 +187,40 @@ void *QWindowsNativeInterface::createMessageWindow(const QString &classNameTempl \class QWindowsIntegration \brief QPlatformIntegration implementation for Windows. \internal + + \section1 Programming Considerations + + The platform plugin should run on Desktop Windows from Windows XP onwards + and Windows Embedded. + + It should compile with: + \list + \li Microsoft Visual Studio 2008 or later (using the Microsoft Windows SDK, + (\c Q_CC_MSVC). + \li Stock \l{http://mingw.org/}{MinGW} (\c Q_CC_MINGW). + This version ships with headers that are missing a lot of WinAPI. + \li MinGW distributions using GCC 4.7 or higher and a recent MinGW-w64 runtime API, + such as \l{http://tdm-gcc.tdragon.net/}{TDM-GCC}, or + \l{http://mingwbuilds.sourceforge.net/}{MinGW-builds} + (\c Q_CC_MINGW and \c __MINGW64_VERSION_MAJOR indicating the version). + MinGW-w64 provides more complete headers (compared to stock MinGW from mingw.org), + including a considerable part of the Windows SDK. + \li Visual Studio 2008 for Windows Embedded (\c Q_OS_WINCE). + \endlist + + The file \c qtwindows_additional.h contains defines and declarations that + are missing in MinGW. When encountering missing declarations, it should + be added there so that \c #ifdefs for MinGW can be avoided. Similarly, + \c qplatformfunctions_wince.h contains defines and declarations for + Windows Embedded. + + When using a function from the WinAPI, the minimum supported Windows version + and Windows Embedded support should be checked. If the function is not supported + on Windows XP or is not present in the MinGW-headers, it should be dynamically + resolved. For this purpose, QWindowsContext has static structs like + QWindowsUser32DLL and QWindowsShell32DLL. All function pointers should go to + these structs to avoid lookups in several places. + \ingroup qt-lighthouse-win */ From e0ad6e5f7dd644c35baeb5ee714b5abfae2696da Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 13:05:42 +0200 Subject: [PATCH 004/114] Add documentation for ucs4 overloads. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibacd8f260950db195a17cffe8396e8460f227eb9 Reviewed-by: Jan Arve Sæther --- src/corelib/tools/qchar.cpp | 54 +++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 0a027fc229..c66962d931 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -121,7 +121,7 @@ QT_BEGIN_NAMESPACE isDigit() (decimal digits). All of these are wrappers around category() which return the Unicode-defined category of each character. Some of these also calculate the derived properties - (i.e. isSpace() returns true if the character is of category + (for example isSpace() returns true if the character is of category Separator_* or an exceptional code point from Other_Control category). QChar also provides direction(), which indicates the "natural" @@ -766,14 +766,14 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) \fn bool QChar::isHighSurrogate() const Returns true if the QChar is the high part of a UTF16 surrogate - (i.e. if its code point is in range [0xd800..0xdbff]); false otherwise. + (for example if its code point is in range [0xd800..0xdbff]); false otherwise. */ /*! \fn bool QChar::isLowSurrogate() const Returns true if the QChar is the low part of a UTF16 surrogate - (i.e. if its code point is in range [0xdc00..0xdfff]); false otherwise. + (for example if its code point is in range [0xdc00..0xdfff]); false otherwise. */ /*! @@ -782,7 +782,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the QChar contains a code point that is in either the high or the low part of the UTF-16 surrogate range - (i.e. if its code point is in range [0xd800..0xdfff]); false otherwise. + (for example if its code point is in range [0xd800..0xdfff]); false otherwise. */ /*! @@ -806,7 +806,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 is the high part of a UTF16 surrogate - (i.e. if its code point is in range [0xd800..0xdbff]); false otherwise. + (for example if its code point is in range [0xd800..0xdbff]); false otherwise. */ /*! @@ -815,7 +815,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 is the low part of a UTF16 surrogate - (i.e. if its code point is in range [0xdc00..0xdfff]); false otherwise. + (for example if its code point is in range [0xdc00..0xdfff]); false otherwise. */ /*! @@ -825,7 +825,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 contains a code point that is in either the high or the low part of the - UTF-16 surrogate range (i.e. if its code point is in range [0xd800..0xdfff]); + UTF-16 surrogate range (for example if its code point is in range [0xd800..0xdfff]); false otherwise. */ @@ -834,7 +834,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 can be split into the high and low parts of a UTF16 surrogate - (i.e. if its code point is greater than or equals to 0x10000); + (for example if its code point is greater than or equals to 0x10000); false otherwise. */ @@ -969,30 +969,62 @@ bool QChar::hasMirrored(uint ucs4) /*! \fn bool QChar::isLower() const - Returns true if the character is a lowercase letter, i.e. + Returns true if the character is a lowercase letter, for example category() is Letter_Lowercase. \sa isUpper(), toLower(), toUpper() */ +/*! + \fn static bool QChar::isLower(uint ucs4) + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is a lowercase letter, for example category() is Letter_Lowercase. + + \sa isUpper(), toLower(), toUpper() +*/ + /*! \fn bool QChar::isUpper() const - Returns true if the character is an uppercase letter, i.e. + Returns true if the character is an uppercase letter, for example category() is Letter_Uppercase. \sa isLower(), toUpper(), toLower() */ +/*! + \fn static bool QChar::isUpper(uint ucs4) + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is an uppercase letter, for example category() is Letter_Uppercase. + + \sa isLower(), toUpper(), toLower() +*/ + /*! \fn bool QChar::isTitleCase() const - Returns true if the character is a titlecase letter, i.e. + Returns true if the character is a titlecase letter, for example category() is Letter_Titlecase. \sa isLower(), toUpper(), toLower(), toTitleCase() */ +/*! + \fn static bool QChar::isTitleCase(uint ucs4) + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is a titlecase letter, for example category() is Letter_Titlecase. + + \sa isLower(), toUpper(), toLower(), toTitleCase() +*/ /*! \fn QChar QChar::mirroredChar() const From e437051ff51d57bcc6937dc23fe6a77bf9897130 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Tue, 16 Oct 2012 01:46:44 +0200 Subject: [PATCH 005/114] QComboBox: replace homebrew with QSignalSpy for editTextChanged test Change-Id: Id4c81ae71d6dc87f9ad7cfb99a89d335162e1f75 Reviewed-by: Marc Mutz --- .../widgets/qcombobox/tst_qcombobox.cpp | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 6016a19ff2..116f3a99f3 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -160,15 +160,10 @@ private slots: void task_QTBUG_10491_currentIndexAndModelColumn(); void highlightedSignal(); -protected slots: - void onEditTextChanged( const QString &newString ); - private: QComboBox *testWidget; QWidget *parent; QPushButton* ok; - int editTextCount; - QString editText; }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -403,10 +398,6 @@ void tst_QComboBox::initTestCase() testWidget = new QComboBox(parent); testWidget->setObjectName("testObject"); testWidget->setGeometry(0, 0, 100, 100); - editTextCount = 0; - editText.clear(); - connect(testWidget, SIGNAL(editTextChanged(const QString&)), - this, SLOT(onEditTextChanged(const QString&))); parent->show(); } @@ -1375,23 +1366,19 @@ void tst_QComboBox::editTextChanged() testWidget->setEditable(false); QCOMPARE(testWidget->isEditable(), false); + QSignalSpy spy(testWidget, SIGNAL(editTextChanged(QString))); + // no signal should be sent when current is set to the same QCOMPARE(testWidget->currentIndex(), 0); - editTextCount = 0; - editText.clear(); testWidget->setCurrentIndex(0); QCOMPARE(testWidget->currentIndex(), 0); - QCOMPARE(editTextCount, 0); - QCOMPARE(editText.isEmpty(), true); + QCOMPARE(spy.count(), 0); // no signal should be sent when changing to other index because we are not editable QCOMPARE(testWidget->currentIndex(), 0); - editTextCount = 0; - editText.clear(); testWidget->setCurrentIndex(1); QCOMPARE(testWidget->currentIndex(), 1); - QCOMPARE(editTextCount, 0); - QCOMPARE(editText.isEmpty(), true); + QCOMPARE(spy.count(), 0); // now set to editable and reset current index testWidget->setEditable(true); @@ -1399,35 +1386,25 @@ void tst_QComboBox::editTextChanged() testWidget->setCurrentIndex(0); // no signal should be sent when current is set to the same + spy.clear(); QCOMPARE(testWidget->currentIndex(), 0); - editTextCount = 0; - editText.clear(); testWidget->setCurrentIndex(0); QCOMPARE(testWidget->currentIndex(), 0); - QCOMPARE(editTextCount, 0); - QCOMPARE(editText.isEmpty(), true); + QCOMPARE(spy.count(), 0); // signal should be sent when changing to other index QCOMPARE(testWidget->currentIndex(), 0); - editTextCount = 0; - editText.clear(); testWidget->setCurrentIndex(1); QCOMPARE(testWidget->currentIndex(), 1); - QCOMPARE(editTextCount, 1); - QCOMPARE(editText, QString("bar")); + QCOMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), QString("bar")); + // insert some keys and notice they are all signaled - editTextCount = 0; - editText.clear(); + spy.clear(); QTest::keyClicks(testWidget, "bingo"); - QCOMPARE(editTextCount, 5); - QCOMPARE(editText, QString("barbingo")); -} - -void tst_QComboBox::onEditTextChanged(const QString &text) -{ - editTextCount++; - editText = text; + QCOMPARE(spy.count(), 5); + QCOMPARE(qvariant_cast(spy.at(4).at(0)), QString("barbingo")); } void tst_QComboBox::setModel() From 7501d55ae005cf9a155a6bcbeac468bfde40177d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 5 Oct 2012 10:42:10 +0200 Subject: [PATCH 006/114] Introduce (private) QStyleAnimation QStyleAnimation handles style animations in a generic fashion by sending StyleAnimationUpdate events back to the animation target instead of calling QWidget::update() directly. This decouples style animations from widgets and makes it possible to run style animations for QQuickItems (ie. the desktop components). The next step is to add "QObject* QStyleOption::target" and use that everywhere instead of the widget pointer passed to various QStyle methods. Change-Id: Ib963c54872805fc3f0123ff922f82c9962a68b90 Reviewed-by: J-P Nurmi Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qcleanlooksstyle.cpp | 9 +- src/widgets/styles/qcleanlooksstyle_p.h | 1 - src/widgets/styles/qcommonstyle.cpp | 54 ++++++++ src/widgets/styles/qcommonstyle.h | 1 + src/widgets/styles/qcommonstyle_p.h | 25 +++- src/widgets/styles/qgtkstyle.cpp | 9 +- src/widgets/styles/qmacstyle_mac.mm | 134 ++++--------------- src/widgets/styles/qmacstyle_mac_p.h | 8 -- src/widgets/styles/qplastiquestyle.cpp | 71 +++------- src/widgets/styles/qplastiquestyle.h | 1 - src/widgets/styles/qstyleanimation.cpp | 148 ++++++++++++++++++++ src/widgets/styles/qstyleanimation_p.h | 110 +++++++++++++++ src/widgets/styles/qstylesheetstyle.cpp | 7 +- src/widgets/styles/qwindowsstyle.cpp | 58 +++----- src/widgets/styles/qwindowsstyle.h | 1 - src/widgets/styles/qwindowsstyle_p.h | 10 +- src/widgets/styles/qwindowsvistastyle.cpp | 156 ++++++---------------- src/widgets/styles/qwindowsvistastyle.h | 1 - src/widgets/styles/qwindowsvistastyle_p.h | 45 +++---- src/widgets/styles/styles.pri | 3 + 20 files changed, 475 insertions(+), 377 deletions(-) create mode 100644 src/widgets/styles/qstyleanimation.cpp create mode 100644 src/widgets/styles/qstyleanimation_p.h diff --git a/src/widgets/styles/qcleanlooksstyle.cpp b/src/widgets/styles/qcleanlooksstyle.cpp index 99e4b179f4..896f2ead32 100644 --- a/src/widgets/styles/qcleanlooksstyle.cpp +++ b/src/widgets/styles/qcleanlooksstyle.cpp @@ -67,6 +67,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -1759,9 +1760,11 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o } else { Q_D(const QCleanlooksStyle); int slideWidth = ((rect.width() - 4) * 2) / 3; - int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth; - if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth) - step = slideWidth - step; + int step = 0; +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + step = animation->progressStep(slideWidth); +#endif progressBar.setRect(rect.left() + 1 + step, rect.top() + 1, slideWidth / 2, rect.height() - 3); } diff --git a/src/widgets/styles/qcleanlooksstyle_p.h b/src/widgets/styles/qcleanlooksstyle_p.h index ccf0d5e1c2..5a6bef5fe7 100644 --- a/src/widgets/styles/qcleanlooksstyle_p.h +++ b/src/widgets/styles/qcleanlooksstyle_p.h @@ -66,7 +66,6 @@ class QCleanlooksStylePrivate : public QWindowsStylePrivate public: QCleanlooksStylePrivate() : QWindowsStylePrivate() { - animationFps = 24; } ~QCleanlooksStylePrivate() { diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 5c34caef6b..50fceab694 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -75,6 +75,7 @@ #include #include #include +#include #include @@ -1048,6 +1049,57 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget } #endif //QT_NO_TABBAR +/*! \internal */ +QList QCommonStylePrivate::animationTargets() const +{ + return animations.keys(); +} + +/*! \internal */ +QStyleAnimation * QCommonStylePrivate::animation(const QObject *target) const +{ + return animations.value(target); +} + +/*! \internal */ +void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) +{ +#ifndef QT_NO_ANIMATION + Q_Q(QCommonStyle); + stopAnimation(animation->target()); + q->connect(animation, SIGNAL(finished()), SLOT(_q_removeAnimation()), Qt::UniqueConnection); + q->connect(animation, SIGNAL(destroyed()), SLOT(_q_removeAnimation()), Qt::UniqueConnection); + animations.insert(animation->target(), animation); + animation->start(); +#endif // QT_NO_ANIMATION +} + +/*! \internal */ +void QCommonStylePrivate::stopAnimation(const QObject *target) +{ +#ifndef QT_NO_ANIMATION + QStyleAnimation *animation = animations.value(target); + if (animation) { + if (animation->state() == QAbstractAnimation::Stopped) + animations.take(target)->deleteLater(); + else + animation->stop(); + } +#endif // QT_NO_ANIMATION +} + +/*! \internal */ +void QCommonStylePrivate::_q_removeAnimation() +{ +#ifndef QT_NO_ANIMATION + Q_Q(QCommonStyle); + QObject *animation = q->sender(); + if (animation) { + animations.remove(animation->parent()); + animation->deleteLater(); + } +#endif // QT_NO_ANIMATION +} /*! \reimp @@ -5903,3 +5955,5 @@ void QCommonStyle::unpolish(QApplication *application) QT_END_NAMESPACE + +#include "moc_qcommonstyle.cpp" diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h index ba0837a5d5..878213702c 100644 --- a/src/widgets/styles/qcommonstyle.h +++ b/src/widgets/styles/qcommonstyle.h @@ -100,6 +100,7 @@ protected: private: Q_DECLARE_PRIVATE(QCommonStyle) Q_DISABLE_COPY(QCommonStyle) + Q_PRIVATE_SLOT(d_func(), void _q_removeAnimation()) }; QT_END_NAMESPACE diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h index 496723f8dd..2032e06e31 100644 --- a/src/widgets/styles/qcommonstyle_p.h +++ b/src/widgets/styles/qcommonstyle_p.h @@ -44,6 +44,7 @@ #include "qcommonstyle.h" #include "qstyle_p.h" +#include "qstyleanimation_p.h" #include "qstyleoption.h" @@ -67,17 +68,24 @@ class QCommonStylePrivate : public QStylePrivate { Q_DECLARE_PUBLIC(QCommonStyle) public: - inline QCommonStylePrivate() + inline QCommonStylePrivate() : #ifndef QT_NO_ITEMVIEWS - : cachedOption(0) + cachedOption(0), #endif + animationFps(30) { } -#ifndef QT_NO_ITEMVIEWS ~QCommonStylePrivate() { +#ifndef QT_NO_ANIMATION + qDeleteAll(animations); +#endif +#ifndef QT_NO_ITEMVIEWS delete cachedOption; +#endif } + +#ifndef QT_NO_ITEMVIEWS void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const; void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect, QRect *pixmapRect, QRect *textRect, bool sizehint) const; @@ -106,6 +114,17 @@ public: #ifndef QT_NO_TABBAR void tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const; #endif + + int animationFps; + void _q_removeAnimation(); + + QList animationTargets() const; + QStyleAnimation* animation(const QObject *target) const; + void startAnimation(QStyleAnimation *animation); + void stopAnimation(const QObject *target); + +private: + QHash animations; }; QT_END_NAMESPACE diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp index 9bcf45e928..83e70d022b 100644 --- a/src/widgets/styles/qgtkstyle.cpp +++ b/src/widgets/styles/qgtkstyle.cpp @@ -71,6 +71,7 @@ #include #include +#include #undef signals // Collides with GTK stymbols #include #include @@ -3491,9 +3492,11 @@ void QGtkStyle::drawControl(ControlElement element, } else { Q_D(const QGtkStyle); int slideWidth = ((rect.width() - 4) * 2) / 3; - int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth; - if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth) - step = slideWidth - step; + int step = 0; +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + step = animation->progressStep(slideWidth); +#endif progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height()); } diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index ecb3e7f222..77656f9ed5 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -101,6 +101,7 @@ #include #include #include +#include #include QT_USE_NAMESPACE @@ -125,9 +126,9 @@ QMacStylePrivate *mPrivate; { Q_UNUSED(notification); QEvent event(QEvent::StyleChange); - Q_FOREACH (QPointer sb, mPrivate->scrollBars) { - if (sb) - QCoreApplication::sendEvent(sb, &event); + Q_FOREACH (const QObject* target, mPrivate->animationTargets()) { + if (target) + QCoreApplication::sendEvent(const_cast(target), &event); } } @end @@ -1668,7 +1669,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti } QMacStylePrivate::QMacStylePrivate() - : timerID(-1), progressFrame(0), mouseDown(false) + : mouseDown(false) { defaultButtonStart = CFAbsoluteTimeGetCurrent(); memset(&buttonState, 0, sizeof(ButtonState)); @@ -1696,54 +1697,42 @@ bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QWidget * } return true; } - } else if (as == AquaProgressBar) { - if (progressBars.contains((const_cast(w)))) - return true; - } else if (as == AquaScrollBar) { - if (scrollBars.contains((const_cast(w)))) - return true; } - return false; + return animation(w); } void QMacStylePrivate::stopAnimate(QMacStylePrivate::Animates as, QWidget *w) { + stopAnimation(w); if (as == AquaPushButton && defaultButton) { + stopAnimation(defaultButton); QPushButton *tmp = defaultButton; defaultButton = 0; tmp->update(); - } else if (as == AquaProgressBar) { - progressBars.removeAll(w); } else if (as == AquaScrollBar) { - scrollBars.removeAll(w); scrollBarInfos.remove(w); } } void QMacStylePrivate::startAnimate(QMacStylePrivate::Animates as, QWidget *w) { +#ifndef QT_NO_ANIMATION + if (!animation(w)) + { + if (as == AquaProgressBar) + startAnimation(new QProgressStyleAnimation(animateSpeed(as), w)); + else + startAnimation(new QStyleAnimation(w)); + } +#endif if (as == AquaPushButton) defaultButton = static_cast(w); - else if (as == AquaProgressBar) - progressBars.append(w); - else if (as == AquaScrollBar) - scrollBars.append(w); - startAnimationTimer(); -} - -void QMacStylePrivate::startAnimationTimer() -{ - Q_Q(QMacStyle); - if ((defaultButton || !progressBars.isEmpty() || !scrollBars.isEmpty()) && timerID <= -1) - timerID = q->startTimer(animateSpeed(AquaListViewItemOpen)); } bool QMacStylePrivate::addWidget(QWidget *w) { //already knew of it - if (static_cast(w) == defaultButton - || progressBars.contains(static_cast(w)) - || scrollBars.contains(static_cast(w))) + if (w == defaultButton || animation(w)) return false; Q_Q(QMacStyle); @@ -1802,68 +1791,6 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags) return tds; } -void QMacStylePrivate::animate() -{ - Q_Q(QMacStyle); - int animated = 0; - if (defaultButton && defaultButton->isEnabled() && defaultButton->window()->isActiveWindow() - && defaultButton->isVisibleTo(0) && (defaultButton->isDefault() - || (defaultButton->autoDefault() && defaultButton->hasFocus())) - && doAnimate(AquaPushButton)) { - ++animated; - defaultButton->update(); - } - if (!progressBars.isEmpty()) { - int i = 0; - while (i < progressBars.size()) { - QWidget *maybeProgress = progressBars.at(i); - if (!maybeProgress) { - progressBars.removeAt(i); - } else { - if (QProgressBar *pb = qobject_cast(maybeProgress)) { - if (pb->maximum() == 0 || (pb->value() > 0 && pb->value() < pb->maximum())) { - if (doAnimate(AquaProgressBar)) - pb->update(); - } - } - ++i; - } - } - if (i > 0) { - ++progressFrame; - animated += i; - } - } - if (!scrollBars.isEmpty()) { - int i = 0; - const qint64 dt = QDateTime::currentMSecsSinceEpoch(); - while (i < scrollBars.size()) { - QWidget *maybeScroll = scrollBars.at(i); - if (!maybeScroll) { - scrollBars.removeAt(i); - } else { - if (QScrollBar *sb = qobject_cast(maybeScroll)) { - const OverlayScrollBarInfo& info = scrollBarInfos[sb]; - const qreal elapsed = qMax(dt - info.lastHovered, - dt - info.lastUpdate); - const CGFloat opacity = 1.0 - qMax(0.0, (elapsed - ScrollBarFadeOutDelay) / - ScrollBarFadeOutDuration); - if ((opacity > 0.0 || !info.cleared) && (elapsed > ScrollBarFadeOutDelay)) { - if (doAnimate(AquaScrollBar)) - sb->update(); - } - } - ++i; - ++animated; - } - } - } - if (animated <= 0) { - q->killTimer(timerID); - timerID = -1; - } -} - /*! \reimp */ bool QMacStyle::eventFilter(QObject *o, QEvent *e) { @@ -1874,12 +1801,11 @@ bool QMacStyle::eventFilter(QObject *o, QEvent *e) default: break; case QEvent::Show: - if (!d->progressBars.contains(pb)) - d->startAnimate(QMacStylePrivate::AquaProgressBar, pb); + d->startAnimate(QMacStylePrivate::AquaProgressBar, pb); break; case QEvent::Destroy: case QEvent::Hide: - d->progressBars.removeAll(pb); + d->stopAnimate(QMacStylePrivate::AquaProgressBar, pb); } #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 } else if (QScrollBar *sb = qobject_cast(o)) { @@ -1986,17 +1912,6 @@ bool QMacStyle::eventFilter(QObject *o, QEvent *e) return false; } -bool QMacStylePrivate::doAnimate(QMacStylePrivate::Animates as) -{ - if (as == AquaPushButton) { - } else if (as == AquaProgressBar) { - // something for later... - } else if (as == AquaListViewItemOpen) { - // To be revived later... - } - return true; -} - void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, QPainter *p, const QStyleOption *opt) const { @@ -3754,7 +3669,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter bdi.adornment |= kThemeAdornmentDefault; bdi.animation.time.start = d->defaultButtonStart; bdi.animation.time.current = CFAbsoluteTimeGetCurrent(); - const_cast(d)->startAnimationTimer(); } // Unlike Carbon, we want the button to always be drawn inside its bounds. // Therefore, make the button a bit smaller, so that even if it got focus, @@ -4462,7 +4376,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter tdi.min = pb->minimum; tdi.value = pb->progress; tdi.attributes = vertical ? 0 : kThemeTrackHorizontal; - tdi.trackInfo.progress.phase = d->progressFrame; +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(w))) + tdi.trackInfo.progress.phase = animation->animationStep(); +#endif if (!(pb->state & State_Active)) tdi.enableState = kThemeTrackInactive; else if (!(pb->state & State_Enabled)) @@ -6514,9 +6431,6 @@ bool QMacStyle::event(QEvent *e) } else if(e->type() == QEvent::FocusOut) { if(d->focusWidget) d->focusWidget->setWidget(0); - } else if (e->type() == QEvent::Timer) { - if (static_cast(e)->timerId() == d->timerID) - d->animate(); } return false; } diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h index ac482b8fc7..63cc005033 100644 --- a/src/widgets/styles/qmacstyle_mac_p.h +++ b/src/widgets/styles/qmacstyle_mac_p.h @@ -172,8 +172,6 @@ public: QSize szHint=QSize(-1, -1), QSize *insz = 0) const; void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe) const; - void animate(); - bool doAnimate(Animates); inline int animateSpeed(Animates) const { return 33; } // Utility functions @@ -202,13 +200,8 @@ public: HIThemeButtonDrawInfo *bdi) const; QPixmap generateBackgroundPattern() const; - void startAnimationTimer(); - public: QPointer defaultButton; //default push buttons - int timerID; - QList > progressBars; //existing progress bars that need animation - QList > scrollBars; //existing scroll bars that need animation struct OverlayScrollBarInfo { OverlayScrollBarInfo() @@ -235,7 +228,6 @@ public: int frame; enum { ButtonDark, ButtonLight } dir; } buttonState; - UInt8 progressFrame; mutable QPointer focusWidget; CFAbsoluteTime defaultButtonStart; bool mouseDown; diff --git a/src/widgets/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp index d22f82ff85..fe1e5c3dc3 100644 --- a/src/widgets/styles/qplastiquestyle.cpp +++ b/src/widgets/styles/qplastiquestyle.cpp @@ -79,7 +79,6 @@ static const int blueFrameWidth = 2; // with of line edit focus frame #include #include #include -#include #include #include #include @@ -89,6 +88,7 @@ static const int blueFrameWidth = 2; // with of line edit focus frame #include #include #include +#include QT_BEGIN_NAMESPACE @@ -987,12 +987,6 @@ public: virtual ~QPlastiqueStylePrivate(); void drawPartialFrame(QPainter *painter, const QStyleOptionComplex *option, const QRect &rect, const QWidget *widget) const; - -#ifndef QT_NO_PROGRESSBAR - QList bars; - int progressBarAnimateTimer; - QElapsedTimer timer; -#endif }; /*! @@ -1000,9 +994,6 @@ public: */ QPlastiqueStylePrivate::QPlastiqueStylePrivate() : QWindowsStylePrivate() -#ifndef QT_NO_PROGRESSBAR - , progressBarAnimateTimer(0) -#endif { } @@ -2577,9 +2568,11 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } } else { int slideWidth = ((rect.width() - 4) * 2) / 3; - int step = ((d->animateStep * slideWidth) / ProgressBarFps) % slideWidth; - if ((((d->animateStep * slideWidth) / ProgressBarFps) % (2 * slideWidth)) >= slideWidth) - step = slideWidth - step; + int step = 0; +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + step = animation->progressStep(slideWidth); +#endif progressBar.setRect(rect.left() + 2 + step, rect.top() + 2, slideWidth / 2, rect.height() - 4); } @@ -2732,7 +2725,13 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op if (!vertical) progressBar.adjust(0, 1, 0, 1); if (!indeterminate) { - int step = (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) ? (d->animateStep % 20) : 0; + int step = 0; + if (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) { +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + step = animation->animationStep() % 20; +#endif + } if (reverse) painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache); else @@ -5706,11 +5705,8 @@ void QPlastiqueStyle::unpolish(QWidget *widget) } #ifndef QT_NO_PROGRESSBAR - if (AnimateBusyProgressBar && qobject_cast(widget)) { - Q_D(QPlastiqueStyle); + if (AnimateBusyProgressBar && qobject_cast(widget)) widget->removeEventFilter(this); - d->bars.removeAll(static_cast(widget)); - } #endif #if defined QPlastique_MaskButtons @@ -5834,24 +5830,13 @@ bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event) switch (event->type()) { case QEvent::Show: - if (QProgressBar *bar = qobject_cast(watched)) { - d->bars.append(bar); - if (d->bars.size() == 1) { - Q_ASSERT(ProgressBarFps > 0); - d->timer.start(); - d->progressBarAnimateTimer = startTimer(1000 / ProgressBarFps); - } - } + if (QProgressBar *bar = qobject_cast(watched)) + d->startProgressAnimation(this, bar); break; case QEvent::Destroy: case QEvent::Hide: - if(!d->bars.isEmpty()) { - d->bars.removeAll(reinterpret_cast(watched)); - if (d->bars.isEmpty()) { - killTimer(d->progressBarAnimateTimer); - d->progressBarAnimateTimer = 0; - } - } + if (QProgressBar *bar = qobject_cast(watched)) + d->stopProgressAnimation(this, bar); break; #if defined QPlastique_MaskButtons case QEvent::Resize: @@ -5879,26 +5864,6 @@ bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event) return QWindowsStyle::eventFilter(watched, event); } -/*! - \reimp -*/ -void QPlastiqueStyle::timerEvent(QTimerEvent *event) -{ -#ifndef QT_NO_PROGRESSBAR - Q_D(QPlastiqueStyle); - - if (event->timerId() == d->progressBarAnimateTimer) { - Q_ASSERT(ProgressBarFps > 0); - d->animateStep = d->timer.elapsed() / (1000 / ProgressBarFps); - foreach (QProgressBar *bar, d->bars) { - if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0)) - bar->update(); - } - } -#endif // QT_NO_PROGRESSBAR - event->ignore(); -} - QT_END_NAMESPACE #endif // !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN) diff --git a/src/widgets/styles/qplastiquestyle.h b/src/widgets/styles/qplastiquestyle.h index 05679a85c3..bda686e215 100644 --- a/src/widgets/styles/qplastiquestyle.h +++ b/src/widgets/styles/qplastiquestyle.h @@ -101,7 +101,6 @@ public: protected: bool eventFilter(QObject *watched, QEvent *event); - void timerEvent(QTimerEvent *event); private: Q_DISABLE_COPY(QPlastiqueStyle) diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp new file mode 100644 index 0000000000..8bc8e9d241 --- /dev/null +++ b/src/widgets/styles/qstyleanimation.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qstyleanimation_p.h" +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_ANIMATION + +QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target), + _startTime(QTime::currentTime()) +{ +} + +QStyleAnimation::~QStyleAnimation() +{ +} + +int QStyleAnimation::duration() const +{ + return -1; +} + +QObject *QStyleAnimation::target() const +{ + return parent(); +} + +QTime QStyleAnimation::startTime() const +{ + return _startTime; +} + +void QStyleAnimation::setStartTime(const QTime &time) +{ + _startTime = time; +} + +bool QStyleAnimation::isUpdateNeeded() const +{ + return true; +} + +void QStyleAnimation::updateCurrentTime(int) +{ + if (target()->isWidgetType()) { + QWidget *widget = static_cast(target()); + if (!widget->isVisible() || widget->window()->isMinimized()) + stop(); + } + + if (isUpdateNeeded()) { + QEvent event(QEvent::StyleAnimationUpdate); + QCoreApplication::sendEvent(target(), &event); + } +} + +QProgressStyleAnimation::QProgressStyleAnimation(int speed, QObject *target) : + QStyleAnimation(target), _speed(speed), _step(-1) +{ +} + +int QProgressStyleAnimation::animationStep() const +{ + return currentTime() / (1000.0 / _speed); +} + +int QProgressStyleAnimation::progressStep(int width) const +{ + int step = animationStep(); + int progress = (step * width / _speed) % width; + if (((step * width / _speed) % (2 * width)) >= width) + progress = width - progress; + return progress; +} + +int QProgressStyleAnimation::speed() const +{ + return _speed; +} + +void QProgressStyleAnimation::setSpeed(int speed) +{ + _speed = speed; +} + +bool QProgressStyleAnimation::isUpdateNeeded() const +{ + QProgressBar *pb = qobject_cast(parent()); + if (pb && pb->minimum() == 0 && pb->maximum() == 0) { + int current = animationStep(); + if (_step == -1 || _step != current) + { + _step = current; + return true; + } + } else { + // the progress bar is no longer indeterminate -> stop + const_cast(this)->stop(); + } + return false; +} + +#endif // QT_NO_ANIMATION + +QT_END_NAMESPACE diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h new file mode 100644 index 0000000000..2c00048b7d --- /dev/null +++ b/src/widgets/styles/qstyleanimation_p.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSTYLEANIMATION_P_H +#define QSTYLEANIMATION_P_H + +#include "qabstractanimation.h" +#include "qdatetime.h" + +QT_BEGIN_NAMESPACE + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience of +// qcommonstyle.cpp. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#ifndef QT_NO_ANIMATION + +class QStyleAnimation : public QAbstractAnimation +{ + Q_OBJECT + +public: + QStyleAnimation(QObject *target); + virtual ~QStyleAnimation(); + + int duration() const; + QObject *target() const; + + QTime startTime() const; + void setStartTime(const QTime &time); + +protected: + virtual bool isUpdateNeeded() const; + virtual void updateCurrentTime(int time); + +private: + QTime _startTime; +}; + +class QProgressStyleAnimation : public QStyleAnimation +{ + Q_OBJECT + +public: + QProgressStyleAnimation(int speed, QObject *target); + + int animationStep() const; + int progressStep(int width) const; + + int speed() const; + void setSpeed(int speed); + +protected: + bool isUpdateNeeded() const; + +private: + int _speed; + mutable int _step; +}; + +#endif // QT_NO_ANIMATION + +QT_END_NAMESPACE + +#endif // QSTYLEANIMATION_P_H diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 1cd9a98e87..068b7a4355 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -3832,7 +3833,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (pb->minimum == 0 && pb->maximum == 0) { Q_D(const QWindowsStyle); int chunkCount = fillWidth/chunkWidth; - int offset = (d->animateStep*8%rect.width()); + int offset = 0; +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(w))) + offset = animation->animationStep() * 8 % rect.width(); +#endif int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset; while (chunkCount > 0) { r.setRect(x, rect.y(), chunkWidth, rect.height()); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 355ecf8a35..ee13852813 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -70,6 +70,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -117,7 +118,7 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; \internal */ QWindowsStylePrivate::QWindowsStylePrivate() - : alt_down(false), menuBarTimer(0), animationFps(10), animateTimer(0), animateStep(0) + : alt_down(false), menuBarTimer(0) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA @@ -126,27 +127,21 @@ QWindowsStylePrivate::QWindowsStylePrivate() pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo"); } #endif - startTime.start(); } -void QWindowsStylePrivate::startAnimation(QObject *o, QProgressBar *bar) +void QWindowsStylePrivate::startProgressAnimation(QObject *o, QProgressBar *bar) { - if (!animatedProgressBars.contains(bar)) { - animatedProgressBars << bar; - if (!animateTimer) { - Q_ASSERT(animationFps > 0); - animateTimer = o->startTimer(1000 / animationFps); - } - } + Q_UNUSED(o); +#ifndef QT_NO_ANIMATION + if (!animation(bar)) + startAnimation(new QProgressStyleAnimation(animationFps, bar)); +#endif } -void QWindowsStylePrivate::stopAnimation(QObject *o, QProgressBar *bar) +void QWindowsStylePrivate::stopProgressAnimation(QObject *o, QProgressBar *bar) { - animatedProgressBars.removeAll(bar); - if (animatedProgressBars.isEmpty() && animateTimer) { - o->killTimer(animateTimer); - animateTimer = 0; - } + Q_UNUSED(o); + stopAnimation(bar); } // Returns true if the toplevel parent of \a widget has seen the Alt-key @@ -156,23 +151,6 @@ bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const return seenAlt.contains(widget); } -/*! - \reimp -*/ -void QWindowsStyle::timerEvent(QTimerEvent *event) -{ -#ifndef QT_NO_PROGRESSBAR - Q_D(QWindowsStyle); - if (event->timerId() == d->animateTimer) { - Q_ASSERT(d->animationFps> 0); - d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps); - foreach (QProgressBar *bar, d->animatedProgressBars) - bar->update(); - } -#endif // QT_NO_PROGRESSBAR - event->ignore(); -} - /*! \reimp */ @@ -232,9 +210,9 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) // Animation by timer for progress bars that have their min and // max values the same if (bar->minimum() == bar->maximum()) - d->startAnimation(this, bar); + d->startProgressAnimation(this, bar); else - d->stopAnimation(this, bar); + d->stopProgressAnimation(this, bar); } break; case QEvent::Destroy: @@ -242,7 +220,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) // Do static_cast because there is no type info when getting // the destroy event. We know that it is a QProgressBar, since // we only install a widget event filter for QScrollBars. - d->stopAnimation(this, static_cast(o)); + d->stopProgressAnimation(this, static_cast(o)); break; #endif // QT_NO_PROGRESSBAR default: @@ -349,7 +327,7 @@ void QWindowsStyle::unpolish(QWidget *widget) if (QProgressBar *bar=qobject_cast(widget)) { Q_D(QWindowsStyle); widget->removeEventFilter(this); - d->stopAnimation(this, bar); + d->stopProgressAnimation(this, bar); } #endif } @@ -2405,8 +2383,12 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai pbBits.rect = rect; pbBits.palette = pal2; + int step = 0; int chunkCount = w / unit_width + 1; - int step = d->animateStep%chunkCount; +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + step = (animation->animationStep() / 3) % chunkCount; +#endif int chunksInRow = 5; int myY = pbBits.rect.y(); int myHeight = pbBits.rect.height(); diff --git a/src/widgets/styles/qwindowsstyle.h b/src/widgets/styles/qwindowsstyle.h index cacaeaa301..1d9347a72e 100644 --- a/src/widgets/styles/qwindowsstyle.h +++ b/src/widgets/styles/qwindowsstyle.h @@ -91,7 +91,6 @@ public: protected: bool eventFilter(QObject *o, QEvent *e); - void timerEvent(QTimerEvent *event); QWindowsStyle(QWindowsStylePrivate &dd); private: diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h index 0cf53b9903..f24696f0bd 100644 --- a/src/widgets/styles/qwindowsstyle_p.h +++ b/src/widgets/styles/qwindowsstyle_p.h @@ -59,7 +59,6 @@ #ifndef QT_NO_STYLE_WINDOWS #include #include -#include QT_BEGIN_NAMESPACE @@ -71,19 +70,14 @@ class QWindowsStylePrivate : public QCommonStylePrivate Q_DECLARE_PUBLIC(QWindowsStyle) public: QWindowsStylePrivate(); - void startAnimation(QObject *o, QProgressBar *bar); - void stopAnimation(QObject *o, QProgressBar *bar); + void startProgressAnimation(QObject *o, QProgressBar *bar); + void stopProgressAnimation(QObject *o, QProgressBar *bar); bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } bool alt_down; QList seenAlt; int menuBarTimer; - QList animatedProgressBars; - int animationFps; - int animateTimer; - QElapsedTimer startTime; - int animateStep; QColor inactiveCaptionText; QColor activeCaptionColor; QColor activeGradientCaptionColor; diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index cb34a20fa3..d1a0af3a91 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -43,6 +43,7 @@ #include "qwindowsvistastyle_p.h" #include #include +#include #include #include #include @@ -202,6 +203,11 @@ void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option Q_UNUSED(painter); } +bool QWindowsVistaAnimation::isUpdateNeeded() const +{ + return QWindowsVistaStylePrivate::useVista(); +} + /*! \internal Helperfunction to paint the current transition state between two @@ -255,7 +261,7 @@ void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, flo /*! \internal Paints a transition state. The result will be a mix between the initial and final state of the transition, depending on the time - difference between _startTime and current time. + difference between startTime and current time. */ void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option) { @@ -263,18 +269,18 @@ void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *optio if (_duration > 0) { QTime current = QTime::currentTime(); - if (_startTime > current) - _startTime = current; + if (startTime() > current) + setStartTime(current); - int timeDiff = _startTime.msecsTo(current); + int timeDiff = startTime().msecsTo(current); alpha = timeDiff/(float)_duration; if (timeDiff > _duration) { - _running = false; + stop(); alpha = 1.0; } } else { - _running = false; + stop(); } drawBlendedImage(painter, option->rect, alpha); } @@ -282,7 +288,7 @@ void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *optio /*! \internal Paints a pulse. The result will be a mix between the primary and secondary pulse images depending on the time difference between - _startTime and current time. + startTime and current time. */ void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option) { @@ -290,15 +296,15 @@ void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option) if (_duration > 0) { QTime current = QTime::currentTime(); - if (_startTime > current) - _startTime = current; + if (startTime() > current) + setStartTime(current); - int timeDiff = _startTime.msecsTo(current) % _duration*2; + int timeDiff = startTime().msecsTo(current) % _duration*2; if (timeDiff > _duration) timeDiff = _duration*2 - timeDiff; alpha = timeDiff/(float)_duration; } else { - _running = false; + stop(); } drawBlendedImage(painter, option->rect, alpha); } @@ -341,6 +347,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt int state = option->state; if (!QWindowsVistaStylePrivate::useVista()) { + foreach (const QObject *target, d->animationTargets()) + d->stopAnimation(target); QWindowsStyle::drawPrimitive(element, option, painter, widget); return; } @@ -399,9 +407,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt startImage.fill(0); QPainter startPainter(&startImage); - QWindowsVistaAnimation *anim = d->widgetAnimation(widget); - QWindowsVistaTransition *t = new QWindowsVistaTransition; - t->setWidget(w); + QWindowsVistaAnimation *anim = qobject_cast(d->animation(widget)); + QWindowsVistaTransition *t = new QWindowsVistaTransition(w); // If we have a running animation on the widget already, we will use that to paint the initial // state of the new transition, this ensures a smooth transition from a current animation such as a @@ -539,7 +546,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_IndicatorCheckBox: case PE_IndicatorRadioButton: { - if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = qobject_cast(d->animation(widget)) ){ a->paint(painter, option); } else { QWindowsXPStyle::drawPrimitive(element, option, painter, widget); @@ -655,7 +662,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt break; case PE_FrameLineEdit: - if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = qobject_cast(d->animation(widget))) { anim->paint(painter, option); } else { QPainter *p = painter; @@ -903,6 +910,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsVistaStylePrivate *d = const_cast(d_func()); if (!QWindowsVistaStylePrivate::useVista()) { + foreach (const QObject *target, d->animationTargets()) + d->stopAnimation(target); QWindowsStyle::drawControl(element, option, painter, widget); return; } @@ -950,14 +959,13 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - QWindowsVistaAnimation *anim = d->widgetAnimation(widget); + QWindowsVistaAnimation *anim = qobject_cast(d->animation(widget)); QStyleOptionButton opt = *button; opt.state = (QStyle::State)oldState; startImage.fill(0); - QWindowsVistaTransition *t = new QWindowsVistaTransition; - t->setWidget(w); + QWindowsVistaTransition *t = new QWindowsVistaTransition(w); QPainter startPainter(&startImage); if (!anim) { @@ -992,7 +1000,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption case CE_PushButtonBevel: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - QWindowsVistaAnimation *anim = d->widgetAnimation(widget); + QWindowsVistaAnimation *anim = qobject_cast(d->animation(widget)); if (anim && (btn->state & State_Enabled)) { anim->paint(painter, option); } else { @@ -1026,8 +1034,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); alternateImage.fill(0); - QWindowsVistaPulse *pulse = new QWindowsVistaPulse; - pulse->setWidget(const_cast(widget)); + QWindowsVistaPulse *pulse = new QWindowsVistaPulse(const_cast(widget)); QPainter startPainter(&startImage); stateId = PBS_DEFAULTED; @@ -1095,16 +1102,10 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } if (const QProgressBar *progressbar = qobject_cast(widget)) { - if (isIndeterminate || (progressbar->value() > 0 && (progressbar->value() < progressbar->maximum()) && d->transitionsEnabled())) { - if (!d->widgetAnimation(progressbar)) { - QWindowsVistaAnimation *a = new QWindowsVistaAnimation; - a->setWidget(const_cast(widget)); - a->setStartTime(QTime::currentTime()); - d->startAnimation(a); - } - } else { + if (isIndeterminate || (progressbar->value() > 0 && (progressbar->value() < progressbar->maximum()) && d->transitionsEnabled())) + d->startProgressAnimation(0, const_cast(progressbar)); + else d->stopAnimation(progressbar); - } } XPThemeData theme(widget, painter, @@ -1115,7 +1116,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QTime current = QTime::currentTime(); if (isIndeterminate) { - if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { + if (QProgressStyleAnimation *a = qobject_cast(d->animation(widget))) { int glowSize = 120; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1185,7 +1186,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } d->drawBackground(theme); - if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { + if (QProgressStyleAnimation *a = qobject_cast(d->animation(widget))) { int glowSize = 140; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1574,6 +1575,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle { QWindowsVistaStylePrivate *d = const_cast(d_func()); if (!QWindowsVistaStylePrivate::useVista()) { + foreach (const QObject *target, d->animationTargets()) + d->stopAnimation(target); QWindowsStyle::drawComplexControl(control, option, painter, widget); return; } @@ -1636,9 +1639,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - QWindowsVistaAnimation *anim = d->widgetAnimation(widget); - QWindowsVistaTransition *t = new QWindowsVistaTransition; - t->setWidget(w); + QWindowsVistaAnimation *anim = qobject_cast(d->animation(widget)); + QWindowsVistaTransition *t = new QWindowsVistaTransition(w); if (!anim) { if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) { //Combo boxes are special cased to avoid cleartype issues @@ -1692,7 +1694,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle t->setDuration(500); } - if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = qobject_cast(d->animation(widget))) { anim->paint(painter, option); return; } @@ -2335,29 +2337,6 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt return rect; } -/*! - \internal - */ -bool QWindowsVistaStyle::event(QEvent *e) -{ - Q_D(QWindowsVistaStyle); - switch (e->type()) { - case QEvent::Timer: - { - QTimerEvent *timerEvent = (QTimerEvent *)e; - if (d->animationTimer.timerId() == timerEvent->timerId()) { - d->timerEvent(); - e->accept(); - return true; - } - } - break; - default: - break; - } - return QWindowsXPStyle::event(e); -} - /*! \internal */ @@ -2549,53 +2528,9 @@ QWindowsVistaStylePrivate::QWindowsVistaStylePrivate() : QWindowsVistaStylePrivate::~QWindowsVistaStylePrivate() { - qDeleteAll(animations); cleanupTreeViewTheming(); } -void QWindowsVistaStylePrivate::timerEvent() -{ - for (int i = animations.size() - 1 ; i >= 0 ; --i) { - - if (animations[i]->widget()) - animations[i]->widget()->update(); - - if (!animations[i]->widget() || - !animations[i]->widget()->isVisible() || - animations[i]->widget()->window()->isMinimized() || - !animations[i]->running() || - !QWindowsVistaStylePrivate::useVista()) - { - QWindowsVistaAnimation *a = animations.takeAt(i); - delete a; - } - } - if (animations.size() == 0 && animationTimer.isActive()) { - animationTimer.stop(); - } -} - -void QWindowsVistaStylePrivate::stopAnimation(const QWidget *w) -{ - for (int i = animations.size() - 1 ; i >= 0 ; --i) { - if (animations[i]->widget() == w) { - QWindowsVistaAnimation *a = animations.takeAt(i); - delete a; - break; - } - } -} - -void QWindowsVistaStylePrivate::startAnimation(QWindowsVistaAnimation *t) -{ - Q_Q(QWindowsVistaStyle); - stopAnimation(t->widget()); - animations.append(t); - if (animations.size() > 0 && !animationTimer.isActive()) { - animationTimer.start(45, q); - } -} - bool QWindowsVistaStylePrivate::transitionsEnabled() const { BOOL animEnabled = false; @@ -2607,19 +2542,6 @@ bool QWindowsVistaStylePrivate::transitionsEnabled() const return false; } - -QWindowsVistaAnimation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const -{ - if (!widget) - return 0; - foreach (QWindowsVistaAnimation *a, animations) { - if (a->widget() == widget) - return a; - } - return 0; -} - - /*! \internal Returns true if all the necessary theme engine symbols were resolved. diff --git a/src/widgets/styles/qwindowsvistastyle.h b/src/widgets/styles/qwindowsvistastyle.h index 5a030afddc..0b17881101 100644 --- a/src/widgets/styles/qwindowsvistastyle.h +++ b/src/widgets/styles/qwindowsvistastyle.h @@ -88,7 +88,6 @@ public: void polish(QPalette &pal); void polish(QApplication *app); void unpolish(QApplication *app); - bool event(QEvent *event); QPalette standardPalette() const; private: diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h index faf3777025..1d427fe45c 100644 --- a/src/widgets/styles/qwindowsvistastyle_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p.h @@ -57,6 +57,7 @@ #if !defined(QT_NO_STYLE_WINDOWSVISTA) #include +#include #include #include #include @@ -83,7 +84,6 @@ #include #include #include -#include #include #include @@ -135,57 +135,50 @@ QT_BEGIN_NAMESPACE #define TDLG_SECONDARYPANEL 8 #endif -class QWindowsVistaAnimation +class QWindowsVistaAnimation : public QStyleAnimation { -public : - QWindowsVistaAnimation() : _running(true) { } + Q_OBJECT +public: + QWindowsVistaAnimation(QObject *target) : QStyleAnimation(target), _duration(-1) { } virtual ~QWindowsVistaAnimation() { } - QWidget * widget() const { return _widget; } - bool running() const { return _running; } - const QTime &startTime() const { return _startTime; } - void setRunning(bool val) { _running = val; } - void setWidget(QWidget *widget) { _widget = widget; } - void setStartTime(const QTime &startTime) { _startTime = startTime; } virtual void paint(QPainter *painter, const QStyleOption *option); + virtual bool isUpdateNeeded() const; + virtual int duration() const { return _duration; } + //set time in ms to complete a state transition / pulse cycle + void setDuration(int duration) { _duration = duration; } protected: void drawBlendedImage(QPainter *painter, QRect rect, float value); - QTime _startTime; - QPointer _widget; QImage _primaryImage; QImage _secondaryImage; QImage _tempImage; - bool _running; + int _duration; }; // Handles state transition animations class QWindowsVistaTransition : public QWindowsVistaAnimation { -public : - QWindowsVistaTransition() : QWindowsVistaAnimation() {} + Q_OBJECT +public: + QWindowsVistaTransition(QObject *target) : QWindowsVistaAnimation(target) {} virtual ~QWindowsVistaTransition() { } - void setDuration(int duration) { _duration = duration; } void setStartImage(const QImage &image) { _primaryImage = image; } void setEndImage(const QImage &image) { _secondaryImage = image; } virtual void paint(QPainter *painter, const QStyleOption *option); - int duration() const { return _duration; } - int _duration; //set time in ms to complete a state transition }; // Handles pulse animations (default buttons) class QWindowsVistaPulse: public QWindowsVistaAnimation { -public : - QWindowsVistaPulse() : QWindowsVistaAnimation() {} + Q_OBJECT +public: + QWindowsVistaPulse(QObject *target) : QWindowsVistaAnimation(target) {} virtual ~QWindowsVistaPulse() { } - void setDuration(int duration) { _duration = duration; } void setPrimaryImage(const QImage &image) { _primaryImage = image; } void setAlternateImage(const QImage &image) { _secondaryImage = image; } virtual void paint(QPainter *painter, const QStyleOption *option); - int duration() const { return _duration; } - int _duration; //time in ms to complete a pulse cycle }; @@ -198,18 +191,12 @@ public: ~QWindowsVistaStylePrivate(); static bool resolveSymbols(); static inline bool useVista(); - void startAnimation(QWindowsVistaAnimation *); - void stopAnimation(const QWidget *); - QWindowsVistaAnimation* widgetAnimation(const QWidget *) const; - void timerEvent(); bool transitionsEnabled() const; private: bool initTreeViewTheming(); void cleanupTreeViewTheming(); - QList animations; - QBasicTimer animationTimer; HWND m_treeViewHelper; }; diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index 6ba9875236..d04b3d5416 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -3,6 +3,7 @@ HEADERS += \ styles/qdrawutil.h \ styles/qstyle.h \ + styles/qstyleanimation_p.h \ styles/qstylefactory.h \ styles/qstyleoption.h \ styles/qstyleplugin.h \ @@ -11,12 +12,14 @@ HEADERS += \ styles/qstylehelper_p.h \ styles/qproxystyle.h \ styles/qproxystyle_p.h \ + styles/qcommonstyle_p.h \ styles/qstylepainter.h \ styles/qstylesheetstyle_p.h SOURCES += \ styles/qdrawutil.cpp \ styles/qstyle.cpp \ + styles/qstyleanimation.cpp \ styles/qstylefactory.cpp \ styles/qstyleoption.cpp \ styles/qstyleplugin.cpp \ From 3928bd06068cdd301dd4b021af55baa2707fa959 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 16 Oct 2012 09:02:08 +0200 Subject: [PATCH 007/114] Add HasFrame feature to QStyleOptionTab This makes it possible for styles like Fusion to draw tabbars different when they have a frame. Change-Id: I1bb21198c0c3caf44c757f6f39310bf2509054bf Reviewed-by: J-P Nurmi --- src/widgets/styles/qstyleoption.cpp | 17 +++++++++++++++-- src/widgets/styles/qstyleoption.h | 3 +++ src/widgets/widgets/qtabbar.cpp | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index bc363d3a31..3017f30470 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1271,7 +1271,8 @@ QStyleOptionTab::QStyleOptionTab() row(0), position(Beginning), selectedPosition(NotAdjacent), cornerWidgets(QStyleOptionTab::NoCornerWidgets), - documentMode(false) + documentMode(false), + features(QStyleOptionTab::None) { } @@ -1284,7 +1285,8 @@ QStyleOptionTab::QStyleOptionTab(int version) row(0), position(Beginning), selectedPosition(NotAdjacent), cornerWidgets(QStyleOptionTab::NoCornerWidgets), - documentMode(false) + documentMode(false), + features(QStyleOptionTab::None) { } @@ -1437,6 +1439,17 @@ QStyleOptionTab::QStyleOptionTab(int version) The default value is false; */ +/*! + \enum QStyleOptionTab::TabFeature + + Describes the various features that a tab button can have. + + \value None A normal tab button. + \value HasFrame The tab button is positioned on a tab frame + + \sa features +*/ + /*! \variable QStyleOptionTab::leftButtonSize \brief the size for the left widget on the tab. diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 1f35ecb61f..7ca0ca2bf3 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -255,7 +255,9 @@ public: enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected }; enum CornerWidget { NoCornerWidgets = 0x00, LeftCornerWidget = 0x01, RightCornerWidget = 0x02 }; + enum TabFeature { None = 0x00, HasFrame = 0x01 }; Q_DECLARE_FLAGS(CornerWidgets, CornerWidget) + Q_DECLARE_FLAGS(TabFeatures, TabFeature) QTabBar::Shape shape; QString text; @@ -268,6 +270,7 @@ public: bool documentMode; QSize leftButtonSize; QSize rightButtonSize; + TabFeatures features; QStyleOptionTab(); QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; } diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 903f496ab7..f9325e6352 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -185,6 +185,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const #ifndef QT_NO_TABWIDGET if (const QTabWidget *tw = qobject_cast(parentWidget())) { + option->features |= QStyleOptionTab::HasFrame; if (tw->cornerWidget(Qt::TopLeftCorner) || tw->cornerWidget(Qt::BottomLeftCorner)) option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget; if (tw->cornerWidget(Qt::TopRightCorner) || tw->cornerWidget(Qt::BottomRightCorner)) From c153f471d2b45ea0fbe9848b59403807c1cd37ab Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 16 Oct 2012 11:43:53 +0200 Subject: [PATCH 008/114] Remove QImageReader benchmark dependency on QtWidgets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QLabel is not actually used. Change-Id: Ia3f43b734fa52ad002111943ed1ba55b9e8a678c Reviewed-by: Thorbjørn Lund Martsum Reviewed-by: Sean Harmer --- tests/benchmarks/gui/image/qimagereader/qimagereader.pro | 2 +- tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro index 0d8387de34..4f82123596 100644 --- a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro +++ b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro @@ -1,4 +1,4 @@ -QT += widgets testlib +QT += testlib TEMPLATE = app TARGET = tst_bench_qimagereader diff --git a/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp b/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp index 679e2f26e5..ea883cc50b 100644 --- a/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include From c3b939818af214392505c58b93d5f8df46fa09d8 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 10 Oct 2012 13:58:19 +0200 Subject: [PATCH 009/114] QPA: Introducing QPlatformTheme standardPixmap(), fileIconPixmap() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The basic idea is that the platform theme is now responsible for providing the pixmaps for the given standard name, or any file or directory. Then, the QStyle implementation should query the platform theme for the pixmaps, and build the icons accordingly using ThemeHint::IconPixmapSizes. Same thing for QFileIconProvider. This also opens future support for getting platform dependent pixmaps in QtQuick components. Also includes the implementation for the Cocoa (QCocoaTheme) and Windows (QWindowsTheme) platform plugins. Task-number: QTBUG-27450 Change-Id: I4e8406585d970a9af481be10f6643cf0abbc38a3 Reviewed-by: Gabriel de Dietrich Reviewed-by: Friedemann Kleint Reviewed-by: Jens Bache-Wiig Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qplatformtheme.cpp | 19 ++ src/gui/kernel/qplatformtheme.h | 84 +++++- src/plugins/platforms/cocoa/qcocoatheme.h | 2 + src/plugins/platforms/cocoa/qcocoatheme.mm | 144 ++++++++++ .../platforms/windows/qtwindows_additional.h | 15 + .../platforms/windows/qwindowscontext.cpp | 5 +- .../platforms/windows/qwindowscontext.h | 3 + .../platforms/windows/qwindowstheme.cpp | 230 +++++++++++++++ src/plugins/platforms/windows/qwindowstheme.h | 3 + src/widgets/itemviews/qfileiconprovider.cpp | 196 +++---------- src/widgets/styles/qcommonstyle.cpp | 123 +++----- src/widgets/styles/qmacstyle_mac.mm | 1 + src/widgets/styles/qstyle.cpp | 1 + src/widgets/styles/qstyle.h | 1 + src/widgets/styles/qwindowsstyle.cpp | 268 +++--------------- 15 files changed, 626 insertions(+), 469 deletions(-) diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index b91d3d0281..2e896eecf4 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -164,6 +165,22 @@ const QFont *QPlatformTheme::font(Font type) const return 0; } +QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const +{ + Q_UNUSED(sp); + Q_UNUSED(size); + // TODO Should return QCommonStyle pixmaps? + return QPixmap(); +} + +QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const +{ + Q_UNUSED(fileInfo); + Q_UNUSED(size); + // TODO Should return QCommonStyle pixmaps? + return QPixmap(); +} + QVariant QPlatformTheme::themeHint(ThemeHint hint) const { return QPlatformTheme::defaultThemeHint(hint); @@ -223,6 +240,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant(int(QTextCharFormat::SpellCheckUnderline)); case TabAllWidgets: return QVariant(true); + case IconPixmapSizes: + return QVariant::fromValue(QList()); } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 398339255c..25453e792f 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -67,6 +67,9 @@ class QPlatformSystemTrayIcon; class QVariant; class QPalette; class QFont; +class QPixmap; +class QSizeF; +class QFileInfo; class Q_GUI_EXPORT QPlatformTheme { @@ -97,7 +100,8 @@ public: KeyboardScheme, UiEffects, SpellCheckUnderlineStyle, - TabAllWidgets + TabAllWidgets, + IconPixmapSizes }; enum DialogType { @@ -150,6 +154,81 @@ public: NFonts }; + enum StandardPixmap { // Keep in sync with QStyle::StandardPixmap + TitleBarMenuButton, + TitleBarMinButton, + TitleBarMaxButton, + TitleBarCloseButton, + TitleBarNormalButton, + TitleBarShadeButton, + TitleBarUnshadeButton, + TitleBarContextHelpButton, + DockWidgetCloseButton, + MessageBoxInformation, + MessageBoxWarning, + MessageBoxCritical, + MessageBoxQuestion, + DesktopIcon, + TrashIcon, + ComputerIcon, + DriveFDIcon, + DriveHDIcon, + DriveCDIcon, + DriveDVDIcon, + DriveNetIcon, + DirOpenIcon, + DirClosedIcon, + DirLinkIcon, + DirLinkOpenIcon, + FileIcon, + FileLinkIcon, + ToolBarHorizontalExtensionButton, + ToolBarVerticalExtensionButton, + FileDialogStart, + FileDialogEnd, + FileDialogToParent, + FileDialogNewFolder, + FileDialogDetailedView, + FileDialogInfoView, + FileDialogContentsView, + FileDialogListView, + FileDialogBack, + DirIcon, + DialogOkButton, + DialogCancelButton, + DialogHelpButton, + DialogOpenButton, + DialogSaveButton, + DialogCloseButton, + DialogApplyButton, + DialogResetButton, + DialogDiscardButton, + DialogYesButton, + DialogNoButton, + ArrowUp, + ArrowDown, + ArrowLeft, + ArrowRight, + ArrowBack, + ArrowForward, + DirHomeIcon, + CommandLink, + VistaShield, + BrowserReload, + BrowserStop, + MediaPlay, + MediaStop, + MediaPause, + MediaSkipForward, + MediaSkipBackward, + MediaSeekForward, + MediaSeekBackward, + MediaVolume, + MediaVolumeMuted, + // do not add any values below/greater than this + CustomBase = 0xf0000000 + }; + enum KeyboardSchemes { WindowsKeyboardScheme, @@ -190,6 +269,9 @@ public: virtual QVariant themeHint(ThemeHint hint) const; + virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; + virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const; + static QVariant defaultThemeHint(ThemeHint hint); }; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h index a747a82d09..0ff160957f 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.h +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -67,6 +67,8 @@ public: const QPalette *palette(Palette type = SystemPalette) const; const QFont *font(Font type = SystemFont) const; + QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; + QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const; QVariant themeHint(ThemeHint hint) const; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index ddb550dd5f..967d65faec 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -54,7 +54,9 @@ #include "qcocoamenu.h" #include "qcocoamenubar.h" +#include #include +#include #include #include @@ -135,6 +137,143 @@ const QFont *QCocoaTheme::font(Font type) const return m_fonts.value(type, 0); } +// Defined in qpaintengine_mac.mm +extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); + +//! \internal +QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height) +{ + QPixmap ret(width, height); + ret.fill(QColor(0, 0, 0, 0)); + + CGRect rect = CGRectMake(0, 0, width, height); + + CGContextRef ctx = qt_mac_cg_context(&ret); + CGAffineTransform old_xform = CGContextGetCTM(ctx); + CGContextConcatCTM(ctx, CGAffineTransformInvert(old_xform)); + CGContextConcatCTM(ctx, CGAffineTransformIdentity); + + ::RGBColor b; + b.blue = b.green = b.red = 255*255; + PlotIconRefInContext(ctx, &rect, kAlignNone, kTransformNone, &b, kPlotIconRefNormalFlags, icon); + CGContextRelease(ctx); + return ret; +} + +QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const +{ + OSType iconType = 0; + switch (sp) { + case MessageBoxQuestion: + iconType = kQuestionMarkIcon; + break; + case MessageBoxInformation: + iconType = kAlertNoteIcon; + break; + case MessageBoxWarning: + iconType = kAlertCautionIcon; + break; + case MessageBoxCritical: + iconType = kAlertStopIcon; + break; + case DesktopIcon: + iconType = kDesktopIcon; + break; + case TrashIcon: + iconType = kTrashIcon; + break; + case ComputerIcon: + iconType = kComputerIcon; + break; + case DriveFDIcon: + iconType = kGenericFloppyIcon; + break; + case DriveHDIcon: + iconType = kGenericHardDiskIcon; + break; + case DriveCDIcon: + case DriveDVDIcon: + iconType = kGenericCDROMIcon; + break; + case DriveNetIcon: + iconType = kGenericNetworkIcon; + break; + case DirOpenIcon: + iconType = kOpenFolderIcon; + break; + case DirClosedIcon: + case DirLinkIcon: + iconType = kGenericFolderIcon; + break; + case FileLinkIcon: + case FileIcon: + iconType = kGenericDocumentIcon; + break; + default: + break; + } + if (iconType != 0) { + QPixmap pixmap; + IconRef icon; + IconRef overlayIcon = 0; + if (iconType != kGenericApplicationIcon) { + GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); + } else { + FSRef fsRef; + ProcessSerialNumber psn = { 0, kCurrentProcess }; + GetProcessBundleLocation(&psn, &fsRef); + GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); + if (sp == MessageBoxCritical) { + overlayIcon = icon; + GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); + } + } + + if (icon) { + pixmap = qt_mac_convert_iconref(icon, size.width(), size.height()); + ReleaseIconRef(icon); + } + + if (overlayIcon) { + QSizeF littleSize = size / 2; + QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize.width(), littleSize.height()); + QPainter painter(&pixmap); + painter.drawPixmap(littleSize.width(), littleSize.height(), overlayPix); + ReleaseIconRef(overlayIcon); + } + + return pixmap; + } + + return QPlatformTheme::standardPixmap(sp, size); +} + +QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const +{ + FSRef macRef; + OSStatus status = FSPathMakeRef(reinterpret_cast(fileInfo.canonicalFilePath().toUtf8().constData()), + &macRef, 0); + if (status != noErr) + return QPixmap(); + FSCatalogInfo info; + HFSUniStr255 macName; + status = FSGetCatalogInfo(&macRef, kIconServicesCatalogInfoMask, &info, &macName, 0, 0); + if (status != noErr) + return QPixmap(); + IconRef iconRef; + SInt16 iconLabel; + status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode, + kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag, + &iconRef, &iconLabel); + if (status != noErr) + return QPixmap(); + + QPixmap pixmap = qt_mac_convert_iconref(iconRef, size.width(), size.height()); + ReleaseIconRef(iconRef); + + return pixmap; +} + QVariant QCocoaTheme::themeHint(ThemeHint hint) const { switch (hint) { @@ -146,6 +285,11 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const return QVariant(int(MacKeyboardScheme)); case TabAllWidgets: return QVariant(bool([[NSApplication sharedApplication] isFullKeyboardAccessEnabled])); + case IconPixmapSizes: { + QList sizes; + sizes << 16 << 32 << 64 << 128; + return QVariant::fromValue(sizes); + } default: break; } diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h index f5ea2cf6bf..3566367e41 100644 --- a/src/plugins/platforms/windows/qtwindows_additional.h +++ b/src/plugins/platforms/windows/qtwindows_additional.h @@ -83,6 +83,21 @@ #define CHILDID_SELF 0 #define WM_GETOBJECT 0x003D +#ifndef SIID_SHIELD // Shell structures for icons. +typedef struct _SHSTOCKICONINFO +{ + DWORD cbSize; + HICON hIcon; + int iSysImageIndex; + int iIcon; + WCHAR szPath[MAX_PATH]; +} SHSTOCKICONINFO; + +# define SIID_SHIELD 77 +# define SHGFI_ADDOVERLAYS 0x20 +# define SHGFI_OVERLAYINDEX 0x40 +#endif // SIID_SHIELD + #if !defined(__MINGW64_VERSION_MAJOR) #define STATE_SYSTEM_HASPOPUP 0x40000000 diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 98c17deba9..3d4871d7a2 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -210,7 +210,9 @@ bool QWindowsUser32DLL::initTouch() \ingroup qt-lighthouse-win */ -QWindowsShell32DLL::QWindowsShell32DLL() : sHCreateItemFromParsingName(0) +QWindowsShell32DLL::QWindowsShell32DLL() + : sHCreateItemFromParsingName(0) + , sHGetStockIconInfo(0) { } @@ -218,6 +220,7 @@ void QWindowsShell32DLL::init() { QSystemLibrary library(QStringLiteral("shell32")); sHCreateItemFromParsingName = (SHCreateItemFromParsingName)(library.resolve("SHCreateItemFromParsingName")); + sHGetStockIconInfo = (SHGetStockIconInfo)library.resolve("SHGetStockIconInfo"); } QWindowsUser32DLL QWindowsContext::user32dll; diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 450d6c8f4b..78cd104fbe 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -49,6 +49,7 @@ #include struct IBindCtx; +struct _SHSTOCKICONINFO; QT_BEGIN_NAMESPACE @@ -99,8 +100,10 @@ struct QWindowsShell32DLL inline void init(); typedef HRESULT (WINAPI *SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **); + typedef HRESULT (WINAPI *SHGetStockIconInfo)(int , int , _SHSTOCKICONINFO *); SHCreateItemFromParsingName sHCreateItemFromParsingName; + SHGetStockIconInfo sHGetStockIconInfo; }; #endif // Q_OS_WINCE diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 7b3ffc633f..748ba09a90 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -55,9 +55,13 @@ #include #include #include +#include #include #include +#include +#include #include +#include QT_BEGIN_NAMESPACE @@ -348,6 +352,11 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(int(WindowsKeyboardScheme)); case UiEffects: return QVariant(uiEffects()); + case IconPixmapSizes: { + QList sizes; + sizes << 16 << 32; + return QVariant::fromValue(sizes); + } default: break; } @@ -433,4 +442,225 @@ void QWindowsTheme::windowsThemeChanged(QWindow * window) QWindowSystemInterface::handleThemeChange(window); } +// Defined in qpixmap_win.cpp +Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); + +static QPixmap loadIconFromShell32(int resourceId, QSizeF size) +{ +#ifdef Q_OS_WINCE + HMODULE hmod = LoadLibrary(L"ceshell"); +#else + HMODULE hmod = QSystemLibrary::load(L"shell32"); +#endif + if (hmod) { + HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size.width(), size.height(), 0); + if (iconHandle) { + QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle); + DestroyIcon(iconHandle); + return iconpixmap; + } + } + return QPixmap(); +} + +QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const +{ + int resourceId = -1; + LPCTSTR iconName = 0; + switch (sp) { + case DriveCDIcon: + case DriveDVDIcon: + resourceId = 12; + break; + case DriveNetIcon: + resourceId = 10; + break; + case DriveHDIcon: + resourceId = 9; + break; + case DriveFDIcon: + resourceId = 7; + break; + case FileIcon: + case FileLinkIcon: + resourceId = 1; + break; + case DirIcon: + case DirLinkIcon: + case DirClosedIcon: + resourceId = 4; + break; + case DesktopIcon: + resourceId = 35; + break; + case ComputerIcon: + resourceId = 16; + break; + case DirOpenIcon: + case DirLinkOpenIcon: + resourceId = 5; + break; + case FileDialogNewFolder: + resourceId = 319; + break; + case DirHomeIcon: + resourceId = 235; + break; + case TrashIcon: + resourceId = 191; + break; + case MessageBoxInformation: + iconName = IDI_INFORMATION; + break; + case MessageBoxWarning: + iconName = IDI_WARNING; + break; + case MessageBoxCritical: + iconName = IDI_ERROR; + break; + case MessageBoxQuestion: + iconName = IDI_QUESTION; + break; + case VistaShield: + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA + && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { + if (!QWindowsContext::shell32dll.sHGetStockIconInfo) + return QPixmap(); + QPixmap pixmap; + SHSTOCKICONINFO iconInfo; + memset(&iconInfo, 0, sizeof(iconInfo)); + iconInfo.cbSize = sizeof(iconInfo); + const int iconSize = size.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON; + if (QWindowsContext::shell32dll.sHGetStockIconInfo(SIID_SHIELD, SHGFI_ICON | iconSize, &iconInfo) == S_OK) { + pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon); + DestroyIcon(iconInfo.hIcon); + return pixmap; + } + } + break; + default: + break; + } + + if (resourceId != -1) { + QPixmap pixmap = loadIconFromShell32(resourceId, size); + if (!pixmap.isNull()) { + if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) { + QPainter painter(&pixmap); + QPixmap link = loadIconFromShell32(30, size); + painter.drawPixmap(0, 0, size.width(), size.height(), link); + } + return pixmap; + } + } + + if (iconName) { + HICON iconHandle = LoadIcon(NULL, iconName); + QPixmap pixmap = qt_pixmapFromWinHICON(iconHandle); + DestroyIcon(iconHandle); + if (!pixmap.isNull()) + return pixmap; + } + + return QPlatformTheme::standardPixmap(sp, size); +} + +static QString dirIconPixmapCacheKey(int iIcon, int iconSize) +{ + QString key = QLatin1String("qt_dir_") + QString::number(iIcon); + if (iconSize == SHGFI_LARGEICON) + key += QLatin1Char('l'); + return key; +} + +template +class FakePointer +{ +public: + + Q_STATIC_ASSERT_X(sizeof(T) <= sizeof(void *), "FakePointers can only go that far."); + + static FakePointer *create(T thing) + { + return reinterpret_cast(thing); + } + + T operator * () const + { + return reinterpret_cast(this); + } + + void operator delete (void *) {} +}; + +QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const +{ + /* We don't use the variable, but by storing it statically, we + * ensure CoInitialize is only called once. */ + static HRESULT comInit = CoInitialize(NULL); + Q_UNUSED(comInit); + + static QCache > dirIconEntryCache(1000); + static QMutex mx; + + QPixmap pixmap; + const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); + int iconSize = size.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON; + + bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot(); + if (cacheableDirIcon) { + QMutexLocker locker(&mx); + int iIcon = **dirIconEntryCache.object(filePath); + if (iIcon) { + QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize), pixmap); + if (pixmap.isNull()) // Let's keep both caches in sync + dirIconEntryCache.remove(filePath); + else + return pixmap; + } + } + + SHFILEINFO info; + unsigned int flags = +#ifndef Q_OS_WINCE + SHGFI_ICON|iconSize|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX; +#else + iconSize|SHGFI_SYSICONINDEX; +#endif // Q_OS_WINCE + unsigned long val = SHGetFileInfo((const wchar_t *)filePath.utf16(), 0, + &info, sizeof(SHFILEINFO), flags); + + // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases + if (val && info.hIcon) { + QString key; + if (cacheableDirIcon) { + //using the unique icon index provided by windows save us from duplicate keys + key = dirIconPixmapCacheKey(info.iIcon, iconSize); + QPixmapCache::find(key, pixmap); + if (!pixmap.isNull()) { + QMutexLocker locker(&mx); + dirIconEntryCache.insert(filePath, FakePointer::create(info.iIcon)); + } + } + + if (pixmap.isNull()) { + pixmap = qt_pixmapFromWinHICON(info.hIcon); + if (!pixmap.isNull()) { + if (cacheableDirIcon) { + QMutexLocker locker(&mx); + QPixmapCache::insert(key, pixmap); + dirIconEntryCache.insert(filePath, FakePointer::create(info.iIcon)); + } + } else { + qWarning("QWindowsTheme::fileIconPixmap() no icon found"); + } + } + DestroyIcon(info.hIcon); + } + + if (!pixmap.isNull()) + return pixmap; + return QPlatformTheme::fileIconPixmap(fileInfo, size); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 7e885b8f3e..89ef527e76 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -67,6 +67,9 @@ public: virtual const QFont *font(Font type = SystemFont) const { return m_fonts[type]; } + virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; + virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const; + void windowsThemeChanged(QWindow *window); static const char *name; diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index 99a7c1c929..70750c6006 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #if defined(Q_OS_WIN) #if defined(_WIN32_IE) @@ -59,26 +60,14 @@ # include # include # include - -#elif defined(Q_WS_MAC) -# include #endif #if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK) # include #endif -#ifndef SHGFI_ADDOVERLAYS -# define SHGFI_ADDOVERLAYS 0x000000020 -# define SHGFI_OVERLAYINDEX 0x000000040 -#endif - QT_BEGIN_NAMESPACE -#if defined (Q_OS_WIN) -Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); -#endif - /*! \class QFileIconProvider @@ -105,11 +94,8 @@ class QFileIconProviderPrivate public: QFileIconProviderPrivate(); QIcon getIcon(QStyle::StandardPixmap name) const; -#ifdef Q_OS_WIN - QIcon getWinIcon(const QFileInfo &fi) const; -#elif defined(Q_WS_MAC) - QIcon getMacIcon(const QFileInfo &fi) const; -#endif + QIcon getIcon(const QFileInfo &fi) const; + QFileIconProvider *q_ptr; const QString homePath; @@ -238,163 +224,51 @@ QIcon QFileIconProvider::icon(IconType type) const return QIcon(); } -#ifdef Q_OS_WIN -QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const +QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const { QIcon retIcon; - const QString fileExtension = QLatin1Char('.') + fileInfo.suffix().toUpper(); - - QString key; - if (fileInfo.isFile() && !fileInfo.isExecutable() && !fileInfo.isSymLink() && fileExtension != QLatin1String(".ICO")) - key = QLatin1String("qt_") + fileExtension; - - QPixmap pixmap; - if (!key.isEmpty()) { - QPixmapCache::find(key, pixmap); - } - - if (!pixmap.isNull()) { - retIcon.addPixmap(pixmap); - if (QPixmapCache::find(key + QLatin1Char('l'), pixmap)) - retIcon.addPixmap(pixmap); + const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); + if (!theme) return retIcon; - } - /* We don't use the variable, but by storing it statically, we - * ensure CoInitialize is only called once. */ - static HRESULT comInit = CoInitialize(NULL); - Q_UNUSED(comInit); + QList sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value >(); + if (sizes.isEmpty()) + return retIcon; - SHFILEINFO info; - unsigned long val = 0; + const QString fileExtension = fi.suffix().toUpper(); + const QString keyBase = QLatin1String("qt_.") + fi.suffix().toUpper(); - //Get the small icon -#ifndef Q_OS_WINCE - val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, - sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX); -#else - val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, - sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX); -#endif - - // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases - if (val && info.hIcon) { - if (fileInfo.isDir() && !fileInfo.isRoot()) { - //using the unique icon index provided by windows save us from duplicate keys - key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); - QPixmapCache::find(key, pixmap); - if (!pixmap.isNull()) { - retIcon.addPixmap(pixmap); - if (QPixmapCache::find(key + QLatin1Char('l'), pixmap)) + bool cacheable = fi.isFile() && !fi.isExecutable() && !fi.isSymLink() && fileExtension != QLatin1String("ICO"); + if (cacheable) { + QPixmap pixmap; + QPixmapCache::find(keyBase + QString::number(sizes.at(0)), pixmap); + if (!pixmap.isNull()) { + bool iconIsComplete = true; + retIcon.addPixmap(pixmap); + for (int i = 1; i < sizes.count(); i++) + if (QPixmapCache::find(keyBase + QString::number(sizes.at(i)), pixmap)) { retIcon.addPixmap(pixmap); - DestroyIcon(info.hIcon); + } else { + iconIsComplete = false; + break; + } + if (iconIsComplete) return retIcon; - } } - if (pixmap.isNull()) { - pixmap = qt_pixmapFromWinHICON(info.hIcon); - if (!pixmap.isNull()) { - retIcon.addPixmap(pixmap); - if (!key.isEmpty()) - QPixmapCache::insert(key, pixmap); - } - else { - qWarning("QFileIconProviderPrivate::getWinIcon() no small icon found"); - } - } - DestroyIcon(info.hIcon); } - //Get the big icon -#ifndef Q_OS_WINCE - val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, - sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX); -#else - val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, - sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX); -#endif - if (val && info.hIcon) { - if (fileInfo.isDir() && !fileInfo.isRoot()) { - //using the unique icon index provided by windows save us from duplicate keys - key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); - } - pixmap = qt_pixmapFromWinHICON(info.hIcon); + Q_FOREACH (int size, sizes) { + QPixmap pixmap = theme->fileIconPixmap(fi, QSizeF(size, size)); if (!pixmap.isNull()) { retIcon.addPixmap(pixmap); - if (!key.isEmpty()) - QPixmapCache::insert(key + QLatin1Char('l'), pixmap); + if (cacheable) + QPixmapCache::insert(keyBase + QString::number(size), pixmap); } - else { - qWarning("QFileIconProviderPrivate::getWinIcon() no large icon found"); - } - DestroyIcon(info.hIcon); } + return retIcon; } -#elif defined(Q_WS_MAC) -QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const -{ - QIcon retIcon; - QString fileExtension = fi.suffix().toUpper(); - fileExtension.prepend(QLatin1String(".")); - - const QString keyBase = QLatin1String("qt_") + fileExtension; - - QPixmap pixmap; - if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) { - QPixmapCache::find(keyBase + QLatin1String("16"), pixmap); - } - - if (!pixmap.isNull()) { - retIcon.addPixmap(pixmap); - if (QPixmapCache::find(keyBase + QLatin1String("32"), pixmap)) { - retIcon.addPixmap(pixmap); - if (QPixmapCache::find(keyBase + QLatin1String("64"), pixmap)) { - retIcon.addPixmap(pixmap); - if (QPixmapCache::find(keyBase + QLatin1String("128"), pixmap)) { - retIcon.addPixmap(pixmap); - return retIcon; - } - } - } - } - - - FSRef macRef; - OSStatus status = FSPathMakeRef(reinterpret_cast(fi.canonicalFilePath().toUtf8().constData()), - &macRef, 0); - if (status != noErr) - return retIcon; - FSCatalogInfo info; - HFSUniStr255 macName; - status = FSGetCatalogInfo(&macRef, kIconServicesCatalogInfoMask, &info, &macName, 0, 0); - if (status != noErr) - return retIcon; - IconRef iconRef; - SInt16 iconLabel; - status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode, - kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag, - &iconRef, &iconLabel); - if (status != noErr) - return retIcon; - qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon); - ReleaseIconRef(iconRef); - - if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) { - pixmap = retIcon.pixmap(16); - QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap); - pixmap = retIcon.pixmap(32); - QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap); - pixmap = retIcon.pixmap(64); - QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap); - pixmap = retIcon.pixmap(128); - QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap); - } - return retIcon; -} -#endif - /*! Returns an icon for the file described by \a info. @@ -412,15 +286,10 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const } #endif -#ifdef Q_WS_MAC - QIcon retIcon = d->getMacIcon(info); + QIcon retIcon = d->getIcon(info); if (!retIcon.isNull()) return retIcon; -#elif defined Q_OS_WIN - QIcon icon = d->getWinIcon(info); - if (!icon.isNull()) - return icon; -#endif + if (info.isRoot()) #if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) { @@ -445,6 +314,7 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const #else return d->getIcon(QStyle::SP_DriveHDIcon); #endif + if (info.isFile()) { if (info.isSymLink()) return d->getIcon(QStyle::SP_FileLinkIcon); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 50fceab694..d4e4ea22d0 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5519,67 +5519,24 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption break; } } // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) - if (!icon.isNull()) - return icon; -#if defined(Q_WS_MAC) + + if (!icon.isNull()) + return icon; + +#if defined(Q_OS_MAC) if (QApplication::desktopSettingsAware()) { - OSType iconType = 0; switch (standardIcon) { - case QStyle::SP_MessageBoxQuestion: - iconType = kQuestionMarkIcon; - break; - case QStyle::SP_MessageBoxInformation: - iconType = kAlertNoteIcon; - break; - case QStyle::SP_MessageBoxWarning: - iconType = kAlertCautionIcon; - break; - case QStyle::SP_MessageBoxCritical: - iconType = kAlertStopIcon; - break; - case SP_DesktopIcon: - iconType = kDesktopIcon; - break; - case SP_TrashIcon: - iconType = kTrashIcon; - break; - case SP_ComputerIcon: - iconType = kComputerIcon; - break; - case SP_DriveFDIcon: - iconType = kGenericFloppyIcon; - break; - case SP_DriveHDIcon: - iconType = kGenericHardDiskIcon; - break; - case SP_DriveCDIcon: - case SP_DriveDVDIcon: - iconType = kGenericCDROMIcon; - break; - case SP_DriveNetIcon: - iconType = kGenericNetworkIcon; - break; - case SP_DirOpenIcon: - iconType = kOpenFolderIcon; - break; - case SP_DirClosedIcon: - case SP_DirLinkIcon: - iconType = kGenericFolderIcon; - break; - case SP_FileLinkIcon: - case SP_FileIcon: - iconType = kGenericDocumentIcon; - break; case SP_DirIcon: { // A rather special case - QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget); - QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget); + QIcon closeIcon = QCommonStyle::standardIcon(SP_DirClosedIcon, option, widget); + QIcon openIcon = QCommonStyle::standardIcon(SP_DirOpenIcon, option, widget); closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); return closeIcon; } + case SP_TitleBarNormalButton: case SP_TitleBarCloseButton: { QIcon titleBarIcon; @@ -5592,35 +5549,49 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption } return titleBarIcon; } + + case SP_MessageBoxQuestion: + case SP_MessageBoxInformation: + case SP_MessageBoxWarning: + case SP_MessageBoxCritical: + case SP_DesktopIcon: + case SP_TrashIcon: + case SP_ComputerIcon: + case SP_DriveFDIcon: + case SP_DriveHDIcon: + case SP_DriveCDIcon: + case SP_DriveDVDIcon: + case SP_DriveNetIcon: + case SP_DirOpenIcon: + case SP_DirClosedIcon: + case SP_DirLinkIcon: + case SP_FileLinkIcon: + case SP_FileIcon: + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + QPlatformTheme::StandardPixmap sp = static_cast(standardIcon); + QIcon retIcon; + QList sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value >(); + Q_FOREACH (int size, sizes) { + QPixmap mainIcon; + const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size); + if (standardIcon >= QStyle::SP_CustomBase) { + mainIcon = theme->standardPixmap(sp, QSizeF(size, size)); + } else if (QPixmapCache::find(cacheKey, mainIcon) == false) { + mainIcon = theme->standardPixmap(sp, QSizeF(size, size)); + QPixmapCache::insert(cacheKey, mainIcon); + } + + retIcon.addPixmap(mainIcon); + } + if (!retIcon.isNull()) + return retIcon; + } + default: break; } - if (iconType != 0) { - QIcon retIcon; - IconRef icon; - IconRef overlayIcon = 0; - if (iconType != kGenericApplicationIcon) { - GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); - } else { - FSRef fsRef; - ProcessSerialNumber psn = { 0, kCurrentProcess }; - GetProcessBundleLocation(&psn, &fsRef); - GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); - if (standardIcon == SP_MessageBoxCritical) { - overlayIcon = icon; - GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); - } - } - if (icon) { - qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); - ReleaseIconRef(icon); - } - if (overlayIcon) - ReleaseIconRef(overlayIcon); - return retIcon; - } } // if (QApplication::desktopSettingsAware()) -#endif // Q_WS_MAC +#endif // Q_OS_MAC switch (standardIcon) { #ifndef QT_NO_IMAGEFORMAT_PNG diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 77656f9ed5..20791d6625 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -103,6 +103,7 @@ #include #include #include +#include QT_USE_NAMESPACE diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 77c647e136..f0d1d2319c 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1934,6 +1934,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SP_DirClosedIcon The closed directory icon. \value SP_DirIcon The directory icon. \value SP_DirLinkIcon The link to directory icon. + \value SP_DirLinkOpenIcon The link to open directory icon. \value SP_FileIcon The file icon. \value SP_FileLinkIcon The link to file icon. \value SP_FileDialogStart The "start" icon in a file dialog. diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 539424639b..48491b3e3e 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -731,6 +731,7 @@ public: SP_DirOpenIcon, SP_DirClosedIcon, SP_DirLinkIcon, + SP_DirLinkOpenIcon, SP_FileIcon, SP_FileLinkIcon, SP_ToolBarHorizontalExtensionButton, diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index ee13852813..714898e809 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -68,6 +68,8 @@ #include "qlistview.h" #include #include +#include +#include #include #include @@ -889,26 +891,6 @@ static const char *const question_xpm[] = { #endif //QT_NO_IMAGEFORMAT_XPM -#ifdef Q_OS_WIN -static QPixmap loadIconFromShell32( int resourceId, int size ) -{ -#ifdef Q_OS_WINCE - HMODULE hmod = LoadLibrary(L"ceshell"); -#else - HMODULE hmod = QSystemLibrary::load(L"shell32"); -#endif - if( hmod ) { - HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0); - if( iconHandle ) { - QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle); - DestroyIcon(iconHandle); - return iconpixmap; - } - } - return QPixmap(); -} -#endif - /*! \reimp */ @@ -920,125 +902,32 @@ QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyl switch(standardPixmap) { case SP_DriveCDIcon: case SP_DriveDVDIcon: - { - desktopIcon = loadIconFromShell32(12, 16); - break; - } case SP_DriveNetIcon: - { - desktopIcon = loadIconFromShell32(10, 16); - break; - } case SP_DriveHDIcon: - { - desktopIcon = loadIconFromShell32(9, 16); - break; - } case SP_DriveFDIcon: - { - desktopIcon = loadIconFromShell32(7, 16); - break; - } case SP_FileIcon: - { - desktopIcon = loadIconFromShell32(1, 16); - break; - } case SP_FileLinkIcon: - { - desktopIcon = loadIconFromShell32(1, 16); - QPainter painter(&desktopIcon); - QPixmap link = loadIconFromShell32(30, 16); - painter.drawPixmap(0, 0, 16, 16, link); - break; - } case SP_DirLinkIcon: - { - desktopIcon = loadIconFromShell32(4, 16); - QPainter painter(&desktopIcon); - QPixmap link = loadIconFromShell32(30, 16); - painter.drawPixmap(0, 0, 16, 16, link); - break; - } case SP_DirClosedIcon: - { - desktopIcon = loadIconFromShell32(4, 16); - break; - } case SP_DesktopIcon: - { - desktopIcon = loadIconFromShell32(35, 16); - break; - } case SP_ComputerIcon: - { - desktopIcon = loadIconFromShell32(16, 16); - break; - } case SP_DirOpenIcon: - { - desktopIcon = loadIconFromShell32(5, 16); - break; - } case SP_FileDialogNewFolder: - { - desktopIcon = loadIconFromShell32(319, 16); - break; - } case SP_DirHomeIcon: - { - desktopIcon = loadIconFromShell32(235, 16); - break; - } case SP_TrashIcon: - { - desktopIcon = loadIconFromShell32(191, 16); - break; - } - case SP_MessageBoxInformation: - { - HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION); - desktopIcon = qt_pixmapFromWinHICON(iconHandle); - DestroyIcon(iconHandle); - break; - } - case SP_MessageBoxWarning: - { - HICON iconHandle = LoadIcon(NULL, IDI_WARNING); - desktopIcon = qt_pixmapFromWinHICON(iconHandle); - DestroyIcon(iconHandle); - break; - } - case SP_MessageBoxCritical: - { - HICON iconHandle = LoadIcon(NULL, IDI_ERROR); - desktopIcon = qt_pixmapFromWinHICON(iconHandle); - DestroyIcon(iconHandle); - break; - } - case SP_MessageBoxQuestion: - { - HICON iconHandle = LoadIcon(NULL, IDI_QUESTION); - desktopIcon = qt_pixmapFromWinHICON(iconHandle); - DestroyIcon(iconHandle); - break; - } case SP_VistaShield: - { - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA - && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) - && pSHGetStockIconInfo) - { - QPixmap pixmap; - QSHSTOCKICONINFO iconInfo; - memset(&iconInfo, 0, sizeof(iconInfo)); - iconInfo.cbSize = sizeof(iconInfo); - if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) { - pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon); - DestroyIcon(iconInfo.hIcon); - return pixmap; - } - } + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + QPlatformTheme::StandardPixmap sp = static_cast(standardPixmap); + desktopIcon = theme->standardPixmap(sp, QSizeF(16, 16)); + } + break; + case SP_MessageBoxInformation: + case SP_MessageBoxWarning: + case SP_MessageBoxCritical: + case SP_MessageBoxQuestion: + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + QPlatformTheme::StandardPixmap sp = static_cast(standardPixmap); + desktopIcon = theme->standardPixmap(sp, QSizeF()); } break; default: @@ -3046,124 +2935,47 @@ QIcon QWindowsStyle::standardIcon(StandardPixmap standardIcon, const QStyleOptio const QWidget *widget) const { QIcon icon; - QPixmap pixmap; #ifdef Q_OS_WIN + QPixmap pixmap; switch (standardIcon) { - case SP_FileDialogNewFolder: - { - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(319, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; - } - case SP_DirHomeIcon: - { - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(235, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; - } - case SP_DirIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(4, size); - icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off); - pixmap = loadIconFromShell32(5, size); - icon.addPixmap(pixmap, QIcon::Normal, QIcon::On); - } - break; - case SP_DirLinkIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - QPixmap link = loadIconFromShell32(30, size); - pixmap = loadIconFromShell32(4, size); - if (!pixmap.isNull() && !link.isNull()) { - QPainter painter(&pixmap); - painter.drawPixmap(0, 0, size, size, link); - icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off); - } - link = loadIconFromShell32(30, size); - pixmap = loadIconFromShell32(5, size); - if (!pixmap.isNull() && !link.isNull()) { - QPainter painter(&pixmap); - painter.drawPixmap(0, 0, size, size, link); - icon.addPixmap(pixmap, QIcon::Normal, QIcon::On); - } - } - break; - case SP_FileIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(1, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; - case SP_ComputerIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(16, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; - - case SP_DesktopIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(35, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; case SP_DriveCDIcon: case SP_DriveDVDIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(12, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; case SP_DriveNetIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(10, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; case SP_DriveHDIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(9, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; case SP_DriveFDIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - pixmap = loadIconFromShell32(7, size); - icon.addPixmap(pixmap, QIcon::Normal); - } - break; + case SP_FileIcon: case SP_FileLinkIcon: - for (int size = 16 ; size <= 32 ; size += 16) { - QPixmap link; - link = loadIconFromShell32(30, size); - pixmap = loadIconFromShell32(1, size); - if (!pixmap.isNull() && !link.isNull()) { - QPainter painter(&pixmap); - painter.drawPixmap(0, 0, size, size, link); + case SP_DesktopIcon: + case SP_ComputerIcon: + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + QPlatformTheme::StandardPixmap sp = static_cast(standardIcon); + for (int size = 16 ; size <= 32 ; size += 16) { + pixmap = theme->standardPixmap(sp, QSizeF(size, size)); icon.addPixmap(pixmap, QIcon::Normal); } } break; - case SP_VistaShield: - { - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA - && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) - && pSHGetStockIconInfo) - { - icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon - QSHSTOCKICONINFO iconInfo; //append large icon - memset(&iconInfo, 0, sizeof(iconInfo)); - iconInfo.cbSize = sizeof(iconInfo); - if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) { - icon.addPixmap(qt_pixmapFromWinHICON(iconInfo.hIcon)); - DestroyIcon(iconInfo.hIcon); - } + case SP_DirIcon: + case SP_DirLinkIcon: + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + QPlatformTheme::StandardPixmap spOff = static_cast(standardIcon); + QPlatformTheme::StandardPixmap spOn = standardIcon == SP_DirIcon ? QPlatformTheme::DirOpenIcon : + QPlatformTheme::DirLinkOpenIcon; + for (int size = 16 ; size <= 32 ; size += 16) { + QSizeF pixSize(size, size); + pixmap = theme->standardPixmap(spOff, pixSize); + icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off); + pixmap = theme->standardPixmap(spOn, pixSize); + icon.addPixmap(pixmap, QIcon::Normal, QIcon::On); } } break; + case SP_VistaShield: + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + QPlatformTheme::StandardPixmap sp = static_cast(standardIcon); + pixmap = theme->standardPixmap(sp, QSizeF(32, 32)); + } + break; default: break; } From c92ceb179f609de4d3c8ec9433c9329e48214224 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Mon, 15 Oct 2012 22:13:58 +0200 Subject: [PATCH 010/114] Fix compile errors in configure.exe. qstringmatcher.cpp and qchar.cpp are included in qstring.cpp and qunicodetables.cpp is included in qchar.cpp so these files should not be compiled as standalone objects. Change-Id: I323e0878af28b9e5fb2f659fb8077347b93fa439 Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- tools/configure/configure.pro | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 9148199d24..c970880d8c 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -81,7 +81,6 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qarraydata.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qchar.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qhash.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qlist.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qlocale.cpp \ @@ -118,8 +117,6 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qregexp.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qstring.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qstringmatcher.cpp \ - $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qvsnprintf.cpp \ $$QT_SOURCE_TREE/src/corelib/kernel/qvariant.cpp \ $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror.cpp \ From 74230f126be4d7d6d6a91892ddb91bf050a46396 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 15 Oct 2012 14:17:01 +0300 Subject: [PATCH 011/114] Fix setting custom cursor for widgets and windows before showing them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If custom cursor was set before the window was created, it didn't actually get set, and in some cases even caused a crash. Fixed by making sure the cursor is correct when showing widget/window. Task-number: QTBUG-27535 Change-Id: I3bc946a9c406c96af5b86869a3a54893f8980aba Reviewed-by: Friedemann Kleint Reviewed-by: Gatis Paeglis Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 36 +++++++++++++++++------------- src/gui/kernel/qwindow_p.h | 3 +++ src/widgets/kernel/qwidget_qpa.cpp | 3 +++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 27e1571184..39a6603c4b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -286,6 +286,10 @@ void QWindow::setVisible(bool visible) QGuiApplicationPrivate::hideModalWindow(this); } +#ifndef QT_NO_CURSOR + if (visible) + d->applyCursor(); +#endif d->platformWindow->setVisible(visible); if (!visible) { @@ -1853,11 +1857,10 @@ QCursor QWindow::cursor() const void QWindow::setCursor(const QCursor &cursor) { Q_D(QWindow); - if (QPlatformCursor *platformCursor = d->screen->handle()->cursor()) { - d->cursor = cursor; - QCursor *oc = QGuiApplication::overrideCursor(); - QCursor c = oc ? *oc : d->cursor; - platformCursor->changeCursor(&c, this); + d->cursor = cursor; + // Only attempt to set cursor and emit signal if there is an actual platform cursor + if (d->screen->handle()->cursor()) { + d->applyCursor(); QEvent event(QEvent::CursorChange); QGuiApplication::sendEvent(this, &event); } @@ -1868,19 +1871,20 @@ void QWindow::setCursor(const QCursor &cursor) */ void QWindow::unsetCursor() { - Q_D(QWindow); - if (QPlatformCursor *platformCursor = d->screen->handle()->cursor()) { - d->cursor = Qt::ArrowCursor; - QCursor *oc = QGuiApplication::overrideCursor(); - if (!oc) { - QCursor c = d->cursor; - platformCursor->changeCursor(&c, this); - } - QEvent event(QEvent::CursorChange); - QGuiApplication::sendEvent(this, &event); - } + setCursor(Qt::ArrowCursor); } +void QWindowPrivate::applyCursor() +{ + Q_Q(QWindow); + if (platformWindow) { + if (QPlatformCursor *platformCursor = screen->handle()->cursor()) { + QCursor *oc = QGuiApplication::overrideCursor(); + QCursor c = oc ? *oc : cursor; + platformCursor->changeCursor(&c, q); + } + } +} #endif QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 57f79f1faa..159f05d1a5 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -97,6 +97,9 @@ public: } void maybeQuitOnLastWindowClosed(); +#ifndef QT_NO_CURSOR + void applyCursor(); +#endif QPoint globalPosition() const { Q_Q(const QWindow); diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 86d8da254a..e7564261f9 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -547,6 +547,9 @@ void QWidgetPrivate::show_sys() } } +#ifndef QT_NO_CURSOR + qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show +#endif invalidateBuffer(q->rect()); window->setVisible(true); } From 1dc970b0c48d430fa096dde61babfc3f86817ddd Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 28 Sep 2012 20:06:51 +0200 Subject: [PATCH 012/114] Fix function names in warning messages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I14abc176ea670799496e10bee296b4e84fdc7181 Reviewed-by: Jan Arve Sæther --- .../linuxaccessibility/atspiadaptor.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 33c0750263..6a144f849d 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1405,7 +1405,7 @@ bool AtSpiAdaptor::accessibleInterface(const QAIPointer &interface, const QStrin } connection.send(message.createReply(QVariant::fromValue(children))); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path(); return false; } return true; @@ -1673,7 +1673,7 @@ bool AtSpiAdaptor::componentInterface(const QAIPointer &interface, const QString qAtspiDebug() << "SetSize is not implemented."; sendReply(connection, message, false); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::componentInterface does not implement " << function << message.path(); return false; } return true; @@ -1727,7 +1727,7 @@ bool AtSpiAdaptor::actionInterface(const QAIPointer &interface, const QString &f else sendReply(connection, message, QString()); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::actionInterface does not implement " << function << message.path(); return false; } return true; @@ -1884,7 +1884,7 @@ bool AtSpiAdaptor::textInterface(const QAIPointer &interface, const QString &fun interface->textInterface()->setSelection(selectionNum, startOffset, endOffset); sendReply(connection, message, true); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::textInterface does not implement " << function << message.path(); return false; } return true; @@ -2080,7 +2080,7 @@ bool AtSpiAdaptor::editableTextInterface(const QAIPointer &interface, const QStr } else if (function == QLatin1String("")) { connection.send(message.createReply()); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::editableTextInterface does not implement " << function << message.path(); return false; } return true; @@ -2125,7 +2125,7 @@ bool AtSpiAdaptor::valueInterface(const QAIPointer &interface, const QString &fu connection.send(message.createReply( QVariant::fromValue(QDBusVariant(QVariant::fromValue(val))))); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::valueInterface does not implement " << function << message.path(); return false; } return true; @@ -2335,7 +2335,7 @@ bool AtSpiAdaptor::tableInterface(const QAIPointer &interface, const QString &fu int row = message.arguments().at(0).toInt(); connection.send(message.createReply(interface->tableInterface()->unselectRow(row))); } else { - qAtspiDebug() << "WARNING: AtSpiAdaptor::handleMessage does not implement " << function << message.path(); + qAtspiDebug() << "WARNING: AtSpiAdaptor::tableInterface does not implement " << function << message.path(); return false; } return true; From e76f820e557020392b917742aaea2aeea3533c91 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 16 Oct 2012 11:51:29 +0200 Subject: [PATCH 013/114] QML plugins: Make sure that both debug and release versions are built Make sure that both debug and release versions of QML plugins are built if Qt is configured accordingly. Also pass on the other QT_CONFIG configurations. Change-Id: I4aaaf002068dd66277235bef7d1e3da3366d6d12 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qml_plugin.prf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf index 5bbead4b97..ae5fbf28a2 100644 --- a/mkspecs/features/qml_plugin.prf +++ b/mkspecs/features/qml_plugin.prf @@ -3,6 +3,15 @@ load(qt_build_config) TEMPLATE = lib CONFIG += plugin +if(win32|mac):!macx-xcode { + contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release + contains(QT_CONFIG, build_all):CONFIG += build_all +} +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols +contains(QT_CONFIG, separate_debug_info):CONFIG += separate_debug_info +contains(QT_CONFIG, separate_debug_info_nocopy):CONFIG += separate_debug_info_nocopy +contains(QT_CONFIG, c++11):CONFIG += c++11 + isEmpty(CXX_MODULE) { CXX_MODULE = $$TARGET TARGET = declarative_$${TARGET} @@ -21,7 +30,6 @@ INSTALLS += target # Some final setup TARGET = $$qtLibraryTarget($$TARGET) -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols load(qt_targets) From c40333ef505cf0cd9f1102f29473d920fdf7675d Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 2 Oct 2012 15:40:48 +0200 Subject: [PATCH 014/114] Remove unneded forward declaration. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I19157bde9a7b5ac3eb54830841baea08c8af8670 Reviewed-by: Jan Arve Sæther --- src/gui/accessible/qaccessible2.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index c1e7b8b5a2..e93324b4f8 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -52,8 +52,6 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_ACCESSIBILITY -class QModelIndex; - namespace QAccessible2 { enum BoundaryType { From 8fdef974b7014212947fc409543847d97ec7d5b9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Sep 2012 09:57:51 +0200 Subject: [PATCH 015/114] Logging: Mark deprecated API with QT_DEPRECATED Still use it in qtestlib though because using qInstallMessageHandler here would break all tests (still) using qInstallMsgHandler - Qt always uses the new message handler if there's one, ignoring any message handler installed through deprecated API. Change-Id: I6fefefb315a2421425d2b7787e367fd348a33d83 Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 6 ++++++ src/corelib/global/qlogging.h | 5 +++-- src/testlib/qtestlog.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 13bbdbead0..e4ff7eece4 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -780,6 +780,12 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont return message; } +#if !QT_DEPRECATED_SINCE(5, 0) +// make sure they're defined to be exported +typedef void (*QtMsgHandler)(QtMsgType, const char *); +Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); +#endif + static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context) static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context) diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 0c92e71ad6..4a4eb26321 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -161,9 +161,10 @@ Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &contex Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...); Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...); -// deprecated. Use qInstallMessageHandler instead! +#if QT_DEPRECATED_SINCE(5, 0)// deprecated. Use qInstallMessageHandler instead! typedef void (*QtMsgHandler)(QtMsgType, const char *); -Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); +Q_CORE_EXPORT QT_DEPRECATED QtMsgHandler qInstallMsgHandler(QtMsgHandler); +#endif typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &); Q_CORE_EXPORT QtMessageHandler qInstallMessageHandler(QtMessageHandler); diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 7cd83c857d..c56a00237b 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -76,6 +76,14 @@ static void saveCoverageTool(const char * appname, bool testfailed, bool install #endif } +// +// declare deprecated API from qlogging.h locally +// (we can't use qInstallMessageHandler because it would break +// tests that (still) rely on qInstallMsgHandler.) +// +typedef void (*QtMsgHandler)(QtMsgType, const char *); +Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); + namespace QTest { int fails = 0; From 4135951ae8162c4f8ca557eefb8cd2db39f759b0 Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Tue, 16 Oct 2012 12:06:14 +0300 Subject: [PATCH 016/114] Cocoa: use defaultPixmap() if pixmap is not set for drag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-26971 Change-Id: I6aed56a6b292c5aeebf38278d2a1fa982346c909 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoadrag.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index d98c49a1ce..67881d8680 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -119,7 +119,11 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o) m_drag = o; m_executed_drop_action = Qt::IgnoreAction; - NSImage *nsimage = static_cast(qt_mac_create_nsimage(m_drag->pixmap())); + QPixmap pm = m_drag->pixmap(); + if (pm.isNull()) + pm = defaultPixmap(); + + NSImage *nsimage = static_cast(qt_mac_create_nsimage(pm)); QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacPasteboardMime::MIME_DND); m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy")); From f144d538fdb3efd475c55b8af3a99555e448c924 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Tue, 16 Oct 2012 14:00:50 +0200 Subject: [PATCH 017/114] Cocoa: Set platform window geometry correctly. Handle the non-toplevel child window case, where QWindow has a parent NSView instead of a parent NSWindow. QWindow geometry is then equivalent to the frame geometry Task-number: QTBUG-26972 Change-Id: Ie7cedb3ec1a564ce55b72e8269d4853962e073ce Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoahelpers.h | 3 +++ src/plugins/platforms/cocoa/qcocoahelpers.mm | 10 ++++++++++ src/plugins/platforms/cocoa/qnsview.mm | 19 +++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 050a2e69d1..45c35cccbf 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -73,9 +73,12 @@ NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge); NSImage *qt_mac_create_nsimage(const QPixmap &pm); NSSize qt_mac_toNSSize(const QSize &qtSize); +NSRect qt_mac_toNSRect(const QRect &rect); +QRect qt_mac_toQRect(const NSRect &rect); QColor qt_mac_toQColor(const NSColor *color); + // Creates a mutable shape, it's the caller's responsibility to release. HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion); diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 8841a65844..743c78ed05 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -159,6 +159,16 @@ NSSize qt_mac_toNSSize(const QSize &qtSize) return NSMakeSize(qtSize.width(), qtSize.height()); } +NSRect qt_mac_toNSRect(const QRect &rect) +{ + return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); +} + +QRect qt_mac_toQRect(const NSRect &rect) +{ + return QRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); +} + QColor qt_mac_toQColor(const NSColor *color) { QColor qtColor; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f23fd3045f..a953b25d84 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -129,22 +129,29 @@ static QTouchDevice *touchDevice = 0; - (void)updateGeometry { - NSRect rect = [self frame]; - NSRect windowRect = [[self window] frame]; - QRect geo(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height); + QRect geometry; + if (m_platformWindow->m_nsWindow) { + // top level window, get window rect and flip y. + NSRect rect = [self frame]; + NSRect windowRect = [[self window] frame]; + geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height); + } else { + // child window, use the frame rect + geometry = qt_mac_toQRect([self frame]); + } #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QNSView::udpateGeometry" << geo; + qDebug() << "QNSView::udpateGeometry" << m_platformWindow << geometry; #endif // Call setGeometry on QPlatformWindow. (not on QCocoaWindow, // doing that will initiate a geometry change it and possibly create // an infinite loop when this notification is triggered again.) - m_platformWindow->QPlatformWindow::setGeometry(geo); + m_platformWindow->QPlatformWindow::setGeometry(geometry); // Send a geometry change event to Qt, if it's ready to handle events if (!m_platformWindow->m_inConstructor) { - QWindowSystemInterface::handleGeometryChange(m_window, geo); + QWindowSystemInterface::handleGeometryChange(m_window, geometry); QWindowSystemInterface::flushWindowSystemEvents(); } } From dc0927f2b8abea2b10a3c7aa6c20280e229d858c Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 10 Oct 2012 11:23:31 +0200 Subject: [PATCH 018/114] Check if there is an old item before removing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If something had changed with the menu item before it had actually been originally added to the native menu then this would crash when trying to remove a null item from the native menu. This prevents that from happening. Change-Id: I8d78b5504759225364d5fd051a23c8d6dbd7d1eb Reviewed-by: James Turner Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index e4baaab3d3..4d35b3202e 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -218,10 +218,9 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) NSMenuItem *oldItem = [m_nativeMenu itemWithTag:(NSInteger) cocoaItem]; if (cocoaItem->sync() != oldItem) { - // native item was changed for some reason - if (!wasMerged) { + // native item was changed for some reason + if (!wasMerged && oldItem) [m_nativeMenu removeItem:oldItem]; - } QCocoaMenuItem* beforeItem = itemOrNull(m_menuItems.indexOf(cocoaItem) + 1); insertNative(cocoaItem, beforeItem); From fbd10a401f640778d404c99b8633ed402a0fe000 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Oct 2012 10:23:43 +0200 Subject: [PATCH 019/114] Use organization name "QtProject" in examples. Change-Id: Ibbe9517ccf81d25eccbdff98f7cfe8ff6ec485d2 Reviewed-by: hjk --- examples/embedded/lightmaps/mapzoom.cpp | 4 ++-- examples/network/fortuneclient/client.cpp | 4 ++-- examples/network/fortuneserver/server.cpp | 4 ++-- examples/network/network-chat/main.cpp | 4 ++-- examples/network/torrent/mainwindow.cpp | 4 ++-- examples/widgets/mainwindows/application/main.cpp | 2 +- examples/widgets/mainwindows/application/mainwindow.cpp | 4 ++-- examples/widgets/mainwindows/mdi/mainwindow.cpp | 4 ++-- examples/widgets/mainwindows/recentfiles/main.cpp | 2 +- examples/widgets/mainwindows/sdi/main.cpp | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/embedded/lightmaps/mapzoom.cpp b/examples/embedded/lightmaps/mapzoom.cpp index b0b583a88a..f2b1acbce1 100644 --- a/examples/embedded/lightmaps/mapzoom.cpp +++ b/examples/embedded/lightmaps/mapzoom.cpp @@ -75,7 +75,7 @@ MapZoom::MapZoom() QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); @@ -112,7 +112,7 @@ void MapZoom::sessionOpened() id = config.identifier(); } - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); settings.endGroup(); diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index d0a37e051e..d3b6d902b7 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -129,7 +129,7 @@ Client::Client(QWidget *parent) QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); @@ -248,7 +248,7 @@ void Client::sessionOpened() else id = config.identifier(); - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); settings.endGroup(); diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index c0194328d1..94f934fc2d 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -55,7 +55,7 @@ Server::Server(QWidget *parent) QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); @@ -115,7 +115,7 @@ void Server::sessionOpened() else id = config.identifier(); - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); settings.endGroup(); diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp index fab1c25580..4c3985cb5e 100644 --- a/examples/network/network-chat/main.cpp +++ b/examples/network/network-chat/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) id = config.identifier(); } - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); settings.endGroup(); diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp index 63f7245f54..1b10241f6e 100644 --- a/examples/network/torrent/mainwindow.cpp +++ b/examples/network/torrent/mainwindow.cpp @@ -234,7 +234,7 @@ int MainWindow::rowOfClient(TorrentClient *client) const void MainWindow::loadSettings() { // Load base settings (last working directory, upload/download limits). - QSettings settings("Trolltech", "Torrent"); + QSettings settings("QtProject", "Torrent"); lastDirectory = settings.value("LastDirectory").toString(); if (lastDirectory.isEmpty()) lastDirectory = QDir::currentPath(); @@ -411,7 +411,7 @@ void MainWindow::saveSettings() saveChanges = false; // Prepare and reset the settings - QSettings settings("Trolltech", "Torrent"); + QSettings settings("QtProject", "Torrent"); settings.clear(); settings.setValue("LastDirectory", lastDirectory); diff --git a/examples/widgets/mainwindows/application/main.cpp b/examples/widgets/mainwindows/application/main.cpp index 152dbe560c..bb4e072735 100644 --- a/examples/widgets/mainwindows/application/main.cpp +++ b/examples/widgets/mainwindows/application/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(application); QApplication app(argc, argv); - app.setOrganizationName("Trolltech"); + app.setOrganizationName("QtProject"); app.setApplicationName("Application Example"); MainWindow mainWin; mainWin.show(); diff --git a/examples/widgets/mainwindows/application/mainwindow.cpp b/examples/widgets/mainwindows/application/mainwindow.cpp index 2b0cd72604..5cad03b331 100644 --- a/examples/widgets/mainwindows/application/mainwindow.cpp +++ b/examples/widgets/mainwindows/application/mainwindow.cpp @@ -276,7 +276,7 @@ void MainWindow::createStatusBar() void MainWindow::readSettings() //! [34] //! [36] { - QSettings settings("Trolltech", "Application Example"); + QSettings settings("QtProject", "Application Example"); QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); QSize size = settings.value("size", QSize(400, 400)).toSize(); resize(size); @@ -288,7 +288,7 @@ void MainWindow::readSettings() void MainWindow::writeSettings() //! [37] //! [39] { - QSettings settings("Trolltech", "Application Example"); + QSettings settings("QtProject", "Application Example"); settings.setValue("pos", pos()); settings.setValue("size", size()); } diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp index 7a09268374..e40edc76be 100644 --- a/examples/widgets/mainwindows/mdi/mainwindow.cpp +++ b/examples/widgets/mainwindows/mdi/mainwindow.cpp @@ -362,7 +362,7 @@ void MainWindow::createStatusBar() void MainWindow::readSettings() { - QSettings settings("Trolltech", "MDI Example"); + QSettings settings("QtProject", "MDI Example"); QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); QSize size = settings.value("size", QSize(400, 400)).toSize(); move(pos); @@ -371,7 +371,7 @@ void MainWindow::readSettings() void MainWindow::writeSettings() { - QSettings settings("Trolltech", "MDI Example"); + QSettings settings("QtProject", "MDI Example"); settings.setValue("pos", pos()); settings.setValue("size", size()); } diff --git a/examples/widgets/mainwindows/recentfiles/main.cpp b/examples/widgets/mainwindows/recentfiles/main.cpp index 2a9b8caec9..c63ceefcf1 100644 --- a/examples/widgets/mainwindows/recentfiles/main.cpp +++ b/examples/widgets/mainwindows/recentfiles/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - app.setOrganizationName("Trolltech"); + app.setOrganizationName("QtProject"); app.setApplicationName("Recent Files Example"); MainWindow *mainWin = new MainWindow; mainWin->show(); diff --git a/examples/widgets/mainwindows/sdi/main.cpp b/examples/widgets/mainwindows/sdi/main.cpp index 201ae62bc1..38e734e2e6 100644 --- a/examples/widgets/mainwindows/sdi/main.cpp +++ b/examples/widgets/mainwindows/sdi/main.cpp @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(sdi); QApplication app(argc, argv); app.setApplicationName("SDI Example"); - app.setOrganizationName("Trolltech"); + app.setOrganizationName("QtProject"); MainWindow *mainWin = new MainWindow; mainWin->show(); return app.exec(); From 26dddabcaae2a9e0adf3e960165ae481abf39bc7 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:59:06 +0200 Subject: [PATCH 020/114] Test: remove QSKIP from tst_QProcessEnvironment::putenv Instead omit the whole test when Q_OS_WINCE is defined. Change-Id: I19e35b837709c92e0202c6a96d113367bc6c92c2 Reviewed-by: J-P Nurmi --- .../io/qprocessenvironment/tst_qprocessenvironment.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index eb3f25dd1b..3826bfc4e2 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp @@ -57,7 +57,9 @@ private slots: void caseSensitivity(); void systemEnvironment(); +#ifndef Q_OS_WINCE void putenv(); +#endif }; void tst_QProcessEnvironment::operator_eq() @@ -276,11 +278,10 @@ void tst_QProcessEnvironment::systemEnvironment() #endif } +#ifndef Q_OS_WINCE +//Windows CE has no environment void tst_QProcessEnvironment::putenv() { -#ifdef Q_OS_WINCE - QSKIP("Windows CE has no environment"); -#else static const char envname[] = "WE_RE_SETTING_THIS_ENVIRONMENT_VARIABLE"; static bool testRan = false; @@ -311,8 +312,8 @@ void tst_QProcessEnvironment::putenv() QVERIFY(eAfter.contains(lower)); QCOMPARE(eAfter.value(lower), QString("Hello, World")); # endif -#endif } +#endif QTEST_MAIN(tst_QProcessEnvironment) From d81cf44a6b8c465353c9d4fed10fdf1f876c85cb Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:43:08 +0200 Subject: [PATCH 021/114] Test: remove QSKIP from tst_qstextstream Instead omit the whole tests when Q_OS_WINCE is defined. Change-Id: Idb15d622c9e1dbe4c8ec6a43c34a88e7fef2a384 Reviewed-by: J-P Nurmi --- .../io/qtextstream/tst_qtextstream.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index f37209db06..9e2cd5ec2a 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -195,9 +195,11 @@ private slots: void pos(); void pos2(); void pos3LargeFile(); +#ifndef Q_OS_WINCE void readStdin(); void readAllFromStdin(); void readLineFromStdin(); +#endif void read(); void qbool(); void forcePoint(); @@ -1385,11 +1387,10 @@ void tst_QTextStream::pos3LargeFile() } // ------------------------------------------------------------------------------ +#ifndef Q_OS_WINCE +// Qt/CE has no stdin/out support for processes void tst_QTextStream::readStdin() { -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE has no stdin/out support for processes"); -#endif QProcess stdinProcess; stdinProcess.start("stdinProcess/stdinProcess"); stdinProcess.setReadChannel(QProcess::StandardError); @@ -1409,13 +1410,13 @@ void tst_QTextStream::readStdin() QCOMPARE(b, 2); QCOMPARE(c, 3); } +#endif // ------------------------------------------------------------------------------ +#ifndef Q_OS_WINCE +// Qt/CE has no stdin/out support for processes void tst_QTextStream::readAllFromStdin() { -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE has no stdin/out support for processes"); -#endif QProcess stdinProcess; stdinProcess.start("readAllStdinProcess/readAllStdinProcess", QIODevice::ReadWrite | QIODevice::Text); stdinProcess.setReadChannel(QProcess::StandardError); @@ -1430,13 +1431,13 @@ void tst_QTextStream::readAllFromStdin() QChar quoteChar('"'); QCOMPARE(stream.readAll(), QString::fromLatin1("%1hello world%2 \n").arg(quoteChar).arg(quoteChar)); } +#endif // ------------------------------------------------------------------------------ +#ifndef Q_OS_WINCE +// Qt/CE has no stdin/out support for processes void tst_QTextStream::readLineFromStdin() { -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE has no stdin/out support for processes"); -#endif QProcess stdinProcess; stdinProcess.start("readLineStdinProcess/readLineStdinProcess", QIODevice::ReadWrite | QIODevice::Text); stdinProcess.setReadChannel(QProcess::StandardError); @@ -1453,6 +1454,7 @@ void tst_QTextStream::readLineFromStdin() QVERIFY(stdinProcess.waitForFinished(5000)); } +#endif // ------------------------------------------------------------------------------ void tst_QTextStream::read() From 782cae4104ececc05e2864f788ea8a0539c0cbf0 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:37:23 +0200 Subject: [PATCH 022/114] Test: remove QSKIP in tst_QCoreApplication::argc Instead omit the whole test when Q_OS_WIN is defined since the test is invalid on this platform. Change-Id: Idb77df96b0c2a223cddbfffb4e24c6d1f5d33dfb Reviewed-by: J-P Nurmi --- .../kernel/qcoreapplication/tst_qcoreapplication.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index f662a8835a..dce7219ed9 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -53,7 +53,9 @@ private slots: void sendEventsOnProcessEvents(); // this must be the first test void getSetCheck(); void qAppName(); +#ifndef Q_OS_WIN void argc(); +#endif void postEvent(); void removePostedEvents(); #ifndef QT_NO_THREAD @@ -125,11 +127,11 @@ void tst_QCoreApplication::qAppName() QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1("tst_qcoreapplication")); } +// "QCoreApplication::arguments() always parses arguments from actual command line on Windows +// making this test invalid." +#ifndef Q_OS_WIN void tst_QCoreApplication::argc() { -#ifdef Q_OS_WIN - QSKIP("QCoreApplication::arguments() always parses arguments from actual command line in Windows, making this test invalid."); -#endif { int argc = 1; char *argv[] = { const_cast("tst_qcoreapplication") }; @@ -166,6 +168,7 @@ void tst_QCoreApplication::argc() QCOMPARE(app.arguments().count(), 1); } } +#endif class EventGenerator : public QObject { From af13c79b30c1c8d5a5de6fd0e942c57b53fab9b4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 16 Oct 2012 13:06:43 +0300 Subject: [PATCH 023/114] Implement setWindowIcon() for Windows. Platform implementation for QWindow::setWindowIcon() was missing from Windows platform plugin. Task-number: QTBUG-27175 Change-Id: I6807d1ded057b7788a9f2fa5b143e212a666029b Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowswindow.cpp | 39 +++++++++++++++++-- .../platforms/windows/qwindowswindow.h | 16 ++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index f3830eb962..a31b09d2bf 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -61,6 +61,8 @@ QT_BEGIN_NAMESPACE +Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &); + static QByteArray debugWinStyle(DWORD style) { QByteArray rc = "0x"; @@ -699,13 +701,15 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : m_cursor(QWindowsScreen::screenOf(aWindow)->windowsCursor()->standardWindowCursor()), m_dropTarget(0), m_savedStyle(0), - m_format(aWindow->format()) + m_format(aWindow->format()), #ifdef QT_OPENGL_ES_2 - , m_eglSurface(0) + m_eglSurface(0), #endif #ifdef Q_OS_WINCE - , m_previouslyHidden(false) + m_previouslyHidden(false), #endif + m_iconBig(0), + m_iconSmall(0) { if (aWindow->surfaceType() == QWindow::OpenGLSurface) setFlag(OpenGLSurface); @@ -730,6 +734,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : QWindowsWindow::~QWindowsWindow() { destroyWindow(); + destroyIcon(); } void QWindowsWindow::destroyWindow() @@ -1754,4 +1759,32 @@ QByteArray QWindowsWindow::debugWindowFlags(Qt::WindowFlags wf) return rc; } +static HICON createHIcon(const QIcon &icon, int xSize, int ySize) +{ + if (!icon.isNull()) { + const QPixmap pm = icon.pixmap(icon.actualSize(QSize(xSize, ySize))); + if (!pm.isNull()) + return qt_pixmapToWinHICON(pm); + } + return 0; +} + +void QWindowsWindow::setWindowIcon(const QIcon &icon) +{ + if (m_data.hwnd) { + destroyIcon(); + + m_iconSmall = createHIcon(icon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); + m_iconBig = createHIcon(icon, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); + + if (m_iconBig) { + SendMessage(m_data.hwnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)m_iconSmall); + SendMessage(m_data.hwnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)m_iconBig); + } else { + SendMessage(m_data.hwnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)m_iconSmall); + SendMessage(m_data.hwnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)m_iconSmall); + } + } +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 3b7666cf32..5d898a2d41 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -238,6 +238,7 @@ public: void setEnabled(bool enabled); bool isEnabled() const; + void setWindowIcon(const QIcon &icon); #ifndef Q_OS_WINCE void alertWindow(int durationMs = 0); @@ -259,6 +260,7 @@ private: void unregisterDropSite(); void handleGeometryChange(); void handleWindowStateChange(Qt::WindowState state); + inline void destroyIcon(); mutable WindowData m_data; mutable unsigned m_flags; @@ -277,6 +279,8 @@ private: #ifdef Q_OS_WINCE bool m_previouslyHidden; #endif + HICON m_iconSmall; + HICON m_iconBig; }; // Conveniences for window frames. @@ -346,6 +350,18 @@ void QWindowsWindow::setUserDataOf(HWND hwnd, void *ud) SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(ud)); } +inline void QWindowsWindow::destroyIcon() +{ + if (m_iconBig) { + DestroyIcon(m_iconBig); + m_iconBig = 0; + } + if (m_iconSmall) { + DestroyIcon(m_iconSmall); + m_iconSmall = 0; + } +} + QT_END_NAMESPACE #endif // QWINDOWSWINDOW_H From 5fb7d6240b659d2ea176c1791c5f6e251a165061 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 14:34:14 +0200 Subject: [PATCH 024/114] Mark linux accessibility test as insignificant. The test was not run so far and chances are that it would block the CI completely. So disable it for now, enable it again as soon as breakages have been fixed. Change-Id: I452c02027b37a604eefbadb253c9a4d5041ef159 Reviewed-by: Sergio Ahumada --- tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro index c63bf6e460..be6b537c0c 100644 --- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro +++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro @@ -1,4 +1,9 @@ CONFIG += testcase + +# This is temporary to start running the test as part of normal CI. +CONFIG += insignificant_test + + TARGET = tst_qaccessibilitylinux SOURCES += tst_qaccessibilitylinux.cpp \ ../../../../src/platformsupport/linuxaccessibility/dbusconnection.cpp \ From 05c2113350a8abbb1df844a2b1d1befb95a93f5e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 15 Oct 2012 14:10:58 +0200 Subject: [PATCH 025/114] Add QObject* QStyleOption::styleObject The object is used, amongst other things, as a target for sending style animation updates. Change-Id: Ic210e7ae2111bc08b70331a3a2030a494919a06d Reviewed-by: Gabriel de Dietrich Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qstyleoption.cpp | 20 ++++++++++++++++---- src/widgets/styles/qstyleoption.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 3017f30470..8a469b496d 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -155,7 +155,7 @@ QT_BEGIN_NAMESPACE QStyleOption::QStyleOption(int version, int type) : version(version), type(type), state(QStyle::State_None), - direction(QApplication::layoutDirection()), fontMetrics(QFont()) + direction(QApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0) { } @@ -171,8 +171,8 @@ QStyleOption::~QStyleOption() \fn void QStyleOption::initFrom(const QWidget *widget) \since 4.1 - Initializes the \l state, \l direction, \l rect, \l palette, and - \l fontMetrics member variables based on the specified \a widget. + Initializes the \l state, \l direction, \l rect, \l palette, \l fontMetrics + and \l styleObject member variables based on the specified \a widget. This is a convenience function; the member variables can also be initialized manually. @@ -227,6 +227,7 @@ void QStyleOption::init(const QWidget *widget) rect = widget->rect(); palette = widget->palette(); fontMetrics = widget->fontMetrics(); + styleObject = const_cast(widget); } /*! @@ -235,7 +236,7 @@ void QStyleOption::init(const QWidget *widget) QStyleOption::QStyleOption(const QStyleOption &other) : version(Version), type(Type), state(other.state), direction(other.direction), rect(other.rect), fontMetrics(other.fontMetrics), - palette(other.palette) + palette(other.palette), styleObject(other.styleObject) { } @@ -249,6 +250,7 @@ QStyleOption &QStyleOption::operator=(const QStyleOption &other) rect = other.rect; fontMetrics = other.fontMetrics; palette = other.palette; + styleObject = other.styleObject; return *this; } @@ -311,6 +313,15 @@ QStyleOption &QStyleOption::operator=(const QStyleOption &other) \sa initFrom() */ +/*! + \variable QStyleOption::styleObject + \brief the object being styled + + The built-in styles support the following types: QWidget, QGraphicsObject and QQuickItem. + + \sa initFrom() +*/ + /*! \variable QStyleOption::rect \brief the area that should be used for various calculations and painting @@ -4056,6 +4067,7 @@ QDebug operator<<(QDebug debug, const QStyleOption &option) debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); debug << ',' << option.state; debug << ',' << option.rect; + debug << ',' << option.styleObject; debug << ')'; #else Q_UNUSED(option); diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 7ca0ca2bf3..d88582a9f8 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -89,6 +89,7 @@ public: QRect rect; QFontMetrics fontMetrics; QPalette palette; + QObject *styleObject; QStyleOption(int version = QStyleOption::Version, int type = SO_Default); QStyleOption(const QStyleOption &other); From 67ff4607780bf8985aab198178190fcc6fb133f6 Mon Sep 17 00:00:00 2001 From: Niels Weber Date: Tue, 16 Oct 2012 09:58:12 +0200 Subject: [PATCH 026/114] Document needed packages for XCB on Fedora. Change-Id: I415416e82d342b232607fe7087350a9dad615f7a Reviewed-by: Joerg Bornemann --- src/plugins/platforms/xcb/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README index 6254d68ae8..264d28c6b4 100644 --- a/src/plugins/platforms/xcb/README +++ b/src/plugins/platforms/xcb/README @@ -9,3 +9,7 @@ The packages for xcb-render-util can be installed manually from http://packages. On Ubuntu 12.04 icccm1 is replaced by icccm4 and xcb-render-util can be installed automatically: libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev + + +On Fedora, the following packages are required: +libxcb libxcb-devel libXrender libXrender-devel xcb-util-wm xcb-util-wm-devel xcb-util xcb-util-devel xcb-util-image xcb-util-image-devel xcb-util-keysyms xcb-util-keysyms-devel From 3a685dcd5ef3b9e264abd7aacc9a8daffdb67992 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 16 Oct 2012 14:44:55 +0200 Subject: [PATCH 027/114] Fix incorrectly scaled constants on Mac This fixes several scaled constants on mac that are inherited from commonstyle. (such as toolbutton arrows) It is probably easiest to see when running Windows style on mac. The problem was that the code assumed a default dpi of 96 would be used on all platforms. Change-Id: I83789589009b268dcb1d96629c3ec9e8f968a891 Reviewed-by: Gabriel de Dietrich Reviewed-by: Richard Moe Gustavsen Reviewed-by: Shawn Rutledge --- src/widgets/styles/qstylehelper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index b8fbf37333..e23db2b637 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -77,8 +77,13 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & qreal dpiScaled(qreal value) { +#ifdef Q_OS_MAC + // On mac the DPI is allways 72 so we should not scale it + return value; +#else static const qreal scale = qreal(qt_defaultDpiX()) / 96.0; return value * scale; +#endif } From 08748f147b44983d9155baa420b84423aec43e1d Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 12:58:32 +0200 Subject: [PATCH 028/114] Add parameter documentation. Change-Id: I8ce85bbb286c3cb844ef600daa5e99432ee55b74 Reviewed-by: Jerome Pasion --- src/corelib/kernel/qtranslator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 6d9133529a..c4486d3ae6 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -695,7 +695,7 @@ static QString find_translation(const QLocale & locale, \li File name with ui language part stripped further, etc. \endlist - For example, an application running in the locale with the following + For example, an application running in the \a locale with the following \l{QLocale::uiLanguages()}{ui languages} - "es", "fr-CA", "de" might call load(QLocale::system(), "foo", ".", "/opt/foolib", ".qm"). load() would replace '-' (dash) with '_' (underscore) in the ui language and then try to From 77308b46784310028b1210f5c85727f90803e409 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 4 Oct 2012 13:19:32 +0200 Subject: [PATCH 029/114] implement QCocoaWindow::setWindowIcon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code taken from Qt 4.8. Task-number: QTBUG-27175 Change-Id: I0f7a1add3ea63761c956e43d591cd1b26f25760e Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 014db378e7..3c6dd96424 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -102,6 +102,7 @@ public: Qt::WindowState setWindowState(Qt::WindowState state); void setWindowTitle(const QString &title); void setWindowFilePath(const QString &filePath); + void setWindowIcon(const QIcon &icon); void raise(); void lower(); void propagateSizeHints(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f4a4936c28..c658a8d777 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -429,6 +429,26 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath) [m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""]; } +void QCocoaWindow::setWindowIcon(const QIcon &icon) +{ + QCocoaAutoReleasePool pool; + + NSButton *iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton]; + if (iconButton == nil) { + NSString *title = QCFString::toNSString(window()->windowTitle()); + [m_nsWindow setRepresentedURL:[NSURL fileURLWithPath:title]]; + iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton]; + } + if (icon.isNull()) { + [iconButton setImage:nil]; + } else { + QPixmap pixmap = icon.pixmap(QSize(22, 22)); + NSImage *image = static_cast(qt_mac_create_nsimage(pixmap)); + [iconButton setImage:image]; + [image release]; + } +} + void QCocoaWindow::raise() { //qDebug() << "raise" << this; From a5e7c2802af59d4940e3479288cb9346205b984c Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Tue, 16 Oct 2012 12:47:09 +0200 Subject: [PATCH 030/114] QComboBox: mention insert policy in context of editable property This makes it a little bit easier for the reader to discover what editable combo boxes are about. Change-Id: I60ce571f01e32d4cacb4718b42a8e12884bd1c13 Reviewed-by: Marc Mutz --- src/widgets/widgets/qcombobox.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 870e25b241..e71abb2d82 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1597,7 +1597,10 @@ void QComboBox::setIconSize(const QSize &size) \property QComboBox::editable \brief whether the combo box can be edited by the user - By default, this property is false. + By default, this property is false. The effect of editing depends + on the insert policy. + + \sa InsertPolicy */ bool QComboBox::isEditable() const { From 102e1822ffcdc9954d3c698f863734a8083e349c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 16 Oct 2012 12:26:42 +0200 Subject: [PATCH 031/114] Remove addition of dependencies for static libraries. The content in the prl file is not compatible with what CMake expects in the value of the IMPORTED_LINK_INTERFACE_LIBRARIES property. That property expects a list of IMPORTED targets or full paths to libraries. The prl file gives us a whitespace separated string of content suitable for passing to ld, that is, it contains -L and -l content. As this would take a lot of error prone parsing in cmake code in order to resolve the content to a list of full paths to libraries (which can be processed by any cmake generator), it's better to remove the code until qmake is able to generate a list of full paths. Change-Id: I72fe8e862b7f3bd25a7f9a03db94d2e9b815d08a Reviewed-by: Brad King Reviewed-by: Oswald Buddenhagen Reviewed-by: Clinton Stimpson Reviewed-by: Stephen Kelly --- mkspecs/cmake/Qt5BasicConfig.cmake.in | 39 +-------------------------- qmake/generators/makefile.cpp | 7 ----- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/mkspecs/cmake/Qt5BasicConfig.cmake.in b/mkspecs/cmake/Qt5BasicConfig.cmake.in index 28b687ee95..ef959d9ab1 100644 --- a/mkspecs/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/cmake/Qt5BasicConfig.cmake.in @@ -70,48 +70,11 @@ endif() set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS}\") -!!IF !isEmpty(CMAKE_STATIC_TYPE) - -if (NOT Qt5_EXCLUDE_STATIC_DEPENDENCIES) - # For static builds, we also list the dependencies of - # Qt so that consumers can build easily. - - macro(macro_process_prl_file prl_file_location Configuration) - if (EXISTS \"${prl_file_location}\") - file(STRINGS \"${prl_file_location}\" prl_strings REGEX \"QMAKE_PRL_LIBS_FOR_CMAKE\") - string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE *= *([^\\n]*)\" \"\\\\1\" static_depends ${prl_strings} ) - if (_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES) - set(_list_sep \";\") - endif() - set(_Qt5$${CMAKE_MODULE_NAME}_STATIC_${Configuration}_LIB_DEPENDENCIES \"${_list_sep}${static_depends}\") - endif() - endmacro() - -!!IF !isEmpty(CMAKE_DEBUG_TYPE) -!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) - macro_process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG) -!!ELSE - macro_process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG) -!!ENDIF -!!ENDIF - -!!IF !isEmpty(CMAKE_RELEASE_TYPE) -!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) - macro_process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE) -!!ELSE - macro_process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE) -!!ENDIF -!!ENDIF - -endif() - -!!ENDIF # Static - macro(_populate_imported_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES - \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${Configuration}_LIB_DEPENDENCIES}\" + \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\" !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) \"IMPORTED_LOCATION_${Configuration}\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${LIB_LOCATION}\" !!ELSE diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 260c7313f4..49f626b2d9 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1010,13 +1010,6 @@ MakefileGenerator::writePrlFile(QTextStream &t) for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) t << project->values((*it).toKey()).join(' ').replace('\\', "\\\\") << " "; t << endl; - t << "QMAKE_PRL_LIBS_FOR_CMAKE = "; - QString sep; - for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) { - t << sep << project->values((*it).toKey()).join(';').replace('\\', "\\\\"); - sep = ';'; - } - t << endl; } } From 47881a7144503a936f0db0b262e5a26d299679cf Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 9 Oct 2012 23:13:41 +0200 Subject: [PATCH 032/114] Compile fix for AIX with xlc The -qtls option is needed when building with thread support so it can use the local thread storage. Change-Id: I693d944efddac911fe03b2c9a6b06a28f112b54d Reviewed-by: Oswald Buddenhagen Reviewed-by: Andy Shaw --- mkspecs/aix-xlc/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/aix-xlc/qmake.conf b/mkspecs/aix-xlc/qmake.conf index 163e534ff3..8ea3d57299 100644 --- a/mkspecs/aix-xlc/qmake.conf +++ b/mkspecs/aix-xlc/qmake.conf @@ -21,7 +21,7 @@ QMAKE_CFLAGS_DEBUG = -g QMAKE_CFLAGS_SHLIB = QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB QMAKE_CFLAGS_YACC = -QMAKE_CFLAGS_THREAD = -qthreaded +QMAKE_CFLAGS_THREAD = -qthreaded -qtls QMAKE_CXX = xlC QMAKE_CXX_THREAD = xlC_r From 78f946f6dc23185e86d7a59e703cd8b3b6ee0e39 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 4 Oct 2012 15:43:11 +0200 Subject: [PATCH 033/114] QScreen manual test improvements: fields resize, better formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's necessary to set the fieldGrowthPolicy on the QFormLayout in order to have expanding fields on the Mac. Geometry formatting with negative x and y values looks better. Display fewer decimal digits for double fields. Change-Id: Icb252c0c3fb7b605253e04c3361beba124570840 Reviewed-by: Samuel Rødal --- tests/manual/qscreen/main.cpp | 4 ++-- tests/manual/qscreen/propertyfield.cpp | 24 ++++++++++++++++++------ tests/manual/qscreen/propertywatcher.cpp | 1 + tests/manual/qscreen/propertywatcher.h | 6 +++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp index 4f7ff8c96f..460fdc3edb 100644 --- a/tests/manual/qscreen/main.cpp +++ b/tests/manual/qscreen/main.cpp @@ -62,8 +62,8 @@ void updateSiblings(PropertyWatcher* w) void screenAdded(QScreen* screen) { screen->setOrientationUpdateMask((Qt::ScreenOrientations)0x0F); - qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), - screen->virtualSiblings().count(), qPrintable(screen->virtualSiblings().first()->name())); + qDebug("\nscreenAdded %s siblings %d first %s", qPrintable(screen->name()), screen->virtualSiblings().count(), + (screen->virtualSiblings().isEmpty() ? "none" : qPrintable(screen->virtualSiblings().first()->name()))); PropertyWatcher *w = new PropertyWatcher(screen, QString::number(i++)); QLineEdit *siblingsField = new QLineEdit(); siblingsField->setObjectName("siblings"); diff --git a/tests/manual/qscreen/propertyfield.cpp b/tests/manual/qscreen/propertyfield.cpp index 6ac63b3c65..c5e9442a26 100644 --- a/tests/manual/qscreen/propertyfield.cpp +++ b/tests/manual/qscreen/propertyfield.cpp @@ -56,14 +56,26 @@ PropertyField::PropertyField(QObject* subject, const QMetaProperty& prop, QWidge QString PropertyField::valueToString(QVariant val) { - QString text = val.toString(); - if (val.type() == QVariant::Size) + QString text; + switch (val.type()) { + case QVariant::Double: + text = QString("%1").arg(val.toReal(), 0, 'f', 4); + break; + case QVariant::Size: text = QString("%1 x %2").arg(val.toSize().width()).arg(val.toSize().height()); - else if (val.type() == QVariant::SizeF) + break; + case QVariant::SizeF: text = QString("%1 x %2").arg(val.toSizeF().width()).arg(val.toSizeF().height()); - else if (val.type() == QVariant::Rect) - text = QString("%1 x %2 +%3 +%4").arg(val.toRect().width()) - .arg(val.toRect().height()).arg(val.toRect().x()).arg(val.toRect().y()); + break; + case QVariant::Rect: { + QRect rect = val.toRect(); + text = QString("%1 x %2 %3%4 %5%6").arg(rect.width()) + .arg(rect.height()).arg(rect.x() < 0 ? "" : "+").arg(rect.x()) + .arg(rect.y() < 0 ? "" : "+").arg(rect.y()); + } break; + default: + text = val.toString(); + } return text; } diff --git a/tests/manual/qscreen/propertywatcher.cpp b/tests/manual/qscreen/propertywatcher.cpp index d342a94029..ee037a0a7c 100644 --- a/tests/manual/qscreen/propertywatcher.cpp +++ b/tests/manual/qscreen/propertywatcher.cpp @@ -63,6 +63,7 @@ PropertyWatcher::PropertyWatcher(QObject *subject, QString annotation, QWidget * QPushButton *updateButton = new QPushButton("update"); connect(updateButton, &QPushButton::clicked, this, &PropertyWatcher::updateAllFields); m_layout->addRow("", updateButton); + m_layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(m_layout); connect(subject, &QObject::destroyed, this, &PropertyWatcher::subjectDestroyed); } diff --git a/tests/manual/qscreen/propertywatcher.h b/tests/manual/qscreen/propertywatcher.h index c55776e97a..63c828f651 100644 --- a/tests/manual/qscreen/propertywatcher.h +++ b/tests/manual/qscreen/propertywatcher.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef WIDGET_H -#define WIDGET_H +#ifndef PROPERTY_WATCHER_H +#define PROPERTY_WATCHER_H #include @@ -69,4 +69,4 @@ protected: QFormLayout * m_layout; }; -#endif // WIDGET_H +#endif // PROPERTY_WATCHER_H From fb21212f1eeddb9e2f13b7d5b0b4f48147f05412 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 10 Oct 2012 17:52:21 +0200 Subject: [PATCH 034/114] QWindowsKeyMapper: replace one magic constant with a symbolic one Replace occurrences of a literal 9 that mean 'number of modifier key combinations' with the new symbolic constant NumMods. Change-Id: I1e78a1a3c00b81095450ec0557e30751da44c39a Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index b57a27acb4..fff7b848b8 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -436,6 +436,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = { Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 7 Qt::NoModifier, // Fall-back to raw Key_* }; +static const size_t NumMods = sizeof ModsTbl / sizeof *ModsTbl; /** Remap return or action key to select key for windows mobile. @@ -535,7 +536,7 @@ static inline bool isModifierKey(int code) struct KeyboardLayoutItem { bool dirty; quint8 deadkeys; - quint32 qtKey[9]; // Can by any Qt::Key_, or unicode character + quint32 qtKey[NumMods]; // Can by any Qt::Key_, or unicode character }; void QWindowsKeyMapper::deleteLayouts() @@ -666,8 +667,8 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 if (QWindowsContext::verboseEvents > 1) { qDebug("updatePossibleKeyCodes for virtual key = 0x%02x!", vk_key); - for (int i = 0; i < 9; ++i) { - qDebug(" [%d] (%d,0x%02x,'%c') %s", i, + for (size_t i = 0; i < NumMods; ++i) { + qDebug(" [%d] (%d,0x%02x,'%c') %s", int(i), keyLayout[vk_key]->qtKey[i], keyLayout[vk_key]->qtKey[i], keyLayout[vk_key]->qtKey[i] ? keyLayout[vk_key]->qtKey[i] : 0x03, @@ -679,7 +680,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 bool QWindowsKeyMapper::isADeadKey(unsigned int vk_key, unsigned int modifiers) { if (keyLayout && (vk_key < 256) && keyLayout[vk_key]) { - for (register int i = 0; i < 9; ++i) { + for (register size_t i = 0; i < NumMods; ++i) { if (uint(ModsTbl[i]) == modifiers) return bool(keyLayout[vk_key]->deadkeys & 1< QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const } result << int(baseKey + keyMods); // The base key is _always_ valid, of course - for (int i = 1; i < 9; ++i) { + for (int i = 1; i < NumMods; ++i) { Qt::KeyboardModifiers neededMods = ModsTbl[i]; quint32 key = kbItem->qtKey[i]; if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) From cab891dc502f86cfc670d9facb2f9fa6708e9dd3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 10 Oct 2012 18:02:57 +0200 Subject: [PATCH 035/114] QWindowsKeyMapper: remove dead code As an array of automatic storage duration, 'keyLayout' can never be nullptr, so remove the respective check. Change-Id: I2fb2db8311de55b41a1f9aef7c35341949e38e5a Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index fff7b848b8..eeba99f93b 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -679,7 +679,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 bool QWindowsKeyMapper::isADeadKey(unsigned int vk_key, unsigned int modifiers) { - if (keyLayout && (vk_key < 256) && keyLayout[vk_key]) { + if ((vk_key < 256) && keyLayout[vk_key]) { for (register size_t i = 0; i < NumMods; ++i) { if (uint(ModsTbl[i]) == modifiers) return bool(keyLayout[vk_key]->deadkeys & 1< Date: Wed, 10 Oct 2012 18:27:04 +0200 Subject: [PATCH 036/114] QWindowsKeyMapper: use a more efficient data structure for 'keyLayout' Instead of allocating small chunks (40 bytes) on the heap, use a contiguous array to hold them. This always occupies 10240 bytes of memory instead of 1024 (32 bits) or 2048 (64 bits) for the pointer array (plus heap memory which depends on the number of items allocated), but is more cache-friendly and uses less memory when the array isn't sparse. To emulate the nullptr, a new bool has been added (doesn't change sizeof(KeyboardLayoutItem)). Also replace a few more magic numbers by symbolic constants. Change-Id: I7160f600faddd63deea265c89dc6fd857c7b557f Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowskeymapper.cpp | 94 +++++++------------ .../platforms/windows/qwindowskeymapper.h | 23 ++++- 2 files changed, 56 insertions(+), 61 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index eeba99f93b..c11bd8c53c 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -68,7 +68,6 @@ QWindowsKeyMapper::QWindowsKeyMapper() QWindowsKeyMapper::~QWindowsKeyMapper() { - deleteLayouts(); } #ifndef LANG_PASHTO @@ -437,6 +436,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = { Qt::NoModifier, // Fall-back to raw Key_* }; static const size_t NumMods = sizeof ModsTbl / sizeof *ModsTbl; +Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys)); /** Remap return or action key to select key for windows mobile. @@ -521,32 +521,10 @@ static inline bool isModifierKey(int code) // Keyboard map private ----------------------------------------------------------------[ start ]--- -/* - \internal - A Windows KeyboardLayoutItem has 8 possible states: - 1. Unmodified - 2. Shift - 3. Control - 4. Control + Shift - 5. Alt - 6. Alt + Shift - 7. Alt + Control - 8. Alt + Control + Shift -*/ -struct KeyboardLayoutItem { - bool dirty; - quint8 deadkeys; - quint32 qtKey[NumMods]; // Can by any Qt::Key_, or unicode character -}; - void QWindowsKeyMapper::deleteLayouts() { - for (int i = 0; i < 255; ++i) { - if (keyLayout[i]) { - delete keyLayout[i]; - keyLayout[i] = 0; - } - } + for (size_t i = 0; i < NumKeyboardLayoutItems; ++i) + keyLayout[i].exists = false; } void QWindowsKeyMapper::changeKeyboard() @@ -595,12 +573,9 @@ void QWindowsKeyMapper::updateKeyMap(const MSG &msg) void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key) { - if (!vk_key || (keyLayout[vk_key] && !keyLayout[vk_key]->dirty)) + if (!vk_key || (keyLayout[vk_key].exists && !keyLayout[vk_key].dirty)) return; - if (!keyLayout[vk_key]) - keyLayout[vk_key] = new KeyboardLayoutItem; - // Copy keyboard state, so we can modify and query output for each possible permutation unsigned char buffer[256]; memcpy(buffer, kbdBuffer, sizeof(buffer)); @@ -616,40 +591,41 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 buffer[VK_LMENU ] = 0; // Use right Alt, since left Ctrl + right Alt is considered AltGraph bool isDeadKey = false; - keyLayout[vk_key]->deadkeys = 0; - keyLayout[vk_key]->dirty = false; + keyLayout[vk_key].deadkeys = 0; + keyLayout[vk_key].dirty = false; + keyLayout[vk_key].exists = true; setKbdState(buffer, false, false, false); - keyLayout[vk_key]->qtKey[0] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x01 : 0; + keyLayout[vk_key].qtKey[0] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x01 : 0; setKbdState(buffer, true, false, false); - keyLayout[vk_key]->qtKey[1] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x02 : 0; + keyLayout[vk_key].qtKey[1] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x02 : 0; setKbdState(buffer, false, true, false); - keyLayout[vk_key]->qtKey[2] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x04 : 0; + keyLayout[vk_key].qtKey[2] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x04 : 0; setKbdState(buffer, true, true, false); - keyLayout[vk_key]->qtKey[3] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x08 : 0; + keyLayout[vk_key].qtKey[3] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x08 : 0; setKbdState(buffer, false, false, true); - keyLayout[vk_key]->qtKey[4] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x10 : 0; + keyLayout[vk_key].qtKey[4] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x10 : 0; setKbdState(buffer, true, false, true); - keyLayout[vk_key]->qtKey[5] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x20 : 0; + keyLayout[vk_key].qtKey[5] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x20 : 0; setKbdState(buffer, false, true, true); - keyLayout[vk_key]->qtKey[6] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x40 : 0; + keyLayout[vk_key].qtKey[6] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x40 : 0; setKbdState(buffer, true, true, true); - keyLayout[vk_key]->qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); - keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x80 : 0; + keyLayout[vk_key].qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); + keyLayout[vk_key].deadkeys |= isDeadKey ? 0x80 : 0; // Add a fall back key for layouts which don't do composition and show non-latin1 characters int fallbackKey = winceKeyBend(vk_key); if (!fallbackKey || fallbackKey == Qt::Key_unknown) { fallbackKey = 0; - if (vk_key != keyLayout[vk_key]->qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) + if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) fallbackKey = vk_key; } - keyLayout[vk_key]->qtKey[8] = fallbackKey; + keyLayout[vk_key].qtKey[8] = fallbackKey; // If this vk_key a Dead Key if (MapVirtualKey(vk_key, 2) & 0x80000000) { @@ -669,20 +645,20 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 qDebug("updatePossibleKeyCodes for virtual key = 0x%02x!", vk_key); for (size_t i = 0; i < NumMods; ++i) { qDebug(" [%d] (%d,0x%02x,'%c') %s", int(i), - keyLayout[vk_key]->qtKey[i], - keyLayout[vk_key]->qtKey[i], - keyLayout[vk_key]->qtKey[i] ? keyLayout[vk_key]->qtKey[i] : 0x03, - keyLayout[vk_key]->deadkeys & (1<deadkeys & 1< QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const { QList result; - KeyboardLayoutItem *kbItem = keyLayout[e->nativeVirtualKey()]; - if (!kbItem) + const KeyboardLayoutItem &kbItem = keyLayout[e->nativeVirtualKey()]; + if (!kbItem.exists) return result; - quint32 baseKey = kbItem->qtKey[0]; + quint32 baseKey = kbItem.qtKey[0]; Qt::KeyboardModifiers keyMods = e->modifiers(); if (baseKey == Qt::Key_Return && (e->nativeModifiers() & ExtendedKey)) { result << int(Qt::Key_Enter + keyMods); @@ -1138,7 +1114,7 @@ QList QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const for (int i = 1; i < NumMods; ++i) { Qt::KeyboardModifiers neededMods = ModsTbl[i]; - quint32 key = kbItem->qtKey[i]; + quint32 key = kbItem.qtKey[i]; if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) result << int(key + (keyMods & ~neededMods)); } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h index 7b3f18a42d..6de255facf 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.h +++ b/src/plugins/platforms/windows/qwindowskeymapper.h @@ -51,7 +51,25 @@ QT_BEGIN_NAMESPACE class QKeyEvent; class QWindow; -struct KeyboardLayoutItem; +/* + \internal + A Windows KeyboardLayoutItem has 8 possible states: + 1. Unmodified + 2. Shift + 3. Control + 4. Control + Shift + 5. Alt + 6. Alt + Shift + 7. Alt + Control + 8. Alt + Control + Shift +*/ +struct KeyboardLayoutItem { + uint dirty : 1; + uint exists : 1; // whether this item has been initialized (by updatePossibleKeyCodes) + quint8 deadkeys; + static const size_t NumQtKeys = 9; + quint32 qtKey[NumQtKeys]; // Can by any Qt::Key_, or unicode character +}; class QWindowsKeyMapper { @@ -87,8 +105,9 @@ private: bool isADeadKey(unsigned int vk_key, unsigned int modifiers); void deleteLayouts(); - KeyboardLayoutItem *keyLayout[256]; QWindow *m_keyGrabber; + static const size_t NumKeyboardLayoutItems = 256; + KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems]; }; enum WindowsNativeModifiers { From 93e0f1223ae4c68cd7a84924d7525ac63f4395f6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 11 Oct 2012 15:16:48 +0200 Subject: [PATCH 037/114] fix syntax of warning message Change-Id: I2e0a9afd6e46534156b7277dc5ceaf85d2dd4cac Reviewed-by: Joerg Bornemann --- mkspecs/features/spec_post.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/spec_post.prf b/mkspecs/features/spec_post.prf index 3af6bbd36a..a58690e8a6 100644 --- a/mkspecs/features/spec_post.prf +++ b/mkspecs/features/spec_post.prf @@ -41,6 +41,6 @@ isEmpty(QMAKE_COMPILER) { QMAKE_COMPILER = msvc else: \ error("qmake spec does not announce the compiler family, and it cannot be guessed.") - warning("qmake spec does not announce the compiler family. Guessed $$QMAKE_COMPILER.") + warning("qmake spec does not announce the compiler family. Guessed $${QMAKE_COMPILER}.") } CONFIG += $$QMAKE_COMPILER From 098644864713d6956d33d45cc610e2c6afb5211f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 12 Oct 2012 21:42:19 +0200 Subject: [PATCH 038/114] restore compat with old perl: don't use \h in regexps Task-number: QTBUG-27543 Change-Id: I94a1368de69faeabe359e2c5e1f22879e9e96cc8 Reviewed-by: Andy Shaw Reviewed-by: Joerg Bornemann --- bin/syncqt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index bbbbe33d50..3ca057ec6c 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -794,10 +794,10 @@ $isunix = checkUnix; #cache checkUnix my $qt_version = fileContents($qtbasedir."/mkspecs/qconfig.pri"); if (length($qt_version)) { - $qt_version =~ s,.*^QT_VERSION\h*=\h*(\S+).*,$1,sm; + $qt_version =~ s,.*^QT_VERSION[ \t]*=[ \t]*(\S+).*,$1,sm; } else { $qt_version = fileContents($basedir."/src/corelib/global/qglobal.h"); - $qt_version =~ s,.*^#\h*define\h+QT_VERSION_STR\h+"([^"]+)".*,$1,sm; + $qt_version =~ s,.*^#[ \t]*define[ \t]+QT_VERSION_STR[ \t]+"([^"]+)".*,$1,sm; } foreach my $lib (@modules_to_sync) { die "No such module: $lib" unless(defined $modules{$lib}); @@ -808,7 +808,7 @@ foreach my $lib (@modules_to_sync) { my $project = $dir; $project =~ s,/([^/]+)$,/$1/$1.pro,; my $module_version = fileContents($project); - $module_version = $qt_version unless ($module_version =~ s,.*^VERSION\h*=\h*(\S+).*,$1,sm); + $module_version = $qt_version unless ($module_version =~ s,.*^VERSION[ \t]*=[ \t]*(\S+).*,$1,sm); # Backwards compatibility for modules with checked in .pri files. if (defined $modulepris{$lib} and -e "$modulepris{$lib}") { From 9f83e499b5fb4b8a5400405300912c4b8bf6cb30 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 12 Oct 2012 10:08:41 +0200 Subject: [PATCH 039/114] Clarify ownership of scene in QGraphicsView::setScene() docs. Change-Id: I550a02bce0633884ee1ffe2321c6462a34194f89 Reviewed-by: Jerome Pasion --- src/widgets/graphicsview/qgraphicsview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 380d58c4be..5c338367f9 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -1597,6 +1597,8 @@ QGraphicsScene *QGraphicsView::scene() const When a scene is set on a view, the QGraphicsScene::changed() signal is automatically connected to this view's updateScene() slot, and the view's scroll bars are adjusted to fit the size of the scene. + + The view does not take ownership of \a scene. */ void QGraphicsView::setScene(QGraphicsScene *scene) { From 4fc515de4ec4b30365040d5144b1e7c0cd41906d Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 15:08:35 +0200 Subject: [PATCH 040/114] Test: remove QSKIP from tst_LargeFile::mapOffsetOverflow Instead omit the whole test when Q_OS_MAC is defined. Change-Id: I7d35c99ecd69b3c5bb8f8590342edd9665300709 Reviewed-by: J-P Nurmi Reviewed-by: Sergio Ahumada --- tests/auto/corelib/io/largefile/tst_largefile.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index 25b3c05beb..ce5da82c82 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -121,7 +121,9 @@ private slots: // Map/unmap large file void mapFile(); +#ifndef Q_OS_MAC void mapOffsetOverflow(); +#endif void closeFile() { largeFile.close(); } @@ -510,12 +512,10 @@ void tst_LargeFile::mapFile() QVERIFY( largeFile.unmap( baseAddress ) ); } +//Mac: memory-mapping beyond EOF may succeed but it could generate bus error on access +#ifndef Q_OS_MAC void tst_LargeFile::mapOffsetOverflow() { -#if defined(Q_OS_MAC) - QSKIP("mmap'ping beyond EOF may succeed; generate bus error on access"); -#endif - // Out-of-range mappings should fail, and not silently clip the offset for (int i = 50; i < 63; ++i) { uchar *address = 0; @@ -530,6 +530,7 @@ void tst_LargeFile::mapOffsetOverflow() QVERIFY( !address ); } } +#endif QTEST_APPLESS_MAIN(tst_LargeFile) #include "tst_largefile.moc" From c8c0bdffb7d75840b99e5a10dae57ea2172a8eac Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 14:39:15 +0200 Subject: [PATCH 041/114] Test: remove QSKIP in tst_QDataStream::stream_QPixmap Instead omit the whole test when Q_OS_WINCE is defined. Change-Id: I356af3ea145012142b3cf2af0b5d813d4be07a25 Reviewed-by: J-P Nurmi --- .../auto/corelib/io/qdatastream/tst_qdatastream.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index e0f479524f..21089b5a1b 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -103,8 +103,10 @@ private slots: void stream_QPen_data(); void stream_QPen(); +#ifndef Q_OS_WINCE void stream_QPixmap_data(); void stream_QPixmap(); +#endif void stream_QPoint_data(); void stream_QPoint(); @@ -1526,20 +1528,21 @@ void tst_QDataStream::readQPen(QDataStream *s) // pixmap testing is currently limited to one pixmap only. // +#ifndef Q_OS_WINCE +// Test depends on more memory than available on Qt/CE void tst_QDataStream::stream_QPixmap_data() { -#ifndef Q_OS_WINCE stream_data(1); -#endif } +#endif +#ifndef Q_OS_WINCE +// Test depends on more memory than available on Qt/CE void tst_QDataStream::stream_QPixmap() { -#ifdef Q_OS_WINCE - QSKIP("Test depends on more memory than available on Qt/CE"); -#endif STREAM_IMPL(QPixmap); } +#endif void tst_QDataStream::stream_QIcon_data() { From 18a3ebe4e5999b4f01c3f006ae790dfe4bded3a3 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 14:32:37 +0200 Subject: [PATCH 042/114] Test: remove QSKIP in tst_QDirIterator::hiddenDirs_hiddenFiles Instead omit the whole test when Q_OS_WIN is defined. Change-Id: I08060168edb2353f4960129b1c0654fea165ca6c Reviewed-by: J-P Nurmi --- .../corelib/io/qdiriterator/tst_qdiriterator.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index a6be378d3b..f3fc6da968 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -120,7 +120,9 @@ private slots: void uncPaths_data(); void uncPaths(); #endif +#ifndef Q_OS_WIN void hiddenDirs_hiddenFiles(); +#endif }; void tst_QDirIterator::initTestCase() @@ -600,15 +602,13 @@ void tst_QDirIterator::uncPaths() } #endif +#ifndef Q_OS_WIN +// In Unix it is easy to create hidden files, but in Windows it requires +// a special call since hidden files need to be "marked" while in Unix +// anything starting by a '.' is a hidden file. +// For that reason this test is not run in Windows. void tst_QDirIterator::hiddenDirs_hiddenFiles() { - // In Unix it is easy to create hidden files, but in Windows it requires - // a special call since hidden files need to be "marked" while in Unix - // anything starting by a '.' is a hidden file. - // For that reason this test is not run in Windows. -#if defined(Q_OS_WIN) - QSKIP("To create hidden files a special call is required in Windows."); -#else // Only files { int matches = 0; @@ -637,8 +637,8 @@ void tst_QDirIterator::hiddenDirs_hiddenFiles() QCOMPARE(matches, 6); QCOMPARE(failures, 0); } -#endif // Q_OS_WIN || Q_OS_WINCE } +#endif // Q_OS_WIN QTEST_MAIN(tst_QDirIterator) From fdc9ce5908ee47f9f5adac2d49899a4de887ccd5 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:32:17 +0200 Subject: [PATCH 043/114] Test: remove QSKIP from tst_QSocketNotifier::posixSockets Instead omit the whole test when Q_OS_UNIX is not defined. Change-Id: If0ee3345c25f6b1baa38845edfd08ec26a45d6f2 Reviewed-by: J-P Nurmi --- .../kernel/qsocketnotifier/tst_qsocketnotifier.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index 4a0fdad97c..bf745841c0 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -67,7 +67,9 @@ class tst_QSocketNotifier : public QObject private slots: void unexpectedDisconnection(); void mixingWithTimers(); +#ifdef Q_OS_UNIX void posixSockets(); +#endif }; class UnexpectedDisconnectTester : public QObject @@ -240,11 +242,10 @@ void tst_QSocketNotifier::mixingWithTimers() QTRY_COMPARE(helper.socketActivated, true); } +#ifdef Q_OS_UNIX +// test only for posix void tst_QSocketNotifier::posixSockets() { -#ifndef Q_OS_UNIX - QSKIP("test only for posix"); -#else QTcpServer server; QVERIFY(server.listen(QHostAddress::LocalHost, 0)); @@ -299,8 +300,8 @@ void tst_QSocketNotifier::posixSockets() QCOMPARE(passive->readAll(), QByteArray("goodbye",8)); } qt_safe_close(posixSocket); -#endif } +#endif QTEST_MAIN(tst_QSocketNotifier) #include From c35c913916aa9af99f530c08be297263b947e0d6 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:29:03 +0200 Subject: [PATCH 044/114] Test: remove QSKIP from tst_QThread::stressTest Instead omit the whole test when Q_OS_WINCE is defined. Change-Id: Id6f4e65c994115b8bab45f9fbf21dd255d204ea6 Reviewed-by: J-P Nurmi --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 663a1f9c3c..d7b810858d 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -106,7 +106,9 @@ private slots: void customEventDispatcher(); +#ifndef Q_OS_WINCE void stressTest(); +#endif void quitLock(); }; @@ -949,11 +951,11 @@ void tst_QThread::adoptMultipleThreadsOverlap() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(recorder.activationCount.load(), numThreads); } + +#ifndef Q_OS_WINCE +// Disconnects on WinCE void tst_QThread::stressTest() { -#if defined(Q_OS_WINCE) - QSKIP("Disconnects on WinCE, skipping..."); -#endif QTime t; t.start(); while (t.elapsed() < one_minute) { @@ -962,6 +964,7 @@ void tst_QThread::stressTest() t.wait(one_minute); } } +#endif class Syncronizer : public QObject { Q_OBJECT From a530c3381b06a6e26df5f2db6b20a962d98f88ca Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:15:13 +0200 Subject: [PATCH 045/114] Test: remove QSKIP in tst_QSharedPointer::lambdaCustomDeleter Instead omit the whole test when Q_COMPILER_LAMBDA is not defined since the test is not relevant in that case. Change-Id: I541da96a881fa0c9be38ae5c0f86df047dd8fc6b Reviewed-by: J-P Nurmi --- .../corelib/tools/qsharedpointer/tst_qsharedpointer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 614c04654d..9edcb8e787 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -91,7 +91,9 @@ private slots: #endif void constCorrectness(); void customDeleter(); +#ifdef Q_COMPILER_LAMBDA void lambdaCustomDeleter(); +#endif void creating(); void creatingQObject(); void mixTrackingPointerCode(); @@ -1325,11 +1327,10 @@ void tst_QSharedPointer::customDeleter() safetyCheck(); } +#ifdef Q_COMPILER_LAMBDA +// The compiler needs to be in C++11 mode and to support lambdas void tst_QSharedPointer::lambdaCustomDeleter() { -#ifndef Q_COMPILER_LAMBDA - QSKIP("This compiler is not in C++11 mode or does not support lambdas"); -#else { // stateless, one-argument QSharedPointer ptr(new Data, [](Data *d) { delete d; }); @@ -1353,8 +1354,8 @@ void tst_QSharedPointer::lambdaCustomDeleter() QCOMPARE(i, 42); } safetyCheck(); -#endif } +#endif void customQObjectDeleterFn(QObject *obj) { From 8c838f29d4df0082021c8b1792feb1d917249b84 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Aug 2012 19:44:09 +0200 Subject: [PATCH 046/114] QFileInfoGatherer: remove m_resolveSymlinks for non-Q_OS_WIN For some reason, m_resolveSymlinks was never set to true for non-Windows systems. The constructor set it to false and the setter was only implemented for Windows. So remove the member and code that is only executed if it is set to true, except on Windows. Change-Id: I386e980688a603475a413e2ef3628d0754778c5c Reviewed-by: Stephen Kelly Reviewed-by: Marc Mutz --- src/widgets/dialogs/qfileinfogatherer.cpp | 12 +++++++++--- src/widgets/dialogs/qfileinfogatherer_p.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 22a7d50f7c..138b1f9b74 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -75,11 +75,11 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent) #ifndef QT_NO_FILESYSTEMWATCHER watcher(0), #endif - m_resolveSymlinks(false), m_iconProvider(&defaultProvider) -{ #ifdef Q_OS_WIN - m_resolveSymlinks = true; + m_resolveSymlinks(true), #endif + m_iconProvider(&defaultProvider) +{ #ifndef QT_NO_FILESYSTEMWATCHER watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString))); @@ -108,7 +108,11 @@ void QFileInfoGatherer::setResolveSymlinks(bool enable) bool QFileInfoGatherer::resolveSymlinks() const { +#ifdef Q_OS_WIN return m_resolveSymlinks; +#else + return false; +#endif } void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider) @@ -233,6 +237,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const #endif #endif +#ifdef Q_OS_WIN if (fileInfo.isSymLink() && m_resolveSymlinks) { QFileInfo resolvedInfo(fileInfo.symLinkTarget()); resolvedInfo = resolvedInfo.canonicalFilePath(); @@ -240,6 +245,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const emit nameResolved(fileInfo.filePath(), resolvedInfo.fileName()); } } +#endif return info; } diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 9837b1aa08..87afbd96bd 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/dialogs/qfileinfogatherer_p.h @@ -192,7 +192,9 @@ private: #ifndef QT_NO_FILESYSTEMWATCHER QFileSystemWatcher *watcher; #endif +#ifdef Q_OS_WIN bool m_resolveSymlinks; // not accessed by run() +#endif QFileIconProvider *m_iconProvider; // not accessed by run() QFileIconProvider defaultProvider; }; From f8b6d104b981ef420756c0c20f62b8013d93ae15 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 16 Oct 2012 16:19:51 +0200 Subject: [PATCH 047/114] Bring back MacSizeChange event This ensures WA_MacNormalSize & Co. work (almost) properly. Task-number: QTCREATORBUG-7966 Change-Id: Ib03b5c0f163409e2bc387f6cf9b56c72c43caec7 Reviewed-by: Gabriel de Dietrich Reviewed-by: Jens Bache-Wiig Reviewed-by: Marc Mutz --- src/widgets/kernel/qwidget.cpp | 23 +++++++++++++++++++++-- src/widgets/kernel/qwidget_p.h | 5 +++-- src/widgets/styles/qstyleoption.cpp | 6 +++--- src/widgets/widgets/qcheckbox.cpp | 2 +- src/widgets/widgets/qcombobox.cpp | 2 +- src/widgets/widgets/qdatetimeedit.cpp | 2 +- src/widgets/widgets/qdialogbuttonbox.cpp | 2 +- src/widgets/widgets/qframe.cpp | 2 +- src/widgets/widgets/qgroupbox.cpp | 2 +- src/widgets/widgets/qlabel.cpp | 2 +- src/widgets/widgets/qprogressbar.cpp | 2 +- src/widgets/widgets/qpushbutton.cpp | 2 +- src/widgets/widgets/qradiobutton.cpp | 2 +- src/widgets/widgets/qspinbox.cpp | 2 +- src/widgets/widgets/qtabwidget.cpp | 2 +- src/widgets/widgets/qtoolbutton.cpp | 2 +- 16 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 29083b0670..bb148a52ac 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8318,10 +8318,11 @@ void QWidget::changeEvent(QEvent * event) } break; -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC case QEvent::MacSizeChange: updateGeometry(); break; +#elif defined Q_WS_MAC case QEvent::ToolTipChange: case QEvent::MouseTrackingChange: qt_mac_update_mouseTracking(this); @@ -9923,6 +9924,24 @@ static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidge } } +#ifdef Q_OS_MAC +void QWidgetPrivate::macUpdateSizeAttribute() +{ + Q_Q(QWidget); + QEvent event(QEvent::MacSizeChange); + QApplication::sendEvent(q, &event); + for (int i = 0; i < children.size(); ++i) { + QWidget *w = qobject_cast(children.at(i)); + if (w && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) + && !q->testAttribute(Qt::WA_MacMiniSize) // no attribute set? inherit from parent + && !w->testAttribute(Qt::WA_MacSmallSize) + && !w->testAttribute(Qt::WA_MacNormalSize)) + w->d_func()->macUpdateSizeAttribute(); + } + resolveFont(); +} +#endif + /*! Sets the attribute \a attribute on this widget if \a on is true; otherwise clears the attribute. @@ -10004,7 +10023,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) case Qt::WA_MacNormalSize: case Qt::WA_MacSmallSize: case Qt::WA_MacMiniSize: -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC { // We can only have one of these set at a time const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index eb67f756e8..c3a1d27709 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -725,7 +725,9 @@ public: void grabMouseWhileInWindow(); void registerTouchWindow(); void winSetupGestures(); -#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC +#elif defined(Q_OS_MAC) // <--------------------------------------------------------- MAC + void macUpdateSizeAttribute(); +#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC (old stuff) // This is new stuff uint needWindowChange : 1; @@ -752,7 +754,6 @@ public: //these are here just for code compat (HIViews) Qt::HANDLE qd_hd; - void macUpdateSizeAttribute(); void macUpdateHideOnSuspend(); void macUpdateOpaqueSizeGrip(); void macUpdateIgnoreMouseEvents(); diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 8a469b496d..53c1cf4559 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -41,8 +41,7 @@ #include "qstyleoption.h" #include "qapplication.h" -#ifdef Q_WS_MAC -# include "private/qt_mac_p.h" +#ifdef Q_OS_MAC # include "qmacstyle_mac.h" #endif #include @@ -206,7 +205,8 @@ void QStyleOption::init(const QWidget *widget) extern bool qt_mac_can_clickThrough(const QWidget *w); //qwidget_mac.cpp if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget)) state &= ~QStyle::State_Enabled; - +#endif +#ifdef Q_OS_MAC switch (QMacStyle::widgetSizePolicy(widget)) { case QMacStyle::SizeSmall: state |= QStyle::State_Small; diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp index c496198368..29ac80c77d 100644 --- a/src/widgets/widgets/qcheckbox.cpp +++ b/src/widgets/widgets/qcheckbox.cpp @@ -377,7 +377,7 @@ bool QCheckBox::event(QEvent *e) { Q_D(QCheckBox); if (e->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || e->type() == QEvent::MacSizeChange #endif ) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index e71abb2d82..16de0da4ac 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2660,7 +2660,7 @@ void QComboBox::changeEvent(QEvent *e) switch (e->type()) { case QEvent::StyleChange: d->updateDelegate(); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC case QEvent::MacSizeChange: #endif d->sizeHint = QSize(); // invalidate size hint diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 1a2ef8f645..7868690e49 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1036,7 +1036,7 @@ bool QDateTimeEdit::event(QEvent *event) d->updateEdit(); break; case QEvent::StyleChange: -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC case QEvent::MacSizeChange: #endif d->setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem); diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index c278b4f0ac..d25332a077 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -1204,7 +1204,7 @@ void QDialogButtonBox::changeEvent(QEvent *event) it.key()->setStyle(newStyle); } // fallthrough intended -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC case QEvent::MacSizeChange: #endif d->resetLayout(); diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp index 6d3ce9be92..3697a2a01f 100644 --- a/src/widgets/widgets/qframe.cpp +++ b/src/widgets/widgets/qframe.cpp @@ -518,7 +518,7 @@ void QFrame::changeEvent(QEvent *ev) { Q_D(QFrame); if (ev->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || ev->type() == QEvent::MacSizeChange #endif ) diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index 7705edd941..19a0368d94 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -688,7 +688,7 @@ void QGroupBox::changeEvent(QEvent *ev) d->_q_setChildrenEnabled(false); } } else if (ev->type() == QEvent::FontChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || ev->type() == QEvent::MacSizeChange #endif || ev->type() == QEvent::StyleChange) { diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 8c5026d5f6..d4ba3b2265 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -974,7 +974,7 @@ bool QLabel::event(QEvent *e) if (d->control) d->textLayoutDirty = true; } else if (e->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || e->type() == QEvent::MacSizeChange #endif ) { diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 8f0da78613..b7726e7771 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -562,7 +562,7 @@ bool QProgressBar::event(QEvent *e) { Q_D(QProgressBar); if (e->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || e->type() == QEvent::MacSizeChange #endif ) diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index 16e06872ae..5e8d7d16bd 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -674,7 +674,7 @@ bool QPushButton::event(QEvent *e) dialog->d_func()->setMainDefault(this); } } else if (e->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || e->type() == QEvent::MacSizeChange #endif ) { diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp index d257121d20..78d53ad0e6 100644 --- a/src/widgets/widgets/qradiobutton.cpp +++ b/src/widgets/widgets/qradiobutton.cpp @@ -257,7 +257,7 @@ bool QRadioButton::event(QEvent *e) { Q_D(QRadioButton); if (e->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || e->type() == QEvent::MacSizeChange #endif ) diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index fc11232f18..6a11c6d88c 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -1258,7 +1258,7 @@ bool QSpinBox::event(QEvent *event) { Q_D(QSpinBox); if (event->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || event->type() == QEvent::MacSizeChange #endif ) diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index 717550b2ec..963b86adc1 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -1050,7 +1050,7 @@ bool QTabWidget::event(QEvent *ev) void QTabWidget::changeEvent(QEvent *ev) { if (ev->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || ev->type() == QEvent::MacSizeChange #endif ) diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index 955f59ec47..d49bc98e47 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -573,7 +573,7 @@ void QToolButton::changeEvent(QEvent *e) if (qobject_cast(parentWidget())) d->autoRaise = true; } else if (e->type() == QEvent::StyleChange -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC || e->type() == QEvent::MacSizeChange #endif ) { From f2d8b94346fec0d988b87598694b9189b25befc3 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 16 Oct 2012 17:35:14 +0200 Subject: [PATCH 048/114] Add QDrag class to 'draganddrop' group Change-Id: I0cb96f57486dbda7cb9ca19556515e1b2b4f6c3e Reviewed-by: Jerome Pasion Reviewed-by: Marc Mutz --- src/gui/kernel/qdrag.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 1c2a6d301b..ff93801524 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE /*! \class QDrag \inmodule QtGui + \ingroup draganddrop \brief The QDrag class provides support for MIME-based drag and drop data transfer. From 68fd3b9c1f2fc1a69f2fd05d43e7297d03c74ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 3 Oct 2012 08:45:55 +0200 Subject: [PATCH 049/114] Remove mention of freetype options in configure. These options were only used for QWS in 4.x, and their documentation should have been removed as part of f220f99a6d13a395ca723e9f9. Task-number: QTBUG-27369 Change-Id: Ia85a20bdac40087c02f6876f53ce21568759d697 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- configure | 5 ----- 1 file changed, 5 deletions(-) diff --git a/configure b/configure index ef6014144c..684948e385 100755 --- a/configure +++ b/configure @@ -3281,11 +3281,6 @@ Additional options: -feature- .. Compile in . The available features are described in src/corelib/global/qfeatures.txt - -no-freetype ........ Do not compile in Freetype2 support. - -qt-freetype ........ Use the libfreetype bundled with Qt. - * -system-freetype .... Use libfreetype from the operating system. - See http://www.freetype.org/ - -qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the default ($CFG_QCONFIG). From 74227e073d9815be7ad1a7e14545e22fbcba306f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Oct 2012 17:34:48 -0700 Subject: [PATCH 050/114] Remove visibility attribute from function body in QtDBus Those were using an inconsistent macro compared to the function declaration in qdbusthreaddebug_p.h. Change-Id: I3e77ba83ceedc99cb1f957fdfe318e34ab9c9628 Reviewed-by: Olivier Goffart --- src/dbus/qdbusintegrator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index a6d4017a2d..3fb72e34d9 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -112,7 +112,7 @@ static inline QDebug operator<<(QDebug dbg, const QDBusConnectionPrivate *conn) return dbg.space(); } -Q_AUTOTEST_EXPORT void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *conn) +void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *conn) { qDBusDebug() << QThread::currentThread() << "QtDBus threading action" << action @@ -131,7 +131,7 @@ Q_AUTOTEST_EXPORT void qdbusDefaultThreadDebug(int action, int condition, QDBusC "condition unknown") << "in connection" << conn; } -Q_AUTOTEST_EXPORT qdbusThreadDebugFunc qdbusThreadDebug = 0; +qdbusThreadDebugFunc qdbusThreadDebug = 0; #endif typedef void (*QDBusSpyHook)(const QDBusMessage&); From c5b766638ac8cef1acebb97d5952485f5dc846ad Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 16 Oct 2012 13:51:05 +0200 Subject: [PATCH 051/114] Fixed cube opengl example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Proper variable initialization should fix crashs and black screens for that example. Task-number: QTBUG-27281 Task-number: QTBUG-27021 Change-Id: I538f233ea3c2faf6c1864c46be0d03828e92a110 Reviewed-by: Friedemann Kleint Reviewed-by: Samuel Rødal --- examples/opengl/cube/mainwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp index c1001cda33..055dcf49cf 100644 --- a/examples/opengl/cube/mainwidget.cpp +++ b/examples/opengl/cube/mainwidget.cpp @@ -55,7 +55,8 @@ MainWidget::MainWidget(QWidget *parent) : QGLWidget(parent), timer(new QBasicTimer), program(new QGLShaderProgram), - geometries(new GeometryEngine) + geometries(new GeometryEngine), + angularSpeed(0) { } From d6588d20518e6e33fdd5433d8af733657060b11e Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 9 Oct 2012 10:52:44 +0200 Subject: [PATCH 052/114] QPlatformWindow: change API for QPlatformWindow::setWindowState MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current implementation requests the platform window to set the window state if it can, and return the actual window state back. The problem with this approach is that the platform window is created as late as possible, so a call to QWindow::setWindowState would in many (most?) cases never be forwarded to the platform window (instead, the platform window is responsible to check the current window state upon creation). As such, the window state might be left unsynched with the platform window. This patch suggests removing the return value from QPlatformWindow::setWindowState. This will at least be consistent, so that setting/getting state would produce the same result independent of delayed window creation. If needed, we can later add new API to QPlatformIntegration or QPlatformWindow for querying supported/actual window state. Change-Id: Ie43f56169656854a765ce88b47a808f8f3d51bb4 Reviewed-by: Friedemann Kleint Reviewed-by: Thomas McGuire Reviewed-by: Samuel Rødal Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qplatformwindow.cpp | 5 +- src/gui/kernel/qplatformwindow.h | 2 +- src/gui/kernel/qwindow.cpp | 5 +- src/plugins/platforms/cocoa/qcocoawindow.h | 2 +- src/plugins/platforms/cocoa/qcocoawindow.mm | 4 +- src/plugins/platforms/eglfs/qeglfswindow.cpp | 3 +- src/plugins/platforms/eglfs/qeglfswindow.h | 2 +- src/plugins/platforms/qnx/qqnxwindow.cpp | 7 +- src/plugins/platforms/qnx/qqnxwindow.h | 2 +- .../platforms/windows/qwindowswindow.cpp | 3 +- .../platforms/windows/qwindowswindow.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 5 +- src/plugins/platforms/xcb/qxcbwindow.h | 2 +- src/widgets/kernel/qwidget_p.h | 2 - src/widgets/kernel/qwidget_qpa.cpp | 73 ------------------- 15 files changed, 18 insertions(+), 101 deletions(-) diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 27dfd7cf40..2bc6b01b3e 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -213,13 +213,12 @@ QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const /*! Requests setting the window state of this surface - to \a type. Returns the actual state set. + to \a type. Qt::WindowActive can be ignored. */ -Qt::WindowState QPlatformWindow::setWindowState(Qt::WindowState) +void QPlatformWindow::setWindowState(Qt::WindowState) { - return Qt::WindowNoState; } /*! diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 2b2d227fcf..12650d6073 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -91,7 +91,7 @@ public: virtual void setVisible(bool visible); virtual void setWindowFlags(Qt::WindowFlags flags); - virtual Qt::WindowState setWindowState(Qt::WindowState state); + virtual void setWindowState(Qt::WindowState state); virtual WId winId() const; virtual void setParent(const QPlatformWindow *window); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 39a6603c4b..4f1610cb21 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -828,9 +828,8 @@ void QWindow::setWindowState(Qt::WindowState state) Q_D(QWindow); if (d->platformWindow) - d->windowState = d->platformWindow->setWindowState(state); - else - d->windowState = state; + d->platformWindow->setWindowState(state); + d->windowState = state; } /*! diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 3c6dd96424..d5dbe58de9 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -99,7 +99,7 @@ public: void setCocoaGeometry(const QRect &rect); void setVisible(bool visible); void setWindowFlags(Qt::WindowFlags flags); - Qt::WindowState setWindowState(Qt::WindowState state); + void setWindowState(Qt::WindowState state); void setWindowTitle(const QString &title); void setWindowFilePath(const QString &filePath); void setWindowIcon(const QIcon &icon); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c658a8d777..93d566da3b 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -400,12 +400,10 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) m_windowFlags = flags; } -Qt::WindowState QCocoaWindow::setWindowState(Qt::WindowState state) +void QCocoaWindow::setWindowState(Qt::WindowState state) { if ([m_nsWindow isVisible]) syncWindowState(state); // Window state set for hidden windows take effect when show() is called. - - return state; } void QCocoaWindow::setWindowTitle(const QString &title) diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 9822262127..036b26a165 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -117,10 +117,9 @@ void QEglFSWindow::setGeometry(const QRect &) QPlatformWindow::setGeometry(rect); } -Qt::WindowState QEglFSWindow::setWindowState(Qt::WindowState) +void QEglFSWindow::setWindowState(Qt::WindowState) { setGeometry(QRect()); - return Qt::WindowFullScreen; } WId QEglFSWindow::winId() const diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h index c9ef60ac9c..40a38fcb26 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.h +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -56,7 +56,7 @@ public: ~QEglFSWindow(); void setGeometry(const QRect &); - Qt::WindowState setWindowState(Qt::WindowState state); + void setWindowState(Qt::WindowState state); WId winId() const; EGLSurface surface() const { return m_surface; } diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 9dd8ad7a71..097b5788f6 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -580,13 +580,13 @@ void QQnxWindow::requestActivateWindow() } -Qt::WindowState QQnxWindow::setWindowState(Qt::WindowState state) +void QQnxWindow::setWindowState(Qt::WindowState state) { qWindowDebug() << Q_FUNC_INFO << "state =" << state; // Prevent two calls with Qt::WindowFullScreen from changing m_unmaximizedGeometry if (m_windowState == state) - return state; + return; switch (state) { @@ -594,7 +594,7 @@ Qt::WindowState QQnxWindow::setWindowState(Qt::WindowState state) // WindowActive is not an accepted parameter according to the docs case Qt::WindowMinimized: case Qt::WindowActive: - return m_windowState; + return; case Qt::WindowMaximized: case Qt::WindowFullScreen: @@ -609,7 +609,6 @@ Qt::WindowState QQnxWindow::setWindowState(Qt::WindowState state) } m_windowState = state; - return state; } void QQnxWindow::gainedFocus() diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h index d79c6785dd..90226bb9a4 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.h +++ b/src/plugins/platforms/qnx/qqnxwindow.h @@ -101,7 +101,7 @@ public: void raise(); void lower(); void requestActivateWindow(); - Qt::WindowState setWindowState(Qt::WindowState state); + void setWindowState(Qt::WindowState state); void gainedFocus(); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a31b09d2bf..fc3566660a 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1235,13 +1235,12 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) QWindowSystemInterface::handleWindowStateChanged(window(), state); } -Qt::WindowState QWindowsWindow::setWindowState(Qt::WindowState state) +void QWindowsWindow::setWindowState(Qt::WindowState state) { if (m_data.hwnd) { setWindowState_sys(state); m_windowState = state; } - return state; } bool QWindowsWindow::isFullScreen_sys() const diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 5d898a2d41..978d1d5a53 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -160,7 +160,7 @@ public: virtual QPoint mapFromGlobal(const QPoint &pos) const; virtual void setWindowFlags(Qt::WindowFlags flags); - virtual Qt::WindowState setWindowState(Qt::WindowState state); + virtual void setWindowState(Qt::WindowState state); HWND handle() const { return m_data.hwnd; } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index cefe1a7786..bab1884a9a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -847,10 +847,10 @@ void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two) Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); } -Qt::WindowState QXcbWindow::setWindowState(Qt::WindowState state) +void QXcbWindow::setWindowState(Qt::WindowState state) { if (state == m_windowState) - return state; + return; // unset old state switch (m_windowState) { @@ -905,7 +905,6 @@ Qt::WindowState QXcbWindow::setWindowState(Qt::WindowState state) connection()->sync(); m_windowState = state; - return m_windowState; } void QXcbWindow::setNetWmWindowFlags(Qt::WindowFlags flags) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index e2f62401dc..bd4d18a175 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -82,7 +82,7 @@ public: void setVisible(bool visible); void setWindowFlags(Qt::WindowFlags flags); - Qt::WindowState setWindowState(Qt::WindowState state); + void setWindowState(Qt::WindowState state); WId winId() const; void setParent(const QPlatformWindow *window); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index c3a1d27709..8aba276966 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -803,8 +803,6 @@ public: static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool); void registerTouchWindow(bool enable = true); #endif - void setMaxWindowState_helper(); - void setFullScreenSize_helper(); bool stealKeyboardGrab(bool grab); bool stealMouseGrab(bool grab); }; diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index e7564261f9..2950c19768 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -586,33 +586,6 @@ void QWidgetPrivate::hide_sys() window->setVisible(false); } -void QWidgetPrivate::setMaxWindowState_helper() -{ - Q_Q(QWidget); - - const uint old_state = data.in_set_window_state; - data.in_set_window_state = 1; - - const QRect desktop = qApp->desktop()->availableGeometry(qApp->desktop()->screenNumber(q)); - q->setGeometry(desktop); - - data.in_set_window_state = old_state; -} - -void QWidgetPrivate::setFullScreenSize_helper() -{ - Q_Q(QWidget); - - const uint old_state = data.in_set_window_state; - data.in_set_window_state = 1; - - const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q)); - q->move(screen.topLeft()); - q->resize(screen.size()); - - data.in_set_window_state = old_state; -} - Qt::WindowState effectiveState(Qt::WindowStates state) { if (state & Qt::WindowMinimized) @@ -635,7 +608,6 @@ void QWidget::setWindowState(Qt::WindowStates newstate) data->window_state = newstate; data->in_set_window_state = 1; - bool needShow = false; Qt::WindowState newEffectiveState = effectiveState(newstate); Qt::WindowState oldEffectiveState = effectiveState(oldstate); if (isWindow() && newEffectiveState != oldEffectiveState) { @@ -649,54 +621,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate) Q_ASSERT(windowHandle()); windowHandle()->setWindowState(newEffectiveState); - bool supported = windowHandle()->windowState() == newEffectiveState; - - if (!supported) { - const bool wasResized = testAttribute(Qt::WA_Resized); - const bool wasMoved = testAttribute(Qt::WA_Moved); - - // undo the effects of the old emulated state - if (oldEffectiveState == Qt::WindowFullScreen) { - setParent(0, d->topData()->savedFlags); - needShow = true; - } else if (oldEffectiveState == Qt::WindowMinimized) { - needShow = true; - } - - // emulate the new window state - if (newEffectiveState == Qt::WindowMinimized) { - //### not ideal... - hide(); - needShow = false; - } else if (newEffectiveState == Qt::WindowFullScreen) { - d->topData()->savedFlags = windowFlags(); - setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); - d->setFullScreenSize_helper(); - raise(); - needShow = true; - } else if (newEffectiveState == Qt::WindowMaximized) { - createWinId(); - d->setMaxWindowState_helper(); - } else if (newEffectiveState == Qt::WindowNoState) { - // reset old geometry - QRect r = d->topData()->normalGeometry; - if (r.width() >= 0) { - d->topData()->normalGeometry = QRect(0,0,-1,-1); - setGeometry(r); - } - } - - // setWindowState() is not an explicit move/resize, same as the supported == true - // case - setAttribute(Qt::WA_Resized, wasResized); - setAttribute(Qt::WA_Moved, wasMoved); - } } data->in_set_window_state = 0; - if (needShow) - setVisible(true); - if (newstate & Qt::WindowActive) activateWindow(); From d686ad12e867ce3879d040284d48c91a4cb9d262 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 17 Oct 2012 11:29:26 +0200 Subject: [PATCH 053/114] Accessibility doesn't need QApp from QWidgets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I440179bfa95d6aa73c8b69b09431e4dc9fae5436 Reviewed-by: Sergio Ahumada Reviewed-by: Jan Arve Sæther --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 6a144f849d..68c1f8ae4a 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -42,7 +42,7 @@ #include "atspiadaptor_p.h" #include -#include +#include #include #include #include From 932bf57ea284fa7ea2addafc9be6bd4585b1d249 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 15 Oct 2012 14:23:07 +0200 Subject: [PATCH 054/114] QGraphicsObject: handle QEvent::StyleAnimationUpdate Change-Id: I8545d6f26e2c2398e750b0b85ba87892a2e376ae Reviewed-by: Jens Bache-Wiig --- src/widgets/graphicsview/qgraphicsitem.cpp | 12 ++++++++++++ src/widgets/graphicsview/qgraphicsitem.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 02088db6c8..375aa9b6ca 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -7575,6 +7575,18 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent QGraphicsItem::d_ptr->isObject = true; } +/*! + \reimp +*/ +bool QGraphicsObject::event(QEvent *ev) +{ + if (ev->type() == QEvent::StyleAnimationUpdate) { + update(); + return true; + } + return QObject::event(ev); +} + #ifndef QT_NO_GESTURES /*! Subscribes the graphics object to the given \a gesture with specific \a flags. diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 93fddd36ca..ce7adfcfad 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -594,6 +594,9 @@ Q_SIGNALS: protected: QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent); + + bool event(QEvent *ev); + private: friend class QGraphicsItem; friend class QGraphicsItemPrivate; From 037d1e18e39f24b8ebb2772c20444d4b44cfb12b Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Wed, 10 Oct 2012 16:05:22 +0300 Subject: [PATCH 055/114] Cocoa: remove current contentView when clearing window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise they might be still events sent to view with no proper QWindow. Also, add dealloc QNSView for clean up. Task-number: QTBUG-26580 Task-number: QTBUG-27456 Change-Id: Icdbe5c39490b72ec82795c2d71e5671cea81921e Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 1 + src/plugins/platforms/cocoa/qnsview.mm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 93d566da3b..b9ad35600e 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -713,6 +713,7 @@ void QCocoaWindow::setNSWindow(NSWindow *window) void QCocoaWindow::clearNSWindow(NSWindow *window) { + [window setContentView:nil]; [window setDelegate:nil]; [window clearPlatformWindow]; [[NSNotificationCenter defaultCenter] removeObserver:m_contentView]; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a953b25d84..f4ba8154ca 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -89,6 +89,14 @@ static QTouchDevice *touchDevice = 0; return self; } +- (void)dealloc +{ + CGImageRelease(m_cgImage); + m_cgImage = 0; + m_window = 0; + [super dealloc]; +} + - (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow { self = [self init]; From a98b9435579f5abef82036e81af4488d8a464b66 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 16 Oct 2012 16:35:34 +0200 Subject: [PATCH 056/114] Styles: revise indeterminate progress bar animations Remove dependencies to QProgressBar where possible. This makes it possible to animate for example QQuickItem based progress bars (read: the desktop components). Change-Id: If208506702365895576238c24191b8d70b90841c Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qcleanlooksstyle.cpp | 9 ++-- src/widgets/styles/qcommonstyle.cpp | 12 ++--- src/widgets/styles/qcommonstyle_p.h | 8 ++- src/widgets/styles/qgtkstyle.cpp | 8 +-- src/widgets/styles/qmacstyle_mac.mm | 66 ++++++++--------------- src/widgets/styles/qmacstyle_mac_p.h | 6 +-- src/widgets/styles/qplastiquestyle.cpp | 42 +++------------ src/widgets/styles/qstyleanimation.cpp | 20 ++----- src/widgets/styles/qstyleanimation_p.h | 4 -- src/widgets/styles/qstylesheetstyle.cpp | 21 +++----- src/widgets/styles/qwindowsstyle.cpp | 62 +++------------------ src/widgets/styles/qwindowsstyle_p.h | 3 -- src/widgets/styles/qwindowsvistastyle.cpp | 22 ++++---- 13 files changed, 76 insertions(+), 207 deletions(-) diff --git a/src/widgets/styles/qcleanlooksstyle.cpp b/src/widgets/styles/qcleanlooksstyle.cpp index 896f2ead32..5b8b5e0b9f 100644 --- a/src/widgets/styles/qcleanlooksstyle.cpp +++ b/src/widgets/styles/qcleanlooksstyle.cpp @@ -1751,20 +1751,21 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o reverse = !reverse; QRect progressBar; + Q_D(const QCleanlooksStyle); if (!indeterminate) { if (!reverse) { progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3); } else { progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3); } + d->stopAnimation(option->styleObject); } else { - Q_D(const QCleanlooksStyle); int slideWidth = ((rect.width() - 4) * 2) / 3; int step = 0; -#ifndef QT_NO_ANIMATION - if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(option->styleObject))) step = animation->progressStep(slideWidth); -#endif + else + d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject)); progressBar.setRect(rect.left() + 1 + step, rect.top() + 1, slideWidth / 2, rect.height() - 3); } diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index d4e4ea22d0..dd75870437 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1062,22 +1062,19 @@ QStyleAnimation * QCommonStylePrivate::animation(const QObject *target) const } /*! \internal */ -void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) +void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) const { -#ifndef QT_NO_ANIMATION - Q_Q(QCommonStyle); + Q_Q(const QCommonStyle); stopAnimation(animation->target()); q->connect(animation, SIGNAL(finished()), SLOT(_q_removeAnimation()), Qt::UniqueConnection); q->connect(animation, SIGNAL(destroyed()), SLOT(_q_removeAnimation()), Qt::UniqueConnection); animations.insert(animation->target(), animation); animation->start(); -#endif // QT_NO_ANIMATION } /*! \internal */ -void QCommonStylePrivate::stopAnimation(const QObject *target) +void QCommonStylePrivate::stopAnimation(const QObject *target) const { -#ifndef QT_NO_ANIMATION QStyleAnimation *animation = animations.value(target); if (animation) { if (animation->state() == QAbstractAnimation::Stopped) @@ -1085,20 +1082,17 @@ void QCommonStylePrivate::stopAnimation(const QObject *target) else animation->stop(); } -#endif // QT_NO_ANIMATION } /*! \internal */ void QCommonStylePrivate::_q_removeAnimation() { -#ifndef QT_NO_ANIMATION Q_Q(QCommonStyle); QObject *animation = q->sender(); if (animation) { animations.remove(animation->parent()); animation->deleteLater(); } -#endif // QT_NO_ANIMATION } /*! diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h index 2032e06e31..8f22dc7b79 100644 --- a/src/widgets/styles/qcommonstyle_p.h +++ b/src/widgets/styles/qcommonstyle_p.h @@ -77,9 +77,7 @@ public: ~QCommonStylePrivate() { -#ifndef QT_NO_ANIMATION qDeleteAll(animations); -#endif #ifndef QT_NO_ITEMVIEWS delete cachedOption; #endif @@ -120,11 +118,11 @@ public: QList animationTargets() const; QStyleAnimation* animation(const QObject *target) const; - void startAnimation(QStyleAnimation *animation); - void stopAnimation(const QObject *target); + void startAnimation(QStyleAnimation *animation) const; + void stopAnimation(const QObject *target) const; private: - QHash animations; + mutable QHash animations; }; QT_END_NAMESPACE diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp index 83e70d022b..2c8bc4c188 100644 --- a/src/widgets/styles/qgtkstyle.cpp +++ b/src/widgets/styles/qgtkstyle.cpp @@ -3488,15 +3488,15 @@ void QGtkStyle::drawControl(ControlElement element, progressBar.setRect(rect.left(), rect.top(), width, rect.height()); else progressBar.setRect(rect.right() - width, rect.top(), width, rect.height()); - + d->stopAnimation(option->styleObject); } else { Q_D(const QGtkStyle); int slideWidth = ((rect.width() - 4) * 2) / 3; int step = 0; -#ifndef QT_NO_ANIMATION - if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(option->styleObject))) step = animation->progressStep(slideWidth); -#endif + else + d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject)); progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height()); } diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 20791d6625..54b15e39a6 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1683,15 +1683,15 @@ QMacStylePrivate::QMacStylePrivate() } -bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QWidget *w) const +bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QObject *obj) const { - if (!w) + if (!obj) return false; if (as == AquaPushButton) { - QPushButton *pb = const_cast(static_cast(w)); - if (w->window()->isActiveWindow() && pb && !mouseDown) { - if (static_cast(w) != defaultButton) { + QPushButton *pb = const_cast(qobject_cast(obj)); + if (pb && pb->window()->isActiveWindow() && !mouseDown) { + if (pb != defaultButton) { // Changed on its own, update the value. const_cast(this)->stopAnimate(as, defaultButton); const_cast(this)->startAnimate(as, pb); @@ -1699,35 +1699,28 @@ bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QWidget * return true; } } - return animation(w); + return animation(obj); } -void QMacStylePrivate::stopAnimate(QMacStylePrivate::Animates as, QWidget *w) +void QMacStylePrivate::stopAnimate(QMacStylePrivate::Animates as, QObject *obj) { - stopAnimation(w); + stopAnimation(obj); if (as == AquaPushButton && defaultButton) { stopAnimation(defaultButton); QPushButton *tmp = defaultButton; defaultButton = 0; tmp->update(); } else if (as == AquaScrollBar) { - scrollBarInfos.remove(w); + scrollBarInfos.remove(qobject_cast(obj)); } } -void QMacStylePrivate::startAnimate(QMacStylePrivate::Animates as, QWidget *w) +void QMacStylePrivate::startAnimate(QMacStylePrivate::Animates as, QObject *obj) { -#ifndef QT_NO_ANIMATION - if (!animation(w)) - { - if (as == AquaProgressBar) - startAnimation(new QProgressStyleAnimation(animateSpeed(as), w)); - else - startAnimation(new QStyleAnimation(w)); - } -#endif + if (!animation(obj)) + startAnimation(new QStyleAnimation(obj)); if (as == AquaPushButton) - defaultButton = static_cast(w); + defaultButton = qobject_cast(obj); } bool QMacStylePrivate::addWidget(QWidget *w) @@ -1743,12 +1736,6 @@ bool QMacStylePrivate::addWidget(QWidget *w) startAnimate(AquaPushButton, btn); return true; } else { - bool isProgressBar = (qobject_cast(w)); - if (isProgressBar) { - w->installEventFilter(q); - startAnimate(AquaProgressBar, w); - return true; - } bool isScrollBar = (qobject_cast(w)); if (isScrollBar) { w->installEventFilter(q); @@ -1768,8 +1755,6 @@ void QMacStylePrivate::removeWidget(QWidget *w) QPushButton *btn = qobject_cast(w); if (btn && btn == defaultButton) { stopAnimate(AquaPushButton, btn); - } else if (qobject_cast(w)) { - stopAnimate(AquaProgressBar, w); } else if (qobject_cast(w)) { stopAnimate(AquaScrollBar, w); } @@ -1797,19 +1782,8 @@ bool QMacStyle::eventFilter(QObject *o, QEvent *e) { //animate Q_D(QMacStyle); - if (QProgressBar *pb = qobject_cast(o)) { - switch (e->type()) { - default: - break; - case QEvent::Show: - d->startAnimate(QMacStylePrivate::AquaProgressBar, pb); - break; - case QEvent::Destroy: - case QEvent::Hide: - d->stopAnimate(QMacStylePrivate::AquaProgressBar, pb); - } + if (QScrollBar *sb = qobject_cast(o)) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - } else if (QScrollBar *sb = qobject_cast(o)) { // take care of fading out overlaying scrollbars (and only those!) when inactive const QAbstractScrollArea *scrollArea = scrollBarsScrollArea(sb); if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 && @@ -4377,10 +4351,14 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter tdi.min = pb->minimum; tdi.value = pb->progress; tdi.attributes = vertical ? 0 : kThemeTrackHorizontal; -#ifndef QT_NO_ANIMATION - if (QProgressStyleAnimation *animation = qobject_cast(d->animation(w))) - tdi.trackInfo.progress.phase = animation->animationStep(); -#endif + if (isIndeterminate) { + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(opt->styleObject))) + tdi.trackInfo.progress.phase = animation->animationStep(); + else + d->startAnimation(new QProgressStyleAnimation(d->animateSpeed(QMacStylePrivate::AquaProgressBar), opt->styleObject)); + } else { + d->stopAnimation(opt->styleObject); + } if (!(pb->state & State_Active)) tdi.enableState = kThemeTrackInactive; else if (!(pb->state & State_Enabled)) diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h index 63cc005033..812c79e158 100644 --- a/src/widgets/styles/qmacstyle_mac_p.h +++ b/src/widgets/styles/qmacstyle_mac_p.h @@ -163,9 +163,9 @@ public: void removeWidget(QWidget *); enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar }; - bool animatable(Animates, const QWidget *) const; - void stopAnimate(Animates, QWidget *); - void startAnimate(Animates, QWidget *); + bool animatable(Animates, const QObject *) const; + void stopAnimate(Animates, QObject *); + void startAnimate(Animates, QObject *); static ThemeDrawState getDrawState(QStyle::State flags); QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct = QStyle::CT_CustomBase, diff --git a/src/widgets/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp index fe1e5c3dc3..449783fb90 100644 --- a/src/widgets/styles/qplastiquestyle.cpp +++ b/src/widgets/styles/qplastiquestyle.cpp @@ -2396,7 +2396,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } break; #endif // QT_NO_TABBAR -#ifndef QT_NO_PROGRESSBAR + case CE_ProgressBarGroove: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { QRect rect = bar->rect; @@ -2566,13 +2566,14 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } else { progressBar.setRect(rect.right() - 1 - width, rect.top() + 2, width, rect.height() - 4); } + d->stopAnimation(option->styleObject); } else { int slideWidth = ((rect.width() - 4) * 2) / 3; int step = 0; -#ifndef QT_NO_ANIMATION - if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(option->styleObject))) step = animation->progressStep(slideWidth); -#endif + else + d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject)); progressBar.setRect(rect.left() + 2 + step, rect.top() + 2, slideWidth / 2, rect.height() - 4); } @@ -2727,10 +2728,8 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op if (!indeterminate) { int step = 0; if (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) { -#ifndef QT_NO_ANIMATION if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) step = animation->animationStep() % 20; -#endif } if (reverse) painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache); @@ -2743,7 +2742,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op painter->restore(); } break; -#endif // QT_NO_PROGRESSBAR + case CE_HeaderSection: // Draws the header in tables. if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { @@ -4956,12 +4955,10 @@ QRect QPlastiqueStyle::subElementRect(SubElement element, const QStyleOption *op rect = visualRect(option->direction, option->rect, QWindowsStyle::subElementRect(element, option, widget)).adjusted(0, 0, 1, 1); break; -#ifndef QT_NO_PROGRESSBAR case SE_ProgressBarLabel: case SE_ProgressBarContents: case SE_ProgressBarGroove: return option->rect; -#endif // QT_NO_PROGRESSBAR default: return QWindowsStyle::subElementRect(element, option, widget); } @@ -5647,11 +5644,6 @@ void QPlastiqueStyle::polish(QWidget *widget) widget->setBackgroundRole(QPalette::Window); } -#ifndef QT_NO_PROGRESSBAR - if (AnimateBusyProgressBar && qobject_cast(widget)) - widget->installEventFilter(this); -#endif - #if defined QPlastique_MaskButtons if (qobject_cast(widget) || qobject_cast(widget)) widget->installEventFilter(this); @@ -5704,11 +5696,6 @@ void QPlastiqueStyle::unpolish(QWidget *widget) widget->setBackgroundRole(QPalette::Button); } -#ifndef QT_NO_PROGRESSBAR - if (AnimateBusyProgressBar && qobject_cast(widget)) - widget->removeEventFilter(this); -#endif - #if defined QPlastique_MaskButtons if (qobject_cast(widget) || qobject_cast(widget)) widget->removeEventFilter(this); @@ -5825,20 +5812,8 @@ int QPlastiqueStyle::layoutSpacing(QSizePolicy::ControlType control1, */ bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event) { -#ifndef QT_NO_PROGRESSBAR - Q_D(QPlastiqueStyle); - - switch (event->type()) { - case QEvent::Show: - if (QProgressBar *bar = qobject_cast(watched)) - d->startProgressAnimation(this, bar); - break; - case QEvent::Destroy: - case QEvent::Hide: - if (QProgressBar *bar = qobject_cast(watched)) - d->stopProgressAnimation(this, bar); - break; #if defined QPlastique_MaskButtons + switch (event->type()) { case QEvent::Resize: if (qobject_cast(watched) || qobject_cast(watched)) { QWidget *widget = qobject_cast(watched); @@ -5855,11 +5830,10 @@ bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event) widget->setMask(region); } break; -#endif default: break; } -#endif // QT_NO_PROGRESSBAR +#endif return QWindowsStyle::eventFilter(watched, event); } diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 8bc8e9d241..297a929970 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ANIMATION - QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target), _startTime(QTime::currentTime()) { @@ -128,21 +126,13 @@ void QProgressStyleAnimation::setSpeed(int speed) bool QProgressStyleAnimation::isUpdateNeeded() const { - QProgressBar *pb = qobject_cast(parent()); - if (pb && pb->minimum() == 0 && pb->maximum() == 0) { - int current = animationStep(); - if (_step == -1 || _step != current) - { - _step = current; - return true; - } - } else { - // the progress bar is no longer indeterminate -> stop - const_cast(this)->stop(); + int current = animationStep(); + if (_step == -1 || _step != current) + { + _step = current; + return true; } return false; } -#endif // QT_NO_ANIMATION - QT_END_NAMESPACE diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h index 2c00048b7d..8231abbb40 100644 --- a/src/widgets/styles/qstyleanimation_p.h +++ b/src/widgets/styles/qstyleanimation_p.h @@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE // We mean it. // -#ifndef QT_NO_ANIMATION - class QStyleAnimation : public QAbstractAnimation { Q_OBJECT @@ -103,8 +101,6 @@ private: mutable int _step; }; -#endif // QT_NO_ANIMATION - QT_END_NAMESPACE #endif // QSTYLEANIMATION_P_H diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 068b7a4355..d73d25a1af 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -2726,12 +2725,6 @@ void QStyleSheetStyle::polish(QWidget *w) } #endif -#ifndef QT_NO_PROGRESSBAR - if (QProgressBar *pb = qobject_cast(w)) { - QWindowsStyle::polish(pb); - } -#endif - QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any); if (rule.hasDrawable() || rule.hasBox()) { if (w->metaObject() == &QWidget::staticMetaObject @@ -2825,10 +2818,6 @@ void QStyleSheetStyle::unpolish(QWidget *w) QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)), sa, SLOT(update())); } -#endif -#ifndef QT_NO_PROGRESSBAR - if (QProgressBar *pb = qobject_cast(w)) - QWindowsStyle::unpolish(pb); #endif baseStyle()->unpolish(w); } @@ -3830,14 +3819,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q } QRect r = rect; + Q_D(const QWindowsStyle); if (pb->minimum == 0 && pb->maximum == 0) { - Q_D(const QWindowsStyle); int chunkCount = fillWidth/chunkWidth; int offset = 0; -#ifndef QT_NO_ANIMATION - if (QProgressStyleAnimation *animation = qobject_cast(d->animation(w))) + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(opt->styleObject))) offset = animation->animationStep() * 8 % rect.width(); -#endif + else + d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject)); int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset; while (chunkCount > 0) { r.setRect(x, rect.y(), chunkWidth, rect.height()); @@ -3868,6 +3857,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.drawRule(p, r); x += reverse ? -chunkWidth : chunkWidth; } + + d->stopAnimation(opt->styleObject); } p->restore(); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 714898e809..eb39790e36 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -54,7 +54,6 @@ #include #include "qpaintengine.h" #include "qpainter.h" -#include "qprogressbar.h" #include "qrubberband.h" #include "qstyleoption.h" #include "qtabbar.h" @@ -131,21 +130,6 @@ QWindowsStylePrivate::QWindowsStylePrivate() #endif } -void QWindowsStylePrivate::startProgressAnimation(QObject *o, QProgressBar *bar) -{ - Q_UNUSED(o); -#ifndef QT_NO_ANIMATION - if (!animation(bar)) - startAnimation(new QProgressStyleAnimation(animationFps, bar)); -#endif -} - -void QWindowsStylePrivate::stopProgressAnimation(QObject *o, QProgressBar *bar) -{ - Q_UNUSED(o); - stopAnimation(bar); -} - // Returns true if the toplevel parent of \a widget has seen the Alt-key bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const { @@ -204,27 +188,6 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) d->seenAlt.removeAll(widget); d->seenAlt.removeAll(widget->window()); break; -#ifndef QT_NO_PROGRESSBAR - case QEvent::StyleChange: - case QEvent::Paint: - case QEvent::Show: - if (QProgressBar *bar = qobject_cast(o)) { - // Animation by timer for progress bars that have their min and - // max values the same - if (bar->minimum() == bar->maximum()) - d->startProgressAnimation(this, bar); - else - d->stopProgressAnimation(this, bar); - } - break; - case QEvent::Destroy: - case QEvent::Hide: - // Do static_cast because there is no type info when getting - // the destroy event. We know that it is a QProgressBar, since - // we only install a widget event filter for QScrollBars. - d->stopProgressAnimation(this, static_cast(o)); - break; -#endif // QT_NO_PROGRESSBAR default: break; } @@ -315,23 +278,12 @@ void QWindowsStyle::unpolish(QApplication *app) void QWindowsStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); -#ifndef QT_NO_PROGRESSBAR - if (qobject_cast(widget)) - widget->installEventFilter(this); -#endif } /*! \reimp */ void QWindowsStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); -#ifndef QT_NO_PROGRESSBAR - if (QProgressBar *bar=qobject_cast(widget)) { - Q_D(QWindowsStyle); - widget->removeEventFilter(this); - d->stopProgressAnimation(this, bar); - } -#endif } /*! @@ -1582,7 +1534,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0); break; -#ifndef QT_NO_PROGRESSBAR case PE_IndicatorProgressChunk: { bool vertical = false, inverted = false; @@ -1616,7 +1567,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } } break; -#endif // QT_NO_PROGRESSBAR case PE_FrameTabWidget: { qDrawWinButton(p, opt->rect, opt->palette, false, 0); @@ -2232,7 +2182,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai #endif // QT_NO_TOOLBAR -#ifndef QT_NO_PROGRESSBAR + case CE_ProgressBarContents: if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { QRect rect = pb->rect; @@ -2263,8 +2213,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai if (inverted) reverse = !reverse; int w = rect.width(); + Q_D(const QWindowsStyle); if (pb->minimum == 0 && pb->maximum == 0) { - Q_D(const QWindowsStyle); const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget); QStyleOptionProgressBarV2 pbBits = *pb; Q_ASSERT(unit_width >0); @@ -2274,10 +2224,10 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai int step = 0; int chunkCount = w / unit_width + 1; -#ifndef QT_NO_ANIMATION - if (QProgressStyleAnimation *animation = qobject_cast(d->animation(widget))) + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(opt->styleObject))) step = (animation->animationStep() / 3) % chunkCount; -#endif + else + d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject)); int chunksInRow = 5; int myY = pbBits.rect.y(); int myHeight = pbBits.rect.height(); @@ -2311,11 +2261,11 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->restore(); //restore state } else { + d->stopAnimation(opt->styleObject); QCommonStyle::drawControl(ce, opt, p, widget); } } break; -#endif // QT_NO_PROGRESSBAR #ifndef QT_NO_DOCKWIDGET case CE_DockWidgetTitle: diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h index f24696f0bd..6d69557edd 100644 --- a/src/widgets/styles/qwindowsstyle_p.h +++ b/src/widgets/styles/qwindowsstyle_p.h @@ -63,15 +63,12 @@ QT_BEGIN_NAMESPACE class QTime; -class QProgressBar; class QWindowsStylePrivate : public QCommonStylePrivate { Q_DECLARE_PUBLIC(QWindowsStyle) public: QWindowsStylePrivate(); - void startProgressAnimation(QObject *o, QProgressBar *bar); - void stopProgressAnimation(QObject *o, QProgressBar *bar); bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } bool alt_down; diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index d1a0af3a91..d8bf6920ac 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1089,7 +1089,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption return; } break; -#ifndef QT_NO_PROGRESSBAR + case CE_ProgressBarContents: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { @@ -1101,11 +1101,11 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption inverted = pb2->invertedAppearance; } - if (const QProgressBar *progressbar = qobject_cast(widget)) { - if (isIndeterminate || (progressbar->value() > 0 && (progressbar->value() < progressbar->maximum()) && d->transitionsEnabled())) - d->startProgressAnimation(0, const_cast(progressbar)); - else - d->stopAnimation(progressbar); + if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) && d->transitionsEnabled())) { + if (!d->animation(option->styleObject)) + d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject)); + } else { + d->stopAnimation(option->styleObject); } XPThemeData theme(widget, painter, @@ -1116,7 +1116,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QTime current = QTime::currentTime(); if (isIndeterminate) { - if (QProgressStyleAnimation *a = qobject_cast(d->animation(widget))) { + if (QProgressStyleAnimation *a = qobject_cast(d->animation(option->styleObject))) { int glowSize = 120; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1186,7 +1186,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } d->drawBackground(theme); - if (QProgressStyleAnimation *a = qobject_cast(d->animation(widget))) { + if (QProgressStyleAnimation *a = qobject_cast(d->animation(option->styleObject))) { int glowSize = 140; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1195,8 +1195,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (bar->progress < bar->maximum) a->setStartTime(QTime::currentTime()); else - d->stopAnimation(widget); //we stop the glow motion only after it has - //moved out of view + d->stopAnimation(option->styleObject); //we stop the glow motion only after it has + //moved out of view } painter->save(); painter->setClipRect(theme.rect); @@ -1215,7 +1215,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } } break; -#endif // QT_NO_PROGRESSBAR + case CE_MenuBarItem: { From 9d86458d8c0f823beff25eb676469bdc686cd285 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 16 Oct 2012 17:39:52 +0200 Subject: [PATCH 057/114] Fix potential crash in QStyleAnimation::updateCurrentTime() A parentless/targetless QStyleAnimation calls updateCurrentTime() from QAbstractAnimation constructor. Avoid the potential crash even if it's not a valid use case for QStyleAnimation. Change-Id: I9cd263d105c8ea4b5cbabac9a7680991745ccd95 Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qstyleanimation.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 297a929970..6173dc9ddb 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -83,15 +83,17 @@ bool QStyleAnimation::isUpdateNeeded() const void QStyleAnimation::updateCurrentTime(int) { - if (target()->isWidgetType()) { - QWidget *widget = static_cast(target()); - if (!widget->isVisible() || widget->window()->isMinimized()) - stop(); - } + if (QObject *tgt = target()) { + if (tgt->isWidgetType()) { + QWidget *widget = static_cast(tgt); + if (!widget->isVisible() || widget->window()->isMinimized()) + stop(); + } - if (isUpdateNeeded()) { - QEvent event(QEvent::StyleAnimationUpdate); - QCoreApplication::sendEvent(target(), &event); + if (isUpdateNeeded()) { + QEvent event(QEvent::StyleAnimationUpdate); + QCoreApplication::sendEvent(tgt, &event); + } } } From a0280e5cac5b4f268c20e89a1c2d0364c323a7cf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Oct 2012 13:48:07 -0700 Subject: [PATCH 058/114] Add qlibraryinfo.h to global.pri's HEADERS list The file was already present but wasn't mentioned. Change-Id: Icac4fd5276b071ed2173e72aed51abb4c0b5b50a Reviewed-by: Oswald Buddenhagen --- src/corelib/global/global.pri | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 05a2461f1b..01756c8419 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -9,6 +9,7 @@ HEADERS += \ global/qendian.h \ global/qnumeric_p.h \ global/qnumeric.h \ + global/qlibraryinfo.h \ global/qlogging.h \ global/qtypeinfo.h \ global/qsysinfo.h \ From 048b697c0723db563ab20d82b615c55fd16f79c5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Oct 2012 17:20:33 -0700 Subject: [PATCH 059/114] There's no uic3 anymore Change-Id: Iacbe2e6a802278c2c82ae60551eae5bc2636e6f5 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/uic.prf | 76 ---------------------------------------- 1 file changed, 76 deletions(-) diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index 9cb0773b8d..a98c62676c 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -1,4 +1,3 @@ -qtPrepareTool(QMAKE_UIC3, uic3) qtPrepareTool(QMAKE_UIC, uic) isEmpty(UI_DIR):UI_DIR = . @@ -32,78 +31,3 @@ isEmpty(QMAKE_MOD_UIC):QMAKE_MOD_UIC = ui_ contains(ui_dir_short, ^[/\\\\].*):INCLUDEPATH += $$UI_HEADERS_DIR else:INCLUDEPATH += $$OUT_PWD/$$UI_HEADERS_DIR } - -uic3 { - isEmpty(FORMS3) { - UIC3_FORMS = FORMS - !build_pass:message("Project contains CONFIG+=uic3, but no files in FORMS3; UI files in FORMS treated as UIC3 form files.") - } else { - UIC3_FORMS = FORMS3 - } - - uic3_decl.commands = $$QMAKE_UIC3 ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} - uic3_decl.dependency_type = TYPE_UI - uic3_decl.output = $$UI_HEADERS_DIR/${QMAKE_FILE_BASE}$${first(QMAKE_EXT_H)} - uic3_decl.input = $$UIC3_FORMS - uic3_decl.CONFIG += no_link - uic3_decl.variable_out = GENERATED_FILES UIC3_HEADERS - uic3_decl.name = UIC3 Decl ${QMAKE_FILE_IN} - silent:uic3_decl.commands = @echo uic3 ${QMAKE_FILE_IN} && $$uic3_decl.commands - QMAKE_EXTRA_COMPILERS += uic3_decl - - uic3_impl.commands = $$QMAKE_UIC3 -impl ${QMAKE_FILE_BASE}$${first(QMAKE_EXT_H)} ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} - uic3_impl.dependency_type = TYPE_UI - uic3_impl.output = $$UI_SOURCES_DIR/${QMAKE_FILE_BASE}$${first(QMAKE_EXT_CPP)} - uic3_impl.depends = $$UI_HEADERS_DIR/${QMAKE_FILE_BASE}$${first(QMAKE_EXT_H)} - uic3_impl.input = $$UIC3_FORMS - uic3_impl.variable_out = GENERATED_SOURCES - uic3_impl.name = UIC3 Impl ${QMAKE_FILE_IN} - silent:uic3_impl.commands = @echo uic3 -impl ${QMAKE_FILE_IN} && $$uic3_impl.commands - QMAKE_EXTRA_COMPILERS += uic3_impl - - ### add a moc step - load(moc) - uic3_moc.commands = $$moc_header.commands - uic3_moc.output = $$moc_header.output - uic3_moc.depends = $$UI_HEADERS_DIR/${QMAKE_FILE_BASE}$${first(QMAKE_EXT_H)} - uic3_moc.input = UIC3_HEADERS - uic3_moc.variable_out = GENERATED_SOURCES - uic3_moc.name = $$moc_header.name - !contains(TEMPLATE, "vc.*"):!isEmpty(INCLUDETEMP):uic3_moc.depends += $$INCLUDETEMP - QMAKE_EXTRA_COMPILERS += uic3_moc -} - -defineReplace(imageCollectionCmd) { - unset(EMBEDDED_IMAGES) - RET = - for(image, $$list($$split(1))) { - EMBEDDED_IMAGES += $$image - count(EMBEDDED_IMAGES, 5) { - isEmpty(RET): RET += echo $$EMBEDDED_IMAGES > $${UI_DIR}/images.tmp $$escape_expand(\\n\\t) - else: RET += echo $$EMBEDDED_IMAGES >> $${UI_DIR}/images.tmp $$escape_expand(\\n\\t) - unset(EMBEDDED_IMAGES) - } - } - !isEmpty(EMBEDDED_IMAGES):RET += echo $$EMBEDDED_IMAGES >> $${UI_DIR}/images.tmp $$escape_expand(\\n\\t) - !isEmpty(RET) { - RET += $$QMAKE_UIC3 -embed $$TARGET -f $${UI_DIR}/images.tmp -o $$2 $$escape_expand(\\n\\t) - return($$RET) - } - return($$QMAKE_UIC3 -embed $$TARGET $$1 -o $$2) -} - -image_collection.output = $${UI_DIR}/qmake_image_collection$${first(QMAKE_EXT_CPP)} -image_collection.variable_out = SOURCES -image_collection.input = IMAGES -image_collection.CONFIG += combine -image_collection.name = UIC3 Image collection in ${QMAKE_FILE_OUT} -!win32 { - image_collection.commands = $$QMAKE_UIC3 -embed $$TARGET ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} - silent:image_collection.commands = @echo uic3 -embed ${QMAKE_FILE_IN} && $$image_collection.commands -} else { - image_collection.commands = ${QMAKE_FUNC_imageCollectionCmd} - silent:image_collection.commands = @echo uic3 -embed $$TARGET -f $${UI_DIR}/images.tmp && $image_collection.commands -} -QMAKE_EXTRA_COMPILERS += image_collection - - From c5ec39b6cc00d5a923e32e4858c944cda958b870 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Wed, 17 Oct 2012 10:02:57 +0200 Subject: [PATCH 060/114] Test: remove QSKIP from tst_qtconcurrent Instead omit the whole tests when appropriate. Change-Id: I3a22d010b658e54d7d234b786173c62977a50c7d Reviewed-by: J-P Nurmi --- .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index f3f4be3f3f..acb4840ca8 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -60,8 +60,12 @@ private slots: #ifndef QT_NO_EXCEPTIONS void exceptions(); #endif +#ifdef Q_COMPILER_DECLTYPE void functor(); +#endif +#ifdef Q_COMPILER_LAMBDA void lambda(); +#endif }; void light() @@ -398,6 +402,8 @@ void tst_QtConcurrentRun::exceptions() } #endif +#ifdef Q_COMPILER_DECLTYPE +// Compiler supports decltype struct Functor { int operator()() { return 42; } double operator()(double a, double b) { return a/b; } @@ -412,9 +418,6 @@ struct Functor { // This tests functor without result_type; decltype need to be supported by the compiler. void tst_QtConcurrentRun::functor() { -#ifndef Q_COMPILER_DECLTYPE - QSKIP("Compiler does not support decltype"); -#else Functor f; { QFuture fut = QtConcurrent::run(f); @@ -435,14 +438,13 @@ void tst_QtConcurrentRun::functor() QtConcurrent::run(f, 1,2,3,4).waitForFinished(); QtConcurrent::run(f, 1,2,3,4,5).waitForFinished(); } -#endif } +#endif +#ifdef Q_COMPILER_LAMBDA +// Compiler supports lambda void tst_QtConcurrentRun::lambda() { -#ifndef Q_COMPILER_LAMBDA - QSKIP("Compiler does not support lambda"); -#else QCOMPARE(QtConcurrent::run([](){ return 45; }).result(), 45); QCOMPARE(QtConcurrent::run([](int a){ return a+15; }, 12).result(), 12+15); QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); @@ -456,8 +458,8 @@ void tst_QtConcurrentRun::lambda() QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); } #endif -#endif } +#endif QTEST_MAIN(tst_QtConcurrentRun) #include "tst_qtconcurrentrun.moc" From ceb5474d5f71e223373cc957af4a073886e326bd Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:07:21 +0200 Subject: [PATCH 061/114] Test: remove QSKIP in tst_QDBusMarshall::receiveUnknownType Omit the whole test and relative types if DBUS_TYPE_UNIX_FD is not defined since the test is not relevant in that case (D-Bus library too old). Change-Id: I167622f485c0f34d64984c4fa96be974e54f56bc Reviewed-by: J-P Nurmi --- tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index cdee3a7505..6274e0e0fa 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -90,8 +90,10 @@ private slots: void sendCallErrors_data(); void sendCallErrors(); +#ifdef DBUS_TYPE_UNIX_FD void receiveUnknownType_data(); void receiveUnknownType(); +#endif void demarshallPrimitives_data(); void demarshallPrimitives(); @@ -1028,6 +1030,8 @@ void tst_QDBusMarshall::sendCallErrors() QCOMPARE(reply.errorMessage(), errorMsg); } +#ifdef DBUS_TYPE_UNIX_FD +// If DBUS_TYPE_UNIX_FD is not defined, it means the current system's D-Bus library is too old for this test void tst_QDBusMarshall::receiveUnknownType_data() { QTest::addColumn("receivedTypeId"); @@ -1078,9 +1082,6 @@ public: void tst_QDBusMarshall::receiveUnknownType() { -#ifndef DBUS_TYPE_UNIX_FD - QSKIP("Your system's D-Bus library is too old for this test"); -#else QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); @@ -1184,8 +1185,8 @@ void tst_QDBusMarshall::receiveUnknownType() //qDebug() << spy.list.at(0).arguments().at(0).typeName(); QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId); } -#endif } +#endif void tst_QDBusMarshall::demarshallPrimitives_data() { From 8a2d1ce2c67607abb7ca919da22307923fd3a924 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 16 Oct 2012 12:01:16 +0200 Subject: [PATCH 062/114] Test: remove QSKIP and remove whole test cases instead. Change-Id: I8b625d20a2cf9215cbfdb96cd252bf1c81bba522 Reviewed-by: J-P Nurmi --- .../kernel/qkeysequence/tst_qkeysequence.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 601847270e..f7930550cc 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -119,8 +119,10 @@ private slots: void symetricConstructors(); void checkMultipleNames(); void checkMultipleCodes(); +#ifndef Q_OS_MAC void mnemonic_data(); void mnemonic(); +#endif void toString_data(); void toString(); void toStringFromKeycode_data(); @@ -137,8 +139,10 @@ private slots: void standardKeys_data(); void standardKeys(); void keyBindings(); +#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) void translated_data(); void translated(); +#endif void i18nKeys_data(); void i18nKeys(); @@ -396,6 +400,7 @@ void tst_QKeySequence::keyBindings() QCOMPARE(bindings, expected); } +#ifndef Q_OS_MAC void tst_QKeySequence::mnemonic_data() { QTest::addColumn("string"); @@ -417,9 +422,6 @@ void tst_QKeySequence::mnemonic_data() void tst_QKeySequence::mnemonic() { -#ifdef Q_OS_MAC - QSKIP("mnemonics are not used on Mac OS X"); -#endif QFETCH(QString, string); QFETCH(QString, key); QFETCH(bool, warning); @@ -438,6 +440,7 @@ void tst_QKeySequence::mnemonic() QCOMPARE(seq, res); } +#endif void tst_QKeySequence::toString_data() { @@ -628,6 +631,7 @@ void tst_QKeySequence::fromString() QCOMPARE(ks4, ks1); } +#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) void tst_QKeySequence::translated_data() { qApp->installTranslator(ourTranslator); @@ -659,11 +663,6 @@ void tst_QKeySequence::translated() { QFETCH(QString, transKey); QFETCH(QString, compKey); -#ifdef Q_OS_MAC - QSKIP("No need to translate modifiers on Mac OS X"); -#elif defined(Q_OS_WINCE) - QSKIP("No need to translate modifiers on WinCE"); -#endif qApp->installTranslator(ourTranslator); qApp->installTranslator(qtTranslator); @@ -674,7 +673,7 @@ void tst_QKeySequence::translated() qApp->removeTranslator(ourTranslator); qApp->removeTranslator(qtTranslator); } - +#endif void tst_QKeySequence::i18nKeys_data() { From 743d963078a721046e58d31b3900e319ad55299c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 17 Oct 2012 15:22:58 +0200 Subject: [PATCH 063/114] Windows: QT_LIGHTHOUSE_WINDOWS_VERBOSE -> QT_QPA_VERBOSE. Change-Id: Ieffa1f483cddd220b158ccd570af151420c8e3c3 Reviewed-by: Miikka Heikkinen --- src/plugins/platforms/windows/main.cpp | 2 +- src/plugins/platforms/windows/qwindowscontext.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/main.cpp b/src/plugins/platforms/windows/main.cpp index d337234671..826d0df819 100644 --- a/src/plugins/platforms/windows/main.cpp +++ b/src/plugins/platforms/windows/main.cpp @@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE \section1 Tips \list - \li The environment variable \c QT_LIGHTHOUSE_WINDOWS_VERBOSE controls + \li The environment variable \c QT_QPA_VERBOSE controls the debug level. It takes the form \c{:,:}, where keyword is one of \c integration, \c windows, \c backingstore and diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 78cd104fbe..dcc636bfc0 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -118,7 +118,7 @@ public: SI_SupportsTouch = 0x2 }; - // Verbose flag set by environment variable QT_LIGHTHOUSE_WINDOWS_VERBOSE + // Verbose flag set by environment variable QT_QPA_VERBOSE static int verboseIntegration; static int verboseWindows; static int verboseBackingStore; From 4b7dd71aa05570dbf4e7819555c831bd6a79c2d5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 17 Oct 2012 16:18:59 +0200 Subject: [PATCH 064/114] Windows: Multisampling is disabled by default. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous code assumed that -1 indicated some sort of "auto", but this is not the case according to documentation. Task-number: QTBUG-27600 Change-Id: Id17ce32f94ded61a63a33d0c04ec5312f53c7923 Reviewed-by: Samuel Rødal --- src/plugins/platforms/windows/qwindowsglcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 1c9a7d36f5..a760ea06e9 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -439,7 +439,7 @@ static int choosePixelFormat(HDC hdc, iAttributes[i++] = WGL_SAMPLES_ARB; samplesValuePosition = i; iAttributes[i++] = format.samples(); - } else if (samples == 0 || samples == 1 ) { + } else { iAttributes[i++] = WGL_SAMPLE_BUFFERS_ARB; iAttributes[i++] = FALSE; } From 12d25f1a42d03c2d126d0fcf60622aa9b7dac6db Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Wed, 17 Oct 2012 23:47:20 +1100 Subject: [PATCH 065/114] Fix compilation with MinGW-w64 Change-Id: I0c9e6adc54ccce34e0f81af048f2a51a4ac051b4 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qtwindows_additional.h | 2 +- src/plugins/platforms/windows/qwindowstheme.cpp | 2 +- src/plugins/platforms/windows/qwindowswindow.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h index 3566367e41..a35a513579 100644 --- a/src/plugins/platforms/windows/qtwindows_additional.h +++ b/src/plugins/platforms/windows/qtwindows_additional.h @@ -83,7 +83,7 @@ #define CHILDID_SELF 0 #define WM_GETOBJECT 0x003D -#ifndef SIID_SHIELD // Shell structures for icons. +#ifndef SHGFI_ADDOVERLAYS // Shell structures for icons. typedef struct _SHSTOCKICONINFO { DWORD cbSize; diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 748ba09a90..d9de911914 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -587,7 +587,7 @@ public: T operator * () const { - return reinterpret_cast(this); + return T(qintptr(this)); } void operator delete (void *) {} diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index fc3566660a..99b8922768 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -708,8 +708,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : #ifdef Q_OS_WINCE m_previouslyHidden(false), #endif - m_iconBig(0), - m_iconSmall(0) + m_iconSmall(0), + m_iconBig(0) { if (aWindow->surfaceType() == QWindow::OpenGLSurface) setFlag(OpenGLSurface); From 9410b307afc2fec43a5f05ef3761d619f50e4d20 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 17 Oct 2012 09:48:10 +0200 Subject: [PATCH 066/114] Improve branch indicators in common style The branch indicators in common style was painted based on motif style, effectively making it useless. Since most styles inherit from Windows style, I moved that into common style. It was already duplicating most of the code used in commonstyle. Change-Id: I1a383d90254bb97aebc038fa058ec0f225cf9dab Reviewed-by: Jens Bache-Wiig Reviewed-by: J-P Nurmi Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qcommonstyle.cpp | 23 +++++++------- src/widgets/styles/qcommonstylepixmaps_p.h | 27 ----------------- src/widgets/styles/qwindowsstyle.cpp | 35 ---------------------- 3 files changed, 13 insertions(+), 72 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index dd75870437..e6e2e75c4e 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -277,35 +277,38 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q break; #endif // QT_NO_PROGRESSBAR case PE_IndicatorBranch: { + static const int decoration_size = 9; int mid_h = opt->rect.x() + opt->rect.width() / 2; int mid_v = opt->rect.y() + opt->rect.height() / 2; int bef_h = mid_h; int bef_v = mid_v; int aft_h = mid_h; int aft_v = mid_v; -#ifndef QT_NO_IMAGEFORMAT_XPM - static const int decoration_size = 9; - static QPixmap open(tree_branch_open_xpm); - static QPixmap closed(tree_branch_closed_xpm); if (opt->state & State_Children) { int delta = decoration_size / 2; bef_h -= delta; bef_v -= delta; aft_h += delta; aft_v += delta; - p->drawPixmap(bef_h, bef_v, opt->state & State_Open ? open : closed); + p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4); + if (!(opt->state & State_Open)) + p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6); + QPen oldPen = p->pen(); + p->setPen(opt->palette.dark().color()); + p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1); + p->setPen(oldPen); } -#endif // QT_NO_IMAGEFORMAT_XPM + QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern); if (opt->state & State_Item) { if (opt->direction == Qt::RightToLeft) - p->drawLine(opt->rect.left(), mid_v, bef_h, mid_v); + p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush); else - p->drawLine(aft_h, mid_v, opt->rect.right(), mid_v); + p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush); } if (opt->state & State_Sibling) - p->drawLine(mid_h, aft_v, mid_h, opt->rect.bottom()); + p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush); if (opt->state & (State_Open | State_Children | State_Item | State_Sibling)) - p->drawLine(mid_h, opt->rect.y(), mid_h, bef_v); + p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush); break; } case PE_FrameStatusBarItem: qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0); diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h index 4dcbe86ada..5e63302f35 100644 --- a/src/widgets/styles/qcommonstylepixmaps_p.h +++ b/src/widgets/styles/qcommonstylepixmaps_p.h @@ -75,33 +75,6 @@ static const char * const check_list_controller_xpm[] = { " ", " "}; -static const char * const tree_branch_open_xpm[] = { -"9 9 2 1", -" c None", -"# c #000000", -"#########", -"# #", -"# ##### #", -"# ### #", -"# ### #", -"# # #", -"# # #", -"# #", -"#########"}; - -static const char * const tree_branch_closed_xpm[] = { -"9 9 2 1", -" c None", -"# c #000000", -"#########", -"# #", -"# # #", -"# ### #", -"# ##### #", -"# ### #", -"# # #", -"# #", -"#########"}; static const char * const tb_extension_arrow_v_xpm[] = { "5 8 3 1", diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index eb39790e36..4df68a76ad 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1459,41 +1459,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } break; #endif // QT_NO_FRAME - case PE_IndicatorBranch: { - // This is _way_ too similar to the common style. - static const int decoration_size = 9; - int mid_h = opt->rect.x() + opt->rect.width() / 2; - int mid_v = opt->rect.y() + opt->rect.height() / 2; - int bef_h = mid_h; - int bef_v = mid_v; - int aft_h = mid_h; - int aft_v = mid_v; - if (opt->state & State_Children) { - int delta = decoration_size / 2; - bef_h -= delta; - bef_v -= delta; - aft_h += delta; - aft_v += delta; - p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4); - if (!(opt->state & State_Open)) - p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6); - QPen oldPen = p->pen(); - p->setPen(opt->palette.dark().color()); - p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1); - p->setPen(oldPen); - } - QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern); - if (opt->state & State_Item) { - if (opt->direction == Qt::RightToLeft) - p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush); - else - p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush); - } - if (opt->state & State_Sibling) - p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush); - if (opt->state & (State_Open | State_Children | State_Item | State_Sibling)) - p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush); - break; } case PE_FrameButtonBevel: case PE_PanelButtonBevel: { QBrush fill; From 8003fd6d5b12d51bfeb4fd5cd1f5c1b303c19df6 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 17 Oct 2012 18:53:01 +0200 Subject: [PATCH 067/114] Mac: Fix QLineEdit shadow The cursor is still rendered 1px too low, but probably needs to be fixed in QTextLayout. Change-Id: Ie56c7140898b941c8d896f503ce1934d0d681a4d Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qmacstyle_mac.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 54b15e39a6..3110973740 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2280,9 +2280,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW // The combo box popup has no frame. if (qstyleoption_cast(opt) != 0) ret = 0; - // Frame of mac style line edits is two pixels on top and one on the bottom - else if (qobject_cast(widget) != 0) - ret = 2; else ret = 1; break; From 6039179373f7552c2a711b06a7d69b9ca9d2b175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 16 Oct 2012 11:34:00 +0200 Subject: [PATCH 068/114] Fix for memory leak in ResultStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ResultStoreBase::addResults() it possible that the ResultItem we create is invalid (filter-mode enabled). Since an invalid ResultItem won't have any result data, we need to make sure that we don't allocate any data for it. Task-number: QTBUG-27224 Change-Id: Ic99b191db0e9dd4e29b64911f87d90a8148bb7a5 Reviewed-by: Morten Johan Sørvig --- src/corelib/thread/qresultstore.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 3314cd7aaf..d084e24c0c 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -176,7 +176,10 @@ public: int addResults(int index, const QVector *results, int totalCount) { - return ResultStoreBase::addResults(index, new QVector(*results), results->count(), totalCount); + if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) + return ResultStoreBase::addResults(index, 0, 0, totalCount); + else + return ResultStoreBase::addResults(index, new QVector(*results), results->count(), totalCount); } int addCanceledResult(int index) From a23be1b3e1d3f037f9a9b4fce84fad5fa7846247 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Oct 2012 11:15:37 +0200 Subject: [PATCH 069/114] normalise signal/slot signatures [QtOpenGL tests] Change-Id: Ie8a56873013ad2408d792e371a7d3e2ecf1f9c2c Reviewed-by: Friedemann Kleint Reviewed-by: Sean Harmer --- tests/auto/opengl/qgl/tst_qgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 929141c108..899e642249 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -2277,7 +2277,7 @@ protected: delete display; display = new DisplayWidget(this); - connect(producer, SIGNAL(imageReady(const QImage &)), display, SLOT(setImage(const QImage &))); + connect(producer, SIGNAL(imageReady(QImage)), display, SLOT(setImage(QImage))); display->setGeometry(rect()); display->show(); From 1fef528d33a67fa237998a0f244233b272205b03 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 09:16:27 +0200 Subject: [PATCH 070/114] Test: remove QSKIP in tst_QDir::dotAndDotDot Instead omit the omit the whole test when Q_OS_WINCE is defined. Change-Id: I8c0f12c63bbc4567edb3a8626ab060d5ce38f3cd Reviewed-by: J-P Nurmi --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 0fdd97bc8e..9cc3f29e49 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -150,7 +150,9 @@ private slots: void operator_eq(); +#ifndef Q_OS_WINCE void dotAndDotDot(); +#endif void homePath(); void tempPath(); void rootPath(); @@ -1318,18 +1320,17 @@ void tst_QDir::operator_eq() dir1.setPath(".."); } +#ifndef Q_OS_WINCE +// WinCE does not have . nor .. void tst_QDir::dotAndDotDot() { -#if defined(Q_OS_WINCE) - QSKIP("WinCE does not have . nor .."); -#else QDir dir(QString((m_dataPath + "/testdir/"))); QStringList entryList = dir.entryList(QDir::Dirs); QCOMPARE(entryList, QStringList() << QString(".") << QString("..") << QString("dir") << QString("spaces")); entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); QCOMPARE(entryList, QStringList() << QString("dir") << QString("spaces")); -#endif } +#endif void tst_QDir::homePath() { From 6dfeee624aa6c8e833044cc43c0d6db83c04a07e Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 09:31:51 +0200 Subject: [PATCH 071/114] Test: remove QSKIP in tst_file Instead omit the whole tests when appropriate. Change-Id: I5eae127a497e290c5e4ba1a81a8f325c300471c1 Reviewed-by: J-P Nurmi --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 0dddf6ca03..1f2d4fe4f5 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -145,8 +145,10 @@ private slots: void append(); void permissions_data(); void permissions(); +#ifdef Q_OS_WIN void permissionsNtfs_data(); void permissionsNtfs(); +#endif void setPermissions(); void copy(); void copyAfterFail(); @@ -192,7 +194,9 @@ private slots: void writeLargeDataBlock(); void readFromWriteOnlyFile(); void writeToReadOnlyFile(); +#if defined(Q_OS_LINUX) || defined(Q_OS_AIX) || defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) void virtualFile(); +#endif void textFile(); void rename_data(); void rename(); @@ -1132,6 +1136,7 @@ void tst_QFile::permissions() QCOMPARE((staticResult == QFile::Permissions(perms)), expected); } +#ifdef Q_OS_WIN void tst_QFile::permissionsNtfs_data() { permissions_data(); @@ -1139,14 +1144,11 @@ void tst_QFile::permissionsNtfs_data() void tst_QFile::permissionsNtfs() { -#ifdef Q_OS_WIN QScopedValueRollback ntfsMode(qt_ntfs_permission_lookup); qt_ntfs_permission_lookup++; permissions(); -#else - QSKIP("windows test"); -#endif } +#endif void tst_QFile::setPermissions() { @@ -2290,6 +2292,8 @@ void tst_QFile::writeToReadOnlyFile() QCOMPARE(file.write(&c, 1), qint64(-1)); } +#if defined(Q_OS_LINUX) || defined(Q_OS_AIX) || defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) +// This platform have 0-sized virtual files void tst_QFile::virtualFile() { // test if QFile works with virtual files @@ -2298,10 +2302,8 @@ void tst_QFile::virtualFile() fname = "/proc/self/maps"; #elif defined(Q_OS_AIX) fname = QString("/proc/%1/map").arg(getpid()); -#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) +#else // defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) fname = "/proc/curproc/map"; -#else - QSKIP("This platform does not have 0-sized virtual files"); #endif // consistency check @@ -2334,6 +2336,7 @@ void tst_QFile::virtualFile() QVERIFY(f.seek(1)); QCOMPARE(f.pos(), Q_INT64_C(1)); } +#endif void tst_QFile::textFile() { From 0b23cd186c0113692031176f43b7157539174d9d Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 09:56:57 +0200 Subject: [PATCH 072/114] Test: remove QSKIP in tst_QDataStream::stream_QIcon Instead omit the whole test when Q_OS_WINCE is defined. Change-Id: Ic69accb138121d2b39f068cef181da13b18e46ee Reviewed-by: J-P Nurmi --- tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index 21089b5a1b..ef384f86cd 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -138,8 +138,10 @@ private slots: void stream_qint64_data(); void stream_qint64(); +#ifndef Q_OS_WINCE void stream_QIcon_data(); void stream_QIcon(); +#endif void stream_QEasingCurve_data(); void stream_QEasingCurve(); @@ -1544,20 +1546,18 @@ void tst_QDataStream::stream_QPixmap() } #endif +#ifndef Q_OS_WINCE +// Test depends on more memory than available on Qt/CE void tst_QDataStream::stream_QIcon_data() { -#ifndef Q_OS_WINCE stream_data(1); -#endif } void tst_QDataStream::stream_QIcon() { -#ifdef Q_OS_WINCE - QSKIP("Test depends on more memory than available on Qt/CE"); -#endif STREAM_IMPL(QIcon); } +#endif void tst_QDataStream::writeQPixmap(QDataStream *s) { From bfbeaffda89f475370094911f625db10baac72fc Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 18 Oct 2012 11:14:57 +1000 Subject: [PATCH 073/114] Fix compile with -no-widgets Remove more unnecessary references to QtWidgets in accessibility implementation. Disable accessibility tests (which rely on QtWidgets) when QtWidgets is not available. Change-Id: I57315537779d31af1245d42d1b4c49174016da54 Reviewed-by: Jens Bache-Wiig Reviewed-by: Frederik Gladhorn --- src/platformsupport/linuxaccessibility/application.cpp | 6 +++--- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 1 - tests/auto/other/other.pro | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/linuxaccessibility/application.cpp b/src/platformsupport/linuxaccessibility/application.cpp index 0b9f1ce2e5..c2049e536a 100644 --- a/src/platformsupport/linuxaccessibility/application.cpp +++ b/src/platformsupport/linuxaccessibility/application.cpp @@ -42,7 +42,7 @@ #include "application_p.h" -#include +#include #include #include @@ -204,7 +204,7 @@ void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage& delete event.second; } else { QPair event = keyEvents.dequeue(); - QApplication::postEvent(event.first, event.second); + QCoreApplication::postEvent(event.first, event.second); } } @@ -213,7 +213,7 @@ void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error qWarning() << QStringLiteral("QSpiApplication::keyEventError ") << error.name() << error.message(); while (!keyEvents.isEmpty()) { QPair event = keyEvents.dequeue(); - QApplication::postEvent(event.first, event.second); + QCoreApplication::postEvent(event.first, event.second); } } diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 68c1f8ae4a..bea84d04fb 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 0d96c7d0cd..eb6ed667a8 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -39,6 +39,8 @@ contains(QT_CONFIG, no-widgets): SUBDIRS -= \ qnetworkaccessmanager_and_qprogressdialog \ qsharedpointer_and_qwidget \ windowsmobile \ + qaccessibility \ + qaccessibilitylinux \ testcocoon: SUBDIRS -= headersclean From 8660a3bce1637ee833565b8d7c3ba498bd4a81b0 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 18 Oct 2012 11:21:20 +0200 Subject: [PATCH 074/114] Make sure we copy *all known events* properly in order to not assert. This caused the following assertion in tst_QAccessibility::listTest(): ASSERT: "m_type != QAccessible::TableModelChanged" in file qaccessible.h, line 455 Change-Id: If1f1e80521f346019bdbd59aac58e30c870d6e4e Reviewed-by: Frederik Gladhorn --- src/testlib/qtestaccessible.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index 88a554dcea..2642ee206a 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -218,6 +218,14 @@ private: ev = upd; } else if (event->type() == QAccessible::ValueChanged) { ev = new QAccessibleValueChangeEvent(event->object(), static_cast(event)->value()); + } else if (event->type() == QAccessible::TableModelChanged) { + QAccessibleTableModelChangeEvent *oldEvent = static_cast(event); + QAccessibleTableModelChangeEvent *newEvent = new QAccessibleTableModelChangeEvent(event->object(), oldEvent->modelChangeType()); + newEvent->setFirstRow(oldEvent->firstRow()); + newEvent->setFirstColumn(oldEvent->firstColumn()); + newEvent->setLastRow(oldEvent->lastRow()); + newEvent->setLastColumn(oldEvent->lastColumn()); + ev = newEvent; } else { ev = new QAccessibleEvent(event->object(), event->type()); } From 8506850cc882b01352c207b8a2838a0c614323c8 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 10:07:28 +0200 Subject: [PATCH 075/114] Test: remove QSKIP from tst_QTextStream::stillOpenWhenAtEnd Instead omit the whole test when Q_OS_WINCE is defined. Change-Id: Ifd09048687db95913f39a64cffb42a743af8fa81 Reviewed-by: J-P Nurmi --- tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 9e2cd5ec2a..7069ab8d29 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -188,7 +188,9 @@ private slots: void octTest(); void zeroTermination(); void ws_manipulator(); +#ifndef Q_OS_WINCE void stillOpenWhenAtEnd(); +#endif void readNewlines_data(); void readNewlines(); void seek(); @@ -1096,6 +1098,8 @@ void tst_QTextStream::ws_manipulator() } // ------------------------------------------------------------------------------ +#ifndef Q_OS_WINCE +// Qt/CE: Cannot test network on emulator void tst_QTextStream::stillOpenWhenAtEnd() { QFile file(QFINDTESTDATA("tst_qtextstream.cpp")); @@ -1105,9 +1109,6 @@ void tst_QTextStream::stillOpenWhenAtEnd() while (!stream.readLine().isNull()) {} QVERIFY(file.isOpen()); -#ifdef Q_OS_WINCE - QSKIP("Qt/CE: Cannot test network on emulator"); -#endif if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); @@ -1119,6 +1120,7 @@ void tst_QTextStream::stillOpenWhenAtEnd() while (!stream2.readLine().isNull()) {} QVERIFY(socket.isOpen()); } +#endif // ------------------------------------------------------------------------------ void tst_QTextStream::readNewlines_data() From 5c57d1eacb04b4fa6a5dd8b1299926e6c02ac602 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 14:25:36 +0200 Subject: [PATCH 076/114] Test: remove QSKIP in tst_qarraydata Instead omit the whole tests when appropriate. Change-Id: Id4ec171528d4b4d6849b2478ac4f4a2332789b55 Reviewed-by: J-P Nurmi --- .../tools/qarraydata/tst_qarraydata.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 6f7937533a..ad7d8b2ab9 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -87,8 +87,13 @@ private slots: void fromRawData_data(); void fromRawData(); void literals(); +#if defined(Q_COMPILER_VARIADIC_MACROS) \ + && (defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU)) void variadicLiterals(); +#endif +#ifdef Q_COMPILER_RVALUE_REFS void rValueReferences(); +#endif void grow(); }; @@ -1564,10 +1569,11 @@ void tst_QArrayData::literals() } } -void tst_QArrayData::variadicLiterals() -{ #if defined(Q_COMPILER_VARIADIC_MACROS) \ && (defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU)) +// Variadic Q_ARRAY_LITERAL need to be available in the current configuration. +void tst_QArrayData::variadicLiterals() +{ { QArrayDataPointer d = Q_ARRAY_LITERAL(int, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -1610,10 +1616,8 @@ void tst_QArrayData::variadicLiterals() for (int i = 0; i < 7; ++i) QCOMPARE(const_(v)[i], i); } -#else - QSKIP("Variadic Q_ARRAY_LITERAL not available in current configuration."); -#endif // defined(Q_COMPILER_VARIADIC_MACROS) } +#endif #ifdef Q_COMPILER_RVALUE_REFS // std::remove_reference is in C++11, but requires library support @@ -1666,11 +1670,10 @@ struct CompilerHasCxx11ImplicitMoves { }; }; -#endif +// RValue references need to be supported in the current configuration void tst_QArrayData::rValueReferences() { -#ifdef Q_COMPILER_RVALUE_REFS if (!CompilerHasCxx11ImplicitMoves::value()) QSKIP("Implicit move ctor not supported in current configuration"); @@ -1698,10 +1701,8 @@ void tst_QArrayData::rValueReferences() QCOMPARE(v3.size(), size_t(1)); QCOMPARE(v3.front(), 42); -#else - QSKIP("RValue references are not supported in current configuration"); -#endif } +#endif void tst_QArrayData::grow() { From 23c19acc59e791a92bb2a493236ec210cf33e56d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 17 Oct 2012 15:18:28 +0200 Subject: [PATCH 077/114] Windows QPA plugin: Parse arguments from list passed to factory. Using dynamic properties on the native interface is deprecated. Change-Id: Ia3411780dad15af61d4805c0d9fabf00dba92301 Reviewed-by: Miikka Heikkinen --- src/plugins/platforms/windows/main.cpp | 3 +- .../platforms/windows/qwindowsglcontext.cpp | 16 ++--- .../platforms/windows/qwindowsintegration.cpp | 59 ++++++++++--------- .../platforms/windows/qwindowsintegration.h | 10 +++- 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/plugins/platforms/windows/main.cpp b/src/plugins/platforms/windows/main.cpp index 826d0df819..7557b80191 100644 --- a/src/plugins/platforms/windows/main.cpp +++ b/src/plugins/platforms/windows/main.cpp @@ -112,9 +112,8 @@ public: QPlatformIntegration *QWindowsIntegrationPlugin::create(const QString& system, const QStringList& paramList) { - Q_UNUSED(paramList); if (system.compare(system, QStringLiteral("windows"), Qt::CaseInsensitive) == 0) - return new QWindowsIntegration; + return new QWindowsIntegration(paramList); return 0; } diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index a760ea06e9..b50a858f96 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -42,6 +42,7 @@ #include "qwindowsglcontext.h" #include "qwindowscontext.h" #include "qwindowswindow.h" +#include "qwindowsintegration.h" #include #include @@ -855,16 +856,6 @@ QDebug operator<<(QDebug d, const QOpenGLStaticContext &s) return d; } -// Use ARB unless explicitly turned off on command line. -static inline bool useARB() -{ - const QVariant glExtension = qApp->platformNativeInterface()->property("gl"); - if (glExtension.type() == QVariant::String - && !glExtension.toString().compare(QStringLiteral("gdi"), Qt::CaseInsensitive)) - return false; - return true; -} - /*! \class QWindowsGLContext \brief Open GL context. @@ -914,12 +905,13 @@ QWindowsGLContext::QWindowsGLContext(const QOpenGLStaticContextPtr &staticContex if (QWindowsContext::verboseGL > 1) describeFormats(hdc); - // Preferably use direct rendering and ARB extensions (unless pixmap) + // Preferably use direct rendering and ARB extensions (unless pixmap + // or explicitly turned off on command line). const QWindowsOpenGLAdditionalFormat requestedAdditional(QWindowsGLDirectRendering); tryExtensions = m_staticContext->hasExtensions() && !testFlag(requestedAdditional.formatFlags, QWindowsGLRenderToPixmap) - && useARB(); + && !(QWindowsIntegration::instance()->options() & QWindowsIntegration::DisableArb); QWindowsOpenGLAdditionalFormat obtainedAdditional; if (tryExtensions) { m_pixelFormat = diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 12e7d7b5db..50ffb85b01 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -232,9 +232,10 @@ struct QWindowsIntegrationPrivate typedef QSharedPointer QOpenGLStaticContextPtr; #endif - QWindowsIntegrationPrivate(); + explicit QWindowsIntegrationPrivate(const QStringList ¶mList); ~QWindowsIntegrationPrivate(); + const unsigned m_options; QWindowsContext m_context; QPlatformFontDatabase *m_fontDatabase; QWindowsNativeInterface m_nativeInterface; @@ -255,8 +256,27 @@ struct QWindowsIntegrationPrivate QWindowsServices m_services; }; -QWindowsIntegrationPrivate::QWindowsIntegrationPrivate() - : m_fontDatabase(0), m_eventDispatcher(new QWindowsGuiEventDispatcher) +static inline unsigned parseOptions(const QStringList ¶mList) +{ + unsigned options = 0; + foreach (const QString ¶m, paramList) { + if (param.startsWith(QLatin1String("fontengine="))) { + if (param.endsWith(QLatin1String("freetype"))) { + options |= QWindowsIntegration::FontDatabaseFreeType; + } else if (param.endsWith(QLatin1String("native"))) { + options |= QWindowsIntegration::FontDatabaseNative; + } + } else if (param == QLatin1String("gl=gdi")) { + options |= QWindowsIntegration::DisableArb; + } + } + return options; +} + +QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mList) + : m_options(parseOptions(paramList)) + , m_fontDatabase(0) + , m_eventDispatcher(new QWindowsGuiEventDispatcher) { } @@ -266,8 +286,8 @@ QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() delete m_fontDatabase; } -QWindowsIntegration::QWindowsIntegration() : - d(new QWindowsIntegrationPrivate) +QWindowsIntegration::QWindowsIntegration(const QStringList ¶mList) : + d(new QWindowsIntegrationPrivate(paramList)) { QGuiApplicationPrivate::instance()->setEventDispatcher(d->m_eventDispatcher); #ifndef QT_NO_CLIPBOARD @@ -371,25 +391,6 @@ QPlatformOpenGLContext /* Workaround for QTBUG-24205: In 'Auto', pick the FreeType engine for * QML2 applications. */ -enum FontDatabaseOption { - FontDatabaseFreeType, - FontDatabaseNative, - FontDatabaseAuto -}; - -static inline FontDatabaseOption fontDatabaseOption(const QObject &nativeInterface) -{ - const QVariant argumentV = nativeInterface.property("fontengine"); - if (argumentV.isValid()) { - const QString argument = argumentV.toString(); - if (argument == QLatin1String("freetype")) - return FontDatabaseFreeType; - if (argument == QLatin1String("native")) - return FontDatabaseNative; - } - return FontDatabaseAuto; -} - #ifdef Q_OS_WINCE // It's not easy to detect if we are running a QML application // Let's try to do so by checking if the QtQuick module is loaded. @@ -411,10 +412,9 @@ QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const #ifdef QT_NO_FREETYPE d->m_fontDatabase = new QWindowsFontDatabase(); #else // QT_NO_FREETYPE - FontDatabaseOption option = fontDatabaseOption(d->m_nativeInterface); - if (option == FontDatabaseFreeType) { + if (d->m_options & QWindowsIntegration::FontDatabaseFreeType) { d->m_fontDatabase = new QWindowsFontDatabaseFT; - } else if (option == FontDatabaseNative){ + } else if (d->m_options & QWindowsIntegration::FontDatabaseNative){ d->m_fontDatabase = new QWindowsFontDatabase; } else { #ifndef Q_OS_WINCE @@ -520,6 +520,11 @@ QWindowsIntegration *QWindowsIntegration::instance() return static_cast(QGuiApplicationPrivate::platformIntegration()); } +unsigned QWindowsIntegration::options() const +{ + return d->m_options; +} + QAbstractEventDispatcher * QWindowsIntegration::guiThreadEventDispatcher() const { return d->m_eventDispatcher; diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 49780566dd..ca47dabb4b 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -53,7 +53,13 @@ struct QWindowsIntegrationPrivate; class QWindowsIntegration : public QPlatformIntegration { public: - QWindowsIntegration(); + enum Options { // Options to be passed on command line. + FontDatabaseFreeType = 0x1, + FontDatabaseNative = 0x2, + DisableArb = 0x4 + }; + + explicit QWindowsIntegration(const QStringList ¶mList); virtual ~QWindowsIntegration(); bool hasCapability(QPlatformIntegration::Capability cap) const; @@ -87,6 +93,8 @@ public: inline void emitScreenAdded(QPlatformScreen *s) { screenAdded(s); } + unsigned options() const; + private: QScopedPointer d; }; From e75be9f30e88f0bef361144887fb36a30079cb7d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 6 Jul 2012 11:37:26 +0100 Subject: [PATCH 078/114] Add new error strings to QRegularExpression They are introduced in PCRE 8.31. Change-Id: Id0447b381d5e23996d4e87ae0368b07a8bc1c318 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qregularexpression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 5436d1f94a..5c6b3ff044 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -2345,7 +2345,9 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "\\N is not supported in a class"), QT_TRANSLATE_NOOP("QRegularExpression", "too many forward references"), QT_TRANSLATE_NOOP("QRegularExpression", "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"), - QT_TRANSLATE_NOOP("QRegularExpression", "invalid UTF-16 string") + QT_TRANSLATE_NOOP("QRegularExpression", "invalid UTF-16 string"), + QT_TRANSLATE_NOOP("QRegularExpression", "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"), + QT_TRANSLATE_NOOP("QRegularExpression", "character value in \\u.... sequence is too large") }; #endif // #if 0 From 92e4ec7a146660362f365d8a54e0f017c8f48bd9 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 16 Oct 2012 16:53:09 +0200 Subject: [PATCH 079/114] Bring back Mac dependent code in QBoxLayout, QGridLayout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We also made an accessibility auto-test more stable, so that it would not be influenced by this patch. Task-number: QTCREATORBUG-7966 Change-Id: I6ce4e2361c8847aee5dd1cf5664c29cd2d83e38d Reviewed-by: Jan Arve Sæther --- src/widgets/kernel/qboxlayout.cpp | 4 ++-- src/widgets/kernel/qgridlayout.cpp | 2 +- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index d05efaa5b0..d16c999508 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -162,7 +162,7 @@ void QBoxLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int *b int t = topMargin; int r = rightMargin; int b = bottomMargin; -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC Q_Q(const QBoxLayout); if (horz(dir)) { QBoxLayoutItem *leftBox = 0; @@ -311,7 +311,7 @@ void QBoxLayoutPrivate::setupGeom() if (!empty) { if (fixedSpacing >= 0) { spacing = (previousNonEmptyIndex >= 0) ? fixedSpacing : 0; -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if (!horz(dir) && previousNonEmptyIndex >= 0) { QBoxLayoutItem *sibling = (dir == QBoxLayout::TopToBottom ? box : list.at(previousNonEmptyIndex)); if (sibling) { diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index 5dd840e80a..b5cd746c03 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -231,7 +231,7 @@ void QGridLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int * int t = topMargin; int r = rightMargin; int b = bottomMargin; -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC int leftMost = INT_MAX; int topMost = INT_MAX; int rightMost = 0; diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 08d679772e..9d614703c6 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1680,6 +1680,7 @@ void tst_QAccessibility::mdiSubWindowTest() const int subWindowCount = 5; for (int i = 0; i < subWindowCount; ++i) { QMdiSubWindow *window = mdiArea.addSubWindow(new QPushButton("QAccessibilityTest")); + window->setAttribute(Qt::WA_LayoutUsesWidgetRect); window->show(); // Parts of this test requires that the sub windows are placed next // to each other. In order to achieve that QMdiArea must have @@ -1759,7 +1760,7 @@ void tst_QAccessibility::mdiSubWindowTest() const QPoint globalWidgetPos = QPoint(globalPos.x() + widgetGeometry.x(), globalPos.y() + widgetGeometry.y()); #ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-22812", Abort); + QSKIP("QTBUG-22812"); #endif QCOMPARE(childRect(interface), QRect(globalWidgetPos, widgetGeometry.size())); From a2e4b7a92fad04fc6c73a71ede003ccbdf7b5305 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 17 Oct 2012 15:20:10 +0200 Subject: [PATCH 080/114] Remove dependency on QWindowsStyle in QGtkStyle Now that we no longer re-use the animation code in gtk, it is time to remove this strange dependency. Change-Id: Ib672a9b110dfba08d79b8654e572994007675957 Reviewed-by: Jens Bache-Wiig Reviewed-by: J-P Nurmi --- src/widgets/styles/qgtkstyle.cpp | 181 ++++++++++++++++------------- src/widgets/styles/qgtkstyle.h | 2 +- src/widgets/styles/qgtkstyle_p.cpp | 3 +- src/widgets/styles/qgtkstyle_p.h | 13 ++- 4 files changed, 115 insertions(+), 84 deletions(-) diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp index 2c8bc4c188..e9701f9d6f 100644 --- a/src/widgets/styles/qgtkstyle.cpp +++ b/src/widgets/styles/qgtkstyle.cpp @@ -267,7 +267,7 @@ static GdkColor fromQColor(const QColor &color) \since 4.5 \inmodule QtWidgets - + The QGtkStyle style provides a look and feel that integrates well into GTK-based desktop environments such as the XFCe and GNOME. @@ -285,7 +285,7 @@ static GdkColor fromQColor(const QColor &color) Constructs a QGtkStyle object. */ QGtkStyle::QGtkStyle() - : QWindowsStyle(*new QGtkStylePrivate) + : QCommonStyle(*new QGtkStylePrivate) { Q_D(QGtkStyle); d->init(); @@ -297,7 +297,7 @@ QGtkStyle::QGtkStyle() Constructs a QGtkStyle object. */ QGtkStyle::QGtkStyle(QGtkStylePrivate &dd) - : QWindowsStyle(dd) + : QCommonStyle(dd) { Q_D(QGtkStyle); d->init(); @@ -318,7 +318,7 @@ QPalette QGtkStyle::standardPalette() const { Q_D(const QGtkStyle); - QPalette palette = QWindowsStyle::standardPalette(); + QPalette palette = QCommonStyle::standardPalette(); if (d->isThemeAvailable()) { GtkStyle *style = d->gtkStyle(); GtkWidget *gtkButton = d->gtkWidget("GtkButton"); @@ -409,7 +409,7 @@ void QGtkStyle::polish(QPalette &palette) Q_D(QGtkStyle); if (!d->isThemeAvailable()) - QWindowsStyle::polish(palette); + QCommonStyle::polish(palette); else palette = palette.resolve(standardPalette()); } @@ -421,8 +421,8 @@ void QGtkStyle::polish(QApplication *app) { Q_D(QGtkStyle); - QWindowsStyle::polish(app); - // Custom fonts and palettes with QtConfig are intentionally + QCommonStyle::polish(app); + // Custom fonts and palettes with QtConfig are intentionally // not supported as these should be entirely determined by // current Gtk settings if (app->desktopSettingsAware() && d->isThemeAvailable()) { @@ -448,7 +448,7 @@ void QGtkStyle::unpolish(QApplication *app) { Q_D(QGtkStyle); - QWindowsStyle::unpolish(app); + QCommonStyle::unpolish(app); QPixmapCache::clear(); if (app->desktopSettingsAware() && d->isThemeAvailable() @@ -471,7 +471,7 @@ void QGtkStyle::polish(QWidget *widget) { Q_D(QGtkStyle); - QWindowsStyle::polish(widget); + QCommonStyle::polish(widget); if (!d->isThemeAvailable()) return; if (qobject_cast(widget) @@ -495,7 +495,7 @@ void QGtkStyle::polish(QWidget *widget) */ void QGtkStyle::unpolish(QWidget *widget) { - QWindowsStyle::unpolish(widget); + QCommonStyle::unpolish(widget); } /*! @@ -508,7 +508,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric, Q_D(const QGtkStyle); if (!d->isThemeAvailable()) - return QWindowsStyle::pixelMetric(metric, option, widget); + return QCommonStyle::pixelMetric(metric, option, widget); switch (metric) { case PM_DefaultFrameWidth: @@ -693,7 +693,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric, case PM_TabCloseIndicatorHeight: return 20; default: - return QWindowsStyle::pixelMetric(metric, option, widget); + return QCommonStyle::pixelMetric(metric, option, widget); } } @@ -707,17 +707,21 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg Q_D(const QGtkStyle); if (!d->isThemeAvailable()) - return QWindowsStyle::styleHint(hint, option, widget, returnData); + return QCommonStyle::styleHint(hint, option, widget, returnData); switch (hint) { + case SH_ItemView_ChangeHighlightOnFocus: + return true; case SH_ScrollBar_MiddleClickAbsolutePosition: return true; case SH_Menu_AllowActiveAndDisabled: return false; case SH_MainWindow_SpaceBelowMenuBar: - return 0; + return false; case SH_MenuBar_MouseTracking: return true; + case SH_Menu_MouseTracking: + return true; case SH_TitleBar_AutoRaise: return true; case SH_TitleBar_NoBorder: @@ -743,7 +747,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1); mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2); } - return QWindowsStyle::styleHint(hint, option, widget, returnData); + return QCommonStyle::styleHint(hint, option, widget, returnData); case SH_MessageBox_TextInteractionFlags: return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; case SH_MessageBox_CenterButtons: @@ -768,7 +772,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg case SH_ToolButtonStyle: { if (d->isKDE4Session()) - return QWindowsStyle::styleHint(hint, option, widget, returnData); + return QCommonStyle::styleHint(hint, option, widget, returnData); GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL); @@ -839,7 +843,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg default: break; } - return QWindowsStyle::styleHint(hint, option, widget, returnData); + return QCommonStyle::styleHint(hint, option, widget, returnData); } /*! @@ -853,7 +857,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, Q_D(const QGtkStyle); if (!d->isThemeAvailable()) { - QWindowsStyle::drawPrimitive(element, option, painter, widget); + QCommonStyle::drawPrimitive(element, option, painter, widget); return; } @@ -980,14 +984,11 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; case PE_FrameDefaultButton: // fall through - case PE_FrameFocusRect: - if ((widget && qobject_cast(widget))) { - if (option->state & State_KeyboardFocusChange) - QWindowsStyle::drawPrimitive(element, option, painter, widget); - } else { - // ### this mess should move to subcontrolrect - QRect frameRect = option->rect.adjusted(1, 1, -2, -2); - if ( qobject_cast(widget)) { + case PE_FrameFocusRect: { + QRect frameRect = option->rect.adjusted(1, 1, -2, -2); // ### this mess should move to subcontrolrect + if (qobject_cast(widget)) { + // Dont draw anything + } else if (qobject_cast(widget)) { GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); style = gtkPainter.getStyle(gtkNotebook); gtkPainter.paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style); @@ -1422,7 +1423,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, case QTabBar::TriangularWest: case QTabBar::TriangularSouth: painter->restore(); - QWindowsStyle::drawPrimitive(element, option, painter, widget); + QCommonStyle::drawPrimitive(element, option, painter, widget); return; } @@ -1436,7 +1437,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; default: - QWindowsStyle::drawPrimitive(element, option, painter, widget); + QCommonStyle::drawPrimitive(element, option, painter, widget); } } @@ -1450,7 +1451,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom Q_D(const QGtkStyle); if (!d->isThemeAvailable()) { - QWindowsStyle::drawComplexControl(control, option, painter, widget); + QCommonStyle::drawComplexControl(control, option, painter, widget); return; } @@ -2615,7 +2616,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom #endif // QT_NO_SLIDER default: - QWindowsStyle::drawComplexControl(control, option, painter, widget); + QCommonStyle::drawComplexControl(control, option, painter, widget); break; } @@ -2633,7 +2634,7 @@ void QGtkStyle::drawControl(ControlElement element, Q_D(const QGtkStyle); if (!d->isThemeAvailable()) { - QWindowsStyle::drawControl(element, option, painter, widget); + QCommonStyle::drawControl(element, option, painter, widget); return; } @@ -3062,10 +3063,8 @@ void QGtkStyle::drawControl(ControlElement element, // Draws one item in a popup menu. if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { - const int windowsItemFrame = 2; // menu item frame width const int windowsItemHMargin = 3; // menu item hor text margin const int windowsItemVMargin = 26; // menu item ver text margin - const int windowsRightBorder = 15; // right border on windows GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") : d->gtkWidget("GtkMenu.GtkMenuItem"); @@ -3252,9 +3251,9 @@ void QGtkStyle::drawControl(ControlElement element, int x, y, w, h; menuitem->rect.getRect(&x, &y, &w, &h); int tab = menuitem->tabWidth; - int xm = windowsItemFrame + checkcol + windowsItemHMargin; + int xm = QGtkStylePrivate::menuItemFrame + checkcol + windowsItemHMargin; int xpos = menuitem->rect.x() + xm + 1; - QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); + QRect textRect(xpos, y + windowsItemVMargin, w - xm - QGtkStylePrivate::menuRightBorder - tab + 1, h - 2 * windowsItemVMargin); QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); QString s = menuitem->text; @@ -3407,7 +3406,7 @@ void QGtkStyle::drawControl(ControlElement element, break; default: - QWindowsStyle::drawControl(element, option, painter, widget); + QCommonStyle::drawControl(element, option, painter, widget); break; } @@ -3511,7 +3510,7 @@ void QGtkStyle::drawControl(ControlElement element, break; default: - QWindowsStyle::drawControl(element, option, painter, widget); + QCommonStyle::drawControl(element, option, painter, widget); } } @@ -3523,9 +3522,9 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple { Q_D(const QGtkStyle); - QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget); + QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget); if (!d->isThemeAvailable()) - return QWindowsStyle::subControlRect(control, option, subControl, widget); + return QCommonStyle::subControlRect(control, option, subControl, widget); switch (control) { case CC_ScrollBar: @@ -3780,7 +3779,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple GtkWidget *arrowWidget = d->gtkWidget(arrowPath); if (!arrowWidget) - return QWindowsStyle::subControlRect(control, option, subControl, widget); + return QCommonStyle::subControlRect(control, option, subControl, widget); GtkAllocation allocation; d->gtk_widget_get_allocation(arrowWidget, &allocation); @@ -3829,7 +3828,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, { Q_D(const QGtkStyle); - QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); + QSize newSize = QCommonStyle::sizeFromContents(type, option, size, widget); if (!d->isThemeAvailable()) return newSize; @@ -3865,34 +3864,6 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, newSize += QSize(6, 0); } break; - case CT_MenuItem: - if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { - int textMargin = 8; - - if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { - GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); - GtkRequisition sizeReq = {0, 0}; - d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); - newSize = QSize(size.width(), sizeReq.height); - break; - } - - GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem"); - GtkStyle* style = d->gtk_widget_get_style(gtkMenuItem); - - // Note we get the perfect height for the default font since we - // set a fake text label on the gtkMenuItem - // But if custom fonts are used on the widget we need a minimum size - GtkRequisition sizeReq = {0, 0}; - d->gtk_widget_size_request(gtkMenuItem, &sizeReq); - newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); - newSize += QSize(textMargin + style->xthickness - 1, 0); - - gint checkSize; - d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); - newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); - } - break; case CT_SpinBox: // QSpinBox does some nasty things that depends on CT_LineEdit newSize = size + QSize(0, -d->gtk_widget_get_style(d->gtkWidget("GtkSpinButton"))->ythickness * 2); @@ -3957,7 +3928,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, newSize += QSize(1, 1); break; case CT_MenuBarItem: - newSize += QSize(0, 2); + newSize += QSize(QGtkStylePrivate::menuItemHMargin * 4, QGtkStylePrivate::menuItemVMargin * 2 + 2); break; case CT_SizeGrip: newSize += QSize(4, 4); @@ -3976,6 +3947,56 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, newSize = QSize(60, 19); } break; + case CT_MenuItem: + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { + int w = newSize.width(); + int maxpmw = menuItem->maxIconWidth; + int tabSpacing = 20; + if (menuItem->text.contains(QLatin1Char('\t'))) + w += tabSpacing; + else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) + w += 2 * QGtkStylePrivate::menuArrowHMargin; + else if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) { + // adjust the font and add the difference in size. + // it would be better if the font could be adjusted in the initStyleOption qmenu func!! + QFontMetrics fm(menuItem->font); + QFont fontBold = menuItem->font; + fontBold.setBold(true); + QFontMetrics fmBold(fontBold); + w += fmBold.width(menuItem->text) - fm.width(menuItem->text); + } + + int checkcol = qMax(maxpmw, QGtkStylePrivate::menuCheckMarkWidth); // Windows always shows a check column + w += checkcol; + w += int(QGtkStylePrivate::menuRightBorder) + 10; + + newSize.setWidth(w); + + int textMargin = 8; + if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); + GtkRequisition sizeReq = {0, 0}; + d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); + newSize = QSize(newSize.width(), sizeReq.height); + break; + } + + GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem"); + GtkStyle* style = d->gtk_widget_get_style(gtkMenuItem); + + // Note we get the perfect height for the default font since we + // set a fake text label on the gtkMenuItem + // But if custom fonts are used on the widget we need a minimum size + GtkRequisition sizeReq = {0, 0}; + d->gtk_widget_size_request(gtkMenuItem, &sizeReq); + newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); + newSize += QSize(textMargin + style->xthickness - 1, 0); + + gint checkSize; + d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); + newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); + } + break; default: break; } @@ -3991,7 +4012,7 @@ QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, Q_D(const QGtkStyle); if (!d->isThemeAvailable()) - return QWindowsStyle::standardPixmap(sp, option, widget); + return QCommonStyle::standardPixmap(sp, option, widget); QPixmap pixmap; switch (sp) { @@ -4045,7 +4066,7 @@ QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, case SP_MessageBoxCritical: return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); default: - return QWindowsStyle::standardPixmap(sp, option, widget); + return QCommonStyle::standardPixmap(sp, option, widget); } return pixmap; } @@ -4060,7 +4081,7 @@ QIcon QGtkStyle::standardIcon(StandardPixmap standardIcon, Q_D(const QGtkStyle); if (!d->isThemeAvailable()) - return QWindowsStyle::standardIcon(standardIcon, option, widget); + return QCommonStyle::standardIcon(standardIcon, option, widget); switch (standardIcon) { case SP_DialogDiscardButton: return QGtkPainter::getIcon(GTK_STOCK_DELETE); @@ -4089,7 +4110,7 @@ QIcon QGtkStyle::standardIcon(StandardPixmap standardIcon, case SP_MessageBoxCritical: return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); default: - return QWindowsStyle::standardIcon(standardIcon, option, widget); + return QCommonStyle::standardIcon(standardIcon, option, widget); } } @@ -4099,7 +4120,7 @@ QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, { Q_D(const QGtkStyle); - QRect r = QWindowsStyle::subElementRect(element, option, widget); + QRect r = QCommonStyle::subElementRect(element, option, widget); if (!d->isThemeAvailable()) return r; @@ -4152,7 +4173,7 @@ QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, */ QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const { - return QWindowsStyle::itemPixmapRect(r, flags, pixmap); + return QCommonStyle::itemPixmapRect(r, flags, pixmap); } /*! @@ -4161,7 +4182,7 @@ QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const { - QWindowsStyle::drawItemPixmap(painter, rect, alignment, pixmap); + QCommonStyle::drawItemPixmap(painter, rect, alignment, pixmap); } /*! @@ -4170,7 +4191,7 @@ void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect, QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w) const { - return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w); + return QCommonStyle::hitTestComplexControl(cc, opt, pt, w); } /*! @@ -4179,7 +4200,7 @@ QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QSt QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const { - return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, opt); + return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt); } /*! @@ -4188,7 +4209,7 @@ QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixm void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, bool enabled, const QString& text, QPalette::ColorRole textRole) const { - return QWindowsStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole); + return QCommonStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole); } QT_END_NAMESPACE diff --git a/src/widgets/styles/qgtkstyle.h b/src/widgets/styles/qgtkstyle.h index 446305b6ba..c0faca075c 100644 --- a/src/widgets/styles/qgtkstyle.h +++ b/src/widgets/styles/qgtkstyle.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class QPainterPath; class QGtkStylePrivate; -class Q_WIDGETS_EXPORT QGtkStyle : public QWindowsStyle +class Q_WIDGETS_EXPORT QGtkStyle : public QCommonStyle { Q_OBJECT Q_DECLARE_PRIVATE(QGtkStyle) diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp index 85b645c71c..3bd5688f31 100644 --- a/src/widgets/styles/qgtkstyle_p.cpp +++ b/src/widgets/styles/qgtkstyle_p.cpp @@ -289,10 +289,11 @@ QList QGtkStylePrivate::instances; QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0; QGtkStylePrivate::QGtkStylePrivate() - : QWindowsStylePrivate() + : QCommonStylePrivate() , filter(this) { instances.append(this); + animationFps = 60; } QGtkStylePrivate::~QGtkStylePrivate() diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h index 009d49ecbe..71c70c41f1 100644 --- a/src/widgets/styles/qgtkstyle_p.h +++ b/src/widgets/styles/qgtkstyle_p.h @@ -63,7 +63,7 @@ #include #include -#include +#include #undef signals // Collides with GTK symbols #include @@ -317,7 +317,7 @@ typedef char* (*Ptr_gnome_icon_lookup_sync) ( GnomeIconLookupFlags flags, GnomeIconLookupResultFlags *result); -class QGtkStylePrivate : public QWindowsStylePrivate +class QGtkStylePrivate : public QCommonStylePrivate { Q_DECLARE_PUBLIC(QGtkStyle) public: @@ -522,6 +522,15 @@ protected: virtual void init(); + enum { + menuItemFrame = 2, // menu item frame width + menuItemHMargin = 3, // menu item hor text margin + menuArrowHMargin = 6, // menu arrow horizontal margin + menuItemVMargin = 2, // menu item ver text margin + menuRightBorder = 15, // right border on menus + menuCheckMarkWidth = 12 // checkmarks width on menus + }; + private: static QList instances; static WidgetMap *widgetMap; From 6226fcdc3e4ace4636c58778ef53fbf69f46c36e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 18 Sep 2012 22:01:10 +0200 Subject: [PATCH 081/114] add a .qmake.conf file which load()s qt_build_config that way we don't have to auto-generate code for that in the configures. note that we now load qt_build_config.prf instead of just qmodule.pri, which means that exceptions_off is set everywhere. we forcibly re-enable them for testcases to minimize the deviation from default 3rd party usage. testlib selftests are not qt testcases, so the one that needs exceptions needs to enable them explicitly. Change-Id: I1b9360bb11f2e80c92a2b63a7c45991ad17fda1b Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- .qmake.conf | 1 + configure | 1 - mkspecs/features/qt_build_config.prf | 5 +++-- mkspecs/features/testcase.prf | 6 ++++++ .../testlib/selftests/exceptionthrow/exceptionthrow.pro | 1 + tools/configure/configureapp.cpp | 2 -- 6 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .qmake.conf diff --git a/.qmake.conf b/.qmake.conf new file mode 100644 index 0000000000..42ba8e45fb --- /dev/null +++ b/.qmake.conf @@ -0,0 +1 @@ +load(qt_build_config) diff --git a/configure b/configure index 684948e385..643b64024f 100755 --- a/configure +++ b/configure @@ -6114,7 +6114,6 @@ cat >>"$CACHEFILE.tmp" < Date: Thu, 18 Oct 2012 15:34:26 +0200 Subject: [PATCH 082/114] Use the right properties when checking the frame's margins Changed it to check the Frame*Margin property instead of the Block*Margin property as this was incorrect for a QTextFrameFormat. Task-number: QTBUG-22173 Change-Id: I2c3066165fb592ed034874b1180593822859f933 Reviewed-by: Simon Hausmann --- src/gui/text/qtextodfwriter.cpp | 8 ++++---- .../qtextodfwriter/tst_qtextodfwriter.cpp | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 33c6ddd1cd..8f6025fdf0 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -666,13 +666,13 @@ void QTextOdfWriter::writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex)); writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section")); writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties")); - if (format.hasProperty(QTextFormat::BlockTopMargin)) + if (format.hasProperty(QTextFormat::FrameTopMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) ); - if (format.hasProperty(QTextFormat::BlockBottomMargin)) + if (format.hasProperty(QTextFormat::FrameBottomMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) ); - if (format.hasProperty(QTextFormat::BlockLeftMargin)) + if (format.hasProperty(QTextFormat::FrameLeftMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) ); - if (format.hasProperty(QTextFormat::BlockRightMargin)) + if (format.hasProperty(QTextFormat::FrameRightMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) ); writer.writeEndElement(); // style diff --git a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp index 74a7ac95ea..c287ef30ac 100644 --- a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp @@ -69,6 +69,7 @@ private slots: void testWriteAll(); void testWriteSection(); void testWriteTable(); + void testWriteFrameFormat(); private: /// closes the document and returns the part of the XML stream that the test wrote @@ -419,5 +420,23 @@ void tst_QTextOdfWriter::testWriteTable() QCOMPARE(getContentFromXml(), xml); } +void tst_QTextOdfWriter::testWriteFrameFormat() +{ + QTextFrameFormat tff; + tff.setTopMargin(20); + tff.setBottomMargin(20); + tff.setLeftMargin(20); + tff.setRightMargin(20); + QTextCursor tc(document); + odfWriter->writeFrameFormat(*xmlWriter, tff, 0); + // Value of 15pt is based on the pixelToPoint() calculation done in qtextodfwriter.cpp + QString xml = QString::fromLatin1( + "" + "" + ""); + QCOMPARE(getContentFromXml(), xml); +} + QTEST_MAIN(tst_QTextOdfWriter) #include "tst_qtextodfwriter.moc" From b9facbf34595464f677e12ef5100328d4c318380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 17 Oct 2012 14:13:19 +0200 Subject: [PATCH 083/114] Refactor recursive target logic out of default_post into function The qmake function prepareRecursiveTarget can now be used both by the existing logic in default_post, as well as future recursive targets that will be needed as part of the modularization of documentation builds. Change-Id: Ibc72c3e224cb57c9f1796de3b04fda9de663dbb4 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/default_post.prf | 36 +++++-------------------------- mkspecs/features/qt_functions.prf | 26 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 2542cb2f9d..003a73dedf 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -50,42 +50,16 @@ QMAKE_LIBDIR += $$QMAKE_LIBDIR_POST # Let every project have a standard GNU `check' target !contains(QMAKE_EXTRA_TARGETS, check) { - # `make check' should iterate through all subdirs - # (except those with no_default_target or no_check_target) - contains(TEMPLATE, subdirs) { - for(subdir, SUBDIRS) { - subdir_config=$$eval($${subdir}.CONFIG) - !contains(subdir_config, no_check_target):!contains(subdir_config, no_default_target):check.recurse += $$subdir - unset(subdir_config) - } - !isEmpty(check.recurse) { - # setup the recurse target only when there is to recurse into - check.CONFIG = recursive - check.recurse_target = check - } - } - # `make check' should imply building the project - else { - check.depends = first - } + contains(TEMPLATE, subdirs): \ + prepareRecursiveTarget(check) + else: \ + check.depends = first # `make check' implies build QMAKE_EXTRA_TARGETS += check } -# Let every project have a 'docs' target !contains(QMAKE_EXTRA_TARGETS, docs) { contains(TEMPLATE, subdirs) { - # `make docs' should iterate through all subdirs - # (except those with no_default_target or no_docs_target) - !contains(CONFIG, no_docs_target):for(subdir, SUBDIRS) { - subdir_config = $$eval($${subdir}.CONFIG) - !contains(subdir_config, no_docs_target):!contains(subdir_config, no_default_target):docs.recurse += $$subdir - unset(subdir_config) - } - !isEmpty(docs.recurse) { - # setup the recurse target only when there is something to recurse into - docs.CONFIG = recursive - docs.recurse_target = docs - } + prepareRecursiveTarget(docs) } else { # apps and libs only generate docs if QMAKE_DOCS is set !isEmpty(QMAKE_DOCS) { diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index f614ad8f07..2d8f81bae1 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -267,3 +267,29 @@ defineTest(packagesExist) { return(true) } +# Prepares target that will iterate through all subdirs (except those +# with no_default_target or no_{name_of_target}_target. The prepared +# target must still be manually added to QMAKE_EXTRA_TARGETS. +defineTest(prepareRecursiveTarget) { + target = $$1 + no_$${target}_target: return() + + for(subdir, SUBDIRS) { + subdir_config = $$eval($${subdir}.CONFIG) + contains(subdir_config, no_default_target): next() + contains(subdir_config, no_$${target}_target): next() + + $${target}.recurse += $$subdir + } + + # Set up the recurse target only when there + # is something to recurse into. + isEmpty($${target}.recurse): return() + + $${target}.CONFIG = recursive + $${target}.recurse_target = $${target} + + export($${target}.recurse) + export($${target}.CONFIG) + export($${target}.recurse_target) +} From e6cbf2f9858f88f2148e80e528f5aaddc91373a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 17 Oct 2012 15:08:39 +0200 Subject: [PATCH 084/114] Prevent 'make install' from automatically installing documentation Just like 'make docs' is used to build documentation, you will now have to run 'make install_docs' to install it. Change-Id: I57db53160ca91618784f4e39da0a47322c070208 Task-number: QTBUG-27590 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/default_post.prf | 8 ++++++++ mkspecs/features/qt_installs.prf | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 003a73dedf..a77738222f 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -73,3 +73,11 @@ QMAKE_LIBDIR += $$QMAKE_LIBDIR_POST } QMAKE_EXTRA_TARGETS += docs } + +!contains(QMAKE_EXTRA_TARGETS, install_docs) { + contains(TEMPLATE, subdirs) { + prepareRecursiveTarget(install_docs) + prepareRecursiveTarget(uninstall_docs) + } + QMAKE_EXTRA_TARGETS += install_docs uninstall_docs +} diff --git a/mkspecs/features/qt_installs.prf b/mkspecs/features/qt_installs.prf index 507d3ebddc..11005b02ac 100644 --- a/mkspecs/features/qt_installs.prf +++ b/mkspecs/features/qt_installs.prf @@ -51,7 +51,11 @@ qt_install_module { qt_install_module_docs { module_docs.files = $$QMAKE_DOCS_OUTPUTDIR module_docs.path = $$[QT_INSTALL_DOCS] - module_docs.CONFIG += no_check_exist directory + module_docs.CONFIG += no_check_exist directory no_default_install module_docs.depends += docs INSTALLS += module_docs + + install_docs.depends = install_module_docs + uninstall_docs.depends = uninstall_module_docs + QMAKE_EXTRA_TARGETS += install_docs uninstall_docs } From 8b6de4677142cab41790ca50ce6c7f1efbab5de8 Mon Sep 17 00:00:00 2001 From: Tero Ahola Date: Tue, 7 Aug 2012 15:10:47 +0300 Subject: [PATCH 085/114] Modified vertical alignments of simple widgets on OSX Adding QCheckBox, QComboBox, QLineEdit etc. into an HBox layout or grid layout makes the layout look like a snake's trail. Fixed the positioning of these widgets to make the layouts visually more appealing. Updated qmacstyle auto-test accordingly. Task-number: QTBUG-13635 Ammended-by: Gabriel de Dietrich Change-Id: I89461f9aad68ea8488070ed06257b9b8e7f493c5 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 14 +-- .../styles/qmacstyle/tst_qmacstyle.cpp | 11 +-- .../qstylesheetstyle/tst_qstylesheetstyle.cpp | 4 - tests/manual/manual.pro | 1 + tests/manual/qlayout/gridwidget.cpp | 74 +++++++++++++++ tests/manual/qlayout/gridwidget.h | 59 ++++++++++++ tests/manual/qlayout/hbwidget.cpp | 70 ++++++++++++++ tests/manual/qlayout/hbwidget.h | 59 ++++++++++++ tests/manual/qlayout/main.cpp | 52 +++++++++++ tests/manual/qlayout/mainwindow.cpp | 93 +++++++++++++++++++ tests/manual/qlayout/mainwindow.h | 64 +++++++++++++ tests/manual/qlayout/qlayout.pro | 14 +++ tests/manual/qlayout/vbwidget.cpp | 70 ++++++++++++++ tests/manual/qlayout/vbwidget.h | 59 ++++++++++++ 14 files changed, 627 insertions(+), 17 deletions(-) create mode 100644 tests/manual/qlayout/gridwidget.cpp create mode 100644 tests/manual/qlayout/gridwidget.h create mode 100644 tests/manual/qlayout/hbwidget.cpp create mode 100644 tests/manual/qlayout/hbwidget.h create mode 100644 tests/manual/qlayout/main.cpp create mode 100644 tests/manual/qlayout/mainwindow.cpp create mode 100644 tests/manual/qlayout/mainwindow.h create mode 100644 tests/manual/qlayout/qlayout.pro create mode 100644 tests/manual/qlayout/vbwidget.cpp create mode 100644 tests/manual/qlayout/vbwidget.h diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 3110973740..38f4dc3abc 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1013,7 +1013,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg if (!widg || !qobject_cast(widg->parentWidget())) { //should I take into account the font dimentions of the lineedit? -Sam if (sz == QAquaSizeLarge) - ret = QSize(-1, 22); + ret = QSize(-1, 21); else ret = QSize(-1, 19); } @@ -1392,7 +1392,7 @@ HIRect QMacStylePrivate::comboboxInnerBounds(const HIRect &outerBounds, int butt switch (buttonKind){ case kThemePopupButton: innerBounds.origin.x += 2; - innerBounds.origin.y += 3; + innerBounds.origin.y += 2; innerBounds.size.width -= 5; innerBounds.size.height -= 6; break; @@ -1410,9 +1410,9 @@ HIRect QMacStylePrivate::comboboxInnerBounds(const HIRect &outerBounds, int butt break; case kThemeComboBox: innerBounds.origin.x += 3; - innerBounds.origin.y += 3; + innerBounds.origin.y += 2; innerBounds.size.width -= 6; - innerBounds.size.height -= 6; + innerBounds.size.height -= 8; break; case kThemeComboBoxSmall: innerBounds.origin.x += 3; @@ -1441,7 +1441,7 @@ QRect QMacStylePrivate::comboboxEditBounds(const QRect &outerBounds, const HIThe QRect ret = outerBounds; switch (bdi.kind){ case kThemeComboBox: - ret.adjust(5, 8, -23, -4); + ret.adjust(5, 5, -22, -5); break; case kThemeComboBoxSmall: ret.adjust(4, 5, -18, 0); @@ -1452,7 +1452,7 @@ QRect QMacStylePrivate::comboboxEditBounds(const QRect &outerBounds, const HIThe ret.setHeight(13); break; case kThemePopupButton: - ret.adjust(10, 3, -23, -3); + ret.adjust(10, 2, -23, -4); break; case kThemePopupButtonSmall: ret.adjust(9, 3, -20, -3); @@ -4655,7 +4655,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, if(widget->parentWidget() && qobject_cast(widget->parentWidget())) rect.adjust(-1, -2, 0, 0); else - rect.adjust(-1, 0, 0, +1); + rect.adjust(-1, -1, 0, +1); break; case SE_CheckBoxLayoutItem: rect = opt->rect; diff --git a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp index 0fdce91151..c0b857d540 100644 --- a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp +++ b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp @@ -124,7 +124,7 @@ void tst_QMacStyle::sizeHints() setSize(&w, size); QLineEdit lineEdit1(&w); - QCOMPARE(sh(&lineEdit1).height(), SIZE(22, 19, 16)); // 16 in Builder, 15 in AHIG + QCOMPARE(sh(&lineEdit1).height(), SIZE(21, 19, 16)); // 16 in Builder, 15 in AHIG QProgressBar progress1(&w); progress1.setOrientation(Qt::Horizontal); @@ -135,11 +135,10 @@ void tst_QMacStyle::sizeHints() QCOMPARE(sh(&progress1).width(), SIZE(16, 10, 10)); // Builder QRadioButton radio1("Radio", &w); - QEXPECT_FAIL("", "QTBUG-25296", Abort); - QCOMPARE(sh(&radio1).height(), SIZE(15, 12, 10)); // Builder + QCOMPARE(sh(&radio1).height(), SIZE(14, 12, 10)); // Builder QCheckBox checkBox1("Switch", &w); - QCOMPARE(sh(&checkBox1).height(), SIZE(14, 12, 10)); // Builder + QCOMPARE(sh(&checkBox1).height(), SIZE(13, 12, 10)); // Builder QComboBox comboBox1(&w); comboBox1.setEditable(false); @@ -149,7 +148,7 @@ void tst_QMacStyle::sizeHints() QComboBox comboBox2(&w); comboBox2.setEditable(true); comboBox2.addItem("Foo"); - QCOMPARE(sh(&comboBox2).height(), SIZE(20, 17, 15)); + QCOMPARE(sh(&comboBox2).height(), SIZE(22, 17, 15)); // Combos in toolbars use the actual widget rect to // avoid faulty clipping: @@ -227,7 +226,7 @@ void tst_QMacStyle::sizeHints() // QMacStyle bug: label doesn't react to Small and Mini QLabel label1("Blah", &w); - QCOMPARE(sh(&label1).height(), SIZE(17, 14, 11)); + QCOMPARE(sh(&label1).height(), SIZE(16, 14, 11)); } void tst_QMacStyle::layoutMargins_data() diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index dc8b1c12f3..4b2125ad6a 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -874,10 +874,6 @@ void tst_QStyleSheetStyle::hoverColors() QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), (QString::fromLatin1(widget->metaObject()->className()) + " did not contain background color #e8ff66").toLocal8Bit().constData()); -#ifdef Q_OS_MAC - if (qobject_cast(widget)) - QEXPECT_FAIL("", "Failure only for QPushButton and QComboBox, see QTBUG-23686", Continue); -#endif QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), (QString::fromLatin1(widget->metaObject()->className()) + " did not contain text color #ff0084").toLocal8Bit().constData()); diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 6aff45ac4d..04bdff6abc 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -14,6 +14,7 @@ qgraphicsitemgroup \ qgraphicslayout/flicker \ qhttpnetworkconnection \ qimagereader \ +qlayout \ qlocale \ qnetworkaccessmanager/qget \ qnetworkconfigurationmanager \ diff --git a/tests/manual/qlayout/gridwidget.cpp b/tests/manual/qlayout/gridwidget.cpp new file mode 100644 index 0000000000..821ed7f604 --- /dev/null +++ b/tests/manual/qlayout/gridwidget.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "gridwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include + +GridWidget::GridWidget(QWidget *parent) : + QWidget(parent) +{ + QGridLayout *hb = new QGridLayout(this); + QComboBox *combo = new QComboBox(); + combo->addItem("123"); + QComboBox *combo2 = new QComboBox(); + combo2->setEditable(true); + combo2->addItem("123"); + + hb->addWidget(new QLabel("123"), 0, 0); + hb->addWidget(new QLabel("123"), 0, 1); + hb->addWidget(new QLineEdit("123"), 1, 0); + hb->addWidget(new QLineEdit("123"), 1, 1); + hb->addWidget(new QCheckBox("123"), 0, 2); + hb->addWidget(new QCheckBox("123"), 1, 2); + hb->addWidget(combo, 0, 3); + hb->addWidget(combo2, 1, 3); + hb->addWidget(new QDateTimeEdit(), 0, 4); + hb->addWidget(new QPushButton("123"), 1, 4); + hb->addWidget(new QSpinBox(), 0, 5); + hb->addWidget(new QSpinBox(), 1, 5); +} diff --git a/tests/manual/qlayout/gridwidget.h b/tests/manual/qlayout/gridwidget.h new file mode 100644 index 0000000000..481c17f5c3 --- /dev/null +++ b/tests/manual/qlayout/gridwidget.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRIDWIDGET_H +#define GRIDWIDGET_H + +#include + +class GridWidget : public QWidget +{ + Q_OBJECT +public: + explicit GridWidget(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // GRIDWIDGET_H diff --git a/tests/manual/qlayout/hbwidget.cpp b/tests/manual/qlayout/hbwidget.cpp new file mode 100644 index 0000000000..e4a568ef57 --- /dev/null +++ b/tests/manual/qlayout/hbwidget.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "hbwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include + +HbWidget::HbWidget(QWidget *parent) : + QWidget(parent) +{ + QHBoxLayout *hb = new QHBoxLayout(this); + QComboBox *combo = new QComboBox(this); + combo->addItem("123"); + QComboBox *combo2 = new QComboBox(); + combo2->setEditable(true); + combo2->addItem("123"); + + hb->addWidget(new QLabel("123")); + hb->addWidget(new QLineEdit("123")); + hb->addWidget(combo); + hb->addWidget(combo2); + hb->addWidget(new QCheckBox("123")); + hb->addWidget(new QDateTimeEdit()); + hb->addWidget(new QPushButton("123")); + hb->addWidget(new QSpinBox()); +} diff --git a/tests/manual/qlayout/hbwidget.h b/tests/manual/qlayout/hbwidget.h new file mode 100644 index 0000000000..f8efdc3531 --- /dev/null +++ b/tests/manual/qlayout/hbwidget.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef HBWIDGET_H +#define HBWIDGET_H + +#include + +class HbWidget : public QWidget +{ + Q_OBJECT +public: + explicit HbWidget(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // HBWIDGET_H diff --git a/tests/manual/qlayout/main.cpp b/tests/manual/qlayout/main.cpp new file mode 100644 index 0000000000..7c6bbab5e7 --- /dev/null +++ b/tests/manual/qlayout/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/tests/manual/qlayout/mainwindow.cpp b/tests/manual/qlayout/mainwindow.cpp new file mode 100644 index 0000000000..9899e0d881 --- /dev/null +++ b/tests/manual/qlayout/mainwindow.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "hbwidget.h" +#include "vbwidget.h" +#include "gridwidget.h" +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + QWidget *widget = new QWidget(this); + setCentralWidget(widget); + m_mainLayout = new QGridLayout(widget); + + QComboBox *combo = new QComboBox(); + combo->addItem("HBox Layout"); + combo->addItem("VBox Layout"); + combo->addItem("Grid Layout"); + connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutIndexChanged(int))); + HbWidget *hbWidget = new HbWidget(this); + + m_mainLayout->addWidget(combo); + m_mainLayout->addWidget(hbWidget); +} + +MainWindow::~MainWindow() +{ + +} + +void MainWindow::layoutIndexChanged(int index) +{ + delete m_mainLayout->takeAt(1)->widget(); + + switch (index) { + case 0: { + HbWidget *hbWidget = new HbWidget(this); + m_mainLayout->addWidget(hbWidget); + break; + } + case 1: { + VbWidget *vbWidget = new VbWidget(this); + m_mainLayout->addWidget(vbWidget); + break; + } + default: { + GridWidget *gridW = new GridWidget(this); + m_mainLayout->addWidget(gridW); + break; + } + } +} diff --git a/tests/manual/qlayout/mainwindow.h b/tests/manual/qlayout/mainwindow.h new file mode 100644 index 0000000000..44ccd6618a --- /dev/null +++ b/tests/manual/qlayout/mainwindow.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class QGridLayout; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void layoutIndexChanged(int index); + +private: + QGridLayout *m_mainLayout; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/qlayout/qlayout.pro b/tests/manual/qlayout/qlayout.pro new file mode 100644 index 0000000000..44cd7496ef --- /dev/null +++ b/tests/manual/qlayout/qlayout.pro @@ -0,0 +1,14 @@ +QT += widgets + +TEMPLATE = app + +SOURCES += main.cpp\ + mainwindow.cpp \ + hbwidget.cpp \ + gridwidget.cpp \ + vbwidget.cpp + +HEADERS += mainwindow.h \ + hbwidget.h \ + gridwidget.h \ + vbwidget.h diff --git a/tests/manual/qlayout/vbwidget.cpp b/tests/manual/qlayout/vbwidget.cpp new file mode 100644 index 0000000000..9033105d4b --- /dev/null +++ b/tests/manual/qlayout/vbwidget.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "vbwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include + +VbWidget::VbWidget(QWidget *parent) : + QWidget(parent) +{ + QVBoxLayout *hb = new QVBoxLayout(this); + QComboBox *combo = new QComboBox(this); + combo->addItem("123"); + QComboBox *combo2 = new QComboBox(); + combo2->setEditable(true); + combo2->addItem("123"); + + hb->addWidget(new QLabel("123")); + hb->addWidget(new QLineEdit("123")); + hb->addWidget(combo); + hb->addWidget(combo2); + hb->addWidget(new QCheckBox("123")); + hb->addWidget(new QDateTimeEdit()); + hb->addWidget(new QPushButton("123")); + hb->addWidget(new QSpinBox()); +} diff --git a/tests/manual/qlayout/vbwidget.h b/tests/manual/qlayout/vbwidget.h new file mode 100644 index 0000000000..86559c5950 --- /dev/null +++ b/tests/manual/qlayout/vbwidget.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VBWIDGET_H +#define VBWIDGET_H + +#include + +class VbWidget : public QWidget +{ + Q_OBJECT +public: + explicit VbWidget(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // VBWIDGET_H From f45afd71551a6cd1553952ea003e9356651809b5 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 21 Sep 2012 19:53:28 +0200 Subject: [PATCH 086/114] Introduce new style Fusion This is a new non-native style for Qt. It is intended as a replacement for the now aging Plastique and Cleanlooks styles. Change-Id: I30c0518a69e4e3b8b2b05ee7d84c3a5a1f307578 Reviewed-by: Jens Bache-Wiig Reviewed-by: J-P Nurmi --- configure | 2 +- src/widgets/styles/images/fusion_arrow.png | Bin 0 -> 295 bytes src/widgets/styles/images/fusion_groupbox.png | Bin 0 -> 485 bytes src/widgets/styles/qfusionstyle.cpp | 3578 +++++++++++++++++ src/widgets/styles/qfusionstyle.h | 111 + src/widgets/styles/qfusionstyle_p.h | 129 + src/widgets/styles/qstyle.qrc | 270 +- src/widgets/styles/qstyle_p.h | 14 +- src/widgets/styles/qstylefactory.cpp | 12 + src/widgets/styles/styles.pri | 12 + tools/configure/configureapp.cpp | 13 + 11 files changed, 4004 insertions(+), 137 deletions(-) create mode 100644 src/widgets/styles/images/fusion_arrow.png create mode 100644 src/widgets/styles/images/fusion_groupbox.png create mode 100644 src/widgets/styles/qfusionstyle.cpp create mode 100644 src/widgets/styles/qfusionstyle.h create mode 100644 src/widgets/styles/qfusionstyle_p.h diff --git a/configure b/configure index 643b64024f..c5804f3d16 100755 --- a/configure +++ b/configure @@ -727,7 +727,7 @@ mkdir -p "$outpath/config.tests" rm -f "$outpath/config.tests/.qmake.cache" cp "$QMAKE_VARS_FILE" "$outpath/config.tests/.qmake.cache" -QMakeVar add styles "cde mac motif plastique cleanlooks windows" +QMakeVar add styles "cde mac motif fusion plastique cleanlooks windows" # QTDIR may be set and point to an old or system-wide Qt installation unset QTDIR diff --git a/src/widgets/styles/images/fusion_arrow.png b/src/widgets/styles/images/fusion_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..d7945e7f769bd234c04f281c6bddf0ad5e881f7a GIT binary patch literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngf!3HGX_LqeNDVAa<&kznEsNqQI07({jL>4nJ zFi!ztMlZpY+CV|c64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1T+c)B=- zXiS`Y#x{$IQGo4&`6jWjjm6rI8@@2e9r(?{#At0@FLhA3lC%1CNtqa%nrm20Y3PS$ z&9oo)PWbpb_nl<5th>_r|52$@&juH1bsyum@2a+29Ad~W5%7@tI5qRXfcuNY<~-K( zo-!Y1zIgTe~DWM4f-FIlK literal 0 HcmV?d00001 diff --git a/src/widgets/styles/images/fusion_groupbox.png b/src/widgets/styles/images/fusion_groupbox.png new file mode 100644 index 0000000000000000000000000000000000000000..98585ee8c71015b309d94bde67524ce1d7e5c5aa GIT binary patch literal 485 zcmeAS@N?(olHy`uVBq!ia0vp^NkFW|!3HGlbNotx6lZ})WHAE+w=f7ZGR&GI!N9;c z-P6S}B!l(s?1g#F0TQj;w>`YJC4_zBP@buNGdV$U#w|NxrpBkXue8503BMLB5!SO3ob+b_*? z_<{fBlItdCPi_|8c>n$Vi$t4!YGmEa z=9j&+$~bNRLy z9ua(G*7nKf{@2?755l%TvZy<=>5VQ&Q>1l?4EMI9eoog*XFvY<<0HHK@<6+PeS!AC Pcw_K%^>bP0l+XkKBPGf> literal 0 HcmV?d00001 diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp new file mode 100644 index 0000000000..603369d117 --- /dev/null +++ b/src/widgets/styles/qfusionstyle.cpp @@ -0,0 +1,3578 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfusionstyle.h" +#include "qfusionstyle_p.h" + +#if !defined(QT_NO_STYLE_FUSION) || defined(QT_PLUGIN) +#include "qcommonstyle_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +using namespace QStyleHelper; + +enum Direction { + TopDown, + FromLeft, + BottomUp, + FromRight +}; + +// from windows style +static const int windowsItemFrame = 2; // menu item frame width +static const int windowsItemHMargin = 3; // menu item hor text margin +static const int windowsItemVMargin = 8; // menu item ver text margin +static const int windowsRightBorder = 15; // right border on windows + +static const int groupBoxBottomMargin = 0; // space below the groupbox +static const int groupBoxTitleMargin = 2; // space between contents and title +static const int groupBoxTopMargin = 18; + + +/* XPM */ +static const char * const dock_widget_close_xpm[] = { + "11 13 7 1", + " c None", + ". c #D5CFCB", + "+ c #8F8B88", + "@ c #6C6A67", + "# c #ABA6A3", + "$ c #B5B0AC", + "% c #A4A09D", + " ", + " +@@@@@@@+ ", + "+# #+", + "@ $@ @$ @", + "@ @@@ @@@ @", + "@ @@@@@ @", + "@ @@@ @", + "@ @@@@@ @", + "@ @@@ @@@ @", + "@ $@ @$ @", + "+% #+", + " +@@@@@@@+ ", + " "}; + +static const char * const dock_widget_restore_xpm[] = { + "11 13 7 1", + " c None", + ". c #D5CFCB", + "+ c #8F8B88", + "@ c #6C6A67", + "# c #ABA6A3", + "$ c #B5B0AC", + "% c #A4A09D", + " ", + " +@@@@@@@+ ", + "+# #+", + "@ #@@@# @", + "@ @ @ @", + "@ #@@@# @ @", + "@ @ @ @ @", + "@ @ @@@ @", + "@ @ @ @", + "@ #@@@# @", + "+% #+", + " +@@@@@@@+ ", + " "}; + +static const char * const workspace_minimize[] = { + "11 13 7 1", + " c None", + ". c #D5CFCB", + "+ c #8F8B88", + "@ c #6C6A67", + "# c #ABA6A3", + "$ c #B5B0AC", + "% c #A4A09D", + " ", + " +@@@@@@@+ ", + "+# #+", + "@ @", + "@ @", + "@ @", + "@ @@@@@@@ @", + "@ @@@@@@@ @", + "@ @", + "@ @", + "+% #+", + " +@@@@@@@+ ", + " "}; + + +static const char * const qt_titlebar_context_help[] = { + "10 10 3 1", + " c None", + "# c #000000", + "+ c #444444", + " +####+ ", + " ### ### ", + " ## ## ", + " +##+ ", + " +## ", + " ## ", + " ## ", + " ", + " ## ", + " ## "}; + + +static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50) +{ + const int maxFactor = 100; + QColor tmp = colorA; + tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor); + tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor); + tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor); + return tmp; +} + +static QPixmap colorizedImage(const QString &fileName, const QColor &color, int rotation = 0) { + + QString pixmapName = QLatin1String("$qt_ia-") % fileName % HexString(color.rgba()) % QString::number(rotation); + QPixmap pixmap; + if (!QPixmapCache::find(pixmapName, pixmap)) { + QImage image(fileName); + + if (image.format() != QImage::Format_ARGB32_Premultiplied) + image = image.convertToFormat( QImage::Format_ARGB32_Premultiplied); + + int width = image.width(); + int height = image.height(); + int source = color.rgba(); + + unsigned char sourceRed = qRed(source); + unsigned char sourceGreen = qGreen(source); + unsigned char sourceBlue = qBlue(source); + + for (int y = 0; y < height; ++y) + { + QRgb *data = (QRgb*) image.scanLine(y); + for (int x = 0 ; x < width ; x++) { + QRgb col = data[x]; + unsigned int colorDiff = (qBlue(col) - qRed(col)); + unsigned char gray = qGreen(col); + unsigned char red = gray + qt_div_255(sourceRed * colorDiff); + unsigned char green = gray + qt_div_255(sourceGreen * colorDiff); + unsigned char blue = gray + qt_div_255(sourceBlue * colorDiff); + unsigned char alpha = qt_div_255(qAlpha(col) * qAlpha(source)); + data[x] = qRgba(red, green, blue, alpha); + } + } + if (rotation != 0) { + QTransform transform; + transform.translate(-image.width()/2, -image.height()/2); + transform.rotate(rotation); + transform.translate(image.width()/2, image.height()/2); + image = image.transformed(transform); + } + + pixmap = QPixmap::fromImage(image); + QPixmapCache::insert(pixmapName, pixmap); + } + return pixmap; +} + +// The default button and handle gradient +static QLinearGradient qt_fusion_gradient(const QRect &rect, const QBrush &baseColor, Direction direction = TopDown) +{ + int x = rect.center().x(); + int y = rect.center().y(); + QLinearGradient gradient; + switch (direction) { + case FromLeft: + gradient = QLinearGradient(rect.left(), y, rect.right(), y); + break; + case FromRight: + gradient = QLinearGradient(rect.right(), y, rect.left(), y); + break; + case BottomUp: + gradient = QLinearGradient(x, rect.bottom(), x, rect.top()); + break; + case TopDown: + default: + gradient = QLinearGradient(x, rect.top(), x, rect.bottom()); + break; + } + if (baseColor.gradient()) + gradient.setStops(baseColor.gradient()->stops()); + else { + QColor gradientStartColor = baseColor.color().lighter(124); + QColor gradientStopColor = baseColor.color().lighter(102); + gradient.setColorAt(0, gradientStartColor); + gradient.setColorAt(1, gradientStopColor); + // Uncomment for adding shiny shading + // QColor midColor1 = mergedColors(gradientStartColor, gradientStopColor, 55); + // QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 45); + // gradient.setColorAt(0.5, midColor1); + // gradient.setColorAt(0.501, midColor2); + } + return gradient; +} + + +static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken) +{ + QColor dark; + dark.setHsv(option->palette.button().color().hue(), + qMin(255, (int)(option->palette.button().color().saturation())), + qMin(255, (int)(option->palette.button().color().value()*0.7))); + + QColor highlight = option->palette.highlight().color(); + + bool active = (option->titleBarState & QStyle::State_Active); + QColor titleBarHighlight(255, 255, 255, 60); + + if (sunken) + painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().darker(120)); + else if (hover) + painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20)); + + QColor mdiButtonGradientStartColor; + QColor mdiButtonGradientStopColor; + + mdiButtonGradientStartColor = QColor(0, 0, 0, 40); + mdiButtonGradientStopColor = QColor(255, 255, 255, 60); + + if (sunken) + titleBarHighlight = highlight.darker(130); + + QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom()); + gradient.setColorAt(0, mdiButtonGradientStartColor); + gradient.setColorAt(1, mdiButtonGradientStopColor); + QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110)); + + painter->setPen(QPen(mdiButtonBorderColor, 1)); + const QLine lines[4] = { + QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), + QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), + QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), + QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(tmp.left() + 1, tmp.top() + 1), + QPoint(tmp.right() - 1, tmp.top() + 1), + QPoint(tmp.left() + 1, tmp.bottom() - 1), + QPoint(tmp.right() - 1, tmp.bottom() - 1) + }; + painter->drawPoints(points, 4); + + painter->setPen(titleBarHighlight); + painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1); + painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2); + + painter->setPen(QPen(gradient, 1)); + painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2); + painter->drawPoint(tmp.right() , tmp.top() + 1); + + painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1); + painter->drawPoint(tmp.left() + 1, tmp.bottom()); + painter->drawPoint(tmp.right() - 1, tmp.bottom()); + painter->drawPoint(tmp.right() , tmp.bottom() - 1); +} + +/* + \internal +*/ +QFusionStylePrivate::QFusionStylePrivate() +{ + animationFps = 60; +} + +/*! + \class QFusionStyle + \brief The QFusionStyle class provides a custom widget style + + \inmodule QtWidgets + + The Fusion style provides a custom look and feel that is not + tied to a particular platform. + //{Fusion Style Widget Gallery} + \sa QWindowsXPStyle, QMacStyle, QCommonStyle, QPlastiqueStyle +*/ + +/*! + Constructs a QFusionStyle object. +*/ +QFusionStyle::QFusionStyle() : QCommonStyle(*new QFusionStylePrivate) +{ + setObjectName(QLatin1String("Fusion")); +} + +/*! + \internal + + Constructs a QFusionStyle object. +*/ +QFusionStyle::QFusionStyle(QFusionStylePrivate &dd) : QCommonStyle(dd) +{ +} + +/*! + Destroys the QFusionStyle object. +*/ +QFusionStyle::~QFusionStyle() +{ +} + +/*! + \fn void QFusionStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, + bool enabled, const QString& text, QPalette::ColorRole textRole) const + + Draws the given \a text in the specified \a rectangle using the + provided \a painter and \a palette. + + Text is drawn using the painter's pen. If an explicit \a textRole + is specified, then the text is drawn using the \a palette's color + for the specified role. The \a enabled value indicates whether or + not the item is enabled; when reimplementing, this value should + influence how the item is drawn. + + The text is aligned and wrapped according to the specified \a + alignment. + + \sa Qt::Alignment +*/ +void QFusionStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, + bool enabled, const QString& text, QPalette::ColorRole textRole) const +{ + if (text.isEmpty()) + return; + + QPen savedPen = painter->pen(); + if (textRole != QPalette::NoRole) { + painter->setPen(QPen(pal.brush(textRole), savedPen.widthF())); + } + if (!enabled) { + QPen pen = painter->pen(); + painter->setPen(pen); + } + painter->drawText(rect, alignment, text); + painter->setPen(savedPen); +} + + +/*! + \reimp +*/ +void QFusionStyle::drawPrimitive(PrimitiveElement elem, + const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + Q_ASSERT(option); + Q_D (const QFusionStyle); + + QRect rect = option->rect; + int state = option->state; + + QColor outline = d->outline(option->palette); + QColor highlightedOutline = d->highlightedOutline(option->palette); + + QColor tabFrameColor = d->tabFrameColor(option->palette); + + switch (elem) { + + // No frame drawn + case PE_FrameGroupBox: + { + QPixmap pixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_groupbox.png")); + QRect frame = option->rect.adjusted(0, groupBoxTopMargin, 0, 0); + qDrawBorderPixmap(painter, frame, QMargins(6, 6, 6, 6), pixmap); + break; + } + case PE_IndicatorBranch: { + if (!(option->state & State_Children)) + break; + if (option->state & State_Open) + drawPrimitive(PE_IndicatorArrowDown, option, painter, widget); + else + drawPrimitive(PE_IndicatorArrowRight, option, painter, widget); + break; + } + case PE_FrameTabBarBase: + if (const QStyleOptionTabBarBase *tbb + = qstyleoption_cast(option)) { + painter->save(); + painter->setPen(QPen(outline.lighter(110), 0)); + switch (tbb->shape) { + case QTabBar::RoundedNorth: { + QRegion region(tbb->rect); + region -= tbb->selectedTabRect; + painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight()); + painter->setClipRegion(region); + painter->setPen(option->palette.light().color()); + painter->drawLine(tbb->rect.topLeft() + QPoint(0, 1), tbb->rect.topRight() + QPoint(0, 1)); + } + break; + case QTabBar::RoundedWest: + painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom()); + break; + case QTabBar::RoundedSouth: + painter->drawLine(tbb->rect.left(), tbb->rect.bottom(), + tbb->rect.right(), tbb->rect.bottom()); + break; + case QTabBar::RoundedEast: + painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight()); + break; + case QTabBar::TriangularNorth: + case QTabBar::TriangularEast: + case QTabBar::TriangularWest: + case QTabBar::TriangularSouth: + painter->restore(); + QCommonStyle::drawPrimitive(elem, option, painter, widget); + return; + } + painter->restore(); + } + return; + case PE_PanelScrollAreaCorner: { + painter->save(); + QColor alphaOutline = outline; + alphaOutline.setAlpha(180); + painter->setPen(alphaOutline); + painter->setBrush(option->palette.brush(QPalette::Window)); + painter->drawRect(option->rect); + painter->restore(); + } break; + case PE_IndicatorArrowUp: + case PE_IndicatorArrowDown: + case PE_IndicatorArrowRight: + case PE_IndicatorArrowLeft: + { + if (option->rect.width() <= 1 || option->rect.height() <= 1) + break; + QColor arrowColor = option->palette.foreground().color(); + QPixmap arrow; + int rotation = 0; + switch (elem) { + case PE_IndicatorArrowDown: + rotation = 180; + break; + case PE_IndicatorArrowRight: + rotation = 90; + break; + case PE_IndicatorArrowLeft: + rotation = -90; + break; + default: + break; + } + arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation); + QRect rect = option->rect; + QRect arrowRect; + int imageMax = qMin(arrow.height(), arrow.width()); + int rectMax = qMin(rect.height(), rect.width()); + int size = qMin(imageMax, rectMax); + + arrowRect.setWidth(size); + arrowRect.setHeight(size); + if (arrow.width() > arrow.height()) + arrowRect.setHeight(arrow.height() * size / arrow.width()); + else + arrowRect.setWidth(arrow.width() * size / arrow.height()); + + arrowRect.moveTopLeft(rect.center() - arrowRect.center()); + painter->save(); + painter->setRenderHint(QPainter::SmoothPixmapTransform); + painter->drawPixmap(arrowRect, arrow); + painter->restore(); + } + break; + case PE_IndicatorViewItemCheck: + { + QStyleOptionButton button; + button.QStyleOption::operator=(*option); + button.state &= ~State_MouseOver; + proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); + } + return; + case PE_IndicatorHeaderArrow: + if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { + QRect r = header->rect; + QPixmap arrow; + QColor arrowColor = header->palette.foreground().color(); + QPoint offset = QPoint(0, -1); + + if (header->sortIndicator & QStyleOptionHeader::SortUp) { + arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor); + } else if (header->sortIndicator & QStyleOptionHeader::SortDown) { + arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180); + } if (!arrow.isNull()) { + r.setSize(QSize(arrow.width()/2, arrow.height()/2)); + r.moveCenter(header->rect.center()); + painter->drawPixmap(r.translated(offset), arrow); + } + } + break; + case PE_IndicatorButtonDropDown: + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + break; + + case PE_IndicatorToolBarSeparator: + { + QRect rect = option->rect; + const int margin = 6; + if (option->state & State_Horizontal) { + const int offset = rect.width()/2; + painter->setPen(QPen(option->palette.background().color().darker(110))); + painter->drawLine(rect.bottomLeft().x() + offset, + rect.bottomLeft().y() - margin, + rect.topLeft().x() + offset, + rect.topLeft().y() + margin); + painter->setPen(QPen(option->palette.background().color().lighter(110))); + painter->drawLine(rect.bottomLeft().x() + offset + 1, + rect.bottomLeft().y() - margin, + rect.topLeft().x() + offset + 1, + rect.topLeft().y() + margin); + } else { //Draw vertical separator + const int offset = rect.height()/2; + painter->setPen(QPen(option->palette.background().color().darker(110))); + painter->drawLine(rect.topLeft().x() + margin , + rect.topLeft().y() + offset, + rect.topRight().x() - margin, + rect.topRight().y() + offset); + painter->setPen(QPen(option->palette.background().color().lighter(110))); + painter->drawLine(rect.topLeft().x() + margin , + rect.topLeft().y() + offset + 1, + rect.topRight().x() - margin, + rect.topRight().y() + offset + 1); + } + } + break; + case PE_Frame: + if (widget && widget->inherits("QComboBoxPrivateContainer")){ + QStyleOption copy = *option; + copy.state |= State_Raised; + proxy()->drawPrimitive(PE_PanelMenu, ©, painter, widget); + break; + } + painter->save(); + painter->setPen(outline.lighter(108)); + painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + painter->restore(); + break; + case PE_FrameMenu: + painter->save(); + { + painter->setPen(QPen(outline, 1)); + painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + QColor frameLight = option->palette.background().color().lighter(160); + QColor frameShadow = option->palette.background().color().darker(110); + + //paint beveleffect + QRect frame = option->rect.adjusted(1, 1, -1, -1); + painter->setPen(frameLight); + painter->drawLine(frame.topLeft(), frame.bottomLeft()); + painter->drawLine(frame.topLeft(), frame.topRight()); + + painter->setPen(frameShadow); + painter->drawLine(frame.topRight(), frame.bottomRight()); + painter->drawLine(frame.bottomLeft(), frame.bottomRight()); + } + painter->restore(); + break; + case PE_FrameDockWidget: + + painter->save(); + { + QColor softshadow = option->palette.background().color().darker(120); + + QRect rect= option->rect; + painter->setPen(softshadow); + painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + painter->setPen(QPen(option->palette.light(), 0)); + painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1)); + painter->setPen(QPen(option->palette.background().color().darker(120), 0)); + painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1)); + painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1)); + + } + painter->restore(); + break; + case PE_PanelButtonTool: + painter->save(); + if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) { + if (widget && widget->inherits("QDockWidgetTitleButton")) { + if (option->state & State_MouseOver) + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + } else { + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + } + } + painter->restore(); + break; + case PE_IndicatorDockWidgetResizeHandle: + { + QStyleOption dockWidgetHandle = *option; + bool horizontal = option->state & State_Horizontal; + if (horizontal) + dockWidgetHandle.state &= ~State_Horizontal; + else + dockWidgetHandle.state |= State_Horizontal; + proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget); + } + break; + case PE_FrameWindow: + painter->save(); + { + QRect rect= option->rect; + painter->setPen(QPen(outline.darker(150), 0)); + painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + painter->setPen(QPen(option->palette.light(), 0)); + painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), + QPoint(rect.left() + 1, rect.bottom() - 1)); + painter->setPen(QPen(option->palette.background().color().darker(120), 0)); + painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), + QPoint(rect.right() - 2, rect.bottom() - 1)); + painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), + QPoint(rect.right() - 1, rect.bottom() - 1)); + } + painter->restore(); + break; + case PE_FrameLineEdit: + { + QRect r = rect; + bool hasFocus = option->state & State_HasFocus; + + painter->save(); + + painter->setRenderHint(QPainter::Antialiasing, true); + // ### highdpi painter bug. + painter->translate(0.5, 0.5); + + // Draw Outline + painter->setPen( QPen(hasFocus ? highlightedOutline : outline, 0)); + painter->setBrush(option->palette.base()); + painter->drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2); + + if (hasFocus) { + QColor softHighlight = highlightedOutline; + softHighlight.setAlpha(40); + painter->setPen(softHighlight); + painter->drawRoundedRect(r.adjusted(1, 1, -2, -2), 1.7, 1.7); + } + // Draw inner shadow + painter->setPen(d->topShadow()); + painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); + + painter->restore(); + + } + break; + case PE_IndicatorCheckBox: + painter->save(); + if (const QStyleOptionButton *checkbox = qstyleoption_cast(option)) { + painter->setRenderHint(QPainter::Antialiasing, true); + painter->translate(0.5, 0.5); + rect = rect.adjusted(0, 0, -1, -1); + + QColor pressedColor = mergedColors(option->palette.base().color(), option->palette.foreground().color(), 85); + painter->setBrush(Qt::NoBrush); + + // Gradient fill + QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); + gradient.setColorAt(0, (state & State_Sunken) ? pressedColor : option->palette.base().color().darker(115)); + gradient.setColorAt(0.15, (state & State_Sunken) ? pressedColor : option->palette.base().color()); + gradient.setColorAt(1, (state & State_Sunken) ? pressedColor : option->palette.base().color()); + + painter->setBrush((state & State_Sunken) ? QBrush(pressedColor) : gradient); + painter->setPen(QPen(outline.lighter(110), 1)); + + if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) + painter->setPen(QPen(highlightedOutline, 1)); + painter->drawRect(rect); + + if (checkbox->state & (State_On | State_Sunken | State_NoChange)) { + QColor checkMarkColor = option->palette.text().color().darker(120); + checkMarkColor.setAlpha(210); + painter->translate(-1, 0.5); + QPen checkPen = QPen(checkMarkColor, 1.8); + painter->setPen(checkPen); + painter->setBrush(Qt::NoBrush); + painter->translate(0.2, 0.0); + + // Draw checkmark + QPainterPath path; + path.moveTo(5, rect.height() / 2.0); + path.lineTo(rect.width() / 2.0 - 0, rect.height() - 3); + path.lineTo(rect.width() - 2.5, 3); + painter->drawPath(path.translated(rect.topLeft())); + + if (checkbox->state & State_NoChange) { + QColor bgc = option->palette.background().color(); + bgc.setAlpha(127); + painter->fillRect(rect.adjusted(1, 1, -1, -1), bgc); + } + + } + } + painter->restore(); + break; + case PE_IndicatorRadioButton: + painter->save(); + { + QColor pressedColor = mergedColors(option->palette.base().color(), option->palette.foreground().color(), 85); + painter->setBrush((state & State_Sunken) ? pressedColor : option->palette.base().color()); + painter->setRenderHint(QPainter::Antialiasing, true); + QPainterPath circle; + circle.addEllipse(rect.center() + QPoint(1.0, 1.0), 6.5, 6.5); + painter->setPen(QPen(option->palette.background().color().darker(150), 1)); + if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) + painter->setPen(QPen(highlightedOutline, 1)); + painter->drawPath(circle); + + if (state & (State_On )) { + circle = QPainterPath(); + circle.addEllipse(rect.center() + QPoint(1, 1), 2.8, 2.8); + QColor checkMarkColor = option->palette.text().color().darker(120); + checkMarkColor.setAlpha(200); + painter->setPen(checkMarkColor); + checkMarkColor.setAlpha(180); + painter->setBrush(checkMarkColor); + painter->drawPath(circle); + } + } + painter->restore(); + break; + case PE_IndicatorToolBarHandle: + { + //draw grips + if (option->state & State_Horizontal) { + for (int i = -3 ; i < 2 ; i += 3) { + for (int j = -8 ; j < 10 ; j += 3) { + painter->fillRect(rect.center().x() + i, rect.center().y() + j, 2, 2, d->lightShade()); + painter->fillRect(rect.center().x() + i, rect.center().y() + j, 1, 1, d->darkShade()); + } + } + } else { //vertical toolbar + for (int i = -6 ; i < 12 ; i += 3) { + for (int j = -3 ; j < 2 ; j += 3) { + painter->fillRect(rect.center().x() + i, rect.center().y() + j, 2, 2, d->lightShade()); + painter->fillRect(rect.center().x() + i, rect.center().y() + j, 1, 1, d->darkShade()); + } + } + } + break; + } + case PE_FrameDefaultButton: + break; + case PE_FrameFocusRect: + if (const QStyleOptionFocusRect *fropt = qstyleoption_cast(option)) { + //### check for d->alt_down + if (!(fropt->state & State_KeyboardFocusChange)) + return; + QRect rect = option->rect; + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->translate(0.5, 0.5); + QColor fillcolor = highlightedOutline; + fillcolor.setAlpha(80); + painter->setPen(fillcolor.darker(120)); + fillcolor.setAlpha(30); + QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); + gradient.setColorAt(0, fillcolor.lighter(160)); + gradient.setColorAt(1, fillcolor); + painter->setBrush(gradient); + painter->drawRoundedRect(option->rect.adjusted(0, 0, -1, -1), 1, 1); + painter->restore(); + } + break; + case PE_PanelButtonCommand: + { + bool isDefault = false; + bool isFlat = false; + bool isDown = (option->state & State_Sunken) || (option->state & State_On); + QRect r; + + if (const QStyleOptionButton *button = qstyleoption_cast(option)) { + isDefault = (button->features & QStyleOptionButton::DefaultButton) && (button->state & State_Enabled); + isFlat = (button->features & QStyleOptionButton::Flat); + } + + if (isFlat && !isDown) { + if (isDefault) { + r = option->rect.adjusted(0, 1, 0, -1); + painter->setPen(QPen(Qt::black, 0)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.top()), + QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.left(), r.top() + 2), + QPoint(r.left(), r.bottom() - 2)), + QLine(QPoint(r.right(), r.top() + 2), + QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left() + 2, r.bottom()), + QPoint(r.right() - 2, r.bottom())) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points, 4); + } + return; + } + + BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(isDefault)) + r = rect.adjusted(0, 1, -1, 0); + + bool isEnabled = option->state & State_Enabled; + bool hasFocus = (option->state & State_HasFocus && option->state & State_KeyboardFocusChange); + QColor buttonColor = d->buttonColor(option->palette); + + QColor darkOutline = outline; + if (hasFocus | isDefault) { + darkOutline = highlightedOutline; + } + + if (isDefault) + buttonColor = mergedColors(buttonColor, highlightedOutline.lighter(130), 90); + + p->setRenderHint(QPainter::Antialiasing, true); + p->translate(0.5, -0.5); + + QLinearGradient gradient = qt_fusion_gradient(rect, (isEnabled && option->state & State_MouseOver ) ? buttonColor : buttonColor.darker(104)); + p->setPen(Qt::transparent); + p->setBrush(isDown ? QBrush(buttonColor.darker(110)) : gradient); + p->drawRoundedRect(r, 2.0, 2.0); + p->setBrush(Qt::NoBrush); + + // Outline + p->setPen(!isEnabled ? QPen(darkOutline.lighter(115)) : QPen(darkOutline, 1)); + p->drawRoundedRect(r, 2.0, 2.0); + + p->setPen(d->innerContrastLine()); + p->drawRoundedRect(r.adjusted(1, 1, -1, -1), 2.0, 2.0); + + END_STYLE_PIXMAPCACHE + } + break; + case PE_FrameTabWidget: + painter->save(); + painter->fillRect(option->rect.adjusted(0, 0, -1, -1), tabFrameColor); + if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast(option)) { + QColor borderColor = outline.lighter(110); + QRect rect = option->rect.adjusted(0, 0, -1, -1); + + // Shadow outline + if (twf->shape != QTabBar::RoundedSouth) { + rect.adjust(0, 0, 0, -1); + QColor alphaShadow(Qt::black); + alphaShadow.setAlpha(15); + painter->setPen(alphaShadow); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->setPen(borderColor); + } + + // outline + painter->setPen(outline); + painter->drawRect(rect); + + // Inner frame highlight + painter->setPen(d->innerContrastLine()); + painter->drawRect(rect.adjusted(1, 1, -1, -1)); + + } + painter->restore(); + break ; + + case PE_FrameStatusBarItem: + break; + case PE_IndicatorTabClose: + { + Q_D(const QFusionStyle); + if (d->tabBarcloseButtonIcon.isNull()) + d->tabBarcloseButtonIcon = standardIcon(SP_DialogCloseButton, option, widget); + if ((option->state & State_Enabled) && (option->state & State_MouseOver)) + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); + proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); + } + break; + case PE_PanelMenu: { + painter->save(); + QColor menuBackground = option->palette.base().color().lighter(108); + QColor borderColor = option->palette.background().color().darker(160); + painter->setPen(borderColor); + painter->setBrush(menuBackground); + painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); + painter->restore(); + } + break; + + default: + QCommonStyle::drawPrimitive(elem, option, painter, widget); + break; + } +} + +/*! + \reimp +*/ +void QFusionStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, + const QWidget *widget) const +{ + Q_D (const QFusionStyle); + QRect rect = option->rect; + QColor outline = d->outline(option->palette); + QColor highlightedOutline = d->highlightedOutline(option->palette); + QColor shadow = d->darkShade(); + + switch (element) { + case CE_ComboBoxLabel: + if (const QStyleOptionComboBox *cb = qstyleoption_cast(option)) { + QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); + painter->save(); + painter->setClipRect(editRect); + if (!cb->currentIcon.isNull()) { + QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal + : QIcon::Disabled; + QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); + QRect iconRect(editRect); + iconRect.setWidth(cb->iconSize.width() + 4); + iconRect = alignedRect(cb->direction, + Qt::AlignLeft | Qt::AlignVCenter, + iconRect.size(), editRect); + if (cb->editable) + painter->fillRect(iconRect, cb->palette.brush(QPalette::Base)); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); + + if (cb->direction == Qt::RightToLeft) + editRect.translate(-4 - cb->iconSize.width(), 0); + else + editRect.translate(cb->iconSize.width() + 4, 0); + } + if (!cb->currentText.isEmpty() && !cb->editable) { + proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), + visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), + cb->palette, cb->state & State_Enabled, cb->currentText, + cb->editable ? QPalette::Text : QPalette::ButtonText); + } + painter->restore(); + } + break; + case CE_Splitter: + { + // Dont draw handle for single pixel splitters + if (option->rect.width() > 1 && option->rect.height() > 1) { + //draw grips + if (option->state & State_Horizontal) { + for (int j = -6 ; j< 12 ; j += 3) { + painter->fillRect(rect.center().x() + 1, rect.center().y() + j, 2, 2, d->lightShade()); + painter->fillRect(rect.center().x() + 1, rect.center().y() + j, 1, 1, d->darkShade()); + } + } else { + for (int i = -6; i< 12 ; i += 3) { + painter->fillRect(rect.center().x() + i, rect.center().y(), 2, 2, d->lightShade()); + painter->fillRect(rect.center().x() + i, rect.center().y(), 1, 1, d->darkShade()); + } + } + } + break; + } + case CE_RubberBand: + if (qstyleoption_cast(option)) { + QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight); + painter->save(); + QColor penColor = highlight.darker(120); + penColor.setAlpha(180); + painter->setPen(penColor); + QColor dimHighlight(qMin(highlight.red()/2 + 110, 255), + qMin(highlight.green()/2 + 110, 255), + qMin(highlight.blue()/2 + 110, 255)); + dimHighlight.setAlpha(widget && widget->isTopLevel() ? 255 : 80); + QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y())); + gradient.setColorAt(0, dimHighlight.lighter(120)); + gradient.setColorAt(1, dimHighlight); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->translate(0.5, 0.5); + painter->setBrush(dimHighlight); + painter->drawRoundedRect(option->rect.adjusted(0, 0, -1, -1), 1, 1); + QColor innerLine = Qt::white; + innerLine.setAlpha(40); + painter->setPen(innerLine); + painter->drawRoundedRect(option->rect.adjusted(1, 1, -2, -2), 1, 1); + painter->restore(); + return; + } + case CE_SizeGrip: + painter->save(); + { + //draw grips + for (int i = -6; i< 12 ; i += 3) { + for (int j = -6 ; j< 12 ; j += 3) { + if ((option->direction == Qt::LeftToRight && i > -j) || (option->direction == Qt::RightToLeft && j > i) ) { + painter->fillRect(rect.center().x() + i, rect.center().y() + j, 2, 2, d->lightShade()); + painter->fillRect(rect.center().x() + i, rect.center().y() + j, 1, 1, d->darkShade()); + } + } + } + } + painter->restore(); + break; + case CE_ToolBar: + if (const QStyleOptionToolBar *toolBar = qstyleoption_cast(option)) { + // Reserve the beveled appearance only for mainwindow toolbars + if (!(widget && qobject_cast (widget->parentWidget()))) + break; + + // Draws the light line above and the dark line below menu bars and + // tool bars. + QLinearGradient gradient(option->rect.topLeft(), option->rect.bottomLeft()); + if (!option->state & State_Horizontal) + gradient = QLinearGradient(rect.left(), rect.center().y(), + rect.right(), rect.center().y()); + gradient.setColorAt(0, option->palette.window().color().lighter(104)); + gradient.setColorAt(1, option->palette.window().color()); + painter->fillRect(option->rect, gradient); + + QColor light = d->lightShade(); + QColor shadow = d->darkShade(); + + QPen oldPen = painter->pen(); + if (toolBar->toolBarArea == Qt::TopToolBarArea) { + if (toolBar->positionOfLine == QStyleOptionToolBar::End + || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { + // The end and onlyone top toolbar lines draw a double + // line at the bottom to blend with the central + // widget. + painter->setPen(light); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); + painter->setPen(shadow); + painter->drawLine(option->rect.left(), option->rect.bottom() - 1, + option->rect.right(), option->rect.bottom() - 1); + } else { + // All others draw a single dark line at the bottom. + painter->setPen(shadow); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); + } + // All top toolbar lines draw a light line at the top. + painter->setPen(light); + painter->drawLine(option->rect.topLeft(), option->rect.topRight()); + } else if (toolBar->toolBarArea == Qt::BottomToolBarArea) { + if (toolBar->positionOfLine == QStyleOptionToolBar::End + || toolBar->positionOfLine == QStyleOptionToolBar::Middle) { + // The end and middle bottom tool bar lines draw a dark + // line at the bottom. + painter->setPen(shadow); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); + } + if (toolBar->positionOfLine == QStyleOptionToolBar::Beginning + || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { + // The beginning and only one tool bar lines draw a + // double line at the bottom to blend with the + // status bar. + // ### The styleoption could contain whether the + // main window has a menu bar and a status bar, and + // possibly dock widgets. + painter->setPen(shadow); + painter->drawLine(option->rect.left(), option->rect.bottom() - 1, + option->rect.right(), option->rect.bottom() - 1); + painter->setPen(light); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); + } + if (toolBar->positionOfLine == QStyleOptionToolBar::End) { + painter->setPen(shadow); + painter->drawLine(option->rect.topLeft(), option->rect.topRight()); + painter->setPen(light); + painter->drawLine(option->rect.left(), option->rect.top() + 1, + option->rect.right(), option->rect.top() + 1); + + } else { + // All other bottom toolbars draw a light line at the top. + painter->setPen(light); + painter->drawLine(option->rect.topLeft(), option->rect.topRight()); + } + } + if (toolBar->toolBarArea == Qt::LeftToolBarArea) { + if (toolBar->positionOfLine == QStyleOptionToolBar::Middle + || toolBar->positionOfLine == QStyleOptionToolBar::End) { + // The middle and left end toolbar lines draw a light + // line to the left. + painter->setPen(light); + painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); + } + if (toolBar->positionOfLine == QStyleOptionToolBar::End) { + // All other left toolbar lines draw a dark line to the right + painter->setPen(shadow); + painter->drawLine(option->rect.right() - 1, option->rect.top(), + option->rect.right() - 1, option->rect.bottom()); + painter->setPen(light); + painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); + } else { + // All other left toolbar lines draw a dark line to the right + painter->setPen(shadow); + painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); + } + } else if (toolBar->toolBarArea == Qt::RightToolBarArea) { + if (toolBar->positionOfLine == QStyleOptionToolBar::Middle + || toolBar->positionOfLine == QStyleOptionToolBar::End) { + // Right middle and end toolbar lines draw the dark right line + painter->setPen(shadow); + painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); + } + if (toolBar->positionOfLine == QStyleOptionToolBar::End + || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { + // The right end and single toolbar draws the dark + // line on its left edge + painter->setPen(shadow); + painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); + // And a light line next to it + painter->setPen(light); + painter->drawLine(option->rect.left() + 1, option->rect.top(), + option->rect.left() + 1, option->rect.bottom()); + } else { + // Other right toolbars draw a light line on its left edge + painter->setPen(light); + painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); + } + } + painter->setPen(oldPen); + } + break; + case CE_DockWidgetTitle: + painter->save(); + if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast(option)) { + bool verticalTitleBar = dwOpt->verticalTitleBar; + + QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget); + if (verticalTitleBar) { + QRect rect = dwOpt->rect; + QRect r = rect; + QSize s = r.size(); + s.transpose(); + r.setSize(s); + titleRect = QRect(r.left() + rect.bottom() + - titleRect.bottom(), + r.top() + titleRect.left() - rect.left(), + titleRect.height(), titleRect.width()); + } + + if (!dwOpt->title.isEmpty()) { + QString titleText + = painter->fontMetrics().elidedText(dwOpt->title, + Qt::ElideRight, titleRect.width()); + proxy()->drawItemText(painter, + titleRect, + Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, + dwOpt->state & State_Enabled, titleText, + QPalette::WindowText); + } + } + painter->restore(); + break; + case CE_HeaderSection: + painter->save(); + // Draws the header in tables. + if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); + pixmapName += QString::number(- int(header->position)); + pixmapName += QString::number(- int(header->orientation)); + + QPixmap cache; + if (!QPixmapCache::find(pixmapName, cache)) { + cache = styleCachePixmap(rect.size()); + cache.fill(Qt::transparent); + QRect pixmapRect(0, 0, rect.width(), rect.height()); + QPainter cachePainter(&cache); + QColor buttonColor = d->buttonColor(option->palette); + QColor gradientStopColor; + QColor gradientStartColor = buttonColor.lighter(104); + gradientStopColor = buttonColor.darker(102); + QLinearGradient gradient(pixmapRect.topLeft(), pixmapRect.bottomLeft()); + + if (option->palette.background().gradient()) { + gradient.setStops(option->palette.background().gradient()->stops()); + } else { + QColor midColor1 = mergedColors(gradientStartColor, gradientStopColor, 60); + QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 40); + gradient.setColorAt(0, gradientStartColor); + gradient.setColorAt(0.5, midColor1); + gradient.setColorAt(0.501, midColor2); + gradient.setColorAt(0.92, gradientStopColor); + gradient.setColorAt(1, gradientStopColor.darker(104)); + } + cachePainter.fillRect(pixmapRect, gradient); + cachePainter.setPen(d->innerContrastLine()); + cachePainter.setBrush(Qt::NoBrush); + cachePainter.drawLine(pixmapRect.topLeft(), pixmapRect.topRight()); + cachePainter.setPen(d->outline(option->palette)); + cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight()); + + if (header->orientation == Qt::Horizontal && + header->position != QStyleOptionHeader::End && + header->position != QStyleOptionHeader::OnlyOneSection) { + cachePainter.setPen(QColor(0, 0, 0, 40)); + cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight() + QPoint(0, -1)); + cachePainter.setPen(d->innerContrastLine()); + cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 0), pixmapRect.bottomRight() + QPoint(-1, -1)); + } else if (header->orientation == Qt::Vertical) { + cachePainter.setPen(d->outline(option->palette)); + cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight()); + } + cachePainter.end(); + QPixmapCache::insert(pixmapName, cache); + } + painter->drawPixmap(rect.topLeft(), cache); + } + painter->restore(); + break; + case CE_ProgressBarGroove: + painter->save(); + { + painter->setRenderHint(QPainter::Antialiasing, true); + painter->translate(0.5, 0.5); + + QColor shadowAlpha = Qt::black; + shadowAlpha.setAlpha(16); + painter->setPen(shadowAlpha); + painter->drawLine(rect.topLeft() - QPoint(0, 1), rect.topRight() - QPoint(0, 1)); + + painter->setBrush(option->palette.base()); + painter->setPen(QPen(outline, 0)); + painter->drawRoundedRect(rect.adjusted(0, 0, -1, -1), 2, 2); + + // Inner shadow + painter->setPen(d->topShadow()); + painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), + QPoint(rect.right() - 1, rect.top() + 1)); + } + painter->restore(); + break; + case CE_ProgressBarContents: + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->translate(0.5, 0.5); + if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { + bool vertical = false; + bool inverted = false; + bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); + bool complete = bar->progress == bar->maximum; + + // Get extra style options if version 2 + vertical = (bar->orientation == Qt::Vertical); + inverted = bar->invertedAppearance; + + // If the orientation is vertical, we use a transform to rotate + // the progress bar 90 degrees clockwise. This way we can use the + // same rendering code for both orientations. + if (vertical) { + rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height + QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0); + m.rotate(90.0); + painter->setTransform(m, true); + } + + int maxWidth = rect.width(); + int minWidth = 0; + qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar + int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth); + + bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; + if (inverted) + reverse = !reverse; + + int step = 0; + QRect progressBar; + QColor highlight = d->highlight(option->palette); + QColor highlightedoutline = highlight.darker(140); + if (qGray(outline.rgb()) > qGray(highlightedoutline.rgb())) + outline = highlightedoutline; + + if (!indeterminate) { + QColor innerShadow(Qt::black); + innerShadow.setAlpha(35); + painter->setPen(innerShadow); + if (!reverse) { + progressBar.setRect(rect.left(), rect.top(), width - 1, rect.height() - 1); + if (!complete) { + painter->drawLine(progressBar.topRight() + QPoint(2, 1), progressBar.bottomRight() + QPoint(2, 0)); + painter->setPen(QPen(highlight.darker(140), 0)); + painter->drawLine(progressBar.topRight() + QPoint(1, 1), progressBar.bottomRight() + QPoint(1, 0)); + } + } else { + progressBar.setRect(rect.right() - width - 1, rect.top(), width + 2, rect.height() - 1); + if (!complete) { + painter->drawLine(progressBar.topLeft() + QPoint(-2, 1), progressBar.bottomLeft() + QPoint(-2, 0)); + painter->setPen(QPen(highlight.darker(140), 0)); + painter->drawLine(progressBar.topLeft() + QPoint(-1, 1), progressBar.bottomLeft() + QPoint(-1, 0)); + } + } + } else { + progressBar.setRect(rect.left(), rect.top(), rect.width() - 1, rect.height() - 1); + } + + if (indeterminate || bar->progress > bar->minimum) { + + painter->setPen(QPen(outline, 0)); + + QColor highlightedGradientStartColor = highlight.lighter(120); + QColor highlightedGradientStopColor = highlight; + QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y())); + gradient.setColorAt(0, highlightedGradientStartColor); + gradient.setColorAt(1, highlightedGradientStopColor); + + painter->setBrush(gradient); + + painter->save(); + if (!complete && !indeterminate) + painter->setClipRect(progressBar.adjusted(-1, -1, -1, 1)); + QRect fillRect = progressBar.adjusted( !indeterminate && !complete && reverse ? -2 : 0, 0, + indeterminate || complete || reverse ? 0 : 2, 0); + painter->drawRoundedRect(fillRect, 2, 2); + painter->restore(); + + painter->setBrush(Qt::NoBrush); + painter->setPen(QColor(255, 255, 255, 50)); + painter->drawRoundedRect(progressBar.adjusted(1, 1, -1, -1), 1, 1); + + if (!indeterminate) { + (const_cast(d))->stopAnimation(option->styleObject); + } else { + highlightedGradientStartColor.setAlpha(120); + painter->setPen(QPen(highlightedGradientStartColor, 9.0)); + painter->setClipRect(progressBar.adjusted(1, 1, -1, -1)); +#ifndef QT_NO_ANIMATION + if (QProgressStyleAnimation *animation = qobject_cast(d->animation(option->styleObject))) + step = animation->animationStep() % 22; + else + (const_cast(d))->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject)); +#endif + for (int x = progressBar.left() - rect.height(); x < rect.right() ; x += 22) + painter->drawLine(x + step, progressBar.bottom() + 1, + x + rect.height() + step, progressBar.top() - 2); + } + } + } + painter->restore(); + break; + case CE_ProgressBarLabel: + if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { + QRect leftRect; + QRect rect = bar->rect; + QColor textColor = option->palette.text().color(); + QColor alternateTextColor = option->palette.highlightedText().color(); + + painter->save(); + bool vertical = false, inverted = false; + vertical = (bar->orientation == Qt::Vertical); + inverted = bar->invertedAppearance; + if (vertical) + rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height + const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / + qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) + leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); + if (vertical) + leftRect.translate(rect.width() - progressIndicatorPos, 0); + + bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) || + ((bar->direction == Qt::LeftToRight) && inverted))); + + QRegion rightRect = rect; + rightRect = rightRect.subtracted(leftRect); + painter->setClipRegion(rightRect); + painter->setPen(flip ? alternateTextColor : textColor); + painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); + if (!leftRect.isNull()) { + painter->setPen(flip ? textColor : alternateTextColor); + painter->setClipRect(leftRect); + painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); + } + painter->restore(); + } + break; + case CE_MenuBarItem: + painter->save(); + if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(option)) + { + QStyleOptionMenuItem item = *mbi; + item.rect = mbi->rect.adjusted(0, 1, 0, -3); + QColor highlightOutline = option->palette.highlight().color().darker(125); + painter->fillRect(rect, option->palette.window()); + + QCommonStyle::drawControl(element, &item, painter, widget); + + bool act = mbi->state & State_Selected && mbi->state & State_Sunken; + bool dis = !(mbi->state & State_Enabled); + + QRect r = option->rect; + if (act) { + painter->setBrush(option->palette.highlight().color()); + painter->setPen(QPen(highlightOutline, 0)); + painter->drawRect(r.adjusted(0, 0, -1, -1)); + + // painter->drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2); + + //draw text + QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; + uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; + if (!styleHint(SH_UnderlineShortcut, mbi, widget)) + alignment |= Qt::TextHideMnemonic; + proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole); + } else { + + QColor shadow = mergedColors(option->palette.background().color().darker(120), + outline.lighter(140), 60); + painter->setPen(QPen(shadow)); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); + } + } + painter->restore(); + break; + case CE_MenuItem: + painter->save(); + // Draws one item in a popup menu. + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { + QColor highlightOutline = highlightedOutline; + QColor highlight = option->palette.highlight().color(); + if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { + int w = 0; + if (!menuItem->text.isEmpty()) { + painter->setFont(menuItem->font); + proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, + menuItem->palette, menuItem->state & State_Enabled, menuItem->text, + QPalette::Text); + w = menuItem->fontMetrics.width(menuItem->text) + 5; + } + painter->setPen(shadow.lighter(106)); + bool reverse = menuItem->direction == Qt::RightToLeft; + painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(), + menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y()); + painter->restore(); + break; + } + bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; + if (selected) { + QRect r = option->rect; + painter->fillRect(r, highlight); + painter->setPen(QPen(highlightOutline, 0)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())), + QLine(QPoint(r.left(), r.top()), QPoint(r.left(), r.bottom())), + QLine(QPoint(r.right() , r.top()), QPoint(r.right(), r.bottom())), + }; + painter->drawLines(lines, 4); + } + bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; + bool checked = menuItem->checked; + bool sunken = menuItem->state & State_Sunken; + bool enabled = menuItem->state & State_Enabled; + + bool ignoreCheckMark = false; + int checkcol = qMax(menuItem->maxIconWidth, 20); + + if (qobject_cast(widget)) + ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate + + if (!ignoreCheckMark) { + // Check + QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 14, 14); + checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); + if (checkable) { + if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) { + // Radio button + if (checked || sunken) { + painter->setRenderHint(QPainter::Antialiasing); + painter->setPen(Qt::NoPen); + + QPalette::ColorRole textRole = !enabled ? QPalette::Text: + selected ? QPalette::HighlightedText : QPalette::ButtonText; + painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole)); + painter->drawEllipse(checkRect.adjusted(4, 4, -4, -4)); + } + } else { + // Check box + if (menuItem->icon.isNull()) { + QStyleOptionButton box; + box.QStyleOption::operator=(*option); + box.rect = checkRect; + if (checked) + box.state |= State_On; + proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); + } + } + } + } else { //ignore checkmark + if (menuItem->icon.isNull()) + checkcol = 0; + else + checkcol = menuItem->maxIconWidth; + } + + // Text and icon, ripped from windows style + bool dis = !(menuItem->state & State_Enabled); + bool act = menuItem->state & State_Selected; + const QStyleOption *opt = option; + const QStyleOptionMenuItem *menuitem = menuItem; + + QPainter *p = painter; + QRect vCheckRect = visualRect(opt->direction, menuitem->rect, + QRect(menuitem->rect.x() + 4, menuitem->rect.y(), + checkcol, menuitem->rect.height())); + if (!menuItem->icon.isNull()) { + QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; + if (act && !dis) + mode = QIcon::Active; + QPixmap pixmap; + + int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); + QSize iconSize(smallIconSize, smallIconSize); + if (const QComboBox *combo = qobject_cast(widget)) + iconSize = combo->iconSize(); + if (checked) + pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); + else + pixmap = menuItem->icon.pixmap(iconSize, mode); + + int pixw = pixmap.width(); + int pixh = pixmap.height(); + + QRect pmr(0, 0, pixw, pixh); + pmr.moveCenter(vCheckRect.center()); + painter->setPen(menuItem->palette.text().color()); + if (checkable && checked) { + QStyleOption opt = *option; + if (act) { + QColor activeColor = mergedColors(option->palette.background().color(), + option->palette.highlight().color()); + opt.palette.setBrush(QPalette::Button, activeColor); + } + opt.state |= State_Sunken; + opt.rect = vCheckRect; + proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); + } + painter->drawPixmap(pmr.topLeft(), pixmap); + } + if (selected) { + painter->setPen(menuItem->palette.highlightedText().color()); + } else { + painter->setPen(menuItem->palette.text().color()); + } + int x, y, w, h; + menuitem->rect.getRect(&x, &y, &w, &h); + int tab = menuitem->tabWidth; + QColor discol; + if (dis) { + discol = menuitem->palette.text().color(); + p->setPen(discol); + } + int xm = windowsItemFrame + checkcol + windowsItemHMargin + 2; + int xpos = menuitem->rect.x() + xm; + + QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); + QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); + QString s = menuitem->text; + if (!s.isEmpty()) { // draw text + p->save(); + int t = s.indexOf(QLatin1Char('\t')); + int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; + if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) + text_flags |= Qt::TextHideMnemonic; + text_flags |= Qt::AlignLeft; + if (t >= 0) { + QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, + QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { + p->setPen(menuitem->palette.light().color()); + p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1)); + p->setPen(discol); + } + p->drawText(vShortcutRect, text_flags, s.mid(t + 1)); + s = s.left(t); + } + QFont font = menuitem->font; + // font may not have any "hard" flags set. We override + // the point size so that when it is resolved against the device, this font will win. + // This is mainly to handle cases where someone sets the font on the window + // and then the combo inherits it and passes it onward. At that point the resolve mask + // is very, very weak. This makes it stonger. + font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF()); + + if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) + font.setBold(true); + + p->setFont(font); + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { + p->setPen(menuitem->palette.light().color()); + p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t)); + p->setPen(discol); + } + p->drawText(vTextRect, text_flags, s.left(t)); + p->restore(); + } + + // Arrow + if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow + int dim = (menuItem->rect.height() - 4) / 2; + PrimitiveElement arrow; + arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; + int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim; + QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, + QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim)); + QStyleOptionMenuItem newMI = *menuItem; + newMI.rect = vSubMenuRect; + newMI.state = !enabled ? State_None : State_Enabled; + if (selected) + newMI.palette.setColor(QPalette::Foreground, + newMI.palette.highlightedText().color()); + proxy()->drawPrimitive(arrow, &newMI, painter, widget); + } + } + painter->restore(); + break; + case CE_MenuHMargin: + case CE_MenuVMargin: + break; + case CE_MenuEmptyArea: + break; + case CE_PushButton: + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { + proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); + QStyleOptionButton subopt = *btn; + subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); + proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget); + } + break; + case CE_PushButtonLabel: + if (const QStyleOptionButton *button = qstyleoption_cast(option)) { + QRect ir = button->rect; + uint tf = Qt::AlignVCenter; + if (styleHint(SH_UnderlineShortcut, button, widget)) + tf |= Qt::TextShowMnemonic; + else + tf |= Qt::TextHideMnemonic; + + if (!button->icon.isNull()) { + //Center both icon and text + QPoint point; + + QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal + : QIcon::Disabled; + if (mode == QIcon::Normal && button->state & State_HasFocus) + mode = QIcon::Active; + QIcon::State state = QIcon::Off; + if (button->state & State_On) + state = QIcon::On; + + QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); + int w = pixmap.width(); + int h = pixmap.height(); + + if (!button->text.isEmpty()) + w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2; + + point = QPoint(ir.x() + ir.width() / 2 - w / 2, + ir.y() + ir.height() / 2 - h / 2); + + if (button->direction == Qt::RightToLeft) + point.rx() += pixmap.width(); + + painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap); + + if (button->direction == Qt::RightToLeft) + ir.translate(-point.x() - 2, 0); + else + ir.translate(point.x() + pixmap.width(), 0); + + // left-align text if there is + if (!button->text.isEmpty()) + tf |= Qt::AlignLeft; + + } else { + tf |= Qt::AlignHCenter; + } + + if (button->features & QStyleOptionButton::HasMenu) + ir = ir.adjusted(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget), 0); + proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled), + button->text, QPalette::ButtonText); + } + break; + case CE_MenuBarEmptyArea: + painter->save(); + { + painter->fillRect(rect, option->palette.window()); + if (widget && qobject_cast(widget->parentWidget())) { + QColor shadow = mergedColors(option->palette.background().color().darker(120), + outline.lighter(140), 60); + painter->setPen(QPen(shadow)); + painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); + } + } + painter->restore(); + break; + case CE_TabBarTabShape: + painter->save(); + if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { + + bool rtlHorTabs = (tab->direction == Qt::RightToLeft + && (tab->shape == QTabBar::RoundedNorth + || tab->shape == QTabBar::RoundedSouth)); + bool selected = tab->state & State_Selected; + bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End) + || (rtlHorTabs + && tab->position == QStyleOptionTab::Beginning)); + bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; + int tabOverlap = pixelMetric(PM_TabBarTabOverlap, option, widget); + rect = option->rect.adjusted(0, 0, (onlyOne || lastTab) ? 0 : tabOverlap, 0); + + QRect r2(rect); + int x1 = r2.left(); + int x2 = r2.right(); + int y1 = r2.top(); + int y2 = r2.bottom(); + + painter->setPen(d->innerContrastLine()); + + QTransform rotMatrix; + bool flip = false; + painter->setPen(shadow); + + switch (tab->shape) { + case QTabBar::RoundedNorth: + break; + case QTabBar::RoundedSouth: + rotMatrix.rotate(180); + rotMatrix.translate(0, -rect.height() + 1); + rotMatrix.scale(-1, 1); + painter->setTransform(rotMatrix, true); + break; + case QTabBar::RoundedWest: + rotMatrix.rotate(180 + 90); + rotMatrix.scale(-1, 1); + flip = true; + painter->setTransform(rotMatrix, true); + break; + case QTabBar::RoundedEast: + rotMatrix.rotate(90); + rotMatrix.translate(0, - rect.width() + 1); + flip = true; + painter->setTransform(rotMatrix, true); + break; + default: + painter->restore(); + QCommonStyle::drawControl(element, tab, painter, widget); + return; + } + + if (flip) { + QRect tmp = rect; + rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width()); + int temp = x1; + x1 = y1; + y1 = temp; + temp = x2; + x2 = y2; + y2 = temp; + } + + painter->setRenderHint(QPainter::Antialiasing, true); + painter->translate(0.5, 0.5); + + QColor tabFrameColor = tab->features & QStyleOptionTab::HasFrame ? + d->tabFrameColor(option->palette) : + option->palette.window().color(); + + QLinearGradient fillGradient(rect.topLeft(), rect.bottomLeft()); + QLinearGradient outlineGradient(rect.topLeft(), rect.bottomLeft()); + QPen outlinePen = outline.lighter(110); + if (selected) { + fillGradient.setColorAt(0, tabFrameColor.lighter(104)); + // QColor highlight = option->palette.highlight().color(); + // if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) { + // fillGradient.setColorAt(0, highlight.lighter(130)); + // outlineGradient.setColorAt(0, highlight.darker(130)); + // fillGradient.setColorAt(0.14, highlight); + // outlineGradient.setColorAt(0.14, highlight.darker(130)); + // fillGradient.setColorAt(0.1401, tabFrameColor); + // outlineGradient.setColorAt(0.1401, highlight.darker(130)); + // } + fillGradient.setColorAt(1, tabFrameColor); + outlineGradient.setColorAt(1, outline); + outlinePen = QPen(outlineGradient, 1); + } else { + fillGradient.setColorAt(0, tabFrameColor.darker(108)); + fillGradient.setColorAt(0.85, tabFrameColor.darker(108)); + fillGradient.setColorAt(1, tabFrameColor.darker(116)); + } + + QRect drawRect = rect.adjusted(0, selected ? 0 : 2, 0, 3); + painter->setPen(outlinePen); + painter->save(); + painter->setClipRect(rect.adjusted(-1, -1, 1, selected ? -2 : -3)); + painter->setBrush(fillGradient); + painter->drawRoundedRect(drawRect.adjusted(0, 0, -1, -1), 2.0, 2.0); + painter->setBrush(Qt::NoBrush); + painter->setPen(d->innerContrastLine()); + painter->drawRoundedRect(drawRect.adjusted(1, 1, -2, -1), 2.0, 2.0); + painter->restore(); + + if (selected) { + painter->fillRect(rect.left() + 1, rect.bottom() - 1, rect.width() - 2, rect.bottom() - 1, tabFrameColor); + painter->fillRect(QRect(rect.bottomRight() + QPoint(-2, -1), QSize(1, 1)), d->innerContrastLine()); + painter->fillRect(QRect(rect.bottomLeft() + QPoint(0, -1), QSize(1, 1)), d->innerContrastLine()); + painter->fillRect(QRect(rect.bottomRight() + QPoint(-1, -1), QSize(1, 1)), d->innerContrastLine()); + } + } + painter->restore(); + break; + default: + QCommonStyle::drawControl(element,option,painter,widget); + break; + } +} + +/*! + \reimp +*/ +QPalette QFusionStyle::standardPalette () const +{ + QPalette palette = QCommonStyle::standardPalette(); + palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); + palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126)); + palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126)); + + QColor backGround(239, 235, 231); + + QColor light = backGround.lighter(150); + QColor base = Qt::white; + QColor dark = QColor(170, 156, 143).darker(110); + dark = backGround.darker(150); + QColor darkDisabled = QColor(209, 200, 191).darker(110); + + //### Find the correct disabled text color + palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190)); + + palette.setBrush(QPalette::Window, backGround); + palette.setBrush(QPalette::Mid, backGround.darker(130)); + palette.setBrush(QPalette::Light, light); + + palette.setBrush(QPalette::Active, QPalette::Base, base); + palette.setBrush(QPalette::Inactive, QPalette::Base, base); + palette.setBrush(QPalette::Disabled, QPalette::Base, backGround); + + palette.setBrush(QPalette::Midlight, palette.mid().color().lighter(110)); + + palette.setBrush(QPalette::All, QPalette::Dark, dark); + palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); + + QColor button = backGround; + + palette.setBrush(QPalette::Button, button); + + QColor shadow = dark.darker(135); + palette.setBrush(QPalette::Shadow, shadow); + palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.lighter(150)); + palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff))); + + return palette; +} + +/*! + \reimp +*/ +void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const +{ + + Q_D (const QFusionStyle); + + QColor buttonColor = d->buttonColor(option->palette); + QColor gradientStartColor = buttonColor.lighter(118); + QColor gradientStopColor = buttonColor; + QColor outline = d->outline(option->palette); + + QColor alphaCornerColor; + if (widget) { + // ### backgroundrole/foregroundrole should be part of the style option + alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), outline); + } else { + alphaCornerColor = mergedColors(option->palette.background().color(), outline); + } + + switch (control) { + case CC_GroupBox: + painter->save(); + if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { + // Draw frame + QRect textRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); + QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); + + if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { + QStyleOptionFrame frame; + frame.QStyleOption::operator=(*groupBox); + frame.features = groupBox->features; + frame.lineWidth = groupBox->lineWidth; + frame.midLineWidth = groupBox->midLineWidth; + frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); + proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); + } + + // Draw title + if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { + // groupBox->textColor gets the incorrect palette here + painter->setPen(QPen(option->palette.windowText(), 1)); + int alignment = int(groupBox->textAlignment); + if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) + alignment |= Qt::TextHideMnemonic; + + proxy()->drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignLeft | alignment, + groupBox->palette, groupBox->state & State_Enabled, groupBox->text, QPalette::NoRole); + + if (groupBox->state & State_HasFocus) { + QStyleOptionFocusRect fropt; + fropt.QStyleOption::operator=(*groupBox); + fropt.rect = textRect.translated(0, -2); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + } + } + + // Draw checkbox + if (groupBox->subControls & SC_GroupBoxCheckBox) { + QStyleOptionButton box; + box.QStyleOption::operator=(*groupBox); + box.rect = checkBoxRect; + proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); + } + } + painter->restore(); + break; + case CC_SpinBox: + if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { + QPixmap cache; + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); + if (!QPixmapCache::find(pixmapName, cache)) { + + cache = styleCachePixmap(spinBox->rect.size()); + cache.fill(Qt::transparent); + + QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height()); + QRect rect = pixmapRect; + QRect r = rect.adjusted(0, 1, 0, -1); + QPainter cachePainter(&cache); + QColor arrowColor = spinBox->palette.foreground().color(); + arrowColor.setAlpha(220); + + bool isEnabled = (spinBox->state & State_Enabled); + bool hover = isEnabled && (spinBox->state & State_MouseOver); + bool sunken = (spinBox->state & State_Sunken); + bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp); + bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown); + bool hasFocus = (option->state & State_HasFocus); + + QStyleOptionSpinBox spinBoxCopy = *spinBox; + spinBoxCopy.rect = pixmapRect; + QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget); + QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget); + + if (spinBox->frame) { + cachePainter.save(); + cachePainter.setRenderHint(QPainter::Antialiasing, true); + cachePainter.translate(0.5, 0.5); + + // Fill background + cachePainter.setPen(Qt::NoPen); + cachePainter.setBrush(option->palette.base()); + cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2); + + // Draw inner shadow + cachePainter.setPen(d->topShadow()); + cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); + + // Draw button gradient + QColor buttonColor = d->buttonColor(option->palette); + QRect updownRect = upRect.adjusted(0, -2, 0, downRect.height() + 2); + QLinearGradient gradient = qt_fusion_gradient(updownRect, (isEnabled && option->state & State_MouseOver ) ? buttonColor : buttonColor.darker(104)); + + // Draw button gradient + cachePainter.setPen(Qt::NoPen); + cachePainter.setBrush(gradient); + + cachePainter.save(); + cachePainter.setClipRect(updownRect); + cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2); + cachePainter.setPen(QPen(d->innerContrastLine())); + cachePainter.setBrush(Qt::NoBrush); + cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 2, 2); + cachePainter.restore(); + + if ((spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) && upIsActive) { + if (sunken) + cachePainter.fillRect(upRect.adjusted(0, -1, 0, 0), gradientStopColor.darker(110)); + else if (hover) + cachePainter.fillRect(upRect.adjusted(0, -1, 0, 0), d->innerContrastLine()); + } + + if ((spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) && downIsActive) { + if (sunken) + cachePainter.fillRect(downRect.adjusted(0, 0, 0, 1), gradientStopColor.darker(110)); + else if (hover) + cachePainter.fillRect(downRect.adjusted(0, 0, 0, 1), d->innerContrastLine()); + } + + cachePainter.setPen(hasFocus ? d->highlightedOutline(option->palette) : outline); + cachePainter.setBrush(Qt::NoBrush); + cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2); + if (hasFocus) { + QColor softHighlight = option->palette.highlight().color(); + softHighlight.setAlpha(40); + cachePainter.setPen(softHighlight); + cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 1.7, 1.7); + } + cachePainter.restore(); + } + + // outline the up/down buttons + cachePainter.setPen(outline); + if (spinBox->direction == Qt::RightToLeft) { + cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1); + } else { + cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1); + } + + if (upIsActive && sunken) { + cachePainter.setPen(gradientStopColor.darker(130)); + cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.right(), downRect.top()); + cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom()); + cachePainter.drawLine(upRect.left() + 1, upRect.top() - 1, upRect.right(), upRect.top() - 1); + } + + if (downIsActive && sunken) { + cachePainter.setPen(gradientStopColor.darker(130)); + cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1); + cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.right(), downRect.top()); + cachePainter.setPen(gradientStopColor.darker(110)); + cachePainter.drawLine(downRect.left() + 1, downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1); + } + + QColor disabledColor = mergedColors(arrowColor, option->palette.button().color()); + if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { + int centerX = upRect.center().x(); + int centerY = upRect.center().y(); + + // plus/minus + cachePainter.setPen((spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) ? arrowColor : disabledColor); + cachePainter.drawLine(centerX - 1, centerY, centerX + 3, centerY); + cachePainter.drawLine(centerX + 1, centerY - 2, centerX + 1, centerY + 2); + + centerX = downRect.center().x(); + centerY = downRect.center().y(); + cachePainter.setPen((spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) ? arrowColor : disabledColor); + cachePainter.drawLine(centerX - 1, centerY, centerX + 3, centerY); + + } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows){ + // arrows + painter->setRenderHint(QPainter::SmoothPixmapTransform); + + QPixmap upArrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), + (spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) ? arrowColor : disabledColor); + + cachePainter.drawPixmap(QRect(upRect.center().x() - upArrow.width() / 4 + 1, + upRect.center().y() - upArrow.height() / 4 + 1, + upArrow.width()/2, upArrow.height()/2), upArrow); + + QPixmap downArrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), + (spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) ? arrowColor : disabledColor, 180); + cachePainter.drawPixmap(QRect(downRect.center().x() - downArrow.width() / 4 + 1, + downRect.center().y() - downArrow.height() / 4 + 1, + downArrow.width()/2, downArrow.height()/2), downArrow); + } + + cachePainter.end(); + QPixmapCache::insert(pixmapName, cache); + } + painter->drawPixmap(spinBox->rect.topLeft(), cache); + } + break; + case CC_TitleBar: + painter->save(); + if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast(option)) { + const int buttonMargin = 5; + bool active = (titleBar->titleBarState & State_Active); + QRect fullRect = titleBar->rect; + QPalette palette = option->palette; + QColor highlight = option->palette.highlight().color(); + + QColor titleBarFrameBorder(active ? highlight.darker(180): outline.darker(110)); + QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120)); + QColor textColor(active ? 0xffffff : 0xff000000); + QColor textAlphaColor(active ? 0xffffff : 0xff000000 ); + + { + // Fill title bar gradient + QColor titlebarColor = QColor(active ? highlight: palette.background().color()); + QLinearGradient gradient(option->rect.center().x(), option->rect.top(), + option->rect.center().x(), option->rect.bottom()); + + gradient.setColorAt(0, titlebarColor.lighter(114)); + gradient.setColorAt(0.5, titlebarColor.lighter(102)); + gradient.setColorAt(0.51, titlebarColor.darker(104)); + gradient.setColorAt(1, titlebarColor); + painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient); + + // Frame and rounded corners + painter->setPen(titleBarFrameBorder); + + // top outline + painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); + painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); + const QPoint points[5] = { + QPoint(fullRect.left() + 4, fullRect.top() + 1), + QPoint(fullRect.left() + 3, fullRect.top() + 1), + QPoint(fullRect.left() + 2, fullRect.top() + 2), + QPoint(fullRect.left() + 1, fullRect.top() + 3), + QPoint(fullRect.left() + 1, fullRect.top() + 4) + }; + painter->drawPoints(points, 5); + + painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); + const QPoint points2[5] = { + QPoint(fullRect.right() - 3, fullRect.top() + 1), + QPoint(fullRect.right() - 4, fullRect.top() + 1), + QPoint(fullRect.right() - 2, fullRect.top() + 2), + QPoint(fullRect.right() - 1, fullRect.top() + 3), + QPoint(fullRect.right() - 1, fullRect.top() + 4) + }; + painter->drawPoints(points2, 5); + + // draw bottomline + painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom()); + + // top highlight + painter->setPen(titleBarHighlight); + painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1); + } + // draw title + QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); + painter->setPen(active? (titleBar->palette.text().color().lighter(120)) : + titleBar->palette.text().color() ); + // Note workspace also does elliding but it does not use the correct font + QString title = painter->fontMetrics().elidedText(titleBar->text, Qt::ElideRight, textRect.width() - 14); + painter->drawText(textRect.adjusted(1, 1, 1, 1), title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); + painter->setPen(Qt::white); + if (active) + painter->drawText(textRect, title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); + // min button + if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && + !(titleBar->titleBarState& Qt::WindowMinimized)) { + QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); + if (minButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); + qt_fusion_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); + QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin); + painter->setPen(textColor); + painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3, + minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3); + painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4, + minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4); + painter->setPen(textAlphaColor); + painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3, + minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4); + painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3, + minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4); + } + } + // max button + if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && + !(titleBar->titleBarState & Qt::WindowMaximized)) { + QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); + if (maxButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); + qt_fusion_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); + + QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); + + painter->setPen(textColor); + painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); + painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, + maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); + painter->setPen(textAlphaColor); + const QPoint points[4] = { + maxButtonIconRect.topLeft(), + maxButtonIconRect.topRight(), + maxButtonIconRect.bottomLeft(), + maxButtonIconRect.bottomRight() + }; + painter->drawPoints(points, 4); + } + } + + // close button + if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { + QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); + if (closeButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); + qt_fusion_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); + QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); + painter->setPen(textAlphaColor); + const QLine lines[4] = { + QLine(closeIconRect.left() + 1, closeIconRect.top(), + closeIconRect.right(), closeIconRect.bottom() - 1), + QLine(closeIconRect.left(), closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom()), + QLine(closeIconRect.right() - 1, closeIconRect.top(), + closeIconRect.left(), closeIconRect.bottom() - 1), + QLine(closeIconRect.right(), closeIconRect.top() + 1, + closeIconRect.left() + 1, closeIconRect.bottom()) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + closeIconRect.topLeft(), + closeIconRect.topRight(), + closeIconRect.bottomLeft(), + closeIconRect.bottomRight() + }; + painter->drawPoints(points, 4); + + painter->setPen(textColor); + painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom() - 1); + painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1, + closeIconRect.right() - 1, closeIconRect.top() + 1); + } + } + + // normalize button + if ((titleBar->subControls & SC_TitleBarNormalButton) && + (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && + (titleBar->titleBarState & Qt::WindowMinimized)) || + ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && + (titleBar->titleBarState & Qt::WindowMaximized)))) { + QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); + if (normalButtonRect.isValid()) { + + bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken); + QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); + qt_fusion_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken); + + QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0); + painter->setPen(textColor); + painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1)); + painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, + frontWindowRect.right() - 1, frontWindowRect.top() + 1); + painter->setPen(textAlphaColor); + const QPoint points[4] = { + frontWindowRect.topLeft(), + frontWindowRect.topRight(), + frontWindowRect.bottomLeft(), + frontWindowRect.bottomRight() + }; + painter->drawPoints(points, 4); + + QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); + QRegion clipRegion = backWindowRect; + clipRegion -= frontWindowRect; + painter->save(); + painter->setClipRegion(clipRegion); + painter->setPen(textColor); + painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1)); + painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, + backWindowRect.right() - 1, backWindowRect.top() + 1); + painter->setPen(textAlphaColor); + const QPoint points2[4] = { + backWindowRect.topLeft(), + backWindowRect.topRight(), + backWindowRect.bottomLeft(), + backWindowRect.bottomRight() + }; + painter->drawPoints(points2, 4); + painter->restore(); + } + } + + // context help button + if (titleBar->subControls & SC_TitleBarContextHelpButton + && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) { + QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); + if (contextHelpButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); + qt_fusion_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); + QImage image(qt_titlebar_context_help); + QColor alpha = textColor; + alpha.setAlpha(128); + image.setColor(1, textColor.rgba()); + image.setColor(2, alpha.rgba()); + painter->setRenderHint(QPainter::SmoothPixmapTransform); + painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image); + } + } + + // shade button + if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { + QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); + if (shadeButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); + qt_fusion_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken); + QPixmap arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), textColor); + painter->drawPixmap(shadeButtonRect.adjusted(5, 7, -5, -7), arrow); + } + } + + // unshade button + if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { + QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); + if (unshadeButtonRect.isValid()) { + bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); + bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); + qt_fusion_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken); + QPixmap arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), textColor, 180); + painter->drawPixmap(unshadeButtonRect.adjusted(5, 7, -5, -7), arrow); + } + } + + if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { + QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); + if (iconRect.isValid()) { + if (!titleBar->icon.isNull()) { + titleBar->icon.paint(painter, iconRect); + } else { + QStyleOption tool(0); + tool.palette = titleBar->palette; + QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16); + tool.rect = iconRect; + painter->save(); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); + painter->restore(); + } + } + } + } + painter->restore(); + break; + case CC_ScrollBar: + painter->save(); + if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { + bool horizontal = scrollBar->orientation == Qt::Horizontal; + bool sunken = scrollBar->state & State_Sunken; + + QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); + QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); + QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); + QRect scrollBarGroove = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); + + QRect rect = option->rect; + QColor alphaOutline = outline; + alphaOutline.setAlpha(180); + + QColor arrowColor = option->palette.foreground().color(); + arrowColor.setAlpha(220); + + // Paint groove + if (scrollBar->subControls & SC_ScrollBarGroove) { + QLinearGradient gradient(rect.center().x(), rect.top(), + rect.center().x(), rect.bottom()); + if (!horizontal) + gradient = QLinearGradient(rect.left(), rect.center().y(), + rect.right(), rect.center().y()); + gradient.setColorAt(0, buttonColor.darker(107)); + gradient.setColorAt(0.1, buttonColor.darker(105)); + gradient.setColorAt(0.9, buttonColor.darker(105)); + gradient.setColorAt(1, buttonColor.darker(107)); + + painter->fillRect(option->rect, gradient); + painter->setPen(Qt::NoPen); + painter->setPen(alphaOutline); + if (horizontal) + painter->drawLine(rect.topLeft(), rect.topRight()); + else + painter->drawLine(rect.topLeft(), rect.bottomLeft()); + + QColor subtleEdge = alphaOutline; + subtleEdge.setAlpha(40); + painter->setPen(Qt::NoPen); + painter->setBrush(Qt::NoBrush); + painter->save(); + painter->setClipRect(scrollBarGroove.adjusted(1, 0, -1, -3)); + painter->drawRect(scrollBarGroove.adjusted(1, 0, -1, -1)); + painter->restore(); + } + + QRect pixmapRect = scrollBarSlider; + QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(), + pixmapRect.center().x(), pixmapRect.bottom()); + if (!horizontal) + gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(), + pixmapRect.right(), pixmapRect.center().y()); + + QLinearGradient highlightedGradient = gradient; + + QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 40); + gradient.setColorAt(0, d->buttonColor(option->palette).lighter(108)); + gradient.setColorAt(1, d->buttonColor(option->palette)); + + highlightedGradient.setColorAt(0, gradientStartColor.darker(102)); + highlightedGradient.setColorAt(1, gradientStopColor.lighter(102)); + + // Paint slider + if (scrollBar->subControls & SC_ScrollBarSlider) { + QRect pixmapRect = scrollBarSlider; + painter->setPen(QPen(alphaOutline, 0)); + if (option->state & State_Sunken && scrollBar->activeSubControls & SC_ScrollBarSlider) + painter->setBrush(midColor2); + else if (option->state & State_MouseOver && scrollBar->activeSubControls & SC_ScrollBarSlider) + painter->setBrush(highlightedGradient); + else + painter->setBrush(gradient); + + painter->drawRect(pixmapRect.adjusted(horizontal ? -1 : 0, horizontal ? 0 : -1, horizontal ? 0 : 1, horizontal ? 1 : 0)); + + painter->setPen(d->innerContrastLine()); + painter->drawRect(scrollBarSlider.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, -1, -1)); + + // Outer shadow + // painter->setPen(subtleEdge); + // if (horizontal) { + //// painter->drawLine(scrollBarSlider.topLeft() + QPoint(-2, 0), scrollBarSlider.bottomLeft() + QPoint(2, 0)); + //// painter->drawLine(scrollBarSlider.topRight() + QPoint(-2, 0), scrollBarSlider.bottomRight() + QPoint(2, 0)); + // } else { + //// painter->drawLine(pixmapRect.topLeft() + QPoint(0, -2), pixmapRect.bottomLeft() + QPoint(0, -2)); + //// painter->drawLine(pixmapRect.topRight() + QPoint(0, 2), pixmapRect.bottomRight() + QPoint(0, 2)); + // } + } + + // The SubLine (up/left) buttons + if (scrollBar->subControls & SC_ScrollBarSubLine) { + if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) + painter->setBrush(gradientStopColor); + else if ((scrollBar->activeSubControls & SC_ScrollBarSubLine)) + painter->setBrush(highlightedGradient); + else + painter->setBrush(gradient); + + painter->setPen(Qt::NoPen); + painter->drawRect(scrollBarSubLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, 0, 0)); + painter->setPen(QPen(alphaOutline, 1)); + if (option->state & State_Horizontal) { + if (option->direction == Qt::RightToLeft) { + pixmapRect.setLeft(scrollBarSubLine.left()); + painter->drawLine(pixmapRect.topLeft(), pixmapRect.bottomLeft()); + } else { + pixmapRect.setRight(scrollBarSubLine.right()); + painter->drawLine(pixmapRect.topRight(), pixmapRect.bottomRight()); + } + } else { + pixmapRect.setBottom(scrollBarSubLine.bottom()); + painter->drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight()); + } + + painter->setBrush(Qt::NoBrush); + painter->setPen(d->innerContrastLine()); + painter->drawRect(scrollBarSubLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0 , horizontal ? -2 : -1, horizontal ? -1 : -2)); + + // Arrows + int rotation = 0; + if (option->state & State_Horizontal) + rotation = option->direction == Qt::LeftToRight ? -90 : 90; + QRect upRect = scrollBarSubLine.translated(horizontal ? -2 : -1, 0); + QPixmap arrowPixmap = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation); + painter->drawPixmap(QRect(upRect.center().x() - arrowPixmap.width() / 4 + 2, + upRect.center().y() - arrowPixmap.height() / 4 + 1, + arrowPixmap.width()/2, arrowPixmap.height()/2), arrowPixmap); + } + + // The AddLine (down/right) button + if (scrollBar->subControls & SC_ScrollBarAddLine) { + if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) + painter->setBrush(gradientStopColor); + else if ((scrollBar->activeSubControls & SC_ScrollBarAddLine)) + painter->setBrush(midColor2); + else + painter->setBrush(gradient); + + painter->setPen(Qt::NoPen); + painter->drawRect(scrollBarAddLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, 0, 0)); + painter->setPen(QPen(alphaOutline, 1)); + if (option->state & State_Horizontal) { + if (option->direction == Qt::LeftToRight) { + pixmapRect.setLeft(scrollBarAddLine.left()); + painter->drawLine(pixmapRect.topLeft(), pixmapRect.bottomLeft()); + } else { + pixmapRect.setRight(scrollBarAddLine.right()); + painter->drawLine(pixmapRect.topRight(), pixmapRect.bottomRight()); + } + } else { + pixmapRect.setTop(scrollBarAddLine.top()); + painter->drawLine(pixmapRect.topLeft(), pixmapRect.topRight()); + } + + painter->setPen(d->innerContrastLine()); + painter->setBrush(Qt::NoBrush); + painter->drawRect(scrollBarAddLine.adjusted(1, 1, -1, -1)); + + int rotation = 180; + if (option->state & State_Horizontal) + rotation = option->direction == Qt::LeftToRight ? 90 : -90; + QRect downRect = scrollBarAddLine.translated(-1, 1); + QPixmap arrowPixmap = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation); + painter->drawPixmap(QRect(downRect.center().x() - arrowPixmap.width() / 4 + 2, + downRect.center().y() - arrowPixmap.height() / 4, + arrowPixmap.width()/2, arrowPixmap.height()/2), arrowPixmap); + } + + } + painter->restore(); + break;; + case CC_ComboBox: + painter->save(); + if (const QStyleOptionComboBox *comboBox = qstyleoption_cast(option)) { + bool hasFocus = option->state & State_HasFocus && option->state & State_KeyboardFocusChange; + bool sunken = comboBox->state & State_On; // play dead, if combobox has no items + bool isEnabled = (comboBox->state & State_Enabled); + QPixmap cache; + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size()); + if (sunken) + pixmapName += QLatin1String("-sunken"); + if (comboBox->editable) + pixmapName += QLatin1String("-editable"); + if (isEnabled) + pixmapName += QLatin1String("-enabled"); + + if (!QPixmapCache::find(pixmapName, cache)) { + cache = styleCachePixmap(comboBox->rect.size()); + cache.fill(Qt::transparent); + QPainter cachePainter(&cache); + QRect pixmapRect(0, 0, comboBox->rect.width(), comboBox->rect.height()); + QStyleOptionComboBox comboBoxCopy = *comboBox; + comboBoxCopy.rect = pixmapRect; + + QRect rect = pixmapRect; + QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, + SC_ComboBoxArrow, widget); + // Draw a line edit + if (comboBox->editable) { + QStyleOptionFrame buttonOption; + buttonOption.QStyleOption::operator=(*comboBox); + buttonOption.rect = rect; + buttonOption.state = (comboBox->state & (State_Enabled | State_MouseOver | State_HasFocus)) + | State_KeyboardFocusChange; // Allways show hig + + if (sunken) { + buttonOption.state |= State_Sunken; + buttonOption.state &= ~State_MouseOver; + } + + proxy()->drawPrimitive(PE_FrameLineEdit, &buttonOption, &cachePainter, widget); + + // Draw button clipped + cachePainter.save(); + cachePainter.setClipRect(downArrowRect.adjusted(0, 0, 1, 0)); + buttonOption.rect.setLeft(comboBox->direction == Qt::LeftToRight ? + downArrowRect.left() - 6: downArrowRect.right() + 6); + proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); + cachePainter.restore(); + cachePainter.setPen( QPen(hasFocus ? option->palette.highlight() : outline.lighter(110), 0)); + + if (!sunken) { + int borderSize = 1; + if (comboBox->direction == Qt::RightToLeft) { + cachePainter.drawLine(QPoint(downArrowRect.right() - 1, downArrowRect.top() + borderSize ), + QPoint(downArrowRect.right() - 1, downArrowRect.bottom() - borderSize)); + } else { + cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize), + QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize)); + } + } else { + if (comboBox->direction == Qt::RightToLeft) { + cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + 2), + QPoint(downArrowRect.right(), downArrowRect.bottom() - 2)); + + } else { + cachePainter.drawLine(QPoint(downArrowRect.left(), downArrowRect.top() + 2), + QPoint(downArrowRect.left(), downArrowRect.bottom() - 2)); + } + } + } else { + QStyleOptionButton buttonOption; + buttonOption.QStyleOption::operator=(*comboBox); + buttonOption.rect = rect; + buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver | State_HasFocus | State_KeyboardFocusChange); + if (sunken) { + buttonOption.state |= State_Sunken; + buttonOption.state &= ~State_MouseOver; + } + proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); + } + if (comboBox->subControls & SC_ComboBoxArrow) { + // Draw the up/down arrow + QColor arrowColor = option->palette.buttonText().color(); + arrowColor.setAlpha(220); + QPixmap downArrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180); + cachePainter.drawPixmap(QRect(downArrowRect.center().x() - downArrow.width() / 4 + 1, + downArrowRect.center().y() - downArrow.height() / 4 + 1, + downArrow.width()/2, downArrow.height()/2), downArrow); + } + cachePainter.end(); + QPixmapCache::insert(pixmapName, cache); + } + painter->drawPixmap(comboBox->rect.topLeft(), cache); + } + painter->restore(); + break; + case CC_Slider: + if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { + QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); + + bool horizontal = slider->orientation == Qt::Horizontal; + bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; + bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; + QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight); + QPixmap cache; + QBrush oldBrush = painter->brush(); + QPen oldPen = painter->pen(); + QColor shadowAlpha(Qt::black); + shadowAlpha.setAlpha(10); + if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) + outline = d->highlightedOutline(option->palette); + + + if ((option->subControls & SC_SliderGroove) && groove.isValid()) { + QColor grooveColor; + grooveColor.setHsv(buttonColor.hue(), + qMin(255, (int)(buttonColor.saturation())), + qMin(255, (int)(buttonColor.value()*0.9))); + QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size()); + QRect pixmapRect(0, 0, groove.width(), groove.height()); + + // draw background groove + if (!QPixmapCache::find(groovePixmapName, cache)) { + cache = styleCachePixmap(pixmapRect.size()); + cache.fill(Qt::transparent); + QPainter groovePainter(&cache); + groovePainter.setRenderHint(QPainter::Antialiasing, true); + groovePainter.translate(0.5, 0.5); + QLinearGradient gradient; + if (horizontal) { + gradient.setStart(pixmapRect.center().x(), pixmapRect.top()); + gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom()); + } + else { + gradient.setStart(pixmapRect.left(), pixmapRect.center().y()); + gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y()); + } + groovePainter.setPen(QPen(outline, 0)); + gradient.setColorAt(0, grooveColor.darker(110)); + gradient.setColorAt(1, grooveColor.lighter(110));//palette.button().color().darker(115)); + groovePainter.setBrush(gradient); + groovePainter.drawRoundedRect(pixmapRect.adjusted(1, 1, -2, -2), 1, 1); + groovePainter.end(); + QPixmapCache::insert(groovePixmapName, cache); + } + painter->drawPixmap(groove.topLeft(), cache); + + // draw blue groove highlight + QRect clipRect; + groovePixmapName += QLatin1String("_blue"); + if (!QPixmapCache::find(groovePixmapName, cache)) { + cache = styleCachePixmap(pixmapRect.size()); + cache.fill(Qt::transparent); + QPainter groovePainter(&cache); + QLinearGradient gradient; + if (horizontal) { + gradient.setStart(pixmapRect.center().x(), pixmapRect.top()); + gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom()); + } + else { + gradient.setStart(pixmapRect.left(), pixmapRect.center().y()); + gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y()); + } + QColor highlight = d->highlight(option->palette); + QColor highlightedoutline = highlight.darker(140); + if (qGray(outline.rgb()) > qGray(highlightedoutline.rgb())) + outline = highlightedoutline; + + + groovePainter.setRenderHint(QPainter::Antialiasing, true); + groovePainter.translate(0.5, 0.5); + groovePainter.setPen(QPen(outline, 0)); + gradient.setColorAt(0, activeHighlight); + gradient.setColorAt(1, activeHighlight.lighter(130)); + groovePainter.setBrush(gradient); + groovePainter.drawRoundedRect(pixmapRect.adjusted(1, 1, -2, -2), 1, 1); + groovePainter.setPen(d->innerContrastLine()); + groovePainter.setBrush(Qt::NoBrush); + groovePainter.drawRoundedRect(pixmapRect.adjusted(2, 2, -3, -3), 1, 1); + groovePainter.end(); + QPixmapCache::insert(groovePixmapName, cache); + } + if (horizontal) { + if (slider->upsideDown) + clipRect = QRect(handle.right(), groove.top(), groove.right() - handle.right(), groove.height()); + else + clipRect = QRect(groove.left(), groove.top(), handle.left(), groove.height()); + } else { + if (slider->upsideDown) + clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - handle.bottom()); + else + clipRect = QRect(groove.left(), groove.top(), groove.width(), handle.top() - groove.top()); + } + painter->save(); + painter->setClipRect(clipRect.adjusted(0, 0, 1, 1)); + painter->drawPixmap(groove.topLeft(), cache); + painter->restore(); + } + + // draw handle + if ((option->subControls & SC_SliderHandle) ) { + QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); + if (!QPixmapCache::find(handlePixmapName, cache)) { + cache = styleCachePixmap(handle.size()); + cache.fill(Qt::transparent); + QRect pixmapRect(0, 0, handle.width(), handle.height()); + QPainter handlePainter(&cache); + QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2); + + // gradient fill + QRect r = pixmapRect.adjusted(1, 1, -2, -2); + QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft); + + handlePainter.setRenderHint(QPainter::Antialiasing, true); + handlePainter.translate(0.5, 0.5); + + handlePainter.setPen(Qt::NoPen); + handlePainter.setBrush(QColor(0, 0, 0, 40)); + handlePainter.drawRect(r.adjusted(-1, 2, 1, -2)); + + handlePainter.setPen(QPen(d->outline(option->palette), 1)); + if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) + handlePainter.setPen(QPen(d->highlightedOutline(option->palette), 1)); + + handlePainter.setBrush(gradient); + handlePainter.drawRoundedRect(r, 2, 2); + handlePainter.setBrush(Qt::NoBrush); + handlePainter.setPen(d->innerContrastLine()); + handlePainter.drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2); + + QColor cornerAlpha = outline.darker(120); + cornerAlpha.setAlpha(80); + + //handle shadow + handlePainter.setPen(shadowAlpha); + handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1)); + handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4)); + handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2)); + + handlePainter.end(); + QPixmapCache::insert(handlePixmapName, cache); + } + + painter->drawPixmap(handle.topLeft(), cache); + + } + if (option->subControls & SC_SliderTickmarks) { + painter->setPen(outline); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int interval = slider->tickInterval; + if (interval <= 0) { + interval = slider->singleStep; + if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, + available) + - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, + 0, available) < 3) + interval = slider->pageStep; + } + if (interval <= 0) + interval = 1; + + int v = slider->minimum; + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); + while (v <= slider->maximum + 1) { + if (v == slider->maximum + 1 && interval == 1) + break; + const int v_ = qMin(v, slider->maximum); + int pos = sliderPositionFromValue(slider->minimum, slider->maximum, + v_, (horizontal + ? slider->rect.width() + : slider->rect.height()) - len, + slider->upsideDown) + len / 2; + int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0); + + if (horizontal) { + if (ticksAbove) { + painter->drawLine(pos, slider->rect.top() + extra, + pos, slider->rect.top() + tickSize); + } + if (ticksBelow) { + painter->drawLine(pos, slider->rect.bottom() - extra, + pos, slider->rect.bottom() - tickSize); + } + } else { + if (ticksAbove) { + painter->drawLine(slider->rect.left() + extra, pos, + slider->rect.left() + tickSize, pos); + } + if (ticksBelow) { + painter->drawLine(slider->rect.right() - extra, pos, + slider->rect.right() - tickSize, pos); + } + } + // in the case where maximum is max int + int nextInterval = v + interval; + if (nextInterval < v) + break; + v = nextInterval; + } + } + painter->setBrush(oldBrush); + painter->setPen(oldPen); + } + break; + case CC_Dial: + if (const QStyleOptionSlider *dial = qstyleoption_cast(option)) + QStyleHelper::drawDial(dial, painter); + break; + default: + QCommonStyle::drawComplexControl(control, option, painter, widget); + break; + } +} + +/*! + \reimp +*/ +int QFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const +{ + switch (metric) { + case PM_HeaderMargin: + return 2; + case PM_ToolTipLabelFrameWidth: + return 2; + case PM_ButtonDefaultIndicator: + return 0; + case PM_ButtonShiftHorizontal: + case PM_ButtonShiftVertical: + return 0; + case PM_MessageBoxIconSize: + return 48; + case PM_ListViewIconSize: + return 24; + case PM_DialogButtonsSeparator: + case PM_ScrollBarSliderMin: + return 26; + case PM_TitleBarHeight: + return 24; + case PM_ScrollBarExtent: + return 14; + case PM_SliderThickness: + return 15; + case PM_SliderLength: + return 15; + case PM_DockWidgetTitleMargin: + return 1; + case PM_DefaultFrameWidth: + return 1; + case PM_SpinBoxFrameWidth: + return 3; + case PM_MenuVMargin: + case PM_MenuHMargin: + return 0; + case PM_MenuPanelWidth: + return 0; + case PM_MenuBarItemSpacing: + return 6; + case PM_MenuBarVMargin: + return 0; + case PM_MenuBarHMargin: + return 0; + case PM_MenuBarPanelWidth: + return 0; + case PM_ToolBarHandleExtent: + return 9; + case PM_ToolBarItemSpacing: + return 1; + case PM_ToolBarFrameWidth: + return 2; + case PM_ToolBarItemMargin: + return 2; + case PM_SmallIconSize: + return 16; + case PM_ButtonIconSize: + return 16; + case PM_DockWidgetTitleBarButtonMargin: + return 2; + case PM_MaximumDragDistance: + return -1; + case PM_TabCloseIndicatorWidth: + case PM_TabCloseIndicatorHeight: + return 20; + case PM_TabBarTabVSpace: + return 12; + case PM_TabBarTabOverlap: + return 1; + case PM_TabBarBaseOverlap: + return 2; + case PM_SubMenuOverlap: + return -1; + case PM_DockWidgetHandleExtent: + case PM_SplitterWidth: + return 4; + case PM_IndicatorHeight: + case PM_IndicatorWidth: + case PM_ExclusiveIndicatorHeight: + case PM_ExclusiveIndicatorWidth: + return 14; + case PM_ScrollView_ScrollBarSpacing: + return 0; + default: + break; + } + return QCommonStyle::pixelMetric(metric, option, widget); +} + +/*! + \reimp +*/ +QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &size, const QWidget *widget) const +{ + QSize newSize = QCommonStyle::sizeFromContents(type, option, size, widget); + switch (type) { + case CT_PushButton: + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { + if (!btn->text.isEmpty() && newSize.width() < 80) + newSize.setWidth(80); + if (!btn->icon.isNull() && btn->iconSize.height() > 16) + newSize -= QSize(0, 2); + } + break; + case CT_GroupBox: + newSize += QSize(10, 10); // Add some space below the groupbox + break; + case CT_RadioButton: + case CT_CheckBox: + newSize += QSize(0, 1); + break; + case CT_ToolButton: + newSize += QSize(2, 2); + break; + case CT_SpinBox: + newSize += QSize(0, -2); + break; + case CT_ComboBox: + newSize += QSize(2, 4); + break; + case CT_LineEdit: + newSize += QSize(0, 4); + break; + case CT_MenuBarItem: + newSize += QSize(8, 5); + break; + case CT_MenuItem: + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { + int w = newSize.width(); + int maxpmw = menuItem->maxIconWidth; + int tabSpacing = 20; + if (menuItem->text.contains(QLatin1Char('\t'))) + w += tabSpacing; + else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) + w += 2 * QFusionStylePrivate::menuArrowHMargin; + else if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) { + QFontMetrics fm(menuItem->font); + QFont fontBold = menuItem->font; + fontBold.setBold(true); + QFontMetrics fmBold(fontBold); + w += fmBold.width(menuItem->text) - fm.width(menuItem->text); + } + int checkcol = qMax(maxpmw, QFusionStylePrivate::menuCheckMarkWidth); // Windows always shows a check column + w += checkcol; + w += int(QFusionStylePrivate::menuRightBorder) + 10; + newSize.setWidth(w); + if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { + if (!menuItem->text.isEmpty()) { + newSize.setHeight(menuItem->fontMetrics.height()); + } + } + else if (!menuItem->icon.isNull()) { + if (const QComboBox *combo = qobject_cast(widget)) { + newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height())); + } + } + newSize.setWidth(newSize.width() + 12); + newSize.setWidth(qMax(newSize.width(), 120)); + } + break; + case CT_SizeGrip: + newSize += QSize(4, 4); + break; + case CT_MdiControls: + if (const QStyleOptionComplex *styleOpt = qstyleoption_cast(option)) { + int width = 0; + if (styleOpt->subControls & SC_MdiMinButton) + width += 19 + 1; + if (styleOpt->subControls & SC_MdiNormalButton) + width += 19 + 1; + if (styleOpt->subControls & SC_MdiCloseButton) + width += 19 + 1; + newSize = QSize(width, 19); + } else { + newSize = QSize(60, 19); + } + break; + default: + break; + } + return newSize; +} + +/*! + \reimp +*/ +void QFusionStyle::polish(QApplication *app) +{ + QCommonStyle::polish(app); +} + +/*! + \reimp +*/ +void QFusionStyle::polish(QWidget *widget) +{ + QCommonStyle::polish(widget); + if (qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || (widget->inherits("QDockSeparator")) + || (widget->inherits("QDockWidgetSeparator")) + ) { + widget->setAttribute(Qt::WA_Hover, true); + } +} + +/*! + \reimp +*/ +void QFusionStyle::polish(QPalette &pal) +{ + QCommonStyle::polish(pal); +} + +/*! + \reimp +*/ +void QFusionStyle::unpolish(QWidget *widget) +{ + QCommonStyle::unpolish(widget); + if (qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || qobject_cast(widget) + || (widget->inherits("QDockSeparator")) + || (widget->inherits("QDockWidgetSeparator")) + ) { + widget->setAttribute(Qt::WA_Hover, false); + } +} + +/*! + \reimp +*/ +void QFusionStyle::unpolish(QApplication *app) +{ + QCommonStyle::unpolish(app); +} + +/*! + \reimp +*/ +QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, + SubControl subControl, const QWidget *widget) const +{ + QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget); + + switch (control) { + case CC_Slider: + if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + switch (subControl) { + case SC_SliderHandle: { + if (slider->orientation == Qt::Horizontal) { + rect.setHeight(proxy()->pixelMetric(PM_SliderThickness)); + rect.setWidth(proxy()->pixelMetric(PM_SliderLength)); + int centerY = slider->rect.center().y() - rect.height() / 2; + if (slider->tickPosition & QSlider::TicksAbove) + centerY += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + centerY -= tickSize; + rect.moveTop(centerY); + } else { + rect.setWidth(proxy()->pixelMetric(PM_SliderThickness)); + rect.setHeight(proxy()->pixelMetric(PM_SliderLength)); + int centerX = slider->rect.center().x() - rect.width() / 2; + if (slider->tickPosition & QSlider::TicksAbove) + centerX += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + centerX -= tickSize; + rect.moveLeft(centerX); + } + } + break; + case SC_SliderGroove: { + QPoint grooveCenter = slider->rect.center(); + if (slider->orientation == Qt::Horizontal) { + rect.setHeight(7); + if (slider->tickPosition & QSlider::TicksAbove) + grooveCenter.ry() += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + grooveCenter.ry() -= tickSize; + } else { + rect.setWidth(7); + if (slider->tickPosition & QSlider::TicksAbove) + grooveCenter.rx() += tickSize; + if (slider->tickPosition & QSlider::TicksBelow) + grooveCenter.rx() -= tickSize; + } + rect.moveCenter(grooveCenter); + break; + } + default: + break; + } + } + break; + case CC_SpinBox: + if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { + QSize bs; + int center = spinbox->rect.height() / 2; + int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; + int y = fw; + bs.setHeight(qMax(8, spinbox->rect.height()/2 - y)); + bs.setWidth(14); + int x, lx, rx; + x = spinbox->rect.width() - y - bs.width() + 2; + lx = fw; + rx = x - fw; + switch (subControl) { + case SC_SpinBoxUp: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + return QRect(); + rect = QRect(x, fw, bs.width(), center - fw); + break; + case SC_SpinBoxDown: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + return QRect(); + + rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - fw + 1); + break; + case SC_SpinBoxEditField: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) { + rect = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw); + } else { + rect = QRect(lx, fw, rx - qMax(fw - 1, 0), spinbox->rect.height() - 2*fw); + } + break; + case SC_SpinBoxFrame: + rect = spinbox->rect; + default: + break; + } + rect = visualRect(spinbox->direction, spinbox->rect, rect); + } + break; + + case CC_GroupBox: + if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { + rect = option->rect; + if (subControl == SC_GroupBoxFrame) + return rect.adjusted(0, 0, 0, 0); + else if (subControl == SC_GroupBoxContents) { + QRect frameRect = option->rect.adjusted(0, 0, 0, -groupBoxBottomMargin); + int margin = 3; + int leftMarginExtension = 0; + return frameRect.adjusted(leftMarginExtension + margin, margin + groupBoxTopMargin + groupBoxTitleMargin, -margin, -margin - groupBoxBottomMargin); + } + + QSize textSize = option->fontMetrics.boundingRect(groupBox->text).size() + QSize(4, 4); + int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); + int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); + rect = QRect(); + if (subControl == SC_GroupBoxCheckBox) { + rect.setWidth(indicatorWidth); + rect.setHeight(indicatorHeight); + rect.moveTop((textSize.height() - indicatorHeight - 5) / 2); + rect.moveLeft(1); + } else if (subControl == SC_GroupBoxLabel) { + rect.setSize(textSize); + rect.moveTop(0); + if (option->subControls & QStyle::SC_GroupBoxCheckBox) + rect.translate(indicatorWidth + 5, 0); + } + return visualRect(option->direction, option->rect, rect); + } + + return rect; + + case CC_ComboBox: + switch (subControl) { + case SC_ComboBoxArrow: + rect = visualRect(option->direction, option->rect, rect); + rect.setRect(rect.right() - 18, rect.top() - 2, + 19, rect.height() + 4); + rect = visualRect(option->direction, option->rect, rect); + break; + case SC_ComboBoxEditField: { + int frameWidth = 2; + rect = visualRect(option->direction, option->rect, rect); + rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth, + option->rect.width() - 19 - 2 * frameWidth, + option->rect.height() - 2 * frameWidth); + if (const QStyleOptionComboBox *box = qstyleoption_cast(option)) { + if (!box->editable) { + rect.adjust(2, 0, 0, 0); + if (box->state & (State_Sunken | State_On)) + rect.translate(1, 1); + } + } + rect = visualRect(option->direction, option->rect, rect); + break; + } + default: + break; + } + break; + case CC_TitleBar: + if (const QStyleOptionTitleBar *tb = qstyleoption_cast(option)) { + SubControl sc = subControl; + QRect &ret = rect; + const int indent = 3; + const int controlTopMargin = 3; + const int controlBottomMargin = 3; + const int controlWidthMargin = 2; + const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ; + const int delta = controlHeight + controlWidthMargin; + int offset = 0; + + bool isMinimized = tb->titleBarState & Qt::WindowMinimized; + bool isMaximized = tb->titleBarState & Qt::WindowMaximized; + + switch (sc) { + case SC_TitleBarLabel: + if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) { + ret = tb->rect; + if (tb->titleBarFlags & Qt::WindowSystemMenuHint) + ret.adjust(delta, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) + ret.adjust(0, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) + ret.adjust(0, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowShadeButtonHint) + ret.adjust(0, 0, -delta, 0); + if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) + ret.adjust(0, 0, -delta, 0); + } + break; + case SC_TitleBarContextHelpButton: + if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) + offset += delta; + case SC_TitleBarMinButton: + if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarMinButton) + break; + case SC_TitleBarNormalButton: + if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) + offset += delta; + else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarNormalButton) + break; + case SC_TitleBarMaxButton: + if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarMaxButton) + break; + case SC_TitleBarShadeButton: + if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarShadeButton) + break; + case SC_TitleBarUnshadeButton: + if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) + offset += delta; + else if (sc == SC_TitleBarUnshadeButton) + break; + case SC_TitleBarCloseButton: + if (tb->titleBarFlags & Qt::WindowSystemMenuHint) + offset += delta; + else if (sc == SC_TitleBarCloseButton) + break; + ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin, + controlHeight, controlHeight); + break; + case SC_TitleBarSysMenu: + if (tb->titleBarFlags & Qt::WindowSystemMenuHint) { + ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin, + controlHeight, controlHeight); + } + break; + default: + break; + } + ret = visualRect(tb->direction, tb->rect, ret); + } + break; + default: + break; + } + + return rect; +} + + +/*! + \reimp +*/ +QRect QFusionStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const +{ + return QCommonStyle::itemPixmapRect(r, flags, pixmap); +} + +/*! + \reimp +*/ +void QFusionStyle::drawItemPixmap(QPainter *painter, const QRect &rect, + int alignment, const QPixmap &pixmap) const +{ + QCommonStyle::drawItemPixmap(painter, rect, alignment, pixmap); +} + +/*! + \reimp +*/ +QStyle::SubControl QFusionStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, + const QPoint &pt, const QWidget *w) const +{ + return QCommonStyle::hitTestComplexControl(cc, opt, pt, w); +} + +/*! + \reimp +*/ +QPixmap QFusionStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, + const QStyleOption *opt) const +{ + return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt); +} + +/*! + \reimp +*/ +int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, + QStyleHintReturn *returnData) const +{ + switch (hint) { + case SH_Slider_SnapToValue: + case SH_PrintDialog_RightAlignButtons: + case SH_FontDialog_SelectAssociatedText: + case SH_MenuBar_AltKeyNavigation: + case SH_ComboBox_ListMouseTracking: + case SH_ScrollBar_StopMouseOverSlider: + case SH_ScrollBar_MiddleClickAbsolutePosition: + case SH_EtchDisabledText: + case SH_TitleBar_AutoRaise: + case SH_TitleBar_NoBorder: + case SH_ItemView_ShowDecorationSelected: + case SH_ItemView_ArrowKeysNavigateIntoChildren: + case SH_ItemView_ChangeHighlightOnFocus: + case SH_MenuBar_MouseTracking: + case SH_Menu_MouseTracking: + return 1; + + case SH_ToolBox_SelectedPageTitleBold: + case SH_ScrollView_FrameOnlyAroundContents: + case SH_Menu_AllowActiveAndDisabled: + case SH_MainWindow_SpaceBelowMenuBar: + case SH_DialogButtonBox_ButtonsHaveIcons: + case SH_MessageBox_CenterButtons: + case SH_RubberBand_Mask: + return 0; + + case SH_ComboBox_Popup: + if (const QStyleOptionComboBox *cmb = qstyleoption_cast(option)) + return !cmb->editable; + return 0; + + case SH_Table_GridLineColor: + return option->palette.background().color().darker(120).rgb(); + + case SH_MessageBox_TextInteractionFlags: + return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; + + case SH_WizardStyle: + return QWizard::ClassicStyle; + + case SH_Menu_SubMenuPopupDelay: + return 225; // default from GtkMenu + + case SH_WindowFrame_Mask: + if (QStyleHintReturnMask *mask = qstyleoption_cast(returnData)) { + //left rounded corner + mask->region = option->rect; + mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1); + mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1); + mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1); + mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2); + + //right rounded corner + mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1); + mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1); + mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1); + mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2); + return 1; + } + default: + break; + } + return QCommonStyle::styleHint(hint, option, widget, returnData); +} + +/*! \reimp */ +QRect QFusionStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const +{ + QRect r = QCommonStyle::subElementRect(sr, opt, w); + switch (sr) { + case SE_ProgressBarLabel: + case SE_ProgressBarContents: + case SE_ProgressBarGroove: + return opt->rect; + case SE_PushButtonFocusRect: + r.adjust(0, 1, 0, -1); + break; + case SE_DockWidgetTitleBarText: { + if (const QStyleOptionDockWidget *titlebar = qstyleoption_cast(opt)) { + bool verticalTitleBar = titlebar->verticalTitleBar; + if (verticalTitleBar) { + r.adjust(0, 0, 0, -4); + } else { + if (opt->direction == Qt::LeftToRight) + r.adjust(4, 0, 0, 0); + else + r.adjust(0, 0, -4, 0); + } + } + + break; + } + default: + break; + } + return r; +} + +/*! + \reimp +*/ +QIcon QFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option, + const QWidget *widget) const +{ + return QCommonStyle::standardIcon(standardIcon, option, widget); +} + +/*! + \reimp + */ +QPixmap QFusionStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, + const QWidget *widget) const +{ +#ifndef QT_NO_IMAGEFORMAT_XPM + switch (standardPixmap) { + case SP_TitleBarNormalButton: + return QPixmap((const char **)dock_widget_restore_xpm); + case SP_TitleBarMinButton: + return QPixmap((const char **)workspace_minimize); + case SP_TitleBarCloseButton: + case SP_DockWidgetCloseButton: + return QPixmap((const char **)dock_widget_close_xpm); + + default: + break; + } +#endif //QT_NO_IMAGEFORMAT_XPM + + return QCommonStyle::standardPixmap(standardPixmap, opt, widget); +} + +QT_END_NAMESPACE + +#endif // QT_NO_STYLE_FUSION || QT_PLUGIN diff --git a/src/widgets/styles/qfusionstyle.h b/src/widgets/styles/qfusionstyle.h new file mode 100644 index 0000000000..927ba32342 --- /dev/null +++ b/src/widgets/styles/qfusionstyle.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFUSIONSTYLE_H +#define QFUSIONSTYLE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + + +#if !defined(QT_NO_STYLE_FUSION) + +class QFusionStylePrivate; +class Q_WIDGETS_EXPORT QFusionStyle : public QCommonStyle +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QFusionStyle) + +public: + QFusionStyle(); + ~QFusionStyle(); + + QPalette standardPalette () const; + void drawPrimitive(PrimitiveElement elem, + const QStyleOption *option, + QPainter *painter, const QWidget *widget = 0) const; + void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter, + const QWidget *widget) const; + int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; + void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const; + QSize sizeFromContents(ContentsType type, const QStyleOption *option, + const QSize &size, const QWidget *widget) const; + SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, + const QPoint &pt, const QWidget *w = 0) const; + QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, + SubControl sc, const QWidget *widget) const; + QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, + const QStyleOption *opt) const; + int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, + QStyleHintReturn *returnData = 0) const; + QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, + const QWidget *widget = 0) const; + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, + const QWidget *widget = 0) const; + void drawItemPixmap(QPainter *painter, const QRect &rect, + int alignment, const QPixmap &pixmap) const; + void drawItemText(QPainter *painter, const QRect &rect, + int flags, const QPalette &pal, bool enabled, + const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const; + void polish(QWidget *widget); + void polish(QApplication *app); + void polish(QPalette &pal); + void unpolish(QWidget *widget); + void unpolish(QApplication *app); + +protected: + QFusionStyle(QFusionStylePrivate &dd); + +}; + +#endif // QT_NO_STYLE_FUSION + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QFUSIONSTYLE_H diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h new file mode 100644 index 0000000000..1c8089e736 --- /dev/null +++ b/src/widgets/styles/qfusionstyle_p.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFUSIONSTYLE_P_H +#define QFUSIONSTYLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qcommonstyle.h" +#include "qcommonstyle_p.h" + +#ifndef QT_NO_STYLE_FUSION + +QT_BEGIN_NAMESPACE + +class QFusionStylePrivate : public QCommonStylePrivate +{ + Q_DECLARE_PUBLIC(QFusionStyle) + +public: + QFusionStylePrivate(); + + // Used for grip handles + QColor lightShade() const { + return QColor(255, 255, 255, 90); + } + QColor darkShade() const { + return QColor(0, 0, 0, 60); + } + + QColor topShadow() const { + return QColor(0, 0, 0, 18); + } + + QColor innerContrastLine() const { + return QColor(255, 255, 255, 30); + } + + QColor highlight(const QPalette &pal) const { + return pal.color(QPalette::Active, QPalette::Highlight); + } + + QColor outline(const QPalette &pal) const { + if (!pal.window().texture().isNull()) + return QColor(0, 0, 0, 160); + return pal.background().color().darker(140); + } + + QColor highlightedOutline(const QPalette &pal) const { + QColor highlightedOutline = pal.highlight().color().darker(125); + if (highlightedOutline.value() > 160) + highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160); + return highlightedOutline; + } + + QColor tabFrameColor(const QPalette &pal) const { + if (!pal.button().texture().isNull()) + return QColor(255, 255, 255, 8); + return buttonColor(pal).lighter(104); + } + + QColor buttonColor(const QPalette &pal) const { + QColor buttonColor = pal.button().color(); + int val = qGray(buttonColor.rgb()); + buttonColor = buttonColor.lighter(100 + qMax(0, (180- val)/6)); + buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value()); + return buttonColor; + } + + enum { + menuItemHMargin = 3, // menu item hor text margin + menuArrowHMargin = 6, // menu arrow horizontal margin + menuRightBorder = 15, // right border on menus + menuCheckMarkWidth = 12 // checkmarks width on menus + }; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_STYLE_FUSION + +#endif //QFUSIONSTYLE_P_H diff --git a/src/widgets/styles/qstyle.qrc b/src/widgets/styles/qstyle.qrc index 6e04540f51..d835728928 100644 --- a/src/widgets/styles/qstyle.qrc +++ b/src/widgets/styles/qstyle.qrc @@ -1,135 +1,137 @@ - - -images/filelink-16.png -images/filelink-32.png -images/filelink-128.png -images/file-16.png -images/file-32.png -images/file-128.png -images/newdirectory-16.png -images/newdirectory-32.png -images/newdirectory-128.png -images/parentdir-16.png -images/parentdir-32.png -images/parentdir-128.png -images/dvd-16.png -images/dvd-32.png -images/dvd-128.png -images/cdr-16.png -images/cdr-32.png -images/cdr-128.png -images/floppy-16.png -images/floppy-32.png -images/floppy-128.png -images/harddrive-16.png -images/harddrive-32.png -images/harddrive-128.png -images/trash-16.png -images/trash-32.png -images/trash-128.png -images/networkdrive-16.png -images/networkdrive-32.png -images/networkdrive-128.png -images/computer-16.png -images/computer-32.png -images/desktop-16.png -images/desktop-32.png -images/dirclosed-16.png -images/dirclosed-32.png -images/dirclosed-128.png -images/dirlink-16.png -images/dirlink-32.png -images/dirlink-128.png -images/diropen-16.png -images/diropen-32.png -images/diropen-128.png -images/left-16.png -images/left-32.png -images/left-128.png -images/right-16.png -images/right-32.png -images/right-128.png -images/up-16.png -images/up-32.png -images/up-128.png -images/down-16.png -images/down-32.png -images/down-128.png -images/filecontents-16.png -images/filecontents-32.png -images/filecontents-128.png -images/fileinfo-16.png -images/fileinfo-32.png -images/fileinfo-128.png -images/viewdetailed-16.png -images/viewdetailed-32.png -images/viewdetailed-128.png -images/viewlist-16.png -images/viewlist-32.png -images/viewlist-128.png -images/fontbitmap-16.png -images/fonttruetype-16.png -images/standardbutton-apply-128.png -images/standardbutton-apply-16.png -images/standardbutton-apply-32.png -images/standardbutton-cancel-128.png -images/standardbutton-cancel-16.png -images/standardbutton-cancel-32.png -images/standardbutton-clear-128.png -images/standardbutton-clear-16.png -images/standardbutton-clear-32.png -images/standardbutton-close-128.png -images/standardbutton-close-16.png -images/standardbutton-close-32.png -images/standardbutton-delete-128.png -images/standardbutton-delete-16.png -images/standardbutton-delete-32.png -images/standardbutton-help-128.png -images/standardbutton-help-16.png -images/standardbutton-help-32.png -images/standardbutton-no-128.png -images/standardbutton-no-16.png -images/standardbutton-no-32.png -images/standardbutton-ok-128.png -images/standardbutton-ok-16.png -images/standardbutton-ok-32.png -images/standardbutton-open-128.png -images/standardbutton-open-16.png -images/standardbutton-open-32.png -images/standardbutton-save-128.png -images/standardbutton-save-16.png -images/standardbutton-save-32.png -images/standardbutton-yes-128.png -images/standardbutton-yes-16.png -images/standardbutton-yes-32.png -images/standardbutton-closetab-16.png -images/standardbutton-closetab-down-16.png -images/standardbutton-closetab-hover-16.png -images/refresh-24.png -images/refresh-32.png -images/stop-24.png -images/stop-32.png -images/media-stop-16.png -images/media-stop-32.png -images/media-play-16.png -images/media-play-32.png -images/media-pause-16.png -images/media-pause-32.png -images/media-seek-forward-16.png -images/media-seek-forward-32.png -images/media-seek-backward-16.png -images/media-seek-backward-32.png -images/media-skip-forward-16.png -images/media-skip-forward-32.png -images/media-skip-backward-16.png -images/media-skip-backward-32.png -images/media-volume-16.png -images/media-volume-muted-16.png - - -images/closedock-16.png -images/closedock-down-16.png -images/dockdock-16.png -images/dockdock-down-16.png - + + + images/filelink-16.png + images/filelink-32.png + images/filelink-128.png + images/file-16.png + images/file-32.png + images/file-128.png + images/newdirectory-16.png + images/newdirectory-32.png + images/newdirectory-128.png + images/parentdir-16.png + images/parentdir-32.png + images/parentdir-128.png + images/dvd-16.png + images/dvd-32.png + images/dvd-128.png + images/cdr-16.png + images/cdr-32.png + images/cdr-128.png + images/floppy-16.png + images/floppy-32.png + images/floppy-128.png + images/harddrive-16.png + images/harddrive-32.png + images/harddrive-128.png + images/trash-16.png + images/trash-32.png + images/trash-128.png + images/networkdrive-16.png + images/networkdrive-32.png + images/networkdrive-128.png + images/computer-16.png + images/computer-32.png + images/desktop-16.png + images/desktop-32.png + images/dirclosed-16.png + images/dirclosed-32.png + images/dirclosed-128.png + images/dirlink-16.png + images/dirlink-32.png + images/dirlink-128.png + images/diropen-16.png + images/diropen-32.png + images/diropen-128.png + images/left-16.png + images/left-32.png + images/left-128.png + images/right-16.png + images/right-32.png + images/right-128.png + images/up-16.png + images/up-32.png + images/up-128.png + images/down-16.png + images/down-32.png + images/down-128.png + images/filecontents-16.png + images/filecontents-32.png + images/filecontents-128.png + images/fileinfo-16.png + images/fileinfo-32.png + images/fileinfo-128.png + images/viewdetailed-16.png + images/viewdetailed-32.png + images/viewdetailed-128.png + images/viewlist-16.png + images/viewlist-32.png + images/viewlist-128.png + images/fontbitmap-16.png + images/fonttruetype-16.png + images/standardbutton-apply-128.png + images/standardbutton-apply-16.png + images/standardbutton-apply-32.png + images/standardbutton-cancel-128.png + images/standardbutton-cancel-16.png + images/standardbutton-cancel-32.png + images/standardbutton-clear-128.png + images/standardbutton-clear-16.png + images/standardbutton-clear-32.png + images/standardbutton-close-128.png + images/standardbutton-close-16.png + images/standardbutton-close-32.png + images/standardbutton-delete-128.png + images/standardbutton-delete-16.png + images/standardbutton-delete-32.png + images/standardbutton-help-128.png + images/standardbutton-help-16.png + images/standardbutton-help-32.png + images/standardbutton-no-128.png + images/standardbutton-no-16.png + images/standardbutton-no-32.png + images/standardbutton-ok-128.png + images/standardbutton-ok-16.png + images/standardbutton-ok-32.png + images/standardbutton-open-128.png + images/standardbutton-open-16.png + images/standardbutton-open-32.png + images/standardbutton-save-128.png + images/standardbutton-save-16.png + images/standardbutton-save-32.png + images/standardbutton-yes-128.png + images/standardbutton-yes-16.png + images/standardbutton-yes-32.png + images/standardbutton-closetab-16.png + images/standardbutton-closetab-down-16.png + images/standardbutton-closetab-hover-16.png + images/refresh-24.png + images/refresh-32.png + images/stop-24.png + images/stop-32.png + images/media-stop-16.png + images/media-stop-32.png + images/media-play-16.png + images/media-play-32.png + images/media-pause-16.png + images/media-pause-32.png + images/media-seek-forward-16.png + images/media-seek-forward-32.png + images/media-seek-backward-16.png + images/media-seek-backward-32.png + images/media-skip-forward-16.png + images/media-skip-forward-32.png + images/media-skip-backward-16.png + images/media-skip-backward-32.png + images/media-volume-16.png + images/media-volume-muted-16.png + images/fusion_groupbox.png + images/fusion_arrow.png + + + images/closedock-16.png + images/closedock-down-16.png + images/dockdock-16.png + images/dockdock-down-16.png + diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h index 66cd7eed10..85e8e54b16 100644 --- a/src/widgets/styles/qstyle_p.h +++ b/src/widgets/styles/qstyle_p.h @@ -72,6 +72,15 @@ public: QStyle *proxyStyle; }; +inline QImage styleCacheImage(const QSize &size) +{ + return QImage(size, QImage::Format_ARGB32_Premultiplied); +} + +inline QPixmap styleCachePixmap(const QSize &size) +{ + return QPixmap(size); +} #define BEGIN_STYLE_PIXMAPCACHE(a) \ QRect rect = option->rect; \ @@ -80,13 +89,14 @@ public: QPainter *p = painter; \ QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \ - bool doPixmapCache = txType <= QTransform::TxTranslate; \ + bool doPixmapCache = (txType <= QTransform::TxTranslate) \ + || (painter->deviceTransform().type() == QTransform::TxScale); \ if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \ } else { \ if (doPixmapCache) { \ rect.setRect(0, 0, option->rect.width(), option->rect.height()); \ - imageCache = QImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); \ + imageCache = styleCacheImage(option->rect.size()); \ imageCache.fill(0); \ p = new QPainter(&imageCache); \ } diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp index f12ea27e78..8f4f014ac8 100644 --- a/src/widgets/styles/qstylefactory.cpp +++ b/src/widgets/styles/qstylefactory.cpp @@ -52,6 +52,9 @@ #ifndef QT_NO_STYLE_CLEANLOOKS #include "qcleanlooksstyle.h" #endif +#ifndef QT_NO_STYLE_FUSION +#include "qfusionstyle.h" +#endif #ifndef QT_NO_STYLE_GTK #include "qgtkstyle.h" #endif @@ -146,6 +149,11 @@ QStyle *QStyleFactory::create(const QString& key) ret = new QPlastiqueStyle; else #endif +#ifndef QT_NO_STYLE_FUSION + if (style == QLatin1String("fusion")) + ret = new QFusionStyle; + else +#endif #ifndef QT_NO_STYLE_CLEANLOOKS if (style == QLatin1String("cleanlooks")) ret = new QCleanlooksStyle; @@ -222,6 +230,10 @@ QStringList QStyleFactory::keys() if (!list.contains(QLatin1String("GTK+"))) list << QLatin1String("GTK+"); #endif +#ifndef QT_NO_STYLE_FUSION + if (!list.contains(QLatin1String("Fusion"))) + list << QLatin1String("Fusion"); +#endif #ifndef QT_NO_STYLE_CLEANLOOKS if (!list.contains(QLatin1String("Cleanlooks"))) list << QLatin1String("Cleanlooks"); diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index d04b3d5416..1aae0d89f3 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -129,6 +129,18 @@ contains( styles, cleanlooks ) { DEFINES += QT_NO_STYLE_CLEANLOOKS } +contains( styles, fusion ) { + HEADERS += styles/qfusionstyle.h + HEADERS += styles/qfusionstyle_p.h + SOURCES += styles/qfusionstyle.cpp + !contains( styles, windows ) { + styles += windows + DEFINES+= QT_STYLE_WINDOWS + } +} else { + DEFINES += QT_NO_STYLE_FUSION +} + contains( styles, windows ) { HEADERS += styles/qwindowsstyle.h SOURCES += styles/qwindowsstyle.cpp diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 81daecef2d..508cd37ba4 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -309,6 +309,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "STYLE_WINDOWSVISTA" ] = "auto"; dictionary[ "STYLE_PLASTIQUE" ] = "yes"; dictionary[ "STYLE_CLEANLOOKS" ]= "yes"; + dictionary[ "STYLE_FUSION" ] = "yes"; dictionary[ "STYLE_WINDOWSCE" ] = "no"; dictionary[ "STYLE_WINDOWSMOBILE" ] = "no"; dictionary[ "STYLE_GTK" ] = "no"; @@ -648,6 +649,11 @@ void Configure::parseCmdLine() else if (configCmdLine.at(i) == "-no-style-cleanlooks") dictionary[ "STYLE_CLEANLOOKS" ] = "no"; + else if (configCmdLine.at(i) == "-qt-style-fusion") + dictionary[ "STYLE_FUSION" ] = "yes"; + else if (configCmdLine.at(i) == "-no-style-fusion") + dictionary[ "STYLE_FUSION" ] = "no"; + // Work around compiler nesting limitation else continueElse[1] = true; @@ -1481,6 +1487,7 @@ void Configure::applySpecSpecifics() dictionary[ "STYLE_WINDOWSVISTA" ] = "no"; dictionary[ "STYLE_PLASTIQUE" ] = "no"; dictionary[ "STYLE_CLEANLOOKS" ] = "no"; + dictionary[ "STYLE_FUSION" ] = "no"; dictionary[ "STYLE_WINDOWSCE" ] = "yes"; dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes"; dictionary[ "OPENGL" ] = "no"; @@ -1792,6 +1799,7 @@ bool Configure::displayHelp() desc("STYLE_WINDOWSVISTA", "auto", "", " windowsvista", ' '); desc("STYLE_PLASTIQUE", "yes", "", " plastique", ' '); desc("STYLE_CLEANLOOKS", "yes", "", " cleanlooks", ' '); + desc("STYLE_FUSION", "yes", "", " fusion", ' '); desc("STYLE_WINDOWSCE", "yes", "", " windowsce", ' '); desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile\n", ' '); desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7."); @@ -2373,6 +2381,9 @@ void Configure::generateOutputVars() if (dictionary[ "STYLE_CLEANLOOKS" ] == "yes") qmakeStyles += "cleanlooks"; + if (dictionary[ "STYLE_FUSION" ] == "yes") + qmakeStyles += "fusion"; + if (dictionary[ "STYLE_WINDOWSXP" ] == "yes") qmakeStyles += "windowsxp"; @@ -3153,6 +3164,7 @@ void Configure::generateConfigfiles() if (dictionary["STYLE_WINDOWS"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWS"; if (dictionary["STYLE_PLASTIQUE"] != "yes") qconfigList += "QT_NO_STYLE_PLASTIQUE"; if (dictionary["STYLE_CLEANLOOKS"] != "yes") qconfigList += "QT_NO_STYLE_CLEANLOOKS"; + if (dictionary["STYLE_FUSION"] != "yes") qconfigList += "QT_NO_STYLE_FUSION"; if (dictionary["STYLE_WINDOWSXP"] != "yes" && dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSXP"; if (dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSVISTA"; @@ -3356,6 +3368,7 @@ void Configure::displayConfig() sout << " Windows Vista..........." << dictionary[ "STYLE_WINDOWSVISTA" ] << endl; sout << " Plastique..............." << dictionary[ "STYLE_PLASTIQUE" ] << endl; sout << " Cleanlooks.............." << dictionary[ "STYLE_CLEANLOOKS" ] << endl; + sout << " Fusion.................." << dictionary[ "STYLE_FUSION" ] << endl; sout << " Windows CE.............." << dictionary[ "STYLE_WINDOWSCE" ] << endl; sout << " Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl << endl; From 0221d769c76e50d8b331c2cdf527110b62cb3e66 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 18 Oct 2012 13:25:56 +0200 Subject: [PATCH 087/114] Cocoa: fix frameStrutMouseEvents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out that the calculation of mouse pos over the frame strut (title bar) was wrong. When outside the content view, the nsevent coordinates are negative, so to get this correct, we need to calculate the height of the window above the content view and use this information to get the mouse pos in positive coordinates with origin window top left. This bug was especially apperent with QDockWidget, as it became almost impossible to dock a window under such circumstances. Change-Id: I2faf6aab5e2aa0b4e217ea087ceec8c1b1e978bb Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.mm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f4ba8154ca..33d0fb4bae 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -358,11 +358,15 @@ static QTouchDevice *touchDevice = 0; } NSWindow *window = [self window]; - int windowHeight = [window frame].size.height; NSPoint windowPoint = [theEvent locationInWindow]; + + int windowScreenY = [window frame].origin.y + [window frame].size.height; + int viewScreenY = [window convertBaseToScreen:[self convertPoint:[self frame].origin toView:nil]].y; + int titleBarHeight = windowScreenY - viewScreenY; + NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil]; - QPoint qtWindowPoint = QPoint(nsViewPoint.x, windowHeight - nsViewPoint.y); - NSPoint screenPoint = [window convertBaseToScreen : windowPoint]; + QPoint qtWindowPoint = QPoint(nsViewPoint.x, titleBarHeight + nsViewPoint.y); + NSPoint screenPoint = [window convertBaseToScreen:windowPoint]; QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); ulong timestamp = [theEvent timestamp] * 1000; From 4d693b6cdf879a03f77f2a06ca0e1be5605c0fc0 Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Thu, 18 Oct 2012 11:36:48 +0200 Subject: [PATCH 088/114] QNX: Change base font sizes from pixels to points Previously recommended fonts sizes in pixels do not work very well on the new high resolution devices. Current UX documentation recommends certain point sizes for certain roles. Those work well on both type of devices. Change-Id: Ia4faa4cf2d753cab9b10f91d01dfef1450683272 Reviewed-by: Sean Harmer --- src/plugins/platforms/qnx/qqnxsystemsettings.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxsystemsettings.cpp b/src/plugins/platforms/qnx/qqnxsystemsettings.cpp index ae7cb67314..6194a61012 100644 --- a/src/plugins/platforms/qnx/qqnxsystemsettings.cpp +++ b/src/plugins/platforms/qnx/qqnxsystemsettings.cpp @@ -48,11 +48,13 @@ QT_BEGIN_NAMESPACE QHash qt_qnx_createRoleFonts(QPlatformFontDatabase *fontDatabase) { - // See http://docs.blackberry.com/en/developers/deliverables/27299/Text_tablet_1526156_11.jsp - // which recommends using normal font size of 21 pixels and 36 pixels for titles (not covered - // by the theme system). + // See http://docs.blackberry.com/en/developers/deliverables/41577/typography.jsp + // which recommends using + // - small font size of 6 points + // - normal font size of 8 points + // - 11 points for titles (not covered by the theme system). QFont baseFont = fontDatabase->defaultFont(); - baseFont.setPixelSize(21); + baseFont.setPointSize(8); QHash fonts; fonts.insert(QPlatformTheme::SystemFont, new QFont(baseFont)); @@ -70,7 +72,7 @@ QHash qt_qnx_createRoleFonts(QPlatformFontDatabas fonts.insert(QPlatformTheme::ComboLineEditFont, new QFont(baseFont)); QFont smallFont(baseFont); - smallFont.setPixelSize(15); + smallFont.setPointSize(6); fonts.insert(QPlatformTheme::SmallFont, new QFont(smallFont)); fonts.insert(QPlatformTheme::MiniFont, new QFont(smallFont)); From c67a5df8d83f7741c2b7a0491cdc0782cae44971 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Oct 2012 13:30:49 -0700 Subject: [PATCH 089/114] Rename the syncqt -qtdir to -mkspecsdir It's actually looking for the mkspecs (so it can read qconfig.pri to get the Qt version), so give it exactly what it wants. Change-Id: I2957b2d93a8837b8492d313209d45ff3ec01704c Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- bin/syncqt | 26 +++++++++++++------------- configure | 2 +- mkspecs/features/qt_module_headers.prf | 2 +- src/tools/bootstrap/bootstrap.pro | 2 +- tools/configure/configureapp.cpp | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index 3ca057ec6c..a10117bf2e 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -83,8 +83,8 @@ our $quoted_basedir; # Make sure we use Windows line endings for chomp and friends on Windows. $INPUT_RECORD_SEPARATOR = "\r\n" if ($^O eq "msys"); -my $qtbasedir = dirname(dirname($0)); -normalizePath(\$qtbasedir) if (defined $qtbasedir); +my $mkspecsdir = dirname(dirname($0)); +normalizePath(\$mkspecsdir) if (defined $mkspecsdir); # will be defined based on the modules sync.profile our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %modulepris, %explicitheaders, %deprecatedheaders); @@ -128,7 +128,7 @@ sub showUsage print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; print " -minimal Do not create CamelCase headers (default: " . ($minimal ? "yes" : "no") . ")\n"; print " -outdir Specify output directory for sync (default: $out_basedir)\n"; - print " -qtdir Set the path to QtBase (detected: " . (defined $qtbasedir ? $qtbasedir : "-none-") . ")\n"; + print " -mkspecsdir Set the path to the mkspecs (detected: " . (defined $mkspecsdir ? $mkspecsdir : "-none-") . ")\n"; print " -quiet Only report problems, not activity (same as -verbose 0)\n"; print " -v, -verbose Sets the verbosity level (max. 4) (default: $verbose_level)\n"; print " The short form increases the level by +1\n"; @@ -669,8 +669,8 @@ while ( @ARGV ) { } elsif($arg eq "-private") { $var = "create_private_headers"; $val = "yes"; - } elsif($arg eq "-qtdir") { - $var = "qtdir"; + } elsif($arg eq "-mkspecsdir") { + $var = "mkspecsdir"; $val = shift @ARGV; } elsif($arg =~/^-/) { print "Unknown option: $arg\n\n" if(!$var); @@ -746,12 +746,12 @@ while ( @ARGV ) { push @modules_to_sync, $module; $moduleheaders{$module} = $headerdir; $create_uic_class_map = 0; - } elsif ($var eq "qtdir") { + } elsif ($var eq "mkspecsdir") { if($val) { - $qtbasedir = $val; - normalizePath(\$qtbasedir); + $mkspecsdir = $val; + normalizePath(\$mkspecsdir); } else { - die "The -qtdir option requires an argument"; + die "The -mkspecsdir option requires an argument"; } } elsif ($var eq "output") { my $outdir = $val; @@ -767,9 +767,9 @@ while ( @ARGV ) { } die "Cannot automatically detect/use provided path to QtBase's build directory!\n" . - "QTDIR detected/provided: " . (defined $qtbasedir ? $qtbasedir : "-none-") . "\n" . - "Please use the -qtdir option to provide the correct path.\nsyncqt failed" - if (!$qtbasedir || !-d "$qtbasedir/mkspecs"); + "QTDIR detected/provided: " . (defined $mkspecsdir ? $mkspecsdir : "-none-") . "\n" . + "Please use the -mkspecsdir option to provide the correct path.\nsyncqt failed" + if (!$mkspecsdir || !-d $mkspecsdir); # if we have no $basedir we cannot be sure which sources you want, so die die "Could not find any sync.profile for your module!\nPass to syncqt to sync your header files.\nsyncqt failed" if (!$basedir); @@ -792,7 +792,7 @@ my %allmoduleheadersprivate = map { $_ => 1 } @allmoduleheadersprivate; $isunix = checkUnix; #cache checkUnix -my $qt_version = fileContents($qtbasedir."/mkspecs/qconfig.pri"); +my $qt_version = fileContents($mkspecsdir."/qconfig.pri"); if (length($qt_version)) { $qt_version =~ s,.*^QT_VERSION[ \t]*=[ \t]*(\S+).*,$1,sm; } else { diff --git a/configure b/configure index c5804f3d16..78ae73c2d4 100755 --- a/configure +++ b/configure @@ -2200,7 +2200,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then if [ -x "$relpath/bin/syncqt" ]; then mkdir -p "$outpath/bin" echo "#!/bin/sh" >"$outpath/bin/syncqt" - echo "perl \"$relpath/bin/syncqt\" -qtdir \"$outpath\" \"\$@\"" >>"$outpath/bin/syncqt" + echo "perl \"$relpath/bin/syncqt\" -mkspecsdir \"$outpath/mkspecs\" \"\$@\"" >>"$outpath/bin/syncqt" chmod 755 "$outpath/bin/syncqt" fi diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf index ef2f72f36d..0340f234c5 100644 --- a/mkspecs/features/qt_module_headers.prf +++ b/mkspecs/features/qt_module_headers.prf @@ -8,7 +8,7 @@ else: \ qtPrepareTool(QMAKE_SYNCQT, syncqt) contains(QT_CONFIG, private_tests): \ # -developer-build QMAKE_SYNCQT += -check-includes - QMAKE_SYNCQT += -module $$TARGET -qtdir $$[QT_HOST_DATA/get] -outdir $$mod_component_base $$MODULE_BASE_DIR + QMAKE_SYNCQT += -module $$TARGET -mkspecsdir $$[QT_HOST_DATA/get]/mkspecs -outdir $$mod_component_base $$MODULE_BASE_DIR !silent: message($$QMAKE_SYNCQT) system($$QMAKE_SYNCQT)|error("Failed to run: $$QMAKE_SYNCQT") } diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index ffc369fd18..19c0005bcc 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -140,6 +140,6 @@ exists($$QTDIR/.qmake.cache): \ else: \ mod_component_base = $$dirname(_QMAKE_CACHE_) QMAKE_SYNCQT += -minimal -module QtCore -module QtDBus -module QtXml \ - -qtdir $$[QT_HOST_DATA/get] -outdir $$mod_component_base $$dirname(_QMAKE_CONF_) + -mkspecsdir $$[QT_HOST_DATA/get]/mkspecs -outdir $$mod_component_base $$dirname(_QMAKE_CONF_) !silent:message($$QMAKE_SYNCQT) system($$QMAKE_SYNCQT)|error("Failed to run: $$QMAKE_SYNCQT") diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 508cd37ba4..0d4d6d4ec9 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -164,7 +164,7 @@ Configure::Configure(int& argc, char** argv) QTextStream stream(&syncqt_bat); stream << "@echo off" << endl << "call " << QDir::toNativeSeparators(sourcePath + "/bin/syncqt.bat") - << " -qtdir \"" << QDir::toNativeSeparators(buildPath) << "\" %*" << endl; + << " -mkspecsdir \"" << QDir::toNativeSeparators(buildPath) << "/mkspecs\" %*" << endl; syncqt_bat.close(); } } From 0a7e6c5856b26fb5d74919bceb2778fe5c0dc713 Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Thu, 18 Oct 2012 11:02:33 +0300 Subject: [PATCH 090/114] Cocoa: fix coretext memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id85dbf8a2ea8994d9fca07d3f10b43f62ec305a0 Reviewed-by: Morten Johan Sørvig --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 2 ++ src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 1 + 2 files changed, 3 insertions(+) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 0cc69d129c..8306a47e4f 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -149,6 +149,7 @@ QCoreTextFontDatabase::QCoreTextFontDatabase() // layout of the primary display NSDictionary *d = (NSDictionary *) IODisplayCreateInfoDictionary(iodisplay, kIODisplayOnlyPreferredName); uint displaySubpixelLayout = [[d objectForKey:@kDisplaySubPixelLayout] unsignedIntValue]; + [d release]; font_smoothing = (displaySubpixelLayout == kDisplaySubPixelLayoutUndefined ? 0 : 1); [pool release]; @@ -382,6 +383,7 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData NSLog(@"Unable to register font: %@", error); CFRelease(error); } + CGFontRelease(cgFont); } } else { CFErrorRef error; diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index c453cb7d1b..d989de0abb 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -501,6 +501,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition } CGContextRelease(ctx); + CGColorSpaceRelease(colorspace); return im; } From 3ebee851b29e724dfb5fda7f057d105b0b0fa9ba Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Wed, 17 Oct 2012 15:42:06 +0300 Subject: [PATCH 091/114] Cocoa: fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Release the created CGImageRef. Change-Id: If3b36b636ae1302b8a63bbae7285a6461b993f62 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 743c78ed05..bd89f26fca 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -135,7 +135,10 @@ NSImage *qt_mac_cgimage_to_nsimage(CGImageRef image) NSImage *qt_mac_create_nsimage(const QPixmap &pm) { QImage image = pm.toImage(); - return qt_mac_cgimage_to_nsimage(qt_mac_image_to_cgimage(image)); + CGImageRef cgImage = qt_mac_image_to_cgimage(image); + NSImage *nsImage = qt_mac_cgimage_to_nsimage(cgImage); + CGImageRelease(cgImage); + return nsImage; } HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion) From 730a5a994ff46055055c58b25bd059373dddb934 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 18 Oct 2012 19:31:59 +0200 Subject: [PATCH 092/114] Accessibility: make sure right objects are cached on linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The linux test would actually fail because the qobjects created could end up having the same address (create-delete-create...). After an object is deleted, it's not instantly removed from the cache of valid objects. Instead it would stay in the list with it's smart pointer becoming zero. This patch adds the missing null pointer check so we are always up to date. Change-Id: Ia7be14741d4798c2b8e75cb7127298c73cf206ef Reviewed-by: Jan Arve Sæther --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index bea84d04fb..54ecf537f2 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1540,7 +1540,7 @@ QString AtSpiAdaptor::pathForInterface(const QAIPointer &interface, bool inDestr quintptr uintptr = reinterpret_cast(interfaceWithObject->object()); path.prepend(QLatin1String(QSPI_OBJECT_PATH_PREFIX) + QString::number(uintptr)); - if (!inDestructor && !m_handledObjects.contains(uintptr)) + if (!inDestructor && (!m_handledObjects.contains(uintptr) || m_handledObjects.value(uintptr) == 0)) m_handledObjects[uintptr] = QPointer(interfaceWithObject->object()); return path; From 519dce78f166b6e765fdbb0af2b28723643d2c02 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 18 Oct 2012 18:07:54 +0200 Subject: [PATCH 093/114] Clean up instantiation of mapping of AT-SPI roles. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If31b33f1b259f896408a66b0574d640b0ad57019 Reviewed-by: Jan Arve Sæther --- .../linuxaccessibility/bridge.cpp | 131 +++++++++--------- 1 file changed, 65 insertions(+), 66 deletions(-) diff --git a/src/platformsupport/linuxaccessibility/bridge.cpp b/src/platformsupport/linuxaccessibility/bridge.cpp index 6248056fb2..f22dc4e191 100644 --- a/src/platformsupport/linuxaccessibility/bridge.cpp +++ b/src/platformsupport/linuxaccessibility/bridge.cpp @@ -107,80 +107,79 @@ struct RoleMapping { QAccessible::Role role; AtspiRole spiRole; const char *name; - const char *localizedName; }; static RoleMapping map[] = { - { QAccessible::NoRole, ATSPI_ROLE_INVALID, "invalid", QT_TR_NOOP("invalid role") }, - { QAccessible::TitleBar, ATSPI_ROLE_TEXT, "text", QT_TR_NOOP("title bar") }, - { QAccessible::MenuBar, ATSPI_ROLE_MENU_BAR, "menu bar", QT_TR_NOOP("menu bar") }, - { QAccessible::ScrollBar, ATSPI_ROLE_SCROLL_BAR, "scroll bar", QT_TR_NOOP("scroll bar") }, - { QAccessible::Grip, ATSPI_ROLE_UNKNOWN, "unknown", QT_TR_NOOP("grip") }, - { QAccessible::Sound, ATSPI_ROLE_UNKNOWN, "unknown", QT_TR_NOOP("sound") }, - { QAccessible::Cursor, ATSPI_ROLE_ARROW, "arrow", QT_TR_NOOP("cursor") }, - { QAccessible::Caret, ATSPI_ROLE_UNKNOWN, "unknown", QT_TR_NOOP("caret") }, - { QAccessible::AlertMessage, ATSPI_ROLE_ALERT, "alert", QT_TR_NOOP("alert message") }, - { QAccessible::Window, ATSPI_ROLE_WINDOW, "window", QT_TR_NOOP("window") }, - { QAccessible::Client, ATSPI_ROLE_FILLER, "filler", QT_TR_NOOP("filler") }, - { QAccessible::PopupMenu, ATSPI_ROLE_POPUP_MENU, "popup menu", QT_TR_NOOP("popup menu") }, - { QAccessible::MenuItem, ATSPI_ROLE_MENU_ITEM, "menu item", QT_TR_NOOP("menu item") }, - { QAccessible::ToolTip, ATSPI_ROLE_TOOL_TIP, "tool tip", QT_TR_NOOP("tool tip") }, - { QAccessible::Application, ATSPI_ROLE_APPLICATION, "application", QT_TR_NOOP("application") }, - { QAccessible::Document, ATSPI_ROLE_DOCUMENT_FRAME, "document frame", QT_TR_NOOP("document") }, - { QAccessible::Pane, ATSPI_ROLE_PANEL, "panel", QT_TR_NOOP("pane") }, - { QAccessible::Chart, ATSPI_ROLE_CHART, "chart", QT_TR_NOOP("chart") }, - { QAccessible::Dialog, ATSPI_ROLE_DIALOG, "dialog", QT_TR_NOOP("dialog") }, - { QAccessible::Border, ATSPI_ROLE_FRAME, "frame", QT_TR_NOOP("border") }, - { QAccessible::Grouping, ATSPI_ROLE_PANEL, "panel", QT_TR_NOOP("grouping") }, - { QAccessible::Separator, ATSPI_ROLE_SEPARATOR, "separator", QT_TR_NOOP("separator") }, - { QAccessible::ToolBar, ATSPI_ROLE_TOOL_BAR, "tool bar", QT_TR_NOOP("tool bar") }, - { QAccessible::StatusBar, ATSPI_ROLE_STATUS_BAR, "statusbar", QT_TR_NOOP("status bar") }, - { QAccessible::Table, ATSPI_ROLE_TABLE, "table", QT_TR_NOOP("table") }, - { QAccessible::ColumnHeader, ATSPI_ROLE_TABLE_COLUMN_HEADER, "column header", QT_TR_NOOP("column header") }, - { QAccessible::RowHeader, ATSPI_ROLE_TABLE_ROW_HEADER, "row header", QT_TR_NOOP("row header") }, - { QAccessible::Column, ATSPI_ROLE_TABLE_CELL, "table cell", QT_TR_NOOP("column") }, - { QAccessible::Row, ATSPI_ROLE_TABLE_CELL, "table cell", QT_TR_NOOP("row") }, - { QAccessible::Cell, ATSPI_ROLE_TABLE_CELL, "table cell", QT_TR_NOOP("cell") }, - { QAccessible::Link, ATSPI_ROLE_LINK, "link", QT_TR_NOOP("link") }, - { QAccessible::HelpBalloon, ATSPI_ROLE_DIALOG, "dialog", QT_TR_NOOP("help balloon") }, - { QAccessible::Assistant, ATSPI_ROLE_DIALOG, "dialog", QT_TR_NOOP("assistant") }, - { QAccessible::List, ATSPI_ROLE_LIST, "list", QT_TR_NOOP("list") }, - { QAccessible::ListItem, ATSPI_ROLE_LIST_ITEM, "list item", QT_TR_NOOP("list item") }, - { QAccessible::Tree, ATSPI_ROLE_TREE, "tree", QT_TR_NOOP("tree") }, - { QAccessible::TreeItem, ATSPI_ROLE_TABLE_CELL, "tree item", QT_TR_NOOP("tree item") }, - { QAccessible::PageTab, ATSPI_ROLE_PAGE_TAB, "page tab", QT_TR_NOOP("page tab") }, - { QAccessible::PropertyPage, ATSPI_ROLE_PAGE_TAB, "page tab", QT_TR_NOOP("property page") }, - { QAccessible::Indicator, ATSPI_ROLE_UNKNOWN, "unknown", QT_TR_NOOP("indicator") }, - { QAccessible::Graphic, ATSPI_ROLE_IMAGE, "image", QT_TR_NOOP("graphic") }, - { QAccessible::StaticText, ATSPI_ROLE_LABEL, "label", QT_TR_NOOP("label") }, - { QAccessible::EditableText, ATSPI_ROLE_TEXT, "text", QT_TR_NOOP("text") }, - { QAccessible::PushButton, ATSPI_ROLE_PUSH_BUTTON, "push button", QT_TR_NOOP("push button") }, - { QAccessible::CheckBox, ATSPI_ROLE_CHECK_BOX, "check box", QT_TR_NOOP("check box") }, - { QAccessible::RadioButton, ATSPI_ROLE_RADIO_BUTTON, "radio button", QT_TR_NOOP("radio box") }, - { QAccessible::ComboBox, ATSPI_ROLE_COMBO_BOX, "combo box", QT_TR_NOOP("combo box") }, - { QAccessible::ProgressBar, ATSPI_ROLE_PROGRESS_BAR, "progress bar", QT_TR_NOOP("progress bar") }, - { QAccessible::Dial, ATSPI_ROLE_DIAL, "accelerator label", QT_TR_NOOP("dial") }, - { QAccessible::HotkeyField, ATSPI_ROLE_TEXT, "text", QT_TR_NOOP("hotkey field") }, //FIXME text? - { QAccessible::Slider, ATSPI_ROLE_SLIDER, "slider", QT_TR_NOOP("slider") }, - { QAccessible::SpinBox, ATSPI_ROLE_SPIN_BUTTON, "spin button", QT_TR_NOOP("spin box") }, - { QAccessible::Canvas, ATSPI_ROLE_CANVAS, "canvas", QT_TR_NOOP("canvas") }, - { QAccessible::Animation, ATSPI_ROLE_ANIMATION, "animation", QT_TR_NOOP("animation") }, - { QAccessible::Equation, ATSPI_ROLE_TEXT, "text", QT_TR_NOOP("equation") }, - { QAccessible::ButtonDropDown, ATSPI_ROLE_PUSH_BUTTON, "push button", QT_TR_NOOP("button drop down") }, - { QAccessible::ButtonMenu, ATSPI_ROLE_PUSH_BUTTON, "push button", QT_TR_NOOP("button menu") }, - { QAccessible::ButtonDropGrid, ATSPI_ROLE_PUSH_BUTTON, "push button", QT_TR_NOOP("button drop grid") }, - { QAccessible::Whitespace, ATSPI_ROLE_FILLER, "filler", QT_TR_NOOP("whitespace") }, - { QAccessible::PageTabList, ATSPI_ROLE_PAGE_TAB_LIST, "page tab list", QT_TR_NOOP("page tab list") }, - { QAccessible::Clock, ATSPI_ROLE_UNKNOWN, "unknown", QT_TR_NOOP("clock") }, - { QAccessible::Splitter, ATSPI_ROLE_SPLIT_PANE, "split pane", QT_TR_NOOP("splitter") }, - { QAccessible::LayeredPane, ATSPI_ROLE_LAYERED_PANE, "layered pane", QT_TR_NOOP("layered pane") }, - { QAccessible::UserRole, ATSPI_ROLE_UNKNOWN, "unknown", QT_TR_NOOP("user role") } + { QAccessible::NoRole, ATSPI_ROLE_INVALID, QT_TR_NOOP("invalid role") }, + { QAccessible::TitleBar, ATSPI_ROLE_TEXT, QT_TR_NOOP("title bar") }, + { QAccessible::MenuBar, ATSPI_ROLE_MENU_BAR, QT_TR_NOOP("menu bar") }, + { QAccessible::ScrollBar, ATSPI_ROLE_SCROLL_BAR, QT_TR_NOOP("scroll bar") }, + { QAccessible::Grip, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("grip") }, + { QAccessible::Sound, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("sound") }, + { QAccessible::Cursor, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("cursor") }, + { QAccessible::Caret, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("cursor") }, + { QAccessible::AlertMessage, ATSPI_ROLE_ALERT, QT_TR_NOOP("alert message") }, + { QAccessible::Window, ATSPI_ROLE_WINDOW, QT_TR_NOOP("window") }, + { QAccessible::Client, ATSPI_ROLE_FILLER, QT_TR_NOOP("filler") }, + { QAccessible::PopupMenu, ATSPI_ROLE_POPUP_MENU, QT_TR_NOOP("popup menu") }, + { QAccessible::MenuItem, ATSPI_ROLE_MENU_ITEM, QT_TR_NOOP("menu item") }, + { QAccessible::ToolTip, ATSPI_ROLE_TOOL_TIP, QT_TR_NOOP("tool tip") }, + { QAccessible::Application, ATSPI_ROLE_APPLICATION, QT_TR_NOOP("application") }, + { QAccessible::Document, ATSPI_ROLE_DOCUMENT_FRAME, QT_TR_NOOP("document") }, + { QAccessible::Pane, ATSPI_ROLE_PANEL, QT_TR_NOOP("panel") }, + { QAccessible::Chart, ATSPI_ROLE_CHART, QT_TR_NOOP("chart") }, + { QAccessible::Dialog, ATSPI_ROLE_DIALOG, QT_TR_NOOP("dialog") }, + { QAccessible::Border, ATSPI_ROLE_FRAME, QT_TR_NOOP("frame") }, + { QAccessible::Grouping, ATSPI_ROLE_PANEL, QT_TR_NOOP("panel") }, + { QAccessible::Separator, ATSPI_ROLE_SEPARATOR, QT_TR_NOOP("separator") }, + { QAccessible::ToolBar, ATSPI_ROLE_TOOL_BAR, QT_TR_NOOP("tool bar") }, + { QAccessible::StatusBar, ATSPI_ROLE_STATUS_BAR, QT_TR_NOOP("status bar") }, + { QAccessible::Table, ATSPI_ROLE_TABLE, QT_TR_NOOP("table") }, + { QAccessible::ColumnHeader, ATSPI_ROLE_TABLE_COLUMN_HEADER, QT_TR_NOOP("column header") }, + { QAccessible::RowHeader, ATSPI_ROLE_TABLE_ROW_HEADER, QT_TR_NOOP("row header") }, + { QAccessible::Column, ATSPI_ROLE_TABLE_CELL, QT_TR_NOOP("column") }, + { QAccessible::Row, ATSPI_ROLE_TABLE_ROW, QT_TR_NOOP("row") }, + { QAccessible::Cell, ATSPI_ROLE_TABLE_CELL, QT_TR_NOOP("cell") }, + { QAccessible::Link, ATSPI_ROLE_LINK, QT_TR_NOOP("link") }, + { QAccessible::HelpBalloon, ATSPI_ROLE_DIALOG, QT_TR_NOOP("help balloon") }, + { QAccessible::Assistant, ATSPI_ROLE_DIALOG, QT_TR_NOOP("assistant") }, + { QAccessible::List, ATSPI_ROLE_LIST, QT_TR_NOOP("list") }, + { QAccessible::ListItem, ATSPI_ROLE_LIST_ITEM, QT_TR_NOOP("list item") }, + { QAccessible::Tree, ATSPI_ROLE_TREE, QT_TR_NOOP("tree") }, + { QAccessible::TreeItem, ATSPI_ROLE_TABLE_CELL, QT_TR_NOOP("tree item") }, + { QAccessible::PageTab, ATSPI_ROLE_PAGE_TAB, QT_TR_NOOP("page tab") }, + { QAccessible::PropertyPage, ATSPI_ROLE_PAGE_TAB, QT_TR_NOOP("property page") }, + { QAccessible::Indicator, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("indicator") }, + { QAccessible::Graphic, ATSPI_ROLE_IMAGE, QT_TR_NOOP("graphic") }, + { QAccessible::StaticText, ATSPI_ROLE_LABEL, QT_TR_NOOP("label") }, + { QAccessible::EditableText, ATSPI_ROLE_TEXT, QT_TR_NOOP("text") }, + { QAccessible::PushButton, ATSPI_ROLE_PUSH_BUTTON, QT_TR_NOOP("push button") }, + { QAccessible::CheckBox, ATSPI_ROLE_CHECK_BOX, QT_TR_NOOP("check box") }, + { QAccessible::RadioButton, ATSPI_ROLE_RADIO_BUTTON, QT_TR_NOOP("radio button") }, + { QAccessible::ComboBox, ATSPI_ROLE_COMBO_BOX, QT_TR_NOOP("combo box") }, + { QAccessible::ProgressBar, ATSPI_ROLE_PROGRESS_BAR, QT_TR_NOOP("progress bar") }, + { QAccessible::Dial, ATSPI_ROLE_DIAL, QT_TR_NOOP("dial") }, + { QAccessible::HotkeyField, ATSPI_ROLE_TEXT, QT_TR_NOOP("hotkey field") }, + { QAccessible::Slider, ATSPI_ROLE_SLIDER, QT_TR_NOOP("slider") }, + { QAccessible::SpinBox, ATSPI_ROLE_SPIN_BUTTON, QT_TR_NOOP("spin box") }, + { QAccessible::Canvas, ATSPI_ROLE_CANVAS, QT_TR_NOOP("canvas") }, + { QAccessible::Animation, ATSPI_ROLE_ANIMATION, QT_TR_NOOP("animation") }, + { QAccessible::Equation, ATSPI_ROLE_TEXT, QT_TR_NOOP("equation") }, + { QAccessible::ButtonDropDown, ATSPI_ROLE_PUSH_BUTTON, QT_TR_NOOP("button drop down") }, + { QAccessible::ButtonMenu, ATSPI_ROLE_PUSH_BUTTON, QT_TR_NOOP("button menu") }, + { QAccessible::ButtonDropGrid, ATSPI_ROLE_PUSH_BUTTON, QT_TR_NOOP("button drop grid") }, + { QAccessible::Whitespace, ATSPI_ROLE_FILLER, QT_TR_NOOP("whitespace") }, + { QAccessible::PageTabList, ATSPI_ROLE_PAGE_TAB_LIST, QT_TR_NOOP("page tab list") }, + { QAccessible::Clock, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("clock") }, + { QAccessible::Splitter, ATSPI_ROLE_SPLIT_PANE, QT_TR_NOOP("splitter") }, + { QAccessible::LayeredPane, ATSPI_ROLE_LAYERED_PANE, QT_TR_NOOP("layered pane") }, + { QAccessible::UserRole, ATSPI_ROLE_UNKNOWN, QT_TR_NOOP("unknown") } }; void QSpiAccessibleBridge::initializeConstantMappings() { for (uint i = 0; i < sizeof(map) / sizeof(RoleMapping); ++i) - qSpiRoleMapping.insert(map[i].role, RoleNames(map[i].spiRole, QLatin1String(map[i].name), tr(map[i].localizedName))); + qSpiRoleMapping.insert(map[i].role, RoleNames(map[i].spiRole, QLatin1String(map[i].name), tr(map[i].name))); } QT_END_NAMESPACE From 0783b1670d5862b51747b0246a222878ff3b9c44 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 12:57:31 +0200 Subject: [PATCH 094/114] Doc fix in return value of QDate::setYMD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie107e451a7b2a084fb6131939f212acd412a9df6 Reviewed-by: Mitch Curtis Reviewed-by: Jerome Pasion Reviewed-by: Jan Arve Sæther --- src/corelib/tools/qdatetime.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index cbdd183f33..a9d3095224 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -847,6 +847,7 @@ QString QDate::toString(const QString& format) const If \a y is in the range 0 to 99, it is interpreted as 1900 to 1999. + Returns \c false if the date is invalid. Use setDate() instead. */ From bb73c085a6092ea10c60e652cb66d8c369cfb65e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Oct 2012 11:08:13 +0200 Subject: [PATCH 095/114] normalise signal/slot signatures [QtWidgets tests] Change-Id: Iffab60f0911a55e4be09faeb29df0bae1ea2eb19 Reviewed-by: Friedemann Kleint --- .../dialogs/qfiledialog/tst_qfiledialog.cpp | 54 +++++++++---------- .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 18 +++---- .../widgets/dialogs/qsidebar/tst_qsidebar.cpp | 4 +- .../tst_qgraphicsproxywidget.cpp | 2 +- .../qgraphicsscene/tst_qgraphicsscene.cpp | 4 +- .../tst_qgraphicssceneindex.cpp | 4 +- .../qgraphicsview/tst_qgraphicsview.cpp | 4 +- .../itemviews/qcolumnview/tst_qcolumnview.cpp | 4 +- .../itemviews/qheaderview/tst_qheaderview.cpp | 8 +-- .../qitemdelegate/tst_qitemdelegate.cpp | 2 +- .../itemviews/qlistview/tst_qlistview.cpp | 4 +- .../itemviews/qlistwidget/tst_qlistwidget.cpp | 42 +++++++-------- .../itemviews/qtableview/tst_qtableview.cpp | 6 +-- .../qtablewidget/tst_qtablewidget.cpp | 2 +- .../itemviews/qtreeview/tst_qtreeview.cpp | 20 +++---- .../itemviews/qtreewidget/tst_qtreewidget.cpp | 16 +++--- .../widgets/kernel/qaction/tst_qaction.cpp | 2 +- .../kernel/qapplication/tst_qapplication.cpp | 2 +- .../kernel/qshortcut/tst_qshortcut.cpp | 4 +- .../widgets/kernel/qwidget/tst_qwidget.cpp | 4 +- .../util/qcompleter/tst_qcompleter.cpp | 4 +- .../qabstractslider/tst_qabstractslider.cpp | 4 +- .../widgets/qbuttongroup/tst_qbuttongroup.cpp | 8 +-- .../widgets/qcombobox/tst_qcombobox.cpp | 4 +- .../qdatetimeedit/tst_qdatetimeedit.cpp | 26 ++++----- .../qdialogbuttonbox/tst_qdialogbuttonbox.cpp | 4 +- .../qdoublespinbox/tst_qdoublespinbox.cpp | 2 +- .../qfontcombobox/tst_qfontcombobox.cpp | 8 +-- .../widgets/qlineedit/tst_qlineedit.cpp | 8 +-- .../widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 24 ++++----- .../qmdisubwindow/tst_qmdisubwindow.cpp | 2 +- .../auto/widgets/widgets/qmenu/tst_qmenu.cpp | 2 +- .../widgets/widgets/qmenubar/tst_qmenubar.cpp | 2 +- .../widgets/widgets/qspinbox/tst_qspinbox.cpp | 2 +- .../widgets/qtextbrowser/tst_qtextbrowser.cpp | 4 +- .../widgets/qtextedit/tst_qtextedit.cpp | 2 +- .../widgets/widgets/qtoolbar/tst_qtoolbar.cpp | 2 +- .../qheaderview/qheaderviewtest1.cpp | 2 +- 38 files changed, 158 insertions(+), 158 deletions(-) diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 8a2d6e33ec..32610fda18 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -196,7 +196,7 @@ void tst_QFiledialog::currentChangedSignal() { QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); - QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(const QString &))); + QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); QListView* listView = qFindChild(&fd, "listView"); QVERIFY(listView); @@ -224,7 +224,7 @@ void tst_QFiledialog::directoryEnteredSignal() fd.setOptions(QFileDialog::DontUseNativeDialog); fd.show(); QTRY_COMPARE(fd.isVisible(), true); - QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(const QString &))); + QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); // sidebar QSidebar *sidebar = qFindChild(&fd, "sidebar"); @@ -287,7 +287,7 @@ void tst_QFiledialog::filesSelectedSignal() fd.setDirectory(testDir); QFETCH(QFileDialog::FileMode, fileMode); fd.setFileMode(fileMode); - QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); + QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList))); fd.show(); QVERIFY(QTest::qWaitForWindowExposed(&fd)); @@ -327,7 +327,7 @@ void tst_QFiledialog::filterSelectedSignal() QNonNativeFileDialog fd; fd.setAcceptMode(QFileDialog::AcceptSave); fd.show(); - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); QStringList filterChoices; filterChoices << "Image files (*.png *.xpm *.jpg)" @@ -368,10 +368,10 @@ void tst_QFiledialog::directory() QFileSystemModel *model = qFindChild(&fd, "qt_filesystem_model"); QVERIFY(model); fd.setDirectory(QDir::currentPath()); - QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(const QString &))); - QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(const QString &))); - QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); + QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); + QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); QCOMPARE(QDir::current().absolutePath(), fd.directory().absolutePath()); QDir temp = QDir::temp(); @@ -559,10 +559,10 @@ void tst_QFiledialog::completer_up() { QNonNativeFileDialog fd; fd.setOptions(QFileDialog::DontUseNativeDialog); - QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(const QString &))); - QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(const QString &))); - QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); + QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); + QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); fd.show(); QLineEdit *lineEdit = qFindChild(&fd, "fileNameEdit"); @@ -649,10 +649,10 @@ void tst_QFiledialog::filters() { QNonNativeFileDialog fd; fd.setOptions(QFileDialog::DontUseNativeDialog); - QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(const QString &))); - QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(const QString &))); - QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); + QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); + QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); QCOMPARE(fd.nameFilters(), QStringList("All Files (*)")); // effects @@ -702,7 +702,7 @@ void tst_QFiledialog::filters() void tst_QFiledialog::selectFilter() { QNonNativeFileDialog fd; - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); QCOMPARE(fd.selectedNameFilter(), QString("All Files (*)")); QStringList filters; filters << "Image files (*.png *.xpm *.jpg)" @@ -728,10 +728,10 @@ void tst_QFiledialog::history() fd.setViewMode(QFileDialog::List); QFileSystemModel *model = qFindChild(&fd, "qt_filesystem_model"); QVERIFY(model); - QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(const QString &))); - QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(const QString &))); - QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); + QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); + QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); QCOMPARE(model->index(fd.history().first()), model->index(QDir::toNativeSeparators(fd.directory().absolutePath()))); fd.setDirectory(QDir::current().absolutePath()); QStringList history; @@ -890,10 +890,10 @@ void tst_QFiledialog::selectFiles() QDir dir; QVERIFY(dir.mkpath(tempPath)); fd.setDirectory(tempPath); - QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(const QString &))); - QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(const QString &))); - QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); - QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(const QString &))); + QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); + QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); + QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList))); + QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); fd.show(); fd.setFileMode(QFileDialog::ExistingFiles); @@ -1043,7 +1043,7 @@ void tst_QFiledialog::historyBack() QToolButton *forwardButton = qFindChild(&fd, "forwardButton"); QVERIFY(forwardButton); - QSignalSpy spy(model, SIGNAL(rootPathChanged(const QString &))); + QSignalSpy spy(model, SIGNAL(rootPathChanged(QString))); QString home = fd.directory().absolutePath(); QString desktop = QDir::homePath(); @@ -1091,7 +1091,7 @@ void tst_QFiledialog::historyForward() QFileSystemModel *model = qFindChild(&fd, "qt_filesystem_model"); QVERIFY(model); - QSignalSpy spy(model, SIGNAL(rootPathChanged(const QString &))); + QSignalSpy spy(model, SIGNAL(rootPathChanged(QString))); QString home = fd.directory().absolutePath(); QString desktop = QDir::homePath(); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index e0256d207c..46f0e5aafb 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -202,7 +202,7 @@ void tst_QFileSystemModel::rootPath() { QCOMPARE(model->rootPath(), QString(QDir().path())); - QSignalSpy rootChanged(model, SIGNAL(rootPathChanged(const QString &))); + QSignalSpy rootChanged(model, SIGNAL(rootPathChanged(QString))); QModelIndex root = model->setRootPath(model->rootPath()); root = model->setRootPath("this directory shouldn't exist"); QCOMPARE(rootChanged.count(), 0); @@ -430,8 +430,8 @@ void tst_QFileSystemModel::rowCount() QString tmp = flatDirTestPath; QVERIFY(createFiles(tmp, QStringList())); - QSignalSpy spy2(model, SIGNAL(rowsInserted(const QModelIndex &, int, int))); - QSignalSpy spy3(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int))); + QSignalSpy spy2(model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spy3(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); #if !defined(Q_OS_WINCE) QStringList files = QStringList() << "b" << "d" << "f" << "h" << "j" << ".a" << ".c" << ".e" << ".g"; @@ -472,8 +472,8 @@ void tst_QFileSystemModel::rowsInserted() QFETCH(int, count); model->sort(0, (Qt::SortOrder)assending); - QSignalSpy spy0(model, SIGNAL(rowsInserted(const QModelIndex &, int, int))); - QSignalSpy spy1(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int))); + QSignalSpy spy0(model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spy1(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); int oldCount = model->rowCount(root); QStringList files; for (int i = 0; i < count; ++i) @@ -528,8 +528,8 @@ void tst_QFileSystemModel::rowsRemoved() model->sort(0, (Qt::SortOrder)assending); QTest::qWait(WAITTIME); - QSignalSpy spy0(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); - QSignalSpy spy1(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int))); + QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy spy1(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); int oldCount = model->rowCount(root); for (int i = count - 1; i >= 0; --i) { //qDebug() << "removing" << model->index(i, 0, root).data().toString(); @@ -588,7 +588,7 @@ void tst_QFileSystemModel::dataChanged() QFETCH(int, assending); model->sort(0, (Qt::SortOrder)assending); - QSignalSpy spy(model, SIGNAL(dataChanged (const QModelIndex &, const QModelIndex &))); + QSignalSpy spy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); QStringList files; for (int i = 0; i < count; ++i) files.append(model->index(i, 0, root).data().toString()); @@ -763,7 +763,7 @@ void tst_QFileSystemModel::setData_data() void tst_QFileSystemModel::setData() { - QSignalSpy spy(model, SIGNAL(fileRenamed(const QString&, const QString&, const QString&))); + QSignalSpy spy(model, SIGNAL(fileRenamed(QString,QString,QString))); QString tmp = flatDirTestPath; QFETCH(QStringList, files); QFETCH(QString, oldFileName); diff --git a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp index 809627e188..9752e163b4 100644 --- a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp +++ b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp @@ -107,7 +107,7 @@ void tst_QSidebar::selectUrls() QSidebar qsidebar; qsidebar.setModelAndUrls(&fsmodel, urls); - QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(const QUrl &))); + QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(QUrl))); qsidebar.selectUrl(urls.at(0)); QCOMPARE(spy.count(), 0); } @@ -214,7 +214,7 @@ void tst_QSidebar::goToUrl() qsidebar.setModelAndUrls(&fsmodel, urls); qsidebar.show(); - QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(const QUrl &))); + QSignalSpy spy(&qsidebar, SIGNAL(goToUrl(QUrl))); QTest::mousePress(qsidebar.viewport(), Qt::LeftButton, 0, qsidebar.visualRect(qsidebar.model()->index(0, 0)).center()); QCOMPARE(spy.count(), 1); QCOMPARE((spy.value(0)).at(0).toUrl(), urls.first()); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index e9865f2b22..883c47b26a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -2768,7 +2768,7 @@ void tst_QGraphicsProxyWidget::windowOpacity() QVERIFY(view.isActiveWindow()); qRegisterMetaType >("QList"); - QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList &))); + QSignalSpy signalSpy(&scene, SIGNAL(changed(QList))); EventSpy eventSpy(widget); QVERIFY(widget->isVisible()); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 2f09ca5005..90d21d6d95 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3655,7 +3655,7 @@ void tst_QGraphicsScene::changedSignal() QFETCH(bool, withView); QGraphicsScene scene; ChangedListener cl; - connect(&scene, SIGNAL(changed(const QList &)), &cl, SLOT(changed(const QList &))); + connect(&scene, SIGNAL(changed(QList)), &cl, SLOT(changed(QList))); QGraphicsView *view = 0; if (withView) @@ -4533,7 +4533,7 @@ void tst_QGraphicsScene::zeroScale() QGraphicsView view(&scene); ChangedListener cl; - connect(&scene, SIGNAL(changed(const QList &)), &cl, SLOT(changed(const QList &))); + connect(&scene, SIGNAL(changed(QList)), &cl, SLOT(changed(QList))); QGraphicsRectItem *rect1 = new QGraphicsRectItem(0, 0, 0.0000001, 0.00000001); scene.addItem(rect1); diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index c5cf8b0056..70ebd3c8a7 100644 --- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -189,10 +189,10 @@ void tst_QGraphicsSceneIndex::connectedToSceneRectChanged() }; MyScene scene; // Uses QGraphicsSceneBspTreeIndex by default. - QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(const QRectF&))), 1); + QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(QRectF))), 1); scene.setItemIndexMethod(QGraphicsScene::NoIndex); // QGraphicsSceneLinearIndex - QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(const QRectF&))), 1); + QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(QRectF))), 1); } void tst_QGraphicsSceneIndex::items() diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 0ddae14738..474ac47ea1 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -3157,9 +3157,9 @@ void tst_QGraphicsView::task239729_noViewUpdate() if (a) { view = new QGraphicsView(&scene); - connect(&scene, SIGNAL(changed(const QList &)), &cl, SLOT(changed(const QList &))); + connect(&scene, SIGNAL(changed(QList)), &cl, SLOT(changed(QList))); } else { - connect(&scene, SIGNAL(changed(const QList &)), &cl, SLOT(changed(const QList &))); + connect(&scene, SIGNAL(changed(QList)), &cl, SLOT(changed(QList))); view = new QGraphicsView(&scene); } diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp index 1857e18c9e..60c0906d75 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp @@ -589,7 +589,7 @@ void tst_QColumnView::clicked() QVERIFY(parent.isValid()); qRegisterMetaType("QModelIndex"); - QSignalSpy clickedSpy(&view, SIGNAL(clicked(const QModelIndex &))); + QSignalSpy clickedSpy(&view, SIGNAL(clicked(QModelIndex))); QPoint localPoint = view.visualRect(home).center(); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint); @@ -829,7 +829,7 @@ void tst_QColumnView::swapPreview() QStringListModel model(sl); view.setModel(&model); view.setCurrentIndex(view.indexAt(QPoint(1, 1))); - connect(&view, SIGNAL(updatePreviewWidget(const QModelIndex &)), + connect(&view, SIGNAL(updatePreviewWidget(QModelIndex)), this, SLOT(setPreviewWidget())); view.setCurrentIndex(view.indexAt(QPoint(1, 1))); QTest::qWait(ANIMATION_DELAY); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index c86eed1deb..844c66432e 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -416,7 +416,7 @@ void tst_QHeaderView::init() } */ - QSignalSpy spy(view, SIGNAL(sectionCountChanged(int, int))); + QSignalSpy spy(view, SIGNAL(sectionCountChanged(int,int))); view->setModel(model); QCOMPARE(spy.count(), 1); view->resize(200,200); @@ -846,7 +846,7 @@ void tst_QHeaderView::swapSections() QVector logical = (QVector() << 0 << 1 << 2 << 3); - QSignalSpy spy1(view, SIGNAL(sectionMoved(int, int, int))); + QSignalSpy spy1(view, SIGNAL(sectionMoved(int,int,int))); QCOMPARE(view->sectionsMoved(), false); view->swapSections(1, 1); @@ -914,7 +914,7 @@ void tst_QHeaderView::moveSection() QVERIFY(from.count() == moved.count()); QVERIFY(view->count() == logical.count()); - QSignalSpy spy1(view, SIGNAL(sectionMoved(int, int, int))); + QSignalSpy spy1(view, SIGNAL(sectionMoved(int,int,int))); QCOMPARE(view->sectionsMoved(), false); for (int h = 0; h < hidden.count(); ++h) @@ -1227,7 +1227,7 @@ void tst_QHeaderView::resizeSection() for (int j = 0; j < logical.count(); ++j) view->resizeSection(logical.at(j), initial); - QSignalSpy spy(view, SIGNAL(sectionResized(int, int, int))); + QSignalSpy spy(view, SIGNAL(sectionResized(int,int,int))); for (int k = 0; k < logical.count(); ++k) view->resizeSection(logical.at(k), size.at(k)); diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index c6a3a69088..bed1d52f94 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -702,7 +702,7 @@ void tst_QItemDelegate::eventFilter() qRegisterMetaType("QAbstractItemDelegate::EndEditHint"); - QSignalSpy commitDataSpy(&delegate, SIGNAL(commitData(QWidget *))); + QSignalSpy commitDataSpy(&delegate, SIGNAL(commitData(QWidget*))); QSignalSpy closeEditorSpy(&delegate, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint))); diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index d252d78624..9f3cd0a3e1 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -657,7 +657,7 @@ void tst_QListView::clicked() QModelIndex index = view.indexAt(p); if (!index.isValid()) continue; - QSignalSpy spy(&view, SIGNAL(clicked(const QModelIndex&))); + QSignalSpy spy(&view, SIGNAL(clicked(QModelIndex))); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p); QCOMPARE(spy.count(), 1); } @@ -1568,7 +1568,7 @@ void tst_QListView::task228566_infiniteRelayout() view.show(); QTest::qWait(100); //make sure the layout is done once - QSignalSpy spy(view.horizontalScrollBar(), SIGNAL(rangeChanged(int, int))); + QSignalSpy spy(view.horizontalScrollBar(), SIGNAL(rangeChanged(int,int))); QTest::qWait(200); //the layout should already have been done diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index b882b56735..7e246e5936 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -182,23 +182,23 @@ void tst_QListWidget::initTestCase() testWidget = new QListWidget(); testWidget->show(); - connect(testWidget->model(), SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeInserted(QModelIndex, int, int))); - connect(testWidget->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), - this, SLOT(rowsInserted(QModelIndex, int, int))); - connect(testWidget->model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); - connect(testWidget->model(), SIGNAL(rowsRemoved(QModelIndex, int, int)), - this, SLOT(rowsRemoved(QModelIndex, int, int))); + connect(testWidget->model(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); + connect(testWidget->model(), SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(rowsInserted(QModelIndex,int,int))); + connect(testWidget->model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); + connect(testWidget->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(rowsRemoved(QModelIndex,int,int))); - connect(testWidget->model(), SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), - this, SLOT(columnsAboutToBeInserted(QModelIndex, int, int))); - connect(testWidget->model(), SIGNAL(columnsInserted(QModelIndex, int, int)), - this, SLOT(columnsInserted(QModelIndex, int, int))); - connect(testWidget->model(), SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(columnsAboutToBeRemoved(QModelIndex, int, int))); - connect(testWidget->model(), SIGNAL(columnsRemoved(QModelIndex, int, int)), - this, SLOT(columnsRemoved(QModelIndex, int, int))); + connect(testWidget->model(), SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(columnsAboutToBeInserted(QModelIndex,int,int))); + connect(testWidget->model(), SIGNAL(columnsInserted(QModelIndex,int,int)), + this, SLOT(columnsInserted(QModelIndex,int,int))); + connect(testWidget->model(), SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(columnsAboutToBeRemoved(QModelIndex,int,int))); + connect(testWidget->model(), SIGNAL(columnsRemoved(QModelIndex,int,int)), + this, SLOT(columnsRemoved(QModelIndex,int,int))); checkDefaultValues(); } @@ -1187,8 +1187,8 @@ void tst_QListWidget::setData() testWidget->insertItems(0, initialItems); QCOMPARE(testWidget->count(), initialItems.count()); - QSignalSpy itemChanged(testWidget, SIGNAL(itemChanged(QListWidgetItem *))); - QSignalSpy dataChanged(testWidget->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + QSignalSpy itemChanged(testWidget, SIGNAL(itemChanged(QListWidgetItem*))); + QSignalSpy dataChanged(testWidget->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex))); for (int i=0; i < roles.count(); ++i) { if (manipulateModel) @@ -1454,7 +1454,7 @@ void tst_QListWidget::changeDataWithSorting() for (int j = 0; j < model->rowCount(QModelIndex()); ++j) persistent << model->index(j, 0, QModelIndex()); - QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); QSignalSpy layoutChangedSpy(model, SIGNAL(layoutChanged())); QListWidgetItem *item = w.item(itemIndex); @@ -1569,7 +1569,7 @@ void tst_QListWidget::task199503_crashWhenCleared() QListWidget w; w.addItems( QStringList() << "item1" << "item2" << "item3"); w.setCurrentRow(0); - w.connect(&w, SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem*)), SLOT(clear())); + w.connect(&w, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(clear())); w.setCurrentRow(1); } @@ -1630,7 +1630,7 @@ void tst_QListWidget::QTBUG8086_currentItemChangedOnClick() edit.setFocus(); win.show(); - QSignalSpy spy(&list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*))); + QSignalSpy spy(&list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*))); QVERIFY(QTest::qWaitForWindowExposed(&win)); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index dc4171ef56..2fbd90a3fe 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -2028,7 +2028,7 @@ void tst_QTableView::resizeRowsToContents() delegate.hint = QSize(cellWidth, cellHeight); - QSignalSpy resizedSpy(view.verticalHeader(), SIGNAL(sectionResized(int, int, int))); + QSignalSpy resizedSpy(view.verticalHeader(), SIGNAL(sectionResized(int,int,int))); view.resizeRowsToContents(); QCOMPARE(resizedSpy.count(), model.rowCount()); @@ -2075,7 +2075,7 @@ void tst_QTableView::resizeColumnsToContents() delegate.hint = QSize(cellWidth, cellHeight); - QSignalSpy resizedSpy(view.horizontalHeader(), SIGNAL(sectionResized(int, int, int))); + QSignalSpy resizedSpy(view.horizontalHeader(), SIGNAL(sectionResized(int,int,int))); view.resizeColumnsToContents(); QCOMPARE(resizedSpy.count(), model.columnCount()); @@ -3981,7 +3981,7 @@ Q_OBJECT public: TestTableView(QWidget *parent = 0) : QTableView(parent) { - connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(openEditor(const QModelIndex&))); + connect(this, SIGNAL(entered(QModelIndex)), this, SLOT(openEditor(QModelIndex))); } ~TestTableView(){} public slots: diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index c02479a7c0..2c93492fe9 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -1334,7 +1334,7 @@ void tst_QTableWidget::setItemWithSorting() w.sortItems(sortColumn, static_cast(sortOrder)); w.setSortingEnabled(true); - QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); QSignalSpy layoutChangedSpy(model, SIGNAL(layoutChanged())); if (i == 0) { diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index b2a87164f1..314592b987 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -1428,8 +1428,8 @@ void tst_QTreeView::expandAndCollapse() QModelIndex a = model.index(0, 0, QModelIndex()); QModelIndex b = model.index(0, 0, a); - QSignalSpy expandedSpy(&view, SIGNAL(expanded(const QModelIndex&))); - QSignalSpy collapsedSpy(&view, SIGNAL(collapsed(const QModelIndex&))); + QSignalSpy expandedSpy(&view, SIGNAL(expanded(QModelIndex))); + QSignalSpy collapsedSpy(&view, SIGNAL(collapsed(QModelIndex))); QVariantList args; for (int y = 0; y < 2; ++y) { @@ -1552,8 +1552,8 @@ void tst_QTreeView::expandAndCollapseAll() view.setUniformRowHeights(true); view.setModel(&model); - QSignalSpy expandedSpy(&view, SIGNAL(expanded(const QModelIndex&))); - QSignalSpy collapsedSpy(&view, SIGNAL(collapsed(const QModelIndex&))); + QSignalSpy expandedSpy(&view, SIGNAL(expanded(QModelIndex))); + QSignalSpy collapsedSpy(&view, SIGNAL(collapsed(QModelIndex))); view.expandAll(); view.show(); @@ -1982,7 +1982,7 @@ void tst_QTreeView::clicked() QModelIndex index = view.indexAt(p); if (!index.isValid()) continue; - QSignalSpy spy(&view, SIGNAL(clicked(const QModelIndex&))); + QSignalSpy spy(&view, SIGNAL(clicked(QModelIndex))); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p); QTRY_COMPARE(spy.count(), 1); } @@ -2329,7 +2329,7 @@ void tst_QTreeView::selection() treeView.setSelectionBehavior(QAbstractItemView::SelectRows); treeView.setSelectionMode(QAbstractItemView::ExtendedSelection); - connect(treeView.selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + connect(treeView.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionOrderTest())); treeView.show(); @@ -3756,7 +3756,7 @@ public slots: //let's select the last item QModelIndex idx = model()->index(0, 0); selectionModel()->select(QItemSelection(idx, idx), QItemSelectionModel::Select); - disconnect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(handleSelectionChanged())); + disconnect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSelectionChanged())); } }; @@ -3769,7 +3769,7 @@ void tst_QTreeView::task248022_changeSelection() QStringListModel model(list); view.setSelectionMode(QAbstractItemView::ExtendedSelection); view.setModel(&model); - view.connect(view.selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(handleSelectionChanged())); + view.connect(view.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(handleSelectionChanged())); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.visualRect(model.index(1)).center()); QCOMPARE(view.selectionModel()->selectedIndexes().count(), list.count()); } @@ -3935,8 +3935,8 @@ public: // set up the model to have two top level items and a few others m_selectionModel = new QItemSelectionModel(this, this); // owned by this - connect(m_selectionModel, SIGNAL(currentChanged(const QModelIndex &,const QModelIndex &)), - this, SLOT(slotCurrentChanged(const QModelIndex &,const QModelIndex &))); + connect(m_selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), + this, SLOT(slotCurrentChanged(QModelIndex,QModelIndex))); }; int rowCount(const QModelIndex &parent) const diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index fe5b5f4def..fa57da0d5d 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -383,7 +383,7 @@ void tst_QTreeWidget::currentItem() tree.setSelectionBehavior(x ? QAbstractItemView::SelectItems : QAbstractItemView::SelectRows); QSignalSpy currentItemChangedSpy( - &tree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); + &tree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); QSignalSpy itemSelectionChangedSpy( &tree, SIGNAL(itemSelectionChanged())); @@ -1719,9 +1719,9 @@ void tst_QTreeWidget::setData() testWidget->setHeaderItem(headerItem); QSignalSpy headerDataChangedSpy( - testWidget->model(), SIGNAL(headerDataChanged(Qt::Orientation, int, int))); + testWidget->model(), SIGNAL(headerDataChanged(Qt::Orientation,int,int))); QSignalSpy dataChangedSpy( - testWidget->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + testWidget->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex))); QSignalSpy itemChangedSpy( testWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int))); headerItem->setText(0, "test"); @@ -2403,7 +2403,7 @@ void tst_QTreeWidget::changeDataWithSorting() for (int j = 0; j < model->rowCount(QModelIndex()); ++j) persistent << model->index(j, 0, QModelIndex()); - QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); QSignalSpy layoutChangedSpy(model, SIGNAL(layoutChanged())); QTreeWidgetItem *item = w.topLevelItem(itemIndex); @@ -2579,7 +2579,7 @@ void tst_QTreeWidget::changeDataWithStableSorting() for (int j = 0; j < model->rowCount(QModelIndex()); ++j) persistent << model->index(j, 0, QModelIndex()); - QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); + QSignalSpy dataChangedSpy(model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); QSignalSpy layoutChangedSpy(model, SIGNAL(layoutChanged())); StableItem *item = static_cast(w.topLevelItem(itemIndex)); @@ -2675,8 +2675,8 @@ void tst_QTreeWidget::expandAndCallapse() for (int j = 0; j < 10; ++j) new QTreeWidgetItem(p, QStringList() << QString("%1").arg(j)); } - QSignalSpy spy0(&tw, SIGNAL(itemExpanded(QTreeWidgetItem *))); - QSignalSpy spy1(&tw, SIGNAL(itemCollapsed(QTreeWidgetItem *))); + QSignalSpy spy0(&tw, SIGNAL(itemExpanded(QTreeWidgetItem*))); + QSignalSpy spy1(&tw, SIGNAL(itemCollapsed(QTreeWidgetItem*))); tw.expandItem(p); @@ -3183,7 +3183,7 @@ void tst_QTreeWidget::emitDataChanged() { QTreeWidget *tree = new QTreeWidget; - QSignalSpy spy(tree, SIGNAL(itemChanged(QTreeWidgetItem *, int))); + QSignalSpy spy(tree, SIGNAL(itemChanged(QTreeWidgetItem*,int))); TreeWidgetItem *item = new TreeWidgetItem(); tree->insertTopLevelItem(0, item); item->_emitDataChanged(); diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 8bcfe1f77c..b5e51d9204 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -369,7 +369,7 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() checkedAction->setChecked(true); QSignalSpy actionSpy(checkedAction, SIGNAL(triggered(bool))); - QSignalSpy actionGroupSpy(&ag, SIGNAL(triggered(QAction *))); + QSignalSpy actionGroupSpy(&ag, SIGNAL(triggered(QAction*))); QCOMPARE(actionGroupSpy.count(), 0); QCOMPARE(actionSpy.count(), 0); checkedAction->trigger(); diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index abb979c76c..4ce2795c9a 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1513,7 +1513,7 @@ void tst_QApplication::focusChanged() int argc = 0; QApplication app(argc, 0, QApplication::GuiServer); - QSignalSpy spy(&app, SIGNAL(focusChanged(QWidget *, QWidget *))); + QSignalSpy spy(&app, SIGNAL(focusChanged(QWidget*,QWidget*))); QWidget *now = 0; QWidget *old = 0; diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 7fccc494ec..d65a98d7ba 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -218,8 +218,8 @@ void tst_QShortcut::initTestCase() mainW->show(); mainW->activateWindow(); QVERIFY(QTest::qWaitForWindowActive(mainW)); - connect( mainW->statusBar(), SIGNAL(messageChanged(const QString&)), - this, SLOT(statusMessage(const QString&)) ); + connect( mainW->statusBar(), SIGNAL(messageChanged(QString)), + this, SLOT(statusMessage(QString)) ); } void tst_QShortcut::cleanupTestCase() diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b4f31acaef..1052a9100d 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4311,7 +4311,7 @@ void tst_QWidget::qobject_castInDestroyedSlot() QWidget *widget = new QWidget(); - QObject::connect(widget, SIGNAL(destroyed(QObject *)), &checker, SLOT(destroyedSlot(QObject *))); + QObject::connect(widget, SIGNAL(destroyed(QObject*)), &checker, SLOT(destroyedSlot(QObject*))); delete widget; QVERIFY(checker.wasQWidget == true); @@ -8757,7 +8757,7 @@ class MyEvilObject : public QObject public: MyEvilObject(QWidget *widgetToCrash) : QObject(), widget(widgetToCrash) { - connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(beEvil(QObject *))); + connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(beEvil(QObject*))); delete widget; } QWidget *widget; diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index c341ab1ad1..2fbe2a2c16 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1184,7 +1184,7 @@ void tst_QCompleter::disabledItems() model->appendRow(suggestions); model->appendRow(new QStandardItem("suggestions Enabled")); QCompleter *completer = new QCompleter(model, &lineEdit); - QSignalSpy spy(completer, SIGNAL(activated(const QString &))); + QSignalSpy spy(completer, SIGNAL(activated(QString))); lineEdit.setCompleter(completer); lineEdit.show(); @@ -1207,7 +1207,7 @@ void tst_QCompleter::task178797_activatedOnReturn() QLineEdit *ledit = new QLineEdit; QCompleter *completer = new QCompleter(words); ledit->setCompleter(completer); - QSignalSpy spy(completer, SIGNAL(activated(const QString))); + QSignalSpy spy(completer, SIGNAL(activated(QString))); QCOMPARE(spy.count(), 0); ledit->show(); QTest::keyClick(ledit, Qt::Key_F); diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index a7bcdb1e2a..548d5b7c26 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -1130,7 +1130,7 @@ void tst_QAbstractSlider::rangeChanged() QFETCH(int, expectedCount); QSlider slider; slider.setRange(minimum, maximum); - QSignalSpy spy(&slider, SIGNAL(rangeChanged(int, int))); + QSignalSpy spy(&slider, SIGNAL(rangeChanged(int,int))); slider.setRange(newMin, newMax); QCOMPARE(spy.count(), expectedCount); } @@ -1263,7 +1263,7 @@ void tst_QAbstractSlider::setRepeatAction() void tst_QAbstractSlider::connectedSliders() { Slider *slider2 = new Slider(topLevel); - connect(slider, SIGNAL(rangeChanged(int, int)), slider2, SLOT(setRange(int, int))); + connect(slider, SIGNAL(rangeChanged(int,int)), slider2, SLOT(setRange(int,int))); const int sliderlow = 13; const int sliderhigh = 1017; slider->setRange(sliderlow, sliderhigh); diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index 5c1de27ef9..772ba7e00b 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -317,11 +317,11 @@ void tst_QButtonGroup::testSignals() buttons.addButton(&pb3); qRegisterMetaType("QAbstractButton *"); - QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton *))); + QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*))); QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int))); - QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton *))); + QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*))); QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int))); - QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton *))); + QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*))); QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int))); pb1.animateClick(); @@ -480,7 +480,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() task209485_ButtonDeleter buttonDeleter(&group, deleteButton); - QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton *))); + QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton*))); QSignalSpy spy2(&group, SIGNAL(buttonClicked(int))); // NOTE: Reintroducing the bug of this task will cause the following line to crash: diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 116f3a99f3..bd16085639 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1121,7 +1121,7 @@ void tst_QComboBox::currentIndex() // spy on currentIndexChanged QSignalSpy indexChangedInt(testWidget, SIGNAL(currentIndexChanged(int))); - QSignalSpy indexChangedString(testWidget, SIGNAL(currentIndexChanged(const QString&))); + QSignalSpy indexChangedString(testWidget, SIGNAL(currentIndexChanged(QString))); // stuff items into it foreach(QString text, initialItems) { @@ -2120,7 +2120,7 @@ void tst_QComboBox::task247863_keyBoardSelection() QApplication::setActiveWindow(&combo); QTRY_COMPARE(QApplication::activeWindow(), static_cast(&combo)); - QSignalSpy spy(&combo, SIGNAL(activated(const QString &))); + QSignalSpy spy(&combo, SIGNAL(activated(QString))); qApp->setEffectEnabled(Qt::UI_AnimateCombo, false); QTest::keyClick(&combo, Qt::Key_Space); qApp->setEffectEnabled(Qt::UI_AnimateCombo, true); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 916b60ab6f..b12708a159 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -1068,7 +1068,7 @@ void tst_QDateTimeEdit::enterKey() // causes the dateChanged() signal to be emitted, even if the date // wasn't actually changed. While this behaviour is questionable, // we include this test so a change to the behaviour can't go unnoticed. - QSignalSpy enterSpy(testWidget, SIGNAL(dateChanged(const QDate &))); + QSignalSpy enterSpy(testWidget, SIGNAL(dateChanged(QDate))); QTest::keyClick(testWidget, Qt::Key_Enter); QCOMPARE(enterSpy.count(), 1); QVariantList list = enterSpy.takeFirst(); @@ -2028,9 +2028,9 @@ void tst_QDateTimeEdit::dateSignalChecking() testWidget->setDate(originalDate); - QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(const QDate &))); - QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &))); - QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(const QTime &))); + QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(QDate))); + QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime))); + QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime))); testWidget->setDate(newDate); QCOMPARE(dateSpy.count(), timesEmitted); @@ -2064,9 +2064,9 @@ void tst_QDateTimeEdit::timeSignalChecking() testWidget->setTime(originalTime); testWidget->setDisplayFormat("hh:mm:ss"); - QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(const QDate &))); - QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &))); - QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(const QTime &))); + QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(QDate))); + QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime))); + QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime))); testWidget->setTime(newTime); QCOMPARE(timeSpy.count(), timesEmitted); @@ -2114,9 +2114,9 @@ void tst_QDateTimeEdit::dateTimeSignalChecking() testWidget->setDisplayFormat("dd/MM/yyyy hh:mm:ss"); testWidget->setDateTime(originalDateTime); - QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(const QDate &))); - QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(const QTime &))); - QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &))); + QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(QDate))); + QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime))); + QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime))); testWidget->setDateTime(newDateTime); QCOMPARE(dateSpy.count(), timesDateEmitted); @@ -2981,9 +2981,9 @@ void tst_QDateTimeEdit::task108572() void tst_QDateTimeEdit::task149097() { - QSignalSpy dtSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &))); - QSignalSpy dSpy(testWidget, SIGNAL(dateChanged(const QDate &))); - QSignalSpy tSpy(testWidget, SIGNAL(timeChanged(const QTime &))); + QSignalSpy dtSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime))); + QSignalSpy dSpy(testWidget, SIGNAL(dateChanged(QDate))); + QSignalSpy tSpy(testWidget, SIGNAL(timeChanged(QTime))); testWidget->setDisplayFormat("yyyy/MM/dd hh:mm:ss"); testWidget->setDateTime(QDateTime(QDate(2001, 02, 03), QTime(5, 1, 2))); diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index 61b57b00b0..8c8f5b5d71 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -547,8 +547,8 @@ void tst_QDialogButtonBox::testSignalOrder() buttonClicked1TimeStamp = acceptTimeStamp = rejectTimeStamp = helpRequestedTimeStamp = timeStamp = 0; QDialogButtonBox buttonBox; - connect(&buttonBox, SIGNAL(clicked(QAbstractButton *)), - this, SLOT(buttonClicked1(QAbstractButton *))); + connect(&buttonBox, SIGNAL(clicked(QAbstractButton*)), + this, SLOT(buttonClicked1(QAbstractButton*))); connect(&buttonBox, SIGNAL(accepted()), this, SLOT(acceptClicked())); connect(&buttonBox, SIGNAL(rejected()), this, SLOT(rejectClicked())); connect(&buttonBox, SIGNAL(helpRequested()), this, SLOT(helpRequestedClicked())); diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index b8af7844bd..898f566995 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -311,7 +311,7 @@ void tst_QDoubleSpinBox::setTracking() spin.setDecimals(decimals); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(const QString &))); + connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); keys.simulate(&spin); QCOMPARE(actualTexts, texts); diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp index faea7f420d..58ef5f1bf9 100644 --- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp @@ -142,7 +142,7 @@ void tst_QFontComboBox::currentFont() QFETCH(QFont, currentFont); SubQFontComboBox box; - QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); + QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont oldCurrentFont = box.currentFont(); box.setCurrentFont(currentFont); @@ -192,7 +192,7 @@ void tst_QFontComboBox::fontFilters() QFETCH(QFontComboBox::FontFilters, fontFilters); SubQFontComboBox box; - QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); + QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont currentFont = box.currentFont(); box.setFontFilters(fontFilters); @@ -265,7 +265,7 @@ void tst_QFontComboBox::writingSystem() QFETCH(QFontDatabase::WritingSystem, writingSystem); SubQFontComboBox box; - QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); + QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont currentFont = box.currentFont(); box.setWritingSystem(writingSystem); @@ -285,7 +285,7 @@ void tst_QFontComboBox::writingSystem() void tst_QFontComboBox::currentFontChanged() { SubQFontComboBox box; - QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); + QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); if (box.model()->rowCount() > 2) { QTest::keyPress(&box, Qt::Key_Down); diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 08913650ad..c971566a6a 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -360,9 +360,9 @@ void tst_QLineEdit::initTestCase() { testWidget = new QLineEdit(0); testWidget->setObjectName("testWidget"); - connect(testWidget, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(onCursorPositionChanged(int, int))); - connect(testWidget, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); - connect(testWidget, SIGNAL(textEdited(const QString&)), this, SLOT(onTextEdited(const QString&))); + connect(testWidget, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(onCursorPositionChanged(int,int))); + connect(testWidget, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString))); + connect(testWidget, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited(QString))); connect(testWidget, SIGNAL(returnPressed()), this, SLOT(onReturnPressed())); connect(testWidget, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(testWidget, SIGNAL(editingFinished()), this, SLOT(editingFinished())); @@ -3183,7 +3183,7 @@ void tst_QLineEdit::inlineCompletion() void tst_QLineEdit::noTextEditedOnClear() { testWidget->setText("Test"); - QSignalSpy textEditedSpy(testWidget, SIGNAL(textEdited(const QString &))); + QSignalSpy textEditedSpy(testWidget, SIGNAL(textEdited(QString))); testWidget->clear(); QCOMPARE(textEditedSpy.count(), 0); } diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 259ec2ecd3..6fa9c10ddf 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -333,8 +333,8 @@ void tst_QMdiArea::subWindowActivated() QMdiArea *workspace = new QMdiArea(&mw); workspace->setObjectName(QLatin1String("testWidget")); mw.setCentralWidget(workspace); - QSignalSpy spy(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *))); - connect( workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *))); + QSignalSpy spy(workspace, SIGNAL(subWindowActivated(QMdiSubWindow*))); + connect( workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*))); mw.show(); qApp->setActiveWindow(&mw); @@ -456,7 +456,7 @@ bool macHasAccessToWindowsServer() void tst_QMdiArea::subWindowActivated2() { QMdiArea mdiArea; - QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *))); + QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*))); for (int i = 0; i < 5; ++i) mdiArea.addSubWindow(new QWidget); QCOMPARE(spy.count(), 0); @@ -540,8 +540,8 @@ void tst_QMdiArea::subWindowActivatedWithMinimize() QMdiArea *workspace = new QMdiArea(&mw); workspace->setObjectName(QLatin1String("testWidget")); mw.setCentralWidget(workspace); - QSignalSpy spy(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *))); - connect( workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *)) ); + QSignalSpy spy(workspace, SIGNAL(subWindowActivated(QMdiSubWindow*))); + connect( workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*)) ); mw.show(); qApp->setActiveWindow(&mw); QWidget *widget = new QWidget(workspace); @@ -924,8 +924,8 @@ void tst_QMdiArea::setActiveSubWindow() QMdiArea workspace; workspace.show(); - QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *))); - connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *))); + QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*))); + connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*))); qApp->setActiveWindow(&workspace); // Activate hidden windows @@ -1321,8 +1321,8 @@ void tst_QMdiArea::closeWindows() workspace.addSubWindow(new QWidget)->show(); qApp->processEvents(); QCOMPARE(workspace.subWindowList().count(), windowCount); - QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *))); - connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *))); + QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*))); + connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*))); workspace.closeAllSubWindows(); qApp->processEvents(); QCOMPARE(workspace.subWindowList().count(), 0); @@ -1344,8 +1344,8 @@ void tst_QMdiArea::activateNextAndPreviousWindow() qApp->processEvents(); } - QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *))); - connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *))); + QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*))); + connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(activeChanged(QMdiSubWindow*))); // activateNextSubWindow for (int i = 0; i < windowCount; ++i) { @@ -2284,7 +2284,7 @@ void tst_QMdiArea::tabBetweenSubWindows() QWidget *focusWidget = subWindows.back()->widget(); QCOMPARE(qApp->focusWidget(), focusWidget); - QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *))); + QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*))); QCOMPARE(spy.count(), 0); // Walk through the entire list of sub windows. diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 3807bad1ba..caf030e3b6 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -502,7 +502,7 @@ void tst_QMdiSubWindow::emittingOfSignals() QSignalSpy spy(window, signal == SIGNAL(aboutToActivate()) ? signal.data() - : SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates))); + : SIGNAL(windowStateChanged(Qt::WindowStates,Qt::WindowStates))); QVERIFY(spy.isEmpty()); triggerSignal(window, &workspace, signal); // Unless the signal is windowRestored or windowDeactivated, diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index b159d0e6c3..4a53473903 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -448,7 +448,7 @@ void tst_QMenu::statusTip() { //check that the statustip of actions inserted into the menu are displayed QMainWindow w; - connect(w.statusBar(), SIGNAL(messageChanged(const QString &)), SLOT(onStatusMessageChanged(const QString &)));; //creates the status bar + connect(w.statusBar(), SIGNAL(messageChanged(QString)), SLOT(onStatusMessageChanged(QString)));; //creates the status bar QToolBar tb; QAction a("main action", &tb); a.setStatusTip("main action"); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index c8b5d95dc9..572f0a6a4f 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -245,7 +245,7 @@ void tst_QMenuBar::initTestCase() // widget under test mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint); mb = new QMenuBar( mw ); - connect( mb, SIGNAL(triggered(QAction *)), this, SLOT(onActivated(QAction *)) ); + connect( mb, SIGNAL(triggered(QAction*)), this, SLOT(onActivated(QAction*)) ); initSimpleMenubar(); mw->show(); diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 2e7f281d62..beea5f3052 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -377,7 +377,7 @@ void tst_QSpinBox::setTracking() QSpinBox spin(0); spin.setKeyboardTracking(tracking); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(const QString &))); + connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); keys.simulate(&spin); QCOMPARE(actualTexts, texts); diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index 5bf2b02ce4..6fef2d4b9a 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -250,7 +250,7 @@ void tst_QTextBrowser::viewportPositionInHistory() void tst_QTextBrowser::relativeLinks() { qRegisterMetaType("QUrl"); - QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(const QUrl &))); + QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(QUrl))); browser->setSource(QUrl("subdir/../qtextbrowser.html")); QVERIFY(!browser->document()->isEmpty()); QVERIFY(sourceChangedSpy.count() == 1); @@ -658,7 +658,7 @@ void tst_QTextBrowser::urlEncoding() browser->setHtml("link"); browser->focusTheNextChild(); - QSignalSpy spy(browser, SIGNAL(anchorClicked(const QUrl &))); + QSignalSpy spy(browser, SIGNAL(anchorClicked(QUrl))); #ifdef QT_KEYPAD_NAVIGATION browser->setEditFocus(true); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index ec656d35d7..d7a95a8e63 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -1744,7 +1744,7 @@ void tst_QTextEdit::currentCharFormatChanged() ff.setPointSize(11); SignalReceiver receiver; - QObject::connect(ed, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)) , &receiver, SLOT(charFormatChanged(const QTextCharFormat &))); + QObject::connect(ed, SIGNAL(currentCharFormatChanged(QTextCharFormat)) , &receiver, SLOT(charFormatChanged(QTextCharFormat))); ed->show(); ed->setCurrentFont(ff); diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp index da5b2a79f6..3ad9994336 100644 --- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp @@ -838,7 +838,7 @@ void tst_QToolBar::toolButtonStyle() void tst_QToolBar::actionTriggered() { QToolBar tb; - connect(&tb, SIGNAL(actionTriggered(QAction *)), SLOT(slot(QAction *))); + connect(&tb, SIGNAL(actionTriggered(QAction*)), SLOT(slot(QAction*))); QAction action1(0); QAction action2(0); diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp index 9226846a9b..498042c117 100644 --- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp +++ b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp @@ -57,7 +57,7 @@ SomeHandler::SomeHandler(QHeaderView *hv, QTableView *tv) m_hv = hv; m_tv = tv; m_tv->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); - connect(hv, SIGNAL(sectionResized(int, int, int)), this, SLOT(slotSectionResized(int, int, int))); + connect(hv, SIGNAL(sectionResized(int,int,int)), this, SLOT(slotSectionResized(int,int,int))); } void SomeHandler::slotSectionResized(int logsection, int oldsize, int newsize) { From b5b165ffb3933114fc891ddcc2f1b25cfc56c0e7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Oct 2012 11:09:03 +0200 Subject: [PATCH 096/114] normalise signal/slot signatures [QtDBus tests] Change-Id: I4a0441d37e455dce28072ee3650b2062bec65759 Reviewed-by: Thiago Macieira --- tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp | 4 ++-- tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp | 2 +- tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp | 4 ++-- tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp | 4 ++-- tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp index 0135d43937..097e32b76f 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp @@ -63,7 +63,7 @@ public: m_conn("none"), obj(NULL) { - connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&))); + connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } ~MyServer() @@ -164,4 +164,4 @@ int main(int argc, char *argv[]) return app.exec(); } -#include "qmyserver.moc" \ No newline at end of file +#include "qmyserver.moc" diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp index a60eca7746..277be00f5c 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp @@ -55,7 +55,7 @@ public: : QDBusServer(addr, parent), m_conn("none") { - connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&))); + connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); reset(); } diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index a3e2d3202e..ffcc2ddcdc 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -393,7 +393,7 @@ public: m_path(path), m_connections() { - connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&))); + connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } bool registerObject(const QDBusConnection& c) @@ -605,7 +605,7 @@ public: MyServer2(QString addr, QObject* parent) : QDBusServer(addr, parent), m_conn("none") { - connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&))); + connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } QDBusConnection connection() diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp index 19c5c8f1a0..1388c30b1a 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp @@ -60,7 +60,7 @@ public: : QDBusServer(addr, parent), m_conn("none") { - connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&))); + connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } public slots: @@ -152,4 +152,4 @@ int main(int argc, char *argv[]) return app.exec(); } -#include "qmyserver.moc" \ No newline at end of file +#include "qmyserver.moc" diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index 46a9eab591..dfec03fe15 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -350,7 +350,7 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged() QDBusInterface invalidInterface("com.example.Test", "/"); QVERIFY(!invalidInterface.isValid()); - QTestEventLoop::instance().connect(connIface, SIGNAL(serviceOwnerChanged(QString, QString, QString)), + QTestEventLoop::instance().connect(connIface, SIGNAL(serviceOwnerChanged(QString,QString,QString)), SLOT(exitLoop())); QVERIFY(connIface->registerService("com.example.Test") == QDBusConnectionInterface::ServiceRegistered); From a4ffbfefe79ec45d53dc42e2019d3d8f9a83633d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 16 Oct 2012 11:10:22 +0200 Subject: [PATCH 097/114] normalise signal/slot signatures [QtNetwork tests] Change-Id: I2491cfe421a811d00759224da03580b3dcc2a091 Reviewed-by: Shane Kearns --- tests/auto/network/access/qftp/tst_qftp.cpp | 14 ++++---- .../tst_qhttpnetworkconnection.cpp | 20 ++++++------ .../qnetworkreply/tst_qnetworkreply.cpp | 16 +++++----- .../kernel/qhostinfo/tst_qhostinfo.cpp | 10 +++--- .../network/ssl/qsslsocket/tst_qsslsocket.cpp | 32 +++++++++---------- ...tworkaccessmanager_and_qprogressdialog.cpp | 4 +-- .../qnetworkreply/tst_qnetworkreply.cpp | 4 +-- .../network/kernel/qhostinfo/main.cpp | 2 +- tests/manual/bearerex/bearerex.cpp | 20 ++++++------ .../qget/downloadmanager.cpp | 6 ++-- 10 files changed, 64 insertions(+), 64 deletions(-) diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 5da4a9d67f..702d56db54 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -966,11 +966,11 @@ void tst_QFtp::mkdir2() QEventLoop loop; connect(ftp, SIGNAL(done(bool)), &loop, SLOT(quit())); - connect(ftp, SIGNAL(commandFinished(int, bool)), this, SLOT(mkdir2Slot(int, bool))); + connect(ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(mkdir2Slot(int,bool))); QTimer::singleShot(5000, &loop, SLOT(quit())); QSignalSpy commandStartedSpy(ftp, SIGNAL(commandStarted(int))); - QSignalSpy commandFinishedSpy(ftp, SIGNAL(commandFinished(int, bool))); + QSignalSpy commandFinishedSpy(ftp, SIGNAL(commandFinished(int,bool))); loop.exec(); @@ -1933,12 +1933,12 @@ QFtp *tst_QFtp::newFtp() SLOT(done(bool)) ); connect( nFtp, SIGNAL(stateChanged(int)), SLOT(stateChanged(int)) ); - connect( nFtp, SIGNAL(listInfo(const QUrlInfo&)), - SLOT(listInfo(const QUrlInfo&)) ); + connect( nFtp, SIGNAL(listInfo(QUrlInfo)), + SLOT(listInfo(QUrlInfo)) ); connect( nFtp, SIGNAL(readyRead()), SLOT(readyRead()) ); - connect( nFtp, SIGNAL(dataTransferProgress(qint64, qint64)), - SLOT(dataTransferProgress(qint64, qint64)) ); + connect( nFtp, SIGNAL(dataTransferProgress(qint64,qint64)), + SLOT(dataTransferProgress(qint64,qint64)) ); return nFtp; } @@ -2072,7 +2072,7 @@ void tst_QFtp::queueMoreCommandsInDoneSlot() QFtp ftp; QSignalSpy doneSpy(&ftp, SIGNAL(done(bool))); - QSignalSpy commandFinishedSpy(&ftp, SIGNAL(commandFinished(int, bool))); + QSignalSpy commandFinishedSpy(&ftp, SIGNAL(commandFinished(int,bool))); this->ftp = &ftp; connect(&ftp, SIGNAL(done(bool)), this, SLOT(cdUpSlot(bool))); diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index b77634e8e6..948f8078b3 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -335,8 +335,8 @@ void tst_QHttpNetworkConnection::put() QHttpNetworkReply *reply = connection.sendRequest(request); connect(reply, SIGNAL(finished()), SLOT(finishedReply())); - connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString &)), - SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &))); + connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), + SLOT(finishedWithError(QNetworkReply::NetworkError,QString))); QTime stopWatch; stopWatch.start(); @@ -561,15 +561,15 @@ void tst_QHttpNetworkConnection::get401() QHttpNetworkRequest request(protocol + host + path); QHttpNetworkReply *reply = connection.sendRequest(request); - connect(reply, SIGNAL(authenticationRequired(const QHttpNetworkRequest&, QAuthenticator *)), - SLOT(challenge401(const QHttpNetworkRequest&, QAuthenticator *))); + connect(reply, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)), + SLOT(challenge401(QHttpNetworkRequest,QAuthenticator*))); finishedCalled = false; finishedWithErrorCalled = false; connect(reply, SIGNAL(finished()), SLOT(finishedReply())); - connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString &)), - SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &))); + connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), + SLOT(finishedWithError(QNetworkReply::NetworkError,QString))); QTime stopWatch; stopWatch.start(); @@ -722,8 +722,8 @@ void tst_QHttpNetworkConnection::ignoresslerror() QHttpNetworkRequest request(protocol + host + path); QHttpNetworkReply *reply = connection.sendRequest(request); - connect(reply, SIGNAL(sslErrors(const QList&)), - SLOT(sslErrors(const QList&))); + connect(reply, SIGNAL(sslErrors(QList)), + SLOT(sslErrors(QList))); finishedWithErrorCalled = false; @@ -778,8 +778,8 @@ void tst_QHttpNetworkConnection::nossl() netErrorCode = QNetworkReply::NoError; connect(reply, SIGNAL(finished()), SLOT(finishedReply())); - connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString &)), - SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &))); + connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), + SLOT(finishedWithError(QNetworkReply::NetworkError,QString))); QTime stopWatch; stopWatch.start(); diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index a5a79060ee..284768ea13 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -4346,7 +4346,7 @@ public: connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot())); connect(serverSocket, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); serverSocket->setProtocol(QSsl::AnyProtocol); - connect(serverSocket, SIGNAL(sslErrors(const QList&)), serverSocket, SLOT(ignoreSslErrors())); + connect(serverSocket, SIGNAL(sslErrors(QList)), serverSocket, SLOT(ignoreSslErrors())); serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem"); serverSocket->setPrivateKey(testDataDir + "/certs/server.key"); serverSocket->startServerEncryption(); @@ -4396,7 +4396,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress() QSignalSpy spy(reply.data(), SIGNAL(uploadProgress(qint64,qint64))); connect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(reply, SIGNAL(sslErrors(const QList&)), reply.data(), SLOT(ignoreSslErrors())); + connect(reply, SIGNAL(sslErrors(QList)), reply.data(), SLOT(ignoreSslErrors())); // get the request started and the incoming socket connected QTestEventLoop::instance().enterLoop(10); @@ -5611,8 +5611,8 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() QFETCH(QList, expectedSslErrors); // store the errors to ignore them later in the slot connected below storedExpectedSslErrors = expectedSslErrors; - connect(&manager, SIGNAL(sslErrors(QNetworkReply *, const QList &)), - this, SLOT(ignoreSslErrorListSlot(QNetworkReply *, const QList &))); + connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList)), + this, SLOT(ignoreSslErrorListSlot(QNetworkReply*,QList))); QVERIFY(waitForFinish(reply) != Timeout); @@ -6141,10 +6141,10 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() #endif manager.setProxy(proxy); QSignalSpy authSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); - QSignalSpy proxyAuthSpy(&manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *))); + QSignalSpy proxyAuthSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); AuthenticationCacheHelper helper; - connect(&manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), &helper, SLOT(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *))); + connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), &helper, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), &helper, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); QNetworkRequest request(url); @@ -6266,7 +6266,7 @@ void tst_QNetworkReply::authenticationWithDifferentRealm() connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList)), SLOT(sslErrors(QNetworkReply*,QList))); #endif - connect(&manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), &helper, SLOT(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *))); + connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), &helper, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), &helper, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); helper.httpUserName = "httptest"; @@ -6630,7 +6630,7 @@ void tst_QNetworkReply::synchronousRequestSslFailure() QNetworkRequest::SynchronousRequestAttribute, true); QNetworkReplyPtr reply; - QSignalSpy sslErrorsSpy(&manager, SIGNAL(sslErrors(QNetworkReply *, const QList &))); + QSignalSpy sslErrorsSpy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList))); runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0); QVERIFY(reply->isFinished()); QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError); diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 973cf1fe5a..25ea5ca76e 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -283,7 +283,7 @@ void tst_QHostInfo::lookupIPv4() QFETCH(QString, addresses); lookupDone = false; - QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(const QHostInfo&))); + QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(QHostInfo))); QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); @@ -333,7 +333,7 @@ void tst_QHostInfo::lookupIPv6() QSKIP("This platform does not support IPv6 lookups"); lookupDone = false; - QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(const QHostInfo&))); + QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(QHostInfo))); QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); @@ -468,7 +468,7 @@ public: void LookupReceiver::start() { for (int i=0;i &))); + QSignalSpy sslErrorsSpy(&socket, SIGNAL(sslErrors(QList))); connect(&socket, SIGNAL(connected()), this, SLOT(exitLoop())); connect(&socket, SIGNAL(disconnected()), this, SLOT(exitLoop())); connect(&socket, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(exitLoop())); connect(&socket, SIGNAL(encrypted()), this, SLOT(exitLoop())); connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(exitLoop())); - connect(&socket, SIGNAL(sslErrors(const QList &)), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(exitLoop())); // Start connecting socket.connectToHost(QtNetworkSettings::serverName(), 993); @@ -484,13 +484,13 @@ void tst_QSslSocket::simpleConnectWithIgnore() QSslSocket socket; this->socket = &socket; QSignalSpy encryptedSpy(&socket, SIGNAL(encrypted())); - QSignalSpy sslErrorsSpy(&socket, SIGNAL(sslErrors(const QList &))); + QSignalSpy sslErrorsSpy(&socket, SIGNAL(sslErrors(QList))); connect(&socket, SIGNAL(readyRead()), this, SLOT(exitLoop())); connect(&socket, SIGNAL(encrypted()), this, SLOT(exitLoop())); connect(&socket, SIGNAL(connected()), this, SLOT(exitLoop())); - connect(&socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); - connect(&socket, SIGNAL(sslErrors(const QList &)), this, SLOT(exitLoop())); + connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); + connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(exitLoop())); // Start connecting socket.connectToHost(QtNetworkSettings::serverName(), 993); @@ -943,7 +943,7 @@ protected: { socket = new QSslSocket(this); socket->setProtocol(protocol); - connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); QFile file(m_keyFile); QVERIFY(file.open(QIODevice::ReadOnly)); @@ -1071,7 +1071,7 @@ void tst_QSslSocket::protocolServerSide() socket->setProtocol(clientProtocol); // upon SSL wrong version error, error will be triggered, not sslErrors connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); - connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); @@ -1122,7 +1122,7 @@ void tst_QSslSocket::setSocketDescriptor() QSslSocketPtr client(new QSslSocket); socket = client.data();; - connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); @@ -1178,7 +1178,7 @@ void tst_QSslSocket::waitForEncrypted() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - connect(this->socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY(socket->waitForEncrypted(10000)); @@ -1195,7 +1195,7 @@ void tst_QSslSocket::waitForEncryptedMinusOne() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - connect(this->socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY(socket->waitForEncrypted(-1)); @@ -1209,7 +1209,7 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - connect(this->socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); QVERIFY(socket->waitForConnected(10000)); @@ -1586,7 +1586,7 @@ protected: void incomingConnection(qintptr socketDescriptor) { socket = new QSslSocket(this); - connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); QFile file(SRCDIR "certs/fluke.key"); QVERIFY(file.open(QIODevice::ReadOnly)); @@ -1984,8 +1984,8 @@ void tst_QSslSocket::ignoreSslErrorsListWithSlot() storedExpectedSslErrors = expectedSslErrors; connect(&socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); - connect(&socket, SIGNAL(sslErrors(const QList &)), - this, SLOT(ignoreErrorListSlot(const QList &))); + connect(&socket, SIGNAL(sslErrors(QList)), + this, SLOT(ignoreErrorListSlot(QList))); socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QFETCH(int, expectedSslErrorSignalCount); @@ -2027,7 +2027,7 @@ void tst_QSslSocket::writeBigChunk() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - connect(this->socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QByteArray data; @@ -2507,7 +2507,7 @@ void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, QSslConfiguration::setDefaultConfiguration(emptyConf); QSslSocketPtr socket = newSocket(); - connect(socket.data(), SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + connect(socket.data(), SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY2(!socket->waitForEncrypted(4000), qPrintable(socket->errorString())); } diff --git a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp index 037589e02a..4d91d33450 100644 --- a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp +++ b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp @@ -87,8 +87,8 @@ public slots: QNetworkRequest( QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile") )); - connect(reply, SIGNAL(downloadProgress(qint64, qint64)), - this, SLOT(dataReadProgress(qint64, qint64))); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(dataReadProgress(qint64,qint64))); connect(reply, SIGNAL(readyRead()), this, SLOT(dataReadyRead())); connect(reply, SIGNAL(finished()), this, SLOT(finishedFromReply())); diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 72d0b1339c..c518748a19 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -515,7 +515,7 @@ void tst_qnetworkreply::echoPerformance() QBENCHMARK{ QNetworkReply* reply = manager.post(request, data); - connect(reply, SIGNAL(sslErrors( const QList &)), reply, SLOT(ignoreSslErrors())); + connect(reply, SIGNAL(sslErrors(QList)), reply, SLOT(ignoreSslErrors())); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); @@ -783,7 +783,7 @@ public slots: QNetworkRequest request = requestList.takeFirst(); timeOneRequest.restart(); reply = manager.get(request); - QObject::connect(reply, SIGNAL(sslErrors( const QList &)), reply, SLOT(ignoreSslErrors())); + QObject::connect(reply, SIGNAL(sslErrors(QList)), reply, SLOT(ignoreSslErrors())); QObject::connect(reply, SIGNAL(finished()), this, SLOT(doNextRequest())); } diff --git a/tests/benchmarks/network/kernel/qhostinfo/main.cpp b/tests/benchmarks/network/kernel/qhostinfo/main.cpp index 91a067ba0b..4fc14c20cb 100644 --- a/tests/benchmarks/network/kernel/qhostinfo/main.cpp +++ b/tests/benchmarks/network/kernel/qhostinfo/main.cpp @@ -108,7 +108,7 @@ void tst_qhostinfo::lookupSpeed() QBENCHMARK { for (int i = 0; i < hostnameList.size(); i++) - QHostInfo::lookupHost(hostnameList.at(i), &receiver, SLOT(resultsReady(const QHostInfo))); + QHostInfo::lookupHost(hostnameList.at(i), &receiver, SLOT(resultsReady(QHostInfo))); QTestEventLoop::instance().enterLoop(20); QVERIFY(!QTestEventLoop::instance().timeout()); } diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 22f6c26341..a63d5a7f9f 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -53,14 +53,14 @@ BearerEx::BearerEx(QWidget* parent) createMenus(); connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), this, SLOT(configurationsUpdateCompleted())); - connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), - this, SLOT(configurationAdded(const QNetworkConfiguration&))); - connect(&m_NetworkConfigurationManager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), - this, SLOT(configurationRemoved(const QNetworkConfiguration&))); + connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(QNetworkConfiguration)), + this, SLOT(configurationAdded(QNetworkConfiguration))); + connect(&m_NetworkConfigurationManager, SIGNAL(configurationRemoved(QNetworkConfiguration)), + this, SLOT(configurationRemoved(QNetworkConfiguration))); connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool))); - connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), - this, SLOT(configurationChanged(const QNetworkConfiguration&))); + connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(QNetworkConfiguration)), + this, SLOT(configurationChanged(QNetworkConfiguration))); showConfigurations(); } @@ -318,7 +318,7 @@ void SessionTab::on_createQNetworkAccessManagerButton_clicked() return; } createQNetworkAccessManagerButton->setText("Recreate"); - connect(m_dataTransferer, SIGNAL(finished(quint32, qint64, QString)), this, SLOT(finished(quint32, qint64, QString))); + connect(m_dataTransferer, SIGNAL(finished(quint32,qint64,QString)), this, SLOT(finished(quint32,qint64,QString))); } void SessionTab::on_sendRequestButton_clicked() @@ -362,12 +362,12 @@ void SessionTab::on_stopConnectionButton_clicked() void SessionTab::on_alrButton_clicked() { if (!m_alrEnabled) { - connect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(const QNetworkConfiguration&, bool)), - this, SLOT(preferredConfigurationChanged(const QNetworkConfiguration&, bool))); + connect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)), + this, SLOT(preferredConfigurationChanged(QNetworkConfiguration,bool))); alrButton->setText("Disable ALR"); m_alrEnabled = true; } else { - disconnect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(const QNetworkConfiguration&, bool)), 0, 0); + disconnect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)), 0, 0); alrButton->setText("Enable ALR"); m_alrEnabled = false; } diff --git a/tests/manual/qnetworkaccessmanager/qget/downloadmanager.cpp b/tests/manual/qnetworkaccessmanager/qget/downloadmanager.cpp index 2dc6b43737..4dcdeeed59 100644 --- a/tests/manual/qnetworkaccessmanager/qget/downloadmanager.cpp +++ b/tests/manual/qnetworkaccessmanager/qget/downloadmanager.cpp @@ -49,10 +49,10 @@ DownloadManager::DownloadManager() : queueMode (Parallel) { connect(&nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*))); - connect(&nam, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this, SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*))); - connect(&nam, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); + connect(&nam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); + connect(&nam, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); #ifndef QT_NO_SSL - connect(&nam, SIGNAL(sslErrors(QNetworkReply*, const QList&)), this, SLOT(sslErrors(QNetworkReply*, const QList&))); + connect(&nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(sslErrors(QNetworkReply*,QList))); #endif } From 687e31df809433fc90085ce702bd77d0acdff269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mill=C3=A1n=20Soto?= Date: Wed, 12 Sep 2012 19:09:55 +0200 Subject: [PATCH 098/114] Handle separators in menus in AT-SPI (Linux accessibility) Change-Id: Id9c109d53bbb8ded04bbe98a622d44e13d572340 Reviewed-by: Frederik Gladhorn --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 54ecf537f2..f69e2365d8 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1518,8 +1518,9 @@ QString AtSpiAdaptor::pathForInterface(const QAIPointer &interface, bool inDestr QAIPointer interfaceWithObject = interface; QString path; - if (interface->role() == QAccessible::MenuItem && interface->object() && - inheritsQAction(interface->object())) { + QAccessible::Role role = interface->role(); + if (((role == QAccessible::MenuItem) || (role == QAccessible::Separator)) && + interface->object() && inheritsQAction(interface->object())) { interfaceWithObject = QAIPointer(interface->parent()); int childIndex = interfaceWithObject->indexOfChild(interface.data()); path.append(QString::fromLatin1("/%1").arg(childIndex)); From 8bed283f137c14a7be1fb9027eae5eae3ce796be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mill=C3=A1n=20Soto?= Date: Sat, 22 Sep 2012 23:19:44 +0200 Subject: [PATCH 099/114] Correct accessibility index handling in QListView QListView::currentChanged and QListView::selectionChanged changed to use 0-based indexes instead of 1-based indexes. Change-Id: Ie618970c9a37ec76156dbfab2e86685c3c8f374c Reviewed-by: Frederik Gladhorn --- src/widgets/itemviews/qlistview.cpp | 6 +++--- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index ff703c9d8a..592354836a 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -3162,7 +3162,7 @@ void QListView::currentChanged(const QModelIndex ¤t, const QModelIndex &pr #ifndef QT_NO_ACCESSIBILITY if (QAccessible::isActive()) { if (current.isValid()) { - int entry = visualIndex(current) + 1; + int entry = visualIndex(current); QAccessibleEvent event(this, QAccessible::Focus); event.setChild(entry); QAccessible::updateAccessibility(&event); @@ -3183,14 +3183,14 @@ void QListView::selectionChanged(const QItemSelection &selected, // ### does not work properly for selection ranges. QModelIndex sel = selected.indexes().value(0); if (sel.isValid()) { - int entry = visualIndex(sel) + 1; + int entry = visualIndex(sel); QAccessibleEvent event(this, QAccessible::Selection); event.setChild(entry); QAccessible::updateAccessibility(&event); } QModelIndex desel = deselected.indexes().value(0); if (desel.isValid()) { - int entry = visualIndex(desel) + 1; + int entry = visualIndex(desel); QAccessibleEvent event(this, QAccessible::SelectionRemove); event.setChild(entry); QAccessible::updateAccessibility(&event); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 9d614703c6..58ddf531c5 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2369,17 +2369,17 @@ void tst_QAccessibility::listTest() // Check for events QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(1)).center()); QAccessibleEvent selectionEvent(listView, QAccessible::Selection); - selectionEvent.setChild(2); + selectionEvent.setChild(1); QAccessibleEvent focusEvent(listView, QAccessible::Focus); - focusEvent.setChild(2); + focusEvent.setChild(1); QVERIFY(QTestAccessibility::containsEvent(&selectionEvent)); QVERIFY(QTestAccessibility::containsEvent(&focusEvent)); QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(2)).center()); QAccessibleEvent selectionEvent2(listView, QAccessible::Selection); - selectionEvent2.setChild(3); + selectionEvent2.setChild(2); QAccessibleEvent focusEvent2(listView, QAccessible::Focus); - focusEvent2.setChild(3); + focusEvent2.setChild(2); QVERIFY(QTestAccessibility::containsEvent(&selectionEvent2)); QVERIFY(QTestAccessibility::containsEvent(&focusEvent2)); From d84f449bcde56fd2df12f82dd2ba2e1f0a4ae7c7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 2 Oct 2012 13:01:30 +0200 Subject: [PATCH 100/114] Make sure uints remain uints when editing in itemviews. Task-number: QTBUG-22974 Change-Id: I07428862c4dffc629f868f3010f663eb655922d0 Reviewed-by: Marc Mutz --- src/widgets/itemviews/qitemeditorfactory.cpp | 33 +++++++++- .../qitemdelegate/tst_qitemdelegate.cpp | 61 +++++++++++++++++++ .../tst_qitemeditorfactory.cpp | 19 ++++++ 3 files changed, 112 insertions(+), 1 deletion(-) diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 5162a5534c..5f24c3ea1b 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -73,6 +73,36 @@ public: #endif // QT_NO_COMBOBOX + +#ifndef QT_NO_SPINBOX + +class QUIntSpinBox : public QSpinBox +{ + Q_OBJECT + Q_PROPERTY(uint value READ uintValue WRITE setUIntValue NOTIFY uintValueChanged USER true) +public: + explicit QUIntSpinBox(QWidget *parent = 0) + : QSpinBox(parent) + { + connect(this, SIGNAL(valueChanged(int)), SIGNAL(uintValueChanged())); + } + + uint uintValue() + { + return value(); + } + + void setUIntValue(uint value_) + { + return setValue(value_); + } + +Q_SIGNALS: + void uintValueChanged(); +}; + +#endif // QT_NO_SPINBOX + /*! \class QItemEditorFactory \brief The QItemEditorFactory class provides widgets for editing item data @@ -206,8 +236,9 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) #endif #ifndef QT_NO_SPINBOX case QVariant::UInt: { - QSpinBox *sb = new QSpinBox(parent); + QSpinBox *sb = new QUIntSpinBox(parent); sb->setFrame(false); + sb->setMinimum(0); sb->setMaximum(INT_MAX); return sb; } case QVariant::Int: { diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index bed1d52f94..06964bac0d 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -224,6 +224,7 @@ private slots: void dateTimeEditor_data(); void dateTimeEditor(); void dateAndTimeEditorTest2(); + void uintEdit(); void decoration_data(); void decoration(); void editorEvent_data(); @@ -939,6 +940,66 @@ void tst_QItemDelegate::dateAndTimeEditorTest2() w.doCloseEditor(dateEdit); } +void tst_QItemDelegate::uintEdit() +{ + QListView view; + QStandardItemModel model; + + { + QStandardItem *data=new QStandardItem; + data->setEditable(true); + data->setData(QVariant((uint)1), Qt::DisplayRole); + model.setItem(0, 0, data); + } + { + QStandardItem *data=new QStandardItem; + data->setEditable(true); + data->setData(QVariant((uint)1), Qt::DisplayRole); + model.setItem(1, 0, data); + } + + view.setModel(&model); + view.setEditTriggers(QAbstractItemView::AllEditTriggers); + + const QModelIndex firstCell = model.index(0, 0); + + QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast(QMetaType::UInt)); + + view.selectionModel()->setCurrentIndex(model.index(0, 0), QItemSelectionModel::Select); + view.edit(firstCell); + + QSpinBox *sb = view.findChild(); + QVERIFY(sb); + + sb->stepUp(); + + // Select another index to trigger the end of editing. + const QModelIndex secondCell = model.index(1, 0); + view.selectionModel()->setCurrentIndex(secondCell, QItemSelectionModel::Select); + + QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast(QMetaType::UInt)); + QCOMPARE(firstCell.data(Qt::DisplayRole).toUInt(), static_cast(2)); + + + view.edit(secondCell); + + // The first spinbox is deleted with deleteLater, so it is still there. + QList sbList = view.findChildren(); + QCOMPARE(sbList.size(), 2); + + sb = sbList.at(1); + + sb->stepDown(); // 1 -> 0 + sb->stepDown(); // 0 (no effect) + sb->stepDown(); // 0 (no effect) + + // Select another index to trigger the end of editing. + view.selectionModel()->setCurrentIndex(firstCell, QItemSelectionModel::Select); + + QCOMPARE(secondCell.data(Qt::DisplayRole).userType(), static_cast(QMetaType::UInt)); + QCOMPARE(secondCell.data(Qt::DisplayRole).toUInt(), static_cast(0)); +} + void tst_QItemDelegate::decoration_data() { QTest::addColumn("type"); diff --git a/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp index e0a9db3d7d..44b1cebcfb 100644 --- a/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp +++ b/tests/auto/widgets/itemviews/qitemeditorfactory/tst_qitemeditorfactory.cpp @@ -48,6 +48,7 @@ class tst_QItemEditorFactory: public QObject private slots: void createEditor(); void createCustomEditor(); + void uintValues(); }; void tst_QItemEditorFactory::createEditor() @@ -100,6 +101,24 @@ void tst_QItemEditorFactory::createCustomEditor() delete creator; } +void tst_QItemEditorFactory::uintValues() +{ + QItemEditorFactory editorFactory; + + QWidget parent; + + { + QWidget *editor = editorFactory.createEditor(QMetaType::UInt, &parent); + QCOMPARE(editor->metaObject()->className(), "QUIntSpinBox"); + QCOMPARE(editor->metaObject()->userProperty().type(), QVariant::UInt); + } + { + QWidget *editor = editorFactory.createEditor(QMetaType::Int, &parent); + QCOMPARE(editor->metaObject()->className(), "QSpinBox"); + QCOMPARE(editor->metaObject()->userProperty().type(), QVariant::Int); + } +} + QTEST_MAIN(tst_QItemEditorFactory) #include "tst_qitemeditorfactory.moc" From ae3ad0ad211e6b9d745193fc049ad6ee07d731f0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Oct 2012 09:20:10 +0200 Subject: [PATCH 101/114] Handle the case where persistent indexes have gone invalid. Don't add invalid ranges to the result. They will be removed whenever d->ranges is processed for public consumption anyway. For example, QItemSelectionModel::selection() calls merge() with another selection. The merge() method removes invalid ranges already. But the invalid ranges don't need to be there in the first place, so this patch removes them. A longer-term goal is to maintain d->ranges as an always-sorted list. This method can be called with a vector containing invalid QPersistentModelIndexes when those persistent indexes are made invalid in between layoutAboutToBeChanged and layoutChanged. It's a normal thing to happen and a case that should be handled deliberately. Change-Id: I741ed9208d8a75644975c9e8d61f0d6d78e20576 Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qitemselectionmodel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 74bc0e6a9d..4b9391d285 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -853,12 +853,18 @@ static QItemSelection mergeIndexes(const QVector &indexes int i = 0; while (i < indexes.count()) { const QPersistentModelIndex &tl = indexes.at(i); + if (!tl.isValid()) { + ++i; + continue; + } QPersistentModelIndex br = tl; QModelIndex brParent = br.parent(); int brRow = br.row(); int brColumn = br.column(); while (++i < indexes.count()) { const QPersistentModelIndex &next = indexes.at(i); + if (!next.isValid()) + continue; const QModelIndex nextParent = next.parent(); const int nextRow = next.row(); const int nextColumn = next.column(); From 7b8e10ddd02693b3d6b7a7e74d2103787f6e76ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 10 Oct 2012 12:38:07 +0200 Subject: [PATCH 102/114] Fixed inconsistent QPainter fill rules for aliased painting. Qt 5 is the time to get rid of all the old inconsistencies in the raster paint engine caused by trying to preserve the old X11 based coordinate system where (0, 0) is in the center of the top-left pixel instead of the upper left corner of said pixel. However, this was only adhered for line drawing and path / rect filling, and not for image or pixmap drawing and not at all when doing antialiased painting. By defining the antialiased coordinate system as being the right one and letting the aliased fill rules follow from that we finally end up with some consistent behavior that doesn't lead to surprises and workarounds in application code. It is still possible for applications to get the old behavior by setting the QPainter::Qt4CompatiblePainting render hint. This should make porting easier for the few cases where an application relies on the aliased fill rules we used to have in Qt 4. Task-number: QTBUG-27500 Change-Id: If86b95e77d838ec83033d64af86632b9a73c74a9 Reviewed-by: Lars Knoll --- dist/changes-5.0.0 | 9 ++++ src/gui/painting/qcosmeticstroker.cpp | 4 +- src/gui/painting/qcosmeticstroker_p.h | 7 +++ src/gui/painting/qpaintbuffer.cpp | 2 + src/gui/painting/qpaintengine_raster.cpp | 39 +++++++++++---- src/gui/painting/qpaintengine_raster_p.h | 3 ++ src/gui/painting/qpainter.cpp | 5 ++ src/gui/painting/qpainter.h | 3 +- src/gui/painting/qrasterizer.cpp | 50 +++++++++++++------ src/gui/painting/qrasterizer_p.h | 1 + src/widgets/styles/qcommonstyle.cpp | 8 +++ src/widgets/styles/qwindowsstyle.cpp | 5 ++ .../gui/painting/qpainter/tst_qpainter.cpp | 13 +++-- 13 files changed, 117 insertions(+), 32 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 57736472bc..0014760b6c 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -508,6 +508,15 @@ QtGui the existent image data will be invalidated, so that isNull() is guaranteed to return true in this case. +* Behavioral change regarding QPainter fill rules when not using antialiased + painting: The fill rules have changed so that the aliased and antialiased + coordinate systems match. Earlier there used to be an offset of slightly less + than half a pixel when doing sub-pixel rendering, in order to be consistent + with the old X11 paint engine. The new behavior should be more predictable and + gives the same consistent rounding for images / pixmaps as for paths and + rectangle filling. It's possible to still get the old behavior by setting the + QPainter::Qt4CompatiblePainting render hint. + QtWidgets --------- * QInputContext removed as well as related getters and setters on QWidget and QApplication. diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index f99edc6194..2eab7b25c5 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -414,7 +414,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal if (clipLine(rx1, ry1, rx2, ry2)) return; - const int half = 31; + const int half = legacyRounding ? 31 : 0; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; int x2 = toF26Dot6(rx2) + half; @@ -707,7 +707,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, if (stroker->clipLine(rx1, ry1, rx2, ry2)) return; - static const int half = 31; + const int half = stroker->legacyRounding ? 31 : 0; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; int x2 = toF26Dot6(rx2) + half; diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index f71b87d79d..467eb7a836 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -93,11 +93,16 @@ public: patternSize(0), patternLength(0), patternOffset(0), + legacyRounding(false), current_span(0), lastDir(LeftToRight), lastAxisAligned(false) { setup(); } + ~QCosmeticStroker() { free(pattern); free(reversePattern); } + + void setLegacyRoundingEnabled(bool legacyRoundingEnabled) { legacyRounding = legacyRoundingEnabled; } + void drawLine(const QPointF &p1, const QPointF &p2); void drawPath(const QVectorPath &path); void drawPoints(const QPoint *points, int num); @@ -119,6 +124,8 @@ public: int patternLength; int patternOffset; + bool legacyRounding; + enum { NSPANS = 255 }; QT_FT_Span spans[NSPANS]; int current_span; diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index a2bac58d6c..1e5a00e835 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -1467,6 +1467,8 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) painter->setRenderHint(QPainter::SmoothPixmapTransform, nh & QPainter::SmoothPixmapTransform); if (xored & QPainter::NonCosmeticDefaultPen) painter->setRenderHint(QPainter::NonCosmeticDefaultPen, nh & QPainter::NonCosmeticDefaultPen); + if (xored & QPainter::Qt4CompatiblePainting) + painter->setRenderHint(QPainter::Qt4CompatiblePainting, nh & QPainter::Qt4CompatiblePainting); break; } case QPaintBufferPrivate::Cmd_SetOpacity: { diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 5228fdcf1d..e0eab8dc73 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -644,6 +644,7 @@ QRasterPaintEngineState::QRasterPaintEngineState() flags.fast_pen = true; flags.antialiased = false; flags.bilinear = false; + flags.legacy_rounding = false; flags.fast_text = true; flags.int_xform = true; flags.tx_noshear = true; @@ -927,6 +928,7 @@ void QRasterPaintEngine::renderHintsChanged() s->flags.antialiased = bool(s->renderHints & QPainter::Antialiasing); s->flags.bilinear = bool(s->renderHints & QPainter::SmoothPixmapTransform); + s->flags.legacy_rounding = !bool(s->renderHints & QPainter::Antialiasing) && bool(s->renderHints & QPainter::Qt4CompatiblePainting); if (was_aa != s->flags.antialiased) s->strokeFlags |= DirtyHints; @@ -1524,6 +1526,7 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) QRectVectorPath path; if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i = 0; i < rectCount; ++i) { path.set(rects[i]); stroker.drawPath(path); @@ -1570,6 +1573,7 @@ void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount) QRectVectorPath path; if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i = 0; i < rectCount; ++i) { path.set(rects[i]); stroker.drawPath(path); @@ -1603,6 +1607,7 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPath(path); } else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) { qreal width = s->lastPen.isCosmetic() @@ -1658,12 +1663,16 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) QPaintEngineEx::stroke(path, pen); } -static inline QRect toNormalizedFillRect(const QRectF &rect) +QRect QRasterPaintEngine::toNormalizedFillRect(const QRectF &rect) { - int x1 = qRound(rect.x() + aliasedCoordinateDelta); - int y1 = qRound(rect.y() + aliasedCoordinateDelta); - int x2 = qRound(rect.right() + aliasedCoordinateDelta); - int y2 = qRound(rect.bottom() + aliasedCoordinateDelta); + QRasterPaintEngineState *s = state(); + + qreal delta = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0); + + int x1 = qRound(rect.x() + delta); + int y1 = qRound(rect.y() + delta); + int x2 = qRound(rect.right() + delta); + int y2 = qRound(rect.bottom() + delta); if (x2 < x1) qSwap(x1, x2); @@ -1941,6 +1950,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly QVectorPath vp((qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPath(vp); } else { QPaintEngineEx::stroke(vp, s->lastPen); @@ -2005,6 +2015,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPath(vp); } else { QPaintEngineEx::stroke(vp, s->lastPen); @@ -2233,7 +2244,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe // as fillRect will apply the aliased coordinate delta we need to // subtract it here as we don't use it for image drawing QTransform old = s->matrix; - s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); + + if (s->flags.legacy_rounding) + s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied. QRgb color = img.pixel(sr_l, sr_t); @@ -2376,8 +2389,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { d->initializeRasterizer(&d->image_filler_xform); d->rasterizer->setAntialiased(s->flags.antialiased); + d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); - const QPointF offs = s->flags.antialiased ? QPointF() : QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta); + const QPointF offs = s->flags.legacy_rounding ? QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta) : QPointF(); const QRectF &rect = r.normalized(); const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs; @@ -2390,7 +2404,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe return; } #endif - const qreal offs = s->flags.antialiased ? qreal(0) : aliasedCoordinateDelta; + const qreal offs = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0); QPainterPath path; path.addRect(r); QTransform m = s->matrix; @@ -2471,6 +2485,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { d->initializeRasterizer(&d->image_filler_xform); d->rasterizer->setAntialiased(s->flags.antialiased); + d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); const QRectF &rect = r.normalized(); const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); @@ -2802,7 +2817,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, rightShift = 3; // divide by 8 int margin = fontEngine->glyphMargin(glyphType); - const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta); + const QFixed offs = s->flags.legacy_rounding ? QFixed::fromReal(aliasedCoordinateDelta) : QFixed(); const uchar *bits = image.bits(); for (int i=0; ideviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPoints(points, pointCount); } @@ -3097,6 +3113,7 @@ void QRasterPaintEngine::drawPoints(const QPoint *points, int pointCount) } QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPoints(points, pointCount); } @@ -3117,6 +3134,7 @@ void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount) if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i=0; iflags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i=0; istate(); rasterizer->setAntialiased(s->flags.antialiased); + rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); QRect clipRect(deviceRect); ProcessSpans blend; @@ -3484,6 +3504,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, if (!s->flags.antialiased) { rasterizer->setAntialiased(s->flags.antialiased); + rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); rasterizer->setClipRect(deviceRect); rasterizer->initialize(callback, userData); diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index e1beff047e..8fb72edabd 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -110,6 +110,7 @@ public: uint non_complex_pen : 1; // can use rasterizer, rather than stroker uint antialiased : 1; uint bilinear : 1; + uint legacy_rounding : 1; uint fast_text : 1; uint int_xform : 1; uint tx_noshear : 1; @@ -246,6 +247,8 @@ private: bool setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op); + QRect toNormalizedFillRect(const QRectF &rect); + inline void ensureBrush(const QBrush &brush) { if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) updateBrush(brush); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 02555b6fb6..69267b259b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1421,6 +1421,11 @@ void QPainterPrivate::updateState(QPainterState *newState) of 0 (which otherwise enables QPen::isCosmetic()) as being a non-cosmetic pen with a width of 1. + \value Qt4CompatiblePainting Compatibility hint telling the engine to use the + same X11 based fill rules as in Qt 4, where aliased rendering is offset + by slightly less than half a pixel. Potentially useful when porting a + Qt 4 application to Qt 5. + \sa renderHints(), setRenderHint(), {QPainter#Rendering Quality}{Rendering Quality}, {Concentric Circles Example} diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index c6c0e39ba0..a393b291e3 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -94,7 +94,8 @@ public: TextAntialiasing = 0x02, SmoothPixmapTransform = 0x04, HighQualityAntialiasing = 0x08, - NonCosmeticDefaultPen = 0x10 + NonCosmeticDefaultPen = 0x10, + Qt4CompatiblePainting = 0x20 }; Q_DECLARE_FLAGS(RenderHints, RenderHint) diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index fca037b964..e418f2c326 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -129,7 +129,7 @@ public: ~QScanConverter(); void begin(int top, int bottom, int left, int right, - Qt::FillRule fillRule, QSpanBuffer *spanBuffer); + Qt::FillRule fillRule, bool legacyRounding, QSpanBuffer *spanBuffer); void end(); void mergeCurve(const QT_FT_Vector &a, const QT_FT_Vector &b, @@ -177,6 +177,7 @@ private: Q16Dot16 m_rightFP; int m_fillRuleMask; + bool m_legacyRounding; int m_x; int m_y; @@ -196,6 +197,7 @@ class QRasterizerPrivate { public: bool antialiased; + bool legacyRounding; ProcessSpans blend; void *data; QRect clipRect; @@ -219,7 +221,8 @@ QScanConverter::~QScanConverter() } void QScanConverter::begin(int top, int bottom, int left, int right, - Qt::FillRule fillRule, QSpanBuffer *spanBuffer) + Qt::FillRule fillRule, bool legacyRounding, + QSpanBuffer *spanBuffer) { m_top = top; m_bottom = bottom; @@ -229,6 +232,7 @@ void QScanConverter::begin(int top, int bottom, int left, int right, m_lines.reset(); m_fillRuleMask = fillRule == Qt::WindingFill ? ~0x0 : 0x1; + m_legacyRounding = legacyRounding; m_spanBuffer = spanBuffer; } @@ -595,16 +599,20 @@ void QScanConverter::mergeLine(QT_FT_Vector a, QT_FT_Vector b) winding = -1; } - a.x += COORD_OFFSET; - a.y += COORD_OFFSET; - b.x += COORD_OFFSET; - b.y += COORD_OFFSET; + if (m_legacyRounding) { + a.x += COORD_OFFSET; + a.y += COORD_OFFSET; + b.x += COORD_OFFSET; + b.y += COORD_OFFSET; + } - int iTop = qMax(m_top, int((a.y + 32 - COORD_ROUNDING) >> 6)); - int iBottom = qMin(m_bottom, int((b.y - 32 - COORD_ROUNDING) >> 6)); + int rounding = m_legacyRounding ? COORD_ROUNDING : 0; + + int iTop = qMax(m_top, int((a.y + 32 - rounding) >> 6)); + int iBottom = qMin(m_bottom, int((b.y - 32 - rounding) >> 6)); if (iTop <= iBottom) { - Q16Dot16 aFP = Q16Dot16Factor/2 + (a.x << 10) - COORD_ROUNDING; + Q16Dot16 aFP = Q16Dot16Factor/2 + (a.x << 10) - rounding; if (b.x == a.x) { Line line = { qBound(m_leftFP, aFP, m_rightFP), 0, iTop, iBottom, winding }; @@ -635,6 +643,7 @@ void QScanConverter::mergeLine(QT_FT_Vector a, QT_FT_Vector b) QRasterizer::QRasterizer() : d(new QRasterizerPrivate) { + d->legacyRounding = false; } QRasterizer::~QRasterizer() @@ -658,6 +667,11 @@ void QRasterizer::setClipRect(const QRect &clipRect) d->clipRect = clipRect; } +void QRasterizer::setLegacyRoundingEnabled(bool legacyRoundingEnabled) +{ + d->legacyRounding = legacyRoundingEnabled; +} + static Q16Dot16 intersectPixelFP(int x, Q16Dot16 top, Q16Dot16 bottom, Q16Dot16 leftIntersectX, Q16Dot16 rightIntersectX, Q16Dot16 slope, Q16Dot16 invSlope) { Q16Dot16 leftX = IntToQ16Dot16(x); @@ -775,7 +789,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, pb = npb; } - if (!d->antialiased) { + if (!d->antialiased && d->legacyRounding) { pa.rx() += (COORD_OFFSET - COORD_ROUNDING)/64.; pa.ry() += (COORD_OFFSET - COORD_ROUNDING)/64.; pb.rx() += (COORD_OFFSET - COORD_ROUNDING)/64.; @@ -1174,13 +1188,15 @@ void QRasterizer::rasterize(const QT_FT_Outline *outline, Qt::FillRule fillRule) max_y = qMax(p.y, max_y); } - int iTopBound = qMax(d->clipRect.top(), int((min_y + 32 + COORD_OFFSET - COORD_ROUNDING) >> 6)); - int iBottomBound = qMin(d->clipRect.bottom(), int((max_y - 32 + COORD_OFFSET - COORD_ROUNDING) >> 6)); + int rounding = d->legacyRounding ? COORD_OFFSET - COORD_ROUNDING : 0; + + int iTopBound = qMax(d->clipRect.top(), int((min_y + 32 + rounding) >> 6)); + int iBottomBound = qMin(d->clipRect.bottom(), int((max_y - 32 + rounding) >> 6)); if (iTopBound > iBottomBound) return; - d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, &buffer); + d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, d->legacyRounding, &buffer); int first = 0; for (int i = 0; i < outline->n_contours; ++i) { @@ -1210,13 +1226,15 @@ void QRasterizer::rasterize(const QPainterPath &path, Qt::FillRule fillRule) QRectF bounds = path.controlPointRect(); - int iTopBound = qMax(d->clipRect.top(), int(bounds.top() + 0.5 + (COORD_OFFSET - COORD_ROUNDING)/64.)); - int iBottomBound = qMin(d->clipRect.bottom(), int(bounds.bottom() - 0.5 + (COORD_OFFSET - COORD_ROUNDING)/64.)); + double rounding = d->legacyRounding ? (COORD_OFFSET - COORD_ROUNDING) / 64. : 0.0; + + int iTopBound = qMax(d->clipRect.top(), int(bounds.top() + 0.5 + rounding)); + int iBottomBound = qMin(d->clipRect.bottom(), int(bounds.bottom() - 0.5 + rounding)); if (iTopBound > iBottomBound) return; - d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, &buffer); + d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, d->legacyRounding, &buffer); int subpathStart = 0; QT_FT_Vector last = { 0, 0 }; diff --git a/src/gui/painting/qrasterizer_p.h b/src/gui/painting/qrasterizer_p.h index 48e9982532..f535db8e6a 100644 --- a/src/gui/painting/qrasterizer_p.h +++ b/src/gui/painting/qrasterizer_p.h @@ -74,6 +74,7 @@ public: void setAntialiased(bool antialiased); void setClipRect(const QRect &clipRect); + void setLegacyRoundingEnabled(bool legacyRoundingEnabled); void initialize(ProcessSpans blend, void *data); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index e6e2e75c4e..4dd92c1a0c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -174,7 +174,10 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q if (opt->state & (State_Sunken | State_On)) { ir.adjust(2, 2, -2, -2); p->setBrush(opt->palette.foreground()); + bool oldQt4CompatiblePainting = p->testRenderHint(QPainter::Qt4CompatiblePainting); + p->setRenderHint(QPainter::Qt4CompatiblePainting); p->drawEllipse(ir); + p->setRenderHint(QPainter::Qt4CompatiblePainting, oldQt4CompatiblePainting); } break; } case PE_FrameFocusRect: @@ -530,6 +533,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q p->translate(sx + bsx, sy + bsy); p->setPen(opt->palette.buttonText().color()); p->setBrush(opt->palette.buttonText()); + p->setRenderHint(QPainter::Qt4CompatiblePainting); p->drawPolygon(a); p->restore(); break; } @@ -1579,7 +1583,10 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } p->setPen(tb->palette.mid().color().darker(150)); + bool oldQt4CompatiblePainting = p->testRenderHint(QPainter::Qt4CompatiblePainting); + p->setRenderHint(QPainter::Qt4CompatiblePainting); p->drawPolygon(a); + p->setRenderHint(QPainter::Qt4CompatiblePainting, oldQt4CompatiblePainting); p->setPen(tb->palette.light().color()); if (tb->direction != Qt::RightToLeft) { p->drawLine(0, 2, tb->rect.width() - d, 2); @@ -3487,6 +3494,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl p->setPen(Qt::NoPen); p->setBrush(pal.button()); + p->setRenderHint(QPainter::Qt4CompatiblePainting); p->drawPolygon(arrow); a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 4df68a76ad..9e5e65dcc1 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1243,6 +1243,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, imagePainter.translate(sx + bsx, sy + bsy); imagePainter.setPen(opt->palette.buttonText().color()); imagePainter.setBrush(opt->palette.buttonText()); + imagePainter.setRenderHint(QPainter::Qt4CompatiblePainting); if (!(opt->state & State_Enabled)) { imagePainter.translate(1, 1); @@ -1381,6 +1382,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } p->save(); + p->setRenderHint(QPainter::Qt4CompatiblePainting); bool down = opt->state & State_Sunken; bool enabled = opt->state & State_Enabled; bool on = opt->state & State_On; @@ -2487,8 +2489,10 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp } QBrush oldBrush = p->brush(); + bool oldQt4CompatiblePainting = p->testRenderHint(QPainter::Qt4CompatiblePainting); p->setPen(Qt::NoPen); p->setBrush(handleBrush); + p->setRenderHint(QPainter::Qt4CompatiblePainting); Qt::BGMode oldMode = p->backgroundMode(); p->setBackgroundMode(Qt::OpaqueMode); p->drawRect(x1, y1, x2-x1+1, y2-y1+1); @@ -2571,6 +2575,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp p->drawLine(x2, y2-1, x2+d, y2-1-d); break; } + p->setRenderHint(QPainter::Qt4CompatiblePainting, oldQt4CompatiblePainting); } } break; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 13716940b1..24be319173 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -830,6 +830,7 @@ void tst_QPainter::drawLine() { // unclipped pixmapUnclipped.fill(Qt::white); QPainter p(&pixmapUnclipped); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.translate(offset, offset); p.setPen(QPen(Qt::black)); p.drawLine(line); @@ -856,6 +857,7 @@ void tst_QPainter::drawLine() pixmapClipped.fill(Qt::white); QPainter p(&pixmapClipped); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.translate(offset, offset); p.setClipRect(clip); p.setPen(QPen(Qt::black)); @@ -892,6 +894,7 @@ void tst_QPainter::drawLine_task121143() image.fill(0xffffffff); QPainter p(&image); p.setPen(pen); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.drawLine(QLine(0, 0+4, 0+4, 0)); p.end(); @@ -1028,6 +1031,7 @@ void tst_QPainter::drawRect2() QTransform transform(0.368567, 0, 0, 0, 0.368567, 0, 0.0289, 0.0289, 1); QPainter p(&image); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.setTransform(transform); p.setBrush(Qt::red); p.setPen(Qt::NoPen); @@ -1038,6 +1042,7 @@ void tst_QPainter::drawRect2() image.fill(0xffffffff); p.begin(&image); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.setTransform(transform); p.drawRect(QRect(14, 14, 39, 39)); p.end(); @@ -1184,6 +1189,7 @@ void tst_QPainter::drawPath() image.fill(QColor(Qt::white).rgb()); QPainter p(&image); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.setPen(Qt::NoPen); p.setBrush(Qt::black); p.translate(offset - expectedBounds.left(), offset - expectedBounds.top()); @@ -1246,11 +1252,7 @@ void tst_QPainter::drawPath2() void tst_QPainter::drawPath3() { -#if !defined(Q_OS_WINCE) - QImage imgA(400, 400, QImage::Format_RGB32); -#else QImage imgA(100, 100, QImage::Format_RGB32); -#endif imgA.fill(0xffffff); QImage imgB = imgA; @@ -1413,6 +1415,7 @@ void tst_QPainter::drawRoundRect() { pixmap.fill(Qt::white); QPainter p(&pixmap); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.setPen(usePen ? QPen(Qt::black) : QPen(Qt::NoPen)); p.setBrush(Qt::black); p.drawRoundRect(rect); @@ -4185,6 +4188,7 @@ void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() baseLine.fill(Qt::white); { QPainter p(&baseLine); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.drawText(0, fm.ascent(), QString::fromLatin1("e")); } @@ -4195,6 +4199,7 @@ void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() { QPainter p(&comparison); + p.setRenderHint(QPainter::Qt4CompatiblePainting); p.drawText(QPointF(i / 12.0, fm.ascent()), QString::fromLatin1("e")); } From 221bd941ff255947ce7c78d08b1f9705e3d437be Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 16 Oct 2012 23:08:35 +0200 Subject: [PATCH 103/114] test: Moving tst_QProcess::echoTest_performance() tst_QProcess::echoTest_performance() is not an unit test but a performance test, so moving it from 'tests/auto/corelib/io/qprocess' to 'tests/benchmarks/corelib/io/qprocess' Change-Id: I796788534eafc5ca3b8d86c0ec46998285fd4b8f Reviewed-by: Rohan McGovern --- tests/auto/corelib/io/qprocess/.gitignore | 1 - tests/auto/corelib/io/qprocess/qprocess.pri | 1 - .../auto/corelib/io/qprocess/tst_qprocess.cpp | 51 -------- tests/benchmarks/corelib/io/io.pro | 1 + .../benchmarks/corelib/io/qprocess/.gitignore | 2 + .../corelib/io/qprocess/qprocess.pro | 3 + .../corelib/io/qprocess/test/test.pro | 5 + .../io/qprocess/testProcessLoopback/main.cpp | 0 .../testProcessLoopback.pro | 0 .../io/qprocess/tst_bench_qprocess.cpp | 109 ++++++++++++++++++ 10 files changed, 120 insertions(+), 53 deletions(-) create mode 100644 tests/benchmarks/corelib/io/qprocess/.gitignore create mode 100644 tests/benchmarks/corelib/io/qprocess/qprocess.pro create mode 100644 tests/benchmarks/corelib/io/qprocess/test/test.pro rename tests/{auto => benchmarks}/corelib/io/qprocess/testProcessLoopback/main.cpp (100%) rename tests/{auto => benchmarks}/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro (100%) create mode 100644 tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp diff --git a/tests/auto/corelib/io/qprocess/.gitignore b/tests/auto/corelib/io/qprocess/.gitignore index a273810042..7dcb25dede 100644 --- a/tests/auto/corelib/io/qprocess/.gitignore +++ b/tests/auto/corelib/io/qprocess/.gitignore @@ -11,7 +11,6 @@ testProcessEcho/testProcessEcho testProcessEcho2/testProcessEcho2 testProcessEcho3/testProcessEcho3 testProcessEnvironment/testProcessEnvironment -testProcessLoopback/testProcessLoopback testProcessNormal/testProcessNormal testProcessOutput/testProcessOutput testProcessSpacesArgs/nospace diff --git a/tests/auto/corelib/io/qprocess/qprocess.pri b/tests/auto/corelib/io/qprocess/qprocess.pri index 299432db77..d139b3dcef 100644 --- a/tests/auto/corelib/io/qprocess/qprocess.pri +++ b/tests/auto/corelib/io/qprocess/qprocess.pri @@ -4,7 +4,6 @@ SUBPROGRAMS = \ testProcessEcho2 \ testProcessEcho3 \ testProcessEnvironment \ - testProcessLoopback \ testProcessNormal \ testProcessOutput \ testProcessDeadWhileReading \ diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index a294dca506..9ec5eb489e 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -87,7 +87,6 @@ private slots: void echoTest_data(); void echoTest(); void echoTest2(); - void echoTest_performance(); #if defined Q_OS_WIN void echoTestGui(); void batFiles_data(); @@ -493,56 +492,6 @@ void tst_QProcess::echoTest2() process = 0; } -//----------------------------------------------------------------------------- -void tst_QProcess::echoTest_performance() -{ -#ifdef Q_OS_WINCE - QSKIP("Reading and writing to a process is not supported on Qt/CE"); -#endif - - QProcess process; - process.start("testProcessLoopback/testProcessLoopback"); - - QByteArray array; - array.resize(1024 * 1024); - for (int j = 0; j < array.size(); ++j) - array[j] = 'a' + (j % 20); - - QVERIFY(process.waitForStarted()); - - QTime stopWatch; - stopWatch.start(); - - qint64 totalBytes = 0; - QByteArray dump; - QSignalSpy readyReadSpy(&process, SIGNAL(readyRead())); - QVERIFY(readyReadSpy.isValid()); - while (stopWatch.elapsed() < 2000) { - process.write(array); - while (process.bytesToWrite() > 0) { - int readCount = readyReadSpy.count(); - QVERIFY(process.waitForBytesWritten(5000)); - if (readyReadSpy.count() == readCount) - QVERIFY(process.waitForReadyRead(5000)); - } - - while (process.bytesAvailable() < array.size()) - QVERIFY2(process.waitForReadyRead(5000), qPrintable(process.errorString())); - dump = process.readAll(); - totalBytes += dump.size(); - } - - qDebug() << "Elapsed time:" << stopWatch.elapsed() << "ms;" - << "transfer rate:" << totalBytes / (1048.576) / stopWatch.elapsed() - << "MB/s"; - - for (int j = 0; j < array.size(); ++j) - QCOMPARE(char(dump.at(j)), char('a' + (j % 20))); - - process.closeWriteChannel(); - QVERIFY(process.waitForFinished()); -} - #if defined Q_OS_WIN //----------------------------------------------------------------------------- void tst_QProcess::echoTestGui() diff --git a/tests/benchmarks/corelib/io/io.pro b/tests/benchmarks/corelib/io/io.pro index 15ae0d2101..863843f2c6 100644 --- a/tests/benchmarks/corelib/io/io.pro +++ b/tests/benchmarks/corelib/io/io.pro @@ -5,5 +5,6 @@ SUBDIRS = \ qfile \ #qfileinfo \ # FIXME: broken qiodevice \ + qprocess \ qtemporaryfile diff --git a/tests/benchmarks/corelib/io/qprocess/.gitignore b/tests/benchmarks/corelib/io/qprocess/.gitignore new file mode 100644 index 0000000000..0d88a2c739 --- /dev/null +++ b/tests/benchmarks/corelib/io/qprocess/.gitignore @@ -0,0 +1,2 @@ +tst_bench_qprocess +testProcessLoopback/testProcessLoopback diff --git a/tests/benchmarks/corelib/io/qprocess/qprocess.pro b/tests/benchmarks/corelib/io/qprocess/qprocess.pro new file mode 100644 index 0000000000..c49542f616 --- /dev/null +++ b/tests/benchmarks/corelib/io/qprocess/qprocess.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = testProcessLoopback test diff --git a/tests/benchmarks/corelib/io/qprocess/test/test.pro b/tests/benchmarks/corelib/io/qprocess/test/test.pro new file mode 100644 index 0000000000..eaae0c8254 --- /dev/null +++ b/tests/benchmarks/corelib/io/qprocess/test/test.pro @@ -0,0 +1,5 @@ +TARGET = ../tst_bench_qprocess +SOURCES += ../tst_bench_qprocess.cpp + +QT = core core-private testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qprocess/testProcessLoopback/main.cpp b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/main.cpp similarity index 100% rename from tests/auto/corelib/io/qprocess/testProcessLoopback/main.cpp rename to tests/benchmarks/corelib/io/qprocess/testProcessLoopback/main.cpp diff --git a/tests/auto/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro similarity index 100% rename from tests/auto/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro rename to tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp new file mode 100644 index 0000000000..141805c6e2 --- /dev/null +++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_QProcess : public QObject +{ + Q_OBJECT + +#ifndef QT_NO_PROCESS +private slots: + + void echoTest_performance(); + +#endif // QT_NO_PROCESS +}; + +#ifndef QT_NO_PROCESS +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::echoTest_performance() +{ + QProcess process; + process.start("testProcessLoopback/testProcessLoopback"); + + QByteArray array; + array.resize(1024 * 1024); + for (int j = 0; j < array.size(); ++j) + array[j] = 'a' + (j % 20); + + QVERIFY(process.waitForStarted()); + + QTime stopWatch; + stopWatch.start(); + + qint64 totalBytes = 0; + QByteArray dump; + QSignalSpy readyReadSpy(&process, SIGNAL(readyRead())); + QVERIFY(readyReadSpy.isValid()); + while (stopWatch.elapsed() < 2000) { + process.write(array); + while (process.bytesToWrite() > 0) { + int readCount = readyReadSpy.count(); + QVERIFY(process.waitForBytesWritten(5000)); + if (readyReadSpy.count() == readCount) + QVERIFY(process.waitForReadyRead(5000)); + } + + while (process.bytesAvailable() < array.size()) + QVERIFY2(process.waitForReadyRead(5000), qPrintable(process.errorString())); + dump = process.readAll(); + totalBytes += dump.size(); + } + + qDebug() << "Elapsed time:" << stopWatch.elapsed() << "ms;" + << "transfer rate:" << totalBytes / (1048.576) / stopWatch.elapsed() + << "MB/s"; + + for (int j = 0; j < array.size(); ++j) + QCOMPARE(char(dump.at(j)), char('a' + (j % 20))); + + process.closeWriteChannel(); + QVERIFY(process.waitForFinished()); +} +#endif // Q_OS_WINCE + +#endif // QT_NO_PROCESS + +QTEST_MAIN(tst_QProcess) +#include "tst_bench_qprocess.moc" From 0510fc149e0c6b955ee9b93917e72ee378369197 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 18 Oct 2012 16:27:35 -0700 Subject: [PATCH 104/114] Make QtDBus work again with D-Bus 1.0 and 1.1 The dbus_get_version function was introduced in 1.2, so we'd need to detect pre-1.2 by the absence of the function. But if we're going to detect the presence or absence of any function, we might as well do it on dbus_connection_can_send_type, which is the function we wanted anyway. Change-Id: I6e17a3a8f1382c6a489490084f6e3f61aa5a1947 Reviewed-by: Giuseppe D'Angelo --- src/dbus/qdbus_symbols_p.h | 12 ------------ src/dbus/qdbusintegrator.cpp | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h index a6e58e9148..f51728b47b 100644 --- a/src/dbus/qdbus_symbols_p.h +++ b/src/dbus/qdbus_symbols_p.h @@ -297,10 +297,6 @@ DEFINEFUNC(void , dbus_message_unref, (DBusMessage *message), (message), ) /* dbus-misc.h */ -DEFINEFUNC(void , dbus_get_version , (int *major_version_p, - int *minor_version_p, - int *micro_version_p), - (major_version_p, minor_version_p, micro_version_p), ) DEFINEFUNC(char* , dbus_get_local_machine_id , (void), (), return) @@ -363,14 +359,6 @@ DEFINEFUNC(void , dbus_server_unref, (DBusServer *server), /* dbus-thread.h */ DEFINEFUNC(dbus_bool_t , dbus_threads_init_default, (), (), return) - -/* D-Bus 1.4 symbols */ -#if !defined(QT_LINKED_LIBDBUS) || (DBUS_VERSION >= 0x010400) -DEFINEFUNC(dbus_bool_t , dbus_connection_can_send_type , (DBusConnection *connection, - int type), - (connection, type), return) -#endif - QT_END_NAMESPACE #endif // QT_NO_DBUS diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 3fb72e34d9..2b3ee901a5 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1687,24 +1687,23 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnection *connection) { QDBusConnection::ConnectionCapabilities result = 0; + typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int); + static can_send_type_t can_send_type = 0; -#if defined(QT_LINKED_LIBDBUS) && DBUS_VERSION < 0x010400 - // no capabilities are possible -#else -# if !defined(QT_LINKED_LIBDBUS) - // run-time check if the next functions are available - int major, minor, micro; - q_dbus_get_version(&major, &minor, µ); - if (major == 1 && minor < 4) - return result; +#if defined(QT_LINKED_LIBDBUS) +# if DBUS_VERSION-0 >= 0x010400 + can_send_type = dbus_connection_can_send_type; # endif +#else + // run-time check if the next functions are available + can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); +#endif #ifndef DBUS_TYPE_UNIX_FD # define DBUS_TYPE_UNIX_FD int('h') #endif - if (q_dbus_connection_can_send_type(connection, DBUS_TYPE_UNIX_FD)) + if (can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD)) result |= QDBusConnection::UnixFileDescriptorPassing; -#endif return result; } From c54a2dca1697974e85cc42b86fa2e1a7f50bde8e Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 16 Oct 2012 10:34:44 +0200 Subject: [PATCH 105/114] tst_qlocalsocket: get rid of QtScript dependency Removing the lackey executable that needs QtScript to be built. This was a qscript bastard that was able to run a client and a server script. It's replaced by a C++ version with the same functionality. Nice side effect: the two second wait per test row could be removed. The client executable is now waiting for the server to be created. Task-number: QTBUG-24142 Change-Id: I135b75abf6620d3b0af50dc226ea8c81c2bf4149 Reviewed-by: Friedemann Kleint Reviewed-by: Rohan McGovern --- .../network/socket/qlocalsocket/.gitignore | 1 - .../socket/qlocalsocket/lackey/lackey.pro | 15 - .../socket/qlocalsocket/lackey/main.cpp | 296 ------------------ .../qlocalsocket/lackey/scripts/client.js | 35 --- .../qlocalsocket/lackey/scripts/server.js | 19 -- .../socket/qlocalsocket/qlocalsocket.pro | 2 +- .../qlocalsocket/socketprocess/main.cpp | 150 +++++++++ .../socketprocess/socketprocess.pro | 9 + .../socket/qlocalsocket/tst_qlocalsocket.cpp | 54 +++- 9 files changed, 197 insertions(+), 384 deletions(-) delete mode 100644 tests/auto/network/socket/qlocalsocket/lackey/lackey.pro delete mode 100644 tests/auto/network/socket/qlocalsocket/lackey/main.cpp delete mode 100755 tests/auto/network/socket/qlocalsocket/lackey/scripts/client.js delete mode 100644 tests/auto/network/socket/qlocalsocket/lackey/scripts/server.js create mode 100644 tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp create mode 100644 tests/auto/network/socket/qlocalsocket/socketprocess/socketprocess.pro diff --git a/tests/auto/network/socket/qlocalsocket/.gitignore b/tests/auto/network/socket/qlocalsocket/.gitignore index b45c266ce3..e82f118896 100644 --- a/tests/auto/network/socket/qlocalsocket/.gitignore +++ b/tests/auto/network/socket/qlocalsocket/.gitignore @@ -1,2 +1 @@ tst_qlocalsocket -lackey/lackey.exe diff --git a/tests/auto/network/socket/qlocalsocket/lackey/lackey.pro b/tests/auto/network/socket/qlocalsocket/lackey/lackey.pro deleted file mode 100644 index 6e697325d7..0000000000 --- a/tests/auto/network/socket/qlocalsocket/lackey/lackey.pro +++ /dev/null @@ -1,15 +0,0 @@ -#include(../src/src.pri) - -QT = core script network testlib - -DESTDIR = ./ - -win32: CONFIG += console -mac:CONFIG -= app_bundle - -DEFINES += QLOCALSERVER_DEBUG -DEFINES += QLOCALSOCKET_DEBUG - -SOURCES += main.cpp -TARGET = lackey -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/network/socket/qlocalsocket/lackey/main.cpp b/tests/auto/network/socket/qlocalsocket/lackey/main.cpp deleted file mode 100644 index 112bf0588a..0000000000 --- a/tests/auto/network/socket/qlocalsocket/lackey/main.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - #include -#include - -#include -#include - -class QScriptLocalSocket : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString serverName WRITE connectToServer READ serverName) - -public: - QScriptLocalSocket(QObject *parent = 0) : QObject(parent) - { - lc = new QLocalSocket(this); - } - -public slots: - QString serverName() - { - return lc->serverName(); - } - - void connectToServer(const QString &name) { - lc->connectToServer(name); - } - - void sleep(int x) const - { - QTest::qSleep(x); - } - - bool isConnected() { - return (lc->state() == QLocalSocket::ConnectedState); - } - - void open() { - lc->open(QIODevice::ReadWrite); - } - - bool waitForConnected() { - return lc->waitForConnected(100000); - } - void waitForReadyRead() { - lc->waitForReadyRead(); - } - - void write(const QString &string) { - QTextStream out(lc); - out << string << endl; - } - - bool waitForBytesWritten(int t = 3000) { - return lc->waitForBytesWritten(t); - } - - QString readLine() { - QTextStream in(lc); - return in.readLine(); - } - - QString errorString() { - return lc->errorString(); - } - - void close() { - lc->close(); - } - -public: - QLocalSocket *lc; -}; - -class QScriptLocalServer : public QLocalServer -{ - Q_OBJECT - Q_PROPERTY(int maxPendingConnections WRITE setMaxPendingConnections READ maxPendingConnections) - Q_PROPERTY(QString name WRITE listen READ serverName) - Q_PROPERTY(bool listening READ isListening) - -public: - QScriptLocalServer(QObject *parent = 0) : QLocalServer(parent) - { - } - -public slots: - bool listen(const QString &name) { - if (!QLocalServer::listen(name)) { - if (serverError() == QAbstractSocket::AddressInUseError) { - QFile::remove(serverName()); - return QLocalServer::listen(name); - } - return false; - } - return true; - } - - QScriptLocalSocket *nextConnection() { - QLocalSocket *other = nextPendingConnection(); - QScriptLocalSocket *s = new QScriptLocalSocket(this); - delete s->lc; - s->lc = other; - return s; - } - - bool waitForNewConnection() { - return QLocalServer::waitForNewConnection(30000); - } - - QString errorString() { - return QLocalServer::errorString(); - } - - -}; - -template -static QScriptValue _q_ScriptValueFromQObject(QScriptEngine *engine, T* const &in) -{ - return engine->newQObject(in); -} -template -static void _q_ScriptValueToQObject(const QScriptValue &v, T* &out) -{ out = qobject_cast(v.toQObject()); -} -template -static int _q_ScriptRegisterQObjectMetaType(QScriptEngine *engine, const QScriptValue &prototype) -{ - return qScriptRegisterMetaType(engine, _q_ScriptValueFromQObject, _q_ScriptValueToQObject, prototype); -} - -QT_BEGIN_NAMESPACE -Q_SCRIPT_DECLARE_QMETAOBJECT(QScriptLocalSocket, QObject*); -Q_SCRIPT_DECLARE_QMETAOBJECT(QScriptLocalServer, QObject*); -QT_END_NAMESPACE - -static void interactive(QScriptEngine &eng) -{ - QTextStream qin(stdin, QFile::ReadOnly); - - const char *qscript_prompt = "qs> "; - const char *dot_prompt = ".... "; - const char *prompt = qscript_prompt; - - QString code; - - forever { - QString line; - - printf("%s", prompt); - fflush(stdout); - - line = qin.readLine(); - if (line.isNull()) - break; - - code += line; - code += QLatin1Char('\n'); - - if (line.trimmed().isEmpty()) { - continue; - - } else if (! eng.canEvaluate(code)) { - prompt = dot_prompt; - - } else { - QScriptValue result = eng.evaluate(code); - code.clear(); - prompt = qscript_prompt; - if (!result.isUndefined()) - fprintf(stderr, "%s\n", qPrintable(result.toString())); - } - } -} -Q_DECLARE_METATYPE(QScriptLocalSocket*) -Q_DECLARE_METATYPE(QScriptLocalServer*) -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - QScriptEngine eng; - QScriptValue globalObject = eng.globalObject(); - - _q_ScriptRegisterQObjectMetaType(&eng, QScriptValue()); - - QScriptValue lss = qScriptValueFromQMetaObject(&eng); - eng.globalObject().setProperty("QScriptLocalServer", lss); - - _q_ScriptRegisterQObjectMetaType(&eng, QScriptValue()); - - QScriptValue lsc = qScriptValueFromQMetaObject(&eng); - eng.globalObject().setProperty("QScriptLocalSocket", lsc); - - if (! *++argv) { - interactive(eng); - return EXIT_SUCCESS; - } - - QStringList arguments; - for (int i = 0; i < argc - 1; ++i) - arguments << QString::fromLocal8Bit(argv[i]); - - while (!arguments.isEmpty()) { - QString fn = arguments.takeFirst(); - - if (fn == QLatin1String("-i")) { - interactive(eng); - break; - } - - QString contents; - - if (fn == QLatin1String("-")) { - QTextStream stream(stdin, QFile::ReadOnly); - contents = stream.readAll(); - } else { - QFile file(fn); - if (!file.exists()) { - fprintf(stderr, "%s doesn't exists\n", qPrintable(fn)); - return EXIT_FAILURE; - } - if (file.open(QFile::ReadOnly)) { - QTextStream stream(&file); - contents = stream.readAll(); - file.close(); - } - } - - if (contents.isEmpty()) - continue; - - if (contents[0] == '#') { - contents.prepend("//"); - QScriptValue args = eng.newArray(); - args.setProperty("0", QScriptValue(&eng, fn)); - int i = 1; - while (!arguments.isEmpty()) - args.setProperty(i++, QScriptValue(&eng, arguments.takeFirst())); - eng.currentContext()->activationObject().setProperty("args", args); - } - QScriptValue r = eng.evaluate(contents); - if (eng.hasUncaughtException()) { - int line = eng.uncaughtExceptionLineNumber(); - fprintf(stderr, "%d: %s\n\t%s\n\n", line, qPrintable(fn), qPrintable(r.toString())); - return EXIT_FAILURE; - } - if (r.isNumber()) - return r.toInt32(); - } - - return EXIT_SUCCESS; -} - -#include "main.moc" diff --git a/tests/auto/network/socket/qlocalsocket/lackey/scripts/client.js b/tests/auto/network/socket/qlocalsocket/lackey/scripts/client.js deleted file mode 100755 index 76cc0b97ad..0000000000 --- a/tests/auto/network/socket/qlocalsocket/lackey/scripts/client.js +++ /dev/null @@ -1,35 +0,0 @@ -#/bin/qscript -function QVERIFY(x, socket) { - if (!(x)) { - throw(socket.errorString()); - } -} - -var socket = new QScriptLocalSocket; -var tries = 0; -do { - socket.serverName = "qlocalsocket_autotest"; - if ((socket.errorString() != "QLocalSocket::connectToServer: Invalid name") - && (socket.errorString() != "QLocalSocket::connectToServer: Connection refused")) - break; - socket.sleep(1); - ++tries; - print("isConnected:", socket.isConnected()); -} while ((socket.errorString() == "QLocalSocket::connectToServer: Invalid name" - || (socket.errorString() == "QlocalSocket::connectToServer: Connection refused")) - && tries < 5000); -if (tries == 5000) { - print("too many tries, exiting"); -} else { -socket.waitForConnected(); -//print("isConnected:", socket.isConnected()); -if (!socket.isConnected()) - print("Not Connected:", socket.errorString()); -socket.waitForReadyRead(); -var text = socket.readLine(); -var testLine = "test"; -QVERIFY((text == testLine), socket); -QVERIFY((socket.errorString() == "Unknown error"), socket); -socket.close(); -//print("client: exiting", text); -} diff --git a/tests/auto/network/socket/qlocalsocket/lackey/scripts/server.js b/tests/auto/network/socket/qlocalsocket/lackey/scripts/server.js deleted file mode 100644 index 98a83bc9dd..0000000000 --- a/tests/auto/network/socket/qlocalsocket/lackey/scripts/server.js +++ /dev/null @@ -1,19 +0,0 @@ -#/bin/qscript -function QVERIFY(x, server) { - if (!(x)) { - throw(server.errorString()); - } -} -var server = new QScriptLocalServer; -QVERIFY(server.listen("qlocalsocket_autotest"), server); -var done = args[1]; -var testLine = "test"; -while (done > 0) { - QVERIFY(server.waitForNewConnection(), server); - var serverSocket = server.nextConnection(); - serverSocket.write(testLine); - QVERIFY(serverSocket.waitForBytesWritten(), serverSocket); - QVERIFY(serverSocket.errorString() == "" - ||serverSocket.errorString() == "Unknown error", serverSocket); - --done; -} diff --git a/tests/auto/network/socket/qlocalsocket/qlocalsocket.pro b/tests/auto/network/socket/qlocalsocket/qlocalsocket.pro index fb09dd6adb..cbf5d160d9 100644 --- a/tests/auto/network/socket/qlocalsocket/qlocalsocket.pro +++ b/tests/auto/network/socket/qlocalsocket/qlocalsocket.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = test # lackey should be moved to the QtScript module +SUBDIRS = test socketprocess diff --git a/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp b/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp new file mode 100644 index 0000000000..de78f9afe7 --- /dev/null +++ b/tests/auto/network/socket/qlocalsocket/socketprocess/main.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +const QString serverName = QStringLiteral("qlocalsocket_autotest"); +const QByteArray testData("test"); +QSystemSemaphore *semaphore = 0; + +bool runServer(int numberOfConnections) +{ + QLocalServer *server = new QLocalServer(qApp); + if (!server->removeServer(serverName)) { + fprintf(stderr, "server: cannot remove server: %s\n", qPrintable(server->errorString())); + return false; + } + printf("server: listen on \"%s\"\n", qPrintable(serverName)); + if (!server->listen(serverName)) { + fprintf(stderr, "server: listen failed: %s\n", qPrintable(server->errorString())); + return false; + } + semaphore->release(); + for (int i = 1; i <= numberOfConnections; ++i) { + printf("server: wait for connection %d\n", i); + if (!server->waitForNewConnection(30000)) { + semaphore->acquire(); + fprintf(stderr, "server: waitForNewConnection failed: %s\n", + qPrintable(server->errorString())); + return false; + } + QLocalSocket *socket = server->nextPendingConnection(); + printf("server: writing \"%s\"\n", testData.data()); + socket->write(testData); + if (!socket->waitForBytesWritten()) { + semaphore->acquire(); + fprintf(stderr, "server: waitForBytesWritten failed: %s\n", + qPrintable(socket->errorString())); + return false; + } + printf("server: data written\n"); + if (socket->error() != QLocalSocket::UnknownSocketError) { + semaphore->acquire(); + fprintf(stderr, "server: socket error %d\n", socket->error()); + return false; + } + } + semaphore->acquire(); + return true; +} + +bool runClient() +{ + semaphore->acquire(); // wait until the server is up and running + semaphore->release(); + + QLocalSocket socket; + printf("client: connecting to \"%s\"\n", qPrintable(serverName)); + socket.connectToServer(serverName, QLocalSocket::ReadWrite); + if (!socket.waitForConnected()) { + fprintf(stderr, "client: waitForConnected failed: %s\n", + qPrintable(socket.errorString())); + return false; + } + printf("client: connected\n"); + if (!socket.waitForReadyRead()) { + fprintf(stderr, "client: waitForReadyRead failed: %s\n", + qPrintable(socket.errorString())); + return false; + } + printf("client: data is available for reading\n"); + const QByteArray data = socket.readLine(); + printf("client: received \"%s\"\n", data.data()); + if (data != testData) { + fprintf(stderr, "client: received unexpected data\n"); + return false; + } + return true; +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + QSystemSemaphore s("tst_qlocalsocket_socketprocess"); + semaphore = &s; + if (argc < 2) + return EXIT_FAILURE; + if (strcmp(argv[1], "--server") == 0) { + if (argc < 3) { + fprintf(stderr, "--server needs the number of incoming connections\n"); + return EXIT_FAILURE; + } + bool ok; + int n = QByteArray(argv[2]).toInt(&ok); + if (!ok) { + fprintf(stderr, "Cannot convert %s to a number.\n", argv[2]); + return EXIT_FAILURE; + } + if (!runServer(n)) + return EXIT_FAILURE; + } else if (strcmp(argv[1], "--client") == 0) { + if (!runClient()) + return EXIT_FAILURE; + } else { + fprintf(stderr, "unknown command line option: %s\n", argv[1]); + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/tests/auto/network/socket/qlocalsocket/socketprocess/socketprocess.pro b/tests/auto/network/socket/qlocalsocket/socketprocess/socketprocess.pro new file mode 100644 index 0000000000..643c4c5733 --- /dev/null +++ b/tests/auto/network/socket/qlocalsocket/socketprocess/socketprocess.pro @@ -0,0 +1,9 @@ +QT = core network testlib + +DESTDIR = ./ +TARGET = socketprocess + +win32:CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 8bcb8cc571..4f6fc4619f 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -735,53 +735,73 @@ void tst_QLocalSocket::processConnection_data() { QTest::addColumn("processes"); QTest::newRow("1 client") << 1; -#ifndef Q_OS_WIN QTest::newRow("2 clients") << 2; QTest::newRow("5 clients") << 5; -#endif QTest::newRow("30 clients") << 30; } +class ProcessOutputDumper +{ +public: + ProcessOutputDumper(QProcess *p = 0) + : process(p) + {} + + ~ProcessOutputDumper() + { + if (process) + fputs(process->readAll().data(), stdout); + } + + void clear() + { + process = 0; + } + +private: + QProcess *process; +}; + /*! Create external processes that produce and consume. */ void tst_QLocalSocket::processConnection() { #ifdef Q_OS_WIN -# define EXE_SUFFIX ".exe" + const QString exeSuffix = QStringLiteral(".exe"); #else -# define EXE_SUFFIX + const QString exeSuffix; #endif -// ### lackey is currently not build - QEXPECT_FAIL("", "lackey is currently not built due to qscript dependency, QTBUG-24142", Abort); - QVERIFY(QFile::exists("lackey/lackey" EXE_SUFFIX)); + QString socketProcess = QStringLiteral("socketprocess/socketprocess") + exeSuffix; + QVERIFY(QFile::exists(socketProcess)); QFETCH(int, processes); - QStringList serverArguments = QStringList() << SRCDIR "lackey/scripts/server.js" << QString::number(processes); + QStringList serverArguments = QStringList() << "--server" << QString::number(processes); QProcess producer; - producer.setProcessChannelMode(QProcess::ForwardedChannels); + ProcessOutputDumper producerOutputDumper(&producer); QList consumers; - producer.start("lackey/lackey", serverArguments); + producer.start(socketProcess, serverArguments); QVERIFY2(producer.waitForStarted(-1), qPrintable(producer.errorString())); - QTest::qWait(2000); for (int i = 0; i < processes; ++i) { - QStringList arguments = QStringList() << SRCDIR "lackey/scripts/client.js"; + QStringList arguments = QStringList() << "--client"; QProcess *p = new QProcess; - p->setProcessChannelMode(QProcess::ForwardedChannels); consumers.append(p); - p->start("lackey/lackey", arguments); + p->start(socketProcess, arguments); } while (!consumers.isEmpty()) { - consumers.first()->waitForFinished(20000); - QCOMPARE(consumers.first()->exitStatus(), QProcess::NormalExit); - QCOMPARE(consumers.first()->exitCode(), 0); QProcess *consumer = consumers.takeFirst(); + ProcessOutputDumper consumerOutputDumper(consumer); + consumer->waitForFinished(20000); + QCOMPARE(consumer->exitStatus(), QProcess::NormalExit); + QCOMPARE(consumer->exitCode(), 0); + consumerOutputDumper.clear(); consumer->terminate(); delete consumer; } producer.waitForFinished(15000); + producerOutputDumper.clear(); } #endif From a61788d139470afa02202945f0723a9c8ef745ec Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 16 Oct 2012 14:58:47 +0200 Subject: [PATCH 106/114] Change the default major version of QGLFormat to 2. This is being changed because: - The OpenGL paint engine in Qt only supports GL2 - QML2 only supports GL2 - QSurfaceFormat has a default value of 2 Applications that want to use GL1 on a QGLWidget will have to explicitly request this format using QGLFormat::setVersion. Task-number: QTBUG-27589 Change-Id: Ieb283ef7d6e15a29ec28ce7e4363dbf477decaa7 Reviewed-by: Sean Harmer --- dist/changes-5.0.0 | 3 +++ src/opengl/qgl_p.h | 2 +- tests/auto/opengl/qgl/tst_qgl.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 0014760b6c..834b62edbe 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -617,6 +617,9 @@ QtOpenGL QGLWidget and a QOpenGLFramebufferObject. It is recommended that applications using QGLPixelBuffer for offscreen rendering to a texture switch to using QOpenGLFramebufferObject directly instead, for improved performance. +* The default major version of QGLFormat has been changed to 2 to be aligned + with QSurfaceFormat. Applications that want to use a different version should + explicitly request it using QGLFormat::setVersion(). QtScript -------- diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 4a2b2b11d1..6ef4eda5fc 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -86,7 +86,7 @@ public: depthSize = accumSize = stencilSize = redSize = greenSize = blueSize = alphaSize = -1; numSamples = -1; swapInterval = -1; - majorVersion = 1; + majorVersion = 2; minorVersion = 0; profile = QGLFormat::NoProfile; } diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 899e642249..3f77aa7233 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -439,7 +439,7 @@ void tst_QGL::getSetCheck() // int QGLFormat::major/minorVersion() // void QGLFormat::setVersion(int, int) - QCOMPARE(obj1.majorVersion(), 1); + QCOMPARE(obj1.majorVersion(), 2); QCOMPARE(obj1.minorVersion(), 0); obj1.setVersion(3, 2); QCOMPARE(obj1.majorVersion(), 3); From 89c53738de46c075e51bc0c185417318fd2d910a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Oct 2012 16:00:50 +0200 Subject: [PATCH 107/114] CMake: Remove content from else() and endif() commands. Having them empty is the common style and is less noisy. Change-Id: I30c0c4d297a7bdb373a57a636f4fdbc488a69fcd Reviewed-by: Clinton Stimpson Reviewed-by: Stephen Kelly Reviewed-by: Alexander Neundorf --- mkspecs/cmake/Qt5ConfigVersion.cmake.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/cmake/Qt5ConfigVersion.cmake.in b/mkspecs/cmake/Qt5ConfigVersion.cmake.in index 66d4b85f60..96ea9c000d 100644 --- a/mkspecs/cmake/Qt5ConfigVersion.cmake.in +++ b/mkspecs/cmake/Qt5ConfigVersion.cmake.in @@ -3,9 +3,9 @@ set(PACKAGE_VERSION $$eval(QT.$${MODULE}.VERSION)) if(\"\${PACKAGE_VERSION}\" VERSION_LESS \"\${PACKAGE_FIND_VERSION}\") set(PACKAGE_VERSION_COMPATIBLE FALSE) -else(\"\${PACKAGE_VERSION}\" VERSION_LESS \"\${PACKAGE_FIND_VERSION}\") +else() set(PACKAGE_VERSION_COMPATIBLE TRUE) if(\"\${PACKAGE_FIND_VERSION}\" STREQUAL \"\${PACKAGE_VERSION}\") set(PACKAGE_VERSION_EXACT TRUE) - endif(\"\${PACKAGE_FIND_VERSION}\" STREQUAL \"\${PACKAGE_VERSION}\") -endif(\"\${PACKAGE_VERSION}\" VERSION_LESS \"\${PACKAGE_FIND_VERSION}\") + endif() +endif() From 9fa2e5a14db453de9d9fec58eeada87b486d3bad Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 28 Sep 2012 19:43:52 +0200 Subject: [PATCH 108/114] Accessibility: itemviews check for valid model. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem is that isValid() should return true as soon as we have a view widget. That sadly means we need to verify that the model is still valid whenever accessing it. Change-Id: I9237528abf2f5c75a73382525103307e9ca15f05 Reviewed-by: Jan Arve Sæther --- src/plugins/accessible/widgets/itemviews.cpp | 53 ++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/plugins/accessible/widgets/itemviews.cpp b/src/plugins/accessible/widgets/itemviews.cpp index 649863ed84..0aeff6e1a3 100644 --- a/src/plugins/accessible/widgets/itemviews.cpp +++ b/src/plugins/accessible/widgets/itemviews.cpp @@ -75,7 +75,7 @@ QAbstractItemView *QAccessibleTable::view() const int QAccessibleTable::logicalIndex(const QModelIndex &index) const { - if (!index.isValid()) + if (!view()->model() || !index.isValid()) return -1; int vHeader = verticalHeader() ? 1 : 0; int hHeader = horizontalHeader() ? 1 : 0; @@ -85,7 +85,7 @@ int QAccessibleTable::logicalIndex(const QModelIndex &index) const QAccessibleInterface *QAccessibleTable::childFromLogical(int logicalIndex) const { - if (!isValid()) + if (!view()->model()) return 0; logicalIndex--; // one based counting ftw @@ -179,6 +179,8 @@ QAccessibleTableCell *QAccessibleTable::cell(const QModelIndex &index) const QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const { + if (!view()->model()) + return 0; Q_ASSERT(role() != QAccessible::Tree); QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); if (!index.isValid()) { @@ -195,42 +197,58 @@ QAccessibleInterface *QAccessibleTable::caption() const QString QAccessibleTable::columnDescription(int column) const { + if (!view()->model()) + return QString(); return view()->model()->headerData(column, Qt::Horizontal).toString(); } int QAccessibleTable::columnCount() const { + if (!view()->model()) + return 0; return view()->model()->columnCount(); } int QAccessibleTable::rowCount() const { + if (!view()->model()) + return 0; return view()->model()->rowCount(); } int QAccessibleTable::selectedCellCount() const { + if (!view()->selectionModel()) + return 0; return view()->selectionModel()->selectedIndexes().count(); } int QAccessibleTable::selectedColumnCount() const { + if (!view()->selectionModel()) + return 0; return view()->selectionModel()->selectedColumns().count(); } int QAccessibleTable::selectedRowCount() const { + if (!view()->selectionModel()) + return 0; return view()->selectionModel()->selectedRows().count(); } QString QAccessibleTable::rowDescription(int row) const { + if (!view()->model()) + return QString(); return view()->model()->headerData(row, Qt::Vertical).toString(); } QList QAccessibleTable::selectedCells() const { QList cells; + if (!view()->selectionModel()) + return cells; Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedIndexes()) { cells.append(cell(index)); } @@ -239,6 +257,8 @@ QList QAccessibleTable::selectedCells() const QList QAccessibleTable::selectedColumns() const { + if (!view()->selectionModel()) + return QList(); QList columns; Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedColumns()) { columns.append(index.column()); @@ -248,6 +268,8 @@ QList QAccessibleTable::selectedColumns() const QList QAccessibleTable::selectedRows() const { + if (!view()->selectionModel()) + return QList(); QList rows; Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedRows()) { rows.append(index.row()); @@ -262,16 +284,22 @@ QAccessibleInterface *QAccessibleTable::summary() const bool QAccessibleTable::isColumnSelected(int column) const { + if (!view()->selectionModel()) + return false; return view()->selectionModel()->isColumnSelected(column, QModelIndex()); } bool QAccessibleTable::isRowSelected(int row) const { + if (!view()->selectionModel()) + return false; return view()->selectionModel()->isRowSelected(row, QModelIndex()); } bool QAccessibleTable::selectRow(int row) { + if (!view()->model() || !view()->selectionModel()) + return false; QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) return false; @@ -281,6 +309,8 @@ bool QAccessibleTable::selectRow(int row) bool QAccessibleTable::selectColumn(int column) { + if (!view()->model() || !view()->selectionModel()) + return false; QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) return false; @@ -290,6 +320,8 @@ bool QAccessibleTable::selectColumn(int column) bool QAccessibleTable::unselectRow(int row) { + if (!view()->model() || !view()->selectionModel()) + return false; QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) return false; @@ -299,6 +331,8 @@ bool QAccessibleTable::unselectRow(int row) bool QAccessibleTable::unselectColumn(int column) { + if (!view()->model() || !view()->selectionModel()) + return false; QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) return false; @@ -340,6 +374,8 @@ int QAccessibleTable::childCount() const int QAccessibleTable::indexOfChild(const QAccessibleInterface *iface) const { + if (!view()->model()) + return -1; Q_ASSERT(iface->role() != QAccessible::TreeItem); // should be handled by tree class if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) { const QAccessibleTableCell* cell = static_cast(iface); @@ -403,7 +439,7 @@ void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const { - if (!isValid()) + if (!isValid() || !view()->model()) return QModelIndex(); const QTreeView *treeView = qobject_cast(view()); @@ -421,6 +457,8 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const { + if (!view()->model()) + return 0; QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); @@ -451,7 +489,8 @@ int QAccessibleTree::childCount() const QAccessibleInterface *QAccessibleTree::child(int index) const { - Q_ASSERT(index >= 0); + if ((index < 0) || (!view()->model())) + return 0; int hHeader = horizontalHeader() ? 1 : 0; if (hHeader) { @@ -480,6 +519,8 @@ int QAccessibleTree::rowCount() const int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const { + if (!view()->model()) + return -1; if (iface->role() == QAccessible::TreeItem) { const QAccessibleTableCell* cell = static_cast(iface); const QTreeView *treeView = qobject_cast(view()); @@ -520,12 +561,16 @@ QString QAccessibleTree::rowDescription(int) const bool QAccessibleTree::isRowSelected(int row) const { + if (!view()->selectionModel()) + return false; QModelIndex index = indexFromLogical(row); return view()->selectionModel()->isRowSelected(index.row(), index.parent()); } bool QAccessibleTree::selectRow(int row) { + if (!view()->selectionModel()) + return false; QModelIndex index = indexFromLogical(row); if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) return false; From f7f9a28a26a071f2f4a3823de1cdf162ac306314 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 18 Oct 2012 15:01:39 +0200 Subject: [PATCH 109/114] Test: remove QSKIP from tst_QDateTime::fromString_LOCALE_ILDATE Instead omit the whole test when Q_OS_WIN is not defined. Change-Id: I311538ce839353d4d5e83edfd12c68968fe61215 Reviewed-by: J-P Nurmi --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index ac544ca904..0189306a1b 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -117,7 +117,9 @@ private slots: void fromStringDateFormat(); void fromStringStringFormat_data(); void fromStringStringFormat(); +#ifdef Q_OS_WIN void fromString_LOCALE_ILDATE(); +#endif void fromStringToStringLocale_data(); void fromStringToStringLocale(); @@ -1543,19 +1545,18 @@ void tst_QDateTime::fromStringStringFormat() QCOMPARE(dt, expected); } +#ifdef Q_OS_WIN +// Windows only void tst_QDateTime::fromString_LOCALE_ILDATE() { -#ifdef Q_OS_WIN QString date1 = QLatin1String("Sun 1. Dec 13:02:00 1974"); QString date2 = QLatin1String("Sun Dec 1 13:02:00 1974"); QDateTime ref(QDate(1974, 12, 1), QTime(13, 2)); QCOMPARE(ref, QDateTime::fromString(date2, Qt::TextDate)); QCOMPARE(ref, QDateTime::fromString(date1, Qt::TextDate)); -#else - QSKIP("Windows only"); -#endif } +#endif void tst_QDateTime::fromStringToStringLocale_data() { From b8fe5e1bbc7f341d03d2704a6110d6e3240589bb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 28 Sep 2012 14:02:29 +0200 Subject: [PATCH 110/114] Make sure functions returning iterators have an iterator as parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The IA-64 C++ ABI does not encode the return type for non-template functions (QVector is the template, not the function), which means that these two functions have the same signature: Node *QVector::begin() typename class QTypedArrayData::iterator QVector::begin() [both are _ZN7QVectorI4NodeE5beginEv] When linking compilation units compiled with different QT_STRICT_ITERATORS settings, only one of the two out-of-line copies will survive. Depending on the ABI, we may have a problem: the ABI can say that a function returning a structure takes an implicit first parameter, which a function returning a regular pointer doesn't. Task-number: QTBUG-27277 Change-Id: I57a59e5a7c46f55faabfe85c073dca89d2a7bbf3 Reviewed-by: Jan Kundrát Reviewed-by: Thiago Macieira --- src/corelib/tools/qarraydata.h | 12 ++++++------ src/corelib/tools/qvector.h | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a67255ad68..7fecbbbeeb 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -209,12 +209,12 @@ struct QTypedArrayData T *data() { return static_cast(QArrayData::data()); } const T *data() const { return static_cast(QArrayData::data()); } - iterator begin() { return data(); } - iterator end() { return data() + size; } - const_iterator begin() const { return data(); } - const_iterator end() const { return data() + size; } - const_iterator constBegin() const { return data(); } - const_iterator constEnd() const { return data() + size; } + iterator begin(iterator = iterator()) { return data(); } + iterator end(iterator = iterator()) { return data() + size; } + const_iterator begin(const_iterator = const_iterator()) const { return data(); } + const_iterator end(const_iterator = const_iterator()) const { return data() + size; } + const_iterator constBegin(const_iterator = const_iterator()) const { return data(); } + const_iterator constEnd(const_iterator = const_iterator()) const { return data() + size; } class AlignmentDummy { QArrayData header; T data; }; diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index c0ae048322..925ad17110 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -151,6 +151,7 @@ public: // STL-style typedef typename Data::iterator iterator; typedef typename Data::const_iterator const_iterator; +#if !defined(QT_STRICT_ITERATORS) || defined(Q_QDOC) inline iterator begin() { detach(); return d->begin(); } inline const_iterator begin() const { return d->constBegin(); } inline const_iterator cbegin() const { return d->constBegin(); } @@ -159,6 +160,16 @@ public: inline const_iterator end() const { return d->constEnd(); } inline const_iterator cend() const { return d->constEnd(); } inline const_iterator constEnd() const { return d->constEnd(); } +#else + inline iterator begin(iterator = iterator()) { detach(); return d->begin(); } + inline const_iterator begin(const_iterator = const_iterator()) const { return d->constBegin(); } + inline const_iterator cbegin(const_iterator = const_iterator()) const { return d->constBegin(); } + inline const_iterator constBegin(const_iterator = const_iterator()) const { return d->constBegin(); } + inline iterator end(iterator = iterator()) { detach(); return d->end(); } + inline const_iterator end(const_iterator = const_iterator()) const { return d->constEnd(); } + inline const_iterator cend(const_iterator = const_iterator()) const { return d->constEnd(); } + inline const_iterator constEnd(const_iterator = const_iterator()) const { return d->constEnd(); } +#endif iterator insert(iterator before, int n, const T &x); inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } iterator erase(iterator begin, iterator end); From efe607e8aa6ecb156ffaea1a9c0ea1b09595133a Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 5 Oct 2012 18:36:03 +0200 Subject: [PATCH 111/114] Review of documentation. Documentation has been updated to reflect changes in Qt5. Change-Id: I378858cf61f4bf62375c30c3903818d754dadcf0 Reviewed-by: Frederik Gladhorn --- .../code/src_corelib_plugin_quuid.cpp | 2 +- src/corelib/plugin/quuid.cpp | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp b/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp index 662ce35054..34c81189c1 100644 --- a/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp @@ -40,5 +40,5 @@ //! [0] // {67C8770B-44F1-410A-AB9A-F9B5446F13EE} -QUuid IID_MyInterface(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee) +QUuid IID_MyInterface(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee); //! [0] diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 445f707a73..c1ebc57cf6 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -181,7 +181,7 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto are in use. Each UUID contains a bit field that specifies which type (variant) of UUID it is. Call variant() to discover which type of UUID an instance of QUuid contains. It extracts the three - most signifcant bits of byte 8 of the 16 bytes. In QUuid, byte 8 + most significant bits of byte 8 of the 16 bytes. In QUuid, byte 8 is \c{QUuid::data4[0]}. If you create instances of QUuid using the constructor that accepts all the numeric values as parameters, use the following table to set the three most significant bits of @@ -428,7 +428,17 @@ QUuid::QUuid(const QByteArray &text) \since 5.0 \fn QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData); - This functions returns a new UUID with variant QUuid::DCE and version QUuid::Md5. + This function returns a new UUID with variant QUuid::DCE and version QUuid::Md5. + \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. + + \sa variant(), version(), createUuidV5() +*/ + +/*! + \since 5.0 + \fn QUuid QUuid::createUuidV3(const QUuid &ns, const QString &baseData); + + This function returns a new UUID with variant QUuid::DCE and version QUuid::Md5. \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. \sa variant(), version(), createUuidV5() @@ -438,7 +448,17 @@ QUuid::QUuid(const QByteArray &text) \since 5.0 \fn QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData); - This functions returns a new UUID with variant QUuid::DCE and version QUuid::Sha1. + This function returns a new UUID with variant QUuid::DCE and version QUuid::Sha1. + \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. + + \sa variant(), version(), createUuidV3() +*/ + +/*! + \since 5.0 + \fn QUuid QUuid::createUuidV5(const QUuid &ns, const QString &baseData); + + This function returns a new UUID with variant QUuid::DCE and version QUuid::Sha1. \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. \sa variant(), version(), createUuidV3() @@ -990,6 +1010,10 @@ QUuid QUuid::createUuid() */ #ifndef QT_NO_DEBUG_STREAM +/*! + \relates QUuid + Writes the UUID \a id to the output stream for debugging information \a dbg. +*/ QDebug operator<<(QDebug dbg, const QUuid &id) { #ifndef QT_NO_QUUID_STRING From c4b2d77f40a42a67480bb49aa63b0953c80c024a Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Wed, 17 Oct 2012 11:19:34 +0200 Subject: [PATCH 112/114] Fix for slowness of touch move events In the event dispatcher native events will be processed in a tight loop to drain the queue. IO events and timers will be postponed. Change-Id: Ic2c06ed182027289eb5e7042fbae99efbd01ea27 Reviewed-by: Fabian Bumberger Reviewed-by: Sean Harmer Reviewed-by: Thomas McGuire --- .../kernel/qeventdispatcher_blackberry.cpp | 102 ++++++++---------- 1 file changed, 45 insertions(+), 57 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 33ca1023dd..b2ec574c89 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -243,28 +243,6 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif } } -static inline bool updateTimeout(int *timeout, const struct timeval &start) -{ - // A timeout of -1 means we should block indefinitely. If we get here, we got woken up by a - // non-IO BPS event, and that event has been processed already. This means we can go back and - // block in bps_get_event(). - // Note that processing the BPS event might have triggered a wakeup, in that case we get a - // IO event in the next bps_get_event() right away. - if (*timeout == -1) - return true; - - if (Q_UNLIKELY(!QElapsedTimer::isMonotonic())) { - // we cannot recalculate the timeout without a monotonic clock as the time may have changed - return false; - } - - // clock source is monotonic, so we can recalculate how much timeout is left - timeval t2 = qt_gettime(); - int elapsed = (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000); - *timeout -= elapsed; - return *timeout >= 0; -} - int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout) { @@ -291,60 +269,70 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef FD_ZERO(exceptfds); // Convert timeout to milliseconds - int timeout_bps = -1; + int timeoutTotal = -1; if (timeout) - timeout_bps = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); + timeoutTotal = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); + + int timeoutLeft = timeoutTotal; - bool hasProcessedEventsOnce = false; bps_event_t *event = 0; + unsigned int eventCount = 0; // This loop exists such that we can drain the bps event queue of all native events // more efficiently than if we were to return control to Qt after each event. This // is important for handling touch events which can come in rapidly. forever { - Q_ASSERT(!hasProcessedEventsOnce || event); + // Only emit the awake() and aboutToBlock() signals in the second iteration. For the + // first iteration, the UNIX event dispatcher will have taken care of that already. + // Also native events are actually processed one loop iteration after they were + // retrieved with bps_get_event(). - // Only emit the awake() and aboutToBlock() signals in the second iteration. For the first - // iteration, the UNIX event dispatcher will have taken care of that already. - if (hasProcessedEventsOnce) - emit awake(); + // Filtering the native event should happen between the awake() and aboutToBlock() + // signal emissions. The calls awake() - filterNativeEvent() - aboutToBlock() - + // bps_get_event() need not to be interrupted by a break or return statement. + if (eventCount > 0) { + if (event) { + emit awake(); + filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast(event), 0); + emit aboutToBlock(); + } - // Filtering the native event should happen between the awake() and aboutToBlock() signal - // emissions. The calls awake() - filterNativeEvent() - aboutToBlock() - bps_get_event() - // need not to be interrupted by a break or return statement. - // - // Because of this, the native event is actually processed one loop iteration - // after it was retrieved with bps_get_event(). - if (event) - filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast(event), 0); - - if (hasProcessedEventsOnce) - emit aboutToBlock(); + // Update the timeout + // Clock source is monotonic, so we can recalculate how much timeout is left + if (timeoutTotal != -1) { + timeval t2 = qt_gettime(); + timeoutLeft = timeoutTotal - ((t2.tv_sec * 1000 + t2.tv_usec / 1000) + - (startTime.tv_sec * 1000 + startTime.tv_usec / 1000)); + if (timeoutLeft < 0) + timeoutLeft = 0; + } + } // Wait for event or file to be ready event = 0; - const int result = bps_get_event(&event, timeout_bps); + const int result = bps_get_event(&event, timeoutLeft); if (result != BPS_SUCCESS) qWarning("QEventDispatcherBlackberry::select: bps_get_event() failed"); - // In the case of !event, we break out of the loop to let Qt process the timers - // that are now ready (since timeout has expired). - // In the case of bpsIOReadyDomain, we break out to let Qt process the FDs that - // are ready. If we do not do this activation of QSocketNotifiers etc would be - // delayed. - if (!event || bps_event_get_domain(event) == bpsIOReadyDomain) - break; + if (!event) // In case of !event, we break out of the loop to let Qt process the timers + break; // (since timeout has expired) and socket notifiers that are now ready. - // Update the timeout. If this fails we have exceeded our alloted time or the system - // clock has changed time and we cannot calculate a new timeout so we bail out. - if (!updateTimeout(&timeout_bps, startTime)) { - - // No more loop iteration, so we need to filter the event here. - filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast(event), 0); - break; + if (bps_event_get_domain(event) == bpsIOReadyDomain) { + timeoutTotal = 0; // in order to immediately drain the event queue of native events + event = 0; // (especially touch move events) we don't break out here } - hasProcessedEventsOnce = true; + ++eventCount; + + // Make sure we are not trapped in this loop due to continuous native events + // also we cannot recalculate the timeout without a monotonic clock as the time may have changed + const unsigned int maximumEventCount = 12; + if (Q_UNLIKELY((eventCount > maximumEventCount && timeoutLeft == 0) + || !QElapsedTimer::isMonotonic())) { + if (event) + filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast(event), 0); + break; + } } // the number of bits set in the file sets From 320c4e31e124f99601399d00935362b587c77510 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Sep 2012 16:30:48 +0200 Subject: [PATCH 113/114] Make QContiguousCache with zero capacity not crash These containers don't make sense and will just result in no action being taken (all items added will simply be discarded), but it shouldn't crash due to a division by zero. Update the documentation to explain the fact. Task-number: QTBUG-27339 Change-Id: Ib9acf5c0a9a826e6853e7beaf5e56511fde98dc6 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Ian Walters Reviewed-by: Thiago Macieira --- src/corelib/tools/qcontiguouscache.cpp | 11 ++++++++-- src/corelib/tools/qcontiguouscache.h | 6 ++++++ .../qcontiguouscache/tst_qcontiguouscache.cpp | 21 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp index 3e325bec59..40edb0fa58 100644 --- a/src/corelib/tools/qcontiguouscache.cpp +++ b/src/corelib/tools/qcontiguouscache.cpp @@ -80,8 +80,15 @@ void QContiguousCacheData::freeData(QContiguousCacheData *data) of matching how user interface views most commonly request data, as a set of rows localized around the current scrolled position. This restriction allows the cache to consume less memory and processor - cycles than QCache. The QContiguousCache class also can provide - an upper bound on memory usage via setCapacity(). + cycles than QCache. + + QContiguousCache operates on a fixed capacity, set with setCapacity() or + passed as a parameter to the constructor. This capacity is the upper bound + on memory usage by the cache itself, not including the memory allocated by + the elements themselves. Note that a cache with a capacity of zero (the + default) means no items will be stored: the insert(), append() and + prepend() operations will effectively be no-ops. Therefore, it's important + to set the capacity to a reasonable value before adding items to the cache. The simplest way of using a contiguous cache is to use the append() and prepend(). diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 8713a3407a..e1cc65f10a 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -341,6 +341,8 @@ void QContiguousCache::freeData(Data *x) template void QContiguousCache::append(const T &value) { + if (!d->alloc) + return; // zero capacity detach(); if (QTypeInfo::isComplex) { if (d->count == d->alloc) @@ -362,6 +364,8 @@ void QContiguousCache::append(const T &value) template void QContiguousCache::prepend(const T &value) { + if (!d->alloc) + return; // zero capacity detach(); if (d->start) d->start--; @@ -385,6 +389,8 @@ template void QContiguousCache::insert(int pos, const T &value) { Q_ASSERT_X(pos >= 0 && pos < INT_MAX, "QContiguousCache::insert", "index out of range"); + if (!d->alloc) + return; // zero capacity detach(); if (containsIndex(pos)) { if (QTypeInfo::isComplex) { diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index d6e8b87383..f813a687cd 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -67,6 +67,7 @@ private slots: void setCapacity(); void zeroCapacity(); + void modifyZeroCapacityCache(); }; QTEST_MAIN(tst_QContiguousCache) @@ -365,4 +366,24 @@ void tst_QContiguousCache::zeroCapacity() QCOMPARE(contiguousCache.capacity(),0); } +void tst_QContiguousCache::modifyZeroCapacityCache() +{ + { + QContiguousCache contiguousCache; + contiguousCache.insert(0, 42); + } + { + QContiguousCache contiguousCache; + contiguousCache.insert(1, 42); + } + { + QContiguousCache contiguousCache; + contiguousCache.append(42); + } + { + QContiguousCache contiguousCache; + contiguousCache.prepend(42); + } +} + #include "tst_qcontiguouscache.moc" From 734324c37cb9d8417aa86f76fc81dadc21be2156 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Oct 2012 15:55:45 +0200 Subject: [PATCH 114/114] QStyleSheetStyle: QObject-based style & render rules The goal is to cut as many QWidget dependencies as possible and make stylesheets eventually work for the desktop components. Change-Id: Ib4aa47af07379fc39fd6df1961e113d03df6df35 Reviewed-by: J-P Nurmi Reviewed-by: Olivier Goffart --- src/widgets/styles/qstylesheetstyle.cpp | 178 ++++++++++++------------ src/widgets/styles/qstylesheetstyle_p.h | 20 +-- 2 files changed, 101 insertions(+), 97 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index d73d25a1af..857750b466 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -468,7 +468,7 @@ class QRenderRule { public: QRenderRule() : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { } - QRenderRule(const QVector &, const QWidget *); + QRenderRule(const QVector &, const QObject *); ~QRenderRule() { } QRect borderRect(const QRect &r) const; @@ -859,7 +859,7 @@ static QStyle::StandardPixmap subControlIcon(int pe) return QStyle::SP_CustomBase; } -QRenderRule::QRenderRule(const QVector &declarations, const QWidget *widget) +QRenderRule::QRenderRule(const QVector &declarations, const QObject *object) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { QPalette palette = QApplication::palette(); // ###: ideally widget's palette @@ -928,7 +928,7 @@ QRenderRule::QRenderRule(const QVector &declarations, const QWidget hasFont = v.extractFont(&font, &adj); #ifndef QT_NO_TOOLTIP - if (widget && qstrcmp(widget->metaObject()->className(), "QTipLabel") == 0) + if (object && qstrcmp(object->metaObject()->className(), "QTipLabel") == 0) palette = QToolTip::palette(); #endif @@ -997,12 +997,15 @@ QRenderRule::QRenderRule(const QVector &declarations, const QWidget } } - if (widget) { + if (object) { QStyleSheetStyle *style = const_cast(globalStyleSheetStyle); - if (!style) - style = qobject_cast(widget->style()); - if (style) - fixupBorder(style->nativeFrameWidth(widget)); + if (!style) { + if (const QWidget *widget = qobject_cast(object)) { + style = qobject_cast(widget->style()); + if (style) + fixupBorder(style->nativeFrameWidth(widget)); + } + } } if (hasBorder() && border()->hasBorderImage()) @@ -1407,14 +1410,14 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q // Style rules #define WIDGET(x) (static_cast(x.ptr)) -static inline QWidget *parentWidget(const QWidget *w) +static inline QObject *parentObject(const QObject *obj) { - if(qobject_cast(w) && qstrcmp(w->metaObject()->className(), "QTipLabel") == 0) { - QWidget *p = qvariant_cast(w->property("_q_stylesheet_parent")); + if (qobject_cast(obj) && qstrcmp(obj->metaObject()->className(), "QTipLabel") == 0) { + QObject *p = qvariant_cast(obj->property("_q_stylesheet_parent")); if (p) return p; } - return w->parentWidget(); + return obj->parent(); } class QStyleSheetStyleSelector : public StyleSelector @@ -1503,7 +1506,7 @@ public: bool isNullNode(NodePtr node) const { return node.ptr == 0; } NodePtr parentNode(NodePtr node) const - { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentWidget(WIDGET(node)); return n; } + { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentObject(WIDGET(node)); return n; } NodePtr previousSiblingNode(NodePtr) const { NodePtr n; n.ptr = 0; return n; } NodePtr duplicateNode(NodePtr node) const @@ -1515,13 +1518,13 @@ private: mutable QHash > m_attributeCache; }; -QVector QStyleSheetStyle::styleRules(const QWidget *w) const +QVector QStyleSheetStyle::styleRules(const QObject *obj) const { - QHash >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(w); + QHash >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(obj); if (cacheIt != styleSheetCaches->styleRulesCache.constEnd()) return cacheIt.value(); - if (!initWidget(w)) { + if (!initObject(obj)) { return QVector(); } @@ -1558,36 +1561,37 @@ QVector QStyleSheetStyle::styleRules(const QWidget *w) const styleSelector.styleSheets += appSs; } - QVector widgetSs; - for (const QWidget *wid = w; wid; wid = parentWidget(wid)) { - if (wid->styleSheet().isEmpty()) + QVector objectSs; + for (const QObject *o = obj; o; o = parentObject(o)) { + QString styleSheet = o->property("styleSheet").toString(); + if (styleSheet.isEmpty()) continue; StyleSheet ss; - QHash::const_iterator widCacheIt = styleSheetCaches->styleSheetCache.constFind(wid); - if (widCacheIt == styleSheetCaches->styleSheetCache.constEnd()) { - parser.init(wid->styleSheet()); + QHash::const_iterator objCacheIt = styleSheetCaches->styleSheetCache.constFind(o); + if (objCacheIt == styleSheetCaches->styleSheetCache.constEnd()) { + parser.init(styleSheet); if (!parser.parse(&ss)) { - parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1Char('}')); + parser.init(QLatin1String("* {") + styleSheet + QLatin1Char('}')); if (!parser.parse(&ss)) - qWarning("Could not parse stylesheet of widget %p", wid); + qWarning("Could not parse stylesheet of object %p", o); } ss.origin = StyleSheetOrigin_Inline; - styleSheetCaches->styleSheetCache.insert(wid, ss); + styleSheetCaches->styleSheetCache.insert(o, ss); } else { - ss = widCacheIt.value(); + ss = objCacheIt.value(); } - widgetSs.append(ss); + objectSs.append(ss); } - for (int i = 0; i < widgetSs.count(); i++) - widgetSs[i].depth = widgetSs.count() - i + 2; + for (int i = 0; i < objectSs.count(); i++) + objectSs[i].depth = objectSs.count() - i + 2; - styleSelector.styleSheets += widgetSs; + styleSelector.styleSheets += objectSs; StyleSelector::NodePtr n; - n.ptr = (void *)w; + n.ptr = (void *)obj; QVector rules = styleSelector.styleRulesForNode(n); - styleSheetCaches->styleRulesCache.insert(w, rules); + styleSheetCaches->styleRulesCache.insert(obj, rules); return rules; } @@ -1696,36 +1700,36 @@ static quint64 pseudoClass(QStyle::State state) return pc; } -static void qt_check_if_internal_widget(const QWidget **w, int *element) +static void qt_check_if_internal_object(const QObject **obj, int *element) { #ifdef QT_NO_DOCKWIDGET - Q_UNUSED(w); + Q_UNUSED(obj); Q_UNUSED(element); #else - if (*w && qstrcmp((*w)->metaObject()->className(), "QDockWidgetTitleButton") == 0) { - if ((*w)->objectName() == QLatin1String("qt_dockwidget_closebutton")) { + if (*obj && qstrcmp((*obj)->metaObject()->className(), "QDockWidgetTitleButton") == 0) { + if ((*obj)->objectName() == QLatin1String("qt_dockwidget_closebutton")) { *element = PseudoElement_DockWidgetCloseButton; - } else if ((*w)->objectName() == QLatin1String("qt_dockwidget_floatbutton")) { + } else if ((*obj)->objectName() == QLatin1String("qt_dockwidget_floatbutton")) { *element = PseudoElement_DockWidgetFloatButton; } - *w = (*w)->parentWidget(); + *obj = (*obj)->parent(); } #endif } -QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, int element, quint64 state) const +QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint64 state) const { - qt_check_if_internal_widget(&w, &element); - QHash &cache = styleSheetCaches->renderRulesCache[w][element]; + qt_check_if_internal_object(&obj, &element); + QHash &cache = styleSheetCaches->renderRulesCache[obj][element]; QHash::const_iterator cacheIt = cache.constFind(state); if (cacheIt != cache.constEnd()) return cacheIt.value(); - if (!initWidget(w)) + if (!initObject(obj)) return QRenderRule(); quint64 stateMask = 0; - const QVector rules = styleRules(w); + const QVector rules = styleRules(obj); for (int i = 0; i < rules.count(); i++) { const Selector& selector = rules.at(i).selectors.at(0); quint64 negated = 0; @@ -1743,14 +1747,14 @@ QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, int element, quint64 const QString part = QLatin1String(knownPseudoElements[element].name); QVector decls = declarations(rules, part, state); - QRenderRule newRule(decls, w); + QRenderRule newRule(decls, obj); cache[state] = newRule; if ((state & stateMask) != state) cache[state&stateMask] = newRule; return newRule; } -QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *opt, int pseudoElement) const +QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption *opt, int pseudoElement) const { quint64 extraClass = 0; QStyle::State state = opt ? opt->state : QStyle::State(QStyle::State_None); @@ -2006,7 +2010,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *o #endif #ifndef QT_NO_LINEEDIT // LineEdit sets Sunken flag to indicate Sunken frame (argh) - if (const QLineEdit *lineEdit = qobject_cast(w)) { + if (const QLineEdit *lineEdit = qobject_cast(obj)) { state &= ~QStyle::State_Sunken; if (lineEdit->hasFrame()) { extraClass &= ~PseudoClass_Frameless; @@ -2015,29 +2019,29 @@ QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *o } } else #endif - if (const QFrame *frm = qobject_cast(w)) { + if (const QFrame *frm = qobject_cast(obj)) { if (frm->lineWidth() == 0) extraClass |= PseudoClass_Frameless; } } - return renderRule(w, pseudoElement, pseudoClass(state) | extraClass); + return renderRule(obj, pseudoElement, pseudoClass(state) | extraClass); } -bool QStyleSheetStyle::hasStyleRule(const QWidget *w, int part) const +bool QStyleSheetStyle::hasStyleRule(const QObject *obj, int part) const { - QHash &cache = styleSheetCaches->hasStyleRuleCache[w]; + QHash &cache = styleSheetCaches->hasStyleRuleCache[obj]; QHash::const_iterator cacheIt = cache.constFind(part); if (cacheIt != cache.constEnd()) return cacheIt.value(); - if (!initWidget(w)) + if (!initObject(obj)) return false; - const QVector &rules = styleRules(w); + const QVector &rules = styleRules(obj); if (part == PseudoElement_None) { - bool result = w && !rules.isEmpty(); + bool result = obj && !rules.isEmpty(); cache[part] = result; return result; } @@ -2594,25 +2598,24 @@ void QStyleSheetStyle::unsetPalette(QWidget *w) } } -static void updateWidgets(const QList& widgets) +static void updateObjects(const QList& objects) { if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) { - for (int i = 0; i < widgets.size(); ++i) { - const QWidget *widget = widgets.at(i); - styleSheetCaches->styleRulesCache.remove(widget); - styleSheetCaches->hasStyleRuleCache.remove(widget); - styleSheetCaches->renderRulesCache.remove(widget); + for (int i = 0; i < objects.size(); ++i) { + const QObject *object = objects.at(i); + styleSheetCaches->styleRulesCache.remove(object); + styleSheetCaches->hasStyleRuleCache.remove(object); + styleSheetCaches->renderRulesCache.remove(object); } } - for (int i = 0; i < widgets.size(); ++i) { - QWidget *widget = const_cast(widgets.at(i)); - if (widget == 0) + for (int i = 0; i < objects.size(); ++i) { + QObject *object = const_cast(objects.at(i)); + if (object == 0) continue; - widget->style()->polish(widget); + if (QWidget *widget = qobject_cast(object)) + widget->style()->polish(widget); QEvent event(QEvent::StyleChange); - QApplication::sendEvent(widget, &event); - widget->update(); - widget->updateGeometry(); + QApplication::sendEvent(object, &event); } } @@ -2645,13 +2648,13 @@ QStyle *QStyleSheetStyle::baseStyle() const return QApplication::style(); } -void QStyleSheetStyleCaches::widgetDestroyed(QObject *o) +void QStyleSheetStyleCaches::objectDestroyed(QObject *o) { - styleRulesCache.remove((const QWidget *)o); - hasStyleRuleCache.remove((const QWidget *)o); - renderRulesCache.remove((const QWidget *)o); + styleRulesCache.remove(o); + hasStyleRuleCache.remove(o); + renderRulesCache.remove(o); customPaletteWidgets.remove((const QWidget *)o); - styleSheetCache.remove((const QWidget *)o); + styleSheetCache.remove(o); autoFillDisabledWidgets.remove((const QWidget *)o); } @@ -2664,18 +2667,19 @@ void QStyleSheetStyleCaches::styleDestroyed(QObject *o) * Make sure that the cache will be clean by connecting destroyed if needed. * return false if the widget is not stylable; */ -bool QStyleSheetStyle::initWidget(const QWidget *w) const +bool QStyleSheetStyle::initObject(const QObject *obj) const { - if (!w) + if (!obj) return false; - if(w->testAttribute(Qt::WA_StyleSheet)) - return true; + if (const QWidget *w = qobject_cast(obj)) { + if (w->testAttribute(Qt::WA_StyleSheet)) + return true; + if (unstylable(w)) + return false; + const_cast(w)->setAttribute(Qt::WA_StyleSheet, true); + } - if(unstylable(w)) - return false; - - const_cast(w)->setAttribute(Qt::WA_StyleSheet, true); - QObject::connect(w, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(widgetDestroyed(QObject*)), Qt::UniqueConnection); + QObject::connect(obj, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(objectDestroyed(QObject*)), Qt::UniqueConnection); return true; } @@ -2684,7 +2688,7 @@ void QStyleSheetStyle::polish(QWidget *w) baseStyle()->polish(w); RECURSION_GUARD(return) - if (!initWidget(w)) + if (!initObject(w)) return; if (styleSheetCaches->styleRulesCache.contains(w)) { @@ -2776,21 +2780,21 @@ void QStyleSheetStyle::polish(QPalette &pal) void QStyleSheetStyle::repolish(QWidget *w) { - QList children = w->findChildren(QString()); + QList children = w->findChildren(QString()); children.append(w); styleSheetCaches->styleSheetCache.remove(w); - updateWidgets(children); + updateObjects(children); } void QStyleSheetStyle::repolish(QApplication *app) { Q_UNUSED(app); - const QList allWidgets = styleSheetCaches->styleRulesCache.keys(); + const QList allObjects = styleSheetCaches->styleRulesCache.keys(); styleSheetCaches->styleSheetCache.remove(qApp); styleSheetCaches->styleRulesCache.clear(); styleSheetCaches->hasStyleRuleCache.clear(); styleSheetCaches->renderRulesCache.clear(); - updateWidgets(allWidgets); + updateObjects(allObjects); } void QStyleSheetStyle::unpolish(QWidget *w) @@ -5870,9 +5874,9 @@ Qt::Alignment QStyleSheetStyle::resolveAlignment(Qt::LayoutDirection layDir, Qt: // This does not mean that any QTabBar which is a child of QTabWidget will // match, only the one that was created by the QTabWidget initialization // (and hence has the correct object name). -bool QStyleSheetStyle::isNaturalChild(const QWidget *w) +bool QStyleSheetStyle::isNaturalChild(const QObject *obj) { - if (w->objectName().startsWith(QLatin1String("qt_"))) + if (obj->objectName().startsWith(QLatin1String("qt_"))) return true; return false; diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index 93bb4441bb..f42c0e9b20 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -143,8 +143,8 @@ private: friend class QRenderRule; int nativeFrameWidth(const QWidget *); - QRenderRule renderRule(const QWidget *, int, quint64 = 0) const; - QRenderRule renderRule(const QWidget *, const QStyleOption *, int = 0) const; + QRenderRule renderRule(const QObject *, int, quint64 = 0) const; + QRenderRule renderRule(const QObject *, const QStyleOption *, int = 0) const; QSize defaultSize(const QWidget *, QSize, const QRect&, int) const; QRect positionRect(const QWidget *, const QRenderRule&, const QRenderRule&, int, const QRect&, Qt::LayoutDirection) const; @@ -157,16 +157,16 @@ private: void unsetPalette(QWidget *); void setProperties(QWidget *); void setGeometry(QWidget *); - QVector styleRules(const QWidget *w) const; - bool hasStyleRule(const QWidget *w, int part) const; + QVector styleRules(const QObject *obj) const; + bool hasStyleRule(const QObject *obj, int part) const; QHash titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const; QCss::StyleSheet getDefaultStyleSheet() const; static Qt::Alignment resolveAlignment(Qt::LayoutDirection, Qt::Alignment); - static bool isNaturalChild(const QWidget *w); - bool initWidget(const QWidget *w) const; + static bool isNaturalChild(const QObject *obj); + bool initObject(const QObject *obj) const; public: static int numinstances; @@ -179,13 +179,13 @@ class QStyleSheetStyleCaches : public QObject { Q_OBJECT public Q_SLOTS: - void widgetDestroyed(QObject *); + void objectDestroyed(QObject *); void styleDestroyed(QObject *); public: - QHash > styleRulesCache; - QHash > hasStyleRuleCache; + QHash > styleRulesCache; + QHash > hasStyleRuleCache; typedef QHash > QRenderRules; - QHash renderRulesCache; + QHash renderRulesCache; QHash customPaletteWidgets; // widgets whose palette we tampered QHash styleSheetCache; // parsed style sheets QSet autoFillDisabledWidgets;