Mercurial > mercurial > hgweb_rsearcher.cgi
diff src/main.cpp @ 6:9a8b581c1993
improve performance.
author | pyon@macmini |
---|---|
date | Tue, 23 Oct 2018 19:15:22 +0900 |
parents | e3b10fb860b3 |
children | 29829e98d510 |
line wrap: on
line diff
--- a/src/main.cpp Mon Oct 22 22:17:02 2018 +0900 +++ b/src/main.cpp Tue Oct 23 19:15:22 2018 +0900 @@ -1,5 +1,5 @@ // Filename : main.cpp -// Last Change: 2018-10-22 月 16:14:28. +// Last Change: 2018-10-23 火 10:09:42. // #include "id.h" #include "main.h" @@ -26,6 +26,11 @@ wxImage::AddHandler( new wxPNGHandler ); InitSetting(); + // Login Dialog + AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION ); + authdlg->SetServer( m_server ); + authdlg->GetDB(); + // Splash Screen wxFileSystem::AddHandler( new wxZipFSHandler ); wxFileSystem* fs = new wxFileSystem(); @@ -36,27 +41,13 @@ wxInputStream* s = file->GetStream(); wxImage image( *s, wxBITMAP_TYPE_PNG ); wxBitmap bmp = wxBitmap( image ); - wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 3000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP ); + wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2500, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP ); delete file; } - wxMilliSleep( 250 ); - } - - unsigned int seed = (unsigned int)time( 0 ); - srand( seed ); - int n = rand() % 13; - wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:%02d.jpg" ), n ) ); - if ( file ) { - wxInputStream* s = file->GetStream(); - wxFileOutputStream of( wxT( "./image/hello.jpg" ) ); - s->Read( of ); - delete file; + wxMilliSleep( 200 ); } delete fs; - // Login Dialog - AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION ); - authdlg->SetServer( m_server ); if ( !authdlg->LoadDB() ) { authdlg->Destroy(); return false; @@ -64,7 +55,22 @@ if ( authdlg->ShowModal() == wxID_OK ) { wxString ui = wxString::Format( wxT( "./image/" ) + authdlg->GetUser() + wxT( ".jpg" ) ); - if ( wxFileExists( ui ) ) wxCopyFile( ui, wxT( "./image/hello.jpg" ), true ); + if ( wxFileExists( ui ) ) { + wxCopyFile( ui, wxT( "./image/hello.jpg" ), true ); + } else { + unsigned int seed = (unsigned int)time( 0 ); + srand( seed ); + int n = rand() % 13; + wxFileSystem* fs = new wxFileSystem(); + wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:%02d.jpg" ), n ) ); + if ( file ) { + wxInputStream* s = file->GetStream(); + wxFileOutputStream of( wxT( "./image/hello.jpg" ) ); + s->Read( of ); + delete file; + } + delete fs; + } // Main Window MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); @@ -83,6 +89,9 @@ int MyApp::OnExit() { + RemoveFile( wxT( "auth.db" ) ); + RemoveFile( wxT( "hhs.db" ) ); + RemoveFile( wxT( ".cache/*" ) ); SaveSetting(); return 0; } @@ -122,3 +131,12 @@ delete config; } +void MyApp::RemoveFile( wxString pattern ) +{ + wxString file = wxFindFirstFile( pattern ); + while ( !file.empty() ) { + wxRemoveFile( file ); + file = wxFindNextFile(); + } +} +