mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 19:45:31 +01:00
Convert QObject subclasses to clementine wrapped python types properly when calling python functions
This commit is contained in:
parent
610399319e
commit
5c29a62b19
@ -28,3 +28,7 @@
|
|||||||
%Include songloader.sip
|
%Include songloader.sip
|
||||||
%Include taskmanager.sip
|
%Include taskmanager.sip
|
||||||
%Include uiinterface.sip
|
%Include uiinterface.sip
|
||||||
|
|
||||||
|
// Remember: when adding a class that inherits from QObject, add it to the list
|
||||||
|
// in scriptinterface.sip as well, or else it won't cast properly when calling
|
||||||
|
// python slots.
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
LibraryBackend* library_backend() const;
|
LibraryBackend* library_backend() const;
|
||||||
// PlaylistBackend* playlist_backend() const;
|
// PlaylistBackend* playlist_backend() const;
|
||||||
PlaylistSequence* sequence() const;
|
PlaylistSequence* sequence() const;
|
||||||
// PlaylistParser* parser() const;
|
PlaylistParser* parser() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void New(const QString& name, const SongList& songs = SongList());
|
void New(const QString& name, const SongList& songs = SongList());
|
||||||
|
@ -4,6 +4,53 @@ class ScriptInterface : QObject {
|
|||||||
#include "scripting/scriptinterface.h"
|
#include "scripting/scriptinterface.h"
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
%ConvertToSubClassCode
|
||||||
|
// Any classes that inherit from QObject must be added to this list
|
||||||
|
|
||||||
|
#define CLASS(name) {sipName_##name, &sipType_##name}
|
||||||
|
static struct class_list {
|
||||||
|
const char *name;
|
||||||
|
sipTypeDef **type;
|
||||||
|
} list[] = {
|
||||||
|
CLASS(LibraryBackend),
|
||||||
|
CLASS(MergedProxyModel),
|
||||||
|
CLASS(NetworkAccessManager),
|
||||||
|
CLASS(ParserBase),
|
||||||
|
CLASS(Player),
|
||||||
|
CLASS(Playlist),
|
||||||
|
CLASS(PlaylistManager),
|
||||||
|
CLASS(PlaylistParser),
|
||||||
|
CLASS(PlaylistSequence),
|
||||||
|
CLASS(Queue),
|
||||||
|
CLASS(RadioModel),
|
||||||
|
CLASS(RadioService),
|
||||||
|
CLASS(ScriptInterface),
|
||||||
|
CLASS(SettingsDialog),
|
||||||
|
CLASS(SongLoader),
|
||||||
|
CLASS(TaskManager),
|
||||||
|
CLASS(UIInterface),
|
||||||
|
{0, 0}
|
||||||
|
};
|
||||||
|
#undef CLASS
|
||||||
|
|
||||||
|
sipType = NULL;
|
||||||
|
|
||||||
|
for (int i=0 ; ; ++i) {
|
||||||
|
struct class_list* p = &list[i];
|
||||||
|
if (!p->name) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sipCpp->inherits(p->name)) {
|
||||||
|
sipType = *p->type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%End
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Abort();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SettingsDialogRequested();
|
void SettingsDialogRequested();
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ ScriptInterface::ScriptInterface(Script* script, QObject* parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptInterface::Abort() {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptInterface::ShowSettingsDialog() {
|
void ScriptInterface::ShowSettingsDialog() {
|
||||||
emit SettingsDialogRequested();
|
emit SettingsDialogRequested();
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ class ScriptInterface : public QObject {
|
|||||||
public:
|
public:
|
||||||
ScriptInterface(Script* script, QObject* parent = 0);
|
ScriptInterface(Script* script, QObject* parent = 0);
|
||||||
|
|
||||||
|
// Gdb will break here
|
||||||
|
void Abort();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Callable by C++
|
// Callable by C++
|
||||||
void ShowSettingsDialog();
|
void ShowSettingsDialog();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user