Changeset 38477 in vbox
- Timestamp:
- Aug 16, 2011 1:46:03 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIFileDialog.cpp
r37629 r38477 400 400 const QString &aCaption, 401 401 QString *aSelectedFilter /* = 0 */, 402 bool aResolveSymlinks /* = true */) 402 bool aResolveSymlinks /* = true */, 403 bool fConfirmOverwrite /* = false */) 403 404 { 404 405 #if defined Q_WS_WIN … … 427 428 Thread (QWidget *aParent, QObject *aTarget, 428 429 const QString &aStartWith, const QString &aFilters, 429 const QString &aCaption ) :430 const QString &aCaption, bool fConfirmOverwrite) : 430 431 mParent (aParent), mTarget (aTarget), 431 432 mStartWith (aStartWith), mFilters (aFilters), 432 mCaption (aCaption) {} 433 mCaption (aCaption) 434 m_fConfirmOverwrite(fConfirmOverwrite) {} 433 435 434 436 virtual void run() … … 476 478 ofn.Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | 477 479 OFN_EXPLORER | OFN_ENABLEHOOK | 478 OFN_NOTESTFILECREATE );480 OFN_NOTESTFILECREATE | (m_fConfirmOverwrite ? OFN_OVERWRITEPROMPT : 0)); 479 481 ofn.lpfnHook = OFNHookProc; 480 482 … … 502 504 QString mFilters; 503 505 QString mCaption; 506 bool m_fConfirmOverwrite; 504 507 }; 505 508 … … 517 520 aParent->setWindowModality (Qt::WindowModal); 518 521 519 Thread openDirThread (aParent, &loopObject, startWith, aFilters, aCaption );522 Thread openDirThread (aParent, &loopObject, startWith, aFilters, aCaption, fConfirmOverwrite); 520 523 openDirThread.start(); 521 524 loop.exec(); … … 542 545 dlg.selectFilter (*aSelectedFilter); 543 546 dlg.setResolveSymlinks (aResolveSymlinks); 544 dlg.setConfirmOverwrite (f alse);547 dlg.setConfirmOverwrite (fConfirmOverwrite); 545 548 QAction *hidden = dlg.findChild <QAction*> ("qt_show_hidden_action"); 546 549 if (hidden) … … 567 570 dlg.selectFilter (*aSelectedFilter); 568 571 dlg.setResolveSymlinks (aResolveSymlinks); 569 dlg.setConfirmOverwrite (f alse);572 dlg.setConfirmOverwrite (fConfirmOverwrite); 570 573 571 574 QEventLoop eventLoop; … … 590 593 if (!aResolveSymlinks) 591 594 o |= QFileDialog::DontResolveSymlinks; 592 o |= QFileDialog::DontConfirmOverwrite; 595 if (!fConfirmOverwrite) 596 o |= QFileDialog::DontConfirmOverwrite; 593 597 return QFileDialog::getSaveFileName (aParent, aCaption, aStartWith, 594 598 aFilters, aSelectedFilter, o); -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIFileDialog.h
r28800 r38477 38 38 static QString getSaveFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent, 39 39 const QString &aCaption, QString *aSelectedFilter = 0, 40 bool aResolveSymLinks = true );40 bool aResolveSymLinks = true, bool fConfirmOverwrite = false); 41 41 42 42 static QString getOpenFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp
r38398 r38477 80 80 void retranslateUi() 81 81 { 82 setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionPool", "Take &Snapshot..."), gMS->shortcut(UIMachineShortcuts::TakeSnapshotShortcut)));82 setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionPool", "Take Sn&apshot..."), gMS->shortcut(UIMachineShortcuts::TakeSnapshotShortcut))); 83 83 setStatusTip(QApplication::translate("UIActionPool", "Take a snapshot of the virtual machine")); 84 } 85 }; 86 87 class PerformTakeScreenshotAction : public UISimpleAction 88 { 89 Q_OBJECT; 90 91 public: 92 93 PerformTakeScreenshotAction(QObject *pParent) 94 : UISimpleAction(pParent, ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png") 95 { 96 retranslateUi(); 97 } 98 99 protected: 100 101 void retranslateUi() 102 { 103 setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionPool", "Take Screensh&ot"), gMS->shortcut(UIMachineShortcuts::TakeScreenshotShortcut))); 104 setStatusTip(QApplication::translate("UIActionPool", "Take a screenshot of the virtual machine")); 84 105 } 85 106 }; … … 184 205 void retranslateUi() 185 206 { 186 setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionPool", " &Insert Ctrl-Alt-Backspace"), gMS->shortcut(UIMachineShortcuts::TypeCABSShortcut)));207 setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionPool", "Ins&ert Ctrl-Alt-Backspace"), gMS->shortcut(UIMachineShortcuts::TypeCABSShortcut))); 187 208 setStatusTip(QApplication::translate("UIActionPool", "Send the Ctrl-Alt-Backspace sequence to the virtual machine")); 188 209 } … … 804 825 m_pool[UIActionIndexRuntime_Simple_SettingsDialog] = new ShowSettingsDialogAction(this); 805 826 m_pool[UIActionIndexRuntime_Simple_TakeSnapshot] = new PerformTakeSnapshotAction(this); 827 m_pool[UIActionIndexRuntime_Simple_TakeScreenshot] = new PerformTakeScreenshotAction(this); 806 828 m_pool[UIActionIndexRuntime_Simple_InformationDialog] = new ShowInformationDialogAction(this); 807 829 m_pool[UIActionIndexRuntime_Toggle_MouseIntegration] = new ToggleMouseIntegrationAction(this); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h
r38355 r38477 30 30 UIActionIndexRuntime_Simple_SettingsDialog, 31 31 UIActionIndexRuntime_Simple_TakeSnapshot, 32 UIActionIndexRuntime_Simple_TakeScreenshot, 32 33 UIActionIndexRuntime_Simple_InformationDialog, 33 34 UIActionIndexRuntime_Menu_MouseIntegration, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r38431 r38477 57 57 #endif /* Q_WS_X11 */ 58 58 59 #include <QDesktopWidget> 59 60 #include <QDir> 60 61 #include <QFileInfo> 61 #include <QDesktopWidget> 62 #include <QImageWriter> 63 #include <QPainter> 62 64 #include <QTimer> 63 65 … … 231 233 } 232 234 233 CSession& UIMachineLogic::session() 235 CSession& UIMachineLogic::session() const 234 236 { 235 237 return uisession()->session(); … … 326 328 connect(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot), SIGNAL(triggered()), 327 329 this, SLOT(sltTakeSnapshot())); 330 connect(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot), SIGNAL(triggered()), 331 this, SLOT(sltTakeScreenshot())); 328 332 connect(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog), SIGNAL(triggered()), 329 333 this, SLOT(sltShowInformationDialog())); … … 417 421 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)); 418 422 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)); 423 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot)); 419 424 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog)); 420 425 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration)); … … 584 589 uisession()->setGuestResizeIgnored(true); 585 590 586 /* Get console :*/591 /* Get console and log folder. */ 587 592 CConsole console = session().GetConsole(); 593 const QString &strLogFolder = console.GetMachine().GetLogFolder(); 588 594 589 595 /* Take the screenshot for debugging purposes and save it. */ 590 QString strLogFolder = console.GetMachine().GetLogFolder(); 591 CDisplay display = console.GetDisplay(); 592 int cGuestScreens = uisession()->session().GetMachine().GetMonitorCount(); 593 for (int i=0; i < cGuestScreens; ++i) 594 { 595 QString strFileName; 596 if (i == 0) 597 strFileName = strLogFolder + "/VBox.png"; 598 else 599 strFileName = QString("%1/VBox.%2.png").arg(strLogFolder).arg(i); 600 ULONG width = 0; 601 ULONG height = 0; 602 ULONG bpp = 0; 603 display.GetScreenResolution(i, width, height, bpp); 604 QImage shot = QImage(width, height, QImage::Format_RGB32); 605 display.TakeScreenShot(i, shot.bits(), shot.width(), shot.height()); 606 shot.save(QFile::encodeName(strFileName), "PNG"); 607 } 596 takeScreenshot(strLogFolder + "/VBox.png", "png"); 608 597 609 598 /* Warn the user about GURU: */ … … 889 878 uisession()->unpause(); 890 879 } 880 } 881 882 void UIMachineLogic::sltTakeScreenshot() 883 { 884 /* Do not process if window(s) missed! */ 885 if (!isMachineWindowsCreated()) 886 return; 887 888 /* Which image formats for writing does this Qt version know of? */ 889 QList<QByteArray> formats = QImageWriter::supportedImageFormats(); 890 QStringList filters; 891 /* Build a filters list out of it. */ 892 for (int i = 0; i < formats.size(); ++i) 893 filters << formats.at(i) + " (*." + formats.at(i).toLower() + ")"; 894 /* Try to select some common defaults. */ 895 QString strFilter; 896 int i = filters.indexOf(QRegExp(".*png.*", Qt::CaseInsensitive)); 897 if (i == -1) 898 { 899 i = filters.indexOf(QRegExp(".*jpe+g*", Qt::CaseInsensitive)); 900 if (i == -1) 901 i = filters.indexOf(QRegExp(".*bmp*", Qt::CaseInsensitive)); 902 } 903 if (i != -1) 904 strFilter = filters.at(i); 905 /* Request the filename from the user. */ 906 const CMachine &machine = session().GetMachine(); 907 const QString &strStart = machine.GetSettingsFilePath(); 908 QString strFilename = QIFileDialog::getSaveFileName(strStart, 909 filters.join(";;"), 910 defaultMachineWindow()->machineWindow(), 911 tr("Select a filename for the screenshot ..."), 912 &strFilter, 913 true /* resolve symlinks */, 914 true /* confirm overwrite */); 915 /* Do the screenshot. */ 916 if (!strFilename.isEmpty()) 917 takeScreenshot(strFilename, strFilter.split(" ").value(0, "png")); 891 918 } 892 919 … … 1606 1633 } 1607 1634 1635 void UIMachineLogic::takeScreenshot(const QString &strFile, const QString &strFormat /* = "png" */) const 1636 { 1637 /* Get console: */ 1638 const CConsole &console = session().GetConsole(); 1639 CDisplay display = console.GetDisplay(); 1640 const int cGuestScreens = uisession()->session().GetMachine().GetMonitorCount(); 1641 QList<QImage> images; 1642 ULONG uMaxWidth = 0; 1643 ULONG uMaxHeight = 0; 1644 /* First create screenshots of all guest screens and save them in a list. 1645 * Also sum the width of all images and search for the biggest image height. */ 1646 for (int i = 0; i < cGuestScreens; ++i) 1647 { 1648 ULONG width = 0; 1649 ULONG height = 0; 1650 ULONG bpp = 0; 1651 display.GetScreenResolution(i, width, height, bpp); 1652 uMaxWidth += width; 1653 uMaxHeight = RT_MAX(uMaxHeight, height); 1654 QImage shot = QImage(width, height, QImage::Format_RGB32); 1655 display.TakeScreenShot(i, shot.bits(), shot.width(), shot.height()); 1656 images << shot; 1657 } 1658 /* Create a image which will hold all sub images vertically. */ 1659 QImage bigImg = QImage(uMaxWidth, uMaxHeight, QImage::Format_RGB32); 1660 QPainter p(&bigImg); 1661 ULONG w = 0; 1662 /* Paint them. */ 1663 for (int i = 0; i < images.size(); ++i) 1664 { 1665 p.drawImage(w, 0, images.at(i)); 1666 w += images.at(i).width(); 1667 } 1668 p.end(); 1669 1670 /* Save the big image in the requested format. */ 1671 const QFileInfo fi(strFile); 1672 const QString &strPath = fi.absolutePath() + "/" + fi.baseName(); 1673 const QString &strSuffix = fi.suffix().isEmpty() ? strFormat : fi.suffix(); 1674 bigImg.save(QFile::encodeName(QString("%1.%2").arg(strPath).arg(strSuffix)), 1675 strFormat.toAscii().constData()); 1676 } 1677 1608 1678 #ifdef VBOX_WITH_DEBUGGER_GUI 1609 1679 bool UIMachineLogic::dbgCreated() -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r38348 r38477 63 63 /* Main getters/setters: */ 64 64 UISession* uisession() const { return m_pSession; } 65 CSession& session() ;65 CSession& session() const; 66 66 UIVisualStateType visualStateType() const { return m_visualStateType; } 67 67 const QList<UIMachineWindow*>& machineWindows() const { return m_machineWindowsList; } … … 157 157 void sltTypeCABS(); 158 158 #endif 159 159 160 void sltTakeSnapshot(); 161 void sltTakeScreenshot(); 160 162 void sltShowInformationDialog(); 161 163 void sltReset(); … … 196 198 const QString &strNameTemplate); 197 199 200 void takeScreenshot(const QString &strFile, const QString &strFormat /* = "png" */) const; 201 198 202 /* Private variables: */ 199 203 UISession *m_pSession; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp
r38476 r38477 193 193 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)); 194 194 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)); 195 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot)); 195 196 pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog)); 196 197 pMenu->addSeparator(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineShortcuts.cpp
r36357 r38477 28 28 m_Shortcuts[SettingsDialogShortcut] = UIKeySequence("SettingsDialog", "S"); 29 29 m_Shortcuts[TakeSnapshotShortcut] = UIKeySequence("TakeSnapshot", "T"); 30 m_Shortcuts[TakeScreenshotShortcut] = UIKeySequence("TakeScreenshot", "E"); 30 31 m_Shortcuts[InformationDialogShortcut] = UIKeySequence("InformationDialog", "N"); 31 32 m_Shortcuts[MouseIntegrationShortcut] = UIKeySequence("MouseIntegration" , "I"); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineShortcuts.h
r36357 r38477 30 30 SettingsDialogShortcut, 31 31 TakeSnapshotShortcut, 32 TakeScreenshotShortcut, 32 33 InformationDialogShortcut, 33 34 MouseIntegrationShortcut,
Note:
See TracChangeset
for help on using the changeset viewer.