1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-22 03:04:09 -04:00

add parameterisation to the theme name.

This commit is contained in:
Shlomi Fish 2019-04-28 23:21:09 +03:00
parent 0ba65a1050
commit 84c760fc93
3 changed files with 19 additions and 21 deletions

View file

@ -1,22 +1,20 @@
/* A file to test imorting C modules for handling arrays to Python */
#include "kcardgame.hpp" #include "kcardgame.hpp"
MyKCardDeck::MyKCardDeck() MyKCardDeck::MyKCardDeck(QString theme_name)
{ {
int argc = 1; int argc = 1;
char * argv[2]={"pysol",NULL}; char *argv[2] = {"pysol", NULL};
app = new QGuiApplication(argc, argv); app = new QGuiApplication(argc, argv);
d = new KCardDeck( KCardTheme("svg-ancient-egyptians"), nullptr); d = new KCardDeck(KCardTheme(theme_name), nullptr);
unsigned int number = 0; unsigned int number = 0;
QList<quint32> ids; QList<quint32> ids;
for ( int i = 0; i < 1; ++i ) for (int i = 0; i < 1; ++i)
foreach ( const KCardDeck::Rank & r, KCardDeck::standardRanks() ) foreach (const KCardDeck::Rank &r, KCardDeck::standardRanks())
foreach ( const KCardDeck::Suit & s, KCardDeck::standardSuits() ) foreach (const KCardDeck::Suit &s, KCardDeck::standardSuits())
ids << KCardDeck::getId( s, r, number++ ); ids << KCardDeck::getId(s, r, number++);
d->setDeckContents(ids); d->setDeckContents(ids);
d->setCardWidth(150); d->setCardWidth(150);
} }
QPixmap *MyKCardDeck::get_card_pixmap(int i) QPixmap *MyKCardDeck::get_card_pixmap(int i)
{ {
auto ret = new QPixmap(d->cardPixmap(i, true)); auto ret = new QPixmap(d->cardPixmap(i, true));

View file

@ -4,13 +4,13 @@
#include <QGuiApplication> #include <QGuiApplication>
#include "KCardDeck" #include "KCardDeck"
#include "KCardTheme" #include "KCardTheme"
class Q_DECL_EXPORT MyKCardDeck: public QObject class Q_DECL_EXPORT MyKCardDeck : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QGuiApplication* app; QGuiApplication *app;
KCardDeck * d; KCardDeck *d;
explicit MyKCardDeck(); explicit MyKCardDeck(QString);
public slots: public slots:
Q_DECL_EXPORT QPixmap *get_card_pixmap(int i); Q_DECL_EXPORT QPixmap *get_card_pixmap(int i);
}; };

View file

@ -25,7 +25,7 @@ class SVGManager:
def __init__(self, filename): def __init__(self, filename):
self.filename = filename self.filename = filename
# self.svg = Rsvg.Handle().new_from_file(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 # Taken from https://stackoverflow.com/questions/44471795
# Under MIT License - thanks. # Under MIT License - thanks.