VirtualBox

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


Ignore:
Timestamp:
Jul 25, 2019 4:09:39 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132416
Message:

FE/Qt: bugref:7720: VirtualBox Manager: Details pane: Possibility to edit VM boot order on-the-fly.

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

Legend:

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

    r79959 r79982  
    2121
    2222/* GUI includes: */
     23#include "UIBootOrderEditor.h"
    2324#include "UIConverter.h"
    2425#include "UIDetailsGenerator.h"
     
    162163    if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_BootOrder)
    163164    {
    164         QStringList bootOrder;
    165         for (ulong i = 1; i <= uiCommon().virtualBox().GetSystemProperties().GetMaxBootPosition(); ++i)
    166         {
    167             const KDeviceType enmDeviceType = comMachine.GetBootOrder(i);
    168             if (enmDeviceType == KDeviceType_Null)
    169                 continue;
    170             bootOrder << gpConverter->toString(enmDeviceType);
    171         }
    172         if (bootOrder.isEmpty())
    173             bootOrder << gpConverter->toString(KDeviceType_Null);
    174         table << UITextTableLine(QApplication::translate("UIDetails", "Boot Order", "details (system)"), bootOrder.join(", "));
     165        /* Configure hovering anchor: */
     166        const QString strAnchorType = QString("boot_order");
     167        const UIBootItemDataList bootItems = loadBootItems(comMachine);
     168        table << UITextTableLine(QApplication::translate("UIDetails", "Boot Order", "details (system)"),
     169                                 QApplication::translate("UIDetails", "<a href=#%1,%2>%3</a>", "details")
     170                                    .arg(strAnchorType,
     171                                         bootItemsToSerializedString(bootItems),
     172                                         bootItemsToReadableString(bootItems)));
    175173    }
    176174
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.cpp

    r79959 r79982  
    2020
    2121/* GUI includes: */
     22#include "UIBootOrderEditor.h"
    2223#include "UICommon.h"
    2324#include "UIMachineAttributeSetter.h"
     
    99100                break;
    100101            }
     102            case MachineAttribute_BootOrder:
     103            {
     104                /* Change machine boot order: */
     105                saveBootItems(guiAttribute.value<UIBootItemDataList>(), comMachine);
     106                if (!comMachine.isOk())
     107                {
     108                    msgCenter().cannotChangeMachineAttribute(comMachine);
     109                    fErrorHappened = true;
     110                }
     111                break;
     112            }
    101113            default:
    102114                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.h

    r79959 r79982  
    3434    MachineAttribute_Location,
    3535    MachineAttribute_BaseMemory,
     36    MachineAttribute_BootOrder,
    3637};
    3738
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp

    r79960 r79982  
    2828#include "UIActionPool.h"
    2929#include "UIBaseMemoryEditor.h"
     30#include "UIBootOrderEditor.h"
    3031#include "UICommon.h"
    3132#include "UIConverter.h"
     
    5051    AnchorRole_OSType,
    5152    AnchorRole_BaseMemory,
     53    AnchorRole_BootOrder,
    5254    AnchorRole_Storage,
    5355};
     
    153155    m_pTextPane->setAnchorRoleRestricted("#os_type", cal != ConfigurationAccessLevel_Full);
    154156    m_pTextPane->setAnchorRoleRestricted("#base_memory", cal != ConfigurationAccessLevel_Full);
     157    m_pTextPane->setAnchorRoleRestricted("#boot_order", cal != ConfigurationAccessLevel_Full);
    155158    m_pTextPane->setAnchorRoleRestricted("#mount", cal == ConfigurationAccessLevel_Null);
    156159    m_pTextPane->setAnchorRoleRestricted("#attach", cal != ConfigurationAccessLevel_Full);
     
    436439    roles["#os_type"] = AnchorRole_OSType;
    437440    roles["#base_memory"] = AnchorRole_BaseMemory;
     441    roles["#boot_order"] = AnchorRole_BootOrder;
    438442    roles["#mount"] = AnchorRole_Storage;
    439443    roles["#attach"] = AnchorRole_Storage;
     
    535539            break;
    536540        }
     541        case AnchorRole_BootOrder:
     542        {
     543            /* Prepare popup: */
     544            QPointer<QIDialogContainer> pPopup = new QIDialogContainer(0, Qt::Tool);
     545            if (pPopup)
     546            {
     547                /* Prepare editor: */
     548                UIBootOrderEditor *pEditor = new UIBootOrderEditor(pPopup, true /* with label */);
     549                if (pEditor)
     550                {
     551                    pEditor->setValue(bootItemsFromSerializedString(strData.section(',', 0, 0)));
     552                    pPopup->setWidget(pEditor);
     553                }
     554
     555                /* Adjust popup geometry: */
     556                pPopup->move(QCursor::pos());
     557                pPopup->adjustSize();
     558
     559                // WORKAROUND:
     560                // On Windows, Tool dialogs aren't activated by default by some reason.
     561                // So we have created sltActivateWindow wrapping actual activateWindow
     562                // to fix that annoying issue.
     563                QMetaObject::invokeMethod(pPopup, "sltActivateWindow", Qt::QueuedConnection);
     564                /* Execute popup, change machine name if confirmed: */
     565                if (pPopup->exec() == QDialog::Accepted)
     566                    setMachineAttribute(machine(), MachineAttribute_BootOrder, QVariant::fromValue(pEditor->value()));
     567
     568                /* Delete popup: */
     569                delete pPopup;
     570            }
     571            break;
     572        }
    537573        case AnchorRole_Storage:
    538574        {
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootOrderEditor.cpp

    r79981 r79982  
    367367}
    368368
     369QString UIBootDataTools::bootItemsToReadableString(const UIBootItemDataList &bootItems)
     370{
     371    /* Prepare list: */
     372    QStringList list;
     373    /* We are reflecting only enabled items: */
     374    foreach (const UIBootItemData &bootItem, bootItems)
     375        if (bootItem.m_fEnabled)
     376            list << gpConverter->toString(bootItem.m_enmType);
     377    /* But if list is empty we are adding Null item at least: */
     378    if (list.isEmpty())
     379        list << gpConverter->toString(KDeviceType_Null);
     380    /* Join list to string: */
     381    return list.join(", ");
     382}
     383
     384QString UIBootDataTools::bootItemsToSerializedString(const UIBootItemDataList &bootItems)
     385{
     386    /* Prepare list: */
     387    QStringList list;
     388    /* This is simple, we are adding '+' before enabled types and '-' before disabled: */
     389    foreach (const UIBootItemData &bootItem, bootItems)
     390        list << (bootItem.m_fEnabled ? QString("+%1").arg(bootItem.m_enmType) : QString("-%1").arg(bootItem.m_enmType));
     391    /* Join list to string: */
     392    return list.join(';');
     393}
     394
     395UIBootItemDataList UIBootDataTools::bootItemsFromSerializedString(const QString &strBootItems)
     396{
     397    /* Prepare list: */
     398    UIBootItemDataList list;
     399    /* First of all, split passed string to arguments: */
     400    const QStringList arguments = strBootItems.split(';');
     401    /* Now parse in backward direction, we have added '+' before enabled types and '-' before disabled: */
     402    foreach (QString strArgument, arguments)
     403    {
     404        UIBootItemData data;
     405        data.m_fEnabled = strArgument.startsWith('+');
     406        strArgument.remove(QRegExp("[+-]"));
     407        data.m_enmType = static_cast<KDeviceType>(strArgument.toInt());
     408        list << data;
     409    }
     410    /* Return list: */
     411    return list;
     412}
     413
    369414
    370415/*********************************************************************************************************************************
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootOrderEditor.h

    r79981 r79982  
    6363};
    6464typedef QList<UIBootItemData> UIBootItemDataList;
     65Q_DECLARE_METATYPE(UIBootItemDataList);
    6566
    6667
     
    7273    /** Saves @a bootItems list to passed @a comMachine. */
    7374    SHARED_LIBRARY_STUFF void saveBootItems(const UIBootItemDataList &bootItems, CMachine &comMachine);
     75
     76    /** Converts passed @a bootItems list into human readable string. */
     77    SHARED_LIBRARY_STUFF QString bootItemsToReadableString(const UIBootItemDataList &bootItems);
     78
     79    /** Performs serialization for passed @a bootItems list. */
     80    SHARED_LIBRARY_STUFF QString bootItemsToSerializedString(const UIBootItemDataList &bootItems);
     81    /** Performs deserialization for passed @a strBootItems string. */
     82    SHARED_LIBRARY_STUFF UIBootItemDataList bootItemsFromSerializedString(const QString &strBootItems);
    7483}
    7584using namespace UIBootDataTools;
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