2014-10-19 20:20:16 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Rafael Sokolowski <Rafael.Sokolowski@web.de>
|
2021-10-06 02:46:53 +00:00
|
|
|
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.TXT for contributors.
|
2014-10-19 20:20:16 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2016-03-11 16:40:24 +00:00
|
|
|
|
2023-01-03 21:54:20 +00:00
|
|
|
#include <build_version.h>
|
2024-04-27 19:57:24 +00:00
|
|
|
#include <eda_base_frame.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/msgdlg.h>
|
2017-12-11 13:56:32 +00:00
|
|
|
#include <wx/hyperlink.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
/* All KiCad icons are linked into shared library 'libbitmaps.a'.
|
2016-03-11 16:40:24 +00:00
|
|
|
* Icons:
|
2020-12-24 19:37:30 +00:00
|
|
|
* preference_xpm; // Icon for 'Developers' tab
|
|
|
|
* editor_xpm; // Icon for 'Doc Writers' tab
|
|
|
|
* color_materials_xpm; // Icon for 'Artists' tab
|
|
|
|
* language_xpm; // Icon for 'Translators' tab
|
|
|
|
* right_xpm; // Right arrow icon for list items
|
|
|
|
* info_xpm; // Bulb for description tab
|
|
|
|
* tools_xpm; // Sheet of paper icon for license info tab
|
2016-03-11 16:40:24 +00:00
|
|
|
*/
|
|
|
|
#include <bitmaps.h>
|
2021-09-14 18:26:03 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2020-05-25 00:39:15 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
|
2017-08-18 14:56:49 +00:00
|
|
|
#include "dialog_about.h"
|
2016-03-11 16:40:24 +00:00
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
DIALOG_ABOUT::DIALOG_ABOUT( EDA_BASE_FRAME *aParent, ABOUT_APP_INFO& aAppInfo ) :
|
|
|
|
DIALOG_ABOUT_BASE( aParent ),
|
2024-03-12 15:17:30 +00:00
|
|
|
m_images( nullptr ),
|
2024-03-05 13:38:46 +00:00
|
|
|
m_info( aAppInfo )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2019-05-13 18:33:30 +00:00
|
|
|
wxASSERT( aParent != nullptr );
|
|
|
|
|
2022-12-15 19:35:35 +00:00
|
|
|
SetEvtHandlerEnabled( false );
|
2024-03-05 13:38:46 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// HiDPI-aware API; will be generally available in wxWidgets 3.4
|
|
|
|
wxVector<wxBitmapBundle> images;
|
|
|
|
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::info ) ); // INFORMATION
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::recent ) ); // VERSION
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::preference ) ); // DEVELOPERS
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::editor ) ); // DOCWRITERS
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::library ) ); // LIBRARIANS
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::color_materials ) ); // ARTISTS
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::language ) ); // TRANSLATORS
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::zip ) ); // PACKAGERS
|
|
|
|
images.push_back( KiBitmapBundle( BITMAPS::tools ) ); // LICENSE
|
|
|
|
|
|
|
|
m_notebook->SetImages( images );
|
|
|
|
#else
|
2020-10-10 16:38:04 +00:00
|
|
|
// TODO: Change these to 16x16 versions when available
|
2020-12-12 17:27:06 +00:00
|
|
|
m_images = new wxImageList( 24, 24, false, 9 );
|
2020-10-10 16:38:04 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
m_images->Add( KiBitmap( BITMAPS::info ) ); // INFORMATION
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::recent ) ); // VERSION
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::preference ) ); // DEVELOPERS
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::editor ) ); // DOCWRITERS
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::library ) ); // LIBRARIANS
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::color_materials ) ); // ARTISTS
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::language ) ); // TRANSLATORS
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::zip ) ); // PACKAGERS
|
|
|
|
m_images->Add( KiBitmap( BITMAPS::tools ) ); // LICENSE
|
2020-10-10 16:38:04 +00:00
|
|
|
|
|
|
|
m_notebook->SetImageList( m_images );
|
2024-03-05 13:38:46 +00:00
|
|
|
#endif
|
2017-08-18 06:06:45 +00:00
|
|
|
|
|
|
|
if( m_info.GetAppIcon().IsOk() )
|
|
|
|
{
|
|
|
|
SetIcon( m_info.GetAppIcon() );
|
|
|
|
m_bitmapApp->SetBitmap( m_info.GetAppIcon() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxIcon icon;
|
2023-01-03 21:54:20 +00:00
|
|
|
|
|
|
|
if( IsNightlyVersion() )
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly ) );
|
|
|
|
else
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
|
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
m_bitmapApp->SetBitmap( icon );
|
|
|
|
}
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2019-05-13 18:33:30 +00:00
|
|
|
m_titleName = aParent->GetAboutTitle();
|
2022-12-31 23:39:04 +00:00
|
|
|
m_untranslatedTitleName = aParent->GetUntranslatedAboutTitle();
|
2019-05-13 18:33:30 +00:00
|
|
|
m_staticTextAppTitle->SetLabel( m_titleName );
|
2017-08-18 06:06:45 +00:00
|
|
|
m_staticTextCopyright->SetLabel( m_info.GetCopyright() );
|
2023-01-22 14:41:33 +00:00
|
|
|
m_staticTextBuildVersion->SetLabel( wxS( "Version: " ) + m_info.GetBuildVersion() );
|
2017-08-18 06:06:45 +00:00
|
|
|
m_staticTextLibVersion->SetLabel( m_info.GetLibVersion() );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2019-05-13 18:33:30 +00:00
|
|
|
SetTitle( wxString::Format( _( "About %s" ), m_titleName ) );
|
2017-08-18 06:06:45 +00:00
|
|
|
createNotebooks();
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2022-12-15 19:35:35 +00:00
|
|
|
SetEvtHandlerEnabled( true );
|
2014-10-19 20:20:16 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2013-05-26 04:36:44 +00:00
|
|
|
SetFocus();
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
DIALOG_ABOUT::~DIALOG_ABOUT()
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2024-03-12 15:17:30 +00:00
|
|
|
#ifndef __WXMAC__
|
|
|
|
delete m_images;
|
|
|
|
#endif
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
void DIALOG_ABOUT::createNotebooks()
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookHtmlPage( m_notebook, _( "About" ), IMAGES::INFORMATION,
|
2021-10-14 19:45:38 +00:00
|
|
|
m_info.GetDescription() );
|
2020-02-21 02:17:32 +00:00
|
|
|
|
2022-12-31 23:39:04 +00:00
|
|
|
wxString version = GetVersionInfoData( m_untranslatedTitleName, true );
|
2020-02-21 02:17:32 +00:00
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookHtmlPage( m_notebook, _( "Version" ), IMAGES::VERSION, version, true );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookPageByCategory( m_notebook, _( "Developers" ) , IMAGES::DEVELOPERS,
|
2021-10-14 19:45:38 +00:00
|
|
|
m_info.GetDevelopers() );
|
2024-03-12 14:31:05 +00:00
|
|
|
createNotebookPageByCategory( m_notebook, _( "Doc Writers" ), IMAGES::DOCWRITERS,
|
|
|
|
m_info.GetDocWriters() );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookPageByCategory( m_notebook, _( "Librarians" ), IMAGES::LIBRARIANS,
|
2020-10-08 23:47:06 +00:00
|
|
|
m_info.GetLibrarians() );
|
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookPageByCategory( m_notebook, _( "Artists" ), IMAGES::ARTISTS,
|
2019-05-13 18:33:30 +00:00
|
|
|
m_info.GetArtists() );
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookPageByCategory( m_notebook, _( "Translators" ), IMAGES::TRANSLATORS,
|
2017-08-18 06:06:45 +00:00
|
|
|
m_info.GetTranslators() );
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookPageByCategory( m_notebook, _( "Packagers" ), IMAGES::PACKAGERS,
|
2017-08-18 06:06:45 +00:00
|
|
|
m_info.GetPackagers() );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
createNotebookHtmlPage( m_notebook, _( "License" ), IMAGES::LICENSE, m_info.GetLicense() );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
void DIALOG_ABOUT::createNotebookPageByCategory( wxNotebook* aParent, const wxString& aCaption,
|
|
|
|
IMAGES aIconIndex,
|
|
|
|
const CONTRIBUTORS& aContributors )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2024-03-12 14:31:05 +00:00
|
|
|
wxString html;
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2016-04-18 18:15:44 +00:00
|
|
|
for( size_t i=0; i < aContributors.GetCount(); ++i )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2017-08-18 06:06:45 +00:00
|
|
|
CONTRIBUTOR* contributor = &aContributors.Item( i );
|
2024-03-12 14:31:05 +00:00
|
|
|
wxString category = contributor->GetCategory();
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
// to construct the next row we expect to have a category and a contributor that was
|
|
|
|
// not considered up to now
|
|
|
|
if( category == wxEmptyString || contributor->IsChecked() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
html += wxString::Format( wxS( "<p><b><u>%s:</u></b><ul>" ),
|
|
|
|
contributor->GetCategory() );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
// Now, all contributors of the same category will follow
|
|
|
|
for( size_t j=0; j < aContributors.GetCount(); ++j )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2024-03-12 14:31:05 +00:00
|
|
|
CONTRIBUTOR* sub_contributor = &aContributors.Item( j );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
if ( sub_contributor->GetCategory() == category )
|
|
|
|
{
|
|
|
|
// No URL supplied, display normal text control
|
|
|
|
if( sub_contributor->GetUrl().IsEmpty() )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2024-03-12 14:31:05 +00:00
|
|
|
html += wxString::Format( wxS( "<li>%s</li>" ),
|
|
|
|
sub_contributor->GetName() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
html += wxString::Format( wxS( "<li><a href='%s'>%s</a></li>" ),
|
|
|
|
sub_contributor->GetUrl(),
|
|
|
|
sub_contributor->GetName() );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
// this contributor was added to the GUI, thus can be ignored next time
|
|
|
|
sub_contributor->SetChecked( true );
|
|
|
|
}
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
html += wxS( "</ul></p>" );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
createNotebookHtmlPage( aParent, aCaption, aIconIndex, html, true );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2020-10-10 16:38:04 +00:00
|
|
|
void DIALOG_ABOUT::createNotebookHtmlPage( wxNotebook* aParent, const wxString& aCaption,
|
|
|
|
IMAGES aIconIndex, const wxString& html,
|
2020-02-22 16:23:47 +00:00
|
|
|
bool aSelection )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2016-04-18 18:15:44 +00:00
|
|
|
wxPanel* panel = new wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
2014-10-19 20:20:16 +00:00
|
|
|
wxTAB_TRAVERSAL );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
2020-02-22 16:23:47 +00:00
|
|
|
int flags = aSelection ? wxHW_SCROLLBAR_AUTO : ( wxHW_SCROLLBAR_AUTO | wxHW_NO_SELECTION );
|
|
|
|
|
2015-11-19 20:03:02 +00:00
|
|
|
// the HTML page is going to be created with previously created HTML content
|
2021-10-14 19:45:38 +00:00
|
|
|
HTML_WINDOW* htmlWindow = new HTML_WINDOW( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
flags );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
// HTML font set to font properties as they are used for widgets to have an unique look
|
|
|
|
// under different platforms with HTML
|
2021-02-09 16:35:43 +00:00
|
|
|
wxFont font = GetFont();
|
2013-05-26 04:36:44 +00:00
|
|
|
htmlWindow->SetStandardFonts( font.GetPointSize(), font.GetFaceName(), font.GetFaceName() );
|
2021-10-10 12:52:37 +00:00
|
|
|
htmlWindow->SetPage( html );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
// the HTML window shall not be used to open external links, thus this task is delegated
|
|
|
|
// to users default browser
|
|
|
|
htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
|
2017-08-18 06:06:45 +00:00
|
|
|
wxHtmlLinkEventHandler( DIALOG_ABOUT::onHtmlLinkClicked ), NULL, this );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2024-03-12 14:31:05 +00:00
|
|
|
// no additional space around the HTML window as it is also the case by the other notebook
|
|
|
|
// pages
|
2020-10-10 16:38:04 +00:00
|
|
|
bSizer->Add( htmlWindow, 1, wxEXPAND, 0 );
|
2013-05-26 04:36:44 +00:00
|
|
|
panel->SetSizer( bSizer );
|
2020-10-10 16:38:04 +00:00
|
|
|
|
|
|
|
aParent->AddPage( panel, aCaption, false, static_cast<int>( aIconIndex ) );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
void DIALOG_ABOUT::onHtmlLinkClicked( wxHtmlLinkEvent& event )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2017-08-18 06:06:45 +00:00
|
|
|
::wxLaunchDefaultBrowser( event.GetLinkInfo().GetHref() );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 20:20:16 +00:00
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
void DIALOG_ABOUT::onCopyVersionInfo( wxCommandEvent& event )
|
|
|
|
{
|
2021-01-29 19:13:12 +00:00
|
|
|
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
|
|
|
|
2017-08-18 06:06:45 +00:00
|
|
|
if( !wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Could not open clipboard to write version information." ),
|
|
|
|
_( "Clipboard Error" ), wxOK | wxICON_EXCLAMATION, this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-31 23:39:04 +00:00
|
|
|
wxString msg_version = GetVersionInfoData( m_untranslatedTitleName );
|
2016-09-03 18:36:20 +00:00
|
|
|
|
2016-03-11 16:40:24 +00:00
|
|
|
wxTheClipboard->SetData( new wxTextDataObject( msg_version ) );
|
2021-01-30 15:43:26 +00:00
|
|
|
wxTheClipboard->Flush(); // Allow clipboard data to be available after KiCad closes
|
2016-03-11 16:40:24 +00:00
|
|
|
wxTheClipboard->Close();
|
2017-08-18 06:06:45 +00:00
|
|
|
m_btCopyVersionInfo->SetLabel( _( "Copied..." ) );
|
2016-03-11 16:40:24 +00:00
|
|
|
}
|
2020-02-21 02:17:32 +00:00
|
|
|
|
|
|
|
|
2021-12-15 18:02:01 +00:00
|
|
|
void DIALOG_ABOUT::onDonateClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( TOOL_MANAGER* mgr = static_cast<EDA_BASE_FRAME*>( GetParent() )->GetToolManager() )
|
2023-06-26 22:16:51 +00:00
|
|
|
mgr->RunAction( "common.SuiteControl.donate" );
|
2021-12-15 18:02:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-21 02:17:32 +00:00
|
|
|
void DIALOG_ABOUT::onReportBug( wxCommandEvent& event )
|
|
|
|
{
|
2020-05-25 00:39:15 +00:00
|
|
|
if( TOOL_MANAGER* mgr = static_cast<EDA_BASE_FRAME*>( GetParent() )->GetToolManager() )
|
2023-06-26 22:16:51 +00:00
|
|
|
mgr->RunAction( "common.SuiteControl.reportBug" );
|
2020-02-21 02:17:32 +00:00
|
|
|
}
|
2020-10-10 16:38:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ABOUT::OnNotebookPageChanged( wxNotebookEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Work around wxMac issue where the notebook pages are blank
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
int page = aEvent.GetSelection();
|
|
|
|
|
|
|
|
if( page >= 0 )
|
|
|
|
m_notebook->ChangeSelection( static_cast<unsigned>( page ) );
|
|
|
|
#endif
|
|
|
|
}
|