-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.cpp
More file actions
84 lines (64 loc) · 1.7 KB
/
app.cpp
File metadata and controls
84 lines (64 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (C) 2016 Frode Roxrud Gill
// See LICENSE file for license
#ifdef __GNUG__
#pragma implementation "app.h"
#endif
#include <wx/config.h>
#include <wx/dir.h>
#include <wx/stdpaths.h>
#include <X11/Xlib.h>
#include "app.h"
wxIMPLEMENT_APP(PhotoMailer::PhotoMailerApp);
using namespace PhotoMailer;
IMPLEMENT_CLASS(PhotoMailerApp, wxApp)
PhotoMailerApp::PhotoMailerApp()
: wxApp(),
m_main_frame(nullptr),
m_preview_frame(nullptr)
{
::XInitThreads();
}
PhotoMailerApp::~PhotoMailerApp()
{
// delete m_main_frame; //Deleted by wxWidgets
}
bool PhotoMailerApp::OnInit()
{
if (!wxApp::OnInit())
return false;
::wxInitAllImageHandlers();
//Create app settings directory if not already present
wxString config_dir = wxStandardPaths::Get().GetUserLocalDataDir();
if (!wxDir::Exists(config_dir))
{
::wxMkdir(config_dir);
}
//Init config
wxConfig* config = new wxConfig(GetAppName(), wxEmptyString, ".settings", wxEmptyString, wxCONFIG_USE_SUBDIR|wxCONFIG_USE_LOCAL_FILE);
if (!config)
{
wxASSERT_MSG(false, _("Could not initialize ConfigBase"));
return false;
}
wxConfigBase::Set(config);
//Initialize main frame
m_main_frame = new PhotoMailerFrame(_("PhotoMailer v1.0"));
if (!m_main_frame)
{
wxASSERT_MSG(false, _("wxMailto_Frame is NULL"));
return false;
}
m_main_frame->Show(true);
return true;
}
PreviewFrame* PhotoMailerApp::GetPreviewFrame()
{
if (!m_preview_frame)
{
m_preview_frame = new PreviewFrame(nullptr, wxID_ANY, _("Preview"),
wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxMAXIMIZE_BOX | wxCLOSE_BOX | wxRESIZE_BORDER);
m_preview_frame->Show(true);
}
return m_preview_frame;
}