2023-01-04 17:28:07 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UKUI_MENU_RECENT_FILE_EXTENSION_H
|
|
|
|
#define UKUI_MENU_RECENT_FILE_EXTENSION_H
|
|
|
|
|
2023-05-31 15:47:11 +08:00
|
|
|
class QThread;
|
2023-01-17 10:53:00 +08:00
|
|
|
|
2023-04-09 11:22:39 +08:00
|
|
|
#include "menu-extension-iface.h"
|
2023-01-04 17:28:07 +08:00
|
|
|
|
|
|
|
namespace UkuiMenu {
|
|
|
|
|
2023-05-31 15:47:11 +08:00
|
|
|
class RecentFilesModel;
|
|
|
|
class RecentFileProvider;
|
|
|
|
|
2023-01-04 17:28:07 +08:00
|
|
|
class RecentFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
quint64 accessTime{0};
|
|
|
|
QString uri;
|
|
|
|
QString name;
|
|
|
|
QString icon;
|
2023-03-16 14:14:16 +08:00
|
|
|
QString infoId;
|
2023-01-04 17:28:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class RecentFileExtension : public MenuExtensionIFace
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-04-09 11:22:39 +08:00
|
|
|
Q_PLUGIN_METADATA(IID UKUI_MENU_EXTENSION_IFACE_IID FILE "metadata.json")
|
|
|
|
Q_INTERFACES(UkuiMenu::MenuExtensionIFace)
|
2023-01-04 17:28:07 +08:00
|
|
|
public:
|
|
|
|
explicit RecentFileExtension(QObject *parent = nullptr);
|
2023-04-09 11:22:39 +08:00
|
|
|
~RecentFileExtension() override;
|
2023-01-04 17:28:07 +08:00
|
|
|
int index() override;
|
|
|
|
QString name() override;
|
|
|
|
QUrl url() override;
|
|
|
|
QVariantMap data() override;
|
|
|
|
void receive(QVariantMap data) override;
|
2023-01-17 10:53:00 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QVector<RecentFile> m_recentFile;
|
|
|
|
QVariantMap m_data;
|
|
|
|
RecentFilesModel *m_recentFilesModel = nullptr;
|
|
|
|
QThread *m_recentFilesProviderThread = nullptr;
|
|
|
|
RecentFileProvider *m_recentFileProvider = nullptr;
|
|
|
|
|
2023-05-31 15:47:11 +08:00
|
|
|
void openFile(const QString& fileUrl);
|
2023-03-16 14:14:16 +08:00
|
|
|
void creatMenu(const QString &path, const int &index);
|
2023-01-17 10:53:00 +08:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void loadRecentFiles();
|
|
|
|
void openFileASync(const QString &path);
|
2023-01-04 17:28:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // UkuiMenu
|
|
|
|
|
|
|
|
#endif //UKUI_MENU_RECENT_FILE_EXTENSION_H
|