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 18ad2b8..12ec753 100644 Binary files a/translations/limereport_ru.qm and b/translations/limereport_ru.qm differ diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index 8d506fa..4329fe8 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -2727,6 +2727,10 @@ This preview is no longer valid. Theme Тема + + Report units + Единицы измерения + LimeReport::SubDetailBand @@ -3154,5 +3158,21 @@ This preview is no longer valid. '' + + Millimeters + Миллиметры + + + Inches + Дюймы + + + Dark + Темная + + + Light + Светлая +