forked from blue/squawk
new optional KDE Frameworks plugin to support system color schemes
This commit is contained in:
parent
802e2f11a1
commit
0ff9f12157
8 changed files with 130 additions and 10 deletions
|
@ -28,6 +28,12 @@ QLibrary Shared::Global::openFileManagerWindowJob("openFileManagerWindowJob");
|
|||
Shared::Global::HighlightInFileManager Shared::Global::hfm = 0;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_KCONFIG
|
||||
QLibrary Shared::Global::colorSchemeTools("colorSchemeTools");
|
||||
Shared::Global::CreatePreview Shared::Global::createPreview = 0;
|
||||
Shared::Global::DeletePreview Shared::Global::deletePreview = 0;
|
||||
#endif
|
||||
|
||||
Shared::Global::Global():
|
||||
availability({
|
||||
tr("Online", "Availability"),
|
||||
|
@ -87,7 +93,8 @@ Shared::Global::Global():
|
|||
defaultSystemStyle(QApplication::style()->objectName()),
|
||||
pluginSupport({
|
||||
{"KWallet", false},
|
||||
{"openFileManagerWindowJob", false}
|
||||
{"openFileManagerWindowJob", false},
|
||||
{"colorSchemeTools", false}
|
||||
}),
|
||||
fileCache()
|
||||
{
|
||||
|
@ -111,6 +118,22 @@ Shared::Global::Global():
|
|||
qDebug() << "KIO::OpenFileManagerWindow support disabled: couldn't load the library" << openFileManagerWindowJob.errorString();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_KCONFIG
|
||||
colorSchemeTools.load();
|
||||
if (colorSchemeTools.isLoaded()) {
|
||||
createPreview = (CreatePreview) colorSchemeTools.resolve("createPreview");
|
||||
deletePreview = (DeletePreview) colorSchemeTools.resolve("deletePreview");
|
||||
if (createPreview && deletePreview) {
|
||||
setSupported("colorSchemeTools", true);
|
||||
qDebug() << "Color Schemes support enabled";
|
||||
} else {
|
||||
qDebug() << "Color Schemes support disabled: couldn't resolve required methods in the library";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Color Schemes support disabled: couldn't load the library" << colorSchemeTools.errorString();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -276,6 +299,18 @@ void Shared::Global::highlightInFileManager(const QString& path)
|
|||
}
|
||||
}
|
||||
|
||||
QIcon Shared::Global::createThemePreview(const QString& path)
|
||||
{
|
||||
if (supported("colorSchemeTools")) {
|
||||
QIcon* icon = createPreview(path);
|
||||
QIcon localIcon = *icon;
|
||||
deletePreview(icon);
|
||||
return localIcon;
|
||||
} else {
|
||||
return QIcon();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define FROM_INT_INPL(Enum) \
|
||||
template<> \
|
||||
|
|
|
@ -95,6 +95,7 @@ namespace Shared {
|
|||
|
||||
static FileInfo getFileInfo(const QString& path);
|
||||
static void highlightInFileManager(const QString& path);
|
||||
static QIcon createThemePreview(const QString& path);
|
||||
|
||||
template<typename T>
|
||||
static T fromInt(int src);
|
||||
|
@ -128,6 +129,16 @@ namespace Shared {
|
|||
|
||||
static HighlightInFileManager hfm;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_KCONFIG
|
||||
static QLibrary colorSchemeTools;
|
||||
|
||||
typedef QIcon* (*CreatePreview)(const QString&);
|
||||
typedef void (*DeletePreview)(QIcon*);
|
||||
|
||||
static CreatePreview createPreview;
|
||||
static DeletePreview deletePreview;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue