ui: Show license type label in title bar: "Sourcetrail [trial, test, non-commercial]"
This commit is contained in:
+19
-4
@@ -106,7 +106,7 @@ void Application::loadStyle(const FilePath& colorSchemePath)
|
||||
|
||||
Application::Application(bool withGUI)
|
||||
: m_hasGUI(withGUI)
|
||||
, m_isInTrial(true)
|
||||
, m_licenseType(MessageEnteredLicense::LICENSE_NONE)
|
||||
{
|
||||
LicenseChecker::createInstance();
|
||||
}
|
||||
@@ -156,7 +156,7 @@ std::shared_ptr<DialogView> Application::getDialogView()
|
||||
|
||||
bool Application::isInTrial() const
|
||||
{
|
||||
return m_isInTrial;
|
||||
return m_licenseType == MessageEnteredLicense::LICENSE_NONE;
|
||||
}
|
||||
|
||||
void Application::updateHistory(const std::vector<SearchMatch>& history)
|
||||
@@ -242,7 +242,7 @@ void Application::handleMessage(MessageEnteredLicense* message)
|
||||
{
|
||||
MessageStatus("Found valid license key, unlocked application.").dispatch();
|
||||
|
||||
m_isInTrial = false;
|
||||
m_licenseType = message->type;
|
||||
|
||||
updateTitle();
|
||||
}
|
||||
@@ -381,7 +381,22 @@ void Application::updateTitle()
|
||||
{
|
||||
if (m_hasGUI)
|
||||
{
|
||||
std::string title = m_isInTrial ? "Sourcetrail [Trial]" : "Sourcetrail";
|
||||
std::string title = "Sourcetrail";
|
||||
|
||||
switch (m_licenseType)
|
||||
{
|
||||
case MessageEnteredLicense::LICENSE_NONE:
|
||||
title += " [trial]";
|
||||
break;
|
||||
case MessageEnteredLicense::LICENSE_TEST:
|
||||
title += " [test]";
|
||||
break;
|
||||
case MessageEnteredLicense::LICENSE_NON_COMMERCIAL:
|
||||
title += " [non-commercial]";
|
||||
break;
|
||||
case MessageEnteredLicense::LICENSE_COMMERCIAL:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_project)
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
|
||||
std::shared_ptr<IDECommunicationController> m_ideCommunicationController;
|
||||
|
||||
bool m_isInTrial;
|
||||
MessageEnteredLicense::LicenseType m_licenseType;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_H
|
||||
|
||||
@@ -128,6 +128,34 @@ LicenseChecker::LicenseState LicenseChecker::checkLicenseString(const std::strin
|
||||
return checkLicense(license);
|
||||
}
|
||||
|
||||
MessageEnteredLicense::LicenseType LicenseChecker::getCurrentLicenseType() const
|
||||
{
|
||||
License license;
|
||||
bool isLoaded = license.loadFromEncodedString(
|
||||
ApplicationSettings::getInstance()->getLicenseString(), AppPath::getAppPath());
|
||||
|
||||
if (!isLoaded)
|
||||
{
|
||||
return MessageEnteredLicense::LICENSE_NONE;
|
||||
}
|
||||
|
||||
LicenseState state = checkLicense(license);
|
||||
if (state != LICENSE_VALID)
|
||||
{
|
||||
return MessageEnteredLicense::LICENSE_NONE;
|
||||
}
|
||||
else if (license.isTestLicense())
|
||||
{
|
||||
return MessageEnteredLicense::LICENSE_TEST;
|
||||
}
|
||||
else if (license.isNonCommercialLicenseType())
|
||||
{
|
||||
return MessageEnteredLicense::LICENSE_NON_COMMERCIAL;
|
||||
}
|
||||
|
||||
return MessageEnteredLicense::LICENSE_COMMERCIAL;
|
||||
}
|
||||
|
||||
LicenseChecker::LicenseChecker()
|
||||
: m_forcedLicenseEntering(false)
|
||||
{
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
LicenseState checkCurrentLicense() const;
|
||||
LicenseState checkLicenseString(const std::string licenseString) const;
|
||||
|
||||
MessageEnteredLicense::LicenseType getCurrentLicenseType() const;
|
||||
|
||||
private:
|
||||
LicenseChecker();
|
||||
LicenseChecker(const LicenseChecker&) = delete;
|
||||
|
||||
@@ -7,7 +7,16 @@ class MessageEnteredLicense
|
||||
: public Message<MessageEnteredLicense>
|
||||
{
|
||||
public:
|
||||
MessageEnteredLicense()
|
||||
enum LicenseType
|
||||
{
|
||||
LICENSE_NONE,
|
||||
LICENSE_TEST,
|
||||
LICENSE_NON_COMMERCIAL,
|
||||
LICENSE_COMMERCIAL
|
||||
};
|
||||
|
||||
MessageEnteredLicense(LicenseType type)
|
||||
: type(type)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
@@ -16,6 +25,8 @@ public:
|
||||
{
|
||||
return "MessageEnteredLicense";
|
||||
}
|
||||
|
||||
const LicenseType type;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ENTERED_LICENSE_H
|
||||
|
||||
Reference in New Issue
Block a user