From 2aaf094f9646995bacb2aa1199559f4a7cb2dc03 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Sun, 28 Apr 2019 23:21:09 +0300 Subject: [PATCH] add parameterisation to the theme name. --- kcardgame/binding-example/kcardgame.cpp | 24 +++++++++++------------- kcardgame/binding-example/kcardgame.hpp | 14 +++++++------- pysollib/ui/tktile/svg.py | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/kcardgame/binding-example/kcardgame.cpp b/kcardgame/binding-example/kcardgame.cpp index 2385c4f0..925e3549 100644 --- a/kcardgame/binding-example/kcardgame.cpp +++ b/kcardgame/binding-example/kcardgame.cpp @@ -1,22 +1,20 @@ -/* A file to test imorting C modules for handling arrays to Python */ - #include "kcardgame.hpp" -MyKCardDeck::MyKCardDeck() - { - int argc = 1; - char * argv[2]={"pysol",NULL}; - app = new QGuiApplication(argc, argv); - d = new KCardDeck( KCardTheme("svg-ancient-egyptians"), nullptr); +MyKCardDeck::MyKCardDeck(QString theme_name) +{ + int argc = 1; + char *argv[2] = {"pysol", NULL}; + app = new QGuiApplication(argc, argv); + d = new KCardDeck(KCardTheme(theme_name), nullptr); unsigned int number = 0; QList ids; - for ( int i = 0; i < 1; ++i ) - foreach ( const KCardDeck::Rank & r, KCardDeck::standardRanks() ) - foreach ( const KCardDeck::Suit & s, KCardDeck::standardSuits() ) - ids << KCardDeck::getId( s, r, number++ ); + for (int i = 0; i < 1; ++i) + foreach (const KCardDeck::Rank &r, KCardDeck::standardRanks()) + foreach (const KCardDeck::Suit &s, KCardDeck::standardSuits()) + ids << KCardDeck::getId(s, r, number++); d->setDeckContents(ids); d->setCardWidth(150); - } +} QPixmap *MyKCardDeck::get_card_pixmap(int i) { auto ret = new QPixmap(d->cardPixmap(i, true)); diff --git a/kcardgame/binding-example/kcardgame.hpp b/kcardgame/binding-example/kcardgame.hpp index 04038eed..a55a5733 100644 --- a/kcardgame/binding-example/kcardgame.hpp +++ b/kcardgame/binding-example/kcardgame.hpp @@ -4,13 +4,13 @@ #include #include "KCardDeck" #include "KCardTheme" -class Q_DECL_EXPORT MyKCardDeck: public QObject +class Q_DECL_EXPORT MyKCardDeck : public QObject { Q_OBJECT - public: - QGuiApplication* app; - KCardDeck * d; - explicit MyKCardDeck(); -public slots: -Q_DECL_EXPORT QPixmap *get_card_pixmap(int i); + public: + QGuiApplication *app; + KCardDeck *d; + explicit MyKCardDeck(QString); + public slots: + Q_DECL_EXPORT QPixmap *get_card_pixmap(int i); }; diff --git a/pysollib/ui/tktile/svg.py b/pysollib/ui/tktile/svg.py index e07b1e14..f52275cf 100644 --- a/pysollib/ui/tktile/svg.py +++ b/pysollib/ui/tktile/svg.py @@ -25,7 +25,7 @@ class SVGManager: def __init__(self, filename): self.filename = filename # self.svg = Rsvg.Handle().new_from_file(filename) - self.d = MyKCardDeck() + self.d = MyKCardDeck("svg-jolly-royal") # Taken from https://stackoverflow.com/questions/44471795 # Under MIT License - thanks.