diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp index ab9d43d..3455fff 100644 --- a/containments/panel/phonepanel.cpp +++ b/containments/panel/phonepanel.cpp @@ -1,135 +1,129 @@ /*************************************************************************** * Copyright (C) 2015 Marco Martin * * Copyright (C) 2018 Bhushan Shah * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "phonepanel.h" #include #include -#include #include -#include -#include +#include #include #include #include #include "screenshotinterface.h" PhonePanel::PhonePanel(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) { //setHasConfigurationInterface(true); } PhonePanel::~PhonePanel() = default; void PhonePanel::executeCommand(const QString &command) { qWarning()<<"Executing"< we need to use screenshot area - // this won't work with multiple screens - QSize screenSize = QGuiApplication::primaryScreen()->size(); - QDBusPendingReply reply = interface->screenshotArea(0, 0, screenSize.width(), screenSize.height()); + QDBusPendingReply reply = interface->screenshotFullscreen(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *watcher) { QDBusPendingReply reply = *watcher; if (reply.isError()) { qWarning() << "Creating the screenshot failed:" << reply.error().name() << reply.error().message(); } else { QString filePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); if (filePath.isEmpty()) { qWarning() << "Couldn't find a writable location for the screenshot! The screenshot is in /tmp."; return; } QDir picturesDir(filePath); if (!picturesDir.mkpath(QStringLiteral("Screenshots"))) { qWarning() << "Couldn't create folder at" << picturesDir.path() + QStringLiteral("/Screenshots") << "to take screenshot."; return; } filePath += QStringLiteral("/Screenshots/Screenshot_%1.png") .arg(QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_hhmmss"))); const QString currentPath = reply.argumentAt<0>(); QtConcurrent::run(QThreadPool::globalInstance(), [=]() { QFile screenshotFile(currentPath); if (!screenshotFile.rename(filePath)) { qWarning() << "Couldn't move screenshot into Pictures folder:" << screenshotFile.errorString(); } qDebug() << "Successfully saved screenshot at" << filePath; }); } watcher->deleteLater(); interface->deleteLater(); }); } K_EXPORT_PLASMA_APPLET_WITH_JSON(quicksettings, PhonePanel, "metadata.json") #include "phonepanel.moc"