mirror of https://github.com/procxx/kepka.git
				
				
				
			Allow switching off debug logs in closed alpha.
This commit is contained in:
		
							parent
							
								
									18b74b9045
								
							
						
					
					
						commit
						9b449a1d26
					
				|  | @ -450,14 +450,35 @@ void WriteInstallBetaVersionsSetting() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void WorkingDirReady() { | ||||
| QString DebugModeSettingPath() { | ||||
| 	return cWorkingDir() + qsl("tdata/withdebug"); | ||||
| } | ||||
| 
 | ||||
| void WriteDebugModeSetting() { | ||||
| 	QFile f(DebugModeSettingPath()); | ||||
| 	if (f.open(QIODevice::WriteOnly)) { | ||||
| 		f.write(Logs::DebugEnabled() ? "1" : "0"); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void ComputeTestMode() { | ||||
| 	if (QFile(cWorkingDir() + qsl("tdata/withtestmode")).exists()) { | ||||
| 		cSetTestMode(true); | ||||
| 	} | ||||
| 	if (!Logs::DebugEnabled() | ||||
| 		&& QFile(cWorkingDir() + qsl("tdata/withdebug")).exists()) { | ||||
| 		Logs::SetDebugEnabled(true); | ||||
| } | ||||
| 
 | ||||
| void ComputeDebugMode() { | ||||
| 	Logs::SetDebugEnabled(cAlphaVersion() != 0); | ||||
| 	const auto debugModeSettingPath = DebugModeSettingPath(); | ||||
| 	if (QFile(debugModeSettingPath).exists()) { | ||||
| 		QFile f(debugModeSettingPath); | ||||
| 		if (f.open(QIODevice::ReadOnly)) { | ||||
| 			Logs::SetDebugEnabled(f.read(1) != "0"); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void ComputeInstallBetaVersions() { | ||||
| 	const auto installBetaSettingPath = InstallBetaVersionsSettingPath(); | ||||
| 	if (cAlphaVersion()) { | ||||
| 		cSetInstallBetaVersion(false); | ||||
|  | @ -469,9 +490,9 @@ void WorkingDirReady() { | |||
| 	} else if (AppBetaVersion) { | ||||
| 		WriteInstallBetaVersionsSetting(); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 	srand((int32)time(NULL)); | ||||
| 
 | ||||
| void ComputeUserTag() { | ||||
| 	SandboxUserTag = 0; | ||||
| 	QFile usertag(cWorkingDir() + qsl("tdata/usertag")); | ||||
| 	if (usertag.open(QIODevice::ReadOnly)) { | ||||
|  | @ -492,6 +513,15 @@ void WorkingDirReady() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| void WorkingDirReady() { | ||||
| 	srand((int32)time(NULL)); | ||||
| 
 | ||||
| 	ComputeTestMode(); | ||||
| 	ComputeDebugMode(); | ||||
| 	ComputeInstallBetaVersions(); | ||||
| 	ComputeUserTag(); | ||||
| } | ||||
| 
 | ||||
| void start() { | ||||
| 	SandboxData = std::make_unique<internal::Data>(); | ||||
| } | ||||
|  |  | |||
|  | @ -188,6 +188,7 @@ namespace Sandbox { | |||
| bool CheckAlphaVersionDir(); | ||||
| void WorkingDirReady(); | ||||
| void WriteInstallBetaVersionsSetting(); | ||||
| void WriteDebugModeSetting(); | ||||
| 
 | ||||
| void MainThreadTaskAdded(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -331,7 +331,6 @@ void start(not_null<Core::Launcher*> launcher) { | |||
| 	auto workingDirChosen = false; | ||||
| 
 | ||||
| 	if (cAlphaVersion()) { | ||||
| 		SetDebugEnabled(true); | ||||
| 		workingDirChosen = true; | ||||
| #if defined Q_OS_MAC || defined Q_OS_LINUX | ||||
| 	} else { | ||||
|  |  | |||
|  | @ -678,17 +678,13 @@ void Messenger::killDownloadSessions() { | |||
| 
 | ||||
| void Messenger::onSwitchDebugMode() { | ||||
| 	if (Logs::DebugEnabled()) { | ||||
| 		QFile(cWorkingDir() + qsl("tdata/withdebug")).remove(); | ||||
| 		Logs::SetDebugEnabled(false); | ||||
| 		Sandbox::WriteDebugModeSetting(); | ||||
| 		App::restart(); | ||||
| 	} else { | ||||
| 		Logs::SetDebugEnabled(true); | ||||
| 		Sandbox::WriteDebugModeSetting(); | ||||
| 		DEBUG_LOG(("Debug logs started.")); | ||||
| 		QFile f(cWorkingDir() + qsl("tdata/withdebug")); | ||||
| 		if (f.open(QIODevice::WriteOnly)) { | ||||
| 			f.write("1"); | ||||
| 			f.close(); | ||||
| 		} | ||||
| 		Ui::hideLayer(); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue