Skip to content

Commit

Permalink
Switched to QUrl::fromLocalFile
Browse files Browse the repository at this point in the history
Formatting.
  • Loading branch information
poetaster committed Apr 12, 2022
1 parent 25f77fd commit a62027b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/calendarthreadwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ QTM_USE_NAMESPACE
# include <extendedstorage.h>
# include <KCalendarCore/Event>
# include <KCalendarCore/ICalFormat>
# include <QTimeZone>
# include <QDesktopServices>
# include <QDirIterator>
# include <QFile>
# include <QTemporaryFile>
# include <QTextStream>
# include <QSettings>
# include <QDir>
# include <QUrl>

Expand Down Expand Up @@ -184,18 +180,20 @@ void CalendarThreadWrapper::addToCalendar()
KCalendarCore::ICalFormat format;
QString icsData = format.toICalString(event);
QTemporaryFile *tmpFile = new QTemporaryFile(
QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
QDir::separator() + "event-XXXXXX.ics",
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) +
QDir::separator() + "event-XXXXXX.ics",
this);
// destructed and file deleted with this object

qDebug() << "IcalData: " << icsData;
if (tmpFile->open()) {
//qDebug() << "IcalData: " << icsData;
if (tmpFile->open())
{
QTextStream stream( tmpFile );
stream << icsData;
tmpFile->close();
qDebug() << "Opening" << tmpFile->fileName();
if (!QDesktopServices::openUrl(QUrl("file://" + tmpFile->fileName(), QUrl::TolerantMode))) {
if ( !QDesktopServices::openUrl(QUrl::fromLocalFile(tmpFile->fileName())) )
{
qWarning() << "QDesktopServices::openUrl fails!";
emit addCalendarEntryComplete(false);
} else {
Expand All @@ -205,8 +203,8 @@ void CalendarThreadWrapper::addToCalendar()
#else
emit addCalendarEntryComplete(false);
#endif

//QThread::currentThread()->exit(0);
// We have to move this for now
// QThread::currentThread()->exit(0);

// Move back to GUI thread so the deleteLater() callback works (it requires
// an event loop which is still alive)
Expand Down

0 comments on commit a62027b

Please sign in to comment.