Mercurial > octave
diff gui/src/resource-manager.cc @ 14804:a565c560e654 gui
Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
* default-settings: New file containing the default settings.
* file-editor-tab: Subclassed event observer and added code to send a run event.
* main-window: Sending workspace events instead of using the terminal.
* octave-event: Added new event types.
* octave-link: Added getter for the current working directory.
* octave-gui: Adjusted code, so the default settings can be loaded.
* resource-manager: Added code to handle the logic with a default settings file.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jun 2012 15:27:10 +0200 |
parents | 5cb54cca8a06 |
children | 9a355dfc7701 |
line wrap: on
line diff
--- a/gui/src/resource-manager.cc Tue Jun 26 10:54:39 2012 +0200 +++ b/gui/src/resource-manager.cc Tue Jun 26 15:27:10 2012 +0200 @@ -24,6 +24,7 @@ resource_manager::resource_manager () { _settings = 0; + _first_run = false; reload_settings (); } @@ -49,21 +50,23 @@ { QDesktopServices desktopServices; _home_path = desktopServices.storageLocation (QDesktopServices::HomeLocation); - set_settings(_home_path + "/.config/octave-gui/settings"); + QString settings_file = _home_path + "/.config/octave-gui/settings"; + + if (!QFile::exists (settings_file)) + { + QFile::copy ("../default-settings", settings_file); + _first_run = true; + } + else + _first_run = false; + + set_settings (settings_file); } void resource_manager::set_settings (QString file) { delete _settings; - - _first_run = false; - if (!QFile::exists (file)) - _first_run = true; - - // If the settings file does not exist, QSettings automatically creates it. - // Therefore we have to check if it exists before instantiating the settings object. - // That way we can detect if the user ran this application before. _settings = new QSettings (file, QSettings::IniFormat); } @@ -122,8 +125,6 @@ _icons [resource_manager::octave] = QIcon ("../media/logo.png"); _icons [resource_manager::terminal] = QIcon ("../media/terminal.png"); _icons [resource_manager::documentation] = QIcon ("../media/help_index.png"); - _icons [resource_manager::chat] = QIcon ("../media/chat.png"); - _icons [resource_manager::chat_new_message] = QIcon ("../media/jabber_protocol.png"); } const char*