VirtualBox

Changeset 100500 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 11, 2023 9:36:58 AM (17 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080. Implementing saveas slot.

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

Legend:

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

    r100497 r100500  
    255255
    256256UIVisoCreatorWidget::UIVisoCreatorWidget(UIActionPool *pActionPool, QWidget *pParent,
    257                                          bool fShowToolBar, const QString& strVisoSavePath, const QString& strMachineName)
     257                                         bool fShowToolBar, const QString& strVisoFilePath, const QString& strMachineName)
    258258    : QIWithRetranslateUI<QWidget>(pParent)
    259259    , m_pActionSettings(0)
     
    275275    , m_pBrowserContainerWidget(0)
    276276    , m_pStackedLayout(0)
    277     , m_strVisoSavePath(strVisoSavePath)
     277    , m_strVisoFilePath(strVisoFilePath)
    278278{
    279279    m_visoOptions.m_strVisoName = !strMachineName.isEmpty() ? strMachineName : "ad-hoc";
     
    301301{
    302302    return m_visoOptions.m_strVisoName;
     303}
     304
     305void UIVisoCreatorWidget::setVisoName(const QString& strName)
     306{
     307    if (m_visoOptions.m_strVisoName == strName)
     308        return;
     309    m_visoOptions.m_strVisoName = strName;
     310    emit sigVisoNameChanged(m_visoOptions.m_strVisoName);
     311}
     312
     313void UIVisoCreatorWidget::setVisoFilePath(const QString& strPath)
     314{
     315    if (m_strVisoFilePath == strPath)
     316        return;
     317    m_strVisoFilePath = strPath;
     318    emit sigVisoFilePathChanged(m_strVisoFilePath);
    303319}
    304320
     
    377393    {
    378394        Settings newSettings = m_pSettingsWidget->settings();
    379         if (m_visoOptions.m_strVisoName != newSettings.m_strVisoName)
    380         {
    381             m_visoOptions.m_strVisoName = newSettings.m_strVisoName;
    382             emit sigVisoNameChanged(m_visoOptions.m_strVisoName);
    383         }
     395        setVisoName(newSettings.m_strVisoName);
    384396        if (m_visoOptions.m_customOptions != newSettings.m_customOptions)
    385397            m_visoOptions.m_customOptions = newSettings.m_customOptions;
     
    420432void UIVisoCreatorWidget::sltSaveAsAction()
    421433{
    422     // QString strSaveFileName = getSaveFileName(visoFileFullPath(), "VISO files (*.viso)", this,
    423     //                                           UIVisoCreatorWidget::tr("Select a file to save Viso content to"));
     434    QString strSaveFileName = QIFileDialog::getSaveFileName(visoFileFullPath(), "VISO files (*.viso)", this,
     435                                                            UIVisoCreatorWidget::tr("Select a file to save Viso content to"));
     436    if (visoFileFullPath() != strSaveFileName)
     437    {
     438        QFileInfo fileInfo(strSaveFileName);
     439        setVisoFilePath(fileInfo.absolutePath());
     440        setVisoName(fileInfo.fileName());
     441    }
    424442}
    425443
     
    695713QString UIVisoCreatorWidget::visoFileFullPath() const
    696714{
    697     return QString("%1/%2%3").arg(m_strVisoSavePath).arg(visoName()).arg(".viso");
     715    return QString("%1/%2%3").arg(m_strVisoFilePath).arg(visoName()).arg(".viso");
    698716}
    699717
     
    703721*********************************************************************************************************************************/
    704722UIVisoCreatorDialog::UIVisoCreatorDialog(UIActionPool *pActionPool, QWidget *pParent,
    705                                          const QString& strVisoSavePath, const QString& strMachineName /* = QString() */)
     723                                         const QString& strVisoFilePath, const QString& strMachineName /* = QString() */)
    706724    : QIWithRetranslateUI<QIWithRestorableGeometry<QIMainDialog> >(pParent)
    707725    , m_pVisoCreatorWidget(0)
     
    713731       we manage escape key here with special casing: */
    714732    setRejectByEscape(false);
    715     prepareWidgets(strVisoSavePath, strMachineName);
    716     prepareConnections();
     733    prepareWidgets(strVisoFilePath, strMachineName);
    717734    loadSettings();
    718735}
     
    759776}
    760777
    761 void UIVisoCreatorDialog::prepareWidgets(const QString& strVisoSavePath, const QString &strMachineName)
     778void UIVisoCreatorDialog::prepareWidgets(const QString& strVisoFilePath, const QString &strMachineName)
    762779{
    763780    QWidget *pCentralWidget = new QWidget;
     
    769786
    770787
    771     m_pVisoCreatorWidget = new UIVisoCreatorWidget(m_pActionPool, this, true /* show toolbar */, strVisoSavePath, strMachineName);
     788    m_pVisoCreatorWidget = new UIVisoCreatorWidget(m_pActionPool, this, true /* show toolbar */, strVisoFilePath, strMachineName);
    772789    AssertPtrReturnVoid(m_pVisoCreatorWidget);
    773790    if (m_pVisoCreatorWidget->menu())
     
    779796        connect(m_pVisoCreatorWidget, &UIVisoCreatorWidget::sigVisoNameChanged,
    780797                this, &UIVisoCreatorDialog::sltVisoNameChanged);
     798        connect(m_pVisoCreatorWidget, &UIVisoCreatorWidget::sigVisoFilePathChanged,
     799                this, &UIVisoCreatorDialog::sltVisoFilePathChanged);
    781800        connect(m_pVisoCreatorWidget, &UIVisoCreatorWidget::sigSettingDialogToggle,
    782801                this, &UIVisoCreatorDialog::sltSettingDialogToggle);
     
    795814    m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);
    796815
     816    connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoCreatorDialog::close);
     817    connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreatorDialog::accept);
     818
     819
    797820    uiCommon().setHelpKeyword(m_pButtonBox->button(QIDialogButtonBox::Help), "create-optical-disk-image");
    798821
    799822    retranslateUi();
    800 }
    801 
    802 void UIVisoCreatorDialog::prepareConnections()
    803 {
    804     if (m_pButtonBox)
    805     {
    806         connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoCreatorDialog::close);
    807         connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreatorDialog::accept);
    808     }
    809823}
    810824
     
    852866{
    853867    Q_UNUSED(strName);
     868    updateWindowTitle();
     869}
     870
     871void UIVisoCreatorDialog::sltVisoFilePathChanged(const QString &strPath)
     872{
     873    Q_UNUSED(strPath);
    854874    updateWindowTitle();
    855875}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r100497 r100500  
    136136    void toggleSettingsWidget(bool fShown);
    137137    QStringList findISOFiles(const QStringList &pathList) const;
     138    void setVisoName(const QString& strName);
     139    void setVisoFilePath(const QString& strPath);
     140
    138141    /** @name Main toolbar (and main menu) actions
    139142      * @{ */
     
    166169    QGraphicsBlurEffect   *m_pOverlayBlurEffect;
    167170    QStackedLayout        *m_pStackedLayout;
    168     QString                m_strVisoSavePath;
     171    QString                m_strVisoFilePath;
    169172};
    170173
     
    203206    void sltSetCancelButtonShortCut(QKeySequence keySequence);
    204207    void sltVisoNameChanged(const QString &strName);
     208    void sltVisoFilePathChanged(const QString &strPath);
    205209    void sltSettingDialogToggle(bool fIsShown);
    206210
    207211private:
    208212    void prepareWidgets(const QString& strVisoSavePath, const QString &strMachineName);
    209     void prepareConnections();
    210213    virtual void retranslateUi() final override;
    211214    void loadSettings();
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