Added patch from braindead

- Added empty entry to stylesheet-choice for "no stylesheet" and moved method "loadStyleSheet" from MainWindow to Rshare


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5133 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-05-02 20:19:51 +00:00
parent 8bd1b7aa4a
commit c99fa5f342
5 changed files with 42 additions and 76 deletions

View File

@ -235,7 +235,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));
/* load the StyleSheet*/
loadStyleSheet(Rshare::stylesheet());
Rshare::loadStyleSheet(Rshare::stylesheet());
/* Create the Main pages and actions */
QActionGroup *grp = new QActionGroup(this);
@ -1345,21 +1345,6 @@ void MainWindow::toggleVisibilitycontextmenu()
show();
}
void MainWindow::loadStyleSheet(const QString &sheetName)
{
/** internal Stylesheets **/
//QFile file(":/qss/" + sheetName.toLower() + ".qss");
/** extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet);
}
void MainWindow::showabout()
{
AboutDialog adlg(this);
@ -1402,18 +1387,6 @@ MainWindow::retranslateUi()
}
}
void MainWindow::setStyle()
{
QString standardSheet = "{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 <color1>, stop:1 <color2>);}";
QColor stop1 = QColorDialog::getColor(Qt::white);
QColor stop2 = QColorDialog::getColor(Qt::black);
//QString widgetSheet = ".QWidget" + standardSheet.replace("<color1>", stop1.name()).replace("<color2>", stop2.name());
QString toolSheet = "QToolBar" + standardSheet.replace("<color1>", stop1.name()).replace("<color2>", stop2.name());
QString menuSheet = "QMenuBar" + standardSheet.replace("<color1>", stop1.name()).replace("<color2>", stop2.name());
qApp->setStyleSheet(/*widgetSheet + */toolSheet + menuSheet);
}
/* set status object to status value */
static void setStatusObject(QObject *pObject, int nStatus)
{

View File

@ -198,7 +198,6 @@ private slots:
void showMess();
void showSettings();
void setStyle();
void statusChangedMenu(QAction *pAction);
void statusChangedComboBox(int index);
@ -222,8 +221,6 @@ private:
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
void loadStyleSheet(const QString &sheetName);
QString nameAndLocation;
QSystemTrayIcon *trayIcon;

View File

@ -33,25 +33,23 @@
AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet()));
connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet()));
/* Populate combo boxes */
foreach (QString code, LanguageSupport::languageCodes()) {
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"),
LanguageSupport::languageName(code),
code);
}
foreach (QString style, QStyleFactory::keys()) {
ui.cmboStyle->addItem(style, style.toLower());
}
/* Populate combo boxes */
foreach (QString code, LanguageSupport::languageCodes()) {
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code);
}
foreach (QString style, QStyleFactory::keys()) {
ui.cmboStyle->addItem(style, style.toLower());
}
//loadStyleSheet("Default");
loadqss();
//loadStyleSheet("Default");
loadqss();
/* Hide platform specific features */
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
@ -93,15 +91,8 @@ AppearancePage::load()
}
ui.styleSheetCombo->setCurrentIndex(index);
/** load saved internal styleSheet **/
//QFile file(":/qss/" + (settings.getSheetName().toLower()) + ".qss");
/** load saved extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + (Settings->getSheetName().toLower()) + ".qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet);
loadStyleSheet (Settings->getSheetName());
}
void AppearancePage::on_styleSheetCombo_activated(const QString &sheetName)
@ -111,28 +102,17 @@ void AppearancePage::on_styleSheetCombo_activated(const QString &sheetName)
void AppearancePage::loadStyleSheet(const QString &sheetName)
{
/** internal Stylesheets **/
//QFile file(":/qss/" + sheetName.toLower() + ".qss");
/** extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet);
Rshare::loadStyleSheet(sheetName);
}
void AppearancePage::loadqss()
{
QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList();
foreach(QFileInfo st, slist)
{
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
}
QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList();
// add empty entry representing "no style sheet"
ui.styleSheetCombo->addItem("");
foreach(QFileInfo st, slist)
{
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
}
}

View File

@ -359,6 +359,21 @@ void Rshare::resetLanguageAndStyle()
setSheet(_args.value(ARG_GUISTYLESHEET));
}
void Rshare::loadStyleSheet(const QString &sheetName)
{
QString styleSheet;
if (!sheetName.isEmpty()) {
/** extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
if (file.open(QFile::ReadOnly)) {
styleSheet = QLatin1String(file.readAll());
file.close();
}
}
qApp->setStyleSheet(styleSheet);
}
/** Initialize plugins. */
void Rshare::initPlugins()
{

View File

@ -75,8 +75,10 @@ public:
static bool setLanguage(QString languageCode = QString());
/** Sets the current GUI style. */
static bool setStyle(QString styleKey = QString());
/** Sets the current GUI stylesheet. */
/** Sets the current GUI stylesheet. */
static bool setSheet(QString sheet = QString());
/** Loads stylesheet from external file **/
static void loadStyleSheet(const QString &sheetName);
/**
* Update Language, Style and StyleSheet.
@ -96,7 +98,6 @@ public:
/** Returns Rshare's application version. */
static QString version() { return RSHARE_VERSION; }
/** Returns the location Rshare uses for its data files. */
static QString dataDirectory();
/** Returns the default location of Rshare's data directory. */