KSycoca Class
Read-only SYstem COnfiguration CAche. More...
Header: | #include <KSycoca> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Service) target_link_libraries(mytarget PRIVATE KF6::Service) |
Inherits: | QObject |
Public Functions
(since 5.15) void | ensureCacheValid() |
Signals
void | databaseChanged() |
Static Public Members
void | disableAutoRebuild() |
bool | isAvailable() |
KSycoca * | self() |
(since 6.0) void | setupTestMenu() |
int | version() |
Macros
Detailed Description
Member Function Documentation
[signal]
void KSycoca::databaseChanged()
Connect to this to get notified when the database changes.
Example: after creating a .desktop file in KOpenWithDialog, it must wait until kbuildsycoca6 finishes until the KService::Ptr is available. Other examples: anything that displays a list of apps or plugins to the user and which is always visible (otherwise querying sycoca before showing could be enough).
[static]
void KSycoca::disableAutoRebuild()
Disables automatic rebuilding of the cache on service file changes.
Be extremely careful when using this. Only threads that definitely have no use for automatic reloading should use this. Specifically shared runner threads (as seen in the threadweaver framework) can avoid claiming persistent resources this way (e.g. inotify instances on Linux).
[since 5.15]
void KSycoca::ensureCacheValid()
Ensures the ksycoca database is up to date.
If the database was modified by another process, close it, so the next use reopens it. If the desktop files have been modified more recently than the database, update it.
Update the sycoca file from the files on disk (e.g. desktop files or mimeapps.list). You don't normally have to call this because the next use of KSycoca (e.g. via KMimeTypeTrader, KService etc.) will notice that the sycoca database is out of date, by looking a directory modification times. In addition, in a full KDE session, kded monitors directories to detect changes.
This is however useful for GUIs that allow to create a new desktop file and then want to ensure it is available immediately in KSycoca. This is also useful after modifying a mimeapps.list file.
KBuildSycocaProgressDialog can also be used instead of this method, in GUI apps.
This function was introduced in 5.15.
[static]
bool KSycoca::isAvailable()
Returns true
if the ksycoca database is available
This is usually the case, except if KDE isn't installed yet, or before kded is started.
[static]
KSycoca *KSycoca::self()
Get or create the only instance of KSycoca (read-only)
[static, since 6.0]
void KSycoca::setupTestMenu()
Sets up a minimal applications.menu file in the appropriate location.
This is useful when writing unit tests that interact with KService.
You should call QStandardPaths::setTestModeEnabled(true) before calling this.
This function was introduced in 6.0.
[static]
int KSycoca::version()
Returns the compiled-in version, i.e. the one used when writing a new ksycoca
Macro Documentation
KBUILDSYCOCA_EXENAME
Executable name of the kbuildsycoca program