File tree Expand file tree Collapse file tree 5 files changed +31
-7
lines changed
Expand file tree Collapse file tree 5 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -421,11 +421,14 @@ void MainWindow::cutFile() {
421421 modelList->addCutItems (fileList);
422422
423423 // Save a temp file to allow pasting in a different instance
424- QFile tempFile (QDir::tempPath () + QString (" /%1.temp" ).arg (APP));
425- tempFile.open (QIODevice::WriteOnly);
426- QDataStream out (&tempFile);
427- out << fileList;
428- tempFile.close ();
424+ const QString clipboardFile = Common::getTempClipboardFile ();
425+ if (!clipboardFile.isEmpty ()) {
426+ QFile tempFile (clipboardFile);
427+ tempFile.open (QIODevice::WriteOnly);
428+ QDataStream out (&tempFile);
429+ out << fileList;
430+ tempFile.close ();
431+ }
429432
430433 QApplication::clipboard ()->setMimeData (modelView->mimeData (selList));
431434
Original file line number Diff line number Diff line change @@ -958,7 +958,7 @@ void MainWindow::pasteClipboard() {
958958 else { newPath = pathEdit->itemText (0 ); }
959959
960960 // Check list of files that are to be cut
961- QFile tempFile (QDir::tempPath () + " / " + APP + " .temp " );
961+ QFile tempFile (Common::getTempClipboardFile () );
962962 if (tempFile.exists ()) {
963963 tempFile.open (QIODevice::ReadOnly);
964964 QDataStream out (&tempFile);
Original file line number Diff line number Diff line change @@ -679,3 +679,21 @@ QString Common::hasThumbnail(const QString &filename)
679679 }
680680 return QString ();
681681}
682+
683+ QString Common::getTempPath ()
684+ {
685+ const QString path = QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation);
686+ qDebug () << " Temp folder" << path;
687+ QDir dir (path);
688+ if (!dir.exists ()) {
689+ if (!dir.mkpath (path)) { return QString (); }
690+ }
691+ return path;
692+ }
693+
694+ QString Common::getTempClipboardFile ()
695+ {
696+ const QString path = getTempPath ();
697+ if (path.isEmpty ()) { return QString (); }
698+ return QString (" %1/clipboard.tmp" ).arg (path);
699+ }
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ class Common
104104 static QString getXdgCacheHome ();
105105 static QString getThumbnailHash (const QString &filename);
106106 static QString hasThumbnail (const QString &filename);
107+ static QString getTempPath ();
108+ static QString getTempClipboardFile ();
107109};
108110
109111#endif // COMMON_H
Original file line number Diff line number Diff line change @@ -1480,6 +1480,7 @@ void myModel::addCutItems(QStringList files)
14801480void myModel::clearCutItems ()
14811481{
14821482 cutItems.clear ();
1483- QFile (QDir::tempPath () + QString (" /%1.temp" ).arg (APP)).remove ();
1483+ QFile temp (Common::getTempClipboardFile ());
1484+ if (temp.exists ()) { temp.remove (); }
14841485}
14851486
You can’t perform that action at this time.
0 commit comments