diff --git a/CMakeLists.txt b/CMakeLists.txt index ad14be9..2aa9b00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,34 +1,14 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +cmake_minimum_required(VERSION 2.8) -PROJECT(SDDM) +project(SDDM) -SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") -SET(CMAKE_AUTOMOC ON) +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) -ADD_DEFINITIONS(-Wall -march=native -O2 -g -std=c++11) +add_definitions(-Wall -march=native -O2 -g -std=c++11) -# Qt -FIND_PACKAGE(Qt4 REQUIRED) -IF(QT_FOUND) - SET(QT_USE_QTDECLARATIVE TRUE) - INCLUDE(${QT_USE_FILE}) - INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src) -ELSE() - MESSAGE(FATAL_ERROR "Qt not found! Please make sure Qt is installed.") -ENDIF(QT_FOUND) - -# PAM -FIND_PACKAGE(PAM REQUIRED) -IF(PAM_FOUND) - INCLUDE_DIRECTORIES(${PAM_INCLUDE_DIR}) -ELSE() - MESSAGE(FATAL_ERROR "PAM not found!") -ENDIF(PAM_FOUND) - -# X11 -FIND_PACKAGE(X11 REQUIRED) - -SET(SOURCES +set(SOURCES src/Authenticator.cpp src/Configuration.cpp src/Cookie.cpp @@ -38,5 +18,24 @@ SET(SOURCES src/SessionManager.cpp ) -ADD_EXECUTABLE(sddm ${SOURCES}) -TARGET_LINK_LIBRARIES(sddm ${PAM_LIBRARIES} ${QT_LIBRARIES} ${X11_X11_LIB}) +# PAM +find_package(PAM REQUIRED) + +# X11 +find_package(X11 REQUIRED) + +if (USE_QT5) + find_package(Qt5Core REQUIRED) + + add_executable(sddm ${SOURCES}) + target_link_libraries(sddm ${PAM_LIBRARIES} ${X11_X11_LIB}) + + qt5_use_modules(sddm Widgets Quick) +else() + find_package(Qt4 REQUIRED) + set(QT_USE_QTDECLARATIVE TRUE) + include(${QT_USE_FILE}) + + add_executable(sddm ${SOURCES}) + target_link_libraries(sddm ${PAM_LIBRARIES} ${X11_X11_LIB} ${QT_LIBRARIES}) +endif(USE_QT5) diff --git a/README.md b/README.md index 977e6e8..2f36a16 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,27 @@ __Dependencies__ SDDM depends on PAM for authorization. SDDM uses a PAM service named "sddm" to authorize user. PAM services are created using simple config files installed into PAM config directory (e.g /etc/pam.d). A sample service file named "sddm.pam" is provided. You should copy this file into your PAM config directory and rename it to "sddm". Since the authorization procedure and available PAM modules may change depending on your distribution or your setup, we strongly advise reviewing this service file to see if it fits your needs. -SDDM depends on Xlib for communicating to the X server. Also we depend on Qt4 for loading the user interface and event loop management, apart from other things. +SDDM depends on Xlib for communicating to the X server. Also we depend on Qt for loading the user interface and event loop management, apart from other things. + +__Compilation__ + +SDDM uses CMake for compile configuration. Typical compilation procedure for a cmake-based project is: + +`mkdir build && cd build && cmake .. && make` + +SDDM by default compiles for Qt4 but supports compiling for Qt5 too. If you want to use Qt5, USE_QT5 arguments must be given to cmake: + +`mkdir build && cd build && cmake .. -DUSE_QT5=true && make` + +Qt4 based themes and Qt5 based ones are incompatible, so if you select Qt5 during compilation, either use a Qt5 based theme, or change + +`import QtQuick 1.1` + +lines to + +`import QtQuick 2.0` + +in the qml files. __Configuration__ @@ -64,4 +84,4 @@ Source code of SDDM is licensed under GNU GPL version 2 or later (at your opinio __Screenshots__ -![sample screenshot](http://s14.postimage.org/kkm44obf5/sddm1.png) \ No newline at end of file +![sample screenshot](http://s14.postimage.org/kkm44obf5/sddm1.png) diff --git a/src/Main.cpp b/src/Main.cpp index be8b2d0..f377186 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -25,9 +25,16 @@ #include #include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#include +#include +#else #include #include -#include +#endif + #include @@ -95,10 +102,17 @@ int main(int argc, char **argv) { // create application QApplication app(argc, argv); // create declarative view +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + // add session manager to context + QQmlContext *context = view.rootContext(); +#else QDeclarativeView view; view.setResizeMode(QDeclarativeView::SizeRootObjectToView); // add session manager to context QDeclarativeContext *context = view.rootContext(); +#endif context->setContextProperty("sessionManager", &sessionManager); // load qml file view.setSource(QUrl::fromLocalFile(QString("%1/Main.qml").arg(themePath)));