mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
Dark theme has been added
This commit is contained in:
parent
13c6386af6
commit
435074064b
@ -13,6 +13,8 @@ SOURCES += main.cpp
|
|||||||
INCLUDEPATH += $$PWD/../include
|
INCLUDEPATH += $$PWD/../include
|
||||||
DEPENDPATH += $$PWD/../include
|
DEPENDPATH += $$PWD/../include
|
||||||
|
|
||||||
|
RESOURCES += $$PWD/../3rdparty/dark_style_sheet/qdarkstyle/style.qrc
|
||||||
|
|
||||||
DEST_DIR = $${DEST_BINS}
|
DEST_DIR = $${DEST_BINS}
|
||||||
REPORTS_DIR = $${DEST_DIR}
|
REPORTS_DIR = $${DEST_DIR}
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ namespace Const{
|
|||||||
Enums(){}
|
Enums(){}
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Enums::VariableDataType VariableDataType;
|
typedef Enums::VariableDataType VariableDataType;
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
@ -95,7 +95,7 @@ void TextAlignmentEditorWidget::initEditor()
|
|||||||
|
|
||||||
void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
|
void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
|
||||||
{
|
{
|
||||||
m_textAttibutesIsChanging=true;
|
m_textAttibutesIsChanging=true;
|
||||||
m_textAliginLeft->setChecked((align & Qt::AlignLeft)==Qt::AlignLeft);
|
m_textAliginLeft->setChecked((align & Qt::AlignLeft)==Qt::AlignLeft);
|
||||||
m_textAliginRight->setChecked((align & Qt::AlignRight)==Qt::AlignRight);
|
m_textAliginRight->setChecked((align & Qt::AlignRight)==Qt::AlignRight);
|
||||||
m_textAliginHCenter->setChecked((align & Qt::AlignHCenter)==Qt::AlignHCenter);
|
m_textAliginHCenter->setChecked((align & Qt::AlignHCenter)==Qt::AlignHCenter);
|
||||||
|
@ -1139,8 +1139,16 @@ void BaseDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* findRootWidget(QWidget* widget){
|
||||||
|
while (widget->parentWidget()) {
|
||||||
|
widget = widget->parentWidget();
|
||||||
|
}
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseDesignIntf::showEditorDialog(){
|
void BaseDesignIntf::showEditorDialog(){
|
||||||
QWidget *editor = defaultEditor();
|
QWidget *editor = defaultEditor();
|
||||||
|
editor->setStyleSheet(findRootWidget(scene()->views().at(0))->styleSheet());
|
||||||
if (editor) {
|
if (editor) {
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -1503,7 +1503,7 @@ VariableDataType DataSourceManager::variableDataType(const QString& name)
|
|||||||
{
|
{
|
||||||
if (m_reportVariables.containsVariable(name))
|
if (m_reportVariables.containsVariable(name))
|
||||||
return m_reportVariables.variableByName(name)->dataType();
|
return m_reportVariables.variableByName(name)->dataType();
|
||||||
return VariableDataType::Undefined;
|
return Enums::Undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceManager::setVariableDataType(const QString& name, VariableDataType value)
|
void DataSourceManager::setVariableDataType(const QString& name, VariableDataType value)
|
||||||
|
@ -161,6 +161,7 @@ namespace Const{
|
|||||||
Enums(){}
|
Enums(){}
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Enums::VariableDataType VariableDataType;
|
typedef Enums::VariableDataType VariableDataType;
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
@ -56,7 +56,7 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QMa
|
|||||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||||
m_dialogDesignerManager(new DialogDesignerManager(this)),
|
m_dialogDesignerManager(new DialogDesignerManager(this)),
|
||||||
#endif
|
#endif
|
||||||
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false)
|
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false), m_useDarkTheme(false)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_QT4
|
#ifdef HAVE_QT4
|
||||||
m_tabWidget = new LimeReportTabWidget(this);
|
m_tabWidget = new LimeReportTabWidget(this);
|
||||||
@ -189,6 +189,7 @@ void ReportDesignWidget::saveState(QSettings* settings)
|
|||||||
settings->setValue("vGridStep",m_verticalGridStep);
|
settings->setValue("vGridStep",m_verticalGridStep);
|
||||||
settings->setValue("defaultFont",m_defaultFont);
|
settings->setValue("defaultFont",m_defaultFont);
|
||||||
settings->setValue("useGrid",m_useGrid);
|
settings->setValue("useGrid",m_useGrid);
|
||||||
|
settings->setValue("useDarkTheme",m_useDarkTheme);
|
||||||
settings->setValue("ScriptEditorState", m_scriptEditor->saveState());
|
settings->setValue("ScriptEditorState", m_scriptEditor->saveState());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
@ -199,6 +200,13 @@ void ReportDesignWidget::applySettings()
|
|||||||
m_report->pageAt(i)->pageItem()->setFont(m_defaultFont);
|
m_report->pageAt(i)->pageItem()->setFont(m_defaultFont);
|
||||||
}
|
}
|
||||||
applyUseGrid();
|
applyUseGrid();
|
||||||
|
if (m_useDarkTheme) {
|
||||||
|
QFile theme(":/qdarkstyle/style.qss");
|
||||||
|
theme.open(QIODevice::ReadOnly);
|
||||||
|
QString styleSheet = theme.readAll();
|
||||||
|
parentWidget()->setStyleSheet(styleSheet);
|
||||||
|
m_report->setStyleSheet(styleSheet);
|
||||||
|
} else parentWidget()->setStyleSheet("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDesignWidget::loadState(QSettings* settings)
|
void ReportDesignWidget::loadState(QSettings* settings)
|
||||||
@ -223,6 +231,11 @@ void ReportDesignWidget::loadState(QSettings* settings)
|
|||||||
m_useGrid = v.toBool();
|
m_useGrid = v.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v = settings->value("useDarkTheme");
|
||||||
|
if (v.isValid()){
|
||||||
|
m_useDarkTheme = v.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
v = settings->value("ScriptEditorState");
|
v = settings->value("ScriptEditorState");
|
||||||
if (v.isValid()){
|
if (v.isValid()){
|
||||||
m_scriptEditor->restoreState(v.toByteArray());
|
m_scriptEditor->restoreState(v.toByteArray());
|
||||||
@ -369,8 +382,6 @@ PageDesignIntf * ReportDesignWidget::activePage()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QList<QGraphicsItem *> ReportDesignWidget::selectedItems(){
|
QList<QGraphicsItem *> ReportDesignWidget::selectedItems(){
|
||||||
return activePage()->selectedItems();
|
return activePage()->selectedItems();
|
||||||
}
|
}
|
||||||
@ -697,11 +708,13 @@ void ReportDesignWidget::editSetting()
|
|||||||
setting.setHorizontalGridStep(m_horizontalGridStep);
|
setting.setHorizontalGridStep(m_horizontalGridStep);
|
||||||
setting.setDefaultFont(m_defaultFont);
|
setting.setDefaultFont(m_defaultFont);
|
||||||
setting.setSuppressAbsentFieldsAndVarsWarnings(m_report->suppressFieldAndVarError());
|
setting.setSuppressAbsentFieldsAndVarsWarnings(m_report->suppressFieldAndVarError());
|
||||||
|
setting.setUseDarkTheme(m_useDarkTheme);
|
||||||
|
|
||||||
if (setting.exec()){
|
if (setting.exec()){
|
||||||
m_horizontalGridStep = setting.horizontalGridStep();
|
m_horizontalGridStep = setting.horizontalGridStep();
|
||||||
m_verticalGridStep = setting.verticalGridStep();
|
m_verticalGridStep = setting.verticalGridStep();
|
||||||
m_defaultFont = setting.defaultFont();
|
m_defaultFont = setting.defaultFont();
|
||||||
|
m_useDarkTheme = setting.userDarkTheme();
|
||||||
m_report->setSuppressFieldAndVarError(setting.suppressAbsentFieldsAndVarsWarnings());
|
m_report->setSuppressFieldAndVarError(setting.suppressAbsentFieldsAndVarsWarnings());
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
@ -199,6 +199,7 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *target, QEvent *event);
|
bool eventFilter(QObject *target, QEvent *event);
|
||||||
|
void prepareReport();
|
||||||
private:
|
private:
|
||||||
ReportEnginePrivateInterface* m_report;
|
ReportEnginePrivateInterface* m_report;
|
||||||
QGraphicsView *m_view;
|
QGraphicsView *m_view;
|
||||||
@ -221,7 +222,7 @@ private:
|
|||||||
bool m_useGrid;
|
bool m_useGrid;
|
||||||
bool m_useMagnet;
|
bool m_useMagnet;
|
||||||
bool m_dialogChanged;
|
bool m_dialogChanged;
|
||||||
void prepareReport();
|
bool m_useDarkTheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
@ -502,7 +502,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
|
|||||||
}
|
}
|
||||||
|
|
||||||
w->setHideResultEditButton(resultIsEditable());
|
w->setHideResultEditButton(resultIsEditable());
|
||||||
|
w->setStyleSheet(m_styleSheet);
|
||||||
m_activePreview = w;
|
m_activePreview = w;
|
||||||
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*)));
|
||||||
w->exec();
|
w->exec();
|
||||||
@ -932,10 +932,20 @@ void ReportEnginePrivate::activateLanguage(QLocale::Language language)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ReportEnginePrivate::styleSheet() const
|
||||||
|
{
|
||||||
|
return m_styleSheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportEnginePrivate::setStyleSheet(const QString &styleSheet)
|
||||||
|
{
|
||||||
|
m_styleSheet = styleSheet;
|
||||||
|
}
|
||||||
|
|
||||||
bool ReportEnginePrivate::setReportLanguage(QLocale::Language language){
|
bool ReportEnginePrivate::setReportLanguage(QLocale::Language language){
|
||||||
m_reportLanguage = language;
|
m_reportLanguage = language;
|
||||||
if (!m_translations.keys().contains(language)) return false;
|
if (!m_translations.keys().contains(language)) return false;
|
||||||
// activateLanguage(language);
|
// activateLanguage(language);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,6 @@ class PageDesignIntf;
|
|||||||
class PrintRange;
|
class PrintRange;
|
||||||
class ReportDesignWindow;
|
class ReportDesignWindow;
|
||||||
|
|
||||||
//TODO: Add on render callback
|
|
||||||
|
|
||||||
class ReportEnginePrivateInterface {
|
class ReportEnginePrivateInterface {
|
||||||
public:
|
public:
|
||||||
virtual PageDesignIntf* appendPage(const QString& pageName="") = 0;
|
virtual PageDesignIntf* appendPage(const QString& pageName="") = 0;
|
||||||
@ -84,7 +82,8 @@ public:
|
|||||||
virtual QString currentReportsDir() = 0;
|
virtual QString currentReportsDir() = 0;
|
||||||
virtual bool suppressFieldAndVarError() const = 0;
|
virtual bool suppressFieldAndVarError() const = 0;
|
||||||
virtual void setSuppressFieldAndVarError(bool suppressFieldAndVarError) = 0;
|
virtual void setSuppressFieldAndVarError(bool suppressFieldAndVarError) = 0;
|
||||||
|
virtual void setStyleSheet(const QString& styleSheet) = 0;
|
||||||
|
virtual QString styleSheet() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReportEnginePrivate : public QObject, public ICollectionContainer, public ITranslationContainer,
|
class ReportEnginePrivate : public QObject, public ICollectionContainer, public ITranslationContainer,
|
||||||
@ -179,6 +178,9 @@ public:
|
|||||||
void clearSelection();
|
void clearSelection();
|
||||||
Qt::LayoutDirection previewLayoutDirection();
|
Qt::LayoutDirection previewLayoutDirection();
|
||||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||||
|
QString styleSheet() const;
|
||||||
|
void setStyleSheet(const QString &styleSheet);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pagesLoadFinished();
|
void pagesLoadFinished();
|
||||||
void datasourceCollectionLoadFinished(const QString& collectionName);
|
void datasourceCollectionLoadFinished(const QString& collectionName);
|
||||||
@ -243,6 +245,7 @@ private:
|
|||||||
void activateLanguage(QLocale::Language language);
|
void activateLanguage(QLocale::Language language);
|
||||||
Qt::LayoutDirection m_previewLayoutDirection;
|
Qt::LayoutDirection m_previewLayoutDirection;
|
||||||
LimeReportPluginInterface* m_designerFactory;
|
LimeReportPluginInterface* m_designerFactory;
|
||||||
|
QString m_styleSheet;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "lrsettingdialog.h"
|
#include "lrsettingdialog.h"
|
||||||
#include "ui_lrsettingdialog.h"
|
#include "ui_lrsettingdialog.h"
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
namespace LimeReport{
|
namespace LimeReport{
|
||||||
|
|
||||||
@ -8,6 +9,10 @@ SettingDialog::SettingDialog(QWidget *parent) :
|
|||||||
ui(new Ui::SettingDialog)
|
ui(new Ui::SettingDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
QFile theme(":/qdarkstyle/style.qss");
|
||||||
|
if (!theme.exists()){
|
||||||
|
ui->cbbUseDarkTheme->setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingDialog::~SettingDialog()
|
SettingDialog::~SettingDialog()
|
||||||
@ -32,6 +37,11 @@ QFont SettingDialog::defaultFont()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingDialog::userDarkTheme()
|
||||||
|
{
|
||||||
|
return ui->cbbUseDarkTheme->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
bool SettingDialog::suppressAbsentFieldsAndVarsWarnings()
|
bool SettingDialog::suppressAbsentFieldsAndVarsWarnings()
|
||||||
{
|
{
|
||||||
return ui->cbSuppressWarnings->isChecked();
|
return ui->cbSuppressWarnings->isChecked();
|
||||||
@ -57,4 +67,9 @@ void SettingDialog::setDefaultFont(const QFont &value)
|
|||||||
ui->defaultFontSize->setValue(value.pointSize());
|
ui->defaultFontSize->setValue(value.pointSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingDialog::setUseDarkTheme(bool value)
|
||||||
|
{
|
||||||
|
ui->cbbUseDarkTheme->setChecked(value);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
@ -19,11 +19,13 @@ public:
|
|||||||
int verticalGridStep();
|
int verticalGridStep();
|
||||||
int horizontalGridStep();
|
int horizontalGridStep();
|
||||||
QFont defaultFont();
|
QFont defaultFont();
|
||||||
|
bool userDarkTheme();
|
||||||
bool suppressAbsentFieldsAndVarsWarnings();
|
bool suppressAbsentFieldsAndVarsWarnings();
|
||||||
void setSuppressAbsentFieldsAndVarsWarnings(bool value);
|
void setSuppressAbsentFieldsAndVarsWarnings(bool value);
|
||||||
void setHorizontalGridStep(int value);
|
void setHorizontalGridStep(int value);
|
||||||
void setVerticalGridStep(int value);
|
void setVerticalGridStep(int value);
|
||||||
void setDefaultFont(const QFont& value);
|
void setDefaultFont(const QFont& value);
|
||||||
|
void setUseDarkTheme(bool value);
|
||||||
private:
|
private:
|
||||||
Ui::SettingDialog *ui;
|
Ui::SettingDialog *ui;
|
||||||
};
|
};
|
||||||
|
@ -108,6 +108,13 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbbUseDarkTheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use dark theme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -45,7 +45,7 @@ class VarDesc : public QObject{
|
|||||||
Q_PROPERTY(bool isMandatory READ isMandatory WRITE setMandatory)
|
Q_PROPERTY(bool isMandatory READ isMandatory WRITE setMandatory)
|
||||||
Q_PROPERTY(int dataType READ readDataTypeProperty WRITE setDataTypeProperty)
|
Q_PROPERTY(int dataType READ readDataTypeProperty WRITE setDataTypeProperty)
|
||||||
public:
|
public:
|
||||||
VarDesc() : m_dataType(VariableDataType::Undefined), m_mandatory(false){}
|
VarDesc() : m_dataType(Enums::Undefined), m_mandatory(false){}
|
||||||
enum VarType {System, User, Report};
|
enum VarType {System, User, Report};
|
||||||
void setVarType(VarType value){m_varType=value;}
|
void setVarType(VarType value){m_varType=value;}
|
||||||
VarType varType(){return m_varType;}
|
VarType varType(){return m_varType;}
|
||||||
|
Loading…
Reference in New Issue
Block a user