logic: iterated on license checking
- moved LicenseChecker from App to Lib project - added MessageDispatchWhenLicenseValid. This message takes another message as an argument which is dispatched once the LicenseChecher confirms the current license key or (if the key is invalid) once the user entered a valid key. This message is used when messages are sent that should not be working when no license key has been entered (LoadProject or ActivateTokenLocation via the IDE communication). - added MessageShowStartScreen which makes the MainView display this screen. This message is also sent via the MessageDispatchWhenLicenseValid. - removed startup project from appsettings.
This commit is contained in:
+84
-81
@@ -123,85 +123,6 @@ else()
|
||||
set(BOTAN_INCLUDE_DIR "$ENV{BOTAN_DIR}")
|
||||
endif()
|
||||
|
||||
# Lib --------------------------------------------------------------------------
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
|
||||
|
||||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/external)
|
||||
|
||||
set_source_files_properties(${EXTERNAL_FILES} PROPERTIES COMPILE_FLAGS "-w")
|
||||
set_source_files_properties(${EXTERNAL_C_FILES} PROPERTIES COMPILE_FLAGS "-std=gnu89 -w")
|
||||
|
||||
add_library(${LIB_PROJECT_NAME} ${LIB_FILES} ${EXTERNAL_FILES} ${EXTERNAL_C_FILES})
|
||||
|
||||
create_source_groups(${LIB_FILES})
|
||||
create_source_groups(${EXTERNAL_FILES})
|
||||
create_source_groups(${EXTERNAL_C_FILES})
|
||||
|
||||
set_target_properties(
|
||||
${LIB_PROJECT_NAME}
|
||||
PROPERTIES
|
||||
DEBUG_OUTPUT_NAME ${PROJECT_NAME}_d
|
||||
RELEASE_OUTPUT_NAME ${PROJECT_NAME}
|
||||
)
|
||||
|
||||
set_property(
|
||||
TARGET ${LIB_PROJECT_NAME}
|
||||
PROPERTY INCLUDE_DIRECTORIES
|
||||
"${CMAKE_SOURCE_DIR}/src/lib"
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_PROJECT_NAME} SYSTEM
|
||||
PUBLIC ${LLVM_INCLUDE_DIRS}
|
||||
${CLANG_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${EIGEN_ROOT}
|
||||
"${CMAKE_SOURCE_DIR}/src/external"
|
||||
)
|
||||
|
||||
target_link_libraries(${LIB_PROJECT_NAME} ${Boost_LIBRARIES})
|
||||
|
||||
# Lib Parser -------------------------------------------------------------------
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_parser)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_parser)
|
||||
|
||||
add_subdirectory(src/lib_parser)
|
||||
|
||||
set_source_files_properties(${CLANG_FILES} PROPERTIES COMPILE_FLAGS "-fno-rtti")
|
||||
|
||||
add_library(${LIB_PARSER_PROJECT_NAME} ${CLANG_FILES})
|
||||
|
||||
create_source_groups(${CLANG_FILES})
|
||||
|
||||
set_property(
|
||||
TARGET ${LIB_PARSER_PROJECT_NAME}
|
||||
PROPERTY INCLUDE_DIRECTORIES
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_parser"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib"
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
${LIB_PARSER_PROJECT_NAME}
|
||||
PROPERTIES
|
||||
DEBUG_OUTPUT_NAME ${LIB_PARSER_PROJECT_NAME}_d
|
||||
RELEASE_OUTPUT_NAME ${LIB_PARSER_PROJECT_NAME}
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_PARSER_PROJECT_NAME} SYSTEM
|
||||
PUBLIC ${LLVM_INCLUDE_DIRS}
|
||||
${CLANG_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
|
||||
llvm_map_components_to_libnames(REQ_LLVM_LIBS support core libdriver)
|
||||
|
||||
#target_link_libraries(${LIB_PARSER_PROJECT_NAME} ${CLANG_LIBRARIES} ${LLVM_AVAILABLE_LIBS})
|
||||
target_link_libraries(${LIB_PARSER_PROJECT_NAME} ${CLANG_LIBRARIES} ${REQ_LLVM_LIBS})
|
||||
|
||||
# Lib License -------------------------------------------------------------------
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_license)
|
||||
@@ -246,6 +167,86 @@ else()
|
||||
target_link_libraries(${LIB_LICENSE_PROJECT_NAME} optimized ${BOTAN})
|
||||
endif()
|
||||
|
||||
# Lib --------------------------------------------------------------------------
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib)
|
||||
|
||||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/external)
|
||||
|
||||
set_source_files_properties(${EXTERNAL_FILES} PROPERTIES COMPILE_FLAGS "-w")
|
||||
set_source_files_properties(${EXTERNAL_C_FILES} PROPERTIES COMPILE_FLAGS "-std=gnu89 -w")
|
||||
|
||||
add_library(${LIB_PROJECT_NAME} ${LIB_FILES} ${EXTERNAL_FILES} ${EXTERNAL_C_FILES})
|
||||
|
||||
create_source_groups(${LIB_FILES})
|
||||
create_source_groups(${EXTERNAL_FILES})
|
||||
create_source_groups(${EXTERNAL_C_FILES})
|
||||
|
||||
set_target_properties(
|
||||
${LIB_PROJECT_NAME}
|
||||
PROPERTIES
|
||||
DEBUG_OUTPUT_NAME ${PROJECT_NAME}_d
|
||||
RELEASE_OUTPUT_NAME ${PROJECT_NAME}
|
||||
)
|
||||
|
||||
set_property(
|
||||
TARGET ${LIB_PROJECT_NAME}
|
||||
PROPERTY INCLUDE_DIRECTORIES
|
||||
"${CMAKE_SOURCE_DIR}/src/lib"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_license"
|
||||
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_PROJECT_NAME} SYSTEM
|
||||
PUBLIC ${LLVM_INCLUDE_DIRS}
|
||||
${CLANG_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${EIGEN_ROOT}
|
||||
"${CMAKE_SOURCE_DIR}/src/external"
|
||||
)
|
||||
|
||||
target_link_libraries(${LIB_PROJECT_NAME} ${Boost_LIBRARIES} ${LIB_LICENSE_PROJECT_NAME})
|
||||
|
||||
# Lib Parser -------------------------------------------------------------------
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_parser)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_parser)
|
||||
|
||||
add_subdirectory(src/lib_parser)
|
||||
|
||||
set_source_files_properties(${CLANG_FILES} PROPERTIES COMPILE_FLAGS "-fno-rtti")
|
||||
|
||||
add_library(${LIB_PARSER_PROJECT_NAME} ${CLANG_FILES})
|
||||
|
||||
create_source_groups(${CLANG_FILES})
|
||||
|
||||
set_property(
|
||||
TARGET ${LIB_PARSER_PROJECT_NAME}
|
||||
PROPERTY INCLUDE_DIRECTORIES
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_parser"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib"
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
${LIB_PARSER_PROJECT_NAME}
|
||||
PROPERTIES
|
||||
DEBUG_OUTPUT_NAME ${LIB_PARSER_PROJECT_NAME}_d
|
||||
RELEASE_OUTPUT_NAME ${LIB_PARSER_PROJECT_NAME}
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_PARSER_PROJECT_NAME} SYSTEM
|
||||
PUBLIC ${LLVM_INCLUDE_DIRS}
|
||||
${CLANG_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
|
||||
llvm_map_components_to_libnames(REQ_LLVM_LIBS support core libdriver)
|
||||
|
||||
target_link_libraries(${LIB_PARSER_PROJECT_NAME} ${CLANG_LIBRARIES} ${REQ_LLVM_LIBS})
|
||||
|
||||
# Lib Gui ----------------------------------------------------------------------
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib_gui)
|
||||
@@ -368,7 +369,7 @@ if (WIN32)
|
||||
"IDI_ICON1 ICON \"${CMAKE_SOURCE_DIR}/build/coati.ico\"\n"
|
||||
)
|
||||
|
||||
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${CLANG_FILES} ${GEN_FILES} ${CMAKE_SOURCE_DIR}/build/Coati.rc ${CMAKE_SOURCE_DIR}/build/src/lib_gui/version.h)
|
||||
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${CLANG_FILES} ${GEN_FILES} ${CMAKE_SOURCE_DIR}/build/Coati.rc)
|
||||
|
||||
# hide the console when running a release build.
|
||||
set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||
@@ -378,7 +379,7 @@ if (WIN32)
|
||||
set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:WINDOWS")
|
||||
set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
|
||||
else ()
|
||||
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${GEN_FILES} ${CMAKE_SOURCE_DIR}/build/src/lib_gui/version.h)
|
||||
add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${GEN_FILES})
|
||||
endif ()
|
||||
|
||||
create_source_groups(${APP_FILES})
|
||||
@@ -394,6 +395,7 @@ set_property(
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_license"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_parser"
|
||||
"${CMAKE_SOURCE_DIR}/build/src/lib_gui"
|
||||
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
|
||||
"${CMAKE_SOURCE_DIR}/build/src/app"
|
||||
)
|
||||
|
||||
@@ -460,6 +462,7 @@ set_property(
|
||||
"${CMAKE_SOURCE_DIR}/src/lib"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_gui"
|
||||
"${CMAKE_SOURCE_DIR}/build/src/lib_gui"
|
||||
"${CMAKE_SOURCE_DIR}/build/src/lib_license"
|
||||
)
|
||||
|
||||
target_include_directories(${TRIAL_PROJECT_NAME} SYSTEM
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
<!-- COLOR: int int int int - rgba e.g. 125 125 125 255 -->
|
||||
|
||||
<config>
|
||||
<startup_project><!-- STRING: path to project settings xml file --></startup_project>
|
||||
|
||||
<source>
|
||||
<compiler_flags>
|
||||
<compiler_flag><!-- STRING: compiler flag, including the dash e.g. -v --></compiler_flag>
|
||||
|
||||
@@ -18,5 +18,5 @@ endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/PublicKey.h.in
|
||||
${CMAKE_SOURCE_DIR}/build/src/lib_gui/PublicKey.h
|
||||
${CMAKE_SOURCE_DIR}/build/src/lib_license/PublicKey.h
|
||||
)
|
||||
@@ -7,6 +7,5 @@ add_files(
|
||||
utility/commandline/CommandLineParser.h
|
||||
|
||||
isTrial.cpp
|
||||
LicenseChecker.h
|
||||
main.cpp
|
||||
)
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
#ifndef LICENSE_CHECKER_H
|
||||
#define LICENSE_CHECKER_H
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "utility/AppPath.h"
|
||||
|
||||
class LicenseChecker
|
||||
: public MessageListener<MessageEnteredLicense>
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageProjectNew>
|
||||
, public MessageListener<MessageActivateTokenLocations>
|
||||
{
|
||||
public:
|
||||
LicenseChecker()
|
||||
: m_forcedLicenseEntering(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline void setApp(Application* app)
|
||||
{
|
||||
m_app = app;
|
||||
if (!m_forcedLicenseEntering && !checkLicenseString())
|
||||
{
|
||||
m_app->showLicenseScreen();
|
||||
m_forcedLicenseEntering = true;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void handleMessage(MessageEnteredLicense* message)
|
||||
{
|
||||
m_forcedLicenseEntering = false;
|
||||
|
||||
if (m_resendMessage)
|
||||
{
|
||||
m_resendMessage->dispatch();
|
||||
m_resendMessage.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void handleMessage(MessageLoadProject* message)
|
||||
{
|
||||
if (!checkLicenseString())
|
||||
{
|
||||
m_resendMessage = std::make_shared<MessageLoadProject>(*message);
|
||||
message->cancel();
|
||||
|
||||
if (!m_forcedLicenseEntering)
|
||||
{
|
||||
m_app->showLicenseScreen();
|
||||
m_forcedLicenseEntering = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleMessage(MessageProjectNew* message)
|
||||
{
|
||||
if (!checkLicenseString())
|
||||
{
|
||||
m_resendMessage = std::make_shared<MessageProjectNew>(*message);
|
||||
message->cancel();
|
||||
|
||||
if (!m_forcedLicenseEntering)
|
||||
{
|
||||
m_app->showLicenseScreen();
|
||||
m_forcedLicenseEntering = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleMessage(MessageActivateTokenLocations* message)
|
||||
{
|
||||
if (!checkLicenseString())
|
||||
{
|
||||
m_resendMessage = std::make_shared<MessageActivateTokenLocations>(*message);
|
||||
message->cancel();
|
||||
|
||||
if (!m_forcedLicenseEntering)
|
||||
{
|
||||
m_app->showLicenseScreen();
|
||||
m_forcedLicenseEntering = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline bool checkLicenseString()
|
||||
{
|
||||
MessageStatus("preparing...", false, true).dispatch();
|
||||
|
||||
bool valid = false;
|
||||
do
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
|
||||
std::string licenseCheck = appSettings->getLicenseCheck();
|
||||
std::string appPath = AppPath::getAppPath(); // for easier debugging...
|
||||
FilePath p(appPath);
|
||||
|
||||
if (!License::checkLocation(p.absolute().str(), licenseCheck))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
std::string licenseString = appSettings->getLicenseString();
|
||||
if (licenseString.size() == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
License license;
|
||||
bool isLoaded = license.loadFromEncodedString(licenseString,AppPath::getAppPath());
|
||||
if (!isLoaded)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
license.loadPublicKeyFromString(PublicKey);
|
||||
valid = license.isValid();
|
||||
if (license.isExpired())
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
while (false);
|
||||
|
||||
MessageStatus("ready").dispatch();
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
Application* m_app;
|
||||
std::shared_ptr<MessageBase> m_resendMessage;
|
||||
bool m_forcedLicenseEntering;
|
||||
};
|
||||
|
||||
#endif // LICENSE_CHECKER_H
|
||||
+3
-3
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
// todo: set app of license checker.
|
||||
return qtApp.exec();
|
||||
}
|
||||
else
|
||||
@@ -81,12 +81,12 @@ int main(int argc, char *argv[])
|
||||
QtViewFactory viewFactory;
|
||||
QtNetworkFactory networkFactory;
|
||||
|
||||
LicenseChecker checker;
|
||||
std::shared_ptr<LicenseChecker> checker = LicenseChecker::getInstance();
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
|
||||
checker.setApp(app.get());
|
||||
checker->setApp(app.get());
|
||||
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
@@ -175,7 +176,9 @@ void CommandLineParser::projectLoad()
|
||||
{
|
||||
if (!m_projectFile.empty())
|
||||
{
|
||||
MessageLoadProject(m_projectFile, m_force).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(m_projectFile, m_force)
|
||||
).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/messaging/type/MessageShowStartScreen.h"
|
||||
#include "utility/scheduling/TaskScheduler.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/Version.h"
|
||||
@@ -31,18 +33,13 @@ std::shared_ptr<Application> Application::create(
|
||||
ptr->m_mainView = viewFactory->createMainView();
|
||||
ptr->m_mainView->setTitle("Coati");
|
||||
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageShowStartScreen>()).dispatch();
|
||||
|
||||
ptr->m_componentManager->setup(ptr->m_mainView.get());
|
||||
ptr->m_mainView->loadLayout();
|
||||
|
||||
ptr->m_project = Project::create(ptr->m_storageCache.get());
|
||||
|
||||
std::string startupProjectFilePath = ApplicationSettings::getInstance()->getStartupProjectFilePath();
|
||||
if (startupProjectFilePath.size())
|
||||
{
|
||||
MessageLoadProject(startupProjectFilePath, false).dispatch();
|
||||
ptr->m_mainView->hideStartScreen();
|
||||
}
|
||||
|
||||
ptr->m_ideCommunicationController = networkFactory->createIDECommunicationController(ptr->m_storageCache.get());
|
||||
|
||||
ptr->startMessagingAndScheduling();
|
||||
@@ -138,11 +135,11 @@ void Application::saveProject(const FilePath& projectSettingsFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
void Application::showLicenseScreen()
|
||||
void Application::forceEnterLicense()
|
||||
{
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_mainView->showLicenseScreen();
|
||||
m_mainView->forceLicenseScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void loadProject(const FilePath& projectSettingsFilePath);
|
||||
void refreshProject();
|
||||
void saveProject(const FilePath& projectSettingsFilePath);
|
||||
void showLicenseScreen();
|
||||
void forceEnterLicense();
|
||||
bool hasGUI();
|
||||
|
||||
private:
|
||||
|
||||
@@ -228,6 +228,7 @@ add_files(
|
||||
utility/messaging/type/MessageChangeFileView.h
|
||||
utility/messaging/type/MessageClearErrorCount.h
|
||||
utility/messaging/type/MessageDeactivateEdge.h
|
||||
utility/messaging/type/MessageDispatchWhenLicenseValid.h
|
||||
utility/messaging/type/MessageEnteredLicense.h
|
||||
utility/messaging/type/MessageFind.h
|
||||
utility/messaging/type/MessageFinishedParsing.h
|
||||
@@ -250,6 +251,7 @@ add_files(
|
||||
utility/messaging/type/MessageSearchAutocomplete.h
|
||||
utility/messaging/type/MessageShowErrors.h
|
||||
utility/messaging/type/MessageShowScope.h
|
||||
utility/messaging/type/MessageShowStartScreen.h
|
||||
utility/messaging/type/MessageStatus.h
|
||||
utility/messaging/type/MessageSwitchColorScheme.h
|
||||
utility/messaging/type/MessageUndo.h
|
||||
@@ -319,6 +321,8 @@ add_files(
|
||||
Application.cpp
|
||||
Application.h
|
||||
isTrial.h
|
||||
LicenseChecker.cpp
|
||||
LicenseChecker.h
|
||||
Project.cpp
|
||||
Project.h
|
||||
)
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#include "LicenseChecker.h"
|
||||
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
#include "License.h"
|
||||
#include "Application.h"
|
||||
#include "PublicKey.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "utility/AppPath.h"
|
||||
|
||||
void LicenseChecker::createInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<LicenseChecker>(new LicenseChecker());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<LicenseChecker> LicenseChecker::getInstance()
|
||||
{
|
||||
createInstance();
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
LicenseChecker::~LicenseChecker()
|
||||
{
|
||||
}
|
||||
|
||||
void LicenseChecker::setApp(Application* app)
|
||||
{
|
||||
m_app = app;
|
||||
}
|
||||
|
||||
LicenseChecker::LicenseChecker()
|
||||
: m_app(nullptr)
|
||||
, m_forcedLicenseEntering(false)
|
||||
{
|
||||
}
|
||||
|
||||
void LicenseChecker::handleMessage(MessageDispatchWhenLicenseValid* message)
|
||||
{
|
||||
if (m_app != nullptr && !checkLicenseString())
|
||||
{
|
||||
m_pendingMessage = message->content;
|
||||
|
||||
if (!m_forcedLicenseEntering)
|
||||
{
|
||||
m_app->forceEnterLicense();
|
||||
m_forcedLicenseEntering = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message->content->dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void LicenseChecker::handleMessage(MessageEnteredLicense* message)
|
||||
{
|
||||
m_forcedLicenseEntering = false;
|
||||
|
||||
if (m_pendingMessage)
|
||||
{
|
||||
m_pendingMessage->dispatch();
|
||||
m_pendingMessage.reset();
|
||||
}
|
||||
}
|
||||
|
||||
bool LicenseChecker::checkLicenseString()
|
||||
{
|
||||
MessageStatus("preparing...", false, true).dispatch();
|
||||
|
||||
bool valid = false;
|
||||
do
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
|
||||
std::string licenseCheck = appSettings->getLicenseCheck();
|
||||
std::string appPath = AppPath::getAppPath(); // for easier debugging...
|
||||
FilePath p(appPath);
|
||||
|
||||
if (!License::checkLocation(p.absolute().str(), licenseCheck))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
std::string licenseString = appSettings->getLicenseString();
|
||||
if (licenseString.size() == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
License license;
|
||||
bool isLoaded = license.loadFromEncodedString(licenseString,AppPath::getAppPath());
|
||||
if (!isLoaded)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
license.loadPublicKeyFromString(PublicKey);
|
||||
valid = license.isValid();
|
||||
if (license.isExpired())
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
while (false);
|
||||
|
||||
MessageStatus("ready").dispatch();
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
std::shared_ptr<LicenseChecker> LicenseChecker::s_instance;
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef LICENSE_CHECKER_H
|
||||
#define LICENSE_CHECKER_H
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
|
||||
class Application;
|
||||
|
||||
class LicenseChecker
|
||||
: public MessageListener<MessageDispatchWhenLicenseValid>
|
||||
, public MessageListener<MessageEnteredLicense>
|
||||
{
|
||||
public:
|
||||
static void createInstance();
|
||||
static std::shared_ptr<LicenseChecker> getInstance();
|
||||
|
||||
~LicenseChecker();
|
||||
|
||||
void setApp(Application* app);
|
||||
|
||||
private:
|
||||
LicenseChecker();
|
||||
LicenseChecker(const LicenseChecker&) = delete;
|
||||
void operator=(const LicenseChecker&) = delete;
|
||||
|
||||
void handleMessage(MessageDispatchWhenLicenseValid* message);
|
||||
void handleMessage(MessageEnteredLicense* message);
|
||||
bool checkLicenseString();
|
||||
|
||||
static std::shared_ptr<LicenseChecker> s_instance;
|
||||
|
||||
Application* m_app;
|
||||
std::shared_ptr<MessageBase> m_pendingMessage;
|
||||
bool m_forcedLicenseEntering;
|
||||
};
|
||||
|
||||
#endif // LICENSE_CHECKER_H
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
||||
#include "utility/messaging/type/MessageActivateWindow.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
@@ -83,14 +84,14 @@ void IDECommunicationController::handleSetActiveTokenMessage(const NetworkProtoc
|
||||
if (selectedLocationIds.size() > 0)
|
||||
{
|
||||
MessageStatus("Activating a source location from external succeeded.").dispatch();
|
||||
MessageActivateTokenLocations(selectedLocationIds).dispatch();
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageActivateTokenLocations>(selectedLocationIds)).dispatch();
|
||||
MessageActivateWindow().dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageStatus(
|
||||
"Activating a source location from external failed. No symbol(s) have been found at the selected location."
|
||||
).dispatch();
|
||||
).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,10 +102,10 @@ void IDECommunicationController::handleCreateProjectMessage(const NetworkProtoco
|
||||
{
|
||||
if (message.ideId == "vs")
|
||||
{
|
||||
MessageProjectNew msg;
|
||||
msg.setSolutionPath(message.solutionFileLocation);
|
||||
msg.ideId = message.ideId;
|
||||
msg.dispatch();
|
||||
std::shared_ptr<MessageProjectNew> msg = std::make_shared<MessageProjectNew>();
|
||||
msg->setSolutionPath(message.solutionFileLocation);
|
||||
msg->ideId = message.ideId;
|
||||
MessageDispatchWhenLicenseValid(msg).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -125,4 +126,4 @@ void IDECommunicationController::handleMessage(MessageMoveIDECursor* message)
|
||||
).dispatch();
|
||||
|
||||
sendMessage(networkMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
virtual void setTitle(const std::string& title) = 0;
|
||||
virtual void activateWindow() = 0;
|
||||
virtual void updateRecentProjectMenu() = 0;
|
||||
virtual void showLicenseScreen() = 0;
|
||||
virtual void forceLicenseScreen() = 0;
|
||||
};
|
||||
|
||||
#endif // MAIN_VIEW_H
|
||||
|
||||
@@ -18,11 +18,6 @@ ApplicationSettings::~ApplicationSettings()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getStartupProjectFilePath() const
|
||||
{
|
||||
return getValue<std::string>("startup_project", "");
|
||||
}
|
||||
|
||||
int ApplicationSettings::getMaxRecentProjectsCount() const
|
||||
{
|
||||
return 7;
|
||||
|
||||
@@ -12,8 +12,6 @@ public:
|
||||
static std::shared_ptr<ApplicationSettings> getInstance();
|
||||
~ApplicationSettings();
|
||||
|
||||
std::string getStartupProjectFilePath() const;
|
||||
|
||||
int getMaxRecentProjectsCount() const;
|
||||
|
||||
// source
|
||||
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
|
||||
protected:
|
||||
ColorScheme();
|
||||
ColorScheme(const ColorScheme&);
|
||||
void operator=(const ColorScheme&);
|
||||
ColorScheme(const ColorScheme&) = delete;
|
||||
void operator=(const ColorScheme&) = delete;
|
||||
|
||||
static std::shared_ptr<ColorScheme> s_instance;
|
||||
|
||||
|
||||
@@ -15,10 +15,14 @@ std::shared_ptr<MessageQueue> MessageQueue::getInstance()
|
||||
{
|
||||
s_instance = std::shared_ptr<MessageQueue>(new MessageQueue());
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
MessageQueue::~MessageQueue()
|
||||
{
|
||||
// TODO: remove remaining listeners. And tell them that they shouldn't unregister anymore.
|
||||
}
|
||||
|
||||
void MessageQueue::registerListener(MessageListenerBase* listener)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
||||
|
||||
@@ -15,6 +15,8 @@ class MessageQueue
|
||||
public:
|
||||
static std::shared_ptr<MessageQueue> getInstance();
|
||||
|
||||
~MessageQueue();
|
||||
|
||||
void registerListener(MessageListenerBase* listener);
|
||||
void unregisterListener(MessageListenerBase* listener);
|
||||
|
||||
@@ -38,8 +40,8 @@ private:
|
||||
static std::shared_ptr<MessageQueue> s_instance;
|
||||
|
||||
MessageQueue();
|
||||
MessageQueue(const MessageQueue&);
|
||||
void operator=(const MessageQueue&);
|
||||
MessageQueue(const MessageQueue&) = delete;
|
||||
void operator=(const MessageQueue&) = delete;
|
||||
|
||||
void processMessages();
|
||||
void sendMessage(std::shared_ptr<MessageBase> message);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_DISPATCH_WHEN_LICENSE_VALID_H
|
||||
#define MESSAGE_DISPATCH_WHEN_LICENSE_VALID_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageDispatchWhenLicenseValid
|
||||
: public Message<MessageDispatchWhenLicenseValid>
|
||||
{
|
||||
public:
|
||||
MessageDispatchWhenLicenseValid(std::shared_ptr<MessageBase> content)
|
||||
: content(content)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageDispatchWhenLicenseValid";
|
||||
}
|
||||
|
||||
std::shared_ptr<MessageBase> content;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_DISPATCH_WHEN_LICENSE_VALID_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MESSAGE_SHOW_START_SCREEN_H
|
||||
#define MESSAGE_SHOW_START_SCREEN_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageShowStartScreen
|
||||
: public Message<MessageShowStartScreen>
|
||||
{
|
||||
public:
|
||||
MessageShowStartScreen()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowStartScreen";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_START_SCREEN_H
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <QFileOpenEvent>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
|
||||
QtApplication::QtApplication(int& argc, char** argv)
|
||||
@@ -21,7 +22,9 @@ bool QtApplication::event(QEvent *event)
|
||||
|
||||
if (path.exists() && path.extension() == ".coatiproject")
|
||||
{
|
||||
MessageLoadProject(path.str(), false).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(path.str(), false)
|
||||
).dispatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
|
||||
QtMainView::QtMainView()
|
||||
: m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this))
|
||||
: m_createNewProjectFromSolutionFunctor(std::bind(&QtMainView::doCreateNewProjectFromSolution, this, std::placeholders::_1, std::placeholders::_2))
|
||||
, m_showStartScreenFunctor(std::bind(&QtMainView::doShowStartScreen, this))
|
||||
, m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this))
|
||||
, m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1))
|
||||
, m_activateWindowFunctor(std::bind(&QtMainView::doActivateWindow, this))
|
||||
, m_updateRecentProjectMenuFunctor(std::bind(&QtMainView::doUpdateRecentProjectMenu, this))
|
||||
, m_showLicenseScreenFunctor(std::bind(&QtMainView::doShowLicenseScreen, this))
|
||||
, m_forceLicenseScreenFunctor(std::bind(&QtMainView::doForceLicenseScreen, this))
|
||||
{
|
||||
m_window = std::make_shared<QtMainWindow>();
|
||||
m_window->show();
|
||||
m_window->init();
|
||||
}
|
||||
|
||||
QtMainView::~QtMainView()
|
||||
@@ -88,14 +89,32 @@ void QtMainView::updateRecentProjectMenu()
|
||||
m_updateRecentProjectMenuFunctor();
|
||||
}
|
||||
|
||||
void QtMainView::showLicenseScreen()
|
||||
void QtMainView::forceLicenseScreen()
|
||||
{
|
||||
m_showLicenseScreenFunctor();
|
||||
m_forceLicenseScreenFunctor();
|
||||
}
|
||||
|
||||
void QtMainView::doUpdateRecentProjectMenu()
|
||||
void QtMainView::handleMessage(MessageProjectNew* message)
|
||||
{
|
||||
m_window->updateRecentProjectMenu();
|
||||
if (message->ideId.size() != 0 && message->solutionPath.size() != 0)
|
||||
{
|
||||
m_createNewProjectFromSolutionFunctor(message->ideId, message->solutionPath);
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainView::handleMessage(MessageShowStartScreen* message)
|
||||
{
|
||||
m_showStartScreenFunctor();
|
||||
}
|
||||
|
||||
void QtMainView::doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
{
|
||||
m_window->newProjectFromSolution(ideId, solutionPath);
|
||||
}
|
||||
|
||||
void QtMainView::doShowStartScreen()
|
||||
{
|
||||
m_window->showStartScreen();
|
||||
}
|
||||
|
||||
void QtMainView::doHideStartScreen()
|
||||
@@ -116,7 +135,12 @@ void QtMainView::doActivateWindow()
|
||||
m_window->setFocus(Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
void QtMainView::doShowLicenseScreen()
|
||||
void QtMainView::doUpdateRecentProjectMenu()
|
||||
{
|
||||
m_window->updateRecentProjectMenu();
|
||||
}
|
||||
|
||||
void QtMainView::doForceLicenseScreen()
|
||||
{
|
||||
m_window->forceEnterLicense();
|
||||
}
|
||||
|
||||
@@ -9,11 +9,17 @@
|
||||
#include "component/view/MainView.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
#include "utility/messaging/type/MessageShowStartScreen.h"
|
||||
|
||||
class QtMainWindow;
|
||||
class View;
|
||||
|
||||
class QtMainView
|
||||
: public MainView
|
||||
, public MessageListener<MessageProjectNew>
|
||||
, public MessageListener<MessageShowStartScreen>
|
||||
{
|
||||
public:
|
||||
QtMainView();
|
||||
@@ -37,23 +43,30 @@ public:
|
||||
virtual void setTitle(const std::string& title);
|
||||
virtual void activateWindow();
|
||||
virtual void updateRecentProjectMenu();
|
||||
virtual void showLicenseScreen();
|
||||
virtual void forceLicenseScreen();
|
||||
|
||||
private:
|
||||
void handleMessage(MessageProjectNew* message);
|
||||
void handleMessage(MessageShowStartScreen* message);
|
||||
|
||||
void doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void doShowStartScreen();
|
||||
void doHideStartScreen();
|
||||
void doSetTitle(const std::string& title);
|
||||
void doActivateWindow();
|
||||
void doUpdateRecentProjectMenu();
|
||||
void doShowLicenseScreen();
|
||||
void doForceLicenseScreen();
|
||||
|
||||
std::shared_ptr<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
QtThreadedFunctor<const std::string&, const std::string&> m_createNewProjectFromSolutionFunctor;
|
||||
QtThreadedFunctor<> m_showStartScreenFunctor;
|
||||
QtThreadedFunctor<> m_hideStartScreenFunctor;
|
||||
QtThreadedFunctor<const std::string&> m_setTitleFunctor;
|
||||
QtThreadedFunctor<> m_activateWindowFunctor;
|
||||
QtThreadedFunctor<> m_updateRecentProjectMenuFunctor;
|
||||
QtThreadedFunctor<> m_showLicenseScreenFunctor;
|
||||
QtThreadedFunctor<> m_forceLicenseScreenFunctor;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_VIEW_H
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
@@ -130,7 +131,6 @@ void MouseWheelFilter::stopWaiting()
|
||||
QtMainWindow::QtMainWindow()
|
||||
: m_showDockWidgetTitleBars(true)
|
||||
, m_windowStack(this)
|
||||
, m_createNewProjectFunctor(std::bind(&QtMainWindow::doCreateNewProject, this, std::placeholders::_1))
|
||||
{
|
||||
setObjectName("QtMainWindow");
|
||||
setCentralWidget(nullptr);
|
||||
@@ -161,11 +161,6 @@ QtMainWindow::QtMainWindow()
|
||||
loadLayout();
|
||||
}
|
||||
|
||||
void QtMainWindow::init()
|
||||
{
|
||||
showStartScreen();
|
||||
}
|
||||
|
||||
QtMainWindow::~QtMainWindow()
|
||||
{
|
||||
if (m_recentProjectAction)
|
||||
@@ -285,12 +280,6 @@ void QtMainWindow::forceEnterLicense()
|
||||
enterLicenseWindow->setEnabled(true);
|
||||
}
|
||||
|
||||
void QtMainWindow::handleMessage(MessageProjectNew* message)
|
||||
{
|
||||
MessageProjectNew msg(*message);
|
||||
m_createNewProjectFunctor(msg);
|
||||
}
|
||||
|
||||
bool QtMainWindow::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowActivate)
|
||||
@@ -374,6 +363,12 @@ void QtMainWindow::newProject()
|
||||
wizzard->newProject();
|
||||
}
|
||||
|
||||
void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
{
|
||||
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
|
||||
wizzard->newProjectFromSolution(ideId, solutionPath);
|
||||
}
|
||||
|
||||
void QtMainWindow::openProject(const QString &path)
|
||||
{
|
||||
QString fileName = path;
|
||||
@@ -385,7 +380,9 @@ void QtMainWindow::openProject(const QString &path)
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
MessageLoadProject(fileName.toStdString(), false).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(fileName.toStdString(), false)
|
||||
).dispatch();
|
||||
m_windowStack.clearWindows();
|
||||
}
|
||||
}
|
||||
@@ -573,20 +570,6 @@ void QtMainWindow::toggleShowDockWidgetTitleBars()
|
||||
setShowDockWidgetTitleBars(!m_showDockWidgetTitleBars);
|
||||
}
|
||||
|
||||
void QtMainWindow::doCreateNewProject(MessageProjectNew message)
|
||||
{
|
||||
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
|
||||
|
||||
if (message.fromSolution())
|
||||
{
|
||||
wizzard->newProjectFromSolution(message.ideId ,message.solutionPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
wizzard->newProject();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::setupEditMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(tr("&Edit"), this);
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#include <QMainWindow>
|
||||
#include <QShortcut>
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "qt/window/QtWindowStack.h"
|
||||
|
||||
@@ -72,7 +69,6 @@ private:
|
||||
|
||||
class QtMainWindow
|
||||
: public QMainWindow
|
||||
, public MessageListener<MessageProjectNew>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -80,8 +76,6 @@ public:
|
||||
QtMainWindow();
|
||||
~QtMainWindow();
|
||||
|
||||
void init();
|
||||
|
||||
void addView(View* view);
|
||||
void removeView(View* view);
|
||||
|
||||
@@ -93,8 +87,6 @@ public:
|
||||
|
||||
void forceEnterLicense();
|
||||
|
||||
void handleMessage(MessageProjectNew* message);
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
@@ -113,6 +105,7 @@ public slots:
|
||||
void hideStartScreen();
|
||||
|
||||
void newProject();
|
||||
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void openProject(const QString &path = QString());
|
||||
void editProject();
|
||||
void openRecentProject();
|
||||
@@ -152,8 +145,6 @@ private:
|
||||
QtViewToggle* toggle;
|
||||
};
|
||||
|
||||
void doCreateNewProject(MessageProjectNew message);
|
||||
|
||||
void setupEditMenu();
|
||||
void setupProjectMenu();
|
||||
void setupViewMenu();
|
||||
@@ -178,8 +169,6 @@ private:
|
||||
QtWindowStack m_windowStack;
|
||||
|
||||
QShortcut* m_escapeShortcut;
|
||||
|
||||
QtThreadedFunctor<MessageProjectNew> m_createNewProjectFunctor;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_WINDOW_H
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
@@ -31,7 +32,7 @@ void QtRecentProjectButton::setProjectPath(const FilePath& projectFilePath)
|
||||
m_projectFilePath = projectFilePath;
|
||||
m_projectExists = projectFilePath.exists();
|
||||
this->setText(m_projectFilePath.withoutExtension().fileName().c_str());
|
||||
if ( m_projectExists )
|
||||
if (m_projectExists)
|
||||
{
|
||||
this->setToolTip(m_projectFilePath.str().c_str());
|
||||
}
|
||||
@@ -44,9 +45,11 @@ void QtRecentProjectButton::setProjectPath(const FilePath& projectFilePath)
|
||||
|
||||
void QtRecentProjectButton::handleButtonClick()
|
||||
{
|
||||
if ( m_projectExists )
|
||||
if (m_projectExists)
|
||||
{
|
||||
MessageLoadProject(m_projectFilePath.str(), false).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(m_projectFilePath.str(), false)
|
||||
).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,14 +57,13 @@ void QtRecentProjectButton::handleButtonClick()
|
||||
+ " in your filesystem. Delete it from this recent Proejct list?";
|
||||
int ret = QMessageBox::question(this, "Missing Project File", text.c_str(), QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if ( ret == QMessageBox::Yes )
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
for (int i = 0
|
||||
; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount()
|
||||
; i++)
|
||||
const int maxRecentProjectsCount = ApplicationSettings::getInstance()->getMaxRecentProjectsCount();
|
||||
for (int i = 0; i < maxRecentProjectsCount; i++)
|
||||
{
|
||||
if (recentProjects[i].str() == m_projectFilePath.str() )
|
||||
if (recentProjects[i].str() == m_projectFilePath.str())
|
||||
{
|
||||
recentProjects.erase(recentProjects.begin()+i);
|
||||
ApplicationSettings::getInstance()->setRecentProjects(recentProjects);
|
||||
@@ -90,7 +92,7 @@ void QtStartScreen::updateButtons()
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
size_t i = 0;
|
||||
for ( QtRecentProjectButton* button : m_recentProjectsButtons )
|
||||
for (QtRecentProjectButton* button : m_recentProjectsButtons)
|
||||
{
|
||||
button->disconnect();
|
||||
if (i < recentProjects.size())
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
|
||||
// #include "utility/solution/SolutionParserCompilationDatabase.h"
|
||||
#include "utility/solution/SolutionParserVisualStudio.h"
|
||||
#include "utility/solution/SolutionParserCodeBlocks.h"
|
||||
|
||||
@@ -597,7 +597,9 @@ void QtProjectWizzard::createProject()
|
||||
|
||||
bool forceRefresh = !(m_settings == *ProjectSettings::getInstance().get());
|
||||
|
||||
MessageLoadProject(path, forceRefresh).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(path, forceRefresh)
|
||||
).dispatch();
|
||||
|
||||
m_windowStack.clearWindows();
|
||||
emit finished();
|
||||
|
||||
+5
-2
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
|
||||
#include "LicenseChecker.h"
|
||||
#include "qt/network/QtNetworkFactory.h"
|
||||
#include "qt/QtApplication.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
@@ -44,12 +45,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
|
||||
QtViewFactory viewFactory;
|
||||
QtNetworkFactory networkFactory;
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
|
||||
LicenseChecker::createInstance();
|
||||
|
||||
return qtApp.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user