VirtualBox

Ignore:
Timestamp:
Apr 2, 2007 2:55:09 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20083
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.
Location:
trunk/src/VBox/Frontends/VirtualBox/ui
Files:
5 edited

Legend:

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

    r879 r1863  
    487487                                <property name="whatsThis" stdset="0">
    488488                                    <string>When checked, the keyboard is automatically
    489 captured every time the VM window is activated. When the keyboard is captured, 
     489captured every time the VM window is activated. When the keyboard is captured,
    490490all keystrokes (including system ones like Alt-Tab) are directed to the VM.</string>
    491491                                </property>
     
    10411041    <variable access="private">bool mUSBFilterListModified;</variable>
    10421042    <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable>
     1043    <variable access="private">QLineEdit *mLastAccessedField;</variable>
    10431044</variables>
    10441045<slots>
     
    10491050    <slot>tbResetFolder_clicked()</slot>
    10501051    <slot>tbSelectFolder_clicked()</slot>
     1052    <slot>folderSelected( const QString &amp; )</slot>
    10511053    <slot>addUSBFilter( const CUSBDeviceFilter &amp;, bool )</slot>
    10521054    <slot>lvUSBFilters_currentChanged( QListViewItem * )</slot>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h

    r1234 r1863  
    148148
    149149    /* General page */
     150
     151    mLastAccessedField = 0;
     152    connect (&vboxGlobal(), SIGNAL (existingDirectoryResult (const QString&)),
     153             this, SLOT (folderSelected (const QString&)));
    150154
    151155/// @todo (dmik) remove
     
    350354        /* disable validators if any */
    351355        pageUSB->setEnabled (false);
    352        
     356
    353357#ifdef Q_OS_WIN32
    354358        /* Show an error message (if there is any).
     
    499503    if (tb == tbSelectVDIFolder) le = leVDIFolder;
    500504    else if (tb == tbSelectMachineFolder) le = leMachineFolder;
     505    mLastAccessedField = le;
    501506    Assert (le);
    502507
    503     QString homeFolder = vboxGlobal().virtualBox().GetHomeFolder();
    504 
    505     QFileDialog dlg (homeFolder, QString::null, this);
    506     dlg.setMode (QFileDialog::DirectoryOnly);
     508    QString initDir = vboxGlobal().virtualBox().GetHomeFolder();
    507509
    508510    if (!le->text().isEmpty())
    509511    {
    510512        /* set the first parent directory that exists as the current */
    511 #if 0 /** @todo fix this linux bustage properly */
    512         QFileInfo fld (QDir (homeFolder), le->text());
    513 #else
    514         const QDir _dir (homeFolder);
     513        const QDir _dir (initDir);
    515514        QFileInfo fld (_dir, le->text());
    516 #endif
    517515        do
    518516        {
     
    523521
    524522        if (fld.exists())
    525             dlg.setDir (fld.absFilePath());
    526     }
    527 
    528     if (dlg.exec() == QDialog::Accepted)
    529     {
    530         QString folder = QDir::convertSeparators (dlg.selectedFile());
    531         /* remove trailing slash */
    532         folder.truncate (folder.length() - 1);
    533 
    534         /*
    535          *  do this instead of le->setText (folder) to cause
    536          *  isModified() return true
    537          */
    538         le->selectAll();
    539         le->insert (folder);
     523            initDir = fld.absFilePath();
     524    }
     525
     526    vboxGlobal().getExistingDirectory (initDir, this);
     527}
     528
     529void VBoxGlobalSettingsDlg::folderSelected (const QString &aFolder)
     530{
     531    if (aFolder.isNull())
     532        return;
     533
     534    QString folder = QDir::convertSeparators (aFolder);
     535    /* remove trailing slash if any */
     536    folder.remove (QRegExp ("[\\\\/]$"));
     537
     538    /*
     539     *  do this instead of le->setText (folder) to cause
     540     *  isModified() return true
     541     */
     542    if (mLastAccessedField)
     543    {
     544        mLastAccessedField->selectAll();
     545        mLastAccessedField->insert (folder);
     546        mLastAccessedField = 0;
    540547    }
    541548}
  • 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
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui

    r1628 r1863  
    26982698    <slot>tbResetSavedStateFolder_clicked()</slot>
    26992699    <slot>tbSelectSavedStateFolder_clicked()</slot>
     2700    <slot>folderSelected( const QString &amp; )</slot>
    27002701    <slot>addUSBFilter( const CUSBDeviceFilter &amp; aFilter, bool isNew )</slot>
    27012702    <slot>lvUSBFilters_currentChanged( QListViewItem * item )</slot>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r1707 r1863  
    18501850        QFileInfo (cmachine.GetSettingsFilePath()).dirPath (true);
    18511851
    1852     QFileDialog dlg (settingsFolder, QString::null, this);
    1853     dlg.setMode (QFileDialog::DirectoryOnly);
    1854 
    18551852    if (!leSnapshotFolder->text().isEmpty())
    18561853    {
    18571854        /* set the first parent directory that exists as the current */
    1858         QDir dir (settingsFolder);
     1855        const QDir dir (settingsFolder);
    18591856        QFileInfo fld (dir, leSnapshotFolder->text());
    18601857        do
     
    18661863
    18671864        if (fld.exists())
    1868             dlg.setDir (fld.absFilePath());
    1869     }
    1870 
    1871     if (dlg.exec() == QDialog::Accepted)
    1872     {
    1873         QString folder = QDir::convertSeparators (dlg.selectedFile());
    1874         /* remove trailing slash */
    1875         folder.truncate (folder.length() - 1);
    1876 
    1877         /*
    1878          *  do this instead of le->setText (folder) to cause
    1879          *  isModified() return true
    1880          */
    1881         leSnapshotFolder->selectAll();
    1882         leSnapshotFolder->insert (folder);
    1883     }
     1865            settingsFolder = fld.absFilePath();
     1866    }
     1867
     1868    vboxGlobal().getExistingDirectory (settingsFolder, this);
     1869}
     1870
     1871void VBoxVMSettingsDlg::folderSelected (const QString &aFolder)
     1872{
     1873    if (aFolder.isNull())
     1874        return;
     1875
     1876    QString folder = QDir::convertSeparators (aFolder);
     1877    /* remove trailing slash if any */
     1878    folder.remove (QRegExp ("[\\\\/]$"));
     1879
     1880    /*
     1881     *  do this instead of le->setText (folder) to cause
     1882     *  isModified() return true
     1883     */
     1884    leSnapshotFolder->selectAll();
     1885    leSnapshotFolder->insert (folder);
    18841886}
    18851887
Note: See TracChangeset for help on using the changeset viewer.

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