Tweak the default wxApp::GetAppDisplayName() logic.
Don't capitalize the app name if it had been explicitly set with SetAppName() as this can result in unexpectedly wrong value. Do capitalize the program name which is used as app name by default and don't store the program name in m_appName to be able to distinguish between the two cases. Closes #11165. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61821 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -136,22 +136,17 @@ public:
|
|||||||
// be argv[0]
|
// be argv[0]
|
||||||
|
|
||||||
// set/get the application name
|
// set/get the application name
|
||||||
wxString GetAppName() const
|
wxString GetAppName() const;
|
||||||
{
|
|
||||||
return m_appName.empty() ? m_className : m_appName;
|
|
||||||
}
|
|
||||||
void SetAppName(const wxString& name) { m_appName = name; }
|
void SetAppName(const wxString& name) { m_appName = name; }
|
||||||
|
|
||||||
// set/get the application display name: the display name is the name
|
// set/get the application display name: the display name is the name
|
||||||
// shown to the user in titles, reports, etc while the app name is
|
// shown to the user in titles, reports, etc while the app name is
|
||||||
// used for paths, config, and other places the user doesn't see
|
// used for paths, config, and other places the user doesn't see
|
||||||
//
|
//
|
||||||
// so the app name could be myapp while display name could be "My App"
|
// by default the display name is the same as app name or a capitalized
|
||||||
wxString GetAppDisplayName() const
|
// version of the program if app name was not set neither but it's
|
||||||
{
|
// usually better to set it explicitly to something nicer
|
||||||
return m_appDisplayName.empty() ? GetAppName().Capitalize()
|
wxString GetAppDisplayName() const;
|
||||||
: m_appDisplayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAppDisplayName(const wxString& name) { m_appDisplayName = name; }
|
void SetAppDisplayName(const wxString& name) { m_appDisplayName = name; }
|
||||||
|
|
||||||
|
@@ -495,8 +495,13 @@ public:
|
|||||||
is that this one is meant to be shown to the user and so should be used
|
is that this one is meant to be shown to the user and so should be used
|
||||||
for the window titles, page headers and so on while the other one
|
for the window titles, page headers and so on while the other one
|
||||||
should be only used internally, e.g. for the file names or
|
should be only used internally, e.g. for the file names or
|
||||||
configuration file keys. By default, returns the application name as
|
configuration file keys.
|
||||||
returned by GetAppName() capitalized using wxString::Capitalize().
|
|
||||||
|
If the application name for display had been previously set by
|
||||||
|
SetAppDisplayName(), it will be returned by this function. Otherwise,
|
||||||
|
if SetAppName() had been called its value will be returned; also as is.
|
||||||
|
Finally if none was called, this function returns the program name
|
||||||
|
capitalized using wxString::Capitalize().
|
||||||
|
|
||||||
@since 2.9.0
|
@since 2.9.0
|
||||||
*/
|
*/
|
||||||
@@ -505,8 +510,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
Returns the application name.
|
Returns the application name.
|
||||||
|
|
||||||
@remarks wxWidgets sets this to a reasonable default before calling
|
If SetAppName() had been called, returns the string passed to it.
|
||||||
OnInit(), but the application can reset it at will.
|
Otherwise returns the program name, i.e. the value of @c argv[0] passed
|
||||||
|
to the @c main() function.
|
||||||
|
|
||||||
@see GetAppDisplayName()
|
@see GetAppDisplayName()
|
||||||
*/
|
*/
|
||||||
|
@@ -161,21 +161,45 @@ wxAppConsoleBase::~wxAppConsoleBase()
|
|||||||
// initialization/cleanup
|
// initialization/cleanup
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxAppConsoleBase::Initialize(int& WXUNUSED(argc), wxChar **argv)
|
bool wxAppConsoleBase::Initialize(int& WXUNUSED(argc), wxChar **WXUNUSED(argv))
|
||||||
{
|
{
|
||||||
#if wxUSE_INTL
|
#if wxUSE_INTL
|
||||||
GetTraits()->SetLocale();
|
GetTraits()->SetLocale();
|
||||||
#endif // wxUSE_INTL
|
#endif // wxUSE_INTL
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxAppConsoleBase::GetAppName() const
|
||||||
|
{
|
||||||
|
wxString name = m_appName;
|
||||||
#ifndef __WXPALMOS__
|
#ifndef __WXPALMOS__
|
||||||
if ( m_appName.empty() && argv && argv[0] )
|
if ( name.empty() )
|
||||||
{
|
{
|
||||||
// the application name is, by default, the name of its executable file
|
if ( argv )
|
||||||
wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL);
|
{
|
||||||
|
// the application name is, by default, the name of its executable file
|
||||||
|
wxFileName::SplitPath(argv[0], NULL, &name, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // !__WXPALMOS__
|
#endif // !__WXPALMOS__
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
wxString wxAppConsoleBase::GetAppDisplayName() const
|
||||||
|
{
|
||||||
|
// use the explicitly provided display name, if any
|
||||||
|
if ( !m_appDisplayName.empty() )
|
||||||
|
return m_appDisplayName;
|
||||||
|
|
||||||
|
// if the application name was explicitly set, use it as is as capitalizing
|
||||||
|
// it won't always produce good results
|
||||||
|
if ( !m_appName.empty() )
|
||||||
|
return m_appName;
|
||||||
|
|
||||||
|
// if neither is set, use the capitalized version of the program file as
|
||||||
|
// it's the most reasonable default
|
||||||
|
return GetAppName().Capitalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEventLoopBase *wxAppConsoleBase::CreateMainLoop()
|
wxEventLoopBase *wxAppConsoleBase::CreateMainLoop()
|
||||||
|
Reference in New Issue
Block a user