Don't hardcode temp path

This commit is contained in:
lupoDharkael
2018-01-12 17:55:19 +01:00
parent 5f96f148d5
commit 514195ff41
2 changed files with 5 additions and 3 deletions

View File

@@ -92,10 +92,11 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent):
void AppLauncherWidget::launch(const QModelIndex &index) {
if (!QFileInfo(m_tempFile).isReadable()) {
m_tempFile = FileNameHandler().generateAbsolutePath("/tmp") + ".png";
m_tempFile = FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png";
bool ok = m_pixmap.save(m_tempFile);
if (!ok) {
QMessageBox::about(this, tr("Error"), tr("Unable to write in") + "/tmp.");
QMessageBox::about(this, tr("Error"), tr("Unable to write in")
+ QDir::tempPath());
return;
}
}

View File

@@ -26,6 +26,7 @@
#ifdef Q_OS_LINUX
#include <QDBusInterface>
#include <QDBusReply>
#include <QDir>
#endif
ScreenGrabber::ScreenGrabber(QObject *parent) : QObject(parent) {
@@ -41,7 +42,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
switch (m_info.windowManager()) {
case m_info.GNOME: {
// https://github.com/GNOME/gnome-shell/blob/695bfb96160033be55cfb5ac41c121998f98c328/data/org.gnome.Shell.Screenshot.xml
QString path = FileNameHandler().generateAbsolutePath("/tmp") + ".png";
QString path = FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png";
QDBusInterface gnomeInterface(QStringLiteral("org.gnome.Shell"),
QStringLiteral("/org/gnome/Shell/Screenshot"),
QStringLiteral("org.gnome.Shell.Screenshot"));