예제 #1
0
void MapController::autoRegistration()
{
    // Buttons registration

    // Move button
    registerController(
        this,
        &MapController::moveMap,
        "qrc:///Images/Move_map_white.svg",
        true,
        false,
        stMove
    );

    // Rotate button
    registerController(
        this,
        &MapController::rotateMap,
        "qrc:///Images/rotate_white.svg",
        true,
        false,
        stRotate
    );

    // Scale plus button
    registerController(
        this,
        &MapController::zoomIn,
        "qrc:///Images/plus_white.svg",
        false,
        true
    );

    // Scale minus button
    registerController(
        this,
        &MapController::zoomOut,
        "qrc:///Images/minus_white.svg",
        false,
        true
    );

    // Panels registration
    registerPanel("qrc:/qml/MapFade.qml", QString::fromUtf8("Панель инструментов"));
    registerPanel("qrc:/qml/MapFade2.qml", QString::fromUtf8("Прочее..."));

    // Settings registration
    registerSetting("qrc:/qml/MapFade.qml", QString::fromUtf8("Карта"));
    registerSetting("qrc:/qml/MapFade2.qml", QString::fromUtf8("Интрументы"));
}
예제 #2
0
InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst, const QString &instDir)
{
	auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
	
	m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
	
	QString inst_type = m_settings->get("InstanceType").toString();
	
	//FIXME: replace with a map lookup, where instance classes register their types
	if(inst_type == "Legacy")
	{
		inst = new LegacyInstance(instDir, m_settings, this);
	}
	else if(inst_type == "OneSix")
	{
		inst = new OneSixInstance(instDir, m_settings, this);
	}
	else if(inst_type == "Nostalgia")
	{
		inst = new NostalgiaInstance(instDir, m_settings, this);
	}
	else
	{
		return InstanceFactory::UnknownLoadError;
	}
	return NoLoadError;
}
예제 #3
0
InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &inst, BaseVersionPtr version,
								const QString &instDir, const InstanceFactory::InstType type)
{
	QDir rootDir(instDir);

	QLOG_DEBUG() << instDir.toUtf8();
	if (!rootDir.exists() && !rootDir.mkpath("."))
	{
		return InstanceFactory::CantCreateDir;
	}
	auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
	if (!mcVer)
		return InstanceFactory::NoSuchVersion;

	auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
	m_settings->registerSetting("InstanceType", "Legacy");

	if (type == NormalInst)
	{
		m_settings->set("InstanceType", "OneSix");
		inst.reset(new OneSixInstance(instDir, m_settings, this));
		inst->setIntendedVersionId(version->descriptor());
		inst->setShouldUseCustomBaseJar(false);
	}
	else if (type == FTBInstance)
	{
		if(mcVer->usesLegacyLauncher())
		{
			m_settings->set("InstanceType", "LegacyFTB");
			inst.reset(new LegacyFTBInstance(instDir, m_settings, this));
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
		}
		else
		{
			m_settings->set("InstanceType", "OneSixFTB");
			inst.reset(new OneSixFTBInstance(instDir, m_settings, this));
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
		}
	}
	else
	{
		delete m_settings;
		return InstanceFactory::NoSuchVersion;
	}

	inst->init();

	// FIXME: really, how do you even know?
	return InstanceFactory::NoCreateError;
}
예제 #4
0
PseudoPluginInterface::PseudoPluginInterface() :
    _closeMainScreenOption(tr("core"), tr("close-main-screen-result"), ConfirmQuit,
                           metaObject()->className(), "Close main screen result", "The result of closing the main screen", this),
    _autoLoadPlugins(tr("core"), tr("autoload-plugins"), true,
                     metaObject()->className(), "Autoload plugins", "Automatically load all plugins that can be found", this)
{

    qRegisterMetaTypeStreamOperators<Ology::Core::PseudoPluginInterface::CloseMainScreenOption>("Ology::Core::PseudoPluginInterface::CloseMainScreenOption");

    registerSetting(&_closeMainScreenOption);
    registerSetting(&_autoLoadPlugins);

#define ADD_ACTION(class, shortcut) { \
        class *action = new class(this); \
        action->setShortcut(shortcut); \
        _actions << action; \
    }

    ADD_ACTION(Core::QuitAction, QKeySequence("Ctrl+Q"));
    ADD_ACTION(Core::CloseScreenAction, Qt::Key_Escape);
    ADD_ACTION(Core::MoreScreenAction, Qt::Key_F1);

    ADD_ACTION(Core::PageUpAction, QKeySequence()); //Qt::Key_PageUp);
    ADD_ACTION(Core::PageDownAction, QKeySequence()); //Qt::Key_PageDown);
    ADD_ACTION(Core::UpAction, QKeySequence()); //Qt::Key_Up);
    ADD_ACTION(Core::DownAction, QKeySequence()); //Qt::Key_Down);
    ADD_ACTION(Core::LeftAction, QKeySequence()); //Qt::Key_Left);
    ADD_ACTION(Core::RightAction, QKeySequence()); //Qt::Key_Right);
    ADD_ACTION(Core::FirstAction, QKeySequence()); //Qt::Key_Home);
    ADD_ACTION(Core::LastAction, QKeySequence()); //Qt::Key_End);

    ADD_ACTION(Core::PlayAction, QKeySequence());
    ADD_ACTION(Core::StopAction, QKeySequence());
    ADD_ACTION(Core::NextAction, Qt::CTRL + Qt::Key_Right);
    ADD_ACTION(Core::PrevAction, Qt::CTRL + Qt::Key_Left);
    ADD_ACTION(Core::PlayOrPauseAction, QKeySequence("Ctrl+P"));
    ADD_ACTION(Core::PauseOrUnpauseAction, QKeySequence());
}
예제 #5
0
InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*& inst, BaseVersionPtr version, const QString& instDir )
{
	QDir rootDir(instDir);
	
	QLOG_DEBUG() << instDir.toUtf8();
	if (!rootDir.exists() && !rootDir.mkpath("."))
	{
		return InstanceFactory::CantCreateDir;
	}
	auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
	if(!mcVer)
		return InstanceFactory::NoSuchVersion;
	
	auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
	m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
	
	switch(mcVer->type)
	{
		case MinecraftVersion::Legacy:
			m_settings->set("InstanceType", "Legacy");
			inst = new LegacyInstance(instDir, m_settings, this);
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
			break;
		case MinecraftVersion::OneSix:
			m_settings->set("InstanceType", "OneSix");
			inst = new OneSixInstance(instDir, m_settings, this);
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
			break;
		case MinecraftVersion::Nostalgia:
			m_settings->set("InstanceType", "Nostalgia");
			inst = new NostalgiaInstance(instDir, m_settings, this);
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
			break;
		default:
		{
			delete m_settings;
			return InstanceFactory::NoSuchVersion;
		}
	}
	
	//FIXME: really, how do you even know?
	return InstanceFactory::NoCreateError;
}
예제 #6
0
Settings::Settings()
 : QObject()
{
	const float touch_button_minimum_size_default = 11;
	float symbol_widget_icon_size_mm_default;
	float map_editor_click_tolerance_default;
	float map_editor_snap_distance_default;
	int start_drag_distance_default;
	
	// Platform-specific settings defaults
	#if defined(ANDROID)
		symbol_widget_icon_size_mm_default = touch_button_minimum_size_default;
		map_editor_click_tolerance_default = 4.0f;
		map_editor_snap_distance_default = 15.0f;
		start_drag_distance_default = Util::mmToPixelLogical(3.0f);
	#else
		symbol_widget_icon_size_mm_default = 8;
		map_editor_click_tolerance_default = 3.0f;
		map_editor_snap_distance_default = 10.0f;
		start_drag_distance_default = QApplication::startDragDistance();
	#endif
	
	qreal ppi = QApplication::primaryScreen()->physicalDotsPerInch();
	// Beware of https://bugreports.qt-project.org/browse/QTBUG-35701
	if (ppi > 2048.0 || ppi < 16.0)
		ppi = QApplication::primaryScreen()->logicalDotsPerInch();
	
	registerSetting(MapDisplay_TextAntialiasing, "MapDisplay/text_antialiasing", false);
	registerSetting(MapEditor_ClickToleranceMM, "MapEditor/click_tolerance_mm", map_editor_click_tolerance_default);
	registerSetting(MapEditor_SnapDistanceMM, "MapEditor/snap_distance_mm", map_editor_snap_distance_default);
	registerSetting(MapEditor_FixedAngleStepping, "MapEditor/fixed_angle_stepping", 15);
	registerSetting(MapEditor_ChangeSymbolWhenSelecting, "MapEditor/change_symbol_when_selecting", true);
	registerSetting(MapEditor_ZoomOutAwayFromCursor, "MapEditor/zoom_out_away_from_cursor", true);
	registerSetting(MapEditor_DrawLastPointOnRightClick, "MapEditor/draw_last_point_on_right_click", true);
	
	registerSetting(EditTool_DeleteBezierPointAction, "EditTool/delete_bezier_point_action", (int)DeleteBezierPoint_RetainExistingShape);
	registerSetting(EditTool_DeleteBezierPointActionAlternative, "EditTool/delete_bezier_point_action_alternative", (int)DeleteBezierPoint_ResetHandles);
	
	registerSetting(RectangleTool_HelperCrossRadiusMM, "RectangleTool/helper_cross_radius_mm", 100.0f);
	registerSetting(RectangleTool_PreviewLineWidth, "RectangleTool/preview_line_with", true);
	
	registerSetting(Templates_KeepSettingsOfClosed, "Templates/keep_settings_of_closed_templates", true);
	
	registerSetting(ActionGridBar_ButtonSizeMM, "ActionGridBar/button_size_mm", touch_button_minimum_size_default);
	registerSetting(SymbolWidget_IconSizeMM, "SymbolWidget/icon_size_mm", symbol_widget_icon_size_mm_default);
	
	registerSetting(General_RetainCompatiblity, "retainCompatiblity", true);
	registerSetting(General_AutosaveInterval, "autosave", 15); // unit: minutes
	registerSetting(General_Language, "language", QVariant((int)QLocale::system().language()));
	registerSetting(General_PixelsPerInch, "pixelsPerInch", ppi);
	registerSetting(General_TranslationFile, "translationFile", QVariant(QString::null));
	registerSetting(General_RecentFilesList, "recentFileList", QVariant(QStringList()));
	registerSetting(General_OpenMRUFile, "openMRUFile", false);
	registerSetting(General_Local8BitEncoding, "local_8bit_encoding", "Windows-1252");
	registerSetting(General_NewOcd8Implementation, "new_ocd8_implementation", true);
	registerSetting(General_StartDragDistance, "startDragDistance", start_drag_distance_default);
	
	registerSetting(HomeScreen_TipsVisible, "HomeScreen/tipsVisible", true);
	registerSetting(HomeScreen_CurrentTip, "HomeScreen/currentTip", -1);
	
	// Set antialiasing default depending on screen pixels per inch
	registerSetting(MapDisplay_Antialiasing, "MapDisplay/antialiasing", Util::isAntialiasingRequired(getSetting(General_PixelsPerInch).toReal()));
	
	// Migrate old settings
	static bool migration_checked = false;
	if (!migration_checked)
	{
		QVariant current_version { "0.5.9" };
		QSettings settings;
		if (settings.value("version") != current_version)
		{
			migrateSettings(settings, current_version);
		}
		
		if (!settings.value("new_ocd8_implementation_v0.6").isNull())
		{
			// Remove/reset to default
			settings.remove("new_ocd8_implementation_v0.6");
			settings.remove("new_ocd8_implementation");
		}
		
		migration_checked = true;
	}
}
예제 #7
0
파일: main.c 프로젝트: amcorreia/squidGuard
static void registerSettings()
{
	registerSetting("dbhome", DEFAULT_DBHOME, NULL);

	registerSetting("logdir", DEFAULT_LOGDIR, NULL);
	registerSetting("debug", optDebug, setDebugFlag);
	registerSetting("syslog", optSyslog, setSyslogFlag);

	/* from sgGroup.c */
	registerSetting("groupttl", "600", setGroupCacheTTL);

	/* from sgRequest.c */
	registerSetting("reverselookup", "false", setReverseLookup);
	registerSetting("strip-realm", "false", setStripRealm);
	registerSetting("realm", NULL, setRealmToStrip);

	/* from sgLDAP.c */
	registerSetting("ldapprotover", NULL, NULL);
	registerSetting("ldapbinddn", NULL, NULL);
	registerSetting("ldapbindpass", NULL, NULL);
}