From 50cfd5744808ff8383cebcc3669eb06791593ca7 Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 18 Apr 2009 23:17:10 +0000 Subject: [PATCH] remove ifdef hack for style files loading --- src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp | 1 - .../gamelobbydialog/gamelobbydialogimpl.cpp | 2 +- src/gui/qt/gametable/gametableimpl.cpp | 3 +- src/gui/qt/styles/carddeckstylereader.cpp | 33 ++++++++----------- src/gui/qt/styles/carddeckstylereader.h | 1 + src/gui/qt/styles/gametablestylereader.cpp | 28 ++++++---------- src/gui/qt/styles/gametablestylereader.h | 1 + 7 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp index e0a47ccd..92aa2850 100755 --- a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp +++ b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp @@ -42,7 +42,6 @@ aboutPokerthImpl::aboutPokerthImpl(QWidget *parent, ConfigFile *c) textBrowser_3->setPalette(myPalette); textBrowser_4->setPalette(myPalette); -// textBrowser_licence->setSource(QUrl(QDir::toNativeSeparators(myAppDataPath+"misc/gpl2.html"))); QFile gplFile(QDir::toNativeSeparators(myAppDataPath+"misc/gpl2.html")); QString gplString; if(gplFile.exists()) { diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 7f506788..e7c4c1c2 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -41,7 +41,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) waitStartGameMsgBoxTimer = new QTimer(this); waitStartGameMsgBoxTimer->setSingleShot(TRUE); - treeWidget_GameList->setStyleSheet("QTreeWidget {background-color: white; background-image: url("+myAppDataPath +"gfx/gui/misc/background_gamelist.png); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + treeWidget_GameList->setStyleSheet("QTreeWidget {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); treeWidget_GameList->setAutoFillBackground(TRUE); connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 12168b0f..f740cd81 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -1077,13 +1077,12 @@ void gameTableImpl::dealHoleCards() { } else { holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(*flipside, TRUE); -/* holeCardsArray[i][j]->setStyleSheet("QLabel:hover { background-image:url(:/cards/resources/graphics/cards/"+QString::number(tempCardsIntArray[j], 10)+".png");*/ + } } else { holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(onePix, FALSE); -// holeCardsArray[i][j]->repaint(); } } } diff --git a/src/gui/qt/styles/carddeckstylereader.cpp b/src/gui/qt/styles/carddeckstylereader.cpp index c4a6283c..1360c247 100644 --- a/src/gui/qt/styles/carddeckstylereader.cpp +++ b/src/gui/qt/styles/carddeckstylereader.cpp @@ -38,36 +38,29 @@ CardDeckStyleReader::~CardDeckStyleReader() void CardDeckStyleReader::readStyleFile(QString file) { - string tinyFileName; - //if style file failed --> default style fallback if(QFile(file).exists()) { - currentFileName = QFile(file).fileName(); -#ifdef _WIN32 - tinyFileName = currentFileName.toStdString(); -#else - tinyFileName = currentFileName.toUtf8().constData(); -#endif - + currentFileName = file; } else { - currentFileName = QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml").fileName(); -#ifdef _WIN32 - tinyFileName = currentFileName.toStdString(); -#else - tinyFileName = currentFileName.toUtf8().constData(); -#endif - + currentFileName = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"; fallBack = 1; } + + QFile myFile(currentFileName); + myFile.open(QIODevice::ReadOnly | QIODevice::Text); + fileContent = myFile.readAll(); + QFileInfo info(currentFileName); currentDir = info.absolutePath()+"/"; //start reading the file and fill vars string tempString1(""); - TiXmlDocument doc(tinyFileName); - - if(doc.LoadFile()) { + + TiXmlDocument doc; + doc.Parse(fileContent.constData()); + + if(doc.RootElement()) { TiXmlHandle docHandle( &doc ); TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).FirstChild().ToElement(); @@ -129,7 +122,7 @@ void CardDeckStyleReader::readStyleFile(QString file) { else { loadedSuccessfull = 0; QMessageBox::warning(myW, tr("Card Deck Style Error"), - tr("Can not load card deck style file: %1 \n\nPlease check the style file or choose another style!").arg(tinyFileName.c_str()), + tr("Cannot load card deck style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName), QMessageBox::Ok); } diff --git a/src/gui/qt/styles/carddeckstylereader.h b/src/gui/qt/styles/carddeckstylereader.h index 2b695dcc..551c91d1 100644 --- a/src/gui/qt/styles/carddeckstylereader.h +++ b/src/gui/qt/styles/carddeckstylereader.h @@ -61,6 +61,7 @@ private: QString currentFileName; QString currentDir; + QByteArray fileContent; QStringList cardsLeft; QStringList leftItems; diff --git a/src/gui/qt/styles/gametablestylereader.cpp b/src/gui/qt/styles/gametablestylereader.cpp index 4d1a6c21..90d48c05 100644 --- a/src/gui/qt/styles/gametablestylereader.cpp +++ b/src/gui/qt/styles/gametablestylereader.cpp @@ -76,36 +76,28 @@ GameTableStyleReader::~GameTableStyleReader() void GameTableStyleReader::readStyleFile(QString file) { - string tinyFileName; - //if style file failed --> default style fallback if(QFile(file).exists()) { currentFileName = QFile(file).fileName(); -#ifdef _WIN32 - tinyFileName = currentFileName.toStdString(); -#else - tinyFileName = currentFileName.toUtf8().constData(); -#endif - } else { currentFileName = QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml").fileName(); -#ifdef _WIN32 - tinyFileName = currentFileName.toStdString(); -#else - tinyFileName = currentFileName.toUtf8().constData(); -#endif - fallBack = 1; } + + QFile myFile(currentFileName); + myFile.open(QIODevice::ReadOnly | QIODevice::Text); + fileContent = myFile.readAll(); + QFileInfo info(currentFileName); currentDir = info.absolutePath()+"/"; //start reading the file and fill vars string tempString1(""); - TiXmlDocument doc(tinyFileName); - - if(doc.LoadFile()) { + TiXmlDocument doc; + doc.Parse(fileContent.constData()); + + if(doc.RootElement()) { TiXmlHandle docHandle( &doc ); TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement(); @@ -488,7 +480,7 @@ void GameTableStyleReader::readStyleFile(QString file) { else { loadedSuccessfull = 0; QMessageBox::warning(myW, tr("Game Table Style Error"), - tr("Cannot load game table style file: %1 \n\nPlease check the style file or choose another style!").arg(tinyFileName.c_str()), + tr("Cannot load game table style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName), QMessageBox::Ok); } } diff --git a/src/gui/qt/styles/gametablestylereader.h b/src/gui/qt/styles/gametablestylereader.h index ffb12970..1676768c 100644 --- a/src/gui/qt/styles/gametablestylereader.h +++ b/src/gui/qt/styles/gametablestylereader.h @@ -271,6 +271,7 @@ private: QString tabBarPaddingTop; QString tabBarPaddingSide; + QByteArray fileContent; QString currentFileName; QString currentDir;