From ca458dc9a859870a8ceffa15f9b7144f41a8cab7 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sun, 30 Jun 2019 22:00:01 +0300 Subject: [PATCH] Report default units setting parameter has been added --- limereport/lrreportdesignwidget.cpp | 62 +++++++++++++++++----------- limereport/lrreportdesignwidget.h | 5 ++- limereport/lrreportdesignwindow.cpp | 1 + limereport/lrsettingdialog.cpp | 16 +++++++ limereport/lrsettingdialog.h | 2 + limereport/lrsettingdialog.ui | 23 ++++++++++- translations/limereport_ru.qm | Bin 123030 -> 123356 bytes translations/limereport_ru.ts | 20 +++++++++ 8 files changed, 103 insertions(+), 26 deletions(-) diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index c2d52b3..12d4116 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -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(v.toInt()); + } + m_settings->endGroup(); + + if (!m_report->pageCount()){ + createStartPage(); + } createTabs(); - connect(dynamic_cast(m_report), SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished())); connect(dynamic_cast(m_report), SIGNAL(cleared()), this, SIGNAL(cleared())); connect(dynamic_cast(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(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; ipageCount();++i){ -// QGraphicsView* view = new QGraphicsView(qobject_cast(this)); + for (int i = 0; i < m_report->pageCount(); ++i){ PageView* view = new PageView(qobject_cast(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 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 { diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 5de247e..f48879c 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -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 m_themes; QMap m_localToEng; + BaseDesignIntf::UnitType m_defaultUnits; }; } // namespace LimeReport diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 20d1273..d98af07 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -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(); diff --git a/limereport/lrsettingdialog.cpp b/limereport/lrsettingdialog.cpp index ee54096..bff304c 100644 --- a/limereport/lrsettingdialog.cpp +++ b/limereport/lrsettingdialog.cpp @@ -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 themes, const QString &curr #endif } +void SettingDialog::setDesignerUnites(QList 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){ diff --git a/limereport/lrsettingdialog.h b/limereport/lrsettingdialog.h index 3049d87..b10139f 100644 --- a/limereport/lrsettingdialog.h +++ b/limereport/lrsettingdialog.h @@ -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 languages, QLocale::Language currentLanguage); void setDesignerThemes(QList themes, const QString& currentTheme); + void setDesignerUnites(QList unitTypes, const QString currentUnitType); void setSettings(QSettings* settings); private slots: void on_bbOkCancel_accepted(); diff --git a/limereport/lrsettingdialog.ui b/limereport/lrsettingdialog.ui index 86fe2e2..3c197bf 100644 --- a/limereport/lrsettingdialog.ui +++ b/limereport/lrsettingdialog.ui @@ -23,7 +23,7 @@ - 2 + 0 @@ -174,6 +174,27 @@ + + + + + + Report units + + + + + + + + 0 + 0 + + + + + + diff --git a/translations/limereport_ru.qm b/translations/limereport_ru.qm index 18ad2b88ee1a568937de2e810ad9e816a30db67b..12ec7530b47fb12eeb917efec1ff743ed4673b60 100644 GIT binary patch delta 1257 zcmY+EeNa?Y7{=fCc=s-MSy&d?oJCm#1#&XXkHsd~lbIOFja27g!XP3QUvwBe7AlGGm4*nd#{Lt2=Y=Z_b?a-1DC2 zJm*yPEAKd!6#>!=0CNCdF0Kp;mI?usCcrDZDifnv>)Og90~;Bxta-^;2H0%`;cP9y zZ;j81?^?RlN_Bv}`{DJ~rA#L_=!2Uo;pLi3{*#XufCt%w@U_DU}aQEfs#HBZ69xMTC z8P_}irD+zWYFY?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4F9d5V_AE7+bbV3O*is3 z9|1PDD?C%h+h3jl>^(|t{yCgGfdpwczC?M_3aXOUaUJv2CZ#{-E*AYmHNYzVS#)LP0yfQy zZsV(fgBE%>u!b9ZoR$KkF}yP}C=R*NCNeI&xx(?2w82#d==fCHdTupf?l#FVKFjP4 zWRRn@eGaLpJ`yl#Rw};48r^-HN@cU|3CVXU7~pP@bTvo|aAQci`xSe7U1RjSoP`Z! z2+q=#sEb-R0cIpB99dLb)+__;siNlK49%13ffFpO@P|TY2rUJtaGkfvpwVM46=~u) z?-ZTXq~Z=5XNL1EEokaF&ogvVo5FcMqj7CA=PD*4Bvoe&EZDgb&~`ZR_3=zV(|U!z zGRg~SK{E-VIo!no$_u@stCUryB*6Tua`@#Ez{1sX>@ZWvb&rf;DM{V}+1zvj@IaLO zP7iBp=o;Db*K17CeR7qBMHmufn=O=$Plar+`3g mtPOW)!|@}V(c%OyC Theme Тема + + Report units + Единицы измерения + LimeReport::SubDetailBand @@ -3154,5 +3158,21 @@ This preview is no longer valid. '' + + Millimeters + Миллиметры + + + Inches + Дюймы + + + Dark + Темная + + + Light + Светлая +