Changeset 77620 in vbox for trunk/src/VBox
- Timestamp:
- Mar 8, 2019 3:03:08 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r77596 r77620 32 32 #include "UIChooser.h" 33 33 #include "UIChooserItem.h" 34 #include "UIChooserView.h"35 #include "UIChooserModel.h"36 34 #include "UIChooserItemGroup.h" 37 35 #include "UIChooserItemGlobal.h" 38 36 #include "UIChooserItemMachine.h" 37 #include "UIChooserView.h" 38 #include "UIChooserModel.h" 39 40 /* Other VBox includes: */ 41 #include "iprt/assert.h" 39 42 40 43 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r77596 r77620 253 253 * @{ */ 254 254 /** Returns previous geometry. */ 255 const QRectF &previousGeometry() const { return m_previousGeometry; }255 QRectF previousGeometry() const { return m_previousGeometry; } 256 256 /** Defines previous @a geometry. */ 257 257 void setPreviousGeometry(const QRectF &geometry) { m_previousGeometry = geometry; } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r77596 r77620 17 17 18 18 /* Qt includes: */ 19 #include <QGraphicsScene>20 19 #include <QGraphicsSceneMouseEvent> 21 20 #include <QGraphicsView> … … 24 23 25 24 /* GUI includes: */ 26 #include "VBoxGlobal.h"27 25 #include "UIChooserItemGlobal.h" 28 26 #include "UIChooserModel.h" … … 226 224 void UIChooserItemGlobal::updateToolTip() 227 225 { 228 // setToolTip(toolTipText()); 226 // Nothing for now.. 229 227 } 230 228 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h
r77596 r77620 24 24 /* GUI includes: */ 25 25 #include "UIChooserItem.h" 26 27 /* Forward declarations: */28 class QMimeData;29 class QPainter;30 class QStyleOptionGraphicsItem;31 class UIGraphicsToolBar;32 class UIGraphicsZoomButton;33 26 34 27 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r77604 r77620 17 17 18 18 /* Qt includes: */ 19 #include <QGraphicsLinearLayout> 19 20 #include <QGraphicsScene> 20 21 #include <QGraphicsSceneDragDropEvent> 22 #include <QGraphicsView> 21 23 #include <QHBoxLayout> 22 24 #include <QLineEdit> 23 #include <QMenu>24 25 #include <QPainter> 25 26 #include <QStyleOptionGraphicsItem> 26 #include <QGraphicsLinearLayout>27 #include <QGraphicsProxyWidget>28 27 #include <QWindow> 29 28 … … 33 32 #include "UIChooserItemMachine.h" 34 33 #include "UIChooserModel.h" 35 #include "UIChooserView.h"36 34 #include "UIGraphicsRotatorButton.h" 37 35 #include "UIGraphicsScrollArea.h" … … 1041 1039 } 1042 1040 1043 /* Copy passed item into this group: */1041 /* Copy passed group-item into this group: */ 1044 1042 UIChooserItem *pNewGroupItem = new UIChooserItemGroup(this, pItem->toGroupItem(), iPosition); 1045 1043 if (isClosed()) … … 1075 1073 UIChooserModel *pModel = model(); 1076 1074 1077 /* Get passed item: */1075 /* Get passed machine-item: */ 1078 1076 const UIChooserItemMimeData *pCastedMime = qobject_cast<const UIChooserItemMimeData*>(pMime); 1079 1077 AssertMsg(pCastedMime, ("Can't cast passed mime-data to UIChooserItemMimeData!")); … … 1238 1236 void UIChooserItemGroup::prepare() 1239 1237 { 1240 /* P ainting stuff: */1238 /* Prepare self: */ 1241 1239 m_nameFont = font(); 1242 1240 m_nameFont.setWeight(QFont::Bold); … … 1244 1242 m_minimumHeaderSize = QSize(0, 0); 1245 1243 1246 /* Items except roots: */ 1247 if (!isRoot()) 1244 /* Prepare header widgets of root item: */ 1245 if (isRoot()) 1246 { 1247 #if 0 1248 /* Except main root ofc: */ 1249 if (!isMainRoot()) 1250 { 1251 /* Setup exit-button: */ 1252 m_pExitButton = new UIGraphicsButton(this, UIIconPool::iconSet(":/previous_16px.png")); 1253 if (m_pExitButton) 1254 { 1255 m_pExitButton->hide(); 1256 QSizeF sh = m_pExitButton->minimumSizeHint(); 1257 m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2); 1258 connect(m_pExitButton, &UIGraphicsButton::sigButtonClicked, 1259 this, &UIChooserItemGroup::sltUnindentRoot); 1260 } 1261 m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0); 1262 } 1263 #endif 1264 } 1265 /* Prepare header widgets of non-root item: */ 1266 else 1248 1267 { 1249 1268 /* Setup toggle-button: */ 1250 1269 m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", isOpened()); 1251 connect(m_pToggleButton, &UIGraphicsRotatorButton::sigRotationStart, 1252 this, &UIChooserItemGroup::sltGroupToggleStart); 1253 connect(m_pToggleButton, &UIGraphicsRotatorButton::sigRotationFinish, 1254 this, &UIChooserItemGroup::sltGroupToggleFinish); 1255 m_pToggleButton->hide(); 1270 if (m_pToggleButton) 1271 { 1272 m_pToggleButton->hide(); 1273 connect(m_pToggleButton, &UIGraphicsRotatorButton::sigRotationStart, 1274 this, &UIChooserItemGroup::sltGroupToggleStart); 1275 connect(m_pToggleButton, &UIGraphicsRotatorButton::sigRotationFinish, 1276 this, &UIChooserItemGroup::sltGroupToggleFinish); 1277 } 1256 1278 m_toggleButtonSize = m_pToggleButton ? m_pToggleButton->minimumSizeHint().toSize() : QSize(0, 0); 1257 1279 1258 1280 /* Setup enter-button: */ 1259 1281 m_pEnterButton = new UIGraphicsButton(this, UIIconPool::iconSet(":/next_16px.png")); 1260 connect(m_pEnterButton, &UIGraphicsButton::sigButtonClicked, 1261 this, &UIChooserItemGroup::sltIndentRoot); 1262 m_pEnterButton->hide(); 1282 if (m_pEnterButton) 1283 { 1284 m_pEnterButton->hide(); 1285 connect(m_pEnterButton, &UIGraphicsButton::sigButtonClicked, 1286 this, &UIChooserItemGroup::sltIndentRoot); 1287 } 1263 1288 m_enterButtonSize = m_pEnterButton ? m_pEnterButton->minimumSizeHint().toSize() : QSize(0, 0); 1264 1289 1265 1290 /* Setup name-editor: */ 1266 1291 m_pNameEditorWidget = new UIEditorGroupRename(name()); 1267 m_pNameEditorWidget->setFont(m_nameFont); 1268 connect(m_pNameEditorWidget, &UIEditorGroupRename::sigEditingFinished, 1269 this, &UIChooserItemGroup::sltNameEditingFinished); 1270 } 1271 1272 #if 0 1273 /* Items except main root: */ 1274 if (!isMainRoot()) 1275 { 1276 /* Setup exit-button: */ 1277 m_pExitButton = new UIGraphicsButton(this, UIIconPool::iconSet(":/previous_16px.png")); 1278 connect(m_pExitButton, &UIGraphicsButton::sigButtonClicked, 1279 this, &UIChooserItemGroup::sltUnindentRoot); 1280 QSizeF sh = m_pExitButton->minimumSizeHint(); 1281 m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2); 1282 m_pExitButton->hide(); 1283 m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0); 1284 } 1285 #endif 1292 if (m_pNameEditorWidget) 1293 { 1294 m_pNameEditorWidget->setFont(m_nameFont); 1295 connect(m_pNameEditorWidget, &UIEditorGroupRename::sigEditingFinished, 1296 this, &UIChooserItemGroup::sltNameEditingFinished); 1297 } 1298 } 1286 1299 1287 1300 /* Prepare favorite children container: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r77596 r77620 22 22 #endif 23 23 24 /* Qt includes: */25 #include <QPixmap>26 #include <QString>27 #include <QWidget>28 29 24 /* GUI includes: */ 30 25 #include "UIChooserItem.h" … … 32 27 /* Forward declarations: */ 33 28 class QGraphicsLinearLayout; 34 class QGraphicsScene;35 class QLineEdit;36 class QMenu;37 class QMimeData;38 class QPainter;39 class QStyleOptionGraphicsItem;40 29 class UIEditorGroupRename; 41 30 class UIGraphicsButton; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp
r77604 r77620 17 17 18 18 /* Qt includes: */ 19 #include <QGraphicsScene> 20 #include <QGraphicsSceneMouseEvent> 19 #include <QGraphicsSceneDragDropEvent> 21 20 #include <QGraphicsView> 22 21 #include <QPainter> … … 25 24 26 25 /* GUI includes: */ 27 #include "VBoxGlobal.h"28 26 #include "UIChooserItemGroup.h" 29 27 #include "UIChooserItemMachine.h" 30 28 #include "UIChooserModel.h" 31 #include "UIActionPoolManager.h"32 29 #include "UIIconPool.h" 33 #include "UIImageTools.h"34 30 #include "UIVirtualBoxManager.h" 35 36 /* COM includes: */37 #include "COMEnums.h"38 #include "CMachine.h"39 31 40 32 /* Other VBox includes: */ … … 91 83 bool UIChooserItemMachine::isLockedMachine() const 92 84 { 93 KMachineState state = machineState();94 return state != KMachineState_PoweredOff &&95 state != KMachineState_Saved &&96 state != KMachineState_Teleported &&97 state != KMachineState_Aborted;85 const KMachineState enmState = machineState(); 86 return enmState != KMachineState_PoweredOff && 87 enmState != KMachineState_Saved && 88 enmState != KMachineState_Teleported && 89 enmState != KMachineState_Aborted; 98 90 } 99 91 … … 164 156 m_strDescription = tr("Virtual Machine"); 165 157 166 /* Update state text : */167 updateStateText ();158 /* Update state text size: */ 159 updateStateTextSize(); 168 160 169 161 /* Update machine tool-tip: */ … … 296 288 recache(); 297 289 updatePixmaps(); 298 updateName(); 299 updateSnapshotName(); 300 updateStateText(); 290 updateMinimumNameWidth(); 291 updateVisibleName(); 292 updateMinimumSnapshotNameWidth(); 293 updateVisibleSnapshotName(); 294 updateStateTextSize(); 301 295 updateToolTip(); 302 296 … … 379 373 /* And machine-item content to take into account: */ 380 374 int iTopLineWidth = m_iMinimumNameWidth; 381 if (! m_strSnapshotName.isEmpty())375 if (!snapshotName().isEmpty()) 382 376 iTopLineWidth += (iMinorSpacing + 383 377 m_iMinimumSnapshotNameWidth); … … 507 501 /* Group passed item with current item into the new group: */ 508 502 UIChooserItemGroup *pNewGroupItem = new UIChooserItemGroup(parentItem(), 509 510 503 UIChooserModel::uniqueGroupName(parentItem()), 504 true); 511 505 new UIChooserItemMachine(pNewGroupItem, this); 512 506 new UIChooserItemMachine(pNewGroupItem, pItem->toMachineItem()); … … 605 599 /* Init: */ 606 600 updatePixmaps(); 607 updateName(); 608 updateSnapshotName(); 601 updateMinimumNameWidth(); 602 updateVisibleName(); 603 updateMinimumSnapshotNameWidth(); 604 updateVisibleSnapshotName(); 609 605 610 606 /* Apply language settings: */ … … 736 732 } 737 733 738 void UIChooserItemMachine::updateName()739 {740 /* Get new name: */741 QString strName = name();742 743 /* Is there something changed? */744 if (m_strName == strName)745 return;746 747 /* Update linked values: */748 m_strName = strName;749 updateMinimumNameWidth();750 updateVisibleName();751 }752 753 void UIChooserItemMachine::updateSnapshotName()754 {755 /* Get new snapshot-name: */756 QString strSnapshotName = snapshotName();757 758 /* Is there something changed? */759 if (m_strSnapshotName == strSnapshotName)760 return;761 762 /* Update linked values: */763 m_strSnapshotName = strSnapshotName;764 updateMinimumSnapshotNameWidth();765 updateVisibleSnapshotName();766 }767 768 734 void UIChooserItemMachine::updateFirstRowMaximumWidth() 769 735 { … … 803 769 QPaintDevice *pPaintDevice = model()->paintDevice(); 804 770 QFontMetrics fm(m_nameFont, pPaintDevice); 805 int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, m_strName, textWidth(m_nameFont, pPaintDevice, 15)));771 int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, name(), textWidth(m_nameFont, pPaintDevice, 15))); 806 772 807 773 /* Is there something changed? */ … … 819 785 int iMinimumSnapshotNameWidth = 0; 820 786 /* Is there any snapshot exists? */ 821 if (! m_strSnapshotName.isEmpty())787 if (!snapshotName().isEmpty()) 822 788 { 823 789 QFontMetrics fm(m_snapshotNameFont, model()->paintDevice()); 824 790 int iBracketWidth = fm.width("()"); /* bracket width */ 825 int iActualTextWidth = fm.width( m_strSnapshotName); /* snapshot-name width */791 int iActualTextWidth = fm.width(snapshotName()); /* snapshot-name width */ 826 792 int iMinimumTextWidth = fm.width("..."); /* ellipsis width */ 827 793 iMinimumSnapshotNameWidth = iBracketWidth + qMin(iActualTextWidth, iMinimumTextWidth); … … 884 850 885 851 /* Calculate new visible name and name-size: */ 886 QString strVisibleName = compressText(m_nameFont, pPaintDevice, m_strName, m_iMaximumNameWidth);852 QString strVisibleName = compressText(m_nameFont, pPaintDevice, name(), m_iMaximumNameWidth); 887 853 QSize visibleNameSize = textSize(m_nameFont, pPaintDevice, strVisibleName); 888 854 … … 908 874 /* Calculate new visible snapshot-name: */ 909 875 int iBracketWidth = QFontMetrics(m_snapshotNameFont, pPaintDevice).width("()"); 910 QString strVisibleSnapshotName = compressText(m_snapshotNameFont, pPaintDevice, m_strSnapshotName,876 QString strVisibleSnapshotName = compressText(m_snapshotNameFont, pPaintDevice, snapshotName(), 911 877 m_iMaximumSnapshotNameWidth - iBracketWidth); 912 878 strVisibleSnapshotName = QString("(%1)").arg(strVisibleSnapshotName); … … 926 892 } 927 893 928 void UIChooserItemMachine::updateStateText ()894 void UIChooserItemMachine::updateStateTextSize() 929 895 { 930 896 /* Get new state-text and state-text size: */ 931 QString strStateText = machineStateName(); 932 QSize stateTextSize = textSize(m_stateTextFont, model()->paintDevice(), m_strStateText); 897 const QSize stateTextSize = textSize(m_stateTextFont, model()->paintDevice(), machineStateName()); 933 898 934 899 /* Update linked values: */ … … 937 902 m_stateTextSize = stateTextSize; 938 903 updateGeometry(); 939 }940 if (m_strStateText != strStateText)941 {942 m_strStateText = strStateText;943 update();944 904 } 945 905 } … … 1276 1236 model()->paintDevice(), 1277 1237 /* Text to paint: */ 1278 m _strStateText);1238 machineStateName()); 1279 1239 } 1280 1240 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h
r77596 r77620 22 22 #endif 23 23 24 /* Qt includes */25 #include <QUuid>26 27 24 /* GUI includes: */ 28 25 #include "UIVirtualMachineItem.h" 29 26 #include "UIChooserItem.h" 30 31 /* Forward declarations: */32 class CMachine;33 27 34 28 /** UIChooserItem extension implementing machine item. */ … … 108 102 /** Updates item tool-tip. */ 109 103 virtual void updateToolTip() /* override */; 110 111 104 /** @} */ 112 105 … … 234 227 /** Updates tool pixmap. */ 235 228 void updateToolPixmap(); 236 /** Updates name. */237 void updateName();238 /** Updates snapshot name. */239 void updateSnapshotName();240 229 /** Updates first row maximum width. */ 241 230 void updateFirstRowMaximumWidth(); … … 252 241 /** Updates visible snapshot name. */ 253 242 void updateVisibleSnapshotName(); 254 /** Updates state text . */255 void updateStateText ();243 /** Updates state text size. */ 244 void updateStateTextSize(); 256 245 /** @} */ 257 246 … … 298 287 QPixmap m_toolPixmap; 299 288 300 /** Holds item name. */301 QString m_strName;302 289 /** Holds item description. */ 303 290 QString m_strDescription; 304 291 /** Holds item visible name. */ 305 292 QString m_strVisibleName; 306 /** Holds item snapshot name. */307 QString m_strSnapshotName;308 293 /** Holds item visible snapshot name. */ 309 294 QString m_strVisibleSnapshotName; 310 /** Holds item state text. */311 QString m_strStateText;312 295 313 296 /** Holds item name font. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77605 r77620 2065 2065 foreach (UIChooserItem *pItem, pParentItem->items(UIChooserItemType_Machine)) 2066 2066 orders[strExtraDataKey] << QString("m=%1").arg(toOldStyleUuid(pItem->toMachineItem()->id())); 2067 2067 } 2068 2068 2069 2069 void UIChooserModel::makeSureGroupDefinitionsSaveIsFinished()
Note:
See TracChangeset
for help on using the changeset viewer.