Changeset 71392 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 20, 2018 11:04:03 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121357
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71388 r71392 626 626 VirtualBox_QT_MOCSRCS.darwin += \ 627 627 src/platform/darwin/UIWindowMenuManager.cpp 628 VirtualBox_QT_MOCSRCS.win += \629 src/extensions/QIFileDialog.cpp630 628 VirtualBox_QT_MOCSRCS.linux += \ 631 629 src/globals/UIDesktopWidgetWatchdog.cpp -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIFileDialog.cpp
r71356 r71392 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 #ifdef VBOX_WITH_PRECOMPILED_HEADERS 19 19 # include <precomp.h> 20 #else 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 22 /* Qt includes: */ 23 # include <QEventLoop> 23 # ifdef VBOX_WS_MAC 24 # include <QEventLoop> 25 # endif 24 26 25 27 /* GUI includes: */ 26 # include " VBoxGlobal.h"28 # include "QIFileDialog.h" 27 29 # include "UIModalWindowManager.h" 28 # include "UIMessageCenter.h"29 # include "QIFileDialog.h"30 31 # ifdef VBOX_WS_WIN32 /* Qt includes */33 # include <QEvent>34 # include <QThread>35 36 /* WinAPI includes */37 # include <iprt/win/shlobj.h>38 # endif /* !VBOX_WS_WIN */39 30 40 31 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 41 32 42 33 43 #ifdef VBOX_WS_WIN 44 45 static QString extractFilter (const QString &aRawFilter) 46 { 47 static const char qt_file_dialog_filter_reg_exp[] = 48 "([a-zA-Z0-9 ]*)\\(([a-zA-Z0-9_.*? +;#\\[\\]]*)\\)$"; 49 50 QString result = aRawFilter; 51 QRegExp r (QString::fromLatin1 (qt_file_dialog_filter_reg_exp)); 52 int index = r.indexIn (result); 53 if (index >= 0) 54 result = r.cap (2); 55 return result.replace (QChar (' '), QChar (';')); 56 } 57 58 /** 59 * Converts QFileDialog filter list to Win32 API filter list. 60 */ 61 static QString winFilter (const QString &aFilter) 62 { 63 QStringList filterLst; 64 65 if (!aFilter.isEmpty()) 66 { 67 int i = aFilter.indexOf (";;", 0); 68 QString sep (";;"); 69 if (i == -1) 70 { 71 if (aFilter.indexOf ("\n", 0) != -1) 72 { 73 sep = "\n"; 74 i = aFilter.indexOf (sep, 0); 75 } 76 } 77 78 filterLst = aFilter.split (sep); 79 } 80 81 QStringList::Iterator it = filterLst.begin(); 82 QString winfilters; 83 for (; it != filterLst.end(); ++ it) 84 { 85 winfilters += *it; 86 winfilters += QChar::Null; 87 winfilters += extractFilter (*it); 88 winfilters += QChar::Null; 89 } 90 winfilters += QChar::Null; 91 return winfilters; 92 } 93 94 /* 95 * Callback function to control the native Win32 API file dialog 96 */ 97 UINT_PTR CALLBACK OFNHookProc (HWND aHdlg, UINT aUiMsg, WPARAM aWParam, LPARAM aLParam) 98 { 99 RT_NOREF(aWParam); 100 if (aUiMsg == WM_NOTIFY) 101 { 102 OFNOTIFY *notif = (OFNOTIFY*) aLParam; 103 if (notif->hdr.code == CDN_TYPECHANGE) 104 { 105 /* locate native dialog controls */ 106 HWND parent = GetParent (aHdlg); 107 HWND button = GetDlgItem (parent, IDOK); 108 HWND textfield = ::GetDlgItem (parent, cmb13); 109 if (textfield == NULL) 110 textfield = ::GetDlgItem (parent, edt1); 111 if (textfield == NULL) 112 return FALSE; 113 HWND selector = ::GetDlgItem (parent, cmb1); 114 115 /* simulate filter change by pressing apply-key */ 116 int size = 256; 117 TCHAR *buffer = (TCHAR*)malloc (size); 118 SendMessage (textfield, WM_GETTEXT, size, (LPARAM)buffer); 119 SendMessage (textfield, WM_SETTEXT, 0, (LPARAM)"\0"); 120 SendMessage (button, BM_CLICK, 0, 0); 121 SendMessage (textfield, WM_SETTEXT, 0, (LPARAM)buffer); 122 free (buffer); 123 124 /* make request for focus moving to filter selector combo-box */ 125 HWND curFocus = GetFocus(); 126 PostMessage (curFocus, WM_KILLFOCUS, (WPARAM)selector, 0); 127 PostMessage (selector, WM_SETFOCUS, (WPARAM)curFocus, 0); 128 WPARAM wParam = MAKEWPARAM (WA_ACTIVE, 0); 129 PostMessage (selector, WM_ACTIVATE, wParam, (LPARAM)curFocus); 130 } 131 } 132 return FALSE; 133 } 134 135 /* 136 * Callback function to control the native Win32 API folders dialog 137 */ 138 static int __stdcall winGetExistDirCallbackProc (HWND hwnd, UINT uMsg, 139 LPARAM lParam, LPARAM lpData) 140 { 141 if (uMsg == BFFM_INITIALIZED && lpData != 0) 142 { 143 QString *initDir = (QString *)(lpData); 144 if (!initDir->isEmpty()) 145 { 146 SendMessage (hwnd, BFFM_SETSELECTION, TRUE, uintptr_t( 147 initDir->isNull() ? 0 : initDir->utf16())); 148 } 149 } 150 else if (uMsg == BFFM_SELCHANGED) 151 { 152 TCHAR path [MAX_PATH]; 153 SHGetPathFromIDList (LPITEMIDLIST (lParam), path); 154 QString tmpStr = QString::fromUtf16 ((ushort*)path); 155 if (!tmpStr.isEmpty()) 156 SendMessage (hwnd, BFFM_ENABLEOK, 1, 1); 157 else 158 SendMessage (hwnd, BFFM_ENABLEOK, 0, 0); 159 SendMessage (hwnd, BFFM_SETSTATUSTEXT, 1, uintptr_t(path)); 160 } 161 return 0; 162 } 163 164 /** 165 * QEvent class to carry Win32 API native dialog's result information 166 */ 167 class OpenNativeDialogEvent : public QEvent 168 { 169 public: 170 171 OpenNativeDialogEvent (const QString &aResult, QEvent::Type aType) 172 : QEvent (aType), mResult (aResult) {} 173 174 const QString& result() { return mResult; } 175 176 private: 177 178 QString mResult; 179 }; 180 181 /** 182 * QObject class reimplementation which is the target for OpenNativeDialogEvent 183 * event. It receives OpenNativeDialogEvent event from another thread, 184 * stores result information and exits the given local event loop. 185 */ 186 class LoopObject : public QObject 187 { 188 Q_OBJECT; 189 190 public: 191 192 LoopObject (QEvent::Type aType, QEventLoop &aLoop) 193 : mType (aType), mLoop (aLoop), mResult (QString::null) {} 194 const QString& result() { return mResult; } 195 196 private: 197 198 bool event (QEvent *aEvent) 199 { 200 if (aEvent->type() == mType) 201 { 202 OpenNativeDialogEvent *ev = (OpenNativeDialogEvent*) aEvent; 203 mResult = ev->result(); 204 mLoop.quit(); 205 return true; 206 } 207 return QObject::event (aEvent); 208 } 209 210 QEvent::Type mType; 211 QEventLoop &mLoop; 212 QString mResult; 213 }; 214 215 #endif /* VBOX_WS_WIN */ 216 217 QIFileDialog::QIFileDialog (QWidget *aParent, Qt::WindowFlags aFlags) 218 : QFileDialog (aParent, aFlags) 219 { 220 } 221 222 /** 223 * Reimplementation of QFileDialog::getExistingDirectory() that removes some 224 * oddities and limitations. 225 * 226 * On Win32, this function makes sure a native dialog is launched in 227 * another thread to avoid dialog visualization errors occurring due to 228 * multi-threaded COM apartment initialization on the main UI thread while 229 * the appropriate native dialog function expects a single-threaded one. 230 * 231 * On all other platforms, this function is equivalent to 232 * QFileDialog::getExistingDirectory(). 233 */ 234 QString QIFileDialog::getExistingDirectory (const QString &aDir, 235 QWidget *aParent, 236 const QString &aCaption, 237 bool aDirOnly, 238 bool aResolveSymlinks) 34 QIFileDialog::QIFileDialog(QWidget *pParent, Qt::WindowFlags enmFlags) 35 : QFileDialog(pParent, enmFlags) 36 { 37 } 38 39 /* static */ 40 QString QIFileDialog::getExistingDirectory(const QString &strDir, 41 QWidget *pParent, 42 const QString &strCaption, 43 bool fDirOnly, 44 bool fResolveSymLinks) 239 45 { 240 46 #ifdef VBOX_WS_MAC 241 47 242 /* After 4.5 exec ignores the Qt::Sheet flag. 243 * See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 244 * We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 245 * which result in showing the native & the Qt dialog at the same time. */ 246 QWidget *pParent = windowManager().realParentWindow(aParent); 247 QFileDialog dlg(pParent); 248 windowManager().registerNewParent(&dlg, pParent); 249 dlg.setWindowTitle(aCaption); 250 dlg.setDirectory(aDir); 251 dlg.setResolveSymlinks(aResolveSymlinks); 252 dlg.setFileMode(aDirOnly ? QFileDialog::DirectoryOnly : QFileDialog::Directory); 48 // WORKAROUND: 49 // After 4.5 exec ignores the Qt::Sheet flag. 50 // See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 51 // We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 52 // which result in showing the native & the Qt dialog at the same time. 53 QWidget *pRealParent = windowManager().realParentWindow(pParent); 54 QFileDialog dlg(pRealParent); 55 windowManager().registerNewParent(&dlg, pRealParent); 56 dlg.setWindowTitle(strCaption); 57 dlg.setDirectory(strDir); 58 dlg.setResolveSymlinks(fResolveSymLinks); 59 dlg.setFileMode(fDirOnly ? QFileDialog::DirectoryOnly : QFileDialog::Directory); 253 60 254 61 QEventLoop eventLoop; … … 260 67 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles().value(0, QString()) : QString(); 261 68 262 #else 69 #else /* !VBOX_WS_MAC */ 263 70 264 71 QFileDialog::Options o; 265 # if defined (VBOX_WS_X11) 266 /** @todo see http://bugs.kde.org/show_bug.cgi?id=210904, make it conditional 267 * when this bug is fixed (xtracker 5167). 268 * Apparently not necessary anymore (xtracker 5748)! */ 269 // if (vboxGlobal().isKWinManaged()) 270 // o |= QFileDialog::DontUseNativeDialog; 271 # endif 272 if (aDirOnly) 72 if (fDirOnly) 273 73 o |= QFileDialog::ShowDirsOnly; 274 if (! aResolveSymlinks)74 if (!fResolveSymLinks) 275 75 o |= QFileDialog::DontResolveSymlinks; 276 return QFileDialog::getExistingDirectory (aParent, aCaption, aDir, o); 277 278 #endif 279 } 280 281 /** 282 * Reimplementation of QFileDialog::getSaveFileName() that removes some 283 * oddities and limitations. 284 * 285 * On Win32, this function makes sure a file filter is applied automatically 286 * right after it is selected from the drop-down list, to conform to common 287 * experience in other applications. Note that currently, @a selectedFilter 288 * is always set to null on return. 289 * 290 * On all other platforms, this function is equivalent to 291 * QFileDialog::getSaveFileName(). 292 */ 293 /* static */ 294 QString QIFileDialog::getSaveFileName (const QString &aStartWith, 295 const QString &aFilters, 296 QWidget *aParent, 297 const QString &aCaption, 298 QString *aSelectedFilter /* = 0 */, 299 bool aResolveSymlinks /* = true */, 300 bool fConfirmOverwrite /* = false */) 76 return QFileDialog::getExistingDirectory(pParent, strCaption, strDir, o); 77 78 #endif /* !VBOX_WS_MAC */ 79 } 80 81 /* static */ 82 QString QIFileDialog::getSaveFileName(const QString &strStartWith, 83 const QString &strFilters, 84 QWidget *pParent, 85 const QString &strCaption, 86 QString *pStrSelectedFilter /* = 0 */, 87 bool fResolveSymLinks /* = true */, 88 bool fConfirmOverwrite /* = false */) 301 89 { 302 90 #ifdef VBOX_WS_MAC 303 91 304 /* After 4.5 exec ignores the Qt::Sheet flag. 305 * See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 306 * We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 307 * which result in showing the native & the Qt dialog at the same time. */ 308 QWidget *pParent = windowManager().realParentWindow(aParent); 309 QFileDialog dlg(pParent); 310 windowManager().registerNewParent(&dlg, pParent); 311 dlg.setWindowTitle(aCaption); 92 // WORKAROUND: 93 // After 4.5 exec ignores the Qt::Sheet flag. 94 // See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 95 // We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 96 // which result in showing the native & the Qt dialog at the same time. 97 QWidget *pRealParent = windowManager().realParentWindow(pParent); 98 QFileDialog dlg(pRealParent); 99 windowManager().registerNewParent(&dlg, pRealParent); 100 dlg.setWindowTitle(strCaption); 312 101 313 102 /* Some predictive algorithm which seems missed in native code. */ 314 QDir dir( aStartWith);103 QDir dir(strStartWith); 315 104 while (!dir.isRoot() && !dir.exists()) 316 105 dir = QDir(QFileInfo(dir.absolutePath()).absolutePath()); … … 318 107 if (!strDirectory.isNull()) 319 108 dlg.setDirectory(strDirectory); 320 if (strDirectory != aStartWith)321 dlg.selectFile(QFileInfo( aStartWith).absoluteFilePath());322 323 dlg.setNameFilter( aFilters);109 if (strDirectory != strStartWith) 110 dlg.selectFile(QFileInfo(strStartWith).absoluteFilePath()); 111 112 dlg.setNameFilter(strFilters); 324 113 dlg.setFileMode(QFileDialog::AnyFile); 325 114 dlg.setAcceptMode(QFileDialog::AcceptSave); 326 if ( aSelectedFilter)327 dlg.selectNameFilter(* aSelectedFilter);328 dlg.setResolveSymlinks( aResolveSymlinks);115 if (pStrSelectedFilter) 116 dlg.selectNameFilter(*pStrSelectedFilter); 117 dlg.setResolveSymlinks(fResolveSymLinks); 329 118 dlg.setConfirmOverwrite(fConfirmOverwrite); 330 119 … … 337 126 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles().value(0, QString()) : QString(); 338 127 339 #else 128 #else /* !VBOX_WS_MAC */ 340 129 341 130 QFileDialog::Options o; 342 # if defined (VBOX_WS_X11) 343 /** @todo see http://bugs.kde.org/show_bug.cgi?id=210904, make it conditional 344 * when this bug is fixed (xtracker 5167) 345 * Apparently not necessary anymore (xtracker 5748)! */ 346 // if (vboxGlobal().isKWinManaged()) 347 // o |= QFileDialog::DontUseNativeDialog; 348 # endif 349 if (!aResolveSymlinks) 131 if (!fResolveSymLinks) 350 132 o |= QFileDialog::DontResolveSymlinks; 351 133 if (!fConfirmOverwrite) 352 134 o |= QFileDialog::DontConfirmOverwrite; 353 return QFileDialog::getSaveFileName (aParent, aCaption, aStartWith, 354 aFilters, aSelectedFilter, o); 355 #endif 356 } 357 358 /** 359 * Reimplementation of QFileDialog::getOpenFileName() that removes some 360 * oddities and limitations. 361 * 362 * On Win32, this function makes sure a file filter is applied automatically 363 * right after it is selected from the drop-down list, to conform to common 364 * experience in other applications. Note that currently, @a selectedFilter 365 * is always set to null on return. 366 * 367 * On all other platforms, this function is equivalent to 368 * QFileDialog::getOpenFileName(). 369 */ 370 /* static */ 371 QString QIFileDialog::getOpenFileName (const QString &aStartWith, 372 const QString &aFilters, 373 QWidget *aParent, 374 const QString &aCaption, 375 QString *aSelectedFilter /* = 0 */, 376 bool aResolveSymlinks /* = true */) 377 { 378 return getOpenFileNames (aStartWith, 379 aFilters, 380 aParent, 381 aCaption, 382 aSelectedFilter, 383 aResolveSymlinks, 384 true /* aSingleFile */).value (0, ""); 385 } 386 387 /** 388 * Reimplementation of QFileDialog::getOpenFileNames() that removes some 389 * oddities and limitations. 390 * 391 * On Win32, this function makes sure a file filter is applied automatically 392 * right after it is selected from the drop-down list, to conform to common 393 * experience in other applications. Note that currently, @a selectedFilter 394 * is always set to null on return. 395 * @todo: implement the multiple file selection on win 396 * @todo: is this extra handling on win still necessary with Qt4? 397 * 398 * On all other platforms, this function is equivalent to 399 * QFileDialog::getOpenFileNames(). 400 */ 401 /* static */ 402 QStringList QIFileDialog::getOpenFileNames (const QString &aStartWith, 403 const QString &aFilters, 404 QWidget *aParent, 405 const QString &aCaption, 406 QString *aSelectedFilter /* = 0 */, 407 bool aResolveSymlinks /* = true */, 408 bool aSingleFile /* = false */) 135 return QFileDialog::getSaveFileName(pParent, strCaption, strStartWith, 136 strFilters, pStrSelectedFilter, o); 137 138 #endif /* !VBOX_WS_MAC */ 139 } 140 141 /* static */ 142 QString QIFileDialog::getOpenFileName(const QString &strStartWith, 143 const QString &strFilters, 144 QWidget *pParent, 145 const QString &strCaption, 146 QString *pStrSelectedFilter /* = 0 */, 147 bool fResolveSymLinks /* = true */) 148 { 149 return getOpenFileNames(strStartWith, 150 strFilters, 151 pParent, 152 strCaption, 153 pStrSelectedFilter, 154 fResolveSymLinks, 155 true /* fSingleFile */).value(0, ""); 156 } 157 158 /* static */ 159 QStringList QIFileDialog::getOpenFileNames(const QString &strStartWith, 160 const QString &strFilters, 161 QWidget *pParent, 162 const QString &strCaption, 163 QString *pStrSelectedFilter /* = 0 */, 164 bool fResolveSymLinks /* = true */, 165 bool fSingleFile /* = false */) 409 166 { 410 167 #ifdef VBOX_WS_MAC 411 168 412 /* After 4.5 exec ignores the Qt::Sheet flag. 413 * See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 414 * We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 415 * which result in showing the native & the Qt dialog at the same time. */ 416 QWidget *pParent = windowManager().realParentWindow(aParent); 417 QFileDialog dlg(pParent); 418 windowManager().registerNewParent(&dlg, pParent); 419 dlg.setWindowTitle(aCaption); 169 // WORKAROUND: 170 // After 4.5 exec ignores the Qt::Sheet flag. 171 // See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 172 // We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 173 // which result in showing the native & the Qt dialog at the same time. 174 QWidget *pRealParent = windowManager().realParentWindow(pParent); 175 QFileDialog dlg(pRealParent); 176 windowManager().registerNewParent(&dlg, pRealParent); 177 dlg.setWindowTitle(strCaption); 420 178 421 179 /* Some predictive algorithm which seems missed in native code. */ 422 QDir dir( aStartWith);180 QDir dir(strStartWith); 423 181 while (!dir.isRoot() && !dir.exists()) 424 182 dir = QDir(QFileInfo(dir.absolutePath()).absolutePath()); … … 426 184 if (!strDirectory.isNull()) 427 185 dlg.setDirectory(strDirectory); 428 if (strDirectory != aStartWith)429 dlg.selectFile(QFileInfo( aStartWith).absoluteFilePath());430 431 dlg.setNameFilter( aFilters);432 if ( aSingleFile)186 if (strDirectory != strStartWith) 187 dlg.selectFile(QFileInfo(strStartWith).absoluteFilePath()); 188 189 dlg.setNameFilter(strFilters); 190 if (fSingleFile) 433 191 dlg.setFileMode(QFileDialog::ExistingFile); 434 192 else 435 193 dlg.setFileMode(QFileDialog::ExistingFiles); 436 if ( aSelectedFilter)437 dlg.selectNameFilter(* aSelectedFilter);438 dlg.setResolveSymlinks( aResolveSymlinks);194 if (pStrSelectedFilter) 195 dlg.selectNameFilter(*pStrSelectedFilter); 196 dlg.setResolveSymlinks(fResolveSymLinks); 439 197 440 198 QEventLoop eventLoop; … … 449 207 450 208 QFileDialog::Options o; 451 if (! aResolveSymlinks)209 if (!fResolveSymLinks) 452 210 o |= QFileDialog::DontResolveSymlinks; 453 # if defined (VBOX_WS_X11) 454 /** @todo see http://bugs.kde.org/show_bug.cgi?id=210904, make it conditional 455 * when this bug is fixed (xtracker 5167) 456 * Apparently not necessary anymore (xtracker 5748)! */ 457 // if (vboxGlobal().isKWinManaged()) 458 // o |= QFileDialog::DontUseNativeDialog; 459 # endif 460 461 if (aSingleFile) 462 return QStringList() << QFileDialog::getOpenFileName (aParent, aCaption, aStartWith, 463 aFilters, aSelectedFilter, o); 211 212 if (fSingleFile) 213 return QStringList() << QFileDialog::getOpenFileName(pParent, strCaption, strStartWith, 214 strFilters, pStrSelectedFilter, o); 464 215 else 465 return QFileDialog::getOpenFileNames (aParent, aCaption, aStartWith, 466 aFilters, aSelectedFilter, o); 216 return QFileDialog::getOpenFileNames(pParent, strCaption, strStartWith, 217 strFilters, pStrSelectedFilter, o); 218 467 219 #endif 468 220 } 469 221 470 /** 471 * Search for the first directory that exists starting from the passed one 472 * and going up through its parents. In case if none of the directories 473 * exist (except the root one), the function returns QString::null. 474 */ 475 /* static */ 476 QString QIFileDialog::getFirstExistingDir (const QString &aStartDir) 477 { 478 QString result = QString::null; 479 QDir dir (aStartDir); 222 /* static */ 223 QString QIFileDialog::getFirstExistingDir(const QString &strStartDir) 224 { 225 QString strResult = QString(); 226 QDir dir(strStartDir); 480 227 while (!dir.exists() && !dir.isRoot()) 481 228 { 482 QFileInfo dirInfo 229 QFileInfo dirInfo(dir.absolutePath()); 483 230 if (dir == QDir(dirInfo.absolutePath())) 484 231 break; … … 486 233 } 487 234 if (dir.exists() && !dir.isRoot()) 488 result = dir.absolutePath(); 489 return result; 490 } 491 492 #if defined VBOX_WS_WIN 493 #include "QIFileDialog.moc" 494 #endif 495 235 strResult = dir.absolutePath(); 236 return strResult; 237 } 238 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIFileDialog.h
r71027 r71392 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ QIFileDialog_h__19 #define __ QIFileDialog_h__18 #ifndef ___QIFileDialog_h___ 19 #define ___QIFileDialog_h___ 20 20 21 /* Qt includes */21 /* Qt includes: */ 22 22 #include <QFileDialog> 23 23 24 /** QFileDialog subclass simplifying access to it's static stuff. */ 24 25 class QIFileDialog : public QFileDialog 25 26 { 26 27 Q_OBJECT; 27 28 29 /** Constructs our own file-dialog passing @a pParent and enmFlags to the base-class. 30 * Doesn't mean to be used directly, cause this subclass is a bunch of statics. */ 31 QIFileDialog(QWidget *pParent, Qt::WindowFlags enmFlags); 32 28 33 public: 29 34 30 QIFileDialog (QWidget *aParent, Qt::WindowFlags aFlags); 35 /** Returns an existing directory selected by the user. 36 * @param strDir Brings the dir to start from. 37 * @param pParent Brings the parent. 38 * @param strCaption Brings the dialog caption. 39 * @param fDirOnly Brings whether dialog should show dirs only. 40 * @param fResolveSymLinks Brings whether dialog should resolve sym-links. */ 41 static QString getExistingDirectory(const QString &strDir, QWidget *pParent, 42 const QString &strCaption = QString(), 43 bool fDirOnly = true, 44 bool fResolveSymLinks = true); 31 45 32 static QString getExistingDirectory (const QString &aDir, QWidget *aParent, 33 const QString &aCaption = QString::null, 34 bool aDirOnly = true, 35 bool resolveSymlinks = true); 46 /** Returns a file name selected by the user. The file does not have to exist. 47 * @param strStartWith Brings the full file path to start from. 48 * @param strFilters Brings the filters. 49 * @param pParent Brings the parent. 50 * @param strCaption Brings the dialog caption. 51 * @param pStrSelectedFilter Brings the selected filter. 52 * @param fResolveSymLinks Brings whether dialog should resolve sym-links. 53 * @param fConfirmOverwrite Brings whether dialog should confirm overwrite. */ 54 static QString getSaveFileName(const QString &strStartWith, const QString &strFilters, QWidget *pParent, 55 const QString &strCaption, QString *pStrSelectedFilter = 0, 56 bool fResolveSymLinks = true, bool fConfirmOverwrite = false); 36 57 37 static QString getSaveFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent, 38 const QString &aCaption, QString *aSelectedFilter = 0, 39 bool aResolveSymLinks = true, bool fConfirmOverwrite = false); 58 /** Returns an existing file selected by the user. If the user presses Cancel, it returns a null string. 59 * @param strStartWith Brings the full file path to start from. 60 * @param strFilters Brings the filters. 61 * @param pParent Brings the parent. 62 * @param strCaption Brings the dialog caption. 63 * @param pStrSelectedFilter Brings the selected filter. 64 * @param fResolveSymLinks Brings whether dialog should resolve sym-links. */ 65 static QString getOpenFileName(const QString &strStartWith, const QString &strFilters, QWidget *pParent, 66 const QString &strCaption, QString *pStrSelectedFilter = 0, 67 bool fResolveSymLinks = true); 40 68 41 static QString getOpenFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent, 42 const QString &aCaption, QString *aSelectedFilter = 0, 43 bool aResolveSymLinks = true); 69 /** Returns one or more existing files selected by the user. 70 * @param strStartWith Brings the full file path to start from. 71 * @param strFilters Brings the filters. 72 * @param pParent Brings the parent. 73 * @param strCaption Brings the dialog caption. 74 * @param pStrSelectedFilter Brings the selected filter. 75 * @param fResolveSymLinks Brings whether dialog should resolve sym-links. 76 * @param fSingleFile Brings whether dialog should allow chosing single file only. */ 77 static QStringList getOpenFileNames(const QString &strStartWith, const QString &strFilters, QWidget *pParent, 78 const QString &strCaption, QString *pStrSelectedFilter = 0, 79 bool fResolveSymLinks = true, 80 bool fSingleFile = false); 44 81 45 static QStringList getOpenFileNames (const QString &aStartWith, const QString &aFilters, QWidget *aParent, 46 const QString &aCaption, QString *aSelectedFilter = 0, 47 bool aResolveSymLinks = true, 48 bool aSingleFile = false); 49 50 static QString getFirstExistingDir (const QString &aStartDir); 82 /** Search for the first directory that exists starting from the 83 * passed one @a strStartDir and going up through its parents. */ 84 static QString getFirstExistingDir(const QString &strStartDir); 51 85 }; 52 86 53 #endif /* __QIFileDialog_h__ */87 #endif /* !___QIFileDialog_h___ */ 54 88
Note:
See TracChangeset
for help on using the changeset viewer.