Changeset 90728 in vbox
- Timestamp:
- Aug 18, 2021 4:24:45 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r90627 r90728 2201 2201 } 2202 2202 2203 void UIMessageCenter::cannotAssignFormValue(const CBooleanFormValue &comValue, QWidget *pParent /* = 0 */) const2203 void UIMessageCenter::cannotAssignFormValue(const QString &strError, QWidget *pParent /* = 0 */) const 2204 2204 { 2205 2205 error(pParent, MessageType_Error, 2206 2206 tr("Failed to assign form value."), 2207 UIErrorString::formatErrorInfo(comValue)); 2208 } 2209 2210 void UIMessageCenter::cannotAssignFormValue(const CStringFormValue &comValue, QWidget *pParent /* = 0 */) const 2211 { 2212 error(pParent, MessageType_Error, 2213 tr("Failed to assign form value."), 2214 UIErrorString::formatErrorInfo(comValue)); 2215 } 2216 2217 void UIMessageCenter::cannotAssignFormValue(const CChoiceFormValue &comValue, QWidget *pParent /* = 0 */) const 2218 { 2219 error(pParent, MessageType_Error, 2220 tr("Failed to assign form value."), 2221 UIErrorString::formatErrorInfo(comValue)); 2222 } 2223 2224 void UIMessageCenter::cannotAssignFormValue(const CRangedIntegerFormValue &comValue, QWidget *pParent /* = 0 */) const 2225 { 2226 error(pParent, MessageType_Error, 2227 tr("Failed to assign form value."), 2228 UIErrorString::formatErrorInfo(comValue)); 2229 } 2230 2231 void UIMessageCenter::cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent /* = 0 */) const 2232 { 2233 error(pParent, MessageType_Error, 2234 tr("Failed to assign form value."), 2235 UIErrorString::formatErrorInfo(comProgress)); 2207 strError); 2236 2208 } 2237 2209 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r90086 r90728 448 448 bool confirmCloudProfileRemoval(const QString &strName, QWidget *pParent = 0) const; 449 449 bool confirmCloudProfilesImport(QWidget *pParent = 0) const; 450 void cannotAssignFormValue(const CBooleanFormValue &comValue, QWidget *pParent = 0) const; 451 void cannotAssignFormValue(const CStringFormValue &comValue, QWidget *pParent = 0) const; 452 void cannotAssignFormValue(const CChoiceFormValue &comValue, QWidget *pParent = 0) const; 453 void cannotAssignFormValue(const CRangedIntegerFormValue &comValue, QWidget *pParent = 0) const; 454 void cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent = 0) const; 450 void cannotAssignFormValue(const QString &strError, QWidget *pParent = 0) const; 455 451 int confirmCloudProfileManagerClosing(QWidget *pParent = 0) const; 456 452 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp
r88104 r90728 37 37 #include "UIIconPool.h" 38 38 #include "UIMessageCenter.h" 39 #include "UIProgressObject.h" 39 40 40 41 /* COM includes: */ … … 318 319 Q_OBJECT; 319 320 321 signals: 322 323 /** Starts @a comProgress execution. */ 324 void sigStartProgress(const CProgress &comProgress); 325 /** Notifies listeners about progress has started. */ 326 void sigProgressStarted(); 327 /** Notifies listeners about progress has changed. 328 * @param uPercent Brings the progress percentage. */ 329 void sigProgressChange(ulong uPercent); 330 /** Notifies listeners about progress has finished. */ 331 void sigProgressFinished(); 332 320 333 public: 321 334 … … 376 389 /** Returns the child item with @a iIndex. */ 377 390 virtual QITableViewCell *childItem(int iIndex) const /* override */; 391 392 private slots: 393 394 /** Handles request to start progress. 395 * @param comProgress Brings the progress just started. */ 396 void sltHandleProgressStarted(CProgress comProgress); 397 /** Handles progress failure. 398 * @param strError Brings error information. */ 399 void sltHandleProgressFailed(const QString &strError); 378 400 379 401 private: … … 416 438 Q_OBJECT; 417 439 440 signals: 441 442 /** Notifies listeners about progress has started. */ 443 void sigProgressStarted(); 444 /** Notifies listeners about progress has changed. 445 * @param uPercent Brings the progress percentage. */ 446 void sigProgressChange(ulong uPercent); 447 /** Notifies listeners about progress has finished. */ 448 void sigProgressFinished(); 449 418 450 public: 419 451 … … 721 753 CBooleanFormValue comValue(m_comValue); 722 754 CProgress comProgress = comValue.SetSelected(fBool); 723 724 /* Show error message if necessary: */ 725 if (!comValue.isOk()) 726 msgCenter().cannotAssignFormValue(comValue, table()->window()); 727 else 728 { 729 /* Show "Acquire export form" progress: */ 730 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value ..."), 731 ":/progress_refresh_90px.png", 732 table()->window(), 0 /* duration */); 733 734 /* Show error message if necessary: */ 735 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 736 msgCenter().cannotAssignFormValue(comProgress, table()->window()); 737 else 738 updateValueCells(); 739 } 755 emit sigStartProgress(comProgress); 740 756 } 741 757 … … 757 773 CStringFormValue comValue(m_comValue); 758 774 CProgress comProgress = comValue.SetString(text.text()); 759 760 /* Show error message if necessary: */ 761 if (!comValue.isOk()) 762 msgCenter().cannotAssignFormValue(comValue, table()->window()); 763 else 764 { 765 /* Show "Acquire export form" progress: */ 766 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value ..."), 767 ":/progress_refresh_90px.png", 768 table()->window(), 0 /* duration */); 769 770 /* Show error message if necessary: */ 771 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 772 msgCenter().cannotAssignFormValue(comProgress, table()->window()); 773 else 774 updateValueCells(); 775 } 775 emit sigStartProgress(comProgress); 776 776 } 777 777 … … 787 787 CStringFormValue comValue(m_comValue); 788 788 CProgress comProgress = comValue.SetString(strString); 789 790 /* Show error message if necessary: */ 791 if (!comValue.isOk()) 792 msgCenter().cannotAssignFormValue(comValue, table()->window()); 793 else 794 { 795 /* Show "Acquire export form" progress: */ 796 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value ..."), 797 ":/progress_refresh_90px.png", 798 table()->window(), 0 /* duration */); 799 800 /* Show error message if necessary: */ 801 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 802 msgCenter().cannotAssignFormValue(comProgress, table()->window()); 803 else 804 updateValueCells(); 805 } 789 emit sigStartProgress(comProgress); 806 790 } 807 791 … … 821 805 CChoiceFormValue comValue(m_comValue); 822 806 CProgress comProgress = comValue.SetSelectedIndex(choice.selectedIndex()); 823 824 /* Show error message if necessary: */ 825 if (!comValue.isOk()) 826 msgCenter().cannotAssignFormValue(comValue, table()->window()); 827 else 828 { 829 /* Show "Acquire export form" progress: */ 830 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value ..."), 831 ":/progress_refresh_90px.png", 832 table()->window(), 0 /* duration */); 833 834 /* Show error message if necessary: */ 835 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 836 msgCenter().cannotAssignFormValue(comProgress, table()->window()); 837 else 838 updateValueCells(); 839 } 807 emit sigStartProgress(comProgress); 840 808 } 841 809 … … 851 819 CRangedIntegerFormValue comValue(m_comValue); 852 820 CProgress comProgress = comValue.SetInteger(rangedInteger.integer()); 853 854 /* Show error message if necessary: */ 855 if (!comValue.isOk()) 856 msgCenter().cannotAssignFormValue(comValue, table()->window()); 857 else 858 { 859 /* Show "Acquire export form" progress: */ 860 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value ..."), 861 ":/progress_refresh_90px.png", 862 table()->window(), 0 /* duration */); 863 864 /* Show error message if necessary: */ 865 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 866 msgCenter().cannotAssignFormValue(comProgress, table()->window()); 867 else 868 updateValueCells(); 869 } 821 emit sigStartProgress(comProgress); 870 822 } 871 823 … … 949 901 } 950 902 903 void UIFormEditorRow::sltHandleProgressStarted(CProgress comProgress) 904 { 905 /* Make sure progress valid: */ 906 if (!comProgress.isNull() && !comProgress.GetCompleted()) 907 { 908 /* Create set value progress object: */ 909 QPointer<UIProgressObject> pObject = new UIProgressObject(comProgress, this); 910 if (pObject) 911 { 912 connect(pObject.data(), &UIProgressObject::sigProgressError, 913 this, &UIFormEditorRow::sltHandleProgressFailed); 914 connect(pObject.data(), &UIProgressObject::sigProgressChange, 915 this, &UIFormEditorRow::sigProgressChange); 916 connect(pObject.data(), &UIProgressObject::sigProgressComplete, 917 this, &UIFormEditorRow::sigProgressFinished); 918 emit sigProgressStarted(); 919 pObject->exec(); 920 if (pObject) 921 delete pObject; 922 else 923 { 924 // Premature application shutdown, 925 // exit immediately: 926 return; 927 } 928 } 929 } 930 931 /* Update values finally: */ 932 updateValueCells(); 933 } 934 935 void UIFormEditorRow::sltHandleProgressFailed(const QString &strError) 936 { 937 msgCenter().cannotAssignFormValue(strError, table()->window()); 938 emit sigProgressFinished(); 939 } 940 951 941 void UIFormEditorRow::prepare() 952 942 { … … 962 952 m_cells[UIFormEditorDataType_Value] = new UIFormEditorCell(this); 963 953 updateValueCells(); 954 955 /* Configure connections: */ 956 connect(this, &UIFormEditorRow::sigStartProgress, 957 this, &UIFormEditorRow::sltHandleProgressStarted); 964 958 } 965 959 … … 1000 994 beginInsertRows(QModelIndex(), 0, values.size() - 1); 1001 995 foreach (const CFormValue &comValue, values) 1002 m_dataList << new UIFormEditorRow(parentTable(), comValue); 996 { 997 UIFormEditorRow *pRow = new UIFormEditorRow(parentTable(), comValue); 998 if (pRow) 999 { 1000 connect(pRow, &UIFormEditorRow::sigProgressStarted, 1001 this, &UIFormEditorModel::sigProgressStarted); 1002 connect(pRow, &UIFormEditorRow::sigProgressChange, 1003 this, &UIFormEditorModel::sigProgressChange); 1004 connect(pRow, &UIFormEditorRow::sigProgressFinished, 1005 this, &UIFormEditorModel::sigProgressFinished); 1006 m_dataList << pRow; 1007 } 1008 } 1003 1009 endInsertRows(); 1004 1010 } … … 1519 1525 pProxyModel->setSourceModel(m_pTableModel); 1520 1526 m_pTableView->setModel(pProxyModel); 1527 connect(m_pTableModel, &UIFormEditorModel::sigProgressStarted, 1528 this, &UIFormEditorWidget::sigProgressStarted); 1529 connect(m_pTableModel, &UIFormEditorModel::sigProgressChange, 1530 this, &UIFormEditorWidget::sigProgressChange); 1531 connect(m_pTableModel, &UIFormEditorModel::sigProgressFinished, 1532 this, &UIFormEditorWidget::sigProgressFinished); 1521 1533 } 1522 1534 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.h
r84008 r90728 41 41 { 42 42 Q_OBJECT; 43 44 signals: 45 46 /** Notifies listeners about progress has started. */ 47 void sigProgressStarted(); 48 /** Notifies listeners about progress has changed. 49 * @param uPercent Brings the progress percentage. */ 50 void sigProgressChange(ulong uPercent); 51 /** Notifies listeners about progress has finished. */ 52 void sigProgressFinished(); 43 53 44 54 public:
Note:
See TracChangeset
for help on using the changeset viewer.