2022-10-12 16:00:12 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2022 by Devin Lin <devin@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "recordutil.h"
|
|
|
|
|
|
2022-10-12 16:06:11 +00:00
|
|
|
#include <QFile>
|
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
|
|
|
|
|
#include <KFileUtils>
|
2022-10-12 16:00:12 +00:00
|
|
|
#include <KNotification>
|
|
|
|
|
|
2022-10-12 16:06:11 +00:00
|
|
|
RecordUtil::RecordUtil(QObject *parent)
|
|
|
|
|
: QObject{parent}
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 16:00:12 +00:00
|
|
|
QString RecordUtil::videoLocation(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
|
|
|
|
|
QString newPath(path + '/' + name);
|
|
|
|
|
if (QFile::exists(newPath)) {
|
|
|
|
|
newPath = path + '/' + KFileUtils::suggestName(QUrl::fromLocalFile(newPath), name);
|
|
|
|
|
}
|
|
|
|
|
return newPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RecordUtil::showNotification(const QString &title, const QString &text, const QString &filePath)
|
|
|
|
|
{
|
|
|
|
|
KNotification *notif = new KNotification("captured");
|
|
|
|
|
notif->setComponentName(QStringLiteral("plasma_phone_components"));
|
|
|
|
|
notif->setTitle(title);
|
|
|
|
|
notif->setUrls({QUrl::fromLocalFile(filePath)});
|
|
|
|
|
notif->setText(text);
|
|
|
|
|
notif->sendEvent();
|
|
|
|
|
}
|