Exemple #1
0
FormMain::FormMain(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormMain)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);
    createPages();
    connect(ui->stackedWidget->widget(m_formIndex.value(FORMLOGIN)),SIGNAL(closeMainForm())
            ,this,SLOT(on_btnClose_clicked()));
    connect(ui->stackedWidget->widget(m_formIndex.value(FORMLOGIN)),SIGNAL(changeToMaintain())
            ,this,SLOT(LoginSuccess()));
    hideToolBox();
    setWidgetSize(400,300);
    //焦点默认给登陆界面
    ((FormLogin*)ui->stackedWidget->widget(m_formIndex.value(FORMLOGIN)))->setFocus();
}
Exemple #2
0
void MainApp::logOut(bool bShowLogin, bool autoLogin, bool webLoggedOut)
{
	gcTrace("");

	m_pInternalLink->closeAll();
	safe_delete(m_pInternalLink);

	closeMainForm();
	wxTheApp->ProcessIdle();

	{
		std::lock_guard<std::mutex> a(m_UserLock);
		if (g_pUserHandle)
		{
			auto user = g_pUserHandle;

			g_pUserHandle = nullptr;
			DesuraJSBinding::gs_pItemManager = nullptr;

			user->getPipeDisconnectEvent() -= guiDelegate(this, &MainApp::onPipeDisconnect);
			user->logOut(!autoLogin);

			user->getAppUpdateProgEvent()				-= guiDelegate(this, &MainApp::onAppUpdateProg);
			user->getAppUpdateCompleteEvent()			-= guiDelegate(this, &MainApp::onAppUpdate);
			user->getWebCore()->getCookieUpdateEvent() -= guiDelegate(this, &MainApp::onCookieUpdate);
			user->getWebCore()->getLoggedOutEvent()		-= delegate(&onLoggedOutEvent);

			user->destroy();
		}
	}

	GetCVarManager()->saveAll();
	GetCVarManager()->cleanUserCvars();

	m_bLoggedIn = false;
	m_iMode = APP_MODE::MODE_UNINT;

	if (bShowLogin)
		showLogin(!autoLogin, webLoggedOut);

	HideLogForm();

	DeleteCookies();
	SetCrashDumpSettings(nullptr, true);
}
Exemple #3
0
void MainApp::offlineMode()
{
	if (m_iMode == APP_MODE::MODE_OFFLINE)
		return;

	if (m_bLoggedIn)
		logOut(false);

	closeMainForm();

	{
		std::lock_guard<std::mutex> a(m_UserLock);

		gcString path = UTIL::OS::getAppDataPath();

		if (g_pUserHandle)
			g_pUserHandle->destroy();

		g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE);
		g_pUserHandle->init(path.c_str());

		try
		{
			g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar);
			g_pUserHandle->getItemManager()->loadItems();
		}
		catch (gcException &)
		{
			g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar);
			g_pUserHandle->logOut();
			g_pUserHandle->destroy();
			throw;
		}
	}

	GetCVarManager()->loadUser(GetUserCore()->getUserId());
	m_iMode = APP_MODE::MODE_OFFLINE;

	showMainWindow();
	m_pInternalLink = new InternalLink(this);
}
Exemple #4
0
void MainApp::logOut(bool bShowLogin, bool autoLogin)
{
	m_pInternalLink->closeAll();
	safe_delete(m_pInternalLink);

	{
		Thread::AutoLock a(m_UserLock);
		if (g_pUserHandle)
		{
			UserCore::UserI* user = g_pUserHandle;
			g_pUserHandle = NULL;

			user->logOut(!autoLogin);

			*user->getAppUpdateProgEvent()				-= guiDelegate(this, &MainApp::onAppUpdateProg);
			*user->getAppUpdateCompleteEvent()			-= guiDelegate(this, &MainApp::onAppUpdate);
			*user->getWebCore()->getCookieUpdateEvent() -= guiDelegate(this, &MainApp::onCookieUpdate);
			*user->getPipeDisconnectEvent()				-= guiDelegate(this, &MainApp::onPipeDisconnect);

			safe_delete(user);
		}
	}

	GetCVarManager()->saveAll();
	GetCVarManager()->cleanUserCvars();

	closeMainForm();

	m_bLoggedIn = false;
	m_iMode = MODE_UNINT;

	if (bShowLogin)
		showLogin(!autoLogin);

	HideLogForm();

	DeleteCookies();
	SetCrashDumpSettings(NULL, true);
}