KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_about.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2010 Rafael Sokolowski <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#if defined( _WIN32 )
26#include <windows.h>
27#endif
28
29#include <build_version.h>
30#include <eda_base_frame.h>
31#include <wx/clipbrd.h>
32#include <wx/msgdlg.h>
33#include <wx/hyperlink.h>
34
35/* All KiCad icons are linked into shared library 'libbitmaps.a'.
36 * Icons:
37 * preference_xpm; // Icon for 'Developers' tab
38 * editor_xpm; // Icon for 'Doc Writers' tab
39 * color_materials_xpm; // Icon for 'Artists' tab
40 * language_xpm; // Icon for 'Translators' tab
41 * right_xpm; // Right arrow icon for list items
42 * info_xpm; // Bulb for description tab
43 * tools_xpm; // Sheet of paper icon for license info tab
44 */
45#include <bitmaps.h>
47#include <tool/tool_manager.h>
48
49#include "dialog_about.h"
50
51
53 DIALOG_ABOUT_BASE( aParent ),
54 m_images( nullptr ),
55 m_info( aAppInfo )
56{
57 wxASSERT( aParent != nullptr );
58
59 SetEvtHandlerEnabled( false );
60
61 const int c_iconSize = 16;
62 wxVector<wxBitmapBundle> images;
63
64 images.push_back( KiBitmapBundleDef( BITMAPS::info, c_iconSize ) ); // INFORMATION
65 images.push_back( KiBitmapBundleDef( BITMAPS::recent, c_iconSize ) ); // VERSION
66 images.push_back( KiBitmapBundleDef( BITMAPS::preference, c_iconSize ) ); // DEVELOPERS
67 images.push_back( KiBitmapBundleDef( BITMAPS::editor, c_iconSize ) ); // DOCWRITERS
68 images.push_back( KiBitmapBundleDef( BITMAPS::library, c_iconSize ) ); // LIBRARIANS
69 images.push_back( KiBitmapBundleDef( BITMAPS::color_materials, c_iconSize ) ); // ARTISTS
70 images.push_back( KiBitmapBundleDef( BITMAPS::language, c_iconSize ) ); // TRANSLATORS
71 images.push_back( KiBitmapBundleDef( BITMAPS::zip, c_iconSize ) ); // PACKAGERS
72 images.push_back( KiBitmapBundleDef( BITMAPS::tools, c_iconSize ) ); // LICENSE
73
74 m_notebook->SetImages( images );
75
76 if( m_info.GetAppIcon().IsOk() )
77 {
78 SetIcon( m_info.GetAppIcon() );
79 m_bitmapApp->SetBitmap( m_info.GetAppIcon() );
80 }
81 else
82 {
83 wxIcon icon;
84
85 if( IsNightlyVersion() )
86 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
87 else
88 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
89
90 SetIcon( icon );
91 m_bitmapApp->SetBitmap( icon );
92 }
93
94 m_titleName = aParent->GetAboutTitle();
97
98 // On windows, display the number of GDI objects in use. Can be useful when some GDI objects
99 // are not displayed because the max count of GDI objects (usually 10000) is reached
100 // So displaying this number can help to diagnose strange display issues
101 wxString extraInfo;
102
103 #if defined( _WIN32 )
104 uint32_t gdi_count = GetGuiResources( GetCurrentProcess(), GR_GDIOBJECTS );
105 extraInfo.Printf( _( "GDI objects in use %u" ), gdi_count );
106 extraInfo.Prepend( wxT( "\n" ) );
107 #endif
108
109 m_staticTextBuildVersion->SetLabel( wxS( "Version: " ) + m_info.GetBuildVersion() );
110 m_staticTextLibVersion->SetLabel( m_info.GetLibVersion() + extraInfo );
111
112 SetTitle( wxString::Format( _( "About %s" ), m_titleName ) );
114
115 SetEvtHandlerEnabled( true );
116 GetSizer()->SetSizeHints( this );
117 SetFocus();
118 Centre();
119}
120
121
123{
124#ifndef __WXMAC__
125 delete m_images;
126#endif
127}
128
129
131{
133 m_info.GetDescription() );
134
135 wxString version = GetVersionInfoData( m_untranslatedTitleName, true );
136
137 createNotebookHtmlPage( m_notebook, _( "Version" ), IMAGES::VERSION, version, true );
138
140 m_info.GetDevelopers() );
142 m_info.GetDocWriters() );
143
145 m_info.GetLibrarians() );
146
148 m_info.GetArtists() );
150 m_info.GetTranslators() );
152 m_info.GetPackagers() );
153
154 createNotebookHtmlPage( m_notebook, _( "License" ), IMAGES::LICENSE, m_info.GetLicense() );
155}
156
157void DIALOG_ABOUT::createNotebookPageByCategory( wxNotebook* aParent, const wxString& aCaption,
158 IMAGES aIconIndex,
159 const CONTRIBUTORS& aContributors )
160{
161 wxString html;
162
163 for( size_t i=0; i < aContributors.GetCount(); ++i )
164 {
165 CONTRIBUTOR* contributor = &aContributors.Item( i );
166 wxString category = contributor->GetCategory();
167
168 // to construct the next row we expect to have a category and a contributor that was
169 // not considered up to now
170 if( category == wxEmptyString || contributor->IsChecked() )
171 continue;
172
173 html += wxString::Format( wxS( "<p><b><u>%s:</u></b><ul>" ),
174 contributor->GetCategory() );
175
176 // Now, all contributors of the same category will follow
177 for( size_t j=0; j < aContributors.GetCount(); ++j )
178 {
179 CONTRIBUTOR* sub_contributor = &aContributors.Item( j );
180
181 if ( sub_contributor->GetCategory() == category )
182 {
183 // No URL supplied, display normal text control
184 if( sub_contributor->GetUrl().IsEmpty() )
185 {
186 html += wxString::Format( wxS( "<li>%s</li>" ),
187 sub_contributor->GetName() );
188 }
189 else
190 {
191 html += wxString::Format( wxS( "<li><a href='%s'>%s</a></li>" ),
192 sub_contributor->GetUrl(),
193 sub_contributor->GetName() );
194 }
195
196 // this contributor was added to the GUI, thus can be ignored next time
197 sub_contributor->SetChecked( true );
198 }
199 }
200
201 html += wxS( "</ul></p>" );
202 }
203
204 createNotebookHtmlPage( aParent, aCaption, aIconIndex, html, true );
205}
206
207
208void DIALOG_ABOUT::createNotebookHtmlPage( wxNotebook* aParent, const wxString& aCaption,
209 IMAGES aIconIndex, const wxString& html,
210 bool aSelection )
211{
212 wxPanel* panel = new wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
213 wxTAB_TRAVERSAL );
214
215 wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
216
217 int flags = aSelection ? wxHW_SCROLLBAR_AUTO : ( wxHW_SCROLLBAR_AUTO | wxHW_NO_SELECTION );
218
219 // the HTML page is going to be created with previously created HTML content
220 HTML_WINDOW* htmlWindow = new HTML_WINDOW( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
221 flags );
222
223 // HTML font set to font properties as they are used for widgets to have an unique look
224 // under different platforms with HTML
225 wxFont font = GetFont();
226 htmlWindow->SetStandardFonts( font.GetPointSize(), font.GetFaceName(), font.GetFaceName() );
227 htmlWindow->SetPage( html );
228
229 // the HTML window shall not be used to open external links, thus this task is delegated
230 // to users default browser
231 htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
232 wxHtmlLinkEventHandler( DIALOG_ABOUT::onHtmlLinkClicked ), NULL, this );
233
234 // no additional space around the HTML window as it is also the case by the other notebook
235 // pages
236 bSizer->Add( htmlWindow, 1, wxEXPAND, 0 );
237 panel->SetSizer( bSizer );
238
239 aParent->AddPage( panel, aCaption, false, static_cast<int>( aIconIndex ) );
240}
241
242
243void DIALOG_ABOUT::onHtmlLinkClicked( wxHtmlLinkEvent& event )
244{
245 ::wxLaunchDefaultBrowser( event.GetLinkInfo().GetHref() );
246}
247
248
249void DIALOG_ABOUT::onCopyVersionInfo( wxCommandEvent& event )
250{
251 wxLogNull doNotLog; // disable logging of failed clipboard actions
252
253 if( !wxTheClipboard->Open() )
254 {
255 wxMessageBox( _( "Could not open clipboard to write version information." ),
256 _( "Clipboard Error" ), wxOK | wxICON_EXCLAMATION, this );
257 return;
258 }
259
260 wxString msg_version = GetVersionInfoData( m_untranslatedTitleName );
261
262 wxTheClipboard->SetData( new wxTextDataObject( msg_version ) );
263 wxTheClipboard->Flush(); // Allow clipboard data to be available after KiCad closes
264 wxTheClipboard->Close();
265 m_btCopyVersionInfo->SetLabel( _( "Copied..." ) );
266}
267
268
269void DIALOG_ABOUT::onDonateClick( wxCommandEvent& event )
270{
271 if( TOOL_MANAGER* mgr = static_cast<EDA_BASE_FRAME*>( GetParent() )->GetToolManager() )
272 mgr->RunAction( "common.SuiteControl.donate" );
273}
274
275
276void DIALOG_ABOUT::onReportBug( wxCommandEvent& event )
277{
278 if( TOOL_MANAGER* mgr = static_cast<EDA_BASE_FRAME*>( GetParent() )->GetToolManager() )
279 mgr->RunAction( "common.SuiteControl.reportBug" );
280}
281
282
283void DIALOG_ABOUT::OnNotebookPageChanged( wxNotebookEvent& aEvent )
284{
285 // Work around wxMac issue where the notebook pages are blank
286#ifdef __WXMAC__
287 int page = aEvent.GetSelection();
288
289 if( page >= 0 )
290 m_notebook->ChangeSelection( static_cast<unsigned>( page ) );
291#endif
292}
wxBitmapBundle KiBitmapBundleDef(BITMAPS aBitmap, int aDefHeight)
Constructs and returns a bitmap bundle for the given icon ID, with the default bitmap size being aDef...
Definition bitmap.cpp:116
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition bitmap.cpp:104
@ icon_kicad_nightly
@ color_materials
wxString GetVersionInfoData(const wxString &aTitle, bool aHtml, bool aBrief)
Create a version info string for bug reports and the about dialog.
bool IsNightlyVersion()
Check if the build is meant to be nightly.
An object of this class is meant to be used to store application specific information like who has co...
Definition aboutinfo.h:45
A contributor, a person which was involved in the development of the application or which has contrib...
Definition aboutinfo.h:157
wxString & GetName()
Definition aboutinfo.h:170
wxString & GetUrl()
Definition aboutinfo.h:171
wxString & GetCategory()
Definition aboutinfo.h:172
bool IsChecked()
Definition aboutinfo.h:174
void SetChecked(bool status)
Definition aboutinfo.h:173
wxStaticText * m_staticTextBuildVersion
wxStaticBitmap * m_bitmapApp
DIALOG_ABOUT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("About"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(570, 500), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxStaticText * m_staticTextLibVersion
wxButton * m_btCopyVersionInfo
wxNotebook * m_notebook
wxStaticText * m_staticTextAppTitle
void OnNotebookPageChanged(wxNotebookEvent &aEvent) override
wxString m_titleName
wxImageList * m_images
wxString m_untranslatedTitleName
void createNotebooks()
ABOUT_APP_INFO & m_info
void createNotebookPageByCategory(wxNotebook *aParent, const wxString &aCaption, IMAGES aIconIndex, const CONTRIBUTORS &aContributors)
DIALOG_ABOUT(EDA_BASE_FRAME *aParent, ABOUT_APP_INFO &aAppInfo)
void onCopyVersionInfo(wxCommandEvent &event) override
void onHtmlLinkClicked(wxHtmlLinkEvent &event)
void onReportBug(wxCommandEvent &event) override
void onDonateClick(wxCommandEvent &event) override
void createNotebookHtmlPage(wxNotebook *aParent, const wxString &aCaption, IMAGES aIconIndex, const wxString &aHtmlMessage, bool aSelection=false)
The base frame for deriving all KiCad main window classes.
const wxString & GetUntranslatedAboutTitle() const
const wxString & GetAboutTitle() const
Add dark theme support to wxHtmlWindow.
Definition html_window.h:35
bool SetPage(const wxString &aSource) override
Master controller class:
IMAGES
@ TRANSLATORS
@ INFORMATION
#define _(s)
Base window classes and related definitions.