void runTests() { std::cout << "Detected home directory: " << ::core::Path::home() << std::endl; std::cout << "Application data directory: " << ::core::Path::data() << std::endl; std::cout << "Current working directory: " << ::core::Path::current() << std::endl; createPaths(); checkPaths(); absolutePaths(); makeDir(); time(timeFs, 1000); }
void ReportDialog::defaultValues() { logMessage("ReportDialog::defaultValues()"); chkProblemInformation->setChecked(true); chkPhysicalProperties->setChecked(true); chkGeometry->setChecked(true); chkScript->setChecked(true); chkFigureGeometry->setChecked(true); chkShowGrid->setChecked(true); chkShowRulers->setChecked(true); txtFigureWidth->setValue(Value("600")); txtFigureHeight->setValue(Value("400")); txtTemplate->setText(QString("%1/doc/report/default.html").arg(datadir())); txtStyleSheet->setText(QString("%1/doc/report/default.css").arg(datadir())); checkPaths(); }
void MainWindow::readSettings(bool reload) { #if QT_VERSION < QT_VERSION_CHECK(5,0,0) const QString DEFAULT_CACHE_PATH = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); #else const QString DEFAULT_CACHE_PATH = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); #endif QSettings settings; settings.beginGroup(SETTINGS_MAIN_SECTION); m_useCustomJava = settings.value(SETTINGS_USE_CUSTOM_JAVA, SETTINGS_USE_CUSTOM_JAVA_DEFAULT).toBool(); m_customJavaPath = settings.value(SETTINGS_CUSTOM_JAVA_PATH, SETTINGS_CUSTOM_JAVA_PATH_DEFAULT).toString(); m_javaPath = m_useCustomJava ? m_customJavaPath : SETTINGS_CUSTOM_JAVA_PATH_DEFAULT; m_useCustomPlantUml = settings.value(SETTINGS_USE_CUSTOM_PLANTUML, SETTINGS_USE_CUSTOM_PLANTUML_DEFAULT).toBool(); m_customPlantUmlPath = settings.value(SETTINGS_CUSTOM_PLANTUML_PATH, SETTINGS_CUSTOM_PLANTUML_PATH_DEFAULT).toString(); m_plantUmlPath = m_useCustomPlantUml ? m_customPlantUmlPath : SETTINGS_CUSTOM_PLANTUML_PATH_DEFAULT; m_useCustomGraphiz = settings.value(SETTINGS_USE_CUSTOM_GRAPHIZ, SETTINGS_USE_CUSTOM_GRAPHIZ_DEFAULT).toBool(); m_customGraphizPath = settings.value(SETTINGS_CUSTOM_GRAPHIZ_PATH, SETTINGS_CUSTOM_GRAPHIZ_PATH_DEFAULT).toString(); m_graphizPath = m_useCustomGraphiz ? m_customGraphizPath : SETTINGS_CUSTOM_GRAPHIZ_PATH_DEFAULT; checkPaths(); m_useCache = settings.value(SETTINGS_USE_CACHE, SETTINGS_USE_CACHE_DEFAULT).toBool(); m_useCustomCache = settings.value(SETTINGS_USE_CUSTOM_CACHE, SETTINGS_USE_CUSTOM_CACHE_DEFAULT).toBool(); m_customCachePath = settings.value(SETTINGS_CUSTOM_CACHE_PATH, DEFAULT_CACHE_PATH).toString(); m_cacheMaxSize = settings.value(SETTINGS_CACHE_MAX_SIZE, SETTINGS_CACHE_MAX_SIZE_DEFAULT).toInt(); m_cachePath = m_useCustomCache ? m_customCachePath : DEFAULT_CACHE_PATH; m_cache->setMaxCost(m_cacheMaxSize); m_cache->setPath(m_cachePath, [](const QString& path, const QString& key, int cost, const QDateTime& date_time, QObject* parent ) { return new FileCacheItem(path, key, cost, date_time, parent); }); reloadAssistantXml(settings.value(SETTINGS_ASSISTANT_XML_PATH).toString()); const bool autorefresh_enabled = settings.value(SETTINGS_AUTOREFRESH_ENABLED, false).toBool(); m_autoRefreshAction->setChecked(autorefresh_enabled); m_autoRefreshTimer->setInterval(settings.value(SETTINGS_AUTOREFRESH_TIMEOUT, SETTINGS_AUTOREFRESH_TIMEOUT_DEFAULT).toInt()); if (autorefresh_enabled) { m_autoRefreshTimer->start(); } m_autoRefreshLabel->setEnabled(autorefresh_enabled); m_autoSaveImageAction->setChecked(settings.value(SETTINGS_AUTOSAVE_IMAGE_ENABLED, SETTINGS_AUTOSAVE_IMAGE_ENABLED_DEFAULT).toBool()); if (!reload) { restoreGeometry(settings.value(SETTINGS_GEOMETRY).toByteArray()); restoreState(settings.value(SETTINGS_WINDOW_STATE).toByteArray()); } m_showMainToolbarAction->setChecked(m_mainToolBar->isVisibleTo(this)); // NOTE: works even if the current window is not yet displayed connect(m_showMainToolbarAction, SIGNAL(toggled(bool)), m_mainToolBar, SLOT(setVisible(bool))); const bool show_statusbar = settings.value(SETTINGS_SHOW_STATUSBAR, true).toBool(); m_showStatusBarAction->setChecked(show_statusbar); statusBar()->setVisible(show_statusbar); connect(m_showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool))); m_currentImageFormat = m_imageFormatNames.key(settings.value(SETTINGS_IMAGE_FORMAT, m_imageFormatNames[SvgFormat]).toString()); if (m_currentImageFormat == SvgFormat) { m_svgPreviewAction->setChecked(true); } else if (m_currentImageFormat == PngFormat) { m_pngPreviewAction->setChecked(true); } m_currentImageFormatLabel->setText(m_imageFormatNames[m_currentImageFormat].toUpper()); m_lastDir = settings.value(SETTINGS_EDITOR_LAST_DIR, SETTINGS_EDITOR_LAST_DIR_DEFAULT).toString(); settings.endGroup(); settings.beginGroup(SETTINGS_EDITOR_SECTION); QFont defaultFont; QFont editorFont; editorFont.fromString(settings.value(SETTINGS_EDITOR_FONT, defaultFont.toString()).toString()); m_editor->setFont(editorFont); m_editor->setAutoIndent(settings.value(SETTINGS_EDITOR_INDENT, SETTINGS_EDITOR_INDENT_DEFAULT).toBool()); m_editor->setIndentWithSpace(settings.value(SETTINGS_EDITOR_INDENT_WITH_SPACE, SETTINGS_EDITOR_INDENT_WITH_SPACE_DEFAULT).toBool()); m_editor->setIndentSize(settings.value(SETTINGS_EDITOR_INDENT_SIZE, SETTINGS_EDITOR_INDENT_SIZE_DEFAULT).toInt()); m_refreshOnSave = settings.value(SETTINGS_EDITOR_REFRESH_ON_SAVE, SETTINGS_EDITOR_REFRESH_ON_SAVE_DEFAULT).toBool(); settings.endGroup(); m_recentDocuments->readFromSettings(settings, SETTINGS_RECENT_DOCUMENTS_SECTION); updateCacheSizeInfo(); }
void ReportDialog::createControls() { logMessage("ReportDialog::createControls()"); chkDescription = new QCheckBox(tr("Description")); chkProblemInformation = new QCheckBox(tr("Problem information")); chkStartupScript = new QCheckBox(tr("Startup script")); chkPhysicalProperties = new QCheckBox(tr("Physical properties")); chkGeometry = new QCheckBox(tr("Geometry")); connect(chkGeometry, SIGNAL(clicked()), this, SLOT(resetControls())); chkMeshAndSolution = new QCheckBox(tr("Mesh and solution")); connect(chkMeshAndSolution, SIGNAL(clicked()), this, SLOT(resetControls())); chkScript = new QCheckBox(tr("Script")); chkFigureGeometry = new QCheckBox(tr("Geometry")); chkFigureMesh = new QCheckBox(tr("Mesh")); chkFigureOrder = new QCheckBox(tr("Order")); chkFigureScalarView = new QCheckBox(tr("Scalar view")); chkFigureContourView = new QCheckBox(tr("Contour view")); chkFigureVectorView = new QCheckBox(tr("Vector view")); chkShowGrid = new QCheckBox(tr("Show grid")); chkShowRulers = new QCheckBox(tr("Show rulers")); txtTemplate = new QLineEdit(); connect(txtTemplate, SIGNAL(textChanged(QString)), this, SLOT(checkPaths())); txtStyleSheet = new QLineEdit(); connect(txtStyleSheet, SIGNAL(textChanged(QString)), this, SLOT(checkPaths())); txtFigureWidth = new ValueLineEdit(); txtFigureWidth->setValue(Value("600")); txtFigureWidth->setMinimum(200); txtFigureHeight = new ValueLineEdit(); txtFigureHeight->setValue(Value("400")); txtFigureHeight->setMinimum(200); btnDefault = new QPushButton(tr("Default")); connect(btnDefault, SIGNAL(clicked()), this, SLOT(defaultValues())); btnShowReport = new QPushButton(tr("Show report")); connect(btnShowReport, SIGNAL(clicked()), this, SLOT(doShowReport())); btnClose = new QPushButton(tr("Close")); btnClose->setDefault(true); connect(btnClose, SIGNAL(clicked()), this, SLOT(doClose())); QVBoxLayout *layoutSections = new QVBoxLayout(); layoutSections->addWidget(chkDescription); layoutSections->addWidget(chkProblemInformation); layoutSections->addWidget(chkStartupScript); layoutSections->addWidget(chkPhysicalProperties); layoutSections->addWidget(chkGeometry); layoutSections->addWidget(chkMeshAndSolution); layoutSections->addWidget(chkScript); QVBoxLayout *layoutFigures = new QVBoxLayout(); layoutFigures->addWidget(chkFigureGeometry); layoutFigures->addWidget(chkFigureMesh); layoutFigures->addWidget(chkFigureOrder); layoutFigures->addWidget(chkFigureScalarView); layoutFigures->addWidget(chkFigureContourView); layoutFigures->addWidget(chkFigureVectorView); layoutFigures->addWidget(new QLabel()); layoutFigures->addWidget(chkShowGrid); layoutFigures->addWidget(chkShowRulers); QGridLayout *layoutSection = new QGridLayout(); layoutSection->addLayout(layoutSections, 0, 0); QGridLayout *layoutTemplate = new QGridLayout(); layoutTemplate->addWidget(new QLabel(tr("Template")), 0, 0); layoutTemplate->addWidget(txtTemplate, 0, 1); layoutTemplate->addWidget(new QLabel(tr("Style sheet")), 1, 0); layoutTemplate->addWidget(txtStyleSheet, 1, 1); QGridLayout *layoutFigureSize = new QGridLayout(); layoutFigureSize->addWidget(new QLabel(tr("Width")), 0, 0); layoutFigureSize->addWidget(txtFigureWidth, 0, 1); layoutFigureSize->addWidget(new QLabel(tr("Height")), 1, 0); layoutFigureSize->addWidget(txtFigureHeight, 1, 1); layoutFigureSize->setRowStretch(2, 1); QHBoxLayout *layoutFigure = new QHBoxLayout(); layoutFigure->addLayout(layoutFigures); layoutFigure->addLayout(layoutFigureSize); layoutFigure->addStretch(); QHBoxLayout *layoutButtons = new QHBoxLayout(); layoutButtons->addStretch(); layoutButtons->addWidget(btnShowReport); layoutButtons->addWidget(btnDefault); layoutButtons->addWidget(btnClose); QGroupBox *grpBasicProperties = new QGroupBox(tr("Sections")); grpBasicProperties->setLayout(layoutSection); QGroupBox *grpFigure = new QGroupBox(tr("Figures properties")); grpFigure->setLayout(layoutFigure); QGroupBox *grpAdditionalProperties = new QGroupBox(tr("Additional properties")); grpAdditionalProperties->setLayout(layoutTemplate); QGridLayout *layout = new QGridLayout(); layout->addWidget(grpBasicProperties, 0, 0); layout->addWidget(grpFigure, 0, 1); // layout->addWidget(grpAdditionalProperties, 1, 0, 1, 2); layout->addLayout(layoutButtons, 2, 0, 2, 2); setLayout(layout); }