#include <screenshot.h>
Inheritance diagram for Screenshot:


Definition at line 39 of file screenshot.h.
Public Member Functions | |
| Screenshot () | |
Protected Member Functions | |
| void | resizeEvent (QResizeEvent *event) |
Private Slots | |
| void | newScreenshot () |
| void | saveScreenshot () |
| void | shootScreen () |
| void | updateCheckBox () |
Private Member Functions | |
| void | createOptionsGroupBox () |
| void | createButtonsLayout () |
| QPushButton * | createButton (const QString &text, QWidget *receiver, const char *member) |
| void | updateScreenshotLabel () |
Private Attributes | |
| QPixmap | originalPixmap |
| QLabel * | screenshotLabel |
| QGroupBox * | optionsGroupBox |
| QSpinBox * | delaySpinBox |
| QLabel * | delaySpinBoxLabel |
| QCheckBox * | hideThisWindowCheckBox |
| QPushButton * | newScreenshotButton |
| QPushButton * | saveScreenshotButton |
| QPushButton * | quitScreenshotButton |
| QVBoxLayout * | mainLayout |
| QGridLayout * | optionsGroupBoxLayout |
| QHBoxLayout * | buttonsLayout |
| Screenshot::Screenshot | ( | ) |
Definition at line 28 of file screenshot.cpp.
References QBoxLayout::addLayout(), QBoxLayout::addWidget(), Qt::AlignCenter, buttonsLayout, createButtonsLayout(), createOptionsGroupBox(), delaySpinBox, QSizePolicy::Expanding, mainLayout, optionsGroupBox, QWidget::resize(), screenshotLabel, QLabel::setAlignment(), QWidget::setLayout(), QWidget::setMinimumSize(), QWidget::setSizePolicy(), QSpinBox::setValue(), QWidget::setWindowTitle(), and shootScreen().
00029 { 00030 screenshotLabel = new QLabel; 00031 screenshotLabel->setSizePolicy(QSizePolicy::Expanding, 00032 QSizePolicy::Expanding); 00033 screenshotLabel->setAlignment(Qt::AlignCenter); 00034 screenshotLabel->setMinimumSize(240, 160); 00035 00036 createOptionsGroupBox(); 00037 createButtonsLayout(); 00038 00039 mainLayout = new QVBoxLayout; 00040 mainLayout->addWidget(screenshotLabel); 00041 mainLayout->addWidget(optionsGroupBox); 00042 mainLayout->addLayout(buttonsLayout); 00043 setLayout(mainLayout); 00044 00045 shootScreen(); 00046 delaySpinBox->setValue(5); 00047 00048 setWindowTitle(tr("Screenshot")); 00049 resize(300, 200); 00050 }
Here is the call graph for this function:

| void Screenshot::resizeEvent | ( | QResizeEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Reimplemented from QWidget.
Definition at line 52 of file screenshot.cpp.
References Qt::KeepAspectRatio, originalPixmap, QLabel::pixmap(), QSize::scale(), screenshotLabel, QWidget::size(), QPixmap::size(), and updateScreenshotLabel().
00053 { 00054 QSize scaledSize = originalPixmap.size(); 00055 scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio); 00056 if (!screenshotLabel->pixmap() 00057 || scaledSize != screenshotLabel->pixmap()->size()) 00058 updateScreenshotLabel(); 00059 }
Here is the call graph for this function:

| void Screenshot::newScreenshot | ( | ) | [private, slot] |
Definition at line 61 of file screenshot.cpp.
References delaySpinBox, QWidget::hide(), hideThisWindowCheckBox, QAbstractButton::isChecked(), newScreenshotButton, QWidget::setDisabled(), shootScreen(), QTimer::singleShot(), SLOT, and QSpinBox::value().
Referenced by createButtonsLayout().
00062 { 00063 if (hideThisWindowCheckBox->isChecked()) 00064 hide(); 00065 newScreenshotButton->setDisabled(true); 00066 00067 QTimer::singleShot(delaySpinBox->value() * 1000, this, SLOT(shootScreen())); 00068 }
| void Screenshot::saveScreenshot | ( | ) | [private, slot] |
Definition at line 70 of file screenshot.cpp.
References QDir::currentPath(), QFileDialog::getSaveFileName(), QString::isEmpty(), originalPixmap, and QPixmap::save().
Referenced by createButtonsLayout().
00071 { 00072 QString format = "png"; 00073 QString initialPath = QDir::currentPath() + tr("/untitled.") + format; 00074 00075 QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), 00076 initialPath, 00077 tr("%1 Files (*.%2);;All Files (*)") 00078 .arg(format.toUpper()) 00079 .arg(format)); 00080 if (!fileName.isEmpty()) 00081 originalPixmap.save(fileName, format.toAscii()); 00082 }
| void Screenshot::shootScreen | ( | ) | [private, slot] |
Definition at line 84 of file screenshot.cpp.
References delaySpinBox, QApplication::desktop(), QPixmap::grabWindow(), hideThisWindowCheckBox, QAbstractButton::isChecked(), newScreenshotButton, originalPixmap, qApp, QWidget::setDisabled(), QWidget::show(), updateScreenshotLabel(), QSpinBox::value(), and QWidget::winId().
Referenced by newScreenshot(), and Screenshot().
00085 { 00086 if (delaySpinBox->value() != 0) 00087 qApp->beep(); 00088 originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId()); 00089 updateScreenshotLabel(); 00090 00091 newScreenshotButton->setDisabled(false); 00092 if (hideThisWindowCheckBox->isChecked()) 00093 show(); 00094 }
| void Screenshot::updateCheckBox | ( | ) | [private, slot] |
Definition at line 96 of file screenshot.cpp.
References delaySpinBox, hideThisWindowCheckBox, QWidget::setDisabled(), and QSpinBox::value().
Referenced by createOptionsGroupBox().
00097 { 00098 if (delaySpinBox->value() == 0) 00099 hideThisWindowCheckBox->setDisabled(true); 00100 else 00101 hideThisWindowCheckBox->setDisabled(false); 00102 }
| void Screenshot::createOptionsGroupBox | ( | ) | [private] |
Definition at line 104 of file screenshot.cpp.
References QGridLayout::addWidget(), QObject::connect(), delaySpinBox, delaySpinBoxLabel, hideThisWindowCheckBox, optionsGroupBox, optionsGroupBoxLayout, QWidget::setLayout(), QSpinBox::setMaximum(), QSpinBox::setSuffix(), SIGNAL, SLOT, and updateCheckBox().
Referenced by Screenshot().
00105 { 00106 optionsGroupBox = new QGroupBox(tr("Options")); 00107 00108 delaySpinBox = new QSpinBox; 00109 delaySpinBox->setSuffix(tr(" s")); 00110 delaySpinBox->setMaximum(60); 00111 connect(delaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateCheckBox())); 00112 00113 delaySpinBoxLabel = new QLabel(tr("Screenshot Delay:")); 00114 00115 hideThisWindowCheckBox = new QCheckBox(tr("Hide This Window")); 00116 00117 optionsGroupBoxLayout = new QGridLayout; 00118 optionsGroupBoxLayout->addWidget(delaySpinBoxLabel, 0, 0); 00119 optionsGroupBoxLayout->addWidget(delaySpinBox, 0, 1); 00120 optionsGroupBoxLayout->addWidget(hideThisWindowCheckBox, 1, 0, 1, 2); 00121 optionsGroupBox->setLayout(optionsGroupBoxLayout); 00122 }
Here is the call graph for this function:

| void Screenshot::createButtonsLayout | ( | ) | [private] |
Definition at line 124 of file screenshot.cpp.
References QBoxLayout::addStretch(), QBoxLayout::addWidget(), buttonsLayout, QWidget::close(), createButton(), newScreenshot(), newScreenshotButton, quitScreenshotButton, saveScreenshot(), saveScreenshotButton, and SLOT.
Referenced by Screenshot().
00125 { 00126 newScreenshotButton = createButton(tr("New Screenshot"), 00127 this, SLOT(newScreenshot())); 00128 00129 saveScreenshotButton = createButton(tr("Save Screenshot"), 00130 this, SLOT(saveScreenshot())); 00131 00132 quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close())); 00133 00134 buttonsLayout = new QHBoxLayout; 00135 buttonsLayout->addStretch(); 00136 buttonsLayout->addWidget(newScreenshotButton); 00137 buttonsLayout->addWidget(saveScreenshotButton); 00138 buttonsLayout->addWidget(quitScreenshotButton); 00139 }
Here is the call graph for this function:

| QPushButton * Screenshot::createButton | ( | const QString & | text, | |
| QWidget * | receiver, | |||
| const char * | member | |||
| ) | [private] |
Definition at line 141 of file screenshot.cpp.
References QObject::connect(), and SIGNAL.
Referenced by createButtonsLayout().
00143 { 00144 QPushButton *button = new QPushButton(text); 00145 button->connect(button, SIGNAL(clicked()), receiver, member); 00146 return button; 00147 }
Here is the call graph for this function:

| void Screenshot::updateScreenshotLabel | ( | ) | [private] |
Definition at line 149 of file screenshot.cpp.
References Qt::KeepAspectRatio, originalPixmap, QPixmap::scaled(), screenshotLabel, QLabel::setPixmap(), QWidget::size(), and Qt::SmoothTransformation.
Referenced by resizeEvent(), and shootScreen().
00150 { 00151 screenshotLabel->setPixmap(originalPixmap.scaled(screenshotLabel->size(), 00152 Qt::KeepAspectRatio, 00153 Qt::SmoothTransformation)); 00154 }
Here is the call graph for this function:

QPixmap Screenshot::originalPixmap [private] |
Definition at line 62 of file screenshot.h.
Referenced by resizeEvent(), saveScreenshot(), shootScreen(), and updateScreenshotLabel().
QLabel* Screenshot::screenshotLabel [private] |
Definition at line 64 of file screenshot.h.
Referenced by resizeEvent(), Screenshot(), and updateScreenshotLabel().
QGroupBox* Screenshot::optionsGroupBox [private] |
Definition at line 65 of file screenshot.h.
Referenced by createOptionsGroupBox(), and Screenshot().
QSpinBox* Screenshot::delaySpinBox [private] |
Definition at line 66 of file screenshot.h.
Referenced by createOptionsGroupBox(), newScreenshot(), Screenshot(), shootScreen(), and updateCheckBox().
QLabel* Screenshot::delaySpinBoxLabel [private] |
QCheckBox* Screenshot::hideThisWindowCheckBox [private] |
Definition at line 68 of file screenshot.h.
Referenced by createOptionsGroupBox(), newScreenshot(), shootScreen(), and updateCheckBox().
QPushButton* Screenshot::newScreenshotButton [private] |
Definition at line 69 of file screenshot.h.
Referenced by createButtonsLayout(), newScreenshot(), and shootScreen().
QPushButton* Screenshot::saveScreenshotButton [private] |
QPushButton* Screenshot::quitScreenshotButton [private] |
QVBoxLayout* Screenshot::mainLayout [private] |
QGridLayout* Screenshot::optionsGroupBoxLayout [private] |
QHBoxLayout* Screenshot::buttonsLayout [private] |
1.5.1