KRecentDocument Class
Manage the "Recent Document Menu" entries displayed by applications such as Kicker and Konqueror. More...
Header: | #include <KRecentDocument> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
Public Types
(since 5.93) enum | RecentDocumentGroup { Development, Office, Database, Email, Presentation, …, Special } |
Static Public Members
void | add(const QUrl &url) |
(since 5.93) void | add(const QUrl &url, KRecentDocument::RecentDocumentGroups groups) |
void | add(const QUrl &url, const QString &desktopEntryName) |
(since 5.93) void | add(const QUrl &url, const QString &desktopEntryName, KRecentDocument::RecentDocumentGroups groups) |
void | clear() |
bool | clearEntriesOldestEntries(int maxEntries) |
int | maximumItems() |
(since 5.93) QList<QUrl> | recentUrls() |
(since 6.6) void | removeApplication(const QString &desktopEntryName) |
(since 6.6) void | removeBookmarksModifiedSince(const QDateTime &since) |
(since 6.6) void | removeFile(const QUrl &url) |
Detailed Description
These entries are automatically generated .desktop files pointing to the current application and document. You should call the static add() method whenever the user opens or saves a new document if you want it to show up in the menu.
It also stores history following xdg specification. Ref: https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec This allows cross-framework file history sharing. I.e Gtk Apps can access files recently opened by KDE Apps.
You don't have to worry about this if you are using QFileDialog to open and save documents, as the KDE implementation (KFileWidget) already calls this class. User defined limits on the maximum number of documents to save, etc... are all automatically handled.
Member Type Documentation
[since 5.93]
enum KRecentDocument::RecentDocumentGroup
Usage group for a file to bookmark in recently-used.xbel file
From spec https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec/#appendixb:registeredgroupnames
Constant | Value | Description |
---|---|---|
KRecentDocument::Development | 0 | A bookmark related to a development environment |
KRecentDocument::Office | 1 | A bookmark related to an office type document or folder |
KRecentDocument::Database | 2 | A bookmark related to a database application; Office; relates to Development |
KRecentDocument::Email | 3 | A bookmark related to an email application relates to Office |
KRecentDocument::Presentation | 4 | A bookmark related to a presentation application relates to Office |
KRecentDocument::Spreadsheet | 5 | A bookmark related to a spreadsheet application relates to Office |
KRecentDocument::WordProcessor | 6 | A bookmark related to a word processing application relates to Office |
KRecentDocument::Graphics | 7 | A bookmark related to a graphical application |
KRecentDocument::TextEditor | 8 | A bookmark related to a text editor |
KRecentDocument::Viewer | 9 | A bookmark related to any kind of file viewer |
KRecentDocument::Archive | 10 | A bookmark related to an archive file |
KRecentDocument::Multimedia | 11 | A bookmark related to a multimedia file or application |
KRecentDocument::Audio | 12 | A bookmark related to an audio file or application relates to Multimedia |
KRecentDocument::Video | 13 | A bookmark related to a video file or application relates to Multimedia |
KRecentDocument::Photo | 14 | A bookmark related to a digital photography file or application relates to Multimedia; Graphics; Viewer |
KRecentDocument::Special | ? | bookmark for application launchers |
This enum was introduced in 5.93.
Member Function Documentation
[static]
void KRecentDocument::add(const QUrl &url)
Add a new item to the Recent Document menu.
url The url to add.
[static, since 5.93]
void KRecentDocument::add(const QUrl &url, KRecentDocument::RecentDocumentGroups groups)
This function was introduced in 5.93.
[static]
void KRecentDocument::add(const QUrl &url, const QString &desktopEntryName)
Add a new item to the Recent Document menu, specifying the application to open it with. The above add() method uses QCoreApplication::applicationName() for the app name, which isn't always flexible enough. This method is used when an application launches another one to open a document.
url The url to add.
desktopEntryName The desktopEntryName of the service to use for opening this document.
[static, since 5.93]
void KRecentDocument::add(const QUrl &url, const QString &desktopEntryName, KRecentDocument::RecentDocumentGroups groups)
This function was introduced in 5.93.
[static]
void KRecentDocument::clear()
Clear the recent document menu of all entries.
[static]
bool KRecentDocument::clearEntriesOldestEntries(int maxEntries)
[static]
int KRecentDocument::maximumItems()
Returns the maximum amount of recent document entries allowed.
[static, since 5.93]
QList<QUrl> KRecentDocument::recentUrls()
Returns a list of recent URLs. This includes all the URLs from recentDocuments() as well as URLs from other applications conforming to the XDG desktop-bookmark-spec (e. g. the GTK file dialog).
This function was introduced in 5.93.
[static, since 6.6]
void KRecentDocument::removeApplication(const QString &desktopEntryName)
This function was introduced in 6.6.
[static, since 6.6]
void KRecentDocument::removeBookmarksModifiedSince(const QDateTime &since)
Remove bookmarks whose modification date is after since parameter.
This function was introduced in 6.6.
[static, since 6.6]
void KRecentDocument::removeFile(const QUrl &url)
This function was introduced in 6.6.