VirtualBox

Changeset 76768 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 11, 2019 10:54:58 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080: It is now possible to pass custom options to viso file thru the viso dialog

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

Legend:

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

    r76739 r76768  
    26542654        QStringList files = pVisoCreator->entryList();
    26552655        QString strVisoName = pVisoCreator->visoName();
     2656
    26562657        if (files.empty() || files[0].isEmpty())
    26572658            return QUuid();
     
    26882689                            break;
    26892690                    }
     2691                    /* Append custom options if any to the file: */
     2692                    const QStringList &customOptions = pVisoCreator->customOptions();
     2693                    foreach (QString strLine, customOptions)
     2694                        RTStrmPrintf(pStrmViso, "%s\n", strLine.toUtf8().constData());
    26902695
    26912696                    RTStrmFlush(pStrmViso);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationDialog.cpp

    r76747 r76768  
    1919#include <QCheckBox>
    2020#include <QGridLayout>
     21#include <QTextEdit>
    2122#include <QPushButton>
    2223#include <QSplitter>
    2324#include <QStyle>
     25#include <QTextBlock>
    2426
    2527/* GUI includes: */
     
    3537    , m_pMainLayout(0)
    3638    , m_pButtonBox(0)
     39    , m_pVisoNameLineEdit(0)
     40    , m_pCustomOptionsTextEdit(0)
    3741    , m_visoOptions(visoOptions)
    3842{
     
    5054}
    5155
    52 void UIVisoConfigurationDialog::sltHandleVisoNameChange(const QString &strText)
     56void UIVisoConfigurationDialog::accept()
    5357{
    54     m_visoOptions.m_strVisoName = strText;
     58    if (m_pVisoNameLineEdit)
     59        m_visoOptions.m_strVisoName = m_pVisoNameLineEdit->text();
     60
     61    if (m_pCustomOptionsTextEdit)
     62    {
     63        QTextDocument *pDocument = m_pCustomOptionsTextEdit->document();
     64        if (pDocument)
     65        {
     66            for(QTextBlock block = pDocument->begin(); block != pDocument->end()/*.isValid()*/; block = block.next())
     67                    m_visoOptions.m_customOptions << block.text();
     68        }
     69    }
     70
     71    QIDialog::accept();
    5572}
    5673
     
    6279        return;
    6380
     81    /* Name edit and and label: */
     82    QILabel *pVisoNameLabel = new QILabel(UIVisoCreator::tr("VISO Name:"));
     83    m_pVisoNameLineEdit = new QILineEdit;
     84    if (pVisoNameLabel && m_pVisoNameLineEdit)
     85    {
     86        m_pVisoNameLineEdit->setText(m_visoOptions.m_strVisoName);
     87        pVisoNameLabel->setBuddy(m_pVisoNameLineEdit);
     88        m_pMainLayout->addWidget(pVisoNameLabel, 0, 0, 1, 1);
     89        m_pMainLayout->addWidget(m_pVisoNameLineEdit, 0, 1, 1, 1);
     90    }
    6491
    65     QILineEdit *pVisoNameLineEdit = new QILineEdit;
    66     connect(pVisoNameLineEdit, &QILineEdit::textChanged,
    67             this, &UIVisoConfigurationDialog::sltHandleVisoNameChange);
    68     pVisoNameLineEdit->setText(m_visoOptions.m_strVisoName);
    69     QILabel *pVisoNameLabel = new QILabel(UIVisoCreator::tr("VISO Name:"));
    70     pVisoNameLabel->setBuddy(pVisoNameLineEdit);
    71 
    72     m_pMainLayout->addWidget(pVisoNameLabel, 0, 0, 1, 1);
    73     m_pMainLayout->addWidget(pVisoNameLineEdit, 0, 1, 1, 1);
     92    /* Cutom Viso options stuff: */
     93    QILabel *pCustomOptionsLabel = new QILabel(UIVisoCreator::tr("Custom VISO options:"));
     94    m_pCustomOptionsTextEdit = new QTextEdit;
     95    if (pCustomOptionsLabel && m_pCustomOptionsTextEdit)
     96    {
     97        m_pCustomOptionsTextEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
     98        pCustomOptionsLabel->setBuddy(m_pCustomOptionsTextEdit);
     99        m_pMainLayout->addWidget(pCustomOptionsLabel, 1, 0, 1, 1, Qt::AlignTop);
     100        m_pMainLayout->addWidget(m_pCustomOptionsTextEdit, 1, 1, 1, 1);
     101        foreach (const QString &strLine, m_visoOptions.m_customOptions)
     102            m_pCustomOptionsTextEdit->append(strLine);
     103    }
    74104
    75105    m_pButtonBox = new QIDialogButtonBox;
     
    78108        m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    79109        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    80         m_pMainLayout->addWidget(m_pButtonBox, 1, 0, 1, 2);
     110        m_pMainLayout->addWidget(m_pButtonBox, 2, 0, 1, 2);
    81111    }
    82112    setLayout(m_pMainLayout);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationDialog.h

    r76747 r76768  
    2828
    2929/* Forward declarations: */
     30class QGridLayout;
     31class QTextEdit;
     32class QIDialogButtonBox;
     33class QILineEdit;
    3034class QITabWidget;
    31 class QGridLayout;
    32 class QIDialogButtonBox;
    3335
    3436class SHARED_LIBRARY_STUFF UIVisoConfigurationDialog : public QIDialog
     
    3739
    3840public:
    39 
    4041    UIVisoConfigurationDialog(const VisoOptions &visoOptions,
    4142                              QWidget *pParent = 0);
     
    4344    const VisoOptions &visoOptions() const;
    4445
    45 private slots:
     46public slots:
    4647
    47     void sltHandleVisoNameChange(const QString &strText);
     48    void accept() /* override */;
     49
    4850
    4951private:
     
    5456    QGridLayout          *m_pMainLayout;
    5557    QIDialogButtonBox    *m_pButtonBox;
     58    QILineEdit           *m_pVisoNameLineEdit;
     59    QTextEdit           *m_pCustomOptionsTextEdit;
    5660    VisoOptions          m_visoOptions;
     61
    5762    friend class UIVisoCreator;
    5863};
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r76762 r76768  
    256256        m_pRenameAction->setToolTip(QApplication::translate("UIVisoCreator", "Rename the selected object"));
    257257
    258 
    259258    UICustomFileSystemItem *pRootItem = rootItem();
    260259    if (pRootItem)
     
    338337        if (!pItem)
    339338            continue;
     339        QString strIsoPath = pItem->data(UICustomFileSystemModelColumn_Path).toString();
     340        if (strIsoPath.isEmpty())
     341            continue;
     342
    340343        bool bFoundInMap = false;
    341344        for (QMap<QString, QString>::iterator iterator = m_entryMap.begin(); iterator != m_entryMap.end(); )
    342345        {
    343             QString strIsoPath = pItem->data(UICustomFileSystemModelColumn_Path).toString();
    344             if (strIsoPath.isEmpty())
    345                 continue;
    346346            if (iterator.key().startsWith(strIsoPath))
    347347            {
     
    465465    if (m_pRenameAction)
    466466    {
    467         m_pVerticalToolBar->addAction(m_pRenameAction);
     467        /** @todo Handle rename correctly in the m_entryMap as well and then enable this rename action. */
     468        /* m_pVerticalToolBar->addAction(m_pRenameAction); */
    468469        m_pRenameAction->setIcon(UIIconPool::iconSet(":/file_manager_rename_16px.png", ":/file_manager_rename_disabled_16px.png"));
    469470        m_pRenameAction->setEnabled(false);
     
    507508        connect(m_pResetAction, &QAction::triggered,
    508509                this, &UIVisoContentBrowser::sltHandleResetAction);
    509 
     510    if (m_pRenameAction)
     511        connect(m_pRenameAction, &QAction::triggered,
     512                this,&UIVisoContentBrowser::sltHandleItemRenameAction);
    510513    if (m_pTableView->selectionModel())
    511514        connect(m_pTableView->selectionModel(), &QItemSelectionModel::selectionChanged,
     
    721724}
    722725
     726void UIVisoContentBrowser::sltHandleItemRenameAction()
     727{
     728    QList<UICustomFileSystemItem*> selectedItems = tableSelectedItems();
     729    if (selectedItems.empty())
     730        return;
     731    /* This is not complete. we have to modify the entries in the m_entryMap as well: */
     732    renameFileObject(selectedItems.at(0));
     733}
     734
    723735void UIVisoContentBrowser::sltHandleItemRenameAttempt(UICustomFileSystemItem *pItem, QString strOldName, QString strNewName)
    724736{
     
    740752
    741753    pItem->setData(UIPathOperations::mergePaths(pItem->parentItem()->path(), pItem->name()), UICustomFileSystemModelColumn_Path);
    742 
    743754    if (m_pTableProxyModel)
    744755        m_pTableProxyModel->invalidate();
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r76762 r76768  
    7676
    7777    void sltHandleCreateNewDirectory();
     78    /** Handles the signal we get from the model during setData call. Restores the old name of the file object
     79     *  to @p strOldName if need be. */
    7880    void sltHandleItemRenameAttempt(UICustomFileSystemItem *pItem, QString strOldName, QString strNewName);
     81    void sltHandleItemRenameAction();
    7982    void sltHandleRemoveItems();
    8083    void sltHandleTableSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r76747 r76768  
    6666}
    6767
     68const QStringList &UIVisoCreator::customOptions() const
     69{
     70    return m_visoOptions.m_customOptions;
     71}
     72
    6873void UIVisoCreator::retranslateUi()
    6974{
     
    228233    }
    229234    m_visoOptions = visoOptions;
    230 
    231 }
     235}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r76747 r76768  
    5555    QStringList entryList() const;
    5656    const QString &visoName() const;
     57    const QStringList &customOptions() const;
    5758
    5859#ifdef VBOX_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorDefs.h

    r76675 r76768  
    2929    bool operator==(const VisoOptions &otherOptions) const
    3030    {
    31         return m_strVisoName == otherOptions.m_strVisoName;
     31        return (m_strVisoName == otherOptions.m_strVisoName) &&
     32            (m_customOptions == otherOptions.m_customOptions);
    3233    }
    3334    QString m_strVisoName;
     35    /** Additions viso options to be inserted to the viso file as separate lines. */
     36    QStringList m_customOptions;
    3437};
    3538
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