0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00

Report default units setting parameter has been added

This commit is contained in:
Arin Alexander 2019-06-30 22:00:01 +03:00
parent 0f227e803c
commit ca458dc9a8
8 changed files with 103 additions and 26 deletions

View File

@ -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_theme("Default"), m_settings(settings)
m_dialogChanged(false), m_theme("Default"), m_settings(settings), m_defaultUnits(BaseDesignIntf::Millimeters)
{
#ifdef HAVE_QT4
m_tabWidget = new LimeReportTabWidget(this);
@ -74,10 +74,19 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QSe
setLayout(mainLayout);
m_report=report;
if (!m_report->pageCount()) m_report->appendPage("page1");
m_settings->beginGroup("DesignerWidget");
QVariant v = m_settings->value("DefaultUnits");
if (v.isValid()){
m_defaultUnits = static_cast<BaseDesignIntf::UnitType>(v.toInt());
}
m_settings->endGroup();
if (!m_report->pageCount()){
createStartPage();
}
createTabs();
connect(dynamic_cast<QObject*>(m_report), SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished()));
connect(dynamic_cast<QObject*>(m_report), SIGNAL(cleared()), this, SIGNAL(cleared()));
connect(dynamic_cast<QObject*>(m_report), SIGNAL(loadFinished()), this, SLOT(slotReportLoaded()));
@ -102,6 +111,8 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivateInterface* report, QSe
#endif
m_themes.insert("Default","");
m_localToEng.insert(QObject::tr("Dark"), "Dark");
m_localToEng.insert(QObject::tr("Light"), "Light");
initThemeIfExist("Dark", ":/qdarkstyle/style.qss");
initThemeIfExist("Light", ":/qlightstyle/lightstyle.qss");
}
@ -135,8 +146,6 @@ QWidget *ReportDesignWidget::toolWindow(ReportDesignWidget::ToolWindowType windo
return dialogDesignerManager()->resourcesEditor();
case SignalSlotEditor:
return dialogDesignerManager()->signalSlotEditor();
default:
return 0;
}
}
@ -191,6 +200,7 @@ void ReportDesignWidget::saveState()
m_settings->setValue("useGrid",m_useGrid);
m_settings->setValue("theme",m_theme);
m_settings->setValue("ScriptEditorState", m_scriptEditor->saveState());
m_settings->setValue("DefaultUnits", m_defaultUnits);
m_settings->endGroup();
}
@ -264,10 +274,15 @@ void ReportDesignWidget::loadState()
}
v = m_settings->value("ScriptEditorState");
if (v.isValid()){
if (v.isValid() && m_scriptEditor){
m_scriptEditor->restoreState(v.toByteArray());
}
v = m_settings->value("DefaultUnits");
if (v.isValid()){
m_defaultUnits = static_cast<BaseDesignIntf::UnitType>(v.toInt());
}
m_settings->endGroup();
applySettings();
}
@ -276,18 +291,13 @@ void ReportDesignWidget::loadState()
void ReportDesignWidget::createTabs(){
m_tabWidget->clear();
int pageIndex = -1;
for (int i = 0; i<m_report->pageCount();++i){
// QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
for (int i = 0; i < m_report->pageCount(); ++i){
PageView* view = new PageView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
view->setScene(m_report->pageAt(i));
view->setPageItem(m_report->pageAt(i)->pageItem());
// foreach(QGraphicsItem* item, m_report->pageAt(i)->selectedItems()){
// item->setSelected(false);
// }
m_report->pageAt(i)->clearSelection();
view->centerOn(0,0);
@ -301,13 +311,6 @@ void ReportDesignWidget::createTabs(){
m_scriptEditor = new ScriptEditor(this);
// m_settings->beginGroup("DesignerWidget");
// QVariant v = m_settings->value("ScriptEditorState");
// if (v.isValid()){
// m_scriptEditor->restoreState(v.toByteArray());
// }
// m_settings->endGroup();
connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged()));
m_scriptEditor->setReportEngine(m_report);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
@ -378,10 +381,12 @@ void ReportDesignWidget::connectPage(PageDesignIntf *page)
emit activePageChanged();
}
void ReportDesignWidget::createStartPage()
PageDesignIntf* ReportDesignWidget::createStartPage()
{
m_report->appendPage("page1");
createTabs();
PageDesignIntf* page = m_report->appendPage("page1");
page->pageItem()->setUnitType(m_defaultUnits);
// createTabs();
return page;
}
void ReportDesignWidget::removeDatasource(const QString &datasourceName)
@ -707,7 +712,6 @@ void ReportDesignWidget::initThemeIfExist(const QString &themeName, const QStrin
theme.open(QIODevice::ReadOnly);
QString styleSheet = theme.readAll();
m_themes.insert(themeName, styleSheet);
m_localToEng.insert(QObject::tr(themeName.toLatin1()), themeName);
}
}
@ -786,10 +790,22 @@ void ReportDesignWidget::editSetting()
setting.setDesignerThemes(themes, QObject::tr(m_theme.toLatin1()));
setting.setDesignerLanguages(m_report->designerLanguages(), m_report->currentDesignerLanguage());
QList<QString> unitTypes;
unitTypes << QObject::tr("Millimeters") << QObject::tr("Inches");
setting.setDesignerUnites(unitTypes,
m_defaultUnits == BaseDesignIntf::Millimeters ?
QObject::tr("Millimeters") :
QObject::tr("Inches"));
if (setting.exec()){
m_horizontalGridStep = setting.horizontalGridStep();
m_verticalGridStep = setting.verticalGridStep();
m_defaultFont = setting.defaultFont();
if (setting.reportUnits().compare(QObject::tr("Millimeters")) == 0)
m_defaultUnits = BaseDesignIntf::Millimeters;
else {
m_defaultUnits = BaseDesignIntf::Inches;
}
if (m_localToEng.contains(setting.theme())){
m_theme = m_localToEng.value(setting.theme());
} else {

View File

@ -125,7 +125,8 @@ public:
ReportDesignWidget(ReportEnginePrivateInterface* report, QSettings* settings,
QMainWindow *mainWindow, QWidget *parent = 0);
~ReportDesignWidget();
void createStartPage();
PageDesignIntf *createStartPage();
void createTabs();
void clear();
DataSourceManager* dataManager();
ScriptEngineManager* scriptManager();
@ -240,7 +241,6 @@ signals:
void pageAdded(PageDesignIntf* page);
void pageDeleted();
protected:
void createTabs();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif
@ -274,6 +274,7 @@ private:
QSettings* m_settings;
QMap<QString, QString> m_themes;
QMap<QString, QString> m_localToEng;
BaseDesignIntf::UnitType m_defaultUnits;
};
} // namespace LimeReport

View File

@ -677,6 +677,7 @@ void ReportDesignWindow::startNewReport()
m_reportDesignWidget->saveState();
m_reportDesignWidget->clear();
m_reportDesignWidget->createStartPage();
m_reportDesignWidget->createTabs();
m_lblReportName->setText("");
updateRedoUndo();
m_reportDesignWidget->slotPagesLoadFinished();

View File

@ -75,6 +75,11 @@ QLocale::Language SettingDialog::designerLanguage()
return QLocale().language();
}
QString SettingDialog::reportUnits()
{
return ui->reportUnits->currentText();
}
void SettingDialog::setSuppressAbsentFieldsAndVarsWarnings(bool value){
ui->cbSuppressWarnings->setChecked(value);
}
@ -148,6 +153,17 @@ void SettingDialog::setDesignerThemes(QList<QString> themes, const QString &curr
#endif
}
void SettingDialog::setDesignerUnites(QList<QString> unitTypes, const QString currentUnitType)
{
ui->reportUnits->clear();
ui->reportUnits->addItems(unitTypes);
#ifdef HAVE_QT4
ui->cbTheme->setCurrentIndex(ui->cbTheme->findText(currentUnitType));
#else
ui->reportUnits->setCurrentText(currentUnitType);
#endif
}
void SettingDialog::setSettings(QSettings* settings){
m_settings = settings;
if (m_settings){

View File

@ -26,6 +26,7 @@ public:
QString theme();
bool suppressAbsentFieldsAndVarsWarnings();
QLocale::Language designerLanguage();
QString reportUnits();
void setSuppressAbsentFieldsAndVarsWarnings(bool value);
void setHorizontalGridStep(int value);
void setVerticalGridStep(int value);
@ -35,6 +36,7 @@ public:
void setTheme(const QString& theme);
void setDesignerLanguages(QList<QLocale::Language> languages, QLocale::Language currentLanguage);
void setDesignerThemes(QList<QString> themes, const QString& currentTheme);
void setDesignerUnites(QList<QString> unitTypes, const QString currentUnitType);
void setSettings(QSettings* settings);
private slots:
void on_bbOkCancel_accepted();

View File

@ -23,7 +23,7 @@
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -174,6 +174,27 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Report units</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="reportUnits">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">

Binary file not shown.

View File

@ -2727,6 +2727,10 @@ This preview is no longer valid.</source>
<source>Theme</source>
<translation>Тема</translation>
</message>
<message>
<source>Report units</source>
<translation>Единицы измерения</translation>
</message>
</context>
<context>
<name>LimeReport::SubDetailBand</name>
@ -3154,5 +3158,21 @@ This preview is no longer valid.</source>
<source>&apos;&apos;</source>
<translation></translation>
</message>
<message>
<source>Millimeters</source>
<translation>Миллиметры</translation>
</message>
<message>
<source>Inches</source>
<translation>Дюймы</translation>
</message>
<message>
<source>Dark</source>
<translation>Темная</translation>
</message>
<message>
<source>Light</source>
<translation>Светлая</translation>
</message>
</context>
</TS>