VirtualBox

Ignore:
Timestamp:
Jun 15, 2023 2:57:14 PM (20 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080. Adding an action for importing ISOs to VISO content. Not complete.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r100156 r100180  
    24002400        setShortcutScope(QApplication::translate("UIActionPool", "VISO Creator"));
    24012401        setStatusTip(QApplication::translate("UIActionPool", "Remove selected item(s) from VISO"));
    2402         setToolTip(QApplication::translate("UIActionPool", "Remove Item(s) from VISO")
     2402        setToolTip(QApplication::translate("UIActionPool", "Remove Selected Item(s) from VISO")
    24032403                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    24042404    }
     
    24702470        setShortcutScope(QApplication::translate("UIActionPool", "VISO Creator"));
    24712471        setStatusTip(QApplication::translate("UIActionPool", "Rename the selected object"));
    2472         setToolTip(QApplication::translate("UIActionPool", "Rename Object")
     2472        setToolTip(QApplication::translate("UIActionPool", "Rename Selected VISO File Object")
    24732473                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    24742474    }
     
    25152515    UIActionMenuVISOCreatorOpen(UIActionPool *pParent)
    25162516        : UIActionSimple(pParent,
    2517                          ":/cd_remove_16px.png", ":/cd_16px.png")
     2517                         ":/cd_remove_16px.png", ":/cd_remove_32px.png")
    25182518    {
    25192519        setShortcutContext(Qt::WidgetWithChildrenShortcut);
     
    25352535        setStatusTip(QApplication::translate("UIActionPool", "Open the VISO content."));
    25362536        setToolTip(QApplication::translate("UIActionPool", "Open the VISO content.")
     2537                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
     2538    }
     2539};
     2540
     2541
     2542class UIActionMenuVISOCreatorImportISO : public UIActionSimple
     2543{
     2544    Q_OBJECT;
     2545
     2546public:
     2547    /** Constructs action passing @a pParent to the base-class. */
     2548    UIActionMenuVISOCreatorImportISO(UIActionPool *pParent)
     2549        : UIActionSimple(pParent,
     2550                         ":/cd_add_16px.png", ":/cd_add_32px.png", ":/cd_add_disabled_16px.png", ":/cd_add_disabled_32px.png")
     2551    {
     2552        setShortcutContext(Qt::WidgetWithChildrenShortcut);
     2553    }
     2554
     2555protected:
     2556
     2557    /** Returns shortcut extra-data ID. */
     2558    virtual QString shortcutExtraDataID() const RT_OVERRIDE
     2559    {
     2560        return QString("ISOImport");
     2561    }
     2562
     2563    /** Handles translation event. */
     2564    virtual void retranslateUi() RT_OVERRIDE
     2565    {
     2566        setName(QApplication::translate("UIActionPool", "ISOImport"));
     2567        setShortcutScope(QApplication::translate("UIActionPool", "VISO Creator"));
     2568        setStatusTip(QApplication::translate("UIActionPool", "Import ISO into the VISO content."));
     2569        setToolTip(QApplication::translate("UIActionPool", "Import Selected ISO(s) into the VISO content.")
    25372570                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    25382571    }
     
    31933226    m_pool[UIActionIndex_M_VISOCreator_Reset] = new UIActionMenuVISOCreatorReset(this);
    31943227    m_pool[UIActionIndex_M_VISOCreator_Open] = new UIActionMenuVISOCreatorOpen(this);
     3228    m_pool[UIActionIndex_M_VISOCreator_ImportISO] = new UIActionMenuVISOCreatorImportISO(this);
    31953229
    31963230    /* Medium Selector actions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r100156 r100180  
    158158    UIActionIndex_M_VISOCreator_Reset,
    159159    UIActionIndex_M_VISOCreator_Open,
     160    UIActionIndex_M_VISOCreator_ImportISO,
    160161
    161162    /* Medium selector actions : */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r100177 r100180  
    266266    , m_pResetAction(0)
    267267    , m_pOpenAction(0)
     268    , m_pImportISOAction(0)
    268269    , m_pMainLayout(0)
    269270    , m_pHostBrowser(0)
     
    393394}
    394395
    395 void UIVisoCreatorWidget::sltHostBrowserTableSelectionChanged(bool fIsSelectionEmpty)
     396void UIVisoCreatorWidget::sltHostBrowserTableSelectionChanged(QStringList pathList)
    396397{
    397398    if (m_pAddAction)
    398         m_pAddAction->setEnabled(!fIsSelectionEmpty);
     399        m_pAddAction->setEnabled(!pathList.isEmpty());
     400    if (m_pImportISOAction)
     401        m_pImportISOAction->setEnabled(!findISOFiles(pathList).isEmpty());
    399402}
    400403
     
    434437    if (!strFileName.isEmpty() && m_pVISOContentBrowser)
    435438        m_pVISOContentBrowser->parseVisoFileContent(strFileName);
     439}
     440
     441void UIVisoCreatorWidget::sltISOImportAction()
     442{
     443    if (!m_pHostBrowser)
     444        return;
     445    // QStringList selectedObjectPaths = m_pHostBrowser->selectedPathList();
     446    // printf("dddd %d\n", findISOFiles(selectedObjectPaths).size());
    436447}
    437448
     
    560571        connect(m_pOpenAction, &QAction::triggered,
    561572                this, &UIVisoCreatorWidget::sltOpenAction);
     573    if (m_pImportISOAction)
     574        connect(m_pImportISOAction, &QAction::triggered,
     575                this, &UIVisoCreatorWidget::sltISOImportAction);
    562576}
    563577
     
    580594        m_pRenameAction->setEnabled(m_pVISOContentBrowser->tableViewHasSelection());
    581595    m_pResetAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_Reset);
     596    m_pOpenAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_Open);
     597    m_pImportISOAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_ImportISO);
     598    if (m_pImportISOAction)
     599        m_pImportISOAction->setEnabled(false);
    582600}
    583601
     
    594612        m_pMainMenu->addAction(m_pActionSettings);
    595613        m_pMainMenu->addSeparator();
     614        if (m_pOpenAction)
     615            m_pMainMenu->addAction(m_pOpenAction);
    596616        if (m_pAddAction)
    597617            m_pMainMenu->addAction(m_pAddAction);
    598         if (m_pOpenAction)
    599             m_pMainMenu->addAction(m_pOpenAction);
     618        if (m_pImportISOAction)
     619            m_pMainMenu->addAction(m_pImportISOAction);
    600620        if (m_pRemoveAction)
    601621            m_pMainMenu->addAction(m_pRemoveAction);
     
    623643        if (m_pAddAction)
    624644            m_pVerticalToolBar->addAction(m_pAddAction);
     645        if (m_pImportISOAction)
     646            m_pVerticalToolBar->addAction(m_pImportISOAction);
    625647        if (m_pRenameAction)
    626648            m_pVerticalToolBar->addAction(m_pRenameAction);
     
    666688            m_pSettingsWidget->setSettings(m_visoOptions);
    667689    }
     690}
     691
     692QStringList UIVisoCreatorWidget::findISOFiles(const QStringList &pathList) const
     693{
     694    QStringList isoList;
     695    foreach (const QString &strPath, pathList)
     696    {
     697        if (QFileInfo(strPath).suffix().compare("iso", Qt::CaseInsensitive) == 0)
     698            isoList << strPath;
     699    }
     700    return isoList;
    668701}
    669702
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r100169 r100180  
    114114    void sltSettingsDialogClosed(bool fAccepted);
    115115    void sltBrowserTreeViewVisibilityChanged(bool fVisible);
    116     void sltHostBrowserTableSelectionChanged(bool fIsSelectionEmpty);
     116    void sltHostBrowserTableSelectionChanged(QStringList pathList);
    117117    void sltContentBrowserTableSelectionChanged(bool fIsSelectionEmpty);
    118118    void sltShowContextMenu(const QWidget *pContextMenuRequester, const QPoint &point);
    119119    void sltOpenAction();
     120    void sltISOImportAction();
    120121
    121122private:
     
    130131    void populateMenuMainToolbar();
    131132
    132      void toggleSettingsWidget(bool fShown);
     133    void toggleSettingsWidget(bool fShown);
     134    QStringList findISOFiles(const QStringList &pathList) const;
    133135    /** @name Main toolbar (and main menu) actions
    134136      * @{ */
     
    144146        QAction              *m_pResetAction;
    145147        QAction              *m_pOpenAction;
     148        QAction              *m_pImportISOAction;
    146149    /** @} */
    147150
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp

    r100169 r100180  
    251251{
    252252    Q_UNUSED(deselected);
    253     emit sigTableSelectionChanged(selected.isEmpty());
     253    Q_UNUSED(selected);
     254    emit sigTableSelectionChanged(selectedPathList());
    254255}
    255256
     
    267268    setTreeCurrentIndex(index);
    268269    m_pTreeView->blockSignals(false);
    269 
    270     /* Check if we still have something selected after table root index change: */
    271     if (m_pTableView && m_pTableView->selectionModel())
    272         emit sigTableSelectionChanged(m_pTableView->selectionModel()->hasSelection());
    273270}
    274271
     
    322319    if (!m_pTableView || !m_pTableModel)
    323320        return;
     321    emit sigAddObjectsToViso(selectedPathList());
     322}
     323
     324QStringList UIVisoHostBrowser::selectedPathList() const
     325{
    324326    QItemSelectionModel *pSelectionModel = m_pTableView->selectionModel();
    325327    if (!pSelectionModel)
    326         return;
     328        return QStringList();
    327329    QModelIndexList selectedIndices = pSelectionModel->selectedRows(0);
    328330    QStringList pathList;
     
    334336        pathList << strPath;
    335337    }
    336     emit sigAddObjectsToViso(pathList);
     338    return pathList;
    337339}
    338340
     
    352354        m_pTableView->setRootIndex(m_pTableModel->index(strCurrentTreePath));
    353355    updateLocationSelectorText(strCurrentTreePath);
     356    m_pTableView->clearSelection();
    354357}
    355358
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h

    r100155 r100180  
    4848
    4949    void sigAddObjectsToViso(QStringList pathList);
    50     void sigTableSelectionChanged(bool fIsSelectionEmpty);
     50    void sigTableSelectionChanged(QStringList pathList);
    5151
    5252public:
     
    5858    void         setCurrentPath(const QString &strPath);
    5959    virtual bool tableViewHasSelection() const final override;
     60    /* The list of path of the selected file objects. */
     61    QStringList selectedPathList() const;
    6062
    6163public slots:
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