mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-09-23 08:39:07 +03:00
Light theme has been added
This commit is contained in:
@@ -63,6 +63,8 @@ DataBrowser::DataBrowser(QWidget *parent) :
|
||||
connect(ui->changeConnection,SIGNAL(clicked()),this,SLOT(slotChangeConnection()));
|
||||
connect(ui->pbConnect,SIGNAL(clicked()),this,SLOT(slotChangeConnectionState()));
|
||||
|
||||
ui->verticalLayout_2->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
|
||||
ui->dataTree->setHeaderLabel(tr("Datasources"));
|
||||
ui->pbConnect->setEnabled(false);
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ namespace Const{
|
||||
const QString DATAFUNCTIONS_MANAGER_NAME = "DatasourceFunctions";
|
||||
const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-=");
|
||||
const int DEFAULT_TAB_INDENTION = 4;
|
||||
|
||||
const int DOCKWIDGET_MARGINS = 4;
|
||||
}
|
||||
QString extractClassName(QString className);
|
||||
QString escapeSimbols(const QString& value);
|
||||
|
@@ -57,7 +57,7 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QSe
|
||||
m_dialogDesignerManager(new DialogDesignerManager(this)),
|
||||
#endif
|
||||
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false),
|
||||
m_dialogChanged(false), m_useDarkTheme(false), m_settings(settings)
|
||||
m_dialogChanged(false), m_theme("Default"), m_settings(settings)
|
||||
{
|
||||
#ifdef HAVE_QT4
|
||||
m_tabWidget = new LimeReportTabWidget(this);
|
||||
@@ -100,6 +100,10 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QSe
|
||||
connect(m_dialogDesignerManager, SIGNAL(dialogNameChanged(QString,QString)),
|
||||
this, SLOT(slotDialogNameChanged(QString,QString)));
|
||||
#endif
|
||||
|
||||
m_themes.insert("Default","");
|
||||
initThemeIfExist("Dark", ":/qdarkstyle/style.qss");
|
||||
initThemeIfExist("Light", ":/qlightstyle/lightstyle.qss");
|
||||
}
|
||||
|
||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||
@@ -185,7 +189,7 @@ void ReportDesignWidget::saveState()
|
||||
m_settings->setValue("vGridStep",m_verticalGridStep);
|
||||
m_settings->setValue("defaultFont",m_defaultFont);
|
||||
m_settings->setValue("useGrid",m_useGrid);
|
||||
m_settings->setValue("useDarkTheme",m_useDarkTheme);
|
||||
m_settings->setValue("theme",m_theme);
|
||||
m_settings->setValue("ScriptEditorState", m_scriptEditor->saveState());
|
||||
m_settings->endGroup();
|
||||
}
|
||||
@@ -196,17 +200,27 @@ void ReportDesignWidget::applySettings()
|
||||
m_report->pageAt(i)->pageItem()->setFont(m_defaultFont);
|
||||
}
|
||||
applyUseGrid();
|
||||
if (m_useDarkTheme) {
|
||||
QFile theme(":/qdarkstyle/style.qss");
|
||||
theme.open(QIODevice::ReadOnly);
|
||||
QString styleSheet = theme.readAll();
|
||||
parentWidget()->setStyleSheet(styleSheet);
|
||||
m_report->setStyleSheet(styleSheet);
|
||||
|
||||
if (m_themes.contains(m_theme)){
|
||||
parentWidget()->setStyleSheet(m_themes.value(m_theme));
|
||||
m_report->setStyleSheet(m_themes.value(m_theme));
|
||||
} else {
|
||||
m_theme = "Default";
|
||||
parentWidget()->setStyleSheet("");
|
||||
m_report->setStyleSheet("");
|
||||
}
|
||||
|
||||
// if (m_theme.compare("Dark") == 0) {
|
||||
// QFile theme(":/qdarkstyle/style.qss");
|
||||
// theme.open(QIODevice::ReadOnly);
|
||||
// QString styleSheet = theme.readAll();
|
||||
// parentWidget()->setStyleSheet(styleSheet);
|
||||
// m_report->setStyleSheet(styleSheet);
|
||||
// } else {
|
||||
// parentWidget()->setStyleSheet("");
|
||||
// m_report->setStyleSheet("");
|
||||
// }
|
||||
|
||||
if (m_settings){
|
||||
m_settings->beginGroup("ScriptEditor");
|
||||
QVariant v = m_settings->value("DefaultFontName");
|
||||
@@ -244,9 +258,9 @@ void ReportDesignWidget::loadState()
|
||||
m_useGrid = v.toBool();
|
||||
}
|
||||
|
||||
v = m_settings->value("useDarkTheme");
|
||||
v = m_settings->value("theme");
|
||||
if (v.isValid()){
|
||||
m_useDarkTheme = v.toBool();
|
||||
m_theme = v.toString();
|
||||
}
|
||||
|
||||
v = m_settings->value("ScriptEditorState");
|
||||
@@ -684,6 +698,17 @@ void ReportDesignWidget::prepareReport()
|
||||
report()->clearSelection();
|
||||
}
|
||||
|
||||
void ReportDesignWidget::initThemeIfExist(const QString &themeName, const QString &path)
|
||||
{
|
||||
QFile theme(path);
|
||||
if (theme.exists()){
|
||||
theme.open(QIODevice::ReadOnly);
|
||||
QString styleSheet = theme.readAll();
|
||||
m_themes.insert(themeName, styleSheet);
|
||||
m_localToEng.insert(QObject::tr(themeName.toLatin1()), themeName);
|
||||
}
|
||||
}
|
||||
|
||||
void ReportDesignWidget::previewReport()
|
||||
{
|
||||
prepareReport();
|
||||
@@ -749,14 +774,25 @@ void ReportDesignWidget::editSetting()
|
||||
setting.setHorizontalGridStep(m_horizontalGridStep);
|
||||
setting.setDefaultFont(m_defaultFont);
|
||||
setting.setSuppressAbsentFieldsAndVarsWarnings(m_report->suppressFieldAndVarError());
|
||||
setting.setUseDarkTheme(m_useDarkTheme);
|
||||
|
||||
QStringList themes;
|
||||
themes.append(QObject::tr("Default"));
|
||||
foreach(QString theme, m_themes.keys())
|
||||
if (!themes.contains(QObject::tr(theme.toLatin1())))
|
||||
themes.append(QObject::tr(theme.toLatin1()));
|
||||
|
||||
setting.setDesignerThemes(themes, QObject::tr(m_theme.toLatin1()));
|
||||
setting.setDesignerLanguages(m_report->designerLanguages(), m_report->currentDesignerLanguage());
|
||||
|
||||
if (setting.exec()){
|
||||
m_horizontalGridStep = setting.horizontalGridStep();
|
||||
m_verticalGridStep = setting.verticalGridStep();
|
||||
m_defaultFont = setting.defaultFont();
|
||||
m_useDarkTheme = setting.userDarkTheme();
|
||||
if (m_localToEng.contains(setting.theme())){
|
||||
m_theme = m_localToEng.value(setting.theme());
|
||||
} else {
|
||||
m_theme = "Default";
|
||||
}
|
||||
m_report->setSuppressFieldAndVarError(setting.suppressAbsentFieldsAndVarsWarnings());
|
||||
if (m_report->currentDesignerLanguage() != setting.designerLanguage() ){
|
||||
m_report->setCurrentDesignerLanguage(setting.designerLanguage());
|
||||
|
@@ -206,6 +206,7 @@ protected:
|
||||
private:
|
||||
bool eventFilter(QObject *target, QEvent *event);
|
||||
void prepareReport();
|
||||
void initThemeIfExist(const QString& themeName, const QString& path);
|
||||
private:
|
||||
ReportEnginePrivateInterface* m_report;
|
||||
QGraphicsView *m_view;
|
||||
@@ -228,8 +229,10 @@ private:
|
||||
bool m_useGrid;
|
||||
bool m_useMagnet;
|
||||
bool m_dialogChanged;
|
||||
bool m_useDarkTheme;
|
||||
QString m_theme;
|
||||
QSettings* m_settings;
|
||||
QMap<QString, QString> m_themes;
|
||||
QMap<QString, QString> m_localToEng;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@@ -512,7 +512,7 @@ void ReportDesignWindow::createObjectInspector()
|
||||
QWidget* w = new QWidget(objectDoc);
|
||||
QVBoxLayout* l = new QVBoxLayout(w);
|
||||
l->addWidget(m_objectInspector);
|
||||
l->setContentsMargins(2,2,2,2);
|
||||
l->setMargin(0);
|
||||
w->setLayout(l);
|
||||
objectDoc->setWindowTitle(tr("Object Inspector"));
|
||||
objectDoc->setWidget(w);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "ui_lrsettingdialog.h"
|
||||
#include "lrglobal.h"
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
@@ -10,10 +11,14 @@ SettingDialog::SettingDialog(QWidget *parent) :
|
||||
ui(new Ui::SettingDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QFile theme(":/qdarkstyle/style.qss");
|
||||
if (!theme.exists()){
|
||||
ui->cbbUseDarkTheme->setVisible(false);
|
||||
}
|
||||
ui->toolBox->setCurrentIndex(0);
|
||||
// ui->cbTheme->addItem(QObject::tr("Default"));
|
||||
// if (isFileExists(":/qdarkstyle/style.qss")){
|
||||
// ui->cbTheme->addItem(QObject::tr("Dark"));
|
||||
// }
|
||||
// if (isFileExists(":/qlightstyle/lightstyle.qss")){
|
||||
// ui->cbTheme->addItem(QObject::tr("Light"));
|
||||
// }
|
||||
ui->indentSize->setRange(0,10);
|
||||
}
|
||||
|
||||
@@ -51,9 +56,9 @@ int SettingDialog::tabIndention()
|
||||
return ui->indentSize->value();
|
||||
}
|
||||
|
||||
bool SettingDialog::userDarkTheme()
|
||||
QString SettingDialog::theme()
|
||||
{
|
||||
return ui->cbbUseDarkTheme->isChecked();
|
||||
return ui->cbTheme->currentText();
|
||||
}
|
||||
|
||||
bool SettingDialog::suppressAbsentFieldsAndVarsWarnings()
|
||||
@@ -101,9 +106,13 @@ void SettingDialog::setScritpTabIndention(int size)
|
||||
ui->indentSize->setValue(size);
|
||||
}
|
||||
|
||||
void SettingDialog::setUseDarkTheme(bool value)
|
||||
void SettingDialog::setTheme(const QString &theme)
|
||||
{
|
||||
ui->cbbUseDarkTheme->setChecked(value);
|
||||
#ifdef HAVE_QT4
|
||||
ui->cbTheme->setCurrentIndex(ui->cbTheme->findText(theme));
|
||||
#else
|
||||
ui->cbTheme->setCurrentText(theme);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingDialog::setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage)
|
||||
@@ -128,6 +137,17 @@ void SettingDialog::setDesignerLanguages(QList<QLocale::Language> languages, QLo
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingDialog::setDesignerThemes(QList<QString> themes, const QString ¤tTheme)
|
||||
{
|
||||
ui->cbTheme->clear();
|
||||
ui->cbTheme->addItems(themes);
|
||||
#ifdef HAVE_QT4
|
||||
ui->cbTheme->setCurrentIndex(ui->cbTheme->findText(currentTheme));
|
||||
#else
|
||||
ui->cbTheme->setCurrentText(currentTheme);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingDialog::setSettings(QSettings* settings){
|
||||
m_settings = settings;
|
||||
if (m_settings){
|
||||
@@ -159,6 +179,12 @@ void SettingDialog::on_bbOkCancel_accepted()
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingDialog::isFileExists(const QString &path)
|
||||
{
|
||||
QFileInfo check_file(path);
|
||||
return check_file.exists() && check_file.isFile();
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
@@ -23,7 +23,7 @@ public:
|
||||
QFont defaultFont();
|
||||
QFont scriptFont();
|
||||
int tabIndention();
|
||||
bool userDarkTheme();
|
||||
QString theme();
|
||||
bool suppressAbsentFieldsAndVarsWarnings();
|
||||
QLocale::Language designerLanguage();
|
||||
void setSuppressAbsentFieldsAndVarsWarnings(bool value);
|
||||
@@ -32,12 +32,14 @@ public:
|
||||
void setDefaultFont(const QFont& value);
|
||||
void setScriptFont(const QFont& value);
|
||||
void setScritpTabIndention(int size);
|
||||
void setUseDarkTheme(bool value);
|
||||
void setTheme(const QString& theme);
|
||||
void setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage);
|
||||
void setDesignerThemes(QList<QString> themes, const QString& currentTheme);
|
||||
void setSettings(QSettings* settings);
|
||||
private slots:
|
||||
void on_bbOkCancel_accepted();
|
||||
|
||||
private:
|
||||
bool isFileExists(const QString& path);
|
||||
private:
|
||||
Ui::SettingDialog *ui;
|
||||
QList<QLocale::Language> m_aviableLanguages;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>419</width>
|
||||
<height>362</height>
|
||||
<height>378</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -23,7 +23,7 @@
|
||||
<item>
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
@@ -31,7 +31,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>218</height>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -148,11 +148,44 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbbUseDarkTheme">
|
||||
<property name="text">
|
||||
<string>Use dark theme</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblTheme">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbTheme">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -162,7 +195,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>218</height>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -251,25 +284,34 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>218</height>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Report settings</string>
|
||||
</attribute>
|
||||
<widget class="QCheckBox" name="cbSuppressWarnings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>280</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Suppress absent fields and variables warning</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbSuppressWarnings">
|
||||
<property name="text">
|
||||
<string>Suppress absent fields and variables warning</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>204</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@@ -189,7 +189,7 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
h->addWidget(pbClear);
|
||||
l->addLayout(h);
|
||||
l->addWidget(m_objectInspectorView);
|
||||
l->setContentsMargins(2,2,2,2);
|
||||
l->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
l->setSpacing(2);
|
||||
this->setLayout(l);
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ ObjectBrowser::ObjectBrowser(QWidget *parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
layout->setMargin(2);
|
||||
layout->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
m_treeView = new QTreeWidget(this);
|
||||
layout->addWidget(m_treeView);
|
||||
m_treeView->headerItem()->setText(0,tr("Objects"));
|
||||
|
@@ -43,6 +43,7 @@ ScriptBrowser::ScriptBrowser(QWidget *parent) :
|
||||
ui(new Ui::ScriptBrowser)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->verticalLayout->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
#ifndef HAVE_UI_LOADER
|
||||
ui->tpDialogs->setVisible(false);
|
||||
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tpDialogs));
|
||||
|
Reference in New Issue
Block a user