VirtualBox

Ignore:
Timestamp:
Apr 2, 2007 2:55:09 PM (18 years ago)
Author:
vboxsync
Message:

1902: "Select Directory" dialogs are not native:

Own Win32 API native folders list dialog implemented. Dialog implemented as designed in parallel thread to avoid errors caused by COM initialization.
Change get-existing-directory to native in three places:

  1. Machine & VDI default location selection in Global Settings.
  2. Default snapshot location selection in VM Settings.
  3. Shared folder selection.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h

    r1062 r1863  
    188188                 this, SLOT (validate()));
    189189        connect (tbPath, SIGNAL (clicked()), this, SLOT (showFileDialog()));
     190        connect (&vboxGlobal(), SIGNAL (existingDirectoryResult (const QString&)),
     191                 this, SLOT (folderSelected (const QString&)));
    190192        QWhatsThis::add (mLePath, tr ("Enter existing path for the shared folder here"));
    191193        QWhatsThis::add (mLeName, tr ("Enter name for the shared folder to be created"));
     
    231233    void showFileDialog()
    232234    {
    233         QFileDialog dlg (QDir::rootDirPath(), QString::null, this);
    234         dlg.setMode (QFileDialog::DirectoryOnly);
    235         dlg.setCaption (tr ("Select a folder to share"));
    236         if (dlg.exec() == QDialog::Accepted)
    237         {
    238             QString folderName = QDir::convertSeparators (dlg.selectedFile());
    239             QRegExp commonRule ("[\\\\/]([^\\\\^/]+)[\\\\/]?$");
    240             QRegExp rootRule ("(([a-zA-Z])[^\\\\^/])?[\\\\/]$");
    241             if (commonRule.search (folderName) != -1)
    242             {
    243                 /* processing non-root folder */
    244                 mLePath->setText (folderName.remove (QRegExp ("[\\\\/]$")));
    245                 mLeName->setText (commonRule.cap (1));
    246             }
    247             else if (rootRule.search (folderName) != -1)
    248             {
    249                 /* processing root folder */
    250                 mLePath->setText (folderName);
     235        vboxGlobal().getExistingDirectory (QDir::convertSeparators (
     236                                           QDir::rootDirPath()),
     237                                           this, "addSharedFolderDialog",
     238                                           tr ("Select a folder to share"));
     239    }
     240
     241    void folderSelected (const QString &aFolder)
     242    {
     243        if (aFolder.isNull())
     244            return;
     245
     246        QString folderName = QDir::convertSeparators (aFolder);
     247        QRegExp commonRule ("[\\\\/]([^\\\\^/]+)[\\\\/]?$");
     248        QRegExp rootRule ("(([a-zA-Z])[^\\\\^/])?[\\\\/]$");
     249        if (commonRule.search (folderName) != -1)
     250        {
     251            /* processing non-root folder */
     252            mLePath->setText (folderName.remove (QRegExp ("[\\\\/]$")));
     253            mLeName->setText (commonRule.cap (1));
     254        }
     255        else if (rootRule.search (folderName) != -1)
     256        {
     257            /* processing root folder */
     258            mLePath->setText (folderName);
    251259#if defined(Q_WS_WIN32)
    252                 mLeName->setText (rootRule.cap (2) + "_DRIVE");
     260            mLeName->setText (rootRule.cap (2) + "_DRIVE");
    253261#elif defined(Q_WS_X11)
    254                 mLeName->setText ("ROOT");
     262            mLeName->setText ("ROOT");
    255263#endif
    256             }
    257             else
    258                 return; /* hm, what type of folder it was? */
    259         }
     264        }
     265        else
     266            return; /* hm, what type of folder it was? */
    260267    }
    261268
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette