Added a GUI style selection combo box. Lists all built in GUI styles available. This allows user to change the GUI style while it is running. Also, style setting is saved and used for future GUI startups.
This commit is contained in:
parent
8347e2fd0b
commit
ac0f377873
|
@ -36,6 +36,8 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
#include <QApplication>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
|
@ -88,6 +90,19 @@ 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;
|
||||||
|
std::string guiStyle;
|
||||||
|
|
||||||
|
g_config->getOption("SDL.GuiStyle", &guiStyle );
|
||||||
|
|
||||||
|
if ( guiStyle.size() > 0 )
|
||||||
|
{
|
||||||
|
QStyle *sty = QStyleFactory::create( tr(guiStyle.c_str()) );
|
||||||
|
|
||||||
|
if ( sty != nullptr )
|
||||||
|
{
|
||||||
|
QApplication::setStyle(sty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
createMainMenu();
|
createMainMenu();
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
// PaletteConf.cpp
|
// PaletteConf.cpp
|
||||||
//
|
//
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
|
||||||
#include "Qt/GuiConf.h"
|
#include "Qt/GuiConf.h"
|
||||||
#include "Qt/main.h"
|
#include "Qt/main.h"
|
||||||
|
@ -38,8 +40,14 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
QVBoxLayout *mainLayout;
|
QVBoxLayout *mainLayout;
|
||||||
QHBoxLayout *hbox;
|
QHBoxLayout *hbox;
|
||||||
QPushButton *closeButton;
|
QPushButton *closeButton;
|
||||||
|
QLabel *lbl;
|
||||||
|
QStringList styleKeys;
|
||||||
|
QString selStyle;
|
||||||
|
|
||||||
//resize( 512, 600 );
|
//resize( 512, 600 );
|
||||||
|
//printf("Style: %s \n", style()->objectName().toStdString().c_str() );
|
||||||
|
|
||||||
|
selStyle = style()->objectName();
|
||||||
|
|
||||||
// sync with config
|
// sync with config
|
||||||
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
g_config->getOption("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||||
|
@ -58,6 +66,29 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)));
|
connect(useNativeFileDialog, SIGNAL(stateChanged(int)), this, SLOT(useNativeFileDialogChanged(int)));
|
||||||
connect(useNativeMenuBar, SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
|
connect(useNativeMenuBar, SIGNAL(stateChanged(int)), this, SLOT(useNativeMenuBarChanged(int)));
|
||||||
|
|
||||||
|
hbox = new QHBoxLayout();
|
||||||
|
lbl = new QLabel( tr("Style:") );
|
||||||
|
|
||||||
|
styleComboBox = new QComboBox();
|
||||||
|
|
||||||
|
styleKeys = QStyleFactory::keys();
|
||||||
|
|
||||||
|
for (int i=0; i<styleKeys.size(); i++)
|
||||||
|
{
|
||||||
|
styleComboBox->addItem( styleKeys[i], i );
|
||||||
|
|
||||||
|
if ( selStyle.compare( styleKeys[i], Qt::CaseInsensitive ) == 0 )
|
||||||
|
{
|
||||||
|
//printf("Style Match: %s \n", selStyle.toStdString().c_str() );
|
||||||
|
styleComboBox->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connect(styleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int)));
|
||||||
|
|
||||||
|
hbox->addWidget( lbl, 1 );
|
||||||
|
hbox->addWidget( styleComboBox, 10 );
|
||||||
|
|
||||||
|
mainLayout->addLayout(hbox);
|
||||||
mainLayout->addWidget(useNativeFileDialog);
|
mainLayout->addWidget(useNativeFileDialog);
|
||||||
mainLayout->addWidget(useNativeMenuBar);
|
mainLayout->addWidget(useNativeMenuBar);
|
||||||
|
|
||||||
|
@ -65,6 +96,7 @@ GuiConfDialog_t::GuiConfDialog_t(QWidget *parent)
|
||||||
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
|
closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
|
||||||
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
|
connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void)));
|
||||||
|
|
||||||
|
|
||||||
hbox = new QHBoxLayout();
|
hbox = new QHBoxLayout();
|
||||||
hbox->addStretch(3);
|
hbox->addStretch(3);
|
||||||
hbox->addWidget( closeButton, 3 );
|
hbox->addWidget( closeButton, 3 );
|
||||||
|
@ -111,3 +143,23 @@ void GuiConfDialog_t::useNativeMenuBarChanged(int state)
|
||||||
consoleWindow->menuBar()->setNativeMenuBar(value);
|
consoleWindow->menuBar()->setNativeMenuBar(value);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void GuiConfDialog_t::styleChanged(int index)
|
||||||
|
{
|
||||||
|
QString s;
|
||||||
|
QStyle *sty;
|
||||||
|
|
||||||
|
s = styleComboBox->currentText();
|
||||||
|
|
||||||
|
//printf("Style: '%s'\n", s.toStdString().c_str() );
|
||||||
|
|
||||||
|
sty = QStyleFactory::create( s );
|
||||||
|
|
||||||
|
if ( sty != nullptr )
|
||||||
|
{
|
||||||
|
QApplication::setStyle(sty);
|
||||||
|
|
||||||
|
g_config->setOption("SDL.GuiStyle", s.toStdString().c_str() );
|
||||||
|
g_config->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
|
|
@ -30,6 +30,7 @@ protected:
|
||||||
|
|
||||||
QCheckBox *useNativeFileDialog;
|
QCheckBox *useNativeFileDialog;
|
||||||
QCheckBox *useNativeMenuBar;
|
QCheckBox *useNativeMenuBar;
|
||||||
|
QComboBox *styleComboBox;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -37,4 +38,5 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void useNativeFileDialogChanged(int v);
|
void useNativeFileDialogChanged(int v);
|
||||||
void useNativeMenuBarChanged(int v);
|
void useNativeMenuBarChanged(int v);
|
||||||
|
void styleChanged(int index);
|
||||||
};
|
};
|
||||||
|
|
|
@ -373,6 +373,7 @@ InitConfig()
|
||||||
|
|
||||||
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
||||||
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
|
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
|
||||||
|
config->addOption("SDL.GuiStyle", "");
|
||||||
|
|
||||||
config->addOption("_setSchedParam" , "SDL.SetSchedParam" , 0);
|
config->addOption("_setSchedParam" , "SDL.SetSchedParam" , 0);
|
||||||
config->addOption("_emuSchedPolicy" , "SDL.EmuSchedPolicy", 0);
|
config->addOption("_emuSchedPolicy" , "SDL.EmuSchedPolicy", 0);
|
||||||
|
|
Loading…
Reference in New Issue