Changeset 75640 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 21, 2018 11:00:23 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r75571 r75640 735 735 src/manager/chooser/UIChooserItemMachine.h \ 736 736 src/manager/details/UIDetails.h \ 737 src/manager/details/UIDetailsContextMenu.h \ 737 738 src/manager/details/UIDetailsModel.h \ 738 739 src/manager/details/UIDetailsView.h \ … … 1420 1421 src/manager/chooser/UIChooserItemMachine.cpp \ 1421 1422 src/manager/details/UIDetails.cpp \ 1423 src/manager/details/UIDetailsContextMenu.cpp \ 1422 1424 src/manager/details/UIDetailsModel.cpp \ 1423 1425 src/manager/details/UIDetailsView.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsContextMenu.cpp
r75636 r75640 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIDetails Modelclass implementation.3 * VBox Qt GUI - UIDetailsContextMenu class implementation. 4 4 */ 5 5 … … 21 21 22 22 /* Qt includes: */ 23 # include <QAction>24 # include <QGraphicsScene>25 # include <QGraphicsSceneContextMenuEvent>26 # include <QGraphicsView>27 23 # include <QHBoxLayout> 28 24 # include <QListWidget> 29 # include <QMenu>30 25 # include <QMetaEnum> 31 26 32 27 /* GUI includes: */ 33 28 # include "UIConverter.h" 34 # include "UIDetails .h"29 # include "UIDetailsContextMenu.h" 35 30 # include "UIDetailsModel.h" 36 # include "UIDetailsGroup.h"37 # include "UIDetailsElement.h"38 # include "UIExtraDataManager.h"39 # include "UIIconPool.h"40 # include "VBoxGlobal.h"41 31 42 32 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 43 33 44 45 /*********************************************************************************************************************************46 * Class UIDetailsContextMenu implementation. *47 *********************************************************************************************************************************/48 34 49 35 UIDetailsContextMenu::UIDetailsContextMenu(UIDetailsModel *pModel) … … 1015 1001 return pItem; 1016 1002 } 1017 1018 1019 /*********************************************************************************************************************************1020 * Class UIDetailsModel implementation. *1021 *********************************************************************************************************************************/1022 1023 UIDetailsModel::UIDetailsModel(UIDetails *pParent)1024 : QObject(pParent)1025 , m_pDetails(pParent)1026 , m_pScene(0)1027 , m_pRoot(0)1028 , m_pAnimationCallback(0)1029 , m_pContextMenu(0)1030 {1031 prepare();1032 }1033 1034 UIDetailsModel::~UIDetailsModel()1035 {1036 cleanup();1037 }1038 1039 QGraphicsScene *UIDetailsModel::scene() const1040 {1041 return m_pScene;1042 }1043 1044 QGraphicsView *UIDetailsModel::paintDevice() const1045 {1046 if (m_pScene && !m_pScene->views().isEmpty())1047 return m_pScene->views().first();1048 return 0;1049 }1050 1051 QGraphicsItem *UIDetailsModel::itemAt(const QPointF &position) const1052 {1053 return scene()->itemAt(position, QTransform());1054 }1055 1056 UIDetailsItem *UIDetailsModel::root() const1057 {1058 return m_pRoot;1059 }1060 1061 void UIDetailsModel::updateLayout()1062 {1063 /* Prepare variables: */1064 const QSize viewportSize = paintDevice()->viewport()->size();1065 const QSize rootSize = viewportSize.expandedTo(m_pRoot->minimumSizeHint().toSize());1066 1067 /* Move root: */1068 m_pRoot->setPos(0, 0);1069 /* Resize root: */1070 m_pRoot->resize(rootSize);1071 /* Layout root content: */1072 m_pRoot->updateLayout();1073 }1074 1075 void UIDetailsModel::setItems(const QList<UIVirtualMachineItem*> &items)1076 {1077 m_pRoot->buildGroup(items);1078 }1079 1080 void UIDetailsModel::setCategories(const QMap<DetailsElementType, bool> &categories)1081 {1082 m_categories = categories;1083 m_pRoot->rebuildGroup();1084 m_pContextMenu->updateCategoryStates();1085 }1086 1087 void UIDetailsModel::setOptionsGeneral(UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral fOptionsGeneral)1088 {1089 m_fOptionsGeneral = fOptionsGeneral;1090 m_pRoot->rebuildGroup();1091 m_pContextMenu->updateOptionStates(DetailsElementType_General);1092 }1093 1094 void UIDetailsModel::setOptionsSystem(UIExtraDataMetaDefs::DetailsElementOptionTypeSystem fOptionsSystem)1095 {1096 m_fOptionsSystem = fOptionsSystem;1097 m_pRoot->rebuildGroup();1098 m_pContextMenu->updateOptionStates(DetailsElementType_System);1099 }1100 1101 void UIDetailsModel::setOptionsDisplay(UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay fOptionsDisplay)1102 {1103 m_fOptionsDisplay = fOptionsDisplay;1104 m_pRoot->rebuildGroup();1105 m_pContextMenu->updateOptionStates(DetailsElementType_Display);1106 }1107 1108 void UIDetailsModel::setOptionsStorage(UIExtraDataMetaDefs::DetailsElementOptionTypeStorage fOptionsStorage)1109 {1110 m_fOptionsStorage = fOptionsStorage;1111 m_pRoot->rebuildGroup();1112 m_pContextMenu->updateOptionStates(DetailsElementType_Storage);1113 }1114 1115 void UIDetailsModel::setOptionsAudio(UIExtraDataMetaDefs::DetailsElementOptionTypeAudio fOptionsAudio)1116 {1117 m_fOptionsAudio = fOptionsAudio;1118 m_pRoot->rebuildGroup();1119 m_pContextMenu->updateOptionStates(DetailsElementType_Audio);1120 }1121 1122 void UIDetailsModel::setOptionsNetwork(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork fOptionsNetwork)1123 {1124 m_fOptionsNetwork = fOptionsNetwork;1125 m_pRoot->rebuildGroup();1126 m_pContextMenu->updateOptionStates(DetailsElementType_Network);1127 }1128 1129 void UIDetailsModel::setOptionsSerial(UIExtraDataMetaDefs::DetailsElementOptionTypeSerial fOptionsSerial)1130 {1131 m_fOptionsSerial = fOptionsSerial;1132 m_pRoot->rebuildGroup();1133 m_pContextMenu->updateOptionStates(DetailsElementType_Serial);1134 }1135 1136 void UIDetailsModel::setOptionsUsb(UIExtraDataMetaDefs::DetailsElementOptionTypeUsb fOptionsUsb)1137 {1138 m_fOptionsUsb = fOptionsUsb;1139 m_pRoot->rebuildGroup();1140 m_pContextMenu->updateOptionStates(DetailsElementType_USB);1141 }1142 1143 void UIDetailsModel::setOptionsSharedFolders(UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders fOptionsSharedFolders)1144 {1145 m_fOptionsSharedFolders = fOptionsSharedFolders;1146 m_pRoot->rebuildGroup();1147 m_pContextMenu->updateOptionStates(DetailsElementType_SF);1148 }1149 1150 void UIDetailsModel::setOptionsUserInterface(UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface fOptionsUserInterface)1151 {1152 m_fOptionsUserInterface = fOptionsUserInterface;1153 m_pRoot->rebuildGroup();1154 m_pContextMenu->updateOptionStates(DetailsElementType_UI);1155 }1156 1157 void UIDetailsModel::setOptionsDescription(UIExtraDataMetaDefs::DetailsElementOptionTypeDescription fOptionsDescription)1158 {1159 m_fOptionsDescription = fOptionsDescription;1160 m_pRoot->rebuildGroup();1161 m_pContextMenu->updateOptionStates(DetailsElementType_Description);1162 }1163 1164 void UIDetailsModel::sltHandleViewResize()1165 {1166 updateLayout();1167 }1168 1169 void UIDetailsModel::sltHandleSlidingStarted()1170 {1171 m_pRoot->stopBuildingGroup();1172 }1173 1174 void UIDetailsModel::sltHandleToggleStarted()1175 {1176 m_pRoot->stopBuildingGroup();1177 }1178 1179 void UIDetailsModel::sltHandleToggleFinished()1180 {1181 m_pRoot->rebuildGroup();1182 }1183 1184 void UIDetailsModel::sltHandleExtraDataCategoriesChange()1185 {1186 loadDetailsCategories();1187 m_pContextMenu->updateCategoryStates();1188 m_pRoot->rebuildGroup();1189 }1190 1191 void UIDetailsModel::sltHandleExtraDataOptionsChange(DetailsElementType enmType)1192 {1193 loadDetailsOptions(enmType);1194 m_pContextMenu->updateOptionStates(enmType);1195 m_pRoot->rebuildGroup();1196 }1197 1198 bool UIDetailsModel::eventFilter(QObject *pObject, QEvent *pEvent)1199 {1200 /* Handle allowed context-menu events: */1201 if (pObject == scene() && pEvent->type() == QEvent::GraphicsSceneContextMenu)1202 return processContextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent*>(pEvent));1203 1204 /* Call to base-class: */1205 return QObject::eventFilter(pObject, pEvent);1206 }1207 1208 void UIDetailsModel::sltToggleElements(DetailsElementType type, bool fToggled)1209 {1210 /* Make sure it is not started yet: */1211 if (m_pAnimationCallback)1212 return;1213 1214 /* Prepare/configure animation callback: */1215 m_pAnimationCallback = new UIDetailsElementAnimationCallback(this, type, fToggled);1216 connect(m_pAnimationCallback, SIGNAL(sigAllAnimationFinished(DetailsElementType, bool)),1217 this, SLOT(sltToggleAnimationFinished(DetailsElementType, bool)), Qt::QueuedConnection);1218 /* For each the set of the group: */1219 foreach (UIDetailsItem *pSetItem, m_pRoot->items())1220 {1221 /* For each the element of the set: */1222 foreach (UIDetailsItem *pElementItem, pSetItem->items())1223 {1224 /* Get each element: */1225 UIDetailsElement *pElement = pElementItem->toElement();1226 /* Check if this element is of required type: */1227 if (pElement->elementType() == type)1228 {1229 if (fToggled && pElement->isClosed())1230 {1231 m_pAnimationCallback->addNotifier(pElement);1232 pElement->open();1233 }1234 else if (!fToggled && pElement->isOpened())1235 {1236 m_pAnimationCallback->addNotifier(pElement);1237 pElement->close();1238 }1239 }1240 }1241 }1242 /* Update layout: */1243 updateLayout();1244 }1245 1246 void UIDetailsModel::sltToggleAnimationFinished(DetailsElementType enmType, bool fToggled)1247 {1248 /* Cleanup animation callback: */1249 delete m_pAnimationCallback;1250 m_pAnimationCallback = 0;1251 1252 /* Mark animation finished: */1253 foreach (UIDetailsItem *pSetItem, m_pRoot->items())1254 {1255 foreach (UIDetailsItem *pElementItem, pSetItem->items())1256 {1257 UIDetailsElement *pElement = pElementItem->toElement();1258 if (pElement->elementType() == enmType)1259 pElement->markAnimationFinished();1260 }1261 }1262 /* Update layout: */1263 updateLayout();1264 1265 /* Update element open/close status: */1266 if (m_categories.contains(enmType))1267 m_categories[enmType] = fToggled;1268 }1269 1270 void UIDetailsModel::prepare()1271 {1272 /* Prepare things: */1273 prepareScene();1274 prepareRoot();1275 prepareContextMenu();1276 loadSettings();1277 }1278 1279 void UIDetailsModel::prepareScene()1280 {1281 m_pScene = new QGraphicsScene(this);1282 if (m_pScene)1283 m_pScene->installEventFilter(this);1284 }1285 1286 void UIDetailsModel::prepareRoot()1287 {1288 m_pRoot = new UIDetailsGroup(scene());1289 }1290 1291 void UIDetailsModel::prepareContextMenu()1292 {1293 m_pContextMenu = new UIDetailsContextMenu(this);1294 }1295 1296 void UIDetailsModel::loadSettings()1297 {1298 loadDetailsCategories();1299 loadDetailsOptions();1300 }1301 1302 void UIDetailsModel::loadDetailsCategories()1303 {1304 m_categories = gEDataManager->selectorWindowDetailsElements();1305 m_pContextMenu->updateCategoryStates();1306 }1307 1308 void UIDetailsModel::loadDetailsOptions(DetailsElementType enmType /* = DetailsElementType_Invalid */)1309 {1310 /* We will handle DetailsElementType_Invalid as a request to load everything. */1311 1312 if (enmType == DetailsElementType_General || enmType == DetailsElementType_Invalid)1313 {1314 m_fOptionsGeneral = UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Invalid;1315 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_General))1316 {1317 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral enmOption =1318 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>(strOption);1319 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Invalid)1320 m_fOptionsGeneral = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>(m_fOptionsGeneral | enmOption);1321 }1322 if (m_fOptionsGeneral == UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Invalid)1323 m_fOptionsGeneral = UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Default;1324 }1325 1326 if (enmType == DetailsElementType_System || enmType == DetailsElementType_Invalid)1327 {1328 m_fOptionsSystem = UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Invalid;1329 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_System))1330 {1331 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem enmOption =1332 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>(strOption);1333 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Invalid)1334 m_fOptionsSystem = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>(m_fOptionsSystem | enmOption);1335 }1336 if (m_fOptionsSystem == UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Invalid)1337 m_fOptionsSystem = UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Default;1338 }1339 1340 if (enmType == DetailsElementType_Display || enmType == DetailsElementType_Invalid)1341 {1342 m_fOptionsDisplay = UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Invalid;1343 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_Display))1344 {1345 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay enmOption =1346 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>(strOption);1347 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Invalid)1348 m_fOptionsDisplay = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>(m_fOptionsDisplay | enmOption);1349 }1350 if (m_fOptionsDisplay == UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Invalid)1351 m_fOptionsDisplay = UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Default;1352 }1353 1354 if (enmType == DetailsElementType_Storage || enmType == DetailsElementType_Invalid)1355 {1356 m_fOptionsStorage = UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Invalid;1357 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_Storage))1358 {1359 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage enmOption =1360 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>(strOption);1361 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Invalid)1362 m_fOptionsStorage = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>(m_fOptionsStorage | enmOption);1363 }1364 if (m_fOptionsStorage == UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Invalid)1365 m_fOptionsStorage = UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Default;1366 }1367 1368 if (enmType == DetailsElementType_Audio || enmType == DetailsElementType_Invalid)1369 {1370 m_fOptionsAudio = UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Invalid;1371 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_Audio))1372 {1373 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio enmOption =1374 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>(strOption);1375 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Invalid)1376 m_fOptionsAudio = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>(m_fOptionsAudio | enmOption);1377 }1378 if (m_fOptionsAudio == UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Invalid)1379 m_fOptionsAudio = UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Default;1380 }1381 1382 if (enmType == DetailsElementType_Network || enmType == DetailsElementType_Invalid)1383 {1384 m_fOptionsNetwork = UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid;1385 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_Network))1386 {1387 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork enmOption =1388 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>(strOption);1389 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid)1390 m_fOptionsNetwork = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>(m_fOptionsNetwork | enmOption);1391 }1392 if (m_fOptionsNetwork == UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid)1393 m_fOptionsNetwork = UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Default;1394 }1395 1396 if (enmType == DetailsElementType_Serial || enmType == DetailsElementType_Invalid)1397 {1398 m_fOptionsSerial = UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Invalid;1399 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_Serial))1400 {1401 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial enmOption =1402 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>(strOption);1403 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Invalid)1404 m_fOptionsSerial = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>(m_fOptionsSerial | enmOption);1405 }1406 if (m_fOptionsSerial == UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Invalid)1407 m_fOptionsSerial = UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Default;1408 }1409 1410 if (enmType == DetailsElementType_USB || enmType == DetailsElementType_Invalid)1411 {1412 m_fOptionsUsb = UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Invalid;1413 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_USB))1414 {1415 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb enmOption =1416 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>(strOption);1417 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Invalid)1418 m_fOptionsUsb = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>(m_fOptionsUsb | enmOption);1419 }1420 if (m_fOptionsUsb == UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Invalid)1421 m_fOptionsUsb = UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Default;1422 }1423 1424 if (enmType == DetailsElementType_SF || enmType == DetailsElementType_Invalid)1425 {1426 m_fOptionsSharedFolders = UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Invalid;1427 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_SF))1428 {1429 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders enmOption =1430 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>(strOption);1431 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Invalid)1432 m_fOptionsSharedFolders = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>(m_fOptionsSharedFolders | enmOption);1433 }1434 if (m_fOptionsSharedFolders == UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Invalid)1435 m_fOptionsSharedFolders = UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Default;1436 }1437 1438 if (enmType == DetailsElementType_UI || enmType == DetailsElementType_Invalid)1439 {1440 m_fOptionsUserInterface = UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Invalid;1441 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_UI))1442 {1443 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface enmOption =1444 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>(strOption);1445 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Invalid)1446 m_fOptionsUserInterface = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>(m_fOptionsUserInterface | enmOption);1447 }1448 if (m_fOptionsUserInterface == UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Invalid)1449 m_fOptionsUserInterface = UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Default;1450 }1451 1452 if (enmType == DetailsElementType_Description || enmType == DetailsElementType_Invalid)1453 {1454 m_fOptionsDescription = UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Invalid;1455 foreach (const QString &strOption, gEDataManager->vboxManagerDetailsPaneElementOptions(DetailsElementType_Description))1456 {1457 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription enmOption =1458 gpConverter->fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(strOption);1459 if (enmOption != UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Invalid)1460 m_fOptionsDescription = static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(m_fOptionsDescription | enmOption);1461 }1462 if (m_fOptionsDescription == UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Invalid)1463 m_fOptionsDescription = UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Default;1464 }1465 1466 m_pContextMenu->updateOptionStates();1467 }1468 1469 void UIDetailsModel::saveDetailsOptions()1470 {1471 /* We will use that one for all the options fetching: */1472 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;1473 int iEnumIndex = -1;1474 1475 /* General options: */1476 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeGeneral");1477 if (iEnumIndex != -1)1478 {1479 bool fDefault = true;1480 QStringList options;1481 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1482 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1483 {1484 /* Prepare current option type: */1485 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral enmOptionType =1486 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1487 /* Skip invalid and default types: */1488 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Invalid1489 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Default)1490 continue;1491 /* If option type enabled: */1492 if (m_fOptionsGeneral & enmOptionType)1493 {1494 /* Add it to the list: */1495 options << gpConverter->toInternalString(enmOptionType);1496 /* Make sure item is included by default: */1497 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Default & enmOptionType))1498 fDefault = false;1499 }1500 /* If option type disabled: */1501 else1502 {1503 /* Make sure item is excluded by default: */1504 if (UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Default & enmOptionType)1505 fDefault = false;1506 }1507 /* Save options: */1508 if (!fDefault)1509 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_General, options);1510 else1511 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_General, QStringList());1512 }1513 }1514 1515 /* System options: */1516 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeSystem");1517 if (iEnumIndex != -1)1518 {1519 bool fDefault = true;1520 QStringList options;1521 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1522 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1523 {1524 /* Prepare current option type: */1525 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem enmOptionType =1526 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1527 /* Skip invalid and default types: */1528 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Invalid1529 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Default)1530 continue;1531 /* If option type enabled: */1532 if (m_fOptionsSystem & enmOptionType)1533 {1534 /* Add it to the list: */1535 options << gpConverter->toInternalString(enmOptionType);1536 /* Make sure item is included by default: */1537 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Default & enmOptionType))1538 fDefault = false;1539 }1540 /* If option type disabled: */1541 else1542 {1543 /* Make sure item is excluded by default: */1544 if (UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Default & enmOptionType)1545 fDefault = false;1546 }1547 /* Save options: */1548 if (!fDefault)1549 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_System, options);1550 else1551 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_System, QStringList());1552 }1553 }1554 1555 /* Display options: */1556 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeDisplay");1557 if (iEnumIndex != -1)1558 {1559 bool fDefault = true;1560 QStringList options;1561 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1562 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1563 {1564 /* Prepare current option type: */1565 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay enmOptionType =1566 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1567 /* Skip invalid and default types: */1568 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Invalid1569 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Default)1570 continue;1571 /* If option type enabled: */1572 if (m_fOptionsDisplay & enmOptionType)1573 {1574 /* Add it to the list: */1575 options << gpConverter->toInternalString(enmOptionType);1576 /* Make sure item is included by default: */1577 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Default & enmOptionType))1578 fDefault = false;1579 }1580 /* If option type disabled: */1581 else1582 {1583 /* Make sure item is excluded by default: */1584 if (UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Default & enmOptionType)1585 fDefault = false;1586 }1587 /* Save options: */1588 if (!fDefault)1589 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Display, options);1590 else1591 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Display, QStringList());1592 }1593 }1594 1595 /* Storage options: */1596 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeStorage");1597 if (iEnumIndex != -1)1598 {1599 bool fDefault = true;1600 QStringList options;1601 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1602 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1603 {1604 /* Prepare current option type: */1605 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage enmOptionType =1606 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1607 /* Skip invalid and default types: */1608 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Invalid1609 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Default)1610 continue;1611 /* If option type enabled: */1612 if (m_fOptionsStorage & enmOptionType)1613 {1614 /* Add it to the list: */1615 options << gpConverter->toInternalString(enmOptionType);1616 /* Make sure item is included by default: */1617 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Default & enmOptionType))1618 fDefault = false;1619 }1620 /* If option type disabled: */1621 else1622 {1623 /* Make sure item is excluded by default: */1624 if (UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Default & enmOptionType)1625 fDefault = false;1626 }1627 /* Save options: */1628 if (!fDefault)1629 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Storage, options);1630 else1631 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Storage, QStringList());1632 }1633 }1634 1635 /* Audio options: */1636 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeAudio");1637 if (iEnumIndex != -1)1638 {1639 bool fDefault = true;1640 QStringList options;1641 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1642 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1643 {1644 /* Prepare current option type: */1645 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio enmOptionType =1646 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1647 /* Skip invalid and default types: */1648 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Invalid1649 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Default)1650 continue;1651 /* If option type enabled: */1652 if (m_fOptionsAudio & enmOptionType)1653 {1654 /* Add it to the list: */1655 options << gpConverter->toInternalString(enmOptionType);1656 /* Make sure item is included by default: */1657 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Default & enmOptionType))1658 fDefault = false;1659 }1660 /* If option type disabled: */1661 else1662 {1663 /* Make sure item is excluded by default: */1664 if (UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Default & enmOptionType)1665 fDefault = false;1666 }1667 /* Save options: */1668 if (!fDefault)1669 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Audio, options);1670 else1671 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Audio, QStringList());1672 }1673 }1674 1675 /* Network options: */1676 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeNetwork");1677 if (iEnumIndex != -1)1678 {1679 bool fDefault = true;1680 QStringList options;1681 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1682 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1683 {1684 /* Prepare current option type: */1685 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork enmOptionType =1686 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1687 /* Skip invalid and default types: */1688 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid1689 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Default)1690 continue;1691 /* If option type enabled: */1692 if (m_fOptionsNetwork & enmOptionType)1693 {1694 /* Add it to the list: */1695 options << gpConverter->toInternalString(enmOptionType);1696 /* Make sure item is included by default: */1697 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Default & enmOptionType))1698 fDefault = false;1699 }1700 /* If option type disabled: */1701 else1702 {1703 /* Make sure item is excluded by default: */1704 if (UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Default & enmOptionType)1705 fDefault = false;1706 }1707 /* Save options: */1708 if (!fDefault)1709 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Network, options);1710 else1711 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Network, QStringList());1712 }1713 }1714 1715 /* Serial options: */1716 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeSerial");1717 if (iEnumIndex != -1)1718 {1719 bool fDefault = true;1720 QStringList options;1721 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1722 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1723 {1724 /* Prepare current option type: */1725 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial enmOptionType =1726 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1727 /* Skip invalid and default types: */1728 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Invalid1729 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Default)1730 continue;1731 /* If option type enabled: */1732 if (m_fOptionsSerial & enmOptionType)1733 {1734 /* Add it to the list: */1735 options << gpConverter->toInternalString(enmOptionType);1736 /* Make sure item is included by default: */1737 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Default & enmOptionType))1738 fDefault = false;1739 }1740 /* If option type disabled: */1741 else1742 {1743 /* Make sure item is excluded by default: */1744 if (UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Default & enmOptionType)1745 fDefault = false;1746 }1747 /* Save options: */1748 if (!fDefault)1749 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Serial, options);1750 else1751 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Serial, QStringList());1752 }1753 }1754 1755 /* Usb options: */1756 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeUsb");1757 if (iEnumIndex != -1)1758 {1759 bool fDefault = true;1760 QStringList options;1761 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1762 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1763 {1764 /* Prepare current option type: */1765 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb enmOptionType =1766 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1767 /* Skip invalid and default types: */1768 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Invalid1769 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Default)1770 continue;1771 /* If option type enabled: */1772 if (m_fOptionsUsb & enmOptionType)1773 {1774 /* Add it to the list: */1775 options << gpConverter->toInternalString(enmOptionType);1776 /* Make sure item is included by default: */1777 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Default & enmOptionType))1778 fDefault = false;1779 }1780 /* If option type disabled: */1781 else1782 {1783 /* Make sure item is excluded by default: */1784 if (UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Default & enmOptionType)1785 fDefault = false;1786 }1787 /* Save options: */1788 if (!fDefault)1789 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_USB, options);1790 else1791 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_USB, QStringList());1792 }1793 }1794 1795 /* SharedFolders options: */1796 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeSharedFolders");1797 if (iEnumIndex != -1)1798 {1799 bool fDefault = true;1800 QStringList options;1801 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1802 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1803 {1804 /* Prepare current option type: */1805 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders enmOptionType =1806 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1807 /* Skip invalid and default types: */1808 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Invalid1809 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Default)1810 continue;1811 /* If option type enabled: */1812 if (m_fOptionsSharedFolders & enmOptionType)1813 {1814 /* Add it to the list: */1815 options << gpConverter->toInternalString(enmOptionType);1816 /* Make sure item is included by default: */1817 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Default & enmOptionType))1818 fDefault = false;1819 }1820 /* If option type disabled: */1821 else1822 {1823 /* Make sure item is excluded by default: */1824 if (UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Default & enmOptionType)1825 fDefault = false;1826 }1827 /* Save options: */1828 if (!fDefault)1829 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_SF, options);1830 else1831 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_SF, QStringList());1832 }1833 }1834 1835 /* UserInterface options: */1836 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeUserInterface");1837 if (iEnumIndex != -1)1838 {1839 bool fDefault = true;1840 QStringList options;1841 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1842 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1843 {1844 /* Prepare current option type: */1845 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface enmOptionType =1846 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1847 /* Skip invalid and default types: */1848 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Invalid1849 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Default)1850 continue;1851 /* If option type enabled: */1852 if (m_fOptionsUserInterface & enmOptionType)1853 {1854 /* Add it to the list: */1855 options << gpConverter->toInternalString(enmOptionType);1856 /* Make sure item is included by default: */1857 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Default & enmOptionType))1858 fDefault = false;1859 }1860 /* If option type disabled: */1861 else1862 {1863 /* Make sure item is excluded by default: */1864 if (UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Default & enmOptionType)1865 fDefault = false;1866 }1867 /* Save options: */1868 if (!fDefault)1869 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_UI, options);1870 else1871 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_UI, QStringList());1872 }1873 }1874 1875 /* Description options: */1876 iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeDescription");1877 if (iEnumIndex != -1)1878 {1879 bool fDefault = true;1880 QStringList options;1881 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);1882 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)1883 {1884 /* Prepare current option type: */1885 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription enmOptionType =1886 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));1887 /* Skip invalid and default types: */1888 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Invalid1889 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Default)1890 continue;1891 /* If option type enabled: */1892 if (m_fOptionsDescription & enmOptionType)1893 {1894 /* Add it to the list: */1895 options << gpConverter->toInternalString(enmOptionType);1896 /* Make sure item is included by default: */1897 if (!(UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Default & enmOptionType))1898 fDefault = false;1899 }1900 /* If option type disabled: */1901 else1902 {1903 /* Make sure item is excluded by default: */1904 if (UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Default & enmOptionType)1905 fDefault = false;1906 }1907 /* Save options: */1908 if (!fDefault)1909 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Description, options);1910 else1911 gEDataManager->setVBoxManagerDetailsPaneElementOptions(DetailsElementType_Description, QStringList());1912 }1913 }1914 }1915 1916 void UIDetailsModel::saveDetailsCategories()1917 {1918 gEDataManager->setSelectorWindowDetailsElements(m_categories);1919 }1920 1921 void UIDetailsModel::saveSettings()1922 {1923 saveDetailsOptions();1924 saveDetailsCategories();1925 }1926 1927 void UIDetailsModel::cleanupContextMenu()1928 {1929 delete m_pContextMenu;1930 m_pContextMenu = 0;1931 }1932 1933 void UIDetailsModel::cleanupRoot()1934 {1935 delete m_pRoot;1936 m_pRoot = 0;1937 }1938 1939 void UIDetailsModel::cleanupScene()1940 {1941 delete m_pScene;1942 m_pScene = 0;1943 }1944 1945 void UIDetailsModel::cleanup()1946 {1947 /* Cleanup things: */1948 saveSettings();1949 cleanupContextMenu();1950 cleanupRoot();1951 cleanupScene();1952 }1953 1954 bool UIDetailsModel::processContextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent)1955 {1956 /* Pass preview context menu instead: */1957 if (QGraphicsItem *pItem = itemAt(pEvent->scenePos()))1958 if (pItem->type() == UIDetailsItemType_Preview)1959 return false;1960 1961 /* Adjust the menu then show it: */1962 m_pContextMenu->resize(m_pContextMenu->minimumSizeHint());1963 m_pContextMenu->move(pEvent->screenPos());1964 m_pContextMenu->show();1965 1966 /* Filter: */1967 return true;1968 }1969 1970 1971 /*********************************************************************************************************************************1972 * Class UIDetailsElementAnimationCallback implementation. *1973 *********************************************************************************************************************************/1974 1975 UIDetailsElementAnimationCallback::UIDetailsElementAnimationCallback(QObject *pParent, DetailsElementType enmType, bool fToggled)1976 : QObject(pParent)1977 , m_enmType(enmType)1978 , m_fToggled(fToggled)1979 {1980 }1981 1982 void UIDetailsElementAnimationCallback::addNotifier(UIDetailsElement *pItem)1983 {1984 /* Connect notifier: */1985 connect(pItem, &UIDetailsElement::sigToggleElementFinished,1986 this, &UIDetailsElementAnimationCallback::sltAnimationFinished);1987 /* Remember notifier: */1988 m_notifiers << pItem;1989 }1990 1991 void UIDetailsElementAnimationCallback::sltAnimationFinished()1992 {1993 /* Determine notifier: */1994 UIDetailsElement *pItem = qobject_cast<UIDetailsElement*>(sender());1995 /* Disconnect notifier: */1996 disconnect(pItem, &UIDetailsElement::sigToggleElementFinished,1997 this, &UIDetailsElementAnimationCallback::sltAnimationFinished);1998 /* Remove notifier: */1999 m_notifiers.removeAll(pItem);2000 /* Check if we finished: */2001 if (m_notifiers.isEmpty())2002 emit sigAllAnimationFinished(m_enmType, m_fToggled);2003 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsContextMenu.h
r75636 r75640 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIDetails Modelclass declaration.3 * VBox Qt GUI - UIDetailsContextMenu class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef ___UIDetailsModel_h___ 19 #define ___UIDetailsModel_h___ 20 21 /* Qt includes: */ 22 #include <QMap> 23 #include <QObject> 24 #include <QPointer> 25 #include <QSet> 18 #ifndef ___UIDetailsContextMenu_h___ 19 #define ___UIDetailsContextMenu_h___ 26 20 27 21 /* GUI includes: */ … … 29 23 #include "UIExtraDataDefs.h" 30 24 31 /* COM includes: */32 #include "COMEnums.h"33 34 25 /* Forward declaration: */ 35 class QGraphicsItem;36 class QGraphicsScene;37 class QGraphicsSceneContextMenuEvent;38 class QGraphicsView;39 26 class QListWidget; 40 27 class QListWidgetItem; 41 class UIVirtualMachineItem;42 class UIDetails;43 class UIDetailsElement;44 class UIDetailsElementAnimationCallback;45 class UIDetailsGroup;46 class UIDetailsItem;47 28 class UIDetailsModel; 48 49 29 50 30 /** QWidget subclass used as Details pane context menu. */ … … 122 102 }; 123 103 124 125 /** QObject sub-class used as graphics details model. */ 126 class UIDetailsModel : public QObject 127 { 128 Q_OBJECT; 129 130 signals: 131 132 /** Notifies listeners about model root item @a iMinimumWidthHint changed. */ 133 void sigRootItemMinimumWidthHintChanged(int iMinimumWidthHint); 134 /** Notifies listeners about model root item @a iMinimumHeightHint changed. */ 135 void sigRootItemMinimumHeightHintChanged(int iMinimumHeightHint); 136 137 /** Notifies listeners about element link clicked. 138 * @param strCategory Brings details element category. 139 * @param strControl Brings settings control to select. 140 * @param uId Brings ID of the machine details referring. */ 141 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QUuid &uId); 142 143 public: 144 145 /** Constructs a details model passing @a pParent to the base-class. 146 * @param pParent Brings the details container to embed into. */ 147 UIDetailsModel(UIDetails *pParent); 148 /** Destructs a details model. */ 149 virtual ~UIDetailsModel() /* override */; 150 151 /** Returns graphics scene this model belongs to. */ 152 QGraphicsScene *scene() const; 153 /** Returns paint device this model belongs to. */ 154 QGraphicsView *paintDevice() const; 155 156 /** Returns graphics item as certain @a position. */ 157 QGraphicsItem *itemAt(const QPointF &position) const; 158 159 /** Returns the details pane reference. */ 160 UIDetails *details() const { return m_pDetails; } 161 162 /** Returns the root item instance. */ 163 UIDetailsItem *root() const; 164 165 /** Updates layout by positioning items manually. */ 166 void updateLayout(); 167 168 /** Defines virtual machine @a items for this model to reflect. */ 169 void setItems(const QList<UIVirtualMachineItem*> &items); 170 171 /** Returns the details categories. */ 172 const QMap<DetailsElementType, bool> &categories() const { return m_categories; } 173 /** Defines the details @a categories. */ 174 void setCategories(const QMap<DetailsElementType, bool> &categories); 175 176 /** Returns options for General element. */ 177 UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral optionsGeneral() const { return m_fOptionsGeneral; } 178 /** Defines @a fOptions for General element. */ 179 void setOptionsGeneral(UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral fOptions); 180 181 /** Returns options for System element. */ 182 UIExtraDataMetaDefs::DetailsElementOptionTypeSystem optionsSystem() const { return m_fOptionsSystem; } 183 /** Defines @a fOptions for System element. */ 184 void setOptionsSystem(UIExtraDataMetaDefs::DetailsElementOptionTypeSystem fOptions); 185 186 /** Returns options for Display element. */ 187 UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay optionsDisplay() const { return m_fOptionsDisplay; } 188 /** Defines @a fOptions for Display element. */ 189 void setOptionsDisplay(UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay fOptions); 190 191 /** Returns options for Storage element. */ 192 UIExtraDataMetaDefs::DetailsElementOptionTypeStorage optionsStorage() const { return m_fOptionsStorage; } 193 /** Defines @a fOptions for Storage element. */ 194 void setOptionsStorage(UIExtraDataMetaDefs::DetailsElementOptionTypeStorage fOptions); 195 196 /** Returns options for Audio element. */ 197 UIExtraDataMetaDefs::DetailsElementOptionTypeAudio optionsAudio() const { return m_fOptionsAudio; } 198 /** Defines @a fOptions for Audio element. */ 199 void setOptionsAudio(UIExtraDataMetaDefs::DetailsElementOptionTypeAudio fOptions); 200 201 /** Returns options for Network element. */ 202 UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork optionsNetwork() const { return m_fOptionsNetwork; } 203 /** Defines @a fOptions for Network element. */ 204 void setOptionsNetwork(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork fOptions); 205 206 /** Returns options for Serial element. */ 207 UIExtraDataMetaDefs::DetailsElementOptionTypeSerial optionsSerial() const { return m_fOptionsSerial; } 208 /** Defines @a fOptions for Serial element. */ 209 void setOptionsSerial(UIExtraDataMetaDefs::DetailsElementOptionTypeSerial fOptions); 210 211 /** Returns options for Usb element. */ 212 UIExtraDataMetaDefs::DetailsElementOptionTypeUsb optionsUsb() const { return m_fOptionsUsb; } 213 /** Defines @a fOptions for Usb element. */ 214 void setOptionsUsb(UIExtraDataMetaDefs::DetailsElementOptionTypeUsb fOptions); 215 216 /** Returns options for Shared Folders element. */ 217 UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders optionsSharedFolders() const { return m_fOptionsSharedFolders; } 218 /** Defines @a fOptions for Shared Folders element. */ 219 void setOptionsSharedFolders(UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders fOptions); 220 221 /** Returns options for User Interface element. */ 222 UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface optionsUserInterface() const { return m_fOptionsUserInterface; } 223 /** Defines @a fOptions for User Interface element. */ 224 void setOptionsUserInterface(UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface fOptions); 225 226 /** Returns options for Description element. */ 227 UIExtraDataMetaDefs::DetailsElementOptionTypeDescription optionsDescription() const { return m_fOptionsDescription; } 228 /** Defines @a fOptions for Description element. */ 229 void setOptionsDescription(UIExtraDataMetaDefs::DetailsElementOptionTypeDescription fOptions); 230 231 public slots: 232 233 /** Handle details view resize. */ 234 void sltHandleViewResize(); 235 236 /** Handles chooser pane signal about item sliding started. */ 237 void sltHandleSlidingStarted(); 238 /** Handles chooser pane signal about group toggle started. */ 239 void sltHandleToggleStarted(); 240 /** Handles chooser pane signal about group toggle finished. */ 241 void sltHandleToggleFinished(); 242 243 /** Handle extra-data categories change. */ 244 void sltHandleExtraDataCategoriesChange(); 245 /** Handle extra-data options change for category of certain @a enmType. */ 246 void sltHandleExtraDataOptionsChange(DetailsElementType enmType); 247 248 protected: 249 250 /** Preprocesses any Qt @a pEvent for passed @a pObject. */ 251 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 252 253 private slots: 254 255 /** Handles request to start toggle details element of certain @a enmType, making element @a fToggled. */ 256 void sltToggleElements(DetailsElementType type, bool fToggled); 257 /** Handles sigal about details element of certain @a enmType toggling finished, making element @a fToggled. */ 258 void sltToggleAnimationFinished(DetailsElementType type, bool fToggled); 259 260 private: 261 262 /** @name Prepare/Cleanup cascade. 263 * @{ */ 264 /** Prepares all. */ 265 void prepare(); 266 /** Prepares scene. */ 267 void prepareScene(); 268 /** Prepares root. */ 269 void prepareRoot(); 270 /** Prepares context-menu. */ 271 void prepareContextMenu(); 272 /** Loads settings. */ 273 void loadSettings(); 274 /** Loads details categories. */ 275 void loadDetailsCategories(); 276 /** Loads details options for certain category @a enmType. 277 * @note enmType equal to DetailsElementType_Invalid means load everything. */ 278 void loadDetailsOptions(DetailsElementType enmType = DetailsElementType_Invalid); 279 280 /** Saves details options. */ 281 void saveDetailsOptions(); 282 /** Saves details categories. */ 283 void saveDetailsCategories(); 284 /** Saves settings. */ 285 void saveSettings(); 286 /** Cleanups context-menu. */ 287 void cleanupContextMenu(); 288 /** Cleanups root. */ 289 void cleanupRoot(); 290 /** Cleanups scene. */ 291 void cleanupScene(); 292 /** Cleanups all. */ 293 void cleanup(); 294 /** @} */ 295 296 /** Performs handling for allowed context menu @a pEvent. */ 297 bool processContextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent); 298 299 /** Holds the details reference. */ 300 UIDetails *m_pDetails; 301 302 /** Holds the graphics scene reference. */ 303 QGraphicsScene *m_pScene; 304 /** Holds the root element instance. */ 305 UIDetailsGroup *m_pRoot; 306 /** Holds the element animation callback instance. */ 307 UIDetailsElementAnimationCallback *m_pAnimationCallback; 308 309 /** Holds the details categories. */ 310 QMap<DetailsElementType, bool> m_categories; 311 312 /** Holds the options for General element. */ 313 UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral m_fOptionsGeneral; 314 /** Holds the options for System element. */ 315 UIExtraDataMetaDefs::DetailsElementOptionTypeSystem m_fOptionsSystem; 316 /** Holds the options for Display element. */ 317 UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay m_fOptionsDisplay; 318 /** Holds the options for Storage element. */ 319 UIExtraDataMetaDefs::DetailsElementOptionTypeStorage m_fOptionsStorage; 320 /** Holds the options for Audio element. */ 321 UIExtraDataMetaDefs::DetailsElementOptionTypeAudio m_fOptionsAudio; 322 /** Holds the options for Network element. */ 323 UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork m_fOptionsNetwork; 324 /** Holds the options for Serial element. */ 325 UIExtraDataMetaDefs::DetailsElementOptionTypeSerial m_fOptionsSerial; 326 /** Holds the options for Usb element. */ 327 UIExtraDataMetaDefs::DetailsElementOptionTypeUsb m_fOptionsUsb; 328 /** Holds the options for Shared Folders element. */ 329 UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders m_fOptionsSharedFolders; 330 /** Holds the options for User Interface element. */ 331 UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface m_fOptionsUserInterface; 332 /** Holds the options for Description element. */ 333 UIExtraDataMetaDefs::DetailsElementOptionTypeDescription m_fOptionsDescription; 334 335 /** Holds the context-menu instance. */ 336 UIDetailsContextMenu *m_pContextMenu; 337 }; 338 339 340 /** QObject sub-class used as details element animation callback. */ 341 class UIDetailsElementAnimationCallback : public QObject 342 { 343 Q_OBJECT; 344 345 signals: 346 347 /** Notifies listeners about all animations finished. 348 * @param enmType Brings the type of element item which was animated. 349 * @param fToggled Brigns whether elements being toggled to be closed or opened. */ 350 void sigAllAnimationFinished(DetailsElementType enmType, bool fToggled); 351 352 public: 353 354 /** Constructors details element animation callback passing @a pParent to the base-class. 355 * @param enmType Brings the type of element item which was animated. 356 * @param fToggled Brigns whether elements being toggled to be closed or opened. */ 357 UIDetailsElementAnimationCallback(QObject *pParent, DetailsElementType enmType, bool fToggled); 358 359 /** Adds notifier for a certain details @a pItem. */ 360 void addNotifier(UIDetailsElement *pItem); 361 362 private slots: 363 364 /** Handles a signal about animation finnished. */ 365 void sltAnimationFinished(); 366 367 private: 368 369 /** Holds the list of elements which notifies this callback about completion. */ 370 QList<UIDetailsElement*> m_notifiers; 371 /** Holds the type of element item which was animated. */ 372 DetailsElementType m_enmType; 373 /** Holds whether elements being toggled to be closed or opened. */ 374 bool m_fToggled; 375 }; 376 377 378 #endif /* !___UIDetailsModel_h___ */ 104 #endif /* !___UIDetailsContextMenu_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.cpp
r75637 r75640 25 25 # include <QGraphicsSceneContextMenuEvent> 26 26 # include <QGraphicsView> 27 # include <QHBoxLayout>28 # include <QListWidget>29 27 # include <QMenu> 30 28 # include <QMetaEnum> … … 33 31 # include "UIConverter.h" 34 32 # include "UIDetails.h" 33 # include "UIDetailsContextMenu.h" 35 34 # include "UIDetailsModel.h" 36 35 # include "UIDetailsGroup.h" 37 36 # include "UIDetailsElement.h" 38 37 # include "UIExtraDataManager.h" 39 # include "UIIconPool.h"40 38 # include "VBoxGlobal.h" 41 39 42 40 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 43 44 45 /*********************************************************************************************************************************46 * Class UIDetailsContextMenu implementation. *47 *********************************************************************************************************************************/48 49 UIDetailsContextMenu::UIDetailsContextMenu(UIDetailsModel *pModel)50 : QIWithRetranslateUI2<QWidget>(0, Qt::Popup)51 , m_pModel(pModel)52 , m_pListWidgetCategories(0)53 , m_pListWidgetOptions(0)54 {55 prepare();56 }57 58 void UIDetailsContextMenu::updateCategoryStates()59 {60 /* Enumerate all the category items: */61 for (int i = 0; i < m_pListWidgetCategories->count(); ++i)62 {63 QListWidgetItem *pCategoryItem = m_pListWidgetCategories->item(i);64 if (pCategoryItem)65 {66 /* Apply check-state on per-enum basis: */67 const DetailsElementType enmCategoryType = pCategoryItem->data(DataField_Type).value<DetailsElementType>();68 pCategoryItem->setCheckState(m_pModel->categories().contains(enmCategoryType) ? Qt::Checked : Qt::Unchecked);69 }70 }71 }72 73 void UIDetailsContextMenu::updateOptionStates(DetailsElementType enmRequiredCategoryType /* = DetailsElementType_Invalid */)74 {75 /* First make sure we really have category item selected: */76 QListWidgetItem *pCategoryItem = m_pListWidgetCategories->currentItem();77 if (!pCategoryItem)78 return;79 80 /* Then acquire category type and check if it is suitable: */81 const DetailsElementType enmCategoryType = pCategoryItem->data(DataField_Type).value<DetailsElementType>();82 if (enmRequiredCategoryType == DetailsElementType_Invalid)83 enmRequiredCategoryType = enmCategoryType;84 if (enmCategoryType != enmRequiredCategoryType)85 return;86 87 /* Handle known category types: */88 switch (enmRequiredCategoryType)89 {90 case DetailsElementType_General:91 {92 /* Enumerate all the option items: */93 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)94 {95 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);96 if (pOptionItem)97 {98 /* Apply check-state on per-enum basis: */99 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral enmOptionType =100 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>();101 pOptionItem->setCheckState(m_pModel->optionsGeneral() & enmOptionType ? Qt::Checked : Qt::Unchecked);102 }103 }104 break;105 }106 case DetailsElementType_System:107 {108 /* Enumerate all the option items: */109 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)110 {111 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);112 if (pOptionItem)113 {114 /* Apply check-state on per-enum basis: */115 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem enmOptionType =116 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>();117 pOptionItem->setCheckState(m_pModel->optionsSystem() & enmOptionType ? Qt::Checked : Qt::Unchecked);118 }119 }120 break;121 }122 case DetailsElementType_Display:123 {124 /* Enumerate all the option items: */125 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)126 {127 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);128 if (pOptionItem)129 {130 /* Apply check-state on per-enum basis: */131 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay enmOptionType =132 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>();133 pOptionItem->setCheckState(m_pModel->optionsDisplay() & enmOptionType ? Qt::Checked : Qt::Unchecked);134 }135 }136 break;137 }138 case DetailsElementType_Storage:139 {140 /* Enumerate all the option items: */141 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)142 {143 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);144 if (pOptionItem)145 {146 /* Apply check-state on per-enum basis: */147 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage enmOptionType =148 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>();149 pOptionItem->setCheckState(m_pModel->optionsStorage() & enmOptionType ? Qt::Checked : Qt::Unchecked);150 }151 }152 break;153 }154 case DetailsElementType_Audio:155 {156 /* Enumerate all the option items: */157 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)158 {159 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);160 if (pOptionItem)161 {162 /* Apply check-state on per-enum basis: */163 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio enmOptionType =164 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>();165 pOptionItem->setCheckState(m_pModel->optionsAudio() & enmOptionType ? Qt::Checked : Qt::Unchecked);166 }167 }168 break;169 }170 case DetailsElementType_Network:171 {172 /* Enumerate all the option items: */173 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)174 {175 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);176 if (pOptionItem)177 {178 /* Apply check-state on per-enum basis: */179 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork enmOptionType =180 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>();181 pOptionItem->setCheckState(m_pModel->optionsNetwork() & enmOptionType ? Qt::Checked : Qt::Unchecked);182 }183 }184 break;185 }186 case DetailsElementType_Serial:187 {188 /* Enumerate all the option items: */189 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)190 {191 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);192 if (pOptionItem)193 {194 /* Apply check-state on per-enum basis: */195 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial enmOptionType =196 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>();197 pOptionItem->setCheckState(m_pModel->optionsSerial() & enmOptionType ? Qt::Checked : Qt::Unchecked);198 }199 }200 break;201 }202 case DetailsElementType_USB:203 {204 /* Enumerate all the option items: */205 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)206 {207 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);208 if (pOptionItem)209 {210 /* Apply check-state on per-enum basis: */211 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb enmOptionType =212 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>();213 pOptionItem->setCheckState(m_pModel->optionsUsb() & enmOptionType ? Qt::Checked : Qt::Unchecked);214 }215 }216 break;217 }218 case DetailsElementType_SF:219 {220 /* Enumerate all the option items: */221 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)222 {223 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);224 if (pOptionItem)225 {226 /* Apply check-state on per-enum basis: */227 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders enmOptionType =228 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>();229 pOptionItem->setCheckState(m_pModel->optionsSharedFolders() & enmOptionType ? Qt::Checked : Qt::Unchecked);230 }231 }232 break;233 }234 case DetailsElementType_UI:235 {236 /* Enumerate all the option items: */237 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)238 {239 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);240 if (pOptionItem)241 {242 /* Apply check-state on per-enum basis: */243 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface enmOptionType =244 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>();245 pOptionItem->setCheckState(m_pModel->optionsUserInterface() & enmOptionType ? Qt::Checked : Qt::Unchecked);246 }247 }248 break;249 }250 case DetailsElementType_Description:251 {252 /* Enumerate all the option items: */253 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)254 {255 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);256 if (pOptionItem)257 {258 /* Apply check-state on per-enum basis: */259 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription enmOptionType =260 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>();261 pOptionItem->setCheckState(m_pModel->optionsDescription() & enmOptionType ? Qt::Checked : Qt::Unchecked);262 }263 }264 break;265 }266 default:267 break;268 }269 }270 271 void UIDetailsContextMenu::retranslateUi()272 {273 retranslateCategories();274 retranslateOptions();275 adjustListWidgets();276 }277 278 void UIDetailsContextMenu::retranslateCategories()279 {280 /* Enumerate all the category items: */281 for (int i = 0; i < m_pListWidgetCategories->count(); ++i)282 {283 QListWidgetItem *pCategoryItem = m_pListWidgetCategories->item(i);284 if (pCategoryItem)285 {286 /* We can translate this thing on per-enum basis: */287 const DetailsElementType enmCategoryType = pCategoryItem->data(DataField_Type).value<DetailsElementType>();288 pCategoryItem->setText(gpConverter->toString(enmCategoryType));289 }290 }291 }292 293 void UIDetailsContextMenu::retranslateOptions()294 {295 /* Acquire currently selected category item: */296 QListWidgetItem *pCategoryItem = m_pListWidgetCategories->currentItem();297 if (!pCategoryItem)298 return;299 300 /* Populate currently selected category options: */301 const DetailsElementType enmCategoryType = pCategoryItem->data(DataField_Type).value<DetailsElementType>();302 switch (enmCategoryType)303 {304 case DetailsElementType_General:305 {306 /* Enumerate all the option items: */307 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)308 {309 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);310 if (pOptionItem)311 {312 /* We can translate this thing on per-enum basis: */313 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral enmOptionType =314 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>();315 pOptionItem->setText(gpConverter->toString(enmOptionType));316 }317 }318 break;319 }320 case DetailsElementType_System:321 {322 /* Enumerate all the option items: */323 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)324 {325 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);326 if (pOptionItem)327 {328 /* We can translate this thing on per-enum basis: */329 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem enmOptionType =330 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>();331 pOptionItem->setText(gpConverter->toString(enmOptionType));332 }333 }334 break;335 }336 case DetailsElementType_Display:337 {338 /* Enumerate all the option items: */339 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)340 {341 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);342 if (pOptionItem)343 {344 /* We can translate this thing on per-enum basis: */345 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay enmOptionType =346 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>();347 pOptionItem->setText(gpConverter->toString(enmOptionType));348 }349 }350 break;351 }352 case DetailsElementType_Storage:353 {354 /* Enumerate all the option items: */355 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)356 {357 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);358 if (pOptionItem)359 {360 /* We can translate this thing on per-enum basis: */361 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage enmOptionType =362 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>();363 pOptionItem->setText(gpConverter->toString(enmOptionType));364 }365 }366 break;367 }368 case DetailsElementType_Audio:369 {370 /* Enumerate all the option items: */371 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)372 {373 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);374 if (pOptionItem)375 {376 /* We can translate this thing on per-enum basis: */377 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio enmOptionType =378 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>();379 pOptionItem->setText(gpConverter->toString(enmOptionType));380 }381 }382 break;383 }384 case DetailsElementType_Network:385 {386 /* Enumerate all the option items: */387 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)388 {389 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);390 if (pOptionItem)391 {392 /* We can translate this thing on per-enum basis: */393 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork enmOptionType =394 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>();395 pOptionItem->setText(gpConverter->toString(enmOptionType));396 }397 }398 break;399 }400 case DetailsElementType_Serial:401 {402 /* Enumerate all the option items: */403 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)404 {405 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);406 if (pOptionItem)407 {408 /* We can translate this thing on per-enum basis: */409 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial enmOptionType =410 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>();411 pOptionItem->setText(gpConverter->toString(enmOptionType));412 }413 }414 break;415 }416 case DetailsElementType_USB:417 {418 /* Enumerate all the option items: */419 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)420 {421 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);422 if (pOptionItem)423 {424 /* We can translate this thing on per-enum basis: */425 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb enmOptionType =426 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>();427 pOptionItem->setText(gpConverter->toString(enmOptionType));428 }429 }430 break;431 }432 case DetailsElementType_SF:433 {434 /* Enumerate all the option items: */435 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)436 {437 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);438 if (pOptionItem)439 {440 /* We can translate this thing on per-enum basis: */441 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders enmOptionType =442 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>();443 pOptionItem->setText(gpConverter->toString(enmOptionType));444 }445 }446 break;447 }448 case DetailsElementType_UI:449 {450 /* Enumerate all the option items: */451 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)452 {453 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);454 if (pOptionItem)455 {456 /* We can translate this thing on per-enum basis: */457 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface enmOptionType =458 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>();459 pOptionItem->setText(gpConverter->toString(enmOptionType));460 }461 }462 break;463 }464 case DetailsElementType_Description:465 {466 /* Enumerate all the option items: */467 for (int i = 0; i < m_pListWidgetOptions->count(); ++i)468 {469 QListWidgetItem *pOptionItem = m_pListWidgetOptions->item(i);470 if (pOptionItem)471 {472 /* We can translate this thing on per-enum basis: */473 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription enmOptionType =474 pOptionItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>();475 pOptionItem->setText(gpConverter->toString(enmOptionType));476 }477 }478 break;479 }480 default:481 break;482 }483 }484 485 void UIDetailsContextMenu::sltCategoryItemEntered(QListWidgetItem *pItem)486 {487 /* Choose hovered item as current one: */488 m_pListWidgetCategories->setCurrentItem(pItem);489 }490 491 void UIDetailsContextMenu::sltCategoryItemClicked(QListWidgetItem *pItem)492 {493 /* Notify listeners: */494 const DetailsElementType enmCategoryType = pItem->data(DataField_Type).value<DetailsElementType>();495 496 /* Toggle element visibility status: */497 QMap<DetailsElementType, bool> categories = m_pModel->categories();498 if (categories.contains(enmCategoryType))499 categories.remove(enmCategoryType);500 else501 categories[enmCategoryType] = true;502 m_pModel->setCategories(categories);503 }504 505 void UIDetailsContextMenu::sltCategoryItemChanged(QListWidgetItem *, QListWidgetItem *)506 {507 /* Update options list: */508 populateOptions();509 updateOptionStates();510 retranslateOptions();511 }512 513 void UIDetailsContextMenu::sltOptionItemEntered(QListWidgetItem *pItem)514 {515 /* Choose hovered item as current one: */516 m_pListWidgetOptions->setCurrentItem(pItem);517 }518 519 void UIDetailsContextMenu::sltOptionItemClicked(QListWidgetItem *pItem)520 {521 /* First make sure we really have category item selected: */522 QListWidgetItem *pCategoryItem = m_pListWidgetCategories->currentItem();523 if (!pCategoryItem)524 return;525 526 /* Then acquire category type: */527 const DetailsElementType enmCategoryType = pCategoryItem->data(DataField_Type).value<DetailsElementType>();528 529 /* Handle known category types: */530 switch (enmCategoryType)531 {532 case DetailsElementType_General:533 {534 /* Toggle element visibility status: */535 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral enmOptionType =536 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>();537 m_pModel->setOptionsGeneral(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>(m_pModel->optionsGeneral() ^ enmOptionType));538 break;539 }540 case DetailsElementType_System:541 {542 /* Toggle element visibility status: */543 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem enmOptionType =544 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>();545 m_pModel->setOptionsSystem(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>(m_pModel->optionsSystem() ^ enmOptionType));546 break;547 }548 case DetailsElementType_Display:549 {550 /* Toggle element visibility status: */551 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay enmOptionType =552 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>();553 m_pModel->setOptionsDisplay(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>(m_pModel->optionsDisplay() ^ enmOptionType));554 break;555 }556 case DetailsElementType_Storage:557 {558 /* Toggle element visibility status: */559 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage enmOptionType =560 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>();561 m_pModel->setOptionsStorage(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>(m_pModel->optionsStorage() ^ enmOptionType));562 break;563 }564 case DetailsElementType_Audio:565 {566 /* Toggle element visibility status: */567 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio enmOptionType =568 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>();569 m_pModel->setOptionsAudio(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>(m_pModel->optionsAudio() ^ enmOptionType));570 break;571 }572 case DetailsElementType_Network:573 {574 /* Toggle element visibility status: */575 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork enmOptionType =576 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>();577 m_pModel->setOptionsNetwork(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>(m_pModel->optionsNetwork() ^ enmOptionType));578 break;579 }580 case DetailsElementType_Serial:581 {582 /* Toggle element visibility status: */583 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial enmOptionType =584 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>();585 m_pModel->setOptionsSerial(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>(m_pModel->optionsSerial() ^ enmOptionType));586 break;587 }588 case DetailsElementType_USB:589 {590 /* Toggle element visibility status: */591 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb enmOptionType =592 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>();593 m_pModel->setOptionsUsb(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>(m_pModel->optionsUsb() ^ enmOptionType));594 break;595 }596 case DetailsElementType_SF:597 {598 /* Toggle element visibility status: */599 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders enmOptionType =600 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>();601 m_pModel->setOptionsSharedFolders(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>(m_pModel->optionsSharedFolders() ^ enmOptionType));602 break;603 }604 case DetailsElementType_UI:605 {606 /* Toggle element visibility status: */607 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface enmOptionType =608 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>();609 m_pModel->setOptionsUserInterface(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>(m_pModel->optionsUserInterface() ^ enmOptionType));610 break;611 }612 case DetailsElementType_Description:613 {614 /* Toggle element visibility status: */615 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription enmOptionType =616 pItem->data(DataField_Type).value<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>();617 m_pModel->setOptionsDescription(static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(m_pModel->optionsDescription() ^ enmOptionType));618 break;619 }620 default:621 break;622 }623 }624 625 void UIDetailsContextMenu::prepare()626 {627 /* Create main layout: */628 QHBoxLayout *pMainLayout = new QHBoxLayout(this);629 if (pMainLayout)630 {631 pMainLayout->setContentsMargins(0, 0, 0, 0);632 pMainLayout->setSpacing(1);633 634 /* Create list of categories: */635 m_pListWidgetCategories = new QListWidget(this);636 if (m_pListWidgetCategories)637 {638 m_pListWidgetCategories->setMouseTracking(true);639 m_pListWidgetCategories->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);640 connect(m_pListWidgetCategories, &QListWidget::itemEntered,641 this, &UIDetailsContextMenu::sltCategoryItemEntered);642 connect(m_pListWidgetCategories, &QListWidget::itemClicked,643 this, &UIDetailsContextMenu::sltCategoryItemClicked);644 connect(m_pListWidgetCategories, &QListWidget::currentItemChanged,645 this, &UIDetailsContextMenu::sltCategoryItemChanged);646 pMainLayout->addWidget(m_pListWidgetCategories);647 }648 649 /* Create list of options: */650 m_pListWidgetOptions = new QListWidget(this);651 if (m_pListWidgetOptions)652 {653 m_pListWidgetOptions->setMouseTracking(true);654 m_pListWidgetOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);655 connect(m_pListWidgetOptions, &QListWidget::itemEntered,656 this, &UIDetailsContextMenu::sltOptionItemEntered);657 connect(m_pListWidgetOptions, &QListWidget::itemClicked,658 this, &UIDetailsContextMenu::sltOptionItemClicked);659 pMainLayout->addWidget(m_pListWidgetOptions);660 }661 }662 663 /* Prepare lists: */664 populateCategories();665 populateOptions();666 /* Apply language settings: */667 retranslateUi();668 }669 670 void UIDetailsContextMenu::populateCategories()671 {672 /* Clear category list initially: */673 m_pListWidgetCategories->clear();674 675 /* Enumerate all the known categories: */676 for (int i = DetailsElementType_Invalid + 1; i < DetailsElementType_Max; ++i)677 {678 /* Prepare current category type: */679 const DetailsElementType enmCategoryType = static_cast<DetailsElementType>(i);680 /* And create list-widget item of it: */681 QListWidgetItem *pCategoryItem = createCategoryItem(gpConverter->toIcon(enmCategoryType));682 if (pCategoryItem)683 {684 pCategoryItem->setData(DataField_Type, QVariant::fromValue(enmCategoryType));685 pCategoryItem->setCheckState(Qt::Unchecked);686 }687 }688 }689 690 void UIDetailsContextMenu::populateOptions()691 {692 /* Clear option list initially: */693 m_pListWidgetOptions->clear();694 695 /* Acquire currently selected category item: */696 QListWidgetItem *pCategoryItem = m_pListWidgetCategories->currentItem();697 if (!pCategoryItem)698 return;699 700 /* We will use that one for all the options fetching: */701 const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;702 703 /* Populate currently selected category options: */704 const DetailsElementType enmCategoryType = pCategoryItem->data(DataField_Type).value<DetailsElementType>();705 switch (enmCategoryType)706 {707 case DetailsElementType_General:708 {709 /* Enumerate all the known options: */710 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeGeneral");711 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);712 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)713 {714 /* Prepare current option type: */715 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral enmOptionType =716 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));717 /* Skip invalid and default types: */718 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Invalid719 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Default)720 continue;721 /* And create list-widget item of it: */722 QListWidgetItem *pOptionItem = createOptionItem();723 if (pOptionItem)724 {725 pOptionItem->setData(DataField_Type, enmOptionType);726 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));727 pOptionItem->setCheckState(Qt::Unchecked);728 }729 }730 break;731 }732 case DetailsElementType_System:733 {734 /* Enumerate all the known options: */735 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeSystem");736 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);737 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)738 {739 /* Prepare current option type: */740 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem enmOptionType =741 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSystem>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));742 /* Skip invalid and default types: */743 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Invalid744 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Default)745 continue;746 /* And create list-widget item of it: */747 QListWidgetItem *pOptionItem = createOptionItem();748 if (pOptionItem)749 {750 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));751 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));752 pOptionItem->setCheckState(Qt::Unchecked);753 }754 }755 break;756 }757 case DetailsElementType_Display:758 {759 /* Enumerate all the known options: */760 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeDisplay");761 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);762 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)763 {764 /* Prepare current option type: */765 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay enmOptionType =766 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));767 /* Skip invalid and default types: */768 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Invalid769 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Default)770 continue;771 /* And create list-widget item of it: */772 QListWidgetItem *pOptionItem = createOptionItem();773 if (pOptionItem)774 {775 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));776 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));777 pOptionItem->setCheckState(Qt::Unchecked);778 }779 }780 break;781 }782 case DetailsElementType_Storage:783 {784 /* Enumerate all the known options: */785 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeStorage");786 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);787 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)788 {789 /* Prepare current option type: */790 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage enmOptionType =791 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeStorage>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));792 /* Skip invalid and default types: */793 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Invalid794 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_Default)795 continue;796 /* And create list-widget item of it: */797 QListWidgetItem *pOptionItem = createOptionItem();798 if (pOptionItem)799 {800 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));801 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));802 pOptionItem->setCheckState(Qt::Unchecked);803 }804 }805 break;806 }807 case DetailsElementType_Audio:808 {809 /* Enumerate all the known options: */810 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeAudio");811 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);812 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)813 {814 /* Prepare current option type: */815 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio enmOptionType =816 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeAudio>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));817 /* Skip invalid and default types: */818 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Invalid819 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Default)820 continue;821 /* And create list-widget item of it: */822 QListWidgetItem *pOptionItem = createOptionItem();823 if (pOptionItem)824 {825 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));826 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));827 pOptionItem->setCheckState(Qt::Unchecked);828 }829 }830 break;831 }832 case DetailsElementType_Network:833 {834 /* Enumerate all the known options: */835 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeNetwork");836 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);837 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)838 {839 /* Prepare current option type: */840 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork enmOptionType =841 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));842 /* Skip invalid and default types: */843 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid844 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Default)845 continue;846 /* And create list-widget item of it: */847 QListWidgetItem *pOptionItem = createOptionItem();848 if (pOptionItem)849 {850 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));851 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));852 pOptionItem->setCheckState(Qt::Unchecked);853 }854 }855 break;856 }857 case DetailsElementType_Serial:858 {859 /* Enumerate all the known options: */860 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeSerial");861 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);862 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)863 {864 /* Prepare current option type: */865 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial enmOptionType =866 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSerial>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));867 /* Skip invalid and default types: */868 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Invalid869 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Default)870 continue;871 /* And create list-widget item of it: */872 QListWidgetItem *pOptionItem = createOptionItem();873 if (pOptionItem)874 {875 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));876 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));877 pOptionItem->setCheckState(Qt::Unchecked);878 }879 }880 break;881 }882 case DetailsElementType_USB:883 {884 /* Enumerate all the known options: */885 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeUsb");886 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);887 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)888 {889 /* Prepare current option type: */890 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb enmOptionType =891 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUsb>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));892 /* Skip invalid and default types: */893 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Invalid894 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Default)895 continue;896 /* And create list-widget item of it: */897 QListWidgetItem *pOptionItem = createOptionItem();898 if (pOptionItem)899 {900 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));901 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));902 pOptionItem->setCheckState(Qt::Unchecked);903 }904 }905 break;906 }907 case DetailsElementType_SF:908 {909 /* Enumerate all the known options: */910 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeSharedFolders");911 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);912 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)913 {914 /* Prepare current option type: */915 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders enmOptionType =916 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));917 /* Skip invalid and default types: */918 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Invalid919 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders_Default)920 continue;921 /* And create list-widget item of it: */922 QListWidgetItem *pOptionItem = createOptionItem();923 if (pOptionItem)924 {925 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));926 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));927 pOptionItem->setCheckState(Qt::Unchecked);928 }929 }930 break;931 }932 case DetailsElementType_UI:933 {934 /* Enumerate all the known options: */935 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeUserInterface");936 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);937 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)938 {939 /* Prepare current option type: */940 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface enmOptionType =941 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));942 /* Skip invalid and default types: */943 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Invalid944 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_Default)945 continue;946 /* And create list-widget item of it: */947 QListWidgetItem *pOptionItem = createOptionItem();948 if (pOptionItem)949 {950 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));951 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));952 pOptionItem->setCheckState(Qt::Unchecked);953 }954 }955 break;956 }957 case DetailsElementType_Description:958 {959 /* Enumerate all the known options: */960 const int iEnumIndex = smo.indexOfEnumerator("DetailsElementOptionTypeDescription");961 const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);962 for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)963 {964 /* Prepare current option type: */965 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription enmOptionType =966 static_cast<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));967 /* Skip invalid and default types: */968 if ( enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Invalid969 || enmOptionType == UIExtraDataMetaDefs::DetailsElementOptionTypeDescription_Default)970 continue;971 /* And create list-widget item of it: */972 QListWidgetItem *pOptionItem = createOptionItem();973 if (pOptionItem)974 {975 pOptionItem->setData(DataField_Type, QVariant::fromValue(enmOptionType));976 pOptionItem->setData(DataField_Name, gpConverter->toInternalString(enmOptionType));977 pOptionItem->setCheckState(Qt::Unchecked);978 }979 }980 break;981 }982 default:983 break;984 }985 }986 987 void UIDetailsContextMenu::adjustListWidgets()988 {989 /* Include frame width: */990 int iW = 2 * m_pListWidgetCategories->frameWidth();991 int iH = iW;992 993 /* Include size hints: */994 iW += m_pListWidgetCategories->sizeHintForColumn(0);995 iH += m_pListWidgetCategories->sizeHintForRow(0) * m_pListWidgetCategories->count();996 997 /* Category list size is constant, options list size is vague: */998 m_pListWidgetCategories->setFixedSize(QSize(iW, iH));999 m_pListWidgetOptions->setFixedSize(QSize(iW * 1.5, iH));1000 }1001 1002 QListWidgetItem *UIDetailsContextMenu::createCategoryItem(const QIcon &icon)1003 {1004 QListWidgetItem *pItem = new QListWidgetItem(icon, QString(), m_pListWidgetCategories);1005 if (pItem)1006 m_pListWidgetCategories->addItem(pItem);1007 return pItem;1008 }1009 1010 QListWidgetItem *UIDetailsContextMenu::createOptionItem()1011 {1012 QListWidgetItem *pItem = new QListWidgetItem(QString(), m_pListWidgetOptions);1013 if (pItem)1014 m_pListWidgetOptions->addItem(pItem);1015 return pItem;1016 }1017 41 1018 42 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.h
r75636 r75640 26 26 27 27 /* GUI includes: */ 28 #include "QIWithRetranslateUI.h"29 28 #include "UIExtraDataDefs.h" 30 29 … … 37 36 class QGraphicsSceneContextMenuEvent; 38 37 class QGraphicsView; 39 class QListWidget;40 class QListWidgetItem;41 38 class UIVirtualMachineItem; 42 39 class UIDetails; 40 class UIDetailsContextMenu; 43 41 class UIDetailsElement; 44 42 class UIDetailsElementAnimationCallback; 45 43 class UIDetailsGroup; 46 44 class UIDetailsItem; 47 class UIDetailsModel;48 49 50 /** QWidget subclass used as Details pane context menu. */51 class UIDetailsContextMenu : public QIWithRetranslateUI2<QWidget>52 {53 Q_OBJECT;54 55 public:56 57 /** Context menu data fields. */58 enum DataField59 {60 DataField_Type = Qt::UserRole + 1,61 DataField_Name = Qt::UserRole + 2,62 };63 64 /** Constructs context-menu.65 * @param pModel Brings model object reference. */66 UIDetailsContextMenu(UIDetailsModel *pModel);67 68 /** Updates category check-states. */69 void updateCategoryStates();70 /** Updates option check-states for certain @a enmRequiredCategoryType. */71 void updateOptionStates(DetailsElementType enmRequiredCategoryType = DetailsElementType_Invalid);72 73 protected:74 75 /** Handles translation event. */76 virtual void retranslateUi() /* override */;77 78 /** Handles translation event for categories list. */79 void retranslateCategories();80 /** Handles translation event for options list. */81 void retranslateOptions();82 83 private slots:84 85 /** Handles signal about category list-widget @a pItem hovered. */86 void sltCategoryItemEntered(QListWidgetItem *pItem);87 /** Handles signal about category list-widget @a pItem clicked. */88 void sltCategoryItemClicked(QListWidgetItem *pItem);89 /** Handles signal about current category list-widget @a pItem hovered. */90 void sltCategoryItemChanged(QListWidgetItem *pCurrent, QListWidgetItem *pPrevious);91 92 /** Handles signal about option list-widget @a pItem hovered. */93 void sltOptionItemEntered(QListWidgetItem *pItem);94 /** Handles signal about option list-widget @a pItem clicked. */95 void sltOptionItemClicked(QListWidgetItem *pItem);96 97 private:98 99 /** Prepares all. */100 void prepare();101 102 /** (Re)populates categories. */103 void populateCategories();104 /** (Re)populates options. */105 void populateOptions();106 107 /** Adjusts both list widgets. */108 void adjustListWidgets();109 110 /** Creates category list item with specified @a icon. */111 QListWidgetItem *createCategoryItem(const QIcon &icon);112 /** Creates option list item. */113 QListWidgetItem *createOptionItem();114 115 /** Holds the model reference. */116 UIDetailsModel *m_pModel;117 118 /** Holds the categories list instance. */119 QListWidget *m_pListWidgetCategories;120 /** Holds the options list instance. */121 QListWidget *m_pListWidgetOptions;122 };123 45 124 46
Note:
See TracChangeset
for help on using the changeset viewer.