Changeset 77130 in webkit


Ignore:
Timestamp:
Jan 31, 2011 7:39:43 AM (13 years ago)
Author:
zoltan@webkit.org
Message:

[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:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r77123 r77130  
     12011-01-31  Zoltan Horvath  <zoltan@webkit.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Add Take Screen Shot action to MiniBrowser
     6        https://bugs.webkit.org/show_bug.cgi?id=53422
     7
     8        Add Take Screen Shot action to MiniBrowser's view menu.
     9
     10        * MiniBrowser/qt/BrowserWindow.cpp:
     11        (BrowserWindow::BrowserWindow):
     12        (BrowserWindow::screenshot):
     13        * MiniBrowser/qt/BrowserWindow.h:
     14
    1152011-01-31  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    216
  • trunk/Tools/MiniBrowser/qt/BrowserWindow.cpp

    r76930 r77130  
    6969    zoomText->setCheckable(true);
    7070    zoomText->setChecked(false);
     71    viewMenu->addSeparator();
     72    viewMenu->addAction("Take Screen Shot...", this, SLOT(screenshot()));
    7173
    7274    zoomIn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus));
     
    180182}
    181183
     184void BrowserWindow::screenshot()
     185{
     186    QPixmap pixmap = QPixmap::grabWidget(m_browser);
     187    QLabel* label = 0;
     188#if !defined(Q_OS_SYMBIAN)
     189    label = new QLabel;
     190    label->setAttribute(Qt::WA_DeleteOnClose);
     191    label->setWindowTitle("Screenshot - Preview");
     192    label->setPixmap(pixmap);
     193    label->show();
     194#endif
     195
     196#ifndef QT_NO_FILEDIALOG
     197    QString fileName = QFileDialog::getSaveFileName(label, "Screenshot", QString(), QString("PNG File (.png)"));
     198    if (!fileName.isEmpty()) {
     199        QRegExp rx("*.png");
     200        rx.setCaseSensitivity(Qt::CaseInsensitive);
     201        rx.setPatternSyntax(QRegExp::Wildcard);
     202
     203        if (!rx.exactMatch(fileName))
     204            fileName += ".png";
     205
     206        pixmap.save(fileName, "png");
     207        if (label)
     208            label->setWindowTitle(QString("Screenshot - Saved at %1").arg(fileName));
     209    }
     210#endif
     211}
     212
    182213void BrowserWindow::zoomIn()
    183214{
  • trunk/Tools/MiniBrowser/qt/BrowserWindow.h

    r76930 r77130  
    6262    void resetZoom();
    6363    void toggleZoomTextOnly(bool on);
     64    void screenshot();
    6465
    6566    void showUserAgentDialog();
Note: See TracChangeset for help on using the changeset viewer.