Changeset 4572 in vbox for trunk/src/VBox
- Timestamp:
- Sep 6, 2007 1:47:22 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r4500 r4572 82 82 # Sources containing local definitions of classes that use the Q_OBJECT macro 83 83 VirtualBox_QT_MOCSRCS = src/VBoxSelectorWnd.cpp 84 ifeq ($(BUILD_TARGET),linux) 85 VirtualBox_QT_MOCSRCS += src/VBoxGlobal.cpp 86 endif 84 87 ifdef VBOX_WITH_XPCOM 85 88 VirtualBox_QT_MOCSRCS += src/COMDefs.cpp -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r4202 r4572 160 160 static const char* GUI_SuppressMessages; 161 161 static const char* GUI_PermanentSharedFoldersAtRuntime; 162 #ifdef Q_WS_X11 163 static const char* GUI_LicenseKey; 164 #endif 162 165 }; 163 166 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r4354 r4572 363 363 364 364 /* VirtualBox helpers */ 365 366 #ifdef Q_WS_X11 367 bool showVirtualBoxLicense(); 368 #endif 365 369 366 370 CSession openSession (const QUuid &id); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r4331 r4572 85 85 // problem handlers 86 86 87 #ifdef Q_WS_X11 88 void cannotFindLicenseFiles (const QString &aPath); 89 void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath); 90 #endif 91 87 92 void cannotOpenURL (const QString &aURL); 88 93 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxDefs.cpp
r4071 r4572 29 29 const char* VBoxDefs::GUI_SuppressMessages = "GUI/SuppressMessages"; 30 30 const char* VBoxDefs::GUI_PermanentSharedFoldersAtRuntime = "GUI/PermanentSharedFoldersAtRuntime"; 31 #ifdef Q_WS_X11 32 const char* VBoxDefs::GUI_LicenseKey = "GUI/LicenseAgreed"; 33 #endif 31 34 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r4459 r4572 33 33 #include <qimage.h> 34 34 #include <qlabel.h> 35 36 #ifdef Q_WS_X11 37 #include <qtextbrowser.h> 38 #include <qpushbutton.h> 39 #include <qlayout.h> 40 #endif 35 41 36 42 #include <qfileinfo.h> … … 491 497 #endif /* Q_WS_WIN */ 492 498 499 #ifdef Q_WS_X11 500 /** 501 * This class is used to show a user license under linux. 502 */ 503 class VBoxLicenseViewer : public QDialog 504 { 505 Q_OBJECT 506 507 public: 508 509 VBoxLicenseViewer (const QString &aFilePath) 510 : QDialog (0, "VBoxLicenseViewerObject") 511 , mFilePath (aFilePath) 512 , mLicenseText (0), mAgreeButton (0), mDisagreeButton (0) 513 { 514 setCaption ("VirtualBox License"); 515 setIcon (QPixmap::fromMimeSource ("ico40x01.png")); 516 517 mLicenseText = new QTextBrowser (this); 518 mAgreeButton = new QPushButton (tr ("I &Agree"), this); 519 mDisagreeButton = new QPushButton (tr ("I &Disagree"), this); 520 521 mLicenseText->setTextFormat (Qt::RichText); 522 mAgreeButton->setEnabled (false); 523 mDisagreeButton->setEnabled (false); 524 525 connect (mLicenseText->verticalScrollBar(), SIGNAL (valueChanged (int)), 526 SLOT (onScrollBarMoving (int))); 527 connect (mAgreeButton, SIGNAL (clicked()), SLOT (accept())); 528 connect (mDisagreeButton, SIGNAL (clicked()), SLOT (reject())); 529 530 QVBoxLayout *mainLayout = new QVBoxLayout (this, 10, 10); 531 mainLayout->addWidget (mLicenseText); 532 533 QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10); 534 buttonLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Expanding, 535 QSizePolicy::Preferred)); 536 buttonLayout->addWidget (mAgreeButton); 537 buttonLayout->addWidget (mDisagreeButton); 538 539 resize (600, 450); 540 } 541 542 public slots: 543 544 int exec() 545 { 546 /* read & show the license file */ 547 QFile file (mFilePath); 548 if (file.open (IO_ReadOnly)) 549 { 550 mLicenseText->setText (file.readAll()); 551 return QDialog::exec(); 552 } 553 else 554 { 555 vboxProblem().cannotOpenLicenseFile (this, mFilePath); 556 return QDialog::Rejected; 557 } 558 } 559 560 private slots: 561 562 void onScrollBarMoving (int aValue) 563 { 564 if (aValue == mLicenseText->verticalScrollBar()->maxValue()) 565 { 566 mAgreeButton->setEnabled (true); 567 mDisagreeButton->setEnabled (true); 568 } 569 } 570 571 private: 572 573 QString mFilePath; 574 QTextBrowser *mLicenseText; 575 QPushButton *mAgreeButton; 576 QPushButton *mDisagreeButton; 577 }; 578 #endif 579 580 493 581 // VBoxGlobal 494 582 //////////////////////////////////////////////////////////////////////////////// … … 831 919 const ulong IOBase; 832 920 } 833 kKnownPorts[] = 921 kKnownPorts[] = 834 922 { 835 923 { "COM1", 4, 0x3F8 }, … … 841 929 }; 842 930 843 /** 931 /** 844 932 * Returns the list of the standard COM port names (i.e. "COMx"). 845 933 */ … … 853 941 } 854 942 855 /** 943 /** 856 944 * Returns the name of the standard COM port corresponding to the given 857 945 * parameters, or "User-defined" (which is also returned when both … … 868 956 } 869 957 870 /** 958 /** 871 959 * Returns port parameters corresponding to the given standard COM name. 872 960 * Returns @c true on success, or @c false if the given port name is not one … … 1385 1473 .arg (vboxGlobal().toString (mode)) 1386 1474 .arg (QDir::convertSeparators (port.GetPath())); 1387 else 1475 else 1388 1476 data += toString (mode); 1389 1477 … … 1491 1579 return QString (sTableTpl). arg (detailsReport); 1492 1580 } 1581 1582 #ifdef Q_WS_X11 1583 bool VBoxGlobal::showVirtualBoxLicense() 1584 { 1585 /* get the apps doc path */ 1586 int size = 256; 1587 char *buffer = (char*) malloc (size); 1588 RTPathAppDocs (buffer, size); 1589 QString path (buffer); 1590 free (buffer); 1591 QDir docDir (path); 1592 docDir.setFilter (QDir::Files); 1593 docDir.setNameFilter ("License*-*.html"); 1594 1595 /* get the license files list and search for the latest license */ 1596 QStringList filesList = docDir.entryList(); 1597 double maxVersionNumber = 0; 1598 for (uint index = 0; index < filesList.count(); ++ index) 1599 { 1600 QRegExp regExp ("License([\\d]+-[\\d]+).html"); 1601 regExp.search (filesList [index]); 1602 QString version = regExp.cap (1); 1603 version = version.replace ("-", "."); 1604 if (maxVersionNumber < version.toDouble()) 1605 maxVersionNumber = version.toDouble(); 1606 } 1607 if (!maxVersionNumber) 1608 { 1609 vboxProblem().cannotFindLicenseFiles (path); 1610 return false; 1611 } 1612 1613 /* compose the latest license file full path */ 1614 QString latestVersion = QString::number (maxVersionNumber); 1615 latestVersion = latestVersion.replace (".", "-"); 1616 QString latestFilePath = docDir.absFilePath ( 1617 QString ("License%1.html").arg (latestVersion)); 1618 1619 /* check for the agreed license version */ 1620 QString licenseAgreed = virtualBox().GetExtraData (VBoxDefs::GUI_LicenseKey); 1621 if (licenseAgreed == latestVersion) 1622 return true; 1623 1624 VBoxLicenseViewer licenseDialog (latestFilePath); 1625 bool result = licenseDialog.exec() == QDialog::Accepted; 1626 if (result) 1627 virtualBox().SetExtraData (VBoxDefs::GUI_LicenseKey, latestVersion); 1628 return result; 1629 } 1630 #endif 1493 1631 1494 1632 /** … … 3721 3859 } 3722 3860 3861 #ifdef Q_WS_X11 3862 #include "VBoxGlobal.moc" 3863 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r4482 r4572 450 450 ///////////////////////////////////////////////////////////////////////////// 451 451 452 #ifdef Q_WS_X11 453 void VBoxProblemReporter::cannotFindLicenseFiles (const QString &aPath) 454 { 455 message 456 (0, VBoxProblemReporter::Error, 457 tr ("Failed to find any license file in " 458 "<nobr><b>%1</b></nobr> path.") 459 .arg (aPath)); 460 } 461 462 void VBoxProblemReporter::cannotOpenLicenseFile (QWidget *aParent, 463 const QString &aPath) 464 { 465 message 466 (aParent, VBoxProblemReporter::Error, 467 tr ("Failed to open license file <nobr><b>%1</b></nobr>. " 468 "Check the file presence and read-permissions.") 469 .arg (aPath)); 470 } 471 #endif 472 452 473 void VBoxProblemReporter::cannotOpenURL (const QString &aURL) 453 474 { … … 1601 1622 } 1602 1623 1603 /** 1624 /** 1604 1625 * Returns @c true if the user has selected to power off the machine. 1605 1626 */ -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r4071 r4572 190 190 if (vboxGlobal().isValid()) 191 191 { 192 #ifdef Q_WS_X11 193 /* show the user license file */ 194 //if (!vboxGlobal().showVirtualBoxLicense()) 195 // return rc; 196 #endif 197 192 198 VBoxGlobalSettings settings = vboxGlobal().settings(); 193 199 /* Process known keys */
Note:
See TracChangeset
for help on using the changeset viewer.