Example #1
0
int main()
{
    gboolean bRet;

    // initialize rwlock
    bRet = erRegRWLockInit();
    if (FALSE == bRet)
    {
        ERREG_ERRORPRINTF("error");
        return 0;
    }
    // get all settings
    getAllSettings();

    // set all settings
    bRet = setAllSettings();

    // test pc profiles
    testPCProfiles();
    
    // test network profiles
    testNetworkProfiles();

    // export device configuration
    exportConfig();

    // import device configuration
    importConfig();

    // test validation
    testValidation(); 
    
    // test minset
    testMinSet();
    
    // test time cosumption
    testTimeConsumption();

    // destroy rwlock
    erRegRWLockDestroy();

    return 0;
}
Example #2
0
QxPreferences::QxPreferences(Ref<CharcoalDirectory> charcoalDirectory, QWidget* parent)
	: QxDialog(parent),
	  charcoalDirectory_(charcoalDirectory),
	  themeManager_(charcoalDirectory->themeManager()),
	  paletteManager_(charcoalDirectory->paletteManager())
{
	setWindowTitle(qApp->applicationName() + " - Preferences");
	#ifdef Q_WS_MAC
	#ifndef QT_MAC_USE_COCOA
	setAttribute(Qt::WA_MacShowFocusRect, false);
	#endif // QT_MAC_USE_COCOA
	#endif // Q_WS_MAC
	
	QGridLayout* grid = new QGridLayout(this);
	{
		tabs_ = new QTabWidget(this);
		tabs_->setElideMode(Qt::ElideNone);
		tabs_->setUsesScrollButtons(false);
		grid->addWidget(tabs_, 0, 0);
		// grid->setMargin(12);
	}
	
	{
		editor_ = new QxEditorPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), editor_, tr("Editor"));
		
		editor_->fontSize_->setRange(8, 32);
		editor_->lineSpacing_->setRange(0, 32);
		editor_->tabWidth_->setRange(2, 32);
		editor_->indentWidth_->setRange(1, 32);
		
		connect(editor_->tabIndentMode_, SIGNAL(toggled(bool)), editor_->indentWidth_, SLOT(setDisabled(bool)));
		editor_->tabIndentMode_->setChecked(true);
		
		connect(editor_->font_, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(updateEditorFontOption(const QFont&)));
		connect(editor_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		connect(editor_->fontAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->subpixelAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		connect(editor_->showLineNumbers_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->showWhitespace_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(editor_->tabWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		
		connect(editor_->autoIndent_, SIGNAL(toggled(bool)), this, SIGNAL(editorAutoIndentChanged(bool)));
		connect(editor_->tabIndentMode_, SIGNAL(toggled(bool)), this, SLOT(updateEditorIndent(bool)));
		connect(editor_->indentWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIndent(int)));
	}
	
	{
		terminal_ = new QxTerminalPreferences;
		tabs_->insertTab(tabs_->count(), terminal_, tr("Terminal"));
		
		terminal_->fontSize_->setRange(8, 32);
		terminal_->lineSpacing_->setRange(0, 32);
		terminal_->numberOfLines_->setRange(100000, 1000000);
		terminal_->numberOfLines_->setSingleStep(100000);
		terminal_->title_->addItems(
			QString(
				"$TITLE,"
				"$FG,"
				"$USER@$HOST,"
				"$USER@$FQHOST,"
				"$USER@$HOST:$CWD,"
				"$FG [$USER@$HOST],"
				"$FG [$USER@$HOST]:$CWD"
			).split(",")
		);
		terminal_->title_->setCurrentIndex(5);
		
		connect(terminal_->font_, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(updateTerminalFontOption(const QFont&)));
		connect(terminal_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int)));
		connect(terminal_->fontAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool)));
		connect(terminal_->subpixelAntialiasing_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool)));
		connect(terminal_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int)));
		connect(terminal_->endlessLogging_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalEndlessLogging(bool)));
		connect(terminal_->numberOfLines_, SIGNAL(valueChanged(int)), this, SIGNAL(terminalNumberOfLinesChanged(int)));
		connect(terminal_->endlessLogging_, SIGNAL(toggled(bool)), terminal_->numberOfLines_, SLOT(setDisabled(bool)));
		connect(terminal_->title_, SIGNAL(activated(const QString&)), this, SIGNAL(terminalTitleChanged(const QString&)));
		
		QStringList paletteNames;
		for (int i = 0, n = paletteManager_->numPalette(); i < n; ++i) {
			Ref<Palette> palette = paletteManager_->paletteByIndex(i);
			if (palette->numColors() >= QxVideoTerminal::NumColors) {
				paletteNames << paletteManager_->paletteByIndex(i)->displayName();
				paletteIndices_.append(i);
			}
		}
		
		QStringListModel* model = new QStringListModel(paletteNames, terminal_->palette_);
		terminal_->palette_->setModel(model);
		
		connect(terminal_->palette_, SIGNAL(activated(int)), this, SLOT(terminalPaletteActivated(int)));
	}
	
	{
		printing_ = new QxPrintingPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), printing_, tr("Printing"));
		
		printing_->fontSize_->setRange(8, 32);
		printing_->lineSpacing_->setRange(0, 32);
	}
	
	/*
	{
		// performance HACK to reduce application launch time
		editor_->font_->setDisabled(true);
		terminal_->font_->setDisabled(true);
		printing_->font_->setDisabled(true);
		#ifdef Q_WS_MAC
		// visual HACK
		editor_->font_->setFixedWidth(editor_->font_->sizeHint().width());
		#endif
		#if 0
		editor_->font_->setMinimumContentsLength(20);
		editor_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
		terminal_->font_->setMinimumContentsLength(20);
		terminal_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
		printing_->font_->setMinimumContentsLength(20);
		printing_->font_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
		#endif
		QTimer::singleShot(0, this, SLOT(startFontFilter()));
	}
	*/
	
	{
		themesView_ = new QListView(tabs_);
		themesView_->setViewMode(QListView::IconMode);
		themesView_->setMovement(QListView::Static);
		themesView_->setResizeMode(QListView::Adjust);
		themesView_->setFlow(QListView::LeftToRight);
		// themesView_->setSpacing(10);
		
		tabs_->insertTab(tabs_->count(), themesView_, tr("Theme"));
		
		themesView_->setModel(new QxThemesModel(charcoalDirectory_, themesView_));
		
		connect(
			themesView_->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)),
			this, SLOT(themeActivate(const QModelIndex&, const QModelIndex&))
		);
	}
	
	{
		commands_ = new QxCommandsPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), commands_, tr("Commands"));
		
		connect(commands_->add_, SIGNAL(clicked()), this, SLOT(addCommand()));
		connect(commands_->edit_, SIGNAL(clicked()), this, SLOT(editCommand()));
		connect(commands_->del_, SIGNAL(clicked()), this, SLOT(delCommand()));
		connect(commands_->import_, SIGNAL(clicked()), this, SLOT(importConfig()));
		connect(commands_->export_, SIGNAL(clicked()), this, SLOT(exportConfig()));
		
		commandsList_ = new QxCommandsList;
		commandsModel_ = new QxCommandsModel(commandsList_);
		commands_->view_->setModel(commandsModel_);
		commands_->view_->setHeaderHidden(false);
	}
	
	{
		codetips_ = new QxCodetipsPreferences(this, tabs_);
		tabs_->insertTab(tabs_->count(), codetips_, tr("Code Tips"));
	}
	
	{
		misc_ = new QxMiscPreferences(tabs_);
		tabs_->insertTab(tabs_->count(), misc_, tr("Misc"));
		misc_->scrollingSpeed_->setRange(1, 6);
		misc_->scrollingSpeed_->setValue(3);
		
		misc_->kinematicScrolling_->setChecked(true);
		misc_->scrollingSpeed_->setEnabled(false);
		connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), misc_->scrollingSpeed_, SLOT(setDisabled(bool)));
		
		connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), this, SLOT(updateEditorBoolOption(bool)));
		connect(misc_->kinematicScrolling_, SIGNAL(toggled(bool)), this, SLOT(updateTerminalBoolOption(bool)));
		connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(updateEditorIntOption(int)));
		connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(updateTerminalIntOption(int)));
		connect(misc_->scrollingSpeed_, SIGNAL(valueChanged(int)), this, SLOT(setWheelScrollLines(int)));
	}
	
	/*{
		config_ = new QxImportExportPreferences(tabs_);
		tabs_->insertTab(5, config_, tr("Import/Export"));
		
		config_->commands_->setChecked(true);
		connect(config_->import_, SIGNAL(pressed()), this, SLOT(importConfig()));
		connect(config_->export_, SIGNAL(pressed()), this, SLOT(exportConfig()));
	}*/
	
	QFontComboBox::FontFilters filters = QFontComboBox::MonospacedFonts|QFontComboBox::ScalableFonts;
	editor_->font_->setFontFilters(filters);
	terminal_->font_->setFontFilters(filters);
	printing_->font_->setFontFilters(filters);
	
	#ifndef QT_MAC_USE_COCOA
	resize(524, 390); // visual HACK
	#else
	resize(599, 421); // visual HACK
	#endif
}