0
|
1 // Filename : main.cpp
|
4
|
2 // Last Change: 2018-10-12 金 16:17:39.
|
0
|
3 //
|
4
|
4 #include "id.h"
|
0
|
5 #include "main.h"
|
|
6 #include "auth.h"
|
|
7 #include "rsearcher.h"
|
|
8
|
|
9 IMPLEMENT_APP( MyApp )
|
|
10
|
|
11 IMPLEMENT_CLASS( MyApp, wxApp )
|
|
12
|
|
13 MyApp::MyApp()
|
|
14 {
|
1
|
15 develop = true;
|
0
|
16 }
|
|
17 MyApp::~MyApp()
|
|
18 {
|
|
19 }
|
|
20
|
|
21 bool MyApp::OnInit()
|
|
22 {
|
|
23 if ( !wxApp::OnInit() ) return false;
|
|
24
|
|
25 wxImage::AddHandler( new wxJPEGHandler );
|
|
26 wxImage::AddHandler( new wxPNGHandler );
|
|
27 InitSetting();
|
|
28
|
3
|
29 wxBitmap bmp;
|
4
|
30 if ( bmp.LoadFile( wxT( "./image/startup.png" ), wxBITMAP_TYPE_PNG ) ){
|
3
|
31 wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 4000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
|
|
32 }
|
|
33
|
|
34 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Check User" ), wxDefaultPosition, wxDefaultSize, wxCAPTION );
|
|
35 authdlg->SetServer( m_server );
|
|
36
|
1
|
37 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
|
2
|
38 mainframe->SetServer( m_server );
|
1
|
39
|
|
40 if ( develop ) {
|
|
41 authdlg->InDevelop( true );
|
|
42 mainframe->InDevelop( true );
|
|
43 }
|
|
44
|
3
|
45 if ( authdlg->ShowModal() == wxID_OK ) {
|
|
46 mainframe->SetUser( authdlg->GetUser() );
|
|
47 mainframe->Show( true );
|
|
48 } else {
|
|
49 mainframe->Destroy();
|
|
50 }
|
|
51 authdlg->Destroy();
|
0
|
52
|
|
53 return true;
|
|
54 }
|
|
55
|
|
56 int MyApp::OnExit()
|
|
57 {
|
|
58 SaveSetting();
|
|
59 return 0;
|
|
60 }
|
|
61
|
|
62 void MyApp::InitSetting()
|
|
63 {
|
2
|
64 conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "app.conf" );
|
|
65 config = new wxFileConfig( wxT( "MyApp" ), wxT( "T.Mutoh" ), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
66
|
|
67 config->SetPath( wxT( "/Geometry" ) );
|
|
68 config->Read( wxT( "x" ), &rect.x );
|
|
69 config->Read( wxT( "y" ), &rect.y );
|
|
70 config->Read( wxT( "w" ), &rect.width );
|
|
71 config->Read( wxT( "h" ), &rect.height );
|
0
|
72
|
3
|
73 wxString proxy;
|
2
|
74 config->SetPath( wxT( "/Server" ) );
|
|
75 config->Read( wxT( "server" ), &m_server );
|
3
|
76 config->Read( wxT( "proxy" ), &proxy );
|
0
|
77 delete config;
|
2
|
78
|
3
|
79 if ( !proxy.IsSameAs( wxEmptyString, false ) ) m_server = proxy;
|
2
|
80 //m_server = wxT( "192.168.79.124:80" );
|
|
81 if ( m_server.IsSameAs( wxEmptyString, false ) )
|
|
82 m_server = wxT( "192.168.21.151:80" ); // nginx
|
0
|
83 }
|
|
84
|
|
85 void MyApp::SaveSetting()
|
|
86 {
|
3
|
87 config = new wxFileConfig( wxT( "MyApp" ), wxT( "T.Mutoh" ), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
0
|
88
|
3
|
89 config->SetPath( wxT( "/Geometry" ) );
|
|
90 config->Write( wxT( "x" ), rect.x );
|
|
91 config->Write( wxT( "y" ), rect.y );
|
|
92 config->Write( wxT( "w" ), rect.width );
|
|
93 config->Write( wxT( "h" ), rect.height );
|
0
|
94 delete config;
|
|
95 }
|
|
96
|