Commit a98455bc authored by zoltan@webkit.org's avatar zoltan@webkit.org

[Qt] Add Take Screen Shot action to MiniBrowser

https://bugs.webkit.org/show_bug.cgi?id=53422

Reviewed by Andreas Kling.

Add Take Screen Shot action to MiniBrowser's view menu.

* MiniBrowser/qt/BrowserWindow.cpp:
(BrowserWindow::BrowserWindow):
(BrowserWindow::screenshot):
* MiniBrowser/qt/BrowserWindow.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f18f02c7
2011-01-31 Zoltan Horvath <zoltan@webkit.org>
Reviewed by Andreas Kling.
[Qt] Add Take Screen Shot action to MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=53422
Add Take Screen Shot action to MiniBrowser's view menu.
* MiniBrowser/qt/BrowserWindow.cpp:
(BrowserWindow::BrowserWindow):
(BrowserWindow::screenshot):
* MiniBrowser/qt/BrowserWindow.h:
2011-01-31 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Reviewed by Xan Lopez.
......@@ -68,6 +68,8 @@ BrowserWindow::BrowserWindow(QWKContext* context)
QAction* zoomText = viewMenu->addAction("Zoom Text Only", this, SLOT(toggleZoomTextOnly(bool)));
zoomText->setCheckable(true);
zoomText->setChecked(false);
viewMenu->addSeparator();
viewMenu->addAction("Take Screen Shot...", this, SLOT(screenshot()));
zoomIn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus));
zoomOut->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus));
......@@ -179,6 +181,35 @@ void BrowserWindow::openFile()
#endif
}
void BrowserWindow::screenshot()
{
QPixmap pixmap = QPixmap::grabWidget(m_browser);
QLabel* label = 0;
#if !defined(Q_OS_SYMBIAN)
label = new QLabel;
label->setAttribute(Qt::WA_DeleteOnClose);
label->setWindowTitle("Screenshot - Preview");
label->setPixmap(pixmap);
label->show();
#endif
#ifndef QT_NO_FILEDIALOG
QString fileName = QFileDialog::getSaveFileName(label, "Screenshot", QString(), QString("PNG File (.png)"));
if (!fileName.isEmpty()) {
QRegExp rx("*.png");
rx.setCaseSensitivity(Qt::CaseInsensitive);
rx.setPatternSyntax(QRegExp::Wildcard);
if (!rx.exactMatch(fileName))
fileName += ".png";
pixmap.save(fileName, "png");
if (label)
label->setWindowTitle(QString("Screenshot - Saved at %1").arg(fileName));
}
#endif
}
void BrowserWindow::zoomIn()
{
if (m_isZoomTextOnly)
......
......@@ -61,6 +61,7 @@ protected slots:
void zoomOut();
void resetZoom();
void toggleZoomTextOnly(bool on);
void screenshot();
void showUserAgentDialog();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment