Changeset 67969 in vbox
- Timestamp:
- Jul 14, 2017 1:12:28 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r67965 r67969 1233 1233 .arg(strLocationOld, strLocationNew), 1234 1234 formatErrorInfo(comProgress)); 1235 } 1236 1237 void UIMessageCenter::cannotChangeMediumDescription(const CMedium &comMedium, const QString &strLocation, QWidget *pParent /* = 0 */) const 1238 { 1239 error(pParent, MessageType_Error, 1240 tr("<p>Error changing the description of the disk image <b>%1</b>.</p>") 1241 .arg(strLocation), 1242 formatErrorInfo(comMedium)); 1235 1243 } 1236 1244 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r67965 r67969 247 247 void cannotMoveMediumStorage(const CMedium &comMedium, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent = 0) const; 248 248 void cannotMoveMediumStorage(const CProgress &comProgress, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent = 0) const; 249 void cannotChangeMediumDescription(const CMedium &comMedium, const QString &strLocation, QWidget *pParent = 0) const; 249 250 bool confirmMediumRelease(const UIMedium &medium, QWidget *pParent = 0) const; 250 251 bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.cpp
r67965 r67969 26 26 # include <QSlider> 27 27 # include <QStackedLayout> 28 # include <QTextEdit> 28 29 # include <QVBoxLayout> 29 30 … … 55 56 , m_pLabelLocation(0), m_pSelectorLocation(0), m_pErrorPaneLocation(0) 56 57 , m_pLabelSize(0), m_pEditorSize(0), m_pErrorPaneSize(0) 58 , m_pLabelDescription(0), m_pEditorDescription(0), m_pErrorPaneDescription(0) 57 59 , m_pButtonBox(0) 58 60 , m_pLayoutDetails(0) … … 93 95 m_pLabelLocation->setText(tr("&Location:")); 94 96 m_pLabelSize->setText(tr("&Size:")); 97 m_pLabelDescription->setText(tr("&Description:")); 95 98 96 99 /* Translate fields: */ … … 100 103 m_pSelectorLocation->setToolTip(tr("Holds the location of this medium.")); 101 104 m_pEditorSize->setToolTip(tr("Holds the size of this medium.")); 105 m_pEditorDescription->setToolTip(tr("Holds the description of this medium.")); 102 106 103 107 /* Translate button-box: */ … … 143 147 } 144 148 149 void UIMediumDetailsWidget::sltDescriptionTextChanged() 150 { 151 m_newData.m_options.m_strDescription = m_pEditorDescription->toPlainText(); 152 revalidate(m_pErrorPaneDescription); 153 updateButtonStates(); 154 } 155 145 156 void UIMediumDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton) 146 157 { … … 373 384 } 374 385 386 /* Create description label: */ 387 m_pLabelDescription = new QLabel; 388 AssertPtrReturnVoid(m_pLabelDescription); 389 { 390 /* Configure label: */ 391 m_pLabelDescription->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 392 393 /* Add into layout: */ 394 pLayoutOptions->addWidget(m_pLabelDescription, 4, 0); 395 } 396 397 /* Create description layout: */ 398 QGridLayout *pLayoutDescription = new QGridLayout; 399 AssertPtrReturnVoid(pLayoutDescription); 400 { 401 /* Configure layout: */ 402 pLayoutDescription->setContentsMargins(0, 0, 0, 0); 403 404 /* Create description editor: */ 405 m_pEditorDescription = new QTextEdit; 406 AssertPtrReturnVoid(m_pEditorDescription); 407 { 408 /* Configure editor: */ 409 m_pLabelDescription->setBuddy(m_pEditorDescription); 410 QFontMetrics fontMetrics = m_pEditorDescription->fontMetrics(); 411 QTextDocument *pTextDocument = m_pEditorDescription->document(); 412 const int iMinimumHeight = fontMetrics.lineSpacing() * 3 413 + pTextDocument->documentMargin() * 2 414 + m_pEditorDescription->frameWidth() * 2; 415 m_pEditorDescription->setMaximumHeight(iMinimumHeight); 416 connect(m_pEditorDescription, &QTextEdit::textChanged, 417 this, &UIMediumDetailsWidget::sltDescriptionTextChanged); 418 419 /* Add into layout: */ 420 pLayoutDescription->addWidget(m_pEditorDescription, 0, 0, 2, 1); 421 } 422 423 /* Create description error pane: */ 424 m_pErrorPaneDescription = new QLabel; 425 AssertPtrReturnVoid(m_pErrorPaneDescription); 426 { 427 /* Configure label: */ 428 m_pErrorPaneDescription->setAlignment(Qt::AlignCenter); 429 m_pErrorPaneDescription->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 430 m_pErrorPaneDescription->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 431 .pixmap(QSize(iIconMetric, iIconMetric))); 432 433 /* Add into layout: */ 434 pLayoutDescription->addWidget(m_pErrorPaneDescription, 0, 1, Qt::AlignCenter); 435 } 436 437 /* Add into layout: */ 438 pLayoutOptions->addLayout(pLayoutDescription, 4, 1, 2, 1); 439 } 440 375 441 /* Create stretch: */ 376 442 QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); … … 378 444 { 379 445 /* Add into layout: */ 380 pLayoutOptions->addItem(pSpacer2, 4, 0, 1, 2);446 pLayoutOptions->addItem(pSpacer2, 6, 0, 1, 2); 381 447 } 382 448 … … 392 458 393 459 /* Add into layout: */ 394 pLayoutOptions->addWidget(m_pButtonBox, 5, 0, 1, 2);460 pLayoutOptions->addWidget(m_pButtonBox, 7, 0, 1, 2); 395 461 } 396 462 } … … 531 597 m_pEditorSize->setEnabled(fEnableResize); 532 598 m_pEditorSize->setMediumSize(m_newData.m_options.m_uLogicalSize); 599 600 /* Load description: */ 601 m_pLabelDescription->setEnabled(m_newData.m_fValid); 602 m_pEditorDescription->setEnabled(m_newData.m_fValid); 603 m_pEditorDescription->setPlainText(m_newData.m_options.m_strDescription); 533 604 } 534 605 … … 570 641 const bool fError = false; 571 642 m_pErrorPaneSize->setVisible(fError); 643 } 644 if (!pWidget || pWidget == m_pErrorPaneDescription) 645 { 646 /* Always valid for now: */ 647 const bool fError = false; 648 m_pErrorPaneDescription->setVisible(fError); 572 649 } 573 650 … … 588 665 // m_pErrorPaneSize->setToolTip(tr("Cannot change medium size from <b>%1</b> to <b>%2</b>.") 589 666 // .arg(m_oldData.m_options.m_uLogicalSize).arg(m_newData.m_options.m_uLogicalSize)); 667 // if (!pWidget || pWidget == m_pErrorPaneDescription) 668 // m_pErrorPaneDescription->setToolTip(tr("Cannot change medium description from <b>%1</b> to <b>%2</b>.") 669 // .arg(m_oldData.m_options.m_strDescription).arg(m_newData.m_options.m_strDescription)); 590 670 } 591 671 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.h
r67965 r67969 35 35 class QLabel; 36 36 class QStackedLayout; 37 class QTextEdit; 37 38 class QWidget; 38 39 class QILabel; … … 50 51 , m_strLocation(QString()) 51 52 , m_uLogicalSize(0) 53 , m_strDescription(QString()) 52 54 {} 53 55 … … 59 61 && (m_strLocation == other.m_strLocation) 60 62 && (m_uLogicalSize == other.m_uLogicalSize) 63 && (m_strDescription == other.m_strDescription) 61 64 ; 62 65 } … … 73 76 /** Holds the logical size. */ 74 77 qulonglong m_uLogicalSize; 78 /** Holds the description. */ 79 QString m_strDescription; 75 80 }; 76 81 … … 202 207 /** Handles size editor change. */ 203 208 void sltSizeValueChanged(qulonglong uSize); 209 /** Handles description text change. */ 210 void sltDescriptionTextChanged(); 204 211 205 212 /** Handles button-box button click. */ … … 290 297 QLabel *m_pErrorPaneSize; 291 298 299 /** Holds the description label. */ 300 QLabel *m_pLabelDescription; 301 /** Holds the description editor. */ 302 QTextEdit *m_pEditorDescription; 303 /** Holds the description error pane. */ 304 QLabel *m_pErrorPaneDescription; 305 292 306 /** Holds the button-box instance. */ 293 307 QIDialogButtonBox *m_pButtonBox; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r67965 r67969 388 388 m_options.m_strLocation = m_guiMedium.location(); 389 389 m_options.m_uLogicalSize = m_guiMedium.logicalSizeInBytes(); 390 m_options.m_strDescription = m_guiMedium.description(); 390 391 /* Gather medium details data: */ 391 392 m_details.m_aFields.clear(); … … 990 991 this); 991 992 } 993 } 994 995 /* Try to assign new medium description: */ 996 if ( comMedium.isOk() 997 && newData.m_options.m_strDescription != oldData.m_options.m_strDescription) 998 { 999 comMedium.SetDescription(newData.m_options.m_strDescription); 1000 1001 /* Show error message if necessary: */ 1002 if (!comMedium.isOk()) 1003 msgCenter().cannotChangeMediumDescription(comMedium, 1004 oldData.m_options.m_strLocation, 1005 this); 992 1006 } 993 1007
Note:
See TracChangeset
for help on using the changeset viewer.