File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 27
27
#include < QClipboard>
28
28
#include < QDrag>
29
29
30
+ #ifdef Q_OS_WIN
31
+ #include < windows.h>
32
+ QString QgsColorButton::fullPath ( const QString &path )
33
+ {
34
+ TCHAR buf[MAX_PATH];
35
+ int len = GetLongPathName ( path.toUtf8 ().constData (), buf, MAX_PATH );
36
+
37
+ if ( len == 0 || len > MAX_PATH )
38
+ {
39
+ QgsDebugMsg ( QString ( " GetLongPathName('%1') failed with %2: %3" )
40
+ .arg ( path ).arg ( len ).arg ( GetLastError () ) );
41
+ return path;
42
+ }
43
+
44
+ QString res = QString::fromUtf8 ( buf );
45
+ return res;
46
+ }
47
+ #endif
48
+
30
49
/* !
31
50
\class QgsColorButton
32
51
@@ -387,11 +406,15 @@ void QgsColorButton::setButtonBackground()
387
406
mTempPNG .close ();
388
407
}
389
408
390
- bkgrd = QString ( " background-image: url(%1);" ).arg ( mTempPNG .fileName () );
409
+ QString bgFileName = mTempPNG .fileName ();
410
+ #ifdef Q_OS_WIN
411
+ // on windows, mTempPNG will use a shortened path for the temporary folder name
412
+ // this does not work with stylesheets, resulting in the whole button disappearing (#10187)
413
+ bgFileName = fullPath ( bgFileName );
414
+ #endif
415
+ bkgrd = QString ( " background-image: url(%1);" ).arg ( bgFileName );
391
416
}
392
417
393
- // QgsDebugMsg( QString( "%1" ).arg( bkgrd ) );
394
-
395
418
// TODO: get OS-style focus color and switch border to that color when button in focus
396
419
setStyleSheet ( QString ( " QgsColorButton{"
397
420
" %1"
Original file line number Diff line number Diff line change @@ -191,6 +191,16 @@ class GUI_EXPORT QgsColorButton: public QPushButton
191
191
*/
192
192
bool colorFromMimeData ( const QMimeData *mimeData, QColor &resultColor );
193
193
194
+ #ifdef Q_OS_WIN
195
+ /* *
196
+ * Expands a shortened Windows path to its full path name.
197
+ * @returns full path name.
198
+ * @param path a (possibly) shortened Windows path
199
+ * @note added in 2.3
200
+ */
201
+ QString fullPath ( const QString &path );
202
+ #endif
203
+
194
204
private slots:
195
205
void onButtonClicked ();
196
206
You can’t perform that action at this time.
0 commit comments