Changeset 18198 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 24, 2009 3:45:22 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxImportApplianceWgt.h
r17053 r18198 39 39 40 40 bool setFile (const QString& aFile); 41 void prepareImport(); 41 42 bool import(); 42 43 43 44 bool isValid() const { return mAppliance != NULL; } 45 QList < QPair <QString, QString> > licenseAgreements() const; 44 46 45 47 static int minGuestRAM() { return mMinGuestRAM; } -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxImportApplianceWzd.h
r17053 r18198 27 27 #include "QIAbstractWizard.h" 28 28 #include "QIWithRetranslateUI.h" 29 #include "QIDialog.h" 29 30 30 31 class QIWidgetValidator; 32 33 class QDialogButtonBox; 34 35 class VBoxImportLicenseViewer: public QIDialog 36 { 37 Q_OBJECT; 38 39 public: 40 VBoxImportLicenseViewer (QWidget *aParent = NULL); 41 42 void setContent (const QString &aName, const QString &aText); 43 44 protected: 45 void retranslateUi(); 46 47 private slots: 48 void print(); 49 void save(); 50 51 private: 52 QLabel *mCaption; 53 QTextEdit *mLicenseText; 54 QDialogButtonBox *mButtonBox; 55 QPushButton *mPrintBtn; 56 QPushButton *mSaveBtn; 57 QString mName; 58 QString mText; 59 }; 31 60 32 61 class VBoxImportApplianceWzd : public QIWithRetranslateUI<QIAbstractWizard>, -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxImportApplianceWgt.cpp
r18009 r18198 53 53 54 54 protected: 55 bool filterAcceptsRow (int aSourceRow, const QModelIndex & aSourceParent) const; 55 56 bool lessThan (const QModelIndex &aLeft, const QModelIndex &aRight) const; 56 57 … … 754 755 KVirtualSystemDescriptionType_Description, 755 756 KVirtualSystemDescriptionType_OS, 757 KVirtualSystemDescriptionType_License, 756 758 KVirtualSystemDescriptionType_CPU, 757 759 KVirtualSystemDescriptionType_Memory, … … 770 772 {} 771 773 774 bool VirtualSystemSortProxyModel::filterAcceptsRow (int aSourceRow, const QModelIndex & aSourceParent) const 775 { 776 /* By default enable all, we will explicitly filter out below */ 777 if (aSourceParent.isValid()) 778 { 779 QModelIndex i = aSourceParent.child (aSourceRow, 0); 780 if (i.isValid()) 781 { 782 ModelItem *item = static_cast<ModelItem*> (i.internalPointer()); 783 /* We filter hardware types only */ 784 if (item->type() == HardwareType) 785 { 786 HardwareItem *hwItem = static_cast<HardwareItem*> (item); 787 /* The license type shouldn't be displayed */ 788 if (hwItem->mType == KVirtualSystemDescriptionType_License) 789 return false; 790 } 791 } 792 } 793 return true; 794 } 795 772 796 bool VirtualSystemSortProxyModel::lessThan (const QModelIndex &aLeft, const QModelIndex &aRight) const 773 797 { … … 1060 1084 mTvSettings->setColumnHidden (OriginalValueSection, true); 1061 1085 mTvSettings->expandAll(); 1062 1063 // @todo can the warnings also be shown when an error occurs? I have the case here that1064 // interpret() failes because there's 16 hard disks attached to four SCSI controllers,1065 // and we support only one SCSI controller, and the warnings about the additional SCSI1066 // controllers are not shown. Instead there's only the error message that disk X cannot1067 // be attached to controller Y. I have fixed VBoxManage accordingly, but the GUI should1068 // have that too. Thanks!1069 1086 1070 1087 /* Check for warnings & if there are one display them. */ … … 1092 1109 } 1093 1110 1111 void VBoxImportApplianceWgt::prepareImport() 1112 { 1113 if (mAppliance) 1114 mModel->putBack(); 1115 } 1116 1094 1117 bool VBoxImportApplianceWgt::import() 1095 1118 { 1096 1119 if (mAppliance) 1097 1120 { 1098 mModel->putBack();1099 1121 /* Start the import asynchronously */ 1100 1122 CProgress progress; … … 1117 1139 } 1118 1140 return false; 1141 } 1142 1143 QList < QPair<QString, QString> > VBoxImportApplianceWgt::licenseAgreements() const 1144 { 1145 QList < QPair<QString, QString> > list; 1146 1147 CVirtualSystemDescriptionVector vsds = mAppliance->GetVirtualSystemDescriptions(); 1148 for (int i=0; i < vsds.size(); ++i) 1149 { 1150 QVector<QString> license; 1151 vsds[i].GetValuesByType (KVirtualSystemDescriptionType_License, 1152 KVirtualSystemDescriptionValueType_Original, 1153 license); 1154 if (!license.isEmpty()) 1155 { 1156 QVector<QString> name; 1157 vsds[i].GetValuesByType (KVirtualSystemDescriptionType_Name, 1158 KVirtualSystemDescriptionValueType_Auto, 1159 name); 1160 list << QPair<QString, QString> (name.first(), license.first()); 1161 } 1162 } 1163 1164 return list; 1119 1165 } 1120 1166 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxImportApplianceWzd.cpp
r17714 r18198 26 26 #include "VBoxProblemReporter.h" 27 27 28 /* Qt includes */ 28 29 #include <QFileInfo> 30 #include <QDialogButtonBox> 31 #include <QPrinter> 32 #include <QPrintDialog> 33 #include <QTextStream> 34 35 //////////////////////////////////////////////////////////////////////////////// 36 // VBoxImportLicenseViewer 37 38 VBoxImportLicenseViewer::VBoxImportLicenseViewer (QWidget *aParent /* = NULL */) 39 : QIDialog (aParent) 40 { 41 QVBoxLayout *pMainLayout = new QVBoxLayout (this); 42 pMainLayout->setMargin (12); 43 44 mCaption = new QLabel (this); 45 mCaption->setWordWrap (true); 46 pMainLayout->addWidget (mCaption); 47 48 mLicenseText = new QTextEdit (this); 49 mLicenseText->setReadOnly (true); 50 pMainLayout->addWidget (mLicenseText); 51 52 mButtonBox = new QDialogButtonBox (QDialogButtonBox::No | QDialogButtonBox::Yes, Qt::Horizontal, this); 53 mPrintBtn = new QPushButton (this); 54 mButtonBox->addButton (mPrintBtn, QDialogButtonBox::ActionRole); 55 mSaveBtn = new QPushButton (this); 56 mButtonBox->addButton (mSaveBtn, QDialogButtonBox::ActionRole); 57 mButtonBox->button (QDialogButtonBox::Yes)->setDefault (true); 58 connect (mButtonBox, SIGNAL (rejected()), 59 this, SLOT (reject())); 60 connect (mButtonBox, SIGNAL (accepted()), 61 this, SLOT (accept())); 62 connect (mPrintBtn, SIGNAL (clicked()), 63 this, SLOT (print())); 64 connect (mSaveBtn, SIGNAL (clicked()), 65 this, SLOT (save())); 66 pMainLayout->addWidget (mButtonBox); 67 68 retranslateUi(); 69 } 70 71 void VBoxImportLicenseViewer::setContent (const QString &aName, const QString &aText) 72 { 73 mName = aName; 74 mText = aText; 75 mCaption->setText (tr ("<b>To continue importing the Appliance you must agree to the terms of the software license agreement for the Virtual System \"%1\".</b><br /><br />Click <b>Agree</b> to continue or click <b>Disagree</b> to cancel the import.").arg (mName)); 76 mLicenseText->setText (mText); 77 78 } 79 80 void VBoxImportLicenseViewer::retranslateUi() 81 { 82 setWindowTitle (tr ("Software License Agreement")); 83 mButtonBox->button (QDialogButtonBox::No)->setText (tr ("&Disagree")); 84 mButtonBox->button (QDialogButtonBox::Yes)->setText (tr ("&Agree")); 85 mPrintBtn->setText (tr ("&Print...")); 86 mSaveBtn->setText (tr ("&Save...")); 87 88 setContent (mName, mText); 89 } 90 91 void VBoxImportLicenseViewer::print() 92 { 93 QPrinter printer; 94 QPrintDialog pd (&printer, this); 95 if (pd.exec() == QDialog::Accepted) 96 mLicenseText->print (&printer); 97 } 98 99 void VBoxImportLicenseViewer::save() 100 { 101 QString fileName = vboxGlobal().getSaveFileName (vboxGlobal().documentsPath(), tr("Text (*.txt)"), this, tr("Select a file to save into...")); 102 if (!fileName.isEmpty()) 103 { 104 QFile file (fileName); 105 if (file.open(QFile::WriteOnly | QFile::Truncate)) 106 { 107 QTextStream out (&file); 108 out << mLicenseText->toPlainText(); 109 } 110 } 111 } 29 112 30 113 //////////////////////////////////////////////////////////////////////////////// … … 97 180 void VBoxImportApplianceWzd::accept() 98 181 { 182 /* Make sure the final values are puted back. */ 183 mImportSettingsWgt->prepareImport(); 184 /* Check if there are license agreements the use must confirm */ 185 QList < QPair <QString, QString> > licAgreements = mImportSettingsWgt->licenseAgreements(); 186 if (!licAgreements.isEmpty()) 187 { 188 VBoxImportLicenseViewer ilv (this); 189 for (int i=0; i < licAgreements.size(); ++i) 190 { 191 const QPair <QString, QString> &lic = licAgreements.at (i); 192 ilv.setContent (lic.first, lic.second); 193 if (ilv.exec() == QDialog::Rejected) 194 return; 195 } 196 } 197 /* Now import all virtual systems */ 99 198 if (mImportSettingsWgt->import()) 100 199 QIAbstractWizard::accept();
Note:
See TracChangeset
for help on using the changeset viewer.