Fix (hopefully) library dependency resolution.
Installing libs is now enabled, hardcoded. Enable -Wall for all builds. Fix many warnings and latent bugs.
This commit is contained in:
		
							
								
								
									
										194
									
								
								CMakeLists.txt
									
									
									
									
									
								
							
							
						
						
									
										194
									
								
								CMakeLists.txt
									
									
									
									
									
								
							| @@ -27,14 +27,14 @@ ENDIF() | ||||
| ######## Set compiler flags ######## | ||||
| IF(APPLE) | ||||
| 	message(STATUS "Using APPLE CMAKE_CXX_FLAGS") | ||||
| 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||||
| 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") | ||||
| ELSEIF(UNIX) | ||||
| 	# assume GCC, add C++0x/C++11 stuff | ||||
| 	MESSAGE(STATUS "Using UNIX CMAKE_CXX_FLAGS") | ||||
| 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||||
| 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") | ||||
| ELSEIF(MINGW) | ||||
| 	MESSAGE(STATUS "Using MINGW CMAKE_CXX_FLAGS") | ||||
| 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") | ||||
| 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall") | ||||
| ENDIF() | ||||
|  | ||||
| ################################ INCLUDE LIBRARIES ################################ | ||||
| @@ -48,6 +48,23 @@ find_package(Qt5LinguistTools REQUIRED) | ||||
|  | ||||
| include_directories(${Qt5Widgets_INCLUDE_DIRS}) | ||||
|  | ||||
| # The Qt5 cmake files don't provide its install paths, so ask qmake. | ||||
| get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) | ||||
| function(QUERY_QMAKE VAR RESULT) | ||||
| 	exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output ) | ||||
| 	if(NOT return_code) | ||||
| 		file(TO_CMAKE_PATH "${output}" output) | ||||
| 		set(${RESULT} ${output} PARENT_SCOPE) | ||||
| 	endif(NOT return_code) | ||||
| endfunction(QUERY_QMAKE) | ||||
|  | ||||
| query_qmake(QT_INSTALL_PLUGINS QT_PLUGINS_DIR) | ||||
| query_qmake(QT_INSTALL_IMPORTS QT_IMPORTS_DIR) | ||||
| query_qmake(QT_INSTALL_LIBS QT_LIBS_DIR) | ||||
| query_qmake(QT_HOST_DATA QT_DATA_DIR) | ||||
| set(QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs) | ||||
|  | ||||
|  | ||||
| ######## Included Libs ######## | ||||
|  | ||||
| # Add quazip | ||||
| @@ -429,7 +446,6 @@ CONFIGURE_FILE(generated.qrc.in generated.qrc) | ||||
| QT5_ADD_RESOURCES(GENERATED_QRC ${CMAKE_CURRENT_BINARY_DIR}/generated.qrc) | ||||
| QT5_ADD_RESOURCES(GRAPHICS_QRC graphics.qrc) | ||||
|  | ||||
|  | ||||
| # Add executable | ||||
| ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 | ||||
| 	${MULTIMC_SOURCES} ${MULTIMC_UI} ${GRAPHICS_QRC} ${GENERATED_QRC} ${MULTIMC_RCS}) | ||||
| @@ -439,110 +455,102 @@ TARGET_LINK_LIBRARIES(MultiMC xz-embedded unpack200 quazip libUtil libSettings l | ||||
| QT5_USE_MODULES(MultiMC Core Widgets Network Xml ${MultiMC_QT_ADDITIONAL_MODULES}) | ||||
| ADD_DEPENDENCIES(MultiMC MultiMCLauncher JavaCheck) | ||||
|  | ||||
| option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF) | ||||
| IF(BUILD_KEYRING_TEST) | ||||
| 	# test.cpp | ||||
| 	ADD_EXECUTABLE(Test test.cpp) | ||||
| 	QT5_USE_MODULES(Test Core) | ||||
| 	TARGET_LINK_LIBRARIES(Test libUtil libSettings) | ||||
| ENDIF() | ||||
|  | ||||
| ################################ INSTALLATION AND PACKAGING ################################ | ||||
| # use QtCreator's QTDIR var | ||||
| IF(DEFINED ENV{QTDIR}) | ||||
| 	SET(Qt5_DIR $ENV{QTDIR}) | ||||
| ENDIF() | ||||
|  | ||||
| ######## Plugin and library folders ######## | ||||
| ######## Packaging/install paths setup ######## | ||||
|  | ||||
| SET(PLUGIN_DEST_DIR plugins) | ||||
| SET(QTCONF_DEST_DIR .) | ||||
| SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC") | ||||
| IF(UNIX AND APPLE) | ||||
| 	SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS) | ||||
| 	SET(QTCONF_DEST_DIR MultiMC.app/Contents/Resources) | ||||
| 	SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app") | ||||
|  | ||||
| IF(WIN32) | ||||
| 	SET(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC") | ||||
| 	SET(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.") | ||||
| 	SET(MACOSX_BUNDLE_BUNDLE_VERSION "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}") | ||||
| 	#SET(MACOSX_BUNDLE_GUI_IDENTIFIER "") | ||||
| 	SET(MACOSX_BUNDLE_ICON_FILE MultiMC.icns) | ||||
| ELSEIF(UNIX) | ||||
| 	SET(PLUGIN_DEST_DIR plugins) | ||||
| 	SET(QTCONF_DEST_DIR .) | ||||
| 	SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") | ||||
| ELSEIF(WIN32) | ||||
| 	SET(PLUGIN_DEST_DIR .) | ||||
| 	SET(QTCONF_DEST_DIR .) | ||||
| 	SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe") | ||||
| ENDIF() | ||||
|  | ||||
| IF(UNIX) | ||||
| IF(APPLE) | ||||
| 	SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS) | ||||
| 	SET(QTCONF_DEST_DIR MultiMC.app/Contents/Resources) | ||||
| 		SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app") | ||||
| ELSE() | ||||
| 	SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC") | ||||
| ENDIF() | ||||
| ENDIF() | ||||
|  | ||||
| SET(QT_PLUGINS_DIR ${Qt5_DIR}/plugins) | ||||
| SET(QT_LIBRARY_DIRS ${Qt5_DIR}/lib) | ||||
|  | ||||
|  | ||||
| ######## OS X Bundle Info ######## | ||||
|  | ||||
| IF(APPLE) | ||||
| 	SET(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC") | ||||
| 	SET(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.") | ||||
| 	SET(MACOSX_BUNDLE_BUNDLE_VERSION  | ||||
| 		"${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}") | ||||
| 	#SET(MACOSX_BUNDLE_GUI_IDENTIFIER "") | ||||
| 	SET(MACOSX_BUNDLE_ICON_FILE MultiMC.icns) | ||||
| ENDIF(APPLE) | ||||
| # directories to look for dependencies | ||||
| SET(DIRS "${QT_LIBS_DIR}") | ||||
|  | ||||
| ######## Install ######## | ||||
|  | ||||
| #### Executable #### | ||||
| IF(WIN32) | ||||
| INSTALL(TARGETS MultiMC  | ||||
| 	BUNDLE DESTINATION . COMPONENT Runtime | ||||
| 	LIBRARY DESTINATION . COMPONENT Runtime | ||||
| 	RUNTIME DESTINATION . COMPONENT Runtime | ||||
| IF(APPLE AND UNIX) ## OSX | ||||
| 	INSTALL(TARGETS MultiMC  | ||||
| 		BUNDLE DESTINATION . COMPONENT Runtime | ||||
| 		RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime | ||||
| 	) | ||||
|  | ||||
| ELSEIF(UNIX) ## LINUX and similar | ||||
| 	INSTALL(TARGETS MultiMC  | ||||
| 		BUNDLE DESTINATION . COMPONENT Runtime | ||||
| 		RUNTIME DESTINATION bin COMPONENT Runtime | ||||
| 	) | ||||
| 	INSTALL(PROGRAMS package/linux/MultiMC DESTINATION .) | ||||
|  | ||||
| ELSEIF(WIN32) ## WINDOWS | ||||
| 	INSTALL(TARGETS MultiMC  | ||||
| 		BUNDLE DESTINATION . COMPONENT Runtime | ||||
| 		LIBRARY DESTINATION . COMPONENT Runtime | ||||
| 		RUNTIME DESTINATION . COMPONENT Runtime | ||||
| 	) | ||||
| ENDIF() | ||||
|  | ||||
| #### Dist package logic #### | ||||
|  | ||||
| # Image formats | ||||
| INSTALL( | ||||
| 	DIRECTORY "${QT_PLUGINS_DIR}/imageformats" | ||||
| 	DESTINATION ${PLUGIN_DEST_DIR} | ||||
| 	COMPONENT Runtime | ||||
| 	REGEX "tga|svg|tiff|mng" EXCLUDE | ||||
| 	REGEX "d\\." EXCLUDE | ||||
| ) | ||||
| ENDIF() | ||||
| IF(UNIX) | ||||
| IF(APPLE) | ||||
| INSTALL(TARGETS MultiMC  | ||||
| 	BUNDLE DESTINATION . COMPONENT Runtime | ||||
| 	RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime | ||||
|  | ||||
| # Platform plugins | ||||
| INSTALL( | ||||
| 	DIRECTORY "${QT_PLUGINS_DIR}/platforms" | ||||
| 	DESTINATION ${PLUGIN_DEST_DIR} | ||||
| 	COMPONENT Runtime | ||||
| 	REGEX "minimal|linuxfb|offscreen" EXCLUDE | ||||
| 	REGEX "d\\." EXCLUDE | ||||
| ) | ||||
| ELSE() | ||||
| INSTALL(TARGETS MultiMC  | ||||
| 	BUNDLE DESTINATION . COMPONENT Runtime | ||||
| 	RUNTIME DESTINATION bin COMPONENT Runtime | ||||
|  | ||||
| # qtconf | ||||
| INSTALL( | ||||
| 	CODE " | ||||
| FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\") | ||||
| " | ||||
| 	COMPONENT Runtime | ||||
| ) | ||||
| INSTALL(PROGRAMS package/linux/MultiMC DESTINATION .) | ||||
| ENDIF() | ||||
| ENDIF() | ||||
|  | ||||
|  | ||||
| #### Plugins #### | ||||
| INSTALL( | ||||
| 	CODE " | ||||
| FILE(GLOB_RECURSE	QTPLUGINS \"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") | ||||
| function(gp_resolved_file_type_override resolved_file type_var) | ||||
| 	if(resolved_file MATCHES \"^/usr/lib/libQt\") | ||||
| 		message(\"resolving \${resolved_file} as system\") | ||||
| 		set(\${type_var} other PARENT_SCOPE) | ||||
|     endif() | ||||
| endfunction() | ||||
|  | ||||
| OPTION(MultiMC_INSTALL_SHARED_LIBS "if set, Qt's shared libraries will be copied to the installation directory on install") | ||||
| include(BundleUtilities) | ||||
| fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") | ||||
| " | ||||
| 	COMPONENT Runtime | ||||
| ) | ||||
|  | ||||
| IF (MultiMC_INSTALL_SHARED_LIBS) | ||||
| 	# Image formats | ||||
| 	INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime) | ||||
|  | ||||
| 	# Platform plugins | ||||
| 	INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/platforms" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime) | ||||
|  | ||||
| 	# qtconf | ||||
| 	INSTALL(CODE " | ||||
| 		FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\") | ||||
| 		" COMPONENT Runtime) | ||||
|  | ||||
|  | ||||
| 	# Dirs to look for dependencies. | ||||
| 	SET(DIRS "${QT_LIBRARY_DIRS}") | ||||
|  | ||||
| 	INSTALL(CODE " | ||||
| 		file(GLOB_RECURSE QTPLUGINS | ||||
|                         \"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") | ||||
| 		include(BundleUtilities) | ||||
| 		fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") | ||||
| 		" COMPONENT Runtime) | ||||
| ENDIF() | ||||
|  | ||||
|  | ||||
| ######## Package ######## | ||||
| @@ -586,11 +594,11 @@ include_directories(${PROJECT_BINARY_DIR}/include) | ||||
| file (GLOB TRANSLATIONS_FILES translations/*.ts) | ||||
|  | ||||
| option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files (WARNING: make clean will delete the source .ts files! Danger!)") | ||||
| if (UPDATE_TRANSLATIONS) | ||||
|   qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES}) | ||||
| else (UPDATE_TRANSLATIONS) | ||||
|   qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES}) | ||||
| endif (UPDATE_TRANSLATIONS)  | ||||
| IF(UPDATE_TRANSLATIONS) | ||||
| 	qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES}) | ||||
| ELSE() | ||||
| 	qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES}) | ||||
| ENDIF() | ||||
|  | ||||
| add_custom_target (translations DEPENDS ${QM_FILES}) | ||||
|  | ||||
|   | ||||
| @@ -190,6 +190,9 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) | ||||
| 		case QNetworkProxy::FtpCachingProxy: | ||||
| 			proxyDesc = "FTP caching: "; | ||||
| 			break; | ||||
| 		default: | ||||
| 			proxyDesc = "DERP proxy: "; | ||||
| 			break; | ||||
| 		} | ||||
| 		proxyDesc += QString("%3@%1:%2 pass %4") | ||||
| 						 .arg(proxy.hostName()) | ||||
|   | ||||
| @@ -58,18 +58,6 @@ struct KCategorizedView::Private::Item | ||||
|  | ||||
| struct KCategorizedView::Private::Block | ||||
| { | ||||
| 	Block() | ||||
| 		: topLeft ( QPoint() ) | ||||
| 		, height ( -1 ) | ||||
| 		, firstIndex ( QModelIndex() ) | ||||
| 		, quarantineStart ( QModelIndex() ) | ||||
| 		, items ( QList<Item>() ) | ||||
| 		, outOfQuarantine ( false ) | ||||
| 		, alternate ( false ) | ||||
| 		, collapsed ( false ) | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	bool operator!= ( const Block &rhs ) const | ||||
| 	{ | ||||
| 		return firstIndex != rhs.firstIndex; | ||||
| @@ -83,7 +71,7 @@ struct KCategorizedView::Private::Block | ||||
| 	} | ||||
|  | ||||
| 	QPoint topLeft; | ||||
| 	int height; | ||||
| 	int height = -1; | ||||
| 	QPersistentModelIndex firstIndex; | ||||
| 	// if we have n elements on this block, and we inserted an element at position i. The quarantine | ||||
| 	// will start at index (i, column, parent). This means that for all elements j where i <= j <= n, the | ||||
| @@ -97,25 +85,16 @@ struct KCategorizedView::Private::Block | ||||
| 	// this affects the whole block, not items separately. items contain the topLeft point relative | ||||
| 	// to the block. Because of insertions or removals a whole block can be moved, so the whole block | ||||
| 	// will enter in quarantine, what is faster than moving all items in absolute terms. | ||||
| 	bool outOfQuarantine; | ||||
| 	bool outOfQuarantine = false; | ||||
|  | ||||
| 	// should we alternate its color ? is just a hint, could not be used | ||||
| 	bool alternate; | ||||
| 	bool collapsed; | ||||
| 	bool alternate = false; | ||||
| 	bool collapsed = false; | ||||
| }; | ||||
|  | ||||
| KCategorizedView::Private::Private ( KCategorizedView *q ) | ||||
| 	: q ( q ) | ||||
| 	, proxyModel ( 0 ) | ||||
| 	, categoryDrawer ( 0 ) | ||||
| 	, categorySpacing ( 5 ) | ||||
| 	, alternatingBlockColors ( false ) | ||||
| 	, collapsibleBlocks ( false ) | ||||
| 	, hoveredBlock ( new Block() ) | ||||
| 	, hoveredIndex ( QModelIndex() ) | ||||
| 	, pressedPosition ( QPoint() ) | ||||
| 	, rubberBandRect ( QRect() ) | ||||
| 	, constantItemWidth( 0 ) | ||||
| { | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -137,14 +137,15 @@ public: | ||||
| 	  */ | ||||
| 	void _k_slotCollapseOrExpandClicked(QModelIndex); | ||||
|  | ||||
| 	KCategorizedView *q; | ||||
| 	KCategorizedSortFilterProxyModel *proxyModel; | ||||
| 	KCategoryDrawer *categoryDrawer; | ||||
| 	int categorySpacing; | ||||
| 	bool alternatingBlockColors; | ||||
| 	bool collapsibleBlocks; | ||||
| 	bool constantItemWidth; | ||||
| 	KCategorizedView *q = nullptr; | ||||
| 	KCategorizedSortFilterProxyModel *proxyModel = nullptr; | ||||
| 	KCategoryDrawer *categoryDrawer = nullptr; | ||||
| 	int categorySpacing = 5; | ||||
| 	bool alternatingBlockColors = false; | ||||
| 	bool collapsibleBlocks = false; | ||||
| 	bool constantItemWidth = false; | ||||
|  | ||||
| 	// FIXME: this is some really weird logic. Investigate. | ||||
| 	Block *hoveredBlock; | ||||
| 	QString hoveredCategory; | ||||
| 	QModelIndex hoveredIndex; | ||||
|   | ||||
| @@ -42,9 +42,9 @@ public: | ||||
|     ~Private() | ||||
|     { | ||||
|     } | ||||
|     KCategorizedView *view; | ||||
|     int leftMargin; | ||||
|     int rightMargin; | ||||
|     KCategorizedView *view; | ||||
| }; | ||||
|  | ||||
| KCategoryDrawer::KCategoryDrawer(KCategorizedView *view) | ||||
|   | ||||
| @@ -79,7 +79,6 @@ void band::readData(int expectedLength) | ||||
|  | ||||
| 	// Read one value to see what it might be. | ||||
| 	int XB = _meta_default; | ||||
| 	int cp1 = 0, cp2 = 0; | ||||
| 	if (!is_BYTE1) | ||||
| 	{ | ||||
| 		// must be a variable-length coding | ||||
| @@ -109,7 +108,6 @@ void band::readData(int expectedLength) | ||||
| 		{ | ||||
| 			// Skip over the escape value. | ||||
| 			u->rp = xvs.rp; | ||||
| 			cp1 = 1; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
|   | ||||
| @@ -87,7 +87,7 @@ struct bytes | ||||
| 		bytes res; | ||||
| 		res.ptr = ptr + beg; | ||||
| 		res.len = end - beg; | ||||
| 		assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit() - 1)); | ||||
| 		assert(res.len == 0 ||(inBounds(res.ptr) && inBounds(res.limit() - 1))); | ||||
| 		return res; | ||||
| 	} | ||||
| 	// building C strings inside byte buffers: | ||||
|   | ||||
| @@ -121,7 +121,6 @@ coding *coding::init() | ||||
| 		this->min = this->umin = 0; | ||||
| 		if (S != 0 && range != 0) | ||||
| 		{ | ||||
| 			int Smask = (1 << S) - 1; | ||||
| 			int64_t maxPosCode = range - 1; | ||||
| 			int64_t maxNegCode = range - 1; | ||||
| 			while (IS_NEG_CODE(S, maxPosCode)) | ||||
|   | ||||
| @@ -483,10 +483,6 @@ void unpacker::putu1ref(entry *e) | ||||
| 	putu1_at(put_space(1), oidx); | ||||
| } | ||||
|  | ||||
| static int total_cp_size[] = {0, 0}; | ||||
| static int largest_cp_ref[] = {0, 0}; | ||||
| static int hash_probes[] = {0, 0}; | ||||
|  | ||||
| // Allocation of small and large blocks. | ||||
|  | ||||
| enum | ||||
| @@ -705,7 +701,7 @@ void unpacker::read_file_header() | ||||
| 			unpack_abort("impossible archive size"); // bad input data | ||||
| 			return; | ||||
| 		} | ||||
| 		if (archive_size < header_size_1) | ||||
| 		if (archive_size < (size_t)header_size_1) | ||||
| 		{ | ||||
| 			unpack_abort("too much read-ahead"); // somehow we pre-fetched too much? | ||||
| 			return; | ||||
| @@ -1316,8 +1312,6 @@ void unpacker::read_signature_values(entry *cpMap, int len) | ||||
| // Cf. PackageReader.readConstantPool | ||||
| void unpacker::read_cp() | ||||
| { | ||||
| 	byte *rp0 = rp; | ||||
|  | ||||
| 	int i; | ||||
|  | ||||
| 	for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++) | ||||
| @@ -1596,7 +1590,6 @@ band **unpacker::attr_definitions::buildBands(unpacker::layout_definition *lo) | ||||
| const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&res, byte le_kind, | ||||
| 													   bool can_be_signed) | ||||
| { | ||||
| 	const char *lp0 = lp; | ||||
| 	band *b = U_NEW(band, 1); | ||||
| 	char le = *lp++; | ||||
| 	int spec = UNSIGNED5_spec; | ||||
| @@ -1638,7 +1631,6 @@ const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&re | ||||
|  | ||||
| const char *unpacker::attr_definitions::parseNumeral(const char *lp, int &res) | ||||
| { | ||||
| 	const char *lp0 = lp; | ||||
| 	bool sgn = false; | ||||
| 	if (*lp == '0') | ||||
| 	{ | ||||
| @@ -1703,7 +1695,6 @@ band **unpacker::attr_definitions::popBody(int bs_base) | ||||
|  | ||||
| const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res, int curCble) | ||||
| { | ||||
| 	const char *lp0 = lp; | ||||
| 	int bs_base = band_stack.length(); | ||||
| 	bool top_level = (bs_base == 0); | ||||
| 	band *b; | ||||
| @@ -3135,8 +3126,6 @@ unpacker::read_bcs() | ||||
|  | ||||
| void unpacker::read_bands() | ||||
| { | ||||
| 	byte *rp0 = rp; | ||||
|  | ||||
| 	read_file_header(); | ||||
|  | ||||
| 	if (cp.nentries == 0) | ||||
| @@ -3312,7 +3301,7 @@ void constant_pool::initMemberIndexes() | ||||
|  | ||||
| 	// Get the pre-existing indexes: | ||||
| 	int nclasses = tag_count[CONSTANT_Class]; | ||||
| 	entry *classes = tag_base[CONSTANT_Class] + entries; | ||||
| 	// entry *classes = tag_base[CONSTANT_Class] + entries; // UNUSED | ||||
| 	int nfields = tag_count[CONSTANT_Fieldref]; | ||||
| 	entry *fields = tag_base[CONSTANT_Fieldref] + entries; | ||||
| 	int nmethods = tag_count[CONSTANT_Methodref]; | ||||
| @@ -3563,8 +3552,6 @@ void unpacker::start(void *packptr, size_t len) | ||||
|  | ||||
| void unpacker::check_options() | ||||
| { | ||||
| 	const char *strue = "true"; | ||||
| 	const char *sfalse = "false"; | ||||
| 	if (deflate_hint_or_zero != 0) | ||||
| 	{ | ||||
| 		bool force_deflate_hint = (deflate_hint_or_zero > 0); | ||||
|   | ||||
| @@ -97,8 +97,6 @@ static int read_magic(unpacker *u, char peek[], int peeklen) | ||||
| void unpack_200(std::string input_path, std::string output_path) | ||||
| { | ||||
| 	unpacker u; | ||||
| 	int status = 0; | ||||
|  | ||||
| 	FILE *input = fopen(input_path.c_str(), "rb"); | ||||
| 	if (!input) | ||||
| 	{ | ||||
|   | ||||
| @@ -1173,7 +1173,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) | ||||
|     if (password != NULL) | ||||
|     { | ||||
|         int i; | ||||
|         s->pcrc_32_tab = get_crc_table(); | ||||
|         s->pcrc_32_tab = (const unsigned long*) get_crc_table(); | ||||
|         init_keys(password,s->keys,s->pcrc_32_tab); | ||||
|         if (ZSEEK(s->z_filefunc, s->filestream, | ||||
|                   s->pfile_in_zip_read->pos_in_zipfile + | ||||
|   | ||||
| @@ -903,7 +903,7 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, | ||||
|         unsigned char bufHead[RAND_HEAD_LEN]; | ||||
|         unsigned int sizeHead; | ||||
|         zi->ci.encrypt = 1; | ||||
|         zi->ci.pcrc_32_tab = get_crc_table(); | ||||
|         zi->ci.pcrc_32_tab = (const unsigned long*) get_crc_table(); | ||||
|         /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ | ||||
|  | ||||
|         crcForCrypting = (uLong)zi->ci.dosDate << 16; // ATTANTION! Without this row, you don't unpack your password protected archive in other app. | ||||
|   | ||||
| @@ -33,6 +33,11 @@ | ||||
| class LIBSETTINGS_EXPORT Keyring | ||||
| { | ||||
| public: | ||||
| 	/** | ||||
| 	 * @brief virtual dtor | ||||
| 	 */ | ||||
| 	virtual ~Keyring() {}; | ||||
|  | ||||
| 	/** | ||||
| 	 * @brief the System Keyring instance | ||||
| 	 * @return the Keyring instance | ||||
|   | ||||
| @@ -24,6 +24,11 @@ | ||||
| class StubKeyring : public Keyring | ||||
| { | ||||
| public: | ||||
| 	/** | ||||
| 	 * @brief virtual dtor | ||||
| 	 */ | ||||
| 	virtual ~StubKeyring() {}; | ||||
|  | ||||
| 	virtual bool storePassword(QString service, QString username, QString password); | ||||
| 	virtual QString getPassword(QString service, QString username); | ||||
| 	virtual bool hasPassword(QString service, QString username); | ||||
|   | ||||
| @@ -33,7 +33,7 @@ | ||||
| #include "logic/BaseInstance.h" | ||||
|  | ||||
| CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent) | ||||
| 	: m_original(original), QDialog(parent), ui(new Ui::CopyInstanceDialog) | ||||
| 	:QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original) | ||||
| { | ||||
| 	MultiMCPlatform::fixWM_CLASS(this); | ||||
| 	ui->setupUi(this); | ||||
|   | ||||
| @@ -21,8 +21,8 @@ | ||||
| #include <QApplication> | ||||
|  | ||||
| EditNotesDialog::EditNotesDialog(QString notes, QString name, QWidget *parent) | ||||
| 	: m_instance_notes(notes), m_instance_name(name), QDialog(parent), | ||||
| 	  ui(new Ui::EditNotesDialog) | ||||
| 	: QDialog(parent), ui(new Ui::EditNotesDialog), m_instance_name(name), | ||||
| 	  m_instance_notes(notes) | ||||
| { | ||||
| 	MultiMCPlatform::fixWM_CLASS(this); | ||||
| 	ui->setupUi(this); | ||||
|   | ||||
| @@ -32,7 +32,7 @@ | ||||
| #include <QMessageBox> | ||||
|  | ||||
| InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent) | ||||
| 	: m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings) | ||||
| 	: QDialog(parent), ui(new Ui::InstanceSettings), m_obj(obj) | ||||
| { | ||||
| 	MultiMCPlatform::fixWM_CLASS(this); | ||||
| 	ui->setupUi(this); | ||||
|   | ||||
| @@ -31,7 +31,7 @@ | ||||
| #include <QKeyEvent> | ||||
|  | ||||
| LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) | ||||
| 	: m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog) | ||||
| 	: QDialog(parent), ui(new Ui::LegacyModEditDialog), m_inst(inst) | ||||
| { | ||||
| 	MultiMCPlatform::fixWM_CLASS(this); | ||||
| 	ui->setupUi(this); | ||||
|   | ||||
| @@ -40,7 +40,7 @@ | ||||
| #include "logic/ForgeInstaller.h" | ||||
|  | ||||
| OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) | ||||
| 	: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog) | ||||
| 	: QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst) | ||||
| { | ||||
| 	MultiMCPlatform::fixWM_CLASS(this); | ||||
| 	ui->setupUi(this); | ||||
|   | ||||
| @@ -21,45 +21,45 @@ | ||||
| #include <QtCore/qmath.h> | ||||
|  | ||||
| // Origin: Qt | ||||
| static void viewItemTextLayout ( QTextLayout &textLayout, int lineWidth, qreal &height, qreal &widthUsed ) | ||||
| static void viewItemTextLayout(QTextLayout &textLayout, int lineWidth, qreal &height, | ||||
| 							   qreal &widthUsed) | ||||
| { | ||||
| 	height = 0; | ||||
| 	widthUsed = 0; | ||||
| 	textLayout.beginLayout(); | ||||
| 	QString str = textLayout.text(); | ||||
| 	while ( true ) | ||||
| 	while (true) | ||||
| 	{ | ||||
| 		QTextLine line = textLayout.createLine(); | ||||
| 		if ( !line.isValid() ) | ||||
| 		if (!line.isValid()) | ||||
| 			break; | ||||
| 		if(line.textLength() == 0) | ||||
| 		if (line.textLength() == 0) | ||||
| 			break; | ||||
| 		line.setLineWidth ( lineWidth ); | ||||
| 		line.setPosition ( QPointF ( 0, height ) ); | ||||
| 		line.setLineWidth(lineWidth); | ||||
| 		line.setPosition(QPointF(0, height)); | ||||
| 		height += line.height(); | ||||
| 		widthUsed = qMax ( widthUsed, line.naturalTextWidth() ); | ||||
| 		widthUsed = qMax(widthUsed, line.naturalTextWidth()); | ||||
| 	} | ||||
| 	textLayout.endLayout(); | ||||
| } | ||||
|  | ||||
| #define QFIXED_MAX (INT_MAX/256) | ||||
| #define QFIXED_MAX (INT_MAX / 256) | ||||
|  | ||||
| ListViewDelegate::ListViewDelegate ( QObject* parent ) : QStyledItemDelegate ( parent ) | ||||
| ListViewDelegate::ListViewDelegate(QObject *parent) : QStyledItemDelegate(parent) | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
| void drawSelectionRect(QPainter *painter, const QStyleOptionViewItemV4 &option, const QRect &rect) | ||||
| void drawSelectionRect(QPainter *painter, const QStyleOptionViewItemV4 &option, | ||||
| 					   const QRect &rect) | ||||
| { | ||||
| 	if ((option.state & QStyle::State_Selected)) | ||||
| 		painter->fillRect ( rect, option.palette.brush ( QPalette::Highlight ) ); | ||||
| 		painter->fillRect(rect, option.palette.brush(QPalette::Highlight)); | ||||
| 	else | ||||
| 	{ | ||||
| 		QColor backgroundColor = option.palette.color(QPalette::Background); | ||||
| 		backgroundColor.setAlpha(160); | ||||
| 		painter->fillRect ( rect, QBrush(backgroundColor) ); | ||||
| 		painter->fillRect(rect, QBrush(backgroundColor)); | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, const QRect &rect) | ||||
| @@ -67,11 +67,12 @@ void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, cons | ||||
| 	if (!(option.state & QStyle::State_HasFocus)) | ||||
| 		return; | ||||
| 	QStyleOptionFocusRect opt; | ||||
| 	opt.direction       = option.direction; | ||||
| 	opt.fontMetrics     = option.fontMetrics; | ||||
| 	opt.palette         = option.palette; | ||||
| 	opt.rect            = rect; | ||||
| 	//opt.state           = option.state | QStyle::State_KeyboardFocusChange | QStyle::State_Item; | ||||
| 	opt.direction = option.direction; | ||||
| 	opt.fontMetrics = option.fontMetrics; | ||||
| 	opt.palette = option.palette; | ||||
| 	opt.rect = rect; | ||||
| 	// opt.state           = option.state | QStyle::State_KeyboardFocusChange | | ||||
| 	// QStyle::State_Item; | ||||
| 	auto col = option.state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base; | ||||
| 	opt.backgroundColor = option.palette.color(col); | ||||
| 	// Apparently some widget styles expect this hint to not be set | ||||
| @@ -84,29 +85,31 @@ void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, cons | ||||
| 	painter->setRenderHint(QPainter::Antialiasing); | ||||
| } | ||||
|  | ||||
| static QSize viewItemTextSize ( const QStyleOptionViewItemV4 *option ) | ||||
| static QSize viewItemTextSize(const QStyleOptionViewItemV4 *option) | ||||
| { | ||||
| 	QStyle *style = option->widget ? option->widget->style() : QApplication::style(); | ||||
| 	QTextOption textOption; | ||||
| 	textOption.setWrapMode ( QTextOption::WrapAtWordBoundaryOrAnywhere ); | ||||
| 	textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); | ||||
| 	QTextLayout textLayout; | ||||
| 	textLayout.setTextOption ( textOption ); | ||||
| 	textLayout.setFont ( option->font ); | ||||
| 	textLayout.setText ( option->text ); | ||||
| 	const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, option, option->widget ) + 1; | ||||
| 	QRect bounds ( 0,0,100 - 2*textMargin,600 ); | ||||
| 	textLayout.setTextOption(textOption); | ||||
| 	textLayout.setFont(option->font); | ||||
| 	textLayout.setText(option->text); | ||||
| 	const int textMargin = | ||||
| 		style->pixelMetric(QStyle::PM_FocusFrameHMargin, option, option->widget) + 1; | ||||
| 	QRect bounds(0, 0, 100 - 2 * textMargin, 600); | ||||
| 	qreal height = 0, widthUsed = 0; | ||||
| 	viewItemTextLayout ( textLayout, bounds.width(), height, widthUsed ); | ||||
| 	const QSize size ( qCeil ( widthUsed ), qCeil ( height ) ); | ||||
| 	return QSize ( size.width() + 2 * textMargin, size.height() ); | ||||
| 	viewItemTextLayout(textLayout, bounds.width(), height, widthUsed); | ||||
| 	const QSize size(qCeil(widthUsed), qCeil(height)); | ||||
| 	return QSize(size.width() + 2 * textMargin, size.height()); | ||||
| } | ||||
|  | ||||
| void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const | ||||
| void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, | ||||
| 							 const QModelIndex &index) const | ||||
| { | ||||
| 	QStyleOptionViewItemV4 opt = option; | ||||
| 	initStyleOption ( &opt, index ); | ||||
| 	initStyleOption(&opt, index); | ||||
| 	painter->save(); | ||||
| 	painter->setClipRect ( opt.rect ); | ||||
| 	painter->setClipRect(opt.rect); | ||||
|  | ||||
| 	opt.features |= QStyleOptionViewItem::WrapText; | ||||
| 	opt.text = index.data().toString(); | ||||
| @@ -115,26 +118,27 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op | ||||
|  | ||||
| 	QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); | ||||
|  | ||||
| 	//const int iconSize =  style->pixelMetric(QStyle::PM_IconViewIconSize); | ||||
| 	// const int iconSize =  style->pixelMetric(QStyle::PM_IconViewIconSize); | ||||
| 	const int iconSize = 48; | ||||
| 	QRect iconbox = opt.rect; | ||||
| 	const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, 0, opt.widget ) + 1; | ||||
| 	const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, opt.widget) + 1; | ||||
| 	QRect textRect = opt.rect; | ||||
| 	QRect textHighlightRect = textRect; | ||||
| 	// clip the decoration on top, remove width padding | ||||
| 	textRect.adjust ( textMargin,iconSize + textMargin + 5,-textMargin,0 ); | ||||
| 	 | ||||
| 	textHighlightRect.adjust ( 0,iconSize + 5,0,0 ); | ||||
| 	textRect.adjust(textMargin, iconSize + textMargin + 5, -textMargin, 0); | ||||
|  | ||||
| 	textHighlightRect.adjust(0, iconSize + 5, 0, 0); | ||||
|  | ||||
| 	// draw background | ||||
| 	{ | ||||
| 		QSize textSize = viewItemTextSize ( &opt ); | ||||
| 		// FIXME: unused | ||||
| 		// QSize textSize = viewItemTextSize ( &opt ); | ||||
| 		QPalette::ColorGroup cg; | ||||
| 		QStyleOptionViewItemV4 opt2(opt); | ||||
| 		 | ||||
| 		if((opt.widget && opt.widget->isEnabled()) || (opt.state & QStyle::State_Enabled)) | ||||
|  | ||||
| 		if ((opt.widget && opt.widget->isEnabled()) || (opt.state & QStyle::State_Enabled)) | ||||
| 		{ | ||||
| 			if(! ( opt.state & QStyle::State_Active )) | ||||
| 			if (!(opt.state & QStyle::State_Active)) | ||||
| 				cg = QPalette::Inactive; | ||||
| 			else | ||||
| 				cg = QPalette::Normal; | ||||
| @@ -144,31 +148,33 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op | ||||
| 			cg = QPalette::Disabled; | ||||
| 		} | ||||
| 		opt2.palette.setCurrentColorGroup(cg); | ||||
| 		 | ||||
|  | ||||
| 		// fill in background, if any | ||||
| 		if ( opt.backgroundBrush.style() != Qt::NoBrush ) | ||||
| 		if (opt.backgroundBrush.style() != Qt::NoBrush) | ||||
| 		{ | ||||
| 			QPointF oldBO = painter->brushOrigin(); | ||||
| 			painter->setBrushOrigin ( opt.rect.topLeft() ); | ||||
| 			painter->fillRect ( opt.rect, opt.backgroundBrush ); | ||||
| 			painter->setBrushOrigin ( oldBO ); | ||||
| 			painter->setBrushOrigin(opt.rect.topLeft()); | ||||
| 			painter->fillRect(opt.rect, opt.backgroundBrush); | ||||
| 			painter->setBrushOrigin(oldBO); | ||||
| 		} | ||||
| 		 | ||||
| 		if ( opt.showDecorationSelected ) | ||||
|  | ||||
| 		if (opt.showDecorationSelected) | ||||
| 		{ | ||||
| 			drawSelectionRect(painter,opt2, opt.rect); | ||||
| 			drawFocusRect(painter,opt2, opt.rect); | ||||
| 			//painter->fillRect ( opt.rect, opt.palette.brush ( cg, QPalette::Highlight ) ); | ||||
| 			drawSelectionRect(painter, opt2, opt.rect); | ||||
| 			drawFocusRect(painter, opt2, opt.rect); | ||||
| 			// painter->fillRect ( opt.rect, opt.palette.brush ( cg, QPalette::Highlight ) ); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			 | ||||
| 			//if ( opt.state & QStyle::State_Selected ) | ||||
|  | ||||
| 			// if ( opt.state & QStyle::State_Selected ) | ||||
| 			{ | ||||
| 				//QRect textRect = subElementRect ( QStyle::SE_ItemViewItemText,  opt, opt.widget ); | ||||
| 				//painter->fillRect ( textHighlightRect, opt.palette.brush ( cg, QPalette::Highlight ) ); | ||||
| 				drawSelectionRect(painter,opt2, textHighlightRect); | ||||
| 				drawFocusRect(painter,opt2, textHighlightRect); | ||||
| 				// QRect textRect = subElementRect ( QStyle::SE_ItemViewItemText,  opt, | ||||
| 				// opt.widget ); | ||||
| 				// painter->fillRect ( textHighlightRect, opt.palette.brush ( cg, | ||||
| 				// QPalette::Highlight ) ); | ||||
| 				drawSelectionRect(painter, opt2, textHighlightRect); | ||||
| 				drawFocusRect(painter, opt2, textHighlightRect); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -176,71 +182,73 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op | ||||
| 	// draw the icon | ||||
| 	{ | ||||
| 		QIcon::Mode mode = QIcon::Normal; | ||||
| 		if ( ! ( opt.state & QStyle::State_Enabled ) ) | ||||
| 		if (!(opt.state & QStyle::State_Enabled)) | ||||
| 			mode = QIcon::Disabled; | ||||
| 		else if ( opt.state & QStyle::State_Selected ) | ||||
| 		else if (opt.state & QStyle::State_Selected) | ||||
| 			mode = QIcon::Selected; | ||||
| 		QIcon::State state = opt.state & QStyle::State_Open ? QIcon::On : QIcon::Off; | ||||
|  | ||||
| 		iconbox.setHeight ( iconSize ); | ||||
| 		opt.icon.paint ( painter, iconbox, Qt::AlignCenter, mode, state ); | ||||
| 		iconbox.setHeight(iconSize); | ||||
| 		opt.icon.paint(painter, iconbox, Qt::AlignCenter, mode, state); | ||||
| 	} | ||||
| 	// set the text colors | ||||
| 	QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; | ||||
| 	if ( cg == QPalette::Normal && ! ( opt.state & QStyle::State_Active ) ) | ||||
| 	QPalette::ColorGroup cg = | ||||
| 		opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; | ||||
| 	if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active)) | ||||
| 		cg = QPalette::Inactive; | ||||
| 	if ( opt.state & QStyle::State_Selected ) | ||||
| 	if (opt.state & QStyle::State_Selected) | ||||
| 	{ | ||||
| 		painter->setPen ( opt.palette.color ( cg, QPalette::HighlightedText ) ); | ||||
| 		painter->setPen(opt.palette.color(cg, QPalette::HighlightedText)); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		painter->setPen ( opt.palette.color ( cg, QPalette::Text ) ); | ||||
| 		painter->setPen(opt.palette.color(cg, QPalette::Text)); | ||||
| 	} | ||||
|  | ||||
| 	// draw the text | ||||
| 	QTextOption textOption; | ||||
| 	textOption.setWrapMode ( QTextOption::WrapAtWordBoundaryOrAnywhere ); | ||||
| 	textOption.setTextDirection ( opt.direction ); | ||||
| 	textOption.setAlignment ( QStyle::visualAlignment ( opt.direction, opt.displayAlignment ) ); | ||||
| 	textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); | ||||
| 	textOption.setTextDirection(opt.direction); | ||||
| 	textOption.setAlignment(QStyle::visualAlignment(opt.direction, opt.displayAlignment)); | ||||
| 	QTextLayout textLayout; | ||||
| 	textLayout.setTextOption ( textOption ); | ||||
| 	textLayout.setFont ( opt.font ); | ||||
| 	textLayout.setText ( opt.text ); | ||||
| 	textLayout.setTextOption(textOption); | ||||
| 	textLayout.setFont(opt.font); | ||||
| 	textLayout.setText(opt.text); | ||||
|  | ||||
| 	qreal width, height; | ||||
| 	viewItemTextLayout ( textLayout, textRect.width(), height, width ); | ||||
| 	viewItemTextLayout(textLayout, textRect.width(), height, width); | ||||
|  | ||||
| 	const int lineCount = textLayout.lineCount(); | ||||
|  | ||||
| 	const QRect layoutRect = QStyle::alignedRect ( opt.direction, opt.displayAlignment, QSize ( textRect.width(), int ( height ) ), textRect ); | ||||
| 	const QRect layoutRect = QStyle::alignedRect( | ||||
| 		opt.direction, opt.displayAlignment, QSize(textRect.width(), int(height)), textRect); | ||||
| 	const QPointF position = layoutRect.topLeft(); | ||||
| 	for ( int i = 0; i < lineCount; ++i ) | ||||
| 	for (int i = 0; i < lineCount; ++i) | ||||
| 	{ | ||||
| 		const QTextLine line = textLayout.lineAt ( i ); | ||||
| 		line.draw ( painter, position ); | ||||
| 		const QTextLine line = textLayout.lineAt(i); | ||||
| 		line.draw(painter, position); | ||||
| 	} | ||||
|  | ||||
| 	painter->restore(); | ||||
| } | ||||
|  | ||||
|  | ||||
| QSize ListViewDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||||
| QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option, | ||||
| 								 const QModelIndex &index) const | ||||
| { | ||||
| 	QStyleOptionViewItemV4 opt = option; | ||||
| 	initStyleOption ( &opt, index ); | ||||
| 	initStyleOption(&opt, index); | ||||
| 	opt.features |= QStyleOptionViewItem::WrapText; | ||||
| 	opt.text = index.data().toString(); | ||||
| 	opt.textElideMode = Qt::ElideRight; | ||||
| 	opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter; | ||||
|  | ||||
| 	QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); | ||||
| 	const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, &option, opt.widget ) + 1; | ||||
| 	const int textMargin = | ||||
| 		style->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, opt.widget) + 1; | ||||
| 	int height = 48 + textMargin * 2 + 5; // TODO: turn constants into variables | ||||
| 	QSize szz = viewItemTextSize ( &opt ); | ||||
| 	QSize szz = viewItemTextSize(&opt); | ||||
| 	height += szz.height(); | ||||
| 	// FIXME: maybe the icon items could scale and keep proportions? | ||||
| 	QSize sz ( 100,height ); | ||||
| 	QSize sz(100, height); | ||||
| 	return sz; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -30,7 +30,7 @@ | ||||
|  | ||||
| BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir, | ||||
| 						   SettingsObject *settings_obj, QObject *parent) | ||||
| 	: inst_d(d_in), QObject(parent) | ||||
| 	: QObject(parent), inst_d(d_in) | ||||
| { | ||||
| 	I_D(BaseInstance); | ||||
| 	d->m_settings = settings_obj; | ||||
|   | ||||
| @@ -133,16 +133,12 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne | ||||
| 	{ | ||||
| 	case NoLoadError: | ||||
| 		return NoCreateError; | ||||
| 	case UnknownLoadError: | ||||
| 	{ | ||||
| 		rootDir.removeRecursively(); | ||||
| 		return UnknownCreateError; | ||||
| 	} | ||||
| 	case NotAnInstance: | ||||
| 	{ | ||||
| 		rootDir.removeRecursively(); | ||||
| 		return CantCreateDir; | ||||
| 	default: | ||||
| 	case UnknownLoadError: | ||||
| 		rootDir.removeRecursively(); | ||||
| 		return UnknownCreateError;	 | ||||
| 	} | ||||
| 	} | ||||
| 	; | ||||
| } | ||||
|   | ||||
| @@ -8,7 +8,7 @@ JavaChecker::JavaChecker(QObject *parent) : QObject(parent) | ||||
| { | ||||
| } | ||||
|  | ||||
| int JavaChecker::performCheck(QString path) | ||||
| void JavaChecker::performCheck(QString path) | ||||
| { | ||||
| 	if(QFile::exists(CHECKER_FILE)) | ||||
| 	{ | ||||
|   | ||||
| @@ -17,7 +17,7 @@ class JavaChecker : public QObject | ||||
| 	Q_OBJECT | ||||
| public: | ||||
| 	explicit JavaChecker(QObject *parent = 0); | ||||
| 	int performCheck(QString path); | ||||
| 	void performCheck(QString path); | ||||
|  | ||||
| signals: | ||||
| 	void checkFinished(JavaCheckResult result); | ||||
|   | ||||
| @@ -274,7 +274,6 @@ bool LegacyInstance::setIntendedVersionId(QString version) | ||||
|  | ||||
| bool LegacyInstance::shouldUpdate() const | ||||
| { | ||||
| 	I_D(LegacyInstance); | ||||
| 	QVariant var = settings().get("ShouldUpdate"); | ||||
| 	if (!var.isValid() || var.toBool() == false) | ||||
| 	{ | ||||
|   | ||||
| @@ -39,18 +39,26 @@ void ModList::startWatching() | ||||
| { | ||||
| 	is_watching = m_watcher->addPath(m_dir.absolutePath()); | ||||
| 	if (is_watching) | ||||
| 	{ | ||||
| 		QLOG_INFO() << "Started watching " << m_dir.absolutePath(); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		QLOG_INFO() << "Failed to start watching " << m_dir.absolutePath(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void ModList::stopWatching() | ||||
| { | ||||
| 	is_watching = !m_watcher->removePath(m_dir.absolutePath()); | ||||
| 	if (!is_watching) | ||||
| 	{ | ||||
| 		QLOG_INFO() << "Stopped watching " << m_dir.absolutePath(); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| bool ModList::update() | ||||
| @@ -64,7 +72,6 @@ bool ModList::update() | ||||
| 	bool orderWasInvalid = false; | ||||
|  | ||||
| 	// first, process the ordered items (if any) | ||||
| 	int currentOrderIndex = 0; | ||||
| 	QStringList listOrder = readListFile(); | ||||
| 	for (auto item : listOrder) | ||||
| 	{ | ||||
| @@ -363,6 +370,7 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, int role) | ||||
| 	case 2: | ||||
| 		return QString("Minecraft"); | ||||
| 	} | ||||
| 	return QString(); | ||||
| } | ||||
|  | ||||
| Qt::ItemFlags ModList::flags(const QModelIndex &index) const | ||||
|   | ||||
| @@ -235,7 +235,6 @@ void OneSixInstance::setShouldUpdate(bool val) | ||||
|  | ||||
| bool OneSixInstance::shouldUpdate() const | ||||
| { | ||||
| 	I_D(OneSixInstance); | ||||
| 	QVariant var = settings().get("ShouldUpdate"); | ||||
| 	if (!var.isValid() || var.toBool() == false) | ||||
| 	{ | ||||
|   | ||||
| @@ -198,7 +198,6 @@ void OneSixUpdate::jarlibStart() | ||||
|  | ||||
| 	auto metacache = MMC->metacache(); | ||||
| 	QList<ForgeXzDownloadPtr> ForgeLibs; | ||||
| 	bool already_forge_xz = false; | ||||
| 	for (auto lib : libs) | ||||
| 	{ | ||||
| 		if (lib->hint() == "local") | ||||
|   | ||||
| @@ -281,14 +281,6 @@ InstanceList::InstListError InstanceList::loadList() | ||||
| 		auto &loader = InstanceFactory::get(); | ||||
| 		auto error = loader.loadInstance(instPtr, subDir); | ||||
|  | ||||
| 		switch (error) | ||||
| 		{ | ||||
| 		case InstanceFactory::NoLoadError: | ||||
| 			break; | ||||
| 		case InstanceFactory::NotAnInstance: | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance) | ||||
| 		{ | ||||
| 			QString errorMsg = QString("Failed to load instance %1: ") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user