mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-31 18:36:24 -05:00
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:
parent
8bd1b7aa4a
commit
c99fa5f342
@ -235,7 +235,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));
|
connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));
|
||||||
|
|
||||||
/* load the StyleSheet*/
|
/* load the StyleSheet*/
|
||||||
loadStyleSheet(Rshare::stylesheet());
|
Rshare::loadStyleSheet(Rshare::stylesheet());
|
||||||
|
|
||||||
/* Create the Main pages and actions */
|
/* Create the Main pages and actions */
|
||||||
QActionGroup *grp = new QActionGroup(this);
|
QActionGroup *grp = new QActionGroup(this);
|
||||||
@ -1345,21 +1345,6 @@ void MainWindow::toggleVisibilitycontextmenu()
|
|||||||
show();
|
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()
|
void MainWindow::showabout()
|
||||||
{
|
{
|
||||||
AboutDialog adlg(this);
|
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 */
|
/* set status object to status value */
|
||||||
static void setStatusObject(QObject *pObject, int nStatus)
|
static void setStatusObject(QObject *pObject, int nStatus)
|
||||||
{
|
{
|
||||||
|
@ -198,7 +198,6 @@ private slots:
|
|||||||
|
|
||||||
void showMess();
|
void showMess();
|
||||||
void showSettings();
|
void showSettings();
|
||||||
void setStyle();
|
|
||||||
void statusChangedMenu(QAction *pAction);
|
void statusChangedMenu(QAction *pAction);
|
||||||
void statusChangedComboBox(int index);
|
void statusChangedComboBox(int index);
|
||||||
|
|
||||||
@ -222,8 +221,6 @@ private:
|
|||||||
/** Adds a new action to the toolbar. */
|
/** Adds a new action to the toolbar. */
|
||||||
void addAction(QAction *action, const char *slot = 0);
|
void addAction(QAction *action, const char *slot = 0);
|
||||||
|
|
||||||
void loadStyleSheet(const QString &sheetName);
|
|
||||||
|
|
||||||
QString nameAndLocation;
|
QString nameAndLocation;
|
||||||
|
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
|
@ -40,9 +40,7 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
|
|||||||
|
|
||||||
/* Populate combo boxes */
|
/* Populate combo boxes */
|
||||||
foreach (QString code, LanguageSupport::languageCodes()) {
|
foreach (QString code, LanguageSupport::languageCodes()) {
|
||||||
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"),
|
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code);
|
||||||
LanguageSupport::languageName(code),
|
|
||||||
code);
|
|
||||||
}
|
}
|
||||||
foreach (QString style, QStyleFactory::keys()) {
|
foreach (QString style, QStyleFactory::keys()) {
|
||||||
ui.cmboStyle->addItem(style, style.toLower());
|
ui.cmboStyle->addItem(style, style.toLower());
|
||||||
@ -93,15 +91,8 @@ AppearancePage::load()
|
|||||||
}
|
}
|
||||||
ui.styleSheetCombo->setCurrentIndex(index);
|
ui.styleSheetCombo->setCurrentIndex(index);
|
||||||
|
|
||||||
/** load saved internal styleSheet **/
|
|
||||||
//QFile file(":/qss/" + (settings.getSheetName().toLower()) + ".qss");
|
|
||||||
|
|
||||||
/** load saved extern Stylesheets **/
|
/** load saved extern Stylesheets **/
|
||||||
QFile file(QApplication::applicationDirPath() + "/qss/" + (Settings->getSheetName().toLower()) + ".qss");
|
loadStyleSheet (Settings->getSheetName());
|
||||||
|
|
||||||
file.open(QFile::ReadOnly);
|
|
||||||
QString styleSheet = QLatin1String(file.readAll());
|
|
||||||
qApp->setStyleSheet(styleSheet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppearancePage::on_styleSheetCombo_activated(const QString &sheetName)
|
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)
|
void AppearancePage::loadStyleSheet(const QString &sheetName)
|
||||||
{
|
{
|
||||||
/** internal Stylesheets **/
|
Rshare::loadStyleSheet(sheetName);
|
||||||
//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 AppearancePage::loadqss()
|
void AppearancePage::loadqss()
|
||||||
{
|
{
|
||||||
|
|
||||||
QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList();
|
QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList();
|
||||||
|
// add empty entry representing "no style sheet"
|
||||||
|
ui.styleSheetCombo->addItem("");
|
||||||
foreach(QFileInfo st, slist)
|
foreach(QFileInfo st, slist)
|
||||||
{
|
{
|
||||||
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
|
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
|
||||||
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
|
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -359,6 +359,21 @@ void Rshare::resetLanguageAndStyle()
|
|||||||
setSheet(_args.value(ARG_GUISTYLESHEET));
|
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. */
|
/** Initialize plugins. */
|
||||||
void Rshare::initPlugins()
|
void Rshare::initPlugins()
|
||||||
{
|
{
|
||||||
|
@ -77,6 +77,8 @@ public:
|
|||||||
static bool setStyle(QString styleKey = QString());
|
static bool setStyle(QString styleKey = QString());
|
||||||
/** Sets the current GUI stylesheet. */
|
/** Sets the current GUI stylesheet. */
|
||||||
static bool setSheet(QString sheet = QString());
|
static bool setSheet(QString sheet = QString());
|
||||||
|
/** Loads stylesheet from external file **/
|
||||||
|
static void loadStyleSheet(const QString &sheetName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Language, Style and StyleSheet.
|
* Update Language, Style and StyleSheet.
|
||||||
@ -96,7 +98,6 @@ public:
|
|||||||
/** Returns Rshare's application version. */
|
/** Returns Rshare's application version. */
|
||||||
static QString version() { return RSHARE_VERSION; }
|
static QString version() { return RSHARE_VERSION; }
|
||||||
|
|
||||||
|
|
||||||
/** Returns the location Rshare uses for its data files. */
|
/** Returns the location Rshare uses for its data files. */
|
||||||
static QString dataDirectory();
|
static QString dataDirectory();
|
||||||
/** Returns the default location of Rshare's data directory. */
|
/** Returns the default location of Rshare's data directory. */
|
||||||
|
Loading…
Reference in New Issue
Block a user