external stylesheet file for easier gui skinning introduced

This commit is contained in:
doitux
2007-12-10 00:29:16 +00:00
parent d60f53228e
commit 85b9f0926c
6 changed files with 160 additions and 7 deletions
+6 -2
View File
@@ -48,6 +48,7 @@
#include "configfile.h"
#include "sdlplayer.h"
#include "stylesheetreader.h"
#include <gamedata.h>
#include <generic/serverguiwrapper.h>
@@ -81,6 +82,9 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
//Sound
mySDLPlayer = new SDLPlayer(myConfig);
//styleSheetReader
myStyleSheetReader = new StyleSheetReader(QString(myAppDataPath+"gfx/stylesheet.xml").toStdString());
//Player0 pixmapCardsLabel needs Myw
pixmapLabel_card0b->setMyW(this);
pixmapLabel_card0a->setMyW(this);
@@ -330,8 +334,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
#endif
textBrowser_Log->setStyleSheet("QTextBrowser { "+ font1String +" font-size: "+textBrowserFontsize+"px; color: #F0F0F0; background-color: #1D3B00; border:none; } QScrollBar:vertical { border: 1px solid #104600; background: #135000; width: 15px; margin: 17px -1px 17px 0px; } QScrollBar::handle:vertical { border-radius: 1px; border: 1px solid #1B7200; background: #176400; min-height: 20px; } QScrollBar::add-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 1px; border-top-left-radius: 1px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 1px; border-bottom-left-radius: 1px; border-top-right-radius: 2px; border-top-left-radius: 2px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 1px solid #208A00; height: 3px; width: 3px; background: #27A800; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }");
textBrowser_Chat->setStyleSheet("QTextBrowser { "+ font1String +" font-size: "+textBrowserFontsize+"px; color: #F0F0F0; background-color: #1D3B00; border:none; } QScrollBar:vertical { border: 1px solid #104600; background: #135000; width: 15px; margin: 17px -1px 17px 0px; } QScrollBar::handle:vertical { border-radius: 1px; border: 1px solid #1B7200; background: #176400; min-height: 20px; } QScrollBar::add-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 1px; border-top-left-radius: 1px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 1px; border-bottom-left-radius: 1px; border-top-right-radius: 2px; border-top-left-radius: 2px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 1px solid #208A00; height: 3px; width: 3px; background: #27A800; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }");
textBrowser_Log->setStyleSheet("QTextBrowser { "+ font1String +" font-size: "+textBrowserFontsize+"px; color: #"+QString::fromUtf8(myStyleSheetReader->readColorString("TextBrowserLogFont").c_str())+"; background-color: #1D3B00; border:none; } QScrollBar:vertical { border: 1px solid #104600; background: #135000; width: 15px; margin: 17px -1px 17px 0px; } QScrollBar::handle:vertical { border-radius: 1px; border: 1px solid #1B7200; background: #176400; min-height: 20px; } QScrollBar::add-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 1px; border-top-left-radius: 1px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 1px; border-bottom-left-radius: 1px; border-top-right-radius: 2px; border-top-left-radius: 2px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 1px solid #208A00; height: 3px; width: 3px; background: #27A800; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }");
textBrowser_Chat->setStyleSheet("QTextBrowser { "+ font1String +" font-size: "+textBrowserFontsize+"px; color: #"+QString::fromUtf8(myStyleSheetReader->readColorString("TextBrowserChatFont").c_str())+"; background-color: #1D3B00; border:none; } QScrollBar:vertical { border: 1px solid #104600; background: #135000; width: 15px; margin: 17px -1px 17px 0px; } QScrollBar::handle:vertical { border-radius: 1px; border: 1px solid #1B7200; background: #176400; min-height: 20px; } QScrollBar::add-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 1px; border-top-left-radius: 1px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 1px; border-bottom-left-radius: 1px; border-top-right-radius: 2px; border-top-left-radius: 2px; border: 1px solid #1E7F00; background: #1A6F00; height: 15px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 1px solid #208A00; height: 3px; width: 3px; background: #27A800; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }");
lineEdit_ChatInput->setStyleSheet("QLineEdit { "+ font1String +" font-size: "+textBrowserFontsize+"px; color: #F0F0F0; background-color: #1D3B00; border-top: 2px solid #286400; }");
+3 -1
View File
@@ -53,6 +53,7 @@ class gameLobbyDialogImpl;
class QColor;
class SDLPlayer;
class StyleSheetReader;
class mainWindowImpl: public QMainWindow, public Ui::mainWindow {
@@ -457,7 +458,8 @@ private:
int keyUpDownChatCounter;
int myLastPreActionBetValue;
StyleSheetReader *myStyleSheetReader;
friend class GuiWrapper;
};
@@ -0,0 +1,79 @@
/***************************************************************************
* Copyright (C) 2006 by Felix Hammer *
* f.hammer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "stylesheetreader.h"
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <fstream>
using namespace std;
StyleSheetReader::StyleSheetReader(std::string f) : styleSheetFileName(f)
{
fillBuffer();
}
StyleSheetReader::~StyleSheetReader()
{
}
void StyleSheetReader::fillBuffer() {
boost::recursive_mutex::scoped_lock lock(m_configMutex);
string tempString1("");
TiXmlDocument doc(styleSheetFileName);
if(doc.LoadFile()) {
TiXmlHandle docHandle( &doc );
TiXmlElement* colorList = docHandle.FirstChild( "PokerTH" ).FirstChild( "Table" ).FirstChild( "Colors" ).FirstChild().ToElement();
for( ; colorList; colorList=colorList->NextSiblingElement()) {
const char *tmpStr1 = colorList->Attribute("value");
if (tmpStr1) {
tempString1 = tmpStr1;
colorsBufferList.push_back(Colors(colorList->ValueStr(), tempString1));
// cout << colorList->ValueStr() << " : " << tempString1 << endl;
}
}
}
}
string StyleSheetReader::readColorString(string varName) const
{
boost::recursive_mutex::scoped_lock lock(m_configMutex);
size_t i;
string tempString("");
for (i=0; i<colorsBufferList.size(); i++) {
if (colorsBufferList[i].name == varName) {
tempString = colorsBufferList[i].value;
}
}
return tempString;
}
@@ -0,0 +1,55 @@
/***************************************************************************
* Copyright (C) 2006 by Felix Hammer *
* f.hammer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef STYLESHEETREADER_H
#define STYLESHEETREADER_H
#include "tinyxml.h"
#include <vector>
#include <string>
#include <boost/thread.hpp>
class StyleSheetReader{
public:
StyleSheetReader(std::string f);
~StyleSheetReader();
void fillBuffer();
std::string readColorString(std::string varName) const;
private:
mutable boost::recursive_mutex m_configMutex;
struct Colors
{
Colors(const std::string &n, const std::string &v) : name(n), value(v) {}
std::string name;
std::string value;
};
std::vector<Colors> colorsBufferList;
std::string styleSheetFileName;
};
#endif