From d0fb8557f3fc3e7c9305662d118228ceca9df72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 13 Nov 2009 17:38:02 +0100 Subject: Character spacing when drawing a QPicture to a high DPI device. Drawing some text into a QPicture, and then drawing that QPicture to e.g. a QPrinter, would make the character spacing all wrong. The old approach that tried to fix this adjusted the DPI of the font that was used, so that the text size would be correct. It seems this is not enough, since it will lay out the text in the default resolution, and then scale that up, which may/may not introduce errors. Task-number: QTBUG-4974, 256481 Reviewed-by: Kim --- src/gui/image/qpicture.cpp | 49 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index f502827..6c5fb02 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -440,36 +440,6 @@ bool QPicture::play(QPainter *painter) return true; // no end-command } - -// -// QFakeDevice is used to create fonts with a custom DPI -// -class QFakeDevice : public QPaintDevice -{ -public: - QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); } - void setDpiX(int dpi) { dpi_x = dpi; } - void setDpiY(int dpi) { dpi_y = dpi; } - QPaintEngine *paintEngine() const { return 0; } - int metric(PaintDeviceMetric m) const - { - switch(m) { - case PdmPhysicalDpiX: - case PdmDpiX: - return dpi_x; - case PdmPhysicalDpiY: - case PdmDpiY: - return dpi_y; - default: - return QPaintDevice::metric(m); - } - } - -private: - int dpi_x; - int dpi_y; -}; - /*! \internal Iterates over the internal picture data and draws the picture using @@ -679,30 +649,29 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) if (d->formatMajor >= 9) { s >> dbl; - QFont fnt(font); - if (dbl != 1.0) { - QFakeDevice fake; - fake.setDpiX(qRound(dbl*qt_defaultDpiX())); - fake.setDpiY(qRound(dbl*qt_defaultDpiY())); - fnt = QFont(font, &fake); - } + QFont fnt(font, painter->device()); + + qreal scale = painter->device()->logicalDpiY() / (dbl*qt_defaultDpiY()); + painter->save(); + painter->scale(1/scale, 1/scale); qreal justificationWidth; s >> justificationWidth; int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight; - QSizeF size(1, 1); + QSizeF size(scale, scale); if (justificationWidth > 0) { - size.setWidth(justificationWidth); + size.setWidth(justificationWidth*scale); flags |= Qt::TextJustificationForced; flags |= Qt::AlignJustify; } QFontMetrics fm(fnt); - QPointF pt(p.x(), p.y() - fm.ascent()); + QPointF pt(p.x()*scale, p.y()*scale - fm.ascent()); qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0, str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + painter->restore(); } else { qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0, str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); -- cgit v0.12 From bba8f557f59d17e68ec0d9707e66c5324bb4bd33 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 16 Dec 2009 10:22:06 +1000 Subject: Remove obsolete code for unsupported platforms This code was apparently put in for OSX10.3. ODBC2 is over 10 years old now, and even microsoft doesn't support any fashion to link to the ansi versions of the functions. Remove the #define so that we don't have to support it any more. Reviewed-by: Justin McPherson --- src/sql/drivers/odbc/qsql_odbc.cpp | 20 -------------------- src/sql/drivers/odbc/qsql_odbc.h | 10 ---------- 2 files changed, 30 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index e686873..445570a 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -62,13 +62,6 @@ QT_BEGIN_NAMESPACE // undefine this to prevent initial check of the ODBC driver #define ODBC_CHECK_DRIVER -#if defined(Q_ODBC_VERSION_2) -//crude hack to get non-unicode capable driver managers to work -# undef UNICODE -# define SQLTCHAR SQLCHAR -# define SQL_C_WCHAR SQL_C_CHAR -#endif - // newer platform SDKs use SQLLEN instead of SQLINTEGER #if defined(WIN32) && (_MSC_VER < 1300) # define QSQLLEN SQLINTEGER @@ -287,13 +280,11 @@ static QVariant::Type qDecodeODBCType(SQLSMALLINT sqltype, const T* p, bool isSi case SQL_TYPE_TIMESTAMP: type = QVariant::DateTime; break; -#ifndef Q_ODBC_VERSION_2 case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: type = QVariant::String; break; -#endif case SQL_CHAR: case SQL_VARCHAR: case SQL_GUID: @@ -566,10 +557,8 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i ) static int qGetODBCVersion(const QString &connOpts) { -#ifndef Q_ODBC_VERSION_2 if (connOpts.contains(QLatin1String("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3"), Qt::CaseInsensitive)) return SQL_OV_ODBC3; -#endif return SQL_OV_ODBC2; } @@ -668,7 +657,6 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) continue; } r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACE, (SQLPOINTER) v, 0); -#ifndef Q_ODBC_VERSION_2 } else if (opt.toUpper() == QLatin1String("SQL_ATTR_CONNECTION_POOLING")) { if (val == QLatin1String("SQL_CP_OFF")) v = SQL_CP_OFF; @@ -695,7 +683,6 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) continue; } r = SQLSetConnectAttr(hDbc, SQL_ATTR_CP_MATCH, (SQLPOINTER)v, 0); -#endif } else if (opt.toUpper() == QLatin1String("SQL_ATTR_ODBC_VERSION")) { // Already handled in QODBCDriver::open() continue; @@ -1416,7 +1403,6 @@ bool QODBCResult::exec() *ind == SQL_NULL_DATA ? ind : NULL); break; case QVariant::String: -#ifndef Q_ODBC_VERSION_2 if (d->unicode) { QString str = val.toString(); str.utf16(); @@ -1453,7 +1439,6 @@ bool QODBCResult::exec() break; } else -#endif { QByteArray str = val.toString().toAscii(); if (*ind != SQL_NULL_DATA) @@ -1854,11 +1839,6 @@ void QODBCDriver::cleanup() // as two byte unicode characters void QODBCDriverPrivate::checkUnicode() { -#if defined(Q_ODBC_VERSION_2) - unicode = false; - return; -#endif - SQLRETURN r; SQLUINTEGER fFunc; diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h index 8bd7660..aa96feb 100644 --- a/src/sql/drivers/odbc/qsql_odbc.h +++ b/src/sql/drivers/odbc/qsql_odbc.h @@ -49,13 +49,6 @@ #include #endif -#if defined (Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3) -// assume we use iodbc on MACX -// comment next line out if you use a -// unicode compatible manager -# define Q_ODBC_VERSION_2 -#endif - #ifdef QT_PLUGIN #define Q_EXPORT_SQLDRIVER_ODBC #else @@ -75,10 +68,7 @@ # undef _MSC_VER #endif -#ifndef Q_ODBC_VERSION_2 #include -#endif - #include QT_BEGIN_HEADER -- cgit v0.12 From 71f7c1d006d0942fb91e795855bd00a35f226385 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 28 Dec 2009 13:58:25 +0100 Subject: QStyleSheetStyle: Fixed some text croped when having padding with native border. The native border width need to be taken into account in QRenderRule::boxRect() Task-number: QTBUG-6855 Reviewed-by: Benjamin Poulain (cherry picked from commit 6e90192b599cee9b903177a0978198326f667613) --- src/gui/styles/qstylesheetstyle.cpp | 2 +- tests/auto/uiloader/baseline/css_qtbug6855.ui | 57 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/auto/uiloader/baseline/css_qtbug6855.ui diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index ca6968b..56cc364 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1065,7 +1065,7 @@ QRect QRenderRule::boxRect(const QRect& cr, int flags) const r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]); } } - if (!hasNativeBorder() && (flags & Border)) { + if (hasBorder() && (flags & Border)) { const int *b = border()->borders; r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]); } diff --git a/tests/auto/uiloader/baseline/css_qtbug6855.ui b/tests/auto/uiloader/baseline/css_qtbug6855.ui new file mode 100644 index 0000000..0727f6b --- /dev/null +++ b/tests/auto/uiloader/baseline/css_qtbug6855.ui @@ -0,0 +1,57 @@ + + + Form + + + + 0 + 0 + 212 + 108 + + + + Form + + + QPushButton { padding: 20px; } + + + + + + Text not cropped + + + + + + + Qt::Horizontal + + + + 258 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 218 + + + + + + + + + -- cgit v0.12 From b4dd6ff29bc921ec81b4fd67ed44830e4d697d1d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 18 Jan 2010 17:27:54 +0100 Subject: Build fix for MSVC2005 and older SDK --- src/gui/dialogs/qfiledialog_win.cpp | 28 ++------------------- src/gui/dialogs/qfiledialog_win_p.h | 49 +++++++++++++++++++++++++++++++++--- src/gui/util/qsystemtrayicon_win.cpp | 1 - 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 6128a8a..c2b6950 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -60,21 +60,6 @@ #ifdef Q_WS_WINCE #include -# ifndef BFFM_SETSELECTION -# define BFFM_SETSELECTION (WM_USER + 102) -# endif -// Windows Mobile has a broken definition for BROWSEINFO -// Only compile fix -typedef struct qt_priv_browseinfo { - HWND hwndOwner; - LPCITEMIDLIST pidlRoot; - LPWSTR pszDisplayName; - LPCWSTR lpszTitle; - UINT ulFlags; - BFFCALLBACK lpfn; - LPARAM lParam; - int iImage; -} qt_BROWSEINFO; bool qt_priv_ptr_valid = false; #else #include "qfiledialog_win_p.h" @@ -457,7 +442,7 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd, // Add the filters to the file dialog. if (numFilters) { wchar_t *szData = (wchar_t*)winfilters.utf16(); - COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[numFilters]; + qt_COMDLG_FILTERSPEC *filterSpec = new qt_COMDLG_FILTERSPEC[numFilters]; for(int i = 0; itestAttribute(Qt::WA_WState_Created)); bi.hwndOwner = (parent ? parent->winId() : 0); @@ -760,7 +736,7 @@ QString qt_win_get_existing_directory(const QFileDialogArgs &args) qt_win_resolve_libs(); if (ptrSHBrowseForFolder) { - LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi); + LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi); if (pItemIDList) { ptrSHGetPathFromIDList(pItemIDList, path); IMalloc *pMalloc; diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index 6d8c7c9..b55d1ff 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include +#include #include -#if !defined(QFILEDIAG_WIN_P_H) && !defined(__shobjidl_h__) +#ifndef QFILEDIAG_WIN_P_H //these are the interface declarations needed for the file dialog on Vista and up @@ -50,6 +50,8 @@ //declarations typedef DWORD SICHINTF; +typedef ULONG SFGAOF; +typedef DWORD SHCONTF; #define FOS_OVERWRITEPROMPT 0x2 #define FOS_STRICTFILETYPES 0x4 #define FOS_NOCHANGEDIR 0x8 @@ -83,6 +85,31 @@ typedef int GETPROPERTYSTOREFLAGS; #define GPS_BESTEFFORT 0x00000040 #define GPS_MASK_VALID 0x0000007F +typedef int (CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); +// message from browser +#define BFFM_INITIALIZED 1 +#define BFFM_SELCHANGED 2 +#define BFFM_ENABLEOK (WM_USER + 101) +#define BFFM_SETSELECTION (WM_USER + 103) +#define BFFM_SETSTATUSTEXT (WM_USER + 104) + +// Browsing for directory. +#define BIF_RETURNONLYFSDIRS 0x0001 +#define BIF_DONTGOBELOWDOMAIN 0x0002 +#define BIF_STATUSTEXT 0x0004 +#define BIF_RETURNFSANCESTORS 0x0008 +#define BIF_EDITBOX 0x0010 +#define BIF_VALIDATE 0x0020 +#define BIF_NEWDIALOGSTYLE 0x0040 +#define BIF_BROWSEINCLUDEURLS 0x0080 +#define BIF_UAHINT 0x0100 +#define BIF_NONEWFOLDERBUTTON 0x0200 +#define BIF_NOTRANSLATETARGETS 0x0400 +#define BIF_BROWSEFORCOMPUTER 0x1000 +#define BIF_BROWSEFORPRINTER 0x2000 +#define BIF_BROWSEINCLUDEFILES 0x4000 +#define BIF_SHAREABLE 0x8000 + //the enums typedef enum { SIATTRIBFLAGS_AND = 0x1, @@ -115,11 +142,25 @@ typedef FDE_SHAREVIOLATION_RESPONSE FDE_OVERWRITE_RESPONSE; typedef struct { LPCWSTR pszName; LPCWSTR pszSpec; -} COMDLG_FILTERSPEC; +} qt_COMDLG_FILTERSPEC; +#ifndef PROPERTYKEY_DEFINED +#define PROPERTYKEY_DEFINED typedef struct { GUID fmtid; DWORD pid; } PROPERTYKEY; +#endif +typedef struct { + HWND hwndOwner; + LPCITEMIDLIST pidlRoot; + LPWSTR pszDisplayName; + LPCWSTR lpszTitle; + UINT ulFlags; + BFFCALLBACK lpfn; + LPARAM lParam; + int iImage; +} BROWSEINFO; + DECLARE_INTERFACE(IFileDialogEvents); DECLARE_INTERFACE_(IShellItem, IUnknown) { @@ -157,7 +198,7 @@ DECLARE_INTERFACE_(IModalWindow, IUnknown) }; DECLARE_INTERFACE_(IFileDialog, IModalWindow) { - STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec) PURE; + STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const qt_COMDLG_FILTERSPEC *rgFilterSpec) PURE; STDMETHOD(SetFileTypeIndex)(THIS_ UINT iFileType) PURE; STDMETHOD(GetFileTypeIndex)(THIS_ UINT *piFileType) PURE; STDMETHOD(Advise)(THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE; diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 474555b..51de62b 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -53,7 +53,6 @@ #include #include -#include #include #include #include -- cgit v0.12 From 5c8c51284b1119f90520b6dbad0ac23fe0487bcf Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 18 Jan 2010 18:22:38 +0100 Subject: build fix for mingw --- src/gui/dialogs/qfiledialog_win_p.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/gui/dialogs/qfiledialog_win_p.h index b55d1ff..ad3bc14 100644 --- a/src/gui/dialogs/qfiledialog_win_p.h +++ b/src/gui/dialogs/qfiledialog_win_p.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #ifndef QFILEDIAG_WIN_P_H @@ -150,6 +149,15 @@ typedef struct { DWORD pid; } PROPERTYKEY; #endif + +typedef struct { + USHORT cb; + BYTE abID[1]; +} SHITEMID, *LPSHITEMID; +typedef struct { + SHITEMID mkid; +} ITEMIDLIST, *LPITEMIDLIST; +typedef const ITEMIDLIST *LPCITEMIDLIST; typedef struct { HWND hwndOwner; LPCITEMIDLIST pidlRoot; -- cgit v0.12