1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

style selector

Unfortunately Qt developers removed some old native skins from support, only 3 skins are supported on Linux.
Number of native skins depends on OS and Qt built system.
This commit is contained in:
agilob 2014-10-08 23:31:20 +01:00
parent 1d31244273
commit c716b615c8
No known key found for this signature in database
GPG Key ID: 2CACF3EEF598C663
7 changed files with 61 additions and 5 deletions

View File

@ -135,6 +135,7 @@ void Settings::load()
timestampFormat = s.value("timestampFormat", "hh:mm").toString();
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
useNativeStyle = s.value("nativeStyle", false).toBool();
style = s.value("style", "None").toString();
s.endGroup();
s.beginGroup("State");
@ -239,6 +240,7 @@ void Settings::save(QString path)
s.setValue("timestampFormat", timestampFormat);
s.setValue("minimizeOnClose", minimizeOnClose);
s.setValue("nativeStyle", useNativeStyle);
s.setValue("style",style);
s.endGroup();
s.beginGroup("State");
@ -356,6 +358,16 @@ bool Settings::getAutostartInTray() const
return autostartInTray;
}
QString Settings::getStyle() const
{
return style;
}
void Settings::setStyle(const QString& newStyle)
{
style = newStyle;
}
void Settings::setAutostartInTray(bool newValue)
{
autostartInTray = newValue;

View File

@ -51,6 +51,9 @@ public:
bool getAutostartInTray() const;
void setAutostartInTray(bool newValue);
QString getStyle() const;
void setStyle(const QString& newValue);
bool getUseTranslations() const;
void setUseTranslations(bool newValue);
@ -192,7 +195,8 @@ private:
QByteArray windowGeometry;
QByteArray windowState;
QByteArray splitterState;
QString style;
// ChatView
int firstColumnHandlePos;
int secondColumnHandlePosFromRight;

View File

@ -11,7 +11,11 @@ QLabel
QGroupBox::title
{
color: black;
background-color: white;
}
QGroupBox
{
background-color: white;
}
QWidget

View File

@ -21,6 +21,7 @@
#include "misc/settings.h"
#include "misc/smileypack.h"
#include <QMessageBox>
#include <QStyleFactory>
GeneralForm::GeneralForm() :
GenericForm(tr("General Settings"), QPixmap(":/img/settings/general.png"))
@ -38,7 +39,14 @@ GeneralForm::GeneralForm() :
bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
}
bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack()));
bodyUI->styleBrowser->addItems(QStyleFactory::keys());
bodyUI->styleBrowser->addItem("None");
if(QStyleFactory::keys().contains(Settings::getInstance().getStyle()))
bodyUI->styleBrowser->setCurrentText(Settings::getInstance().getStyle());
else
bodyUI->styleBrowser->setCurrentText("None");
bodyUI->cbUDPDisabled->setChecked(Settings::getInstance().getForceTCP());
bodyUI->proxyAddr->setText(Settings::getInstance().getProxyAddr());
int port = Settings::getInstance().getProxyPort();
@ -58,6 +66,7 @@ GeneralForm::GeneralForm() :
connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &GeneralForm::onProxyAddrEdited);
connect(bodyUI->proxyPort, SIGNAL(valueChanged(int)), this, SLOT(onProxyPortEdited(int)));
connect(bodyUI->cbUseProxy, &QCheckBox::stateChanged, this, &GeneralForm::onUseProxyUpdated);
connect(bodyUI->styleBrowser, SIGNAL(currentTextChanged(QString)), this, SLOT(onStyleSelected(QString)));
}
GeneralForm::~GeneralForm()
@ -85,6 +94,12 @@ void GeneralForm::onSetAutostartInTray()
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
}
void GeneralForm::onStyleSelected(QString style)
{
Settings::getInstance().setStyle(style);
this->setStyle(QStyleFactory::create(style));
}
void GeneralForm::onSmileyBrowserIndexChanged(int index)
{
QString filename = bodyUI->smileyPackBrowser->itemData(index).toString();

View File

@ -42,6 +42,7 @@ private slots:
void onProxyAddrEdited();
void onProxyPortEdited(int port);
void onUseProxyUpdated();
void onStyleSelected(QString style);
private:
Ui::GeneralSettings *bodyUI;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>527</width>
<height>369</height>
<height>397</height>
</rect>
</property>
<property name="windowTitle">
@ -72,6 +72,16 @@
<item>
<widget class="QComboBox" name="smileyPackBrowser"/>
</item>
<item>
<widget class="QLabel" name="styleLabel">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="styleBrowser"/>
</item>
</layout>
</widget>
</item>

View File

@ -43,6 +43,7 @@
#include <QThread>
#include <QFileDialog>
#include <tox/tox.h>
#include <QStyleFactory>
Widget *Widget::instance{nullptr};
@ -74,7 +75,16 @@ Widget::Widget(QWidget *parent)
ui->mainHead->setLayout(new QVBoxLayout());
ui->mainHead->layout()->setMargin(0);
ui->mainHead->layout()->setSpacing(0);
ui->mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css"));
if(QStyleFactory::keys().contains(Settings::getInstance().getStyle())
&& Settings::getInstance().getStyle() != "None")
{
ui->mainHead->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
ui->mainContent->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
}
ui->mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css"));
ui->mainContent->setStyleSheet(Style::getStylesheet(":ui/settings/mainContent.css"));
contactListWidget = new FriendListWidget();