VirtualBox

Changeset 91349 in vbox


Ignore:
Timestamp:
Sep 23, 2021 12:01:00 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147016
Message:

FE/Qt: bugref:9083. Checking file overwrite as the file path changes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.cpp

    r90564 r91349  
    110110        m_pSizeLabel->setText(tr("Size:"));
    111111    if (m_pButtonBox)
    112         m_pButtonBox->button(QDialogButtonBox::Ok)->setText("Create");
     112        m_pButtonBox->button(QDialogButtonBox::Ok)->setText("C&reate");
    113113    if (m_pCheckBoxFormat)
    114114        m_pCheckBoxFormat->setText(tr("Format disk as FAT12"));
     
    123123}
    124124
     125void UIFDCreationDialog::sltPathChanged(const QString &strPath)
     126{
     127    bool fIsFileUnique = checkFilePath(strPath);
     128    m_pFilePathSelector->mark(!fIsFileUnique, tr("File already exists"));
     129
     130    if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Ok))
     131        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(fIsFileUnique);
     132}
     133
     134bool UIFDCreationDialog::checkFilePath(const QString &strPath) const
     135{
     136    return !QFileInfo(strPath).exists();
     137}
     138
    125139void UIFDCreationDialog::sltHandleMediumCreated(const CMedium &comMedium)
    126140{
     
    162176
    163177            pLayoutMain->addWidget(m_pFilePathSelector, 0, 1, 1, 3);
     178            connect(m_pFilePathSelector, &UIFilePathSelector::pathChanged,
     179                    this, &UIFDCreationDialog::sltPathChanged);
    164180        }
    165181
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.h

    r90453 r91349  
    6868    /** Handles signal about @a comMedium was created. */
    6969    void sltHandleMediumCreated(const CMedium &comMedium);
     70    void sltPathChanged(const QString &strPath);
    7071
    7172private:
     
    8687    /** Returns default file-path. */
    8788    QString getDefaultFilePath() const;
     89    /** Returns false if the file is already exists. */
     90    bool checkFilePath(const QString &strPath) const;
    8891
    8992    /** Holds the default folder. */
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