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