Changeset 67409 in vbox
- Timestamp:
- Jun 14, 2017 2:42:03 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp
r67408 r67409 522 522 , m_pTabWidget(0) 523 523 , m_pLayoutOptions(0) 524 , m_pLabelName(0), m_pEditorName(0) 525 , m_pLabelDescription(0), m_pBrowserDescription(0) 524 , m_pLabelName(0), m_pEditorName(0), m_pErrorPaneName(0) 525 , m_pLabelDescription(0), m_pBrowserDescription(0), m_pErrorPaneDescription(0) 526 526 , m_pLayoutDetails(0) 527 527 , m_pScrollAreaDetails(0) … … 600 600 m_details.value(enmType)->setText("<empty>"); 601 601 } 602 603 /* Retranslate validation: */ 604 retranslateValidation(); 602 605 } 603 606 … … 605 608 { 606 609 m_newData.m_strName = m_pEditorName->text(); 607 // TODO: Validate 608 //revalidate(m_pErrorPaneName); 610 revalidate(m_pErrorPaneName); 609 611 notify(); 610 612 } … … 613 615 { 614 616 m_newData.m_strDescription = m_pBrowserDescription->toPlainText(); 615 // TODO: Validate 616 //revalidate(m_pErrorPaneName); 617 revalidate(m_pErrorPaneDescription); 617 618 notify(); 618 619 } … … 702 703 AssertPtrReturnVoid(m_pLayoutOptions); 703 704 { 705 /* Get the required icon metric: */ 706 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 707 704 708 /* Create name label: */ 705 709 m_pLabelName = new QLabel; … … 712 716 m_pLayoutOptions->addWidget(m_pLabelName, 0, 0); 713 717 } 714 /* Create name editor: */ 715 m_pEditorName = new QLineEdit; 716 AssertPtrReturnVoid(m_pEditorName); 717 { 718 /* Configure editor: */ 719 m_pLabelName->setBuddy(m_pEditorName); 720 QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Minimum); 721 policy.setHorizontalStretch(1); 722 m_pEditorName->setSizePolicy(policy); 723 connect(m_pEditorName, &QLineEdit::textChanged, 724 this, &UISnapshotDetailsWidget::sltHandleNameChange); 718 /* Create name layout: */ 719 QHBoxLayout *pLayoutName = new QHBoxLayout; 720 AssertPtrReturnVoid(pLayoutName); 721 { 722 /* Create name editor: */ 723 m_pEditorName = new QLineEdit; 724 AssertPtrReturnVoid(m_pEditorName); 725 { 726 /* Configure editor: */ 727 m_pLabelName->setBuddy(m_pEditorName); 728 QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Minimum); 729 policy.setHorizontalStretch(1); 730 m_pEditorName->setSizePolicy(policy); 731 connect(m_pEditorName, &QLineEdit::textChanged, 732 this, &UISnapshotDetailsWidget::sltHandleNameChange); 733 734 /* Add into layout: */ 735 pLayoutName->addWidget(m_pEditorName); 736 } 737 /* Create name error pane: */ 738 m_pErrorPaneName = new QLabel; 739 AssertPtrReturnVoid(m_pErrorPaneName); 740 { 741 /* Configure error pane: */ 742 m_pErrorPaneName->setAlignment(Qt::AlignCenter); 743 m_pErrorPaneName->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 744 .pixmap(QSize(iIconMetric, iIconMetric))); 745 746 /* Add into layout: */ 747 pLayoutName->addWidget(m_pErrorPaneName); 748 } 725 749 726 750 /* Add into layout: */ 727 m_pLayoutOptions->add Widget(m_pEditorName, 0, 1);751 m_pLayoutOptions->addLayout(pLayoutName, 0, 1); 728 752 } 729 753 … … 738 762 m_pLayoutOptions->addWidget(m_pLabelDescription, 1, 0); 739 763 } 740 /* Create description browser: */ 741 m_pBrowserDescription = new QTextEdit; 742 AssertPtrReturnVoid(m_pBrowserDescription); 743 { 744 /* Configure browser: */ 745 m_pLabelDescription->setBuddy(m_pBrowserDescription); 746 m_pBrowserDescription->setTabChangesFocus(true); 747 m_pBrowserDescription->setAcceptRichText(false); 748 QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); 749 policy.setHorizontalStretch(1); 750 m_pBrowserDescription->setSizePolicy(policy); 751 connect(m_pBrowserDescription, &QTextEdit::textChanged, 752 this, &UISnapshotDetailsWidget::sltHandleDescriptionChange); 764 /* Create description layout: */ 765 QHBoxLayout *pLayoutDescription = new QHBoxLayout; 766 AssertPtrReturnVoid(pLayoutDescription); 767 { 768 /* Create description browser: */ 769 m_pBrowserDescription = new QTextEdit; 770 AssertPtrReturnVoid(m_pBrowserDescription); 771 { 772 /* Configure browser: */ 773 m_pLabelDescription->setBuddy(m_pBrowserDescription); 774 m_pBrowserDescription->setTabChangesFocus(true); 775 m_pBrowserDescription->setAcceptRichText(false); 776 QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); 777 policy.setHorizontalStretch(1); 778 m_pBrowserDescription->setSizePolicy(policy); 779 connect(m_pBrowserDescription, &QTextEdit::textChanged, 780 this, &UISnapshotDetailsWidget::sltHandleDescriptionChange); 781 782 /* Add into layout: */ 783 pLayoutDescription->addWidget(m_pBrowserDescription); 784 } 785 /* Create description error pane: */ 786 m_pErrorPaneDescription = new QLabel; 787 AssertPtrReturnVoid(m_pErrorPaneDescription); 788 { 789 /* Configure error pane: */ 790 m_pErrorPaneDescription->setAlignment(Qt::AlignCenter); 791 m_pErrorPaneDescription->setPixmap(UIIconPool::iconSet(":/status_error_16px.png") 792 .pixmap(QSize(iIconMetric, iIconMetric))); 793 794 /* Add into layout: */ 795 pLayoutDescription->addWidget(m_pErrorPaneDescription); 796 } 753 797 754 798 /* Add into layout: */ 755 m_pLayoutOptions->add Widget(m_pBrowserDescription, 1, 1);799 m_pLayoutOptions->addLayout(pLayoutDescription, 1, 1); 756 800 } 757 801 } … … 972 1016 /* Retranslate: */ 973 1017 retranslateUi(); 1018 } 1019 1020 void UISnapshotDetailsWidget::revalidate(QWidget *pWidget /* = 0 */) 1021 { 1022 if (!pWidget || pWidget == m_pErrorPaneName) 1023 { 1024 const bool fError = m_newData.m_strName.isEmpty(); 1025 m_pErrorPaneName->setVisible(fError); 1026 } 1027 if (!pWidget || pWidget == m_pErrorPaneDescription) 1028 { 1029 const bool fError = false; 1030 m_pErrorPaneDescription->setVisible(fError); 1031 } 1032 1033 /* Retranslate validation: */ 1034 retranslateValidation(pWidget); 1035 } 1036 1037 void UISnapshotDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */) 1038 { 1039 if (!pWidget || pWidget == m_pErrorPaneName) 1040 m_pErrorPaneName->setToolTip(tr("Snapshot name is empty")); 974 1041 } 975 1042 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.h
r67375 r67409 128 128 void loadSnapshotData(); 129 129 130 /** Revalidates changes for passed @a pWidget. */ 131 void revalidate(QWidget *pWidget = 0); 132 /** Retranslates validation for passed @a pWidget. */ 133 void retranslateValidation(QWidget *pWidget = 0); 130 134 /** Notifies listeners about data changed or not. */ 131 135 void notify(); … … 163 167 /** Holds the name editor instance. */ 164 168 QLineEdit *m_pEditorName; 169 /** Holds the name error pane. */ 170 QLabel *m_pErrorPaneName; 165 171 166 172 /** Holds the description label instance. */ … … 168 174 /** Holds the description editor instance. */ 169 175 QTextEdit *m_pBrowserDescription; 176 /** Holds the description error pane. */ 177 QLabel *m_pErrorPaneDescription; 170 178 171 179 /** Holds the 'Details' layout instance. */
Note:
See TracChangeset
for help on using the changeset viewer.