Changeset 57688 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 10, 2015 12:08:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r57591 r57688 1646 1646 return; 1647 1647 1648 /* Formatting default and temporary filenames for screenshot accroding to current time: */ 1649 const QFileInfo fi(machine().GetSettingsFilePath()); 1650 const QString strCurrentTime = QDateTime::currentDateTime().toString("dd_MM_yyyy_hh_mm_ss"); 1651 const QString strFormatDefaultFileName = QString("VirtualBox").append("_").append(machine().GetName()).append("_"). 1652 append(strCurrentTime); 1653 const QString strDefaultFileName = QDir(fi.absolutePath()).absoluteFilePath(strFormatDefaultFileName); 1654 const QString strTempFile = QDir(fi.absolutePath()).absoluteFilePath("temp").append(strCurrentTime).append(".png"); 1655 1656 /* Do the screenshot: */ 1657 takeScreenshot(strTempFile, "png"); 1658 1648 1659 /* Which image formats for writing does this Qt version know of? */ 1649 1660 QList<QByteArray> formats = QImageWriter::supportedImageFormats(); 1650 1661 QStringList filters; 1651 /* Build a filters list out of it .*/1662 /* Build a filters list out of it: */ 1652 1663 for (int i = 0; i < formats.size(); ++i) 1653 1664 { … … 1657 1668 filters << s; 1658 1669 } 1659 /* Try to select some common defaults .*/1670 /* Try to select some common defaults: */ 1660 1671 QString strFilter; 1661 1672 int i = filters.indexOf(QRegExp(".*png.*", Qt::CaseInsensitive)); … … 1681 1692 #endif /* Q_WS_WIN */ 1682 1693 1683 /* Request the filename from the user. */ 1684 QFileInfo fi(machine().GetSettingsFilePath()); 1685 QString strAbsolutePath(fi.absolutePath()); 1686 QString strCompleteBaseName(fi.completeBaseName()); 1687 QString strStart = QDir(strAbsolutePath).absoluteFilePath(strCompleteBaseName); 1688 QString strFilename = QIFileDialog::getSaveFileName(strStart, 1694 /* Request the filename from the user: */ 1695 const QString strFilename = QIFileDialog::getSaveFileName(strDefaultFileName, 1689 1696 filters.join(";;"), 1690 1697 activeMachineWindow(), … … 1704 1711 #endif /* Q_WS_WIN */ 1705 1712 1706 /* Do the screenshot. */1707 1713 if (!strFilename.isEmpty()) 1708 takeScreenshot(strFilename, strFilter.split(" ").value(0, "png")); 1714 { 1715 const QString strFormat = strFilter.split(" ").value(0, "png"); 1716 const QImage tmpImage(strTempFile); 1717 1718 /* On X11 Qt Filedialog returns the filepath without the filetype suffix, 1719 * so adding it ourselves: */ 1720 #ifdef Q_WS_X11 1721 tmpImage.save(QDir::toNativeSeparators(QFile::encodeName(QString("%1.%2").arg(strFilename, strFormat))), 1722 strFormat.toAscii().constData()); 1723 #else /* !Q_WS_X11 */ 1724 tmpImage.save(QDir::toNativeSeparators(QFile::encodeName(strFilename)), 1725 strFormat.toAscii().constData()); 1726 #endif /* !Q_WS_X11 */ 1727 } 1728 QFile::remove(strTempFile); 1709 1729 } 1710 1730
Note:
See TracChangeset
for help on using the changeset viewer.