Qt
view release on metacpan or search on metacpan
qtgui/examples/desktop/screenshot/Screenshot.pm view on Meta::CPAN
this->shootScreen();
this->delaySpinBox->setValue(5);
this->setWindowTitle(this->tr('Screenshot'));
this->resize(300, 200);
}
# [0]
# [1]
sub resizeEvent
{
my $scaledSize = this->originalPixmap->size();
$scaledSize->scale(this->screenshotLabel->size(), Qt::KeepAspectRatio());
if (!this->screenshotLabel->pixmap()
|| $scaledSize != this->screenshotLabel->pixmap()->size()) {
this->updateScreenshotLabel();
}
}
# [1]
# [2]
sub newScreenshot
{
if (this->hideThisWindowCheckBox->isChecked()) {
this->hide();
}
this->newScreenshotButton->setDisabled(1);
Qt::Timer::singleShot(this->delaySpinBox->value() * 1000, this, SLOT 'shootScreen()');
}
# [2]
# [3]
sub saveScreenshot
{
my $format = 'png';
my $initialPath = Qt::Dir::currentPath() . this->tr('/untitled.') . $format;
my $fileName = Qt::FileDialog::getSaveFileName(this, this->tr('Save As'),
$initialPath,
sprintf this->tr('%s Files (*.%s);;All Files (*)'),
uc($format),
$format);
if ($fileName) {
this->originalPixmap->save($fileName, $format);
}
}
# [3]
# [4]
sub shootScreen
{
if (this->delaySpinBox->value() != 0) {
qApp->beep();
}
# [4]
# clear image for low memory situations on embedded devices.
this->setOriginalPixmap( Qt::Pixmap() );
# [5]
this->setOriginalPixmap( Qt::Pixmap::grabWindow(Qt::Application::desktop()->winId()) );
this->updateScreenshotLabel();
this->newScreenshotButton->setDisabled(0);
if (this->hideThisWindowCheckBox->isChecked()) {
this->show();
}
}
# [5]
# [6]
sub updateCheckBox
{
if (this->delaySpinBox->value() == 0) {
this->hideThisWindowCheckBox->setDisabled(1);
}
else {
this->hideThisWindowCheckBox->setDisabled(0);
}
}
# [6]
# [7]
sub createOptionsGroupBox
{
this->setOptionsGroupBox( Qt::GroupBox(this->tr('Options')) );
this->setDelaySpinBox( Qt::SpinBox() );
this->delaySpinBox->setSuffix(this->tr(' s'));
this->delaySpinBox->setMaximum(60);
this->connect(this->delaySpinBox, SIGNAL 'valueChanged(int)', this, SLOT 'updateCheckBox()');
this->setDelaySpinBoxLabel( Qt::Label(this->tr('Screenshot Delay:')) );
this->setHideThisWindowCheckBox( Qt::CheckBox(this->tr('Hide This Window')) );
this->setOptionsGroupBoxLayout( Qt::GridLayout() );
this->optionsGroupBoxLayout->addWidget(this->delaySpinBoxLabel, 0, 0);
this->optionsGroupBoxLayout->addWidget(this->delaySpinBox, 0, 1);
this->optionsGroupBoxLayout->addWidget(this->hideThisWindowCheckBox, 1, 0, 1, 2);
this->optionsGroupBox->setLayout(this->optionsGroupBoxLayout);
}
# [7]
# [8]
sub createButtonsLayout
{
this->setNewScreenshotButton( createButton(this->tr('New Screenshot'),
this, SLOT 'newScreenshot()') );
this->setSaveScreenshotButton( createButton(this->tr('Save Screenshot'),
this, SLOT 'saveScreenshot()') );
this->setQuitScreenshotButton( createButton(this->tr('Quit'), this, SLOT 'close()') );
this->setButtonsLayout( Qt::HBoxLayout() );
this->buttonsLayout->addStretch();
this->buttonsLayout->addWidget(this->newScreenshotButton);
this->buttonsLayout->addWidget(this->saveScreenshotButton);
this->buttonsLayout->addWidget(this->quitScreenshotButton);
}
( run in 2.227 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )