void CSettingTypeApplication::Initialize( const char * /*AppName*/ ) { stdstr SettingsFile, OrigSettingsFile; for (int i = 0; i < 100; i++) { OrigSettingsFile = SettingsFile; if (!g_Settings->LoadStringVal(SupportFile_Settings,SettingsFile) && i > 0) { break; } if (SettingsFile == OrigSettingsFile) { break; } if (m_SettingsIniFile) { delete m_SettingsIniFile; } CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),""); if (!SettingsDir.DirectoryExists()) { SettingsDir.DirectoryCreate(); } m_SettingsIniFile = new CIniFile(SettingsFile.c_str()); } m_SettingsIniFile->SetAutoFlush(false); m_UseRegistry = g_Settings->LoadBool(Setting_UseFromRegistry); }
void CSettingTypeApplication::Initialize(const char * /*AppName*/) { WriteTrace(TraceAppInit, TraceDebug, "Start"); CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), ""); if (!BaseDir.DirectoryExists()) { WriteTrace(TraceAppInit, TraceDebug, "BaseDir does not exist. Doing nothing."); WriteTrace(TraceAppInit, TraceDebug, "Done"); return; } stdstr SettingsFile, OrigSettingsFile; for (int i = 0; i < 100; i++) { OrigSettingsFile = SettingsFile; if (!g_Settings->LoadStringVal(SupportFile_Settings, SettingsFile) && i > 0) { break; } if (SettingsFile == OrigSettingsFile) { break; } if (m_SettingsIniFile) { delete m_SettingsIniFile; } #ifdef _WIN32 CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(), ""); #else CPath SettingsDir(CPath(SettingsFile).GetDirectory(), ""); #endif if (!SettingsDir.DirectoryExists()) { SettingsDir.DirectoryCreate(); } m_SettingsIniFile = new CIniFile(SettingsFile.c_str()); } m_SettingsIniFile->SetAutoFlush(false); WriteTrace(TraceAppInit, TraceDebug, "Done"); }
void Settings::CreateSettingsDir() { std::wstring settingsDir = SettingsDir(); CLOG(L"Creating settings directory: %s", settingsDir.c_str()); settingsDir = L"\\\\?\\" + settingsDir; /* Use long file path (\\?\) */ BOOL result = CreateDirectory(settingsDir.c_str(), NULL); if (result == FALSE) { if (GetLastError() == ERROR_ALREADY_EXISTS) { QCLOG(L"Directory already exists."); return; } if (GetLastError() == ERROR_PATH_NOT_FOUND) { QCLOG(L"Path not found!"); // TODO: error message? } } }
std::wstring Settings::SettingsFile() { return SettingsDir() + std::wstring(L"\\") + SETTINGS_FILE; }
/// @return full path to file in the settings directory string SettingsPathForFile(string const & file) const { return SettingsDir() + file; }
void MainWindow::readSettings() { qDebug("Reading Settings..."); // This file needs to be read from the users home directory to ensure it is writable QString settingsPath = SettingsPath(); QString settingsDir = SettingsDir(); QString appDir = qApp->applicationDirPath(); QSettings settings(settingsPath, QSettings::IniFormat); QPoint pos = settings.value("Window/Position", QPoint(0, 0)).toPoint(); QSize size = settings.value("Window/Size", QSize(800, 600)).toSize(); layoutState = settings.value("LayoutState").toByteArray(); if(!restoreState(layoutState)) { qDebug("LayoutState NOT restored! Setting Default Layout..."); //someToolBar->setVisible(true); } //General settings_general_language = settings.value("Language", "default").toString(); settings_general_icon_theme = settings.value("IconTheme", "default").toString(); settings_general_icon_size = settings.value("IconSize", 16).toInt(); settings_general_mdi_bg_use_logo = settings.value("MdiBGUseLogo", true).toBool(); settings_general_mdi_bg_use_texture = settings.value("MdiBGUseTexture", true).toBool(); settings_general_mdi_bg_use_color = settings.value("MdiBGUseColor", true).toBool(); settings_general_mdi_bg_logo = settings.value("MdiBGLogo", appDir + "/images/logo-spirals.png").toString(); settings_general_mdi_bg_texture = settings.value("MdiBGTexture", appDir + "/images/texture-spirals.png").toString(); settings_general_mdi_bg_color = settings.value("MdiBGColor", qRgb(192,192,192)).toInt(); settings_general_tip_of_the_day = settings.value("TipOfTheDay", true).toBool(); settings_general_current_tip = settings.value("CurrentTip", 0).toInt(); settings_general_system_help_browser = settings.value("SystemHelpBrowser", true).toBool(); //Display settings_display_use_opengl = settings.value("Display/UseOpenGL", false).toBool(); settings_display_renderhint_aa = settings.value("Display/RenderHintAntiAlias", false).toBool(); settings_display_renderhint_text_aa = settings.value("Display/RenderHintTextAntiAlias", false).toBool(); settings_display_renderhint_smooth_pix = settings.value("Display/RenderHintSmoothPixmap", false).toBool(); settings_display_renderhint_high_aa = settings.value("Display/RenderHintHighQualityAntiAlias", false).toBool(); settings_display_renderhint_noncosmetic = settings.value("Display/RenderHintNonCosmetic", false).toBool(); settings_display_show_scrollbars = settings.value("Display/ShowScrollBars", true).toBool(); settings_display_scrollbar_widget_num = settings.value("Display/ScrollBarWidgetNum", 0).toInt(); settings_display_crosshair_color = settings.value("Display/CrossHairColor", qRgb( 0, 0, 0)).toInt(); settings_display_bg_color = settings.value("Display/BackgroundColor", qRgb(235,235,235)).toInt(); settings_display_selectbox_left_color = settings.value("Display/SelectBoxLeftColor", qRgb( 0,128, 0)).toInt(); settings_display_selectbox_left_fill = settings.value("Display/SelectBoxLeftFill", qRgb( 0,255, 0)).toInt(); settings_display_selectbox_right_color = settings.value("Display/SelectBoxRightColor", qRgb( 0, 0,128)).toInt(); settings_display_selectbox_right_fill = settings.value("Display/SelectBoxRightFill", qRgb( 0, 0,255)).toInt(); settings_display_selectbox_alpha = settings.value("Display/SelectBoxAlpha", 32).toInt(); settings_display_zoomscale_in = settings.value("Display/ZoomScaleIn", 2.0).toFloat(); settings_display_zoomscale_out = settings.value("Display/ZoomScaleOut", 0.5).toFloat(); settings_display_crosshair_percent = settings.value("Display/CrossHairPercent", 5).toInt(); settings_display_units = settings.value("Display/Units", "mm").toString(); //Prompt settings_prompt_text_color = settings.value("Prompt/TextColor", qRgb( 0, 0, 0)).toInt(); settings_prompt_bg_color = settings.value("Prompt/BackgroundColor", qRgb(255,255,255)).toInt(); settings_prompt_font_family = settings.value("Prompt/FontFamily", "Monospace").toString(); settings_prompt_font_style = settings.value("Prompt/FontStyle", "normal").toString(); settings_prompt_font_size = settings.value("Prompt/FontSize", 12).toInt(); settings_prompt_save_history = settings.value("Prompt/SaveHistory", true).toBool(); settings_prompt_save_history_as_html = settings.value("Prompt/SaveHistoryAsHtml", false).toBool(); settings_prompt_save_history_filename = settings.value("Prompt/SaveHistoryFilename", settingsDir + "prompt.log").toString(); //OpenSave settings_opensave_custom_filter = settings.value("OpenSave/CustomFilter", "supported").toString(); settings_opensave_open_format = settings.value("OpenSave/OpenFormat", "*.*").toString(); settings_opensave_open_thumbnail = settings.value("OpenSave/OpenThumbnail", false).toBool(); settings_opensave_save_format = settings.value("OpenSave/SaveFormat", "*.*").toString(); settings_opensave_save_thumbnail = settings.value("OpenSave/SaveThumbnail", false).toBool(); //Recent settings_opensave_recent_max_files = settings.value("OpenSave/RecentMax", 10).toInt(); settings_opensave_recent_list_of_files = settings.value("OpenSave/RecentFiles") .toStringList(); settings_opensave_recent_directory = settings.value("OpenSave/RecentDirectory", appDir + "/samples").toString(); //Trimming settings_opensave_trim_dst_num_jumps = settings.value("OpenSave/TrimDstNumJumps", 5).toInt(); //Printing settings_printing_default_device = settings.value("Printing/DefaultDevice", "").toString(); settings_printing_use_last_device = settings.value("Printing/UseLastDevice", false).toBool(); settings_printing_disable_bg = settings.value("Printing/DisableBG", true).toBool(); //Grid settings_grid_show_on_load = settings.value("Grid/ShowOnLoad", true).toBool(); settings_grid_show_origin = settings.value("Grid/ShowOrigin", true).toBool(); settings_grid_color_match_crosshair = settings.value("Grid/ColorMatchCrossHair", true).toBool(); settings_grid_color = settings.value("Grid/Color", qRgb( 0, 0, 0)).toInt(); settings_grid_load_from_file = settings.value("Grid/LoadFromFile", true).toBool(); settings_grid_type = settings.value("Grid/Type", "Rectangular").toString(); settings_grid_center_on_origin = settings.value("Grid/CenterOnOrigin", true).toBool(); settings_grid_center_x = settings.value("Grid/CenterX", 0.0).toFloat(); settings_grid_center_y = settings.value("Grid/CenterY", 0.0).toFloat(); settings_grid_size_x = settings.value("Grid/SizeX", 100.0).toFloat(); settings_grid_size_y = settings.value("Grid/SizeY", 100.0).toFloat(); settings_grid_spacing_x = settings.value("Grid/SpacingX", 25.0).toFloat(); settings_grid_spacing_y = settings.value("Grid/SpacingY", 25.0).toFloat(); settings_grid_size_radius = settings.value("Grid/SizeRadius", 50.0).toFloat(); settings_grid_spacing_radius = settings.value("Grid/SpacingRadius", 25.0).toFloat(); settings_grid_spacing_angle = settings.value("Grid/SpacingAngle", 45.0).toFloat(); //Ruler settings_ruler_show_on_load = settings.value("Ruler/ShowOnLoad", true).toBool(); settings_ruler_metric = settings.value("Ruler/Metric", true).toBool(); settings_ruler_color = settings.value("Ruler/Color", qRgb(210,210, 50)).toInt(); settings_ruler_pixel_size = settings.value("Ruler/PixelSize", 20).toInt(); //Quick Snap settings_qsnap_enabled = settings.value("QuickSnap/Enabled", true).toBool(); settings_qsnap_locator_color = settings.value("QuickSnap/LocatorColor", qRgb(255,255, 0)).toInt(); settings_qsnap_locator_size = settings.value("QuickSnap/LocatorSize", 4).toInt(); settings_qsnap_aperture_size = settings.value("QuickSnap/ApertureSize", 10).toInt(); settings_qsnap_endpoint = settings.value("QuickSnap/EndPoint", true).toBool(); settings_qsnap_midpoint = settings.value("QuickSnap/MidPoint", true).toBool(); settings_qsnap_center = settings.value("QuickSnap/Center", true).toBool(); settings_qsnap_node = settings.value("QuickSnap/Node", true).toBool(); settings_qsnap_quadrant = settings.value("QuickSnap/Quadrant", true).toBool(); settings_qsnap_intersection = settings.value("QuickSnap/Intersection", true).toBool(); settings_qsnap_extension = settings.value("QuickSnap/Extension", true).toBool(); settings_qsnap_insertion = settings.value("QuickSnap/Insertion", false).toBool(); settings_qsnap_perpendicular = settings.value("QuickSnap/Perpendicular", true).toBool(); settings_qsnap_tangent = settings.value("QuickSnap/Tangent", true).toBool(); settings_qsnap_nearest = settings.value("QuickSnap/Nearest", false).toBool(); settings_qsnap_apparent = settings.value("QuickSnap/Apparent", false).toBool(); settings_qsnap_parallel = settings.value("QuickSnap/Parallel", false).toBool(); //LineWeight settings_lwt_show_lwt = settings.value("LineWeight/ShowLineWeight", false).toBool(); settings_lwt_real_render = settings.value("LineWeight/RealRender", true).toBool(); settings_lwt_default_lwt = settings.value("LineWeight/DefaultLineWeight", 0).toReal(); //Selection settings_selection_mode_pickfirst = settings.value("Selection/PickFirst", true).toBool(); settings_selection_mode_pickadd = settings.value("Selection/PickAdd", true).toBool(); settings_selection_mode_pickdrag = settings.value("Selection/PickDrag", false).toBool(); settings_selection_coolgrip_color = settings.value("Selection/CoolGripColor", qRgb( 0, 0,255)).toInt(); settings_selection_hotgrip_color = settings.value("Selection/HotGripColor", qRgb(255, 0, 0)).toInt(); settings_selection_grip_size = settings.value("Selection/GripSize", 4).toInt(); settings_selection_pickbox_size = settings.value("Selection/PickBoxSize", 4).toInt(); //Text settings_text_font = settings.value("Text/Font", "Arial").toString(); settings_text_size = settings.value("Text/Size", 12).toReal(); settings_text_angle = settings.value("Text/Angle", 0).toReal(); settings_text_style_bold = settings.value("Text/StyleBold", false).toBool(); settings_text_style_italic = settings.value("Text/StyleItalic", false).toBool(); settings_text_style_underline = settings.value("Text/StyleUnderline", false).toBool(); settings_text_style_strikeout = settings.value("Text/StyleStrikeOut", false).toBool(); settings_text_style_overline = settings.value("Text/StyleOverline", false).toBool(); move(pos); resize(size); }