ukui-menu/extension/recent-file/recent-file-extension.h

73 lines
2.0 KiB
C
Raw Permalink Normal View History

/*
* 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
class QThread;
2023-01-17 10:53:00 +08:00
#include "menu-extension-iface.h"
namespace UkuiMenu {
class RecentFilesModel;
class RecentFileProvider;
class RecentFile
{
public:
quint64 accessTime{0};
QString uri;
QString name;
QString icon;
2023-03-16 14:14:16 +08:00
QString infoId;
};
class RecentFileExtension : public MenuExtensionIFace
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_MENU_EXTENSION_IFACE_IID FILE "metadata.json")
Q_INTERFACES(UkuiMenu::MenuExtensionIFace)
public:
explicit RecentFileExtension(QObject *parent = nullptr);
~RecentFileExtension() override;
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;
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);
};
} // UkuiMenu
#endif //UKUI_MENU_RECENT_FILE_EXTENSION_H