// Initialises the settings class, by creating a settings file if one does not exist already, and loading all settings from the 
// file into the class.
void Settings::initSettings() {
	//If the file does not exist then generate a new file.
	if (!settingsFile.good()) {
		//Generate Settings File
		std::cout << "Settings File Does Not Exist... \n";
		std::cout << "Generating Settings File... \n\n";

		//Creates the file and loads the default settings
		generateSettingsFile();
	}

	else {
		std::cout << "Settings File Exists... \n\n";
		settingsFile.close();
	}
	// Opens the settings file for reading and writing.
	settingsFile.open("Settings/settings.txt", std::fstream::in);
	// Read the file line by line.
	std::string settingsLine;
	while (std::getline(settingsFile, settingsLine)) {
		// If the line loaded from the file is not blank and is not a comment (begins with '/') then load that setting
		if (settingsLine.length() != 0) {
			if (settingsLine[0] != '/') {
				loadSettingsFromFile(settingsLine);
			}
		}
	}
	settingsFile.close();
}
bool KMeansFeatures::loadSettingsFromFile(const string filename){
    
    std::fstream file;
    file.open(filename.c_str(), std::ios::in);
    
    if( !loadSettingsFromFile( file ) ){
        return false;
    }
    
    //Close the file
    file.close();
    
    return true;
}
bool KMeansQuantizer::loadSettingsFromFile(string filename){
    
    std::fstream file;
    file.open(filename.c_str(), std::ios::in);
    
    if( !loadSettingsFromFile( file ) ){
        file.close();
        initialized = false;
        return false;
    }
    
    file.close();
    
    return true;
}
示例#4
0
MainWindow::MainWindow() :
	QMainWindow(),
	ui( new Ui::MainWindow ),
	m_configChanged( false )
{
	ui->setupUi( this );

	setWindowTitle( tr( "iTALC Management Console %1" ).arg( ITALC_VERSION ) );

	// reset all widget's values to current configuration
	reset();

	// if local configuration is incomplete, re-enable the apply button
	if( ItalcConfiguration(
			Configuration::Store::LocalBackend ).data().size() <
										ItalcCore::config->data().size() )
	{
		configurationChanged();
	}

	// connect widget signals to configuration property write methods
	FOREACH_ITALC_CONFIG_PROPERTY(CONNECT_WIDGET_TO_PROPERTY)

#define CONNECT_BUTTON_SLOT(name) \
			connect( ui->name, SIGNAL( clicked() ), this, SLOT( name() ) );

	CONNECT_BUTTON_SLOT( startService );
	CONNECT_BUTTON_SLOT( stopService );

	CONNECT_BUTTON_SLOT( openLogFileDirectory );
	CONNECT_BUTTON_SLOT( clearLogFiles );

	CONNECT_BUTTON_SLOT( openGlobalConfig );
	CONNECT_BUTTON_SLOT( openPersonalConfig );
	CONNECT_BUTTON_SLOT( openSnapshotDirectory );

	CONNECT_BUTTON_SLOT( openPublicKeyBaseDir );
	CONNECT_BUTTON_SLOT( openPrivateKeyBaseDir );

	CONNECT_BUTTON_SLOT( launchKeyFileAssistant );
	CONNECT_BUTTON_SLOT( manageACLs );
	CONNECT_BUTTON_SLOT( testLogonAuthentication );

	CONNECT_BUTTON_SLOT( generateBugReportArchive );

	connect( ui->buttonBox, SIGNAL( clicked( QAbstractButton * ) ),
				this, SLOT( resetOrApply( QAbstractButton * ) ) );

	connect( ui->actionLoadSettings, SIGNAL( triggered() ),
				this, SLOT( loadSettingsFromFile() ) );
	connect( ui->actionSaveSettings, SIGNAL( triggered() ),
				this, SLOT( saveSettingsToFile() ) );

	connect( ui->actionAboutQt, SIGNAL( triggered() ),
				QApplication::instance(), SLOT( aboutQt() ) );

	updateServiceControl();

	QTimer *serviceUpdateTimer = new QTimer( this );
	serviceUpdateTimer->start( 2000 );

	connect( serviceUpdateTimer, SIGNAL( timeout() ),
				this, SLOT( updateServiceControl() ) );

	connect( ItalcCore::config, SIGNAL( configurationChanged() ),
				this, SLOT( configurationChanged() ) );

#ifndef ITALC_BUILD_WIN32
	ui->logToWindowsEventLog->hide();
#endif
}
示例#5
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR, int nCmdShow)
{

	MSG msg;
	WNDCLASS wndclass,wndclass2;
	short seed;

	if (!hPrevInstance) {
		wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
		wndclass.lpfnWndProc = WndProc;
		wndclass.cbClsExtra = 0;
		wndclass.cbWndExtra = 0;
		wndclass.hInstance = hInstance;
		wndclass.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10));
		wndclass.hCursor = NULL;
		wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
		wndclass.lpszMenuName = MAKEINTRESOURCE(1);
		wndclass.lpszClassName = szAppName;

		RegisterClass(&wndclass);

		wndclass2.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
		wndclass2.lpfnWndProc = WndProc;
		wndclass2.cbClsExtra = 0;
		wndclass2.cbWndExtra = 0;
		wndclass2.hInstance = hInstance;
		wndclass2.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10));
		wndclass2.hCursor = NULL;
		wndclass2.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
		wndclass2.lpszMenuName = NULL;
		wndclass2.lpszClassName = szWinName;

		RegisterClass(&wndclass2);
		}

		mainPtr = CreateWindow (szAppName,
			"Classic Blades of Exile Scenario Editor",
			WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
			0,
			0,
			536,
			478,
			NULL,
			NULL,
			hInstance,
			NULL);


	if (!hPrevInstance) { // initialize
		//center_window(mainPtr);
 		Get_Path(file_path_name);
		store_hInstance = hInstance;
		accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(1));
		loadSettingsFromFile();

		seed = (short) GetCurrentTime();
		srand(seed);

		data_store = new piles_of_stuff_dumping_type;

		max_window(mainPtr);
		GetWindowRect(mainPtr,&windRect);
		SetTimer(mainPtr,1,20,NULL);

		ShowWindow(mainPtr,nCmdShow);
		Set_up_win ();
		init_lb();
		init_rb();
		init_town(1);
		init_out();

		init_scenario();

		font = CreateFont(12,0,0,0,0, 0,0,0, 0,0,
			0,0,0,"MS Sans Serif");
		small_bold_font = CreateFont(12,0,0,0,700, 0,0,0, 0,0,
			0,0,0,"MS Sans Serif");
		italic_font = CreateFont(12,0,0,0,0, 1,0,0, 0,0,
			0,0,0,"MS Sans Serif");
		underline_font = CreateFont(12,0,0,0,0, 0,1,0, 0,0,
			0,0,0,"MS Sans Serif");
		bold_font = CreateFont(14,0,0,0,700, 0,0,0, 0,0,
			0,0,0,"MS Sans Serif");
		tiny_font = font;
		load_sounds();

		right_sbar_rect.top = RIGHT_AREA_UL_Y;
		right_sbar_rect.left = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH - 16 ;
		right_sbar_rect.bottom = RIGHT_AREA_UL_Y + RIGHT_AREA_HEIGHT;
		right_sbar_rect.right = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH ;
		right_sbar = CreateWindow("scrollbar",NULL,
			WS_CHILD | WS_TABSTOP | SBS_VERT, right_sbar_rect.left + ulx,right_sbar_rect.top + uly,
			right_sbar_rect.right - right_sbar_rect.left,
			right_sbar_rect.bottom - right_sbar_rect.top,
			mainPtr,(HMENU) 1,store_hInstance,NULL);

		init_screen_locs();
		set_up_start_screen();

		file_initialize();
		check_colors();
		cursor_stay();
		update_item_menu();
		shut_down_menus(0);

		cd_init_dialogs();

 		}

		event_handled = FALSE;
		while(GetMessage(&msg,NULL,0,0)) {
			if (event_handled == FALSE) {
				if (!TranslateAccelerator(mainPtr, accel, &msg)) {
					TranslateMessage(&msg);
					DispatchMessage(&msg);
					}
				}
			}

		delete data_store;
		saveSettingsToFile();

		return msg.wParam;
}
示例#6
0
//==============================================================================
ApplicationSettingsComponent::ApplicationSettingsComponent ()
    : label (0),
      connectButton (0),
      label2 (0),
      serialSpeedComboBox (0),
      okButton (0),
      presetDirectoryEditor (0),
      label3 (0),
      cancelButton (0),
      label4 (0),
      midiInputComboBox (0),
      serialPortComboBox (0),
      label5 (0),
      midiOutputComboBox (0),
      label6 (0),
      oscHostEditor (0),
      label7 (0),
      oscPortEditor (0)
{
    addAndMakeVisible (label = new Label (L"new label",
                                          L"Serial Port"));
    label->setFont (Font (15.0000f, Font::plain));
    label->setJustificationType (Justification::centredLeft);
    label->setEditable (false, false, false);
    label->setColour (TextEditor::textColourId, Colours::black);
    label->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (connectButton = new TextButton (L"new button"));
    connectButton->setButtonText (L"connect");
    connectButton->addListener (this);

    addAndMakeVisible (label2 = new Label (L"new label",
                                           L"Serial Speed"));
    label2->setFont (Font (15.0000f, Font::plain));
    label2->setJustificationType (Justification::centredLeft);
    label2->setEditable (false, false, false);
    label2->setColour (TextEditor::textColourId, Colours::black);
    label2->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (serialSpeedComboBox = new ComboBox (L"new combo box"));
    serialSpeedComboBox->setEditableText (false);
    serialSpeedComboBox->setJustificationType (Justification::centredLeft);
    serialSpeedComboBox->setTextWhenNothingSelected (String::empty);
    serialSpeedComboBox->setTextWhenNoChoicesAvailable (L"(no choices)");
    serialSpeedComboBox->addItem (L"9600", 1);
    serialSpeedComboBox->addItem (L"19200", 2);
    serialSpeedComboBox->addItem (L"38400", 3);
    serialSpeedComboBox->addItem (L"57600", 4);
    serialSpeedComboBox->addItem (L"115200", 5);
    serialSpeedComboBox->addListener (this);

    addAndMakeVisible (okButton = new TextButton (L"new button"));
    okButton->setButtonText (L"ok");
    okButton->setConnectedEdges (Button::ConnectedOnRight);
    okButton->addListener (this);

    addAndMakeVisible (presetDirectoryEditor = new TextEditor (L"new text editor"));
    presetDirectoryEditor->setMultiLine (false);
    presetDirectoryEditor->setReturnKeyStartsNewLine (false);
    presetDirectoryEditor->setReadOnly (false);
    presetDirectoryEditor->setScrollbarsShown (true);
    presetDirectoryEditor->setCaretVisible (true);
    presetDirectoryEditor->setPopupMenuEnabled (true);
    presetDirectoryEditor->setText (String::empty);

    addAndMakeVisible (label3 = new Label (L"new label",
                                           L"Preset Directory"));
    label3->setFont (Font (15.0000f, Font::plain));
    label3->setJustificationType (Justification::centredLeft);
    label3->setEditable (false, false, false);
    label3->setColour (TextEditor::textColourId, Colours::black);
    label3->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (cancelButton = new TextButton (L"new button"));
    cancelButton->setButtonText (L"cancel");
    cancelButton->setConnectedEdges (Button::ConnectedOnLeft);
    cancelButton->addListener (this);

    addAndMakeVisible (label4 = new Label (L"new label",
                                           L"MIDI Input"));
    label4->setFont (Font (15.0000f, Font::plain));
    label4->setJustificationType (Justification::centredLeft);
    label4->setEditable (false, false, false);
    label4->setColour (TextEditor::textColourId, Colours::black);
    label4->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (midiInputComboBox = new ComboBox (L"new combo box"));
    midiInputComboBox->setEditableText (false);
    midiInputComboBox->setJustificationType (Justification::centredLeft);
    midiInputComboBox->setTextWhenNothingSelected (String::empty);
    midiInputComboBox->setTextWhenNoChoicesAvailable (L"(no choices)");
    midiInputComboBox->addListener (this);

    addAndMakeVisible (serialPortComboBox = new ComboBox (L"new combo box"));
    serialPortComboBox->setEditableText (true);
    serialPortComboBox->setJustificationType (Justification::centredLeft);
    serialPortComboBox->setTextWhenNothingSelected (String::empty);
    serialPortComboBox->setTextWhenNoChoicesAvailable (L"(no choices)");
    serialPortComboBox->addListener (this);

    addAndMakeVisible (label5 = new Label (L"new label",
                                           L"MIDI Output"));
    label5->setFont (Font (15.0000f, Font::plain));
    label5->setJustificationType (Justification::centredLeft);
    label5->setEditable (false, false, false);
    label5->setColour (TextEditor::textColourId, Colours::black);
    label5->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (midiOutputComboBox = new ComboBox (L"new combo box"));
    midiOutputComboBox->setEditableText (false);
    midiOutputComboBox->setJustificationType (Justification::centredLeft);
    midiOutputComboBox->setTextWhenNothingSelected (String::empty);
    midiOutputComboBox->setTextWhenNoChoicesAvailable (L"(no choices)");
    midiOutputComboBox->addListener (this);

    addAndMakeVisible (label6 = new Label (L"new label",
                                           L"OSC Host"));
    label6->setFont (Font (15.0000f, Font::plain));
    label6->setJustificationType (Justification::centredLeft);
    label6->setEditable (false, false, false);
    label6->setColour (TextEditor::textColourId, Colours::black);
    label6->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (oscHostEditor = new TextEditor (L"new text editor"));
    oscHostEditor->setMultiLine (false);
    oscHostEditor->setReturnKeyStartsNewLine (false);
    oscHostEditor->setReadOnly (false);
    oscHostEditor->setScrollbarsShown (true);
    oscHostEditor->setCaretVisible (true);
    oscHostEditor->setPopupMenuEnabled (true);
    oscHostEditor->setText (String::empty);

    addAndMakeVisible (label7 = new Label (L"new label",
                                           L"OSC Port"));
    label7->setFont (Font (15.0000f, Font::plain));
    label7->setJustificationType (Justification::centredLeft);
    label7->setEditable (false, false, false);
    label7->setColour (TextEditor::textColourId, Colours::black);
    label7->setColour (TextEditor::backgroundColourId, Colour (0x0));

    addAndMakeVisible (oscPortEditor = new TextEditor (L"new text editor"));
    oscPortEditor->setMultiLine (false);
    oscPortEditor->setReturnKeyStartsNewLine (false);
    oscPortEditor->setReadOnly (false);
    oscPortEditor->setScrollbarsShown (true);
    oscPortEditor->setCaretVisible (true);
    oscPortEditor->setPopupMenuEnabled (true);
    oscPortEditor->setText (String::empty);


    //[UserPreSize]
    //[/UserPreSize]

    setSize (600, 360);


    //[Constructor] You can add your own custom stuff here..

    loadSettingsFromFile();

    //[/Constructor]
}
示例#7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    preferencesDialog = new PreferencesDialog();
    fontDialog = new FontDialog();

    //----File----
    connect(ui->actionConvert_to_Handwritten, SIGNAL(triggered()),
            this, SLOT(renderFirstSheet()));
    connect(ui->actionLoad_Text_from_File, SIGNAL(triggered()),
            this, SLOT(loadTextFromFile()));
    connect(ui->actionLoad_Font, SIGNAL(triggered()),
            this, SLOT(loadFont()));
    connect(ui->actionFont_Editor, SIGNAL(triggered()),
            fontDialog, SLOT(exec()));
    connect(ui->actionSave_Current_Sheet_as, SIGNAL(triggered()),
            this, SLOT(saveSheet()));
    connect(ui->actionSave_All_Sheets, SIGNAL(triggered()),
            this, SLOT(saveAllSheets()));
    connect(ui->actionPrint_Current_Sheet, SIGNAL(triggered()),
            this, SLOT(printSheet()));
    connect(ui->actionPrint_All, SIGNAL(triggered()),
            this, SLOT(printAllSheets()));

    //----Edit----
    //connect menu action "Show Toolbar"
    connect(ui->actionShow_ToolBar, SIGNAL(triggered(bool)),
            ui->toolBar, SLOT(setVisible(bool)));
    connect(ui->toolBar, SIGNAL(visibilityChanged(bool)),
            ui->actionShow_ToolBar, SLOT(setChecked(bool)));

    //preferencesDialog connections
    connect(ui->actionPreferences, SIGNAL(triggered()),
            preferencesDialog, SLOT(exec()));
    connect(preferencesDialog, SIGNAL(settingsChanged()),
            ui->svgView, SLOT(loadSettingsFromFile()));

    //----Help----
    connect(ui->actionAbout_Scribbler, SIGNAL(triggered()),
            this, SLOT(showAboutBox()));
    connect(ui->actionLicenses_and_Credits, SIGNAL(triggered()),
            this, SLOT(showLicensesBox()));

    //----ToolBar----
    //add actions to tool bar and connect them to slots
    connect(ui->toolBar->addAction(QPixmap("://render.png"), tr("Convert to Handwritten")), SIGNAL(triggered(bool)),
            this, SLOT(renderFirstSheet()));
    connect(ui->toolBar->addAction(QPixmap("://printer.png"), tr("Print Current Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(printSheet()));
    connect(ui->toolBar->addAction(QPixmap("://save.png"), tr("Save Current Sheet as Image")), SIGNAL(triggered(bool)),
            this, SLOT(saveSheet()));

    ui->toolBar->addSeparator();

    connect(ui->toolBar->addAction(QPixmap("://right.png"), tr("Next Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(renderNextSheet()));
    connect(ui->toolBar->addAction(QPixmap("://left.png"), tr("Previous Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(renderPreviousSheet()));

    connect(fontDialog, SIGNAL(fontReady()),
            ui->svgView, SLOT(loadFont()));

    ui->toolBar->actions()[4]->setDisabled(true);
    ui->toolBar->actions()[5]->setDisabled(true);

    //initialize some class members
    sheetPointers.push_back(0);
    currentSheetNumber = 0;
    version = "0.4 alpha";

    preferencesDialog->loadSettingsFromFile();

    /* This is a hack to avoid a bug. When program starts, it needs some time
     * (at least 1 ms on my configuration, but I set delay to 100 ms just to be sure
     * that it will work on weaker machines) before it can write settings to file,
     * otherwise ui->colorButton->palette().background().color() will return
     * default buttons background color, which will be written to settings
     * file at once program launches.
     */

    QTime dieTime = QTime::currentTime().addMSecs(100);
    while (QTime::currentTime() < dieTime)
        QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

    preferencesDialog->loadSettingsToFile();
}