|
|
|
|
@ -80,7 +80,39 @@ void ScreenshotView::saveFile(QRect rect)
|
|
|
|
|
|
|
|
|
|
QImage image("/tmp/cutefish-screenshot.png");
|
|
|
|
|
QImage cropped = image.copy(rect);
|
|
|
|
|
cropped.save(fileName);
|
|
|
|
|
bool saved = cropped.save(fileName);
|
|
|
|
|
|
|
|
|
|
if (saved) {
|
|
|
|
|
QDBusInterface iface("org.freedesktop.Notifications",
|
|
|
|
|
"/org/freedesktop/Notifications",
|
|
|
|
|
"org.freedesktop.Notifications",
|
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
|
if (iface.isValid()) {
|
|
|
|
|
QList<QVariant> args;
|
|
|
|
|
args << "cutefish-screenshot";
|
|
|
|
|
args << ((unsigned int) 0);
|
|
|
|
|
args << "cutefish-screenshot";
|
|
|
|
|
args << "";
|
|
|
|
|
args << tr("The picture has been saved to %1").arg(fileName);
|
|
|
|
|
args << QStringList();
|
|
|
|
|
args << QVariantMap();
|
|
|
|
|
args << (int) 10;
|
|
|
|
|
iface.asyncCallWithArgumentList("Notify", args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeTmpFile();
|
|
|
|
|
this->quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenshotView::copyToClipboard(QRect rect)
|
|
|
|
|
{
|
|
|
|
|
setVisible(false);
|
|
|
|
|
|
|
|
|
|
QImage image("/tmp/cutefish-screenshot.png");
|
|
|
|
|
QImage cropped = image.copy(rect);
|
|
|
|
|
QClipboard *clipboard = qGuiApp->clipboard();
|
|
|
|
|
clipboard->setImage(cropped);
|
|
|
|
|
|
|
|
|
|
QDBusInterface iface("org.freedesktop.Notifications",
|
|
|
|
|
"/org/freedesktop/Notifications",
|
|
|
|
|
@ -92,7 +124,7 @@ void ScreenshotView::saveFile(QRect rect)
|
|
|
|
|
args << ((unsigned int) 0);
|
|
|
|
|
args << "cutefish-screenshot";
|
|
|
|
|
args << "";
|
|
|
|
|
args << tr("The picture has been saved to %1").arg(fileName);
|
|
|
|
|
args << tr("The picture has been saved to the clipboard");
|
|
|
|
|
args << QStringList();
|
|
|
|
|
args << QVariantMap();
|
|
|
|
|
args << (int) 10;
|
|
|
|
|
@ -103,19 +135,6 @@ void ScreenshotView::saveFile(QRect rect)
|
|
|
|
|
this->quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenshotView::copyToClipboard(QRect rect)
|
|
|
|
|
{
|
|
|
|
|
setVisible(false);
|
|
|
|
|
|
|
|
|
|
QImage image("/tmp/cutefish-screenshot.png");
|
|
|
|
|
QImage cropped = image.copy(rect);
|
|
|
|
|
QClipboard *clipboard = qGuiApp->clipboard();
|
|
|
|
|
clipboard->setImage(cropped);
|
|
|
|
|
|
|
|
|
|
removeTmpFile();
|
|
|
|
|
this->quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenshotView::removeTmpFile()
|
|
|
|
|
{
|
|
|
|
|
bool success = QFile("/tmp/cutefish-screenshot.png").remove();
|
|
|
|
|
|