//######################################################################################################### void NewJournalCreator::on_buttonBox_rejected() { // If this is the firstrun, return to the FirstRun class. It doesn't exist anymore at this //point, so create a new one. No one will ever know. if(Buffer::firstrun){ this->reject(); FirstRun f; f.exec(); } else{ this->reject(); } }
//################################################################################## void SettingsManager::LoadConfig(){ using namespace std; bool reload=false; QString config_path=QDir::homePath()+ QDir::separator() + ".robojournal"+ QDir::separator() + "robojournal.ini"; // construct a file object where the config file is supposed to be. QFile config(config_path); cout << "OUTPUT: Searching for config file..." << endl; // if config file exists, read its contents if(config.exists()){ #ifdef _WIN32 // Use backslashes to separate dirs on Windows. config_path=config_path.replace("/","\\"); #endif cout << "OUTPUT: Config file found: "<< config_path.toStdString() << endl; QSettings settings(config_path,QSettings::IniFormat); cout << "OUTPUT: Buffering data from config file..."; Buffer::toolbar_pos = settings.value("Behavior/toolbar_location").toInt(); Buffer::allowroot = settings.value("Behavior/allow_root_login").toBool(); Buffer::allentries = settings.value("Behavior/show_all_entries").toBool(); Buffer::alwaysusedefaults = settings.value("Behavior/always_use_defaults").toBool(); Buffer::backend = settings.value("Backend/db_type").toString(); Buffer::showwarnings = settings.value("Behavior/show_warnings").toBool(); Buffer::entryrange = settings.value("Backend/entry_range").toInt(); Buffer::defaulthost = settings.value("Backend/default_host").toString(); Buffer::defaultdatabase = settings.value("Backend/default_db").toString(); Buffer::defaultuser = settings.value("Backend/default_user").toString(); Buffer::databaseport = settings.value("Backend/port").toInt(); Buffer::sortbyday = settings.value("Behavior/sort_by_day").toBool(); Buffer::alternate_rows = settings.value("Behavior/alternate_colors").toBool(); Buffer::use_background = settings.value("Appearance/use_background").toBool(); Buffer::use_custom_theme = settings.value("Appearance/use_theme").toBool(); Buffer::tile_bg = settings.value("Appearance/tile_background").toBool(); Buffer::set_tree_background = settings.value("Appearance/background_tree").toBool(); Buffer::text_hexcolor = settings.value("Appearance/font_color").toString(); Buffer::font_face = settings.value("Appearance/font_face").toString(); Buffer::entry_node_icon = settings.value("Appearance/entry_node_icon").toInt(); Buffer::show_spell_errors_by_default = settings.value("Behavior/default_show_errors").toBool(); Buffer::editor_geometry=settings.value("Appearance/editor_size").toSize(); if(Buffer::editor_geometry.isEmpty()){ QSize *y=new QSize(640,480); Buffer::editor_geometry=*y; settings.beginGroup("Appearance"); settings.setValue("editor_size", *y); settings.endGroup(); reload=true; } Buffer::config_geometry=settings.value("Appearance/config_size").toSize(); if(Buffer::config_geometry.isEmpty()){ QSize *s=new QSize(575,525); Buffer::config_geometry=*s; settings.beginGroup("Appearance"); settings.setValue("config_size", *s); settings.endGroup(); reload=true; } Buffer::preview_geometry=settings.value("Appearance/preview_size").toSize(); Buffer::mainwindow_geometry=settings.value("Appearance/mainwindow_size").toByteArray(); Buffer::use_spellcheck = settings.value("Behavior/use_spellcheck").toBool(); Buffer::current_dictionary= settings.value("Behavior/spellcheck_dictionary").toString(); Buffer::current_dictionary_aff = settings.value("Behavior/spellcheck_dictionary_aff").toString(); int font_value=settings.value("Appearance/font_size").toInt(); switch(font_value){ case 0: Buffer::font_size="8"; break; case 1: Buffer::font_size="9"; break; case 2: Buffer::font_size="10"; break; case 3: Buffer::font_size="11"; break; case 4: Buffer::font_size="12"; break; case 5: Buffer::font_size="14"; break; case 6: Buffer::font_size="16"; break; case 7: Buffer::font_size="18"; break; case 8: Buffer::font_size="20"; break; case 9: Buffer::font_size="22"; break; case 10: Buffer::font_size="24"; break; case 11: Buffer::font_size="26"; break; } Buffer::keep_time = settings.value("Behavior/use_time").toBool(); Buffer::show_title = settings.value("Behavior/show_title").toBool(); Buffer::use_24_hour = settings.value("Behavior/use_24_hour_clock").toBool(); Buffer::date_format = settings.value("Behavior/set_date_format").toInt(); Buffer::background_image = settings.value("Appearance/background_image").toString(); Buffer::show_icon_labels = settings.value("Behavior/enable_toolbar_button_text").toBool(); Buffer::autoload = settings.value("Behavior/autoload_recent_entry").toBool(); Buffer::SSL = settings.value("Behavior/ssl_support").toBool(); Buffer::use_indicator = settings.value("Behavior/display_year_indicator").toBool(); Buffer::is_male = settings.value("User/user_gender_male").toBool(); Buffer::full_name = settings.value("User/user_full_name").toString(); Buffer::use_full_name= settings.value("User/use_full_name").toBool(); // 0.4 specific Buffer::use_rounded_corners = settings.value("Export/rounded_corners").toBool(); Buffer::use_system_colors = settings.value("Export/system_colors").toBool(); Buffer::include_tags_in_export = settings.value("Export/include_tags").toBool(); Buffer::header_font = settings.value("Export/header_font").toString(); Buffer::body_font = settings.value("Export/body_font").toString(); Buffer::header_use_em = settings.value("Export/header_use_em").toBool(); Buffer::body_use_em = settings.value("Export/body_use_em").toBool(); Buffer::header_font_size = settings.value("Export/header_font_size").toString(); Buffer::body_font_size = settings.value("Export/body_font_size").toString(); Buffer::highlight_color = settings.value("Appearance/highlight_color").toInt(); Buffer::bg_is_fixed = settings.value("Behavior/background_fixed").toBool(); Buffer::use_highlight = settings.value("Behavior/use_highlights").toBool(); Buffer::trim_whitespace = settings.value("Behavior/trim_whitespace").toBool(); Buffer::use_smart_quotes = settings.value("Behavior/smart_quotes").toBool(); Buffer::use_html_hyphens = settings.value("Behavior/html_hyphens").toBool(); Buffer::datebox_override = settings.value("Appearance/datebox_override").toBool(); Buffer::use_custom_theme_editor=settings.value("Appearance/use_theme_editor").toBool(); Buffer::use_dow=settings.value("Behavior/use_dow").toBool(); Buffer::use_misc_processing=settings.value("Behavior/misc_processing").toBool(); // 0.4.1 specific Buffer::name_in_titlebar=settings.value("Behavior/name_in_titlebar").toBool(); Buffer::show_untagged_reminder=settings.value("Behavior/show_untagged_reminder").toBool(); // 0.4.2 ( backported to 0.4.2 on 9/13/13) Buffer::mw_splitter_size=settings.value("Behavior/mw_splitter_position").toByteArray(); // added 6/21/13 if(reload){ LoadConfig(); } cout << "Done!" << endl; cout << "OUTPUT: Stage 1 completed, proceeding to Stage 2..." << endl; } // if config doesn't exist, rebuild it. else{ cout << "WARNING: Config file does not exist! Starting first run mode..." << endl; // give the journal creator a way to know its the first run Buffer::firstrun=true; // Launch the firstrun tool FirstRun f; f.exec(); } }