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