Added logic to look for a QResource (rcc) file along side a qss file when loading a new stylesheet.
This commit is contained in:
parent
f7480c8560
commit
0203344802
|
@ -90,53 +90,12 @@ consoleWin_t::consoleWin_t(QWidget *parent)
|
||||||
int opt, xWinSize = 256, yWinSize = 240;
|
int opt, xWinSize = 256, yWinSize = 240;
|
||||||
int use_SDL_video = false;
|
int use_SDL_video = false;
|
||||||
int setFullScreen = false;
|
int setFullScreen = false;
|
||||||
//int useCustomQss = false;
|
|
||||||
//const char *styleSheetEnv = NULL;
|
|
||||||
//std::string guiStyle;
|
|
||||||
|
|
||||||
//g_config->getOption("SDL.GuiStyle", &guiStyle );
|
//QString libpath = QLibraryInfo::location(QLibraryInfo::PluginsPath);
|
||||||
|
//printf("LibPath: '%s'\n", libpath.toStdString().c_str() );
|
||||||
|
|
||||||
QApplication::setStyle( new fceuStyle() );
|
QApplication::setStyle( new fceuStyle() );
|
||||||
|
|
||||||
//if ( guiStyle.size() > 0 )
|
|
||||||
//{
|
|
||||||
// QStyle *sty = QStyleFactory::create( tr(guiStyle.c_str()) );
|
|
||||||
|
|
||||||
// if ( sty != nullptr )
|
|
||||||
// {
|
|
||||||
// QApplication::setStyle(sty);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//styleSheetEnv = ::getenv("FCEUX_QT_STYLESHEET");
|
|
||||||
|
|
||||||
//if ( styleSheetEnv )
|
|
||||||
//{
|
|
||||||
// g_config->setOption("SDL.UseCustomQss", 1);
|
|
||||||
// g_config->setOption("SDL.QtStyleSheet", styleSheetEnv);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//g_config->getOption("SDL.UseCustomQss", &useCustomQss);
|
|
||||||
|
|
||||||
//if ( useCustomQss )
|
|
||||||
//{
|
|
||||||
// g_config->getOption("SDL.QtStyleSheet", &guiStyle );
|
|
||||||
|
|
||||||
// if ( guiStyle.size() > 0 )
|
|
||||||
// {
|
|
||||||
// QFile File(guiStyle.c_str());
|
|
||||||
//
|
|
||||||
// if ( File.open(QFile::ReadOnly) )
|
|
||||||
// {
|
|
||||||
// QString StyleSheet = QLatin1String(File.readAll());
|
|
||||||
//
|
|
||||||
// setStyleSheet(StyleSheet);
|
|
||||||
//
|
|
||||||
// //printf("Using Qt Stylesheet file '%s'\n", filepath );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
createMainMenu();
|
createMainMenu();
|
||||||
|
|
||||||
g_config->getOption( "SDL.VideoDriver", &use_SDL_video );
|
g_config->getOption( "SDL.VideoDriver", &use_SDL_video );
|
||||||
|
|
|
@ -370,15 +370,29 @@ void GuiConfDialog_t::openQss(void)
|
||||||
// Custom Style Wrapper Class
|
// Custom Style Wrapper Class
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
fceuStyle::fceuStyle() : fceuStyle(styleBase()){}
|
fceuStyle::fceuStyle(void) : fceuStyle(styleBase()){}
|
||||||
|
|
||||||
fceuStyle::fceuStyle(QStyle *style) : QProxyStyle(style)
|
fceuStyle::fceuStyle(QStyle *style) : QProxyStyle(style)
|
||||||
{
|
{
|
||||||
printf("New Style!!!\n");
|
//printf("New Style!!!\n");
|
||||||
|
|
||||||
setObjectName( style->objectName() );
|
setObjectName( style->objectName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fceuStyle::~fceuStyle(void)
|
||||||
|
{
|
||||||
|
//printf("Style Deleted: %s\n", objectName().toStdString().c_str() );
|
||||||
|
|
||||||
|
if ( rccFilePath.size() > 0 )
|
||||||
|
{
|
||||||
|
if ( QResource::unregisterResource( QString::fromStdString(rccFilePath) ) )
|
||||||
|
{
|
||||||
|
//printf("Removed Resource: '%s'\n", rccFilePath.c_str() );
|
||||||
|
rccFilePath.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QStyle *fceuStyle::styleBase(QStyle *style) const
|
QStyle *fceuStyle::styleBase(QStyle *style) const
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
|
@ -474,6 +488,23 @@ void fceuStyle::polish(QApplication *app)
|
||||||
app->setStyleSheet(qsStylesheet);
|
app->setStyleSheet(qsStylesheet);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( rccFilePath.size() == 0 )
|
||||||
|
{
|
||||||
|
char dir[1024], rccBase[256], tmpFile[2048];
|
||||||
|
|
||||||
|
parseFilepath( s.c_str(), dir, rccBase, NULL );
|
||||||
|
|
||||||
|
sprintf( tmpFile, "%s%s.rcc", dir, rccBase );
|
||||||
|
|
||||||
|
//printf("RCC: '%s%s'\n", dir, rccBase );
|
||||||
|
|
||||||
|
if ( QResource::registerResource( tmpFile ) )
|
||||||
|
{
|
||||||
|
//printf("Loaded RCC File: '%s'\n", tmpFile );
|
||||||
|
rccFilePath.assign( tmpFile );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
fceuStyle(void);
|
fceuStyle(void);
|
||||||
fceuStyle(QStyle *style);
|
fceuStyle(QStyle *style);
|
||||||
|
|
||||||
|
~fceuStyle(void);
|
||||||
|
|
||||||
QStyle *baseStyle() const;
|
QStyle *baseStyle() const;
|
||||||
|
|
||||||
void polish(QPalette &palette) override;
|
void polish(QPalette &palette) override;
|
||||||
|
@ -35,6 +37,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStyle *styleBase(QStyle *style = Q_NULLPTR) const;
|
QStyle *styleBase(QStyle *style = Q_NULLPTR) const;
|
||||||
|
|
||||||
|
std::string rccFilePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GuiConfDialog_t : public QDialog
|
class GuiConfDialog_t : public QDialog
|
||||||
|
|
Loading…
Reference in New Issue