added simple CMake project file
This commit is contained in:
parent
2d3d4b9fa1
commit
372154ce2a
|
@ -0,0 +1,70 @@
|
|||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
|
||||
# meta data
|
||||
set(META_PROJECT_NAME qtutilities)
|
||||
set(META_APP_NAME "Qt Utilities")
|
||||
set(META_APP_AUTHOR "Martchus")
|
||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META APP_DESCRIPTION "Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models.")
|
||||
set(META_VERSION_MAJOR 3)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
|
||||
# define project
|
||||
project(${META_PROJECT_NAME})
|
||||
|
||||
# stringification of meta data
|
||||
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||
set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"")
|
||||
set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"")
|
||||
|
||||
# add configuration header
|
||||
configure_file (
|
||||
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/config.h"
|
||||
)
|
||||
include_directories("${PROJECT_BINARY_DIR}")
|
||||
|
||||
# add source and header files
|
||||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp" "*.c" "*.qrc")
|
||||
file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
|
||||
# enable capslock detection
|
||||
add_definitions(-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION)
|
||||
|
||||
# check required Qt 5 modules
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Gui REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
# enable moc, uic and rcc
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# executable and linking
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES})
|
||||
set(EXTRA_LIBS "")
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
set(EXTRA_LIBS X11)
|
||||
endif()
|
||||
target_link_libraries(${META_PROJECT_NAME} c++utilities Qt5::Core Qt5::Widgets ${EXTRA_LIBS})
|
||||
set_target_properties(${META_PROJECT_NAME} PROPERTIES VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH} SOVERSION ${META_VERSION_MAJOR})
|
||||
|
||||
# enable C++11
|
||||
set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
||||
|
||||
# add install target
|
||||
install(TARGETS ${META_PROJECT_NAME}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
foreach(HEADER_FILE ${HEADER_FILES})
|
||||
get_filename_component(HEADER_DIR ${HEADER_FILE} DIRECTORY)
|
||||
install(FILES ${HEADER_FILE} DESTINATION include/${META_PROJECT_NAME}/${HEADER_DIR})
|
||||
endforeach()
|
|
@ -1,7 +1,7 @@
|
|||
#include "./aboutdialog.h"
|
||||
#include "../misc/dialogutils.h"
|
||||
|
||||
#include "gui/ui_aboutdialog.h"
|
||||
#include "ui_aboutdialog.h"
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QApplication>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef APP_METADATA_AVAIL
|
||||
#define APP_METADATA_AVAIL
|
||||
#define PROJECT_NAME @META_PROJECT_NAME_STR@
|
||||
#define APP_NAME @META_APP_NAME_STR@
|
||||
#define APP_VERSION @META_APP_VERSION_STR@
|
||||
#define APP_AUTHOR @META_APP_AUTHOR_STR@
|
||||
#define APP_URL @META_APP_URL_STR@
|
||||
#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
|
||||
#endif // APP_METADATA_AVAIL
|
|
@ -1,7 +1,7 @@
|
|||
#include "./enterpassworddialog.h"
|
||||
#include "../misc/dialogutils.h"
|
||||
|
||||
#include "gui/ui_enterpassworddialog.h"
|
||||
#include "ui_enterpassworddialog.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
@ -301,15 +301,15 @@ void EnterPasswordDialog::confirm()
|
|||
* \brief Returns an indication whether the capslock key is pressed using platform specific functions.
|
||||
*
|
||||
* \remarks - Returns always false for unsupported platforms.
|
||||
* - This method is only avialable if the library is built with
|
||||
* - This method always returns false when not built with
|
||||
* PLATFORM_SPECIFIC_CAPSLOCK_DETECTION defined.
|
||||
* - This static function will be used internally to detect whether the capslock key is pressed
|
||||
* when initializing the dialog if available.
|
||||
* - The function requires the application to be linked against X11 on Linux/Unix/Max OS X.
|
||||
* - The function requires the application to be linked against X11 on Linux/Unix.
|
||||
*/
|
||||
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||
bool EnterPasswordDialog::isCapslockPressed()
|
||||
{
|
||||
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||
// platform dependent method of determining if CAPS LOCK is pressed
|
||||
# if defined(Q_OS_WIN32)
|
||||
return GetKeyState(VK_CAPITAL) == 1;
|
||||
|
@ -325,7 +325,8 @@ bool EnterPasswordDialog::isCapslockPressed()
|
|||
# else
|
||||
return false;
|
||||
# endif
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,9 +40,7 @@ public:
|
|||
void setPasswordRequired(bool value);
|
||||
const QString &instruction() const;
|
||||
void setInstruction(const QString &value);
|
||||
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||
static bool isCapslockPressed();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#dirs
|
||||
UI_DIR = ./gui
|
||||
MOC_DIR = ./moc
|
||||
OBJECTS_DIR = ./obj
|
||||
RCC_DIR = ./res
|
||||
|
@ -18,6 +17,7 @@ CONFIG(debug, debug|release) {
|
|||
TARGET = $${targetprefix}$${projectname}
|
||||
}
|
||||
# add defines
|
||||
DEFINES += "APP_METADATA_AVAIL"
|
||||
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
||||
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
||||
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "../misc/dialogutils.h"
|
||||
|
||||
#include "gui/ui_settingsdialog.h"
|
||||
#include "ui_settingsdialog.h"
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
#include <QShowEvent>
|
||||
|
|
Loading…
Reference in New Issue