139 lines
3.9 KiB
Diff
139 lines
3.9 KiB
Diff
|
commit 49a4067c58711130848cf4a30a0c4eedead405ac
|
||
|
Author: Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
||
|
Date: Sat Jun 21 05:55:22 2014 +0100
|
||
|
|
||
|
Support Qt5.
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index 7f32926..3824bd9 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -4,7 +4,23 @@ cmake_minimum_required(VERSION 2.8.6)
|
||
|
|
||
|
find_program(SED_PROGRAM sed)
|
||
|
|
||
|
-find_package(Qt4 REQUIRED QtCore QtGui) # Qt
|
||
|
+# Support Qt5
|
||
|
+option(USE_QT5 "Build with Qt5." $ENV{USE_QT5})
|
||
|
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||
|
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||
|
+set(CMAKE_AUTOMOC ON)
|
||
|
+if(USE_QT5)
|
||
|
+ cmake_minimum_required(VERSION 2.8.11)
|
||
|
+ find_package(Qt5Widgets REQUIRED)
|
||
|
+ find_package(Qt5X11Extras REQUIRED)
|
||
|
+ find_package(Qt5LinguistTools REQUIRED QUIET)
|
||
|
+ message(STATUS "Building with Qt${Qt5Core_VERSION_STRING}")
|
||
|
+else()
|
||
|
+ find_package(Qt4 REQUIRED QtCore QtGui) # Qt
|
||
|
+ include(${QT_USE_FILE})
|
||
|
+ message(STATUS "Building with Qt${QTVERSION}")
|
||
|
+endif()
|
||
|
+
|
||
|
find_package(PkgConfig)
|
||
|
pkg_check_modules(GLIB REQUIRED
|
||
|
glib-2.0
|
||
|
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||
|
index 218b72e..4057097 100644
|
||
|
--- a/src/CMakeLists.txt
|
||
|
+++ b/src/CMakeLists.txt
|
||
|
@@ -1,17 +1,21 @@
|
||
|
# set visibility to hidden to hide symbols, unlesss they're exporeted manually in the code
|
||
|
set(CMAKE_CXX_FLAGS "-DQT_NO_KEYWORDS -fno-exceptions")
|
||
|
|
||
|
+if(USE_QT5)
|
||
|
+ set(QTX_INCLUDE_DIRS "")
|
||
|
+ set(QTX_LIBRARIES Qt5::Widgets Qt5::X11Extras)
|
||
|
+else()
|
||
|
+ set(QTX_INCLUDE_DIRS ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTDBUS_DIR})
|
||
|
+ set(QTX_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDBUS_LIBRARY})
|
||
|
+endif()
|
||
|
+
|
||
|
include_directories(
|
||
|
- ${QT_INCLUDES}
|
||
|
+ ${QTX_INCLUDE_DIRS}
|
||
|
${GLIB_INCLUDE_DIRS}
|
||
|
${OPENBOX_INCLUDE_DIRS}
|
||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||
|
- ${CMAKE_CURRENT_SOURCE_DIR}
|
||
|
-
|
||
|
)
|
||
|
|
||
|
-set(CMAKE_AUTOMOC TRUE)
|
||
|
-
|
||
|
set(obconf-qt_SRCS
|
||
|
obconf-qt.cpp
|
||
|
maindialog.cpp
|
||
|
@@ -32,9 +36,11 @@ set(obconf-qt_UIS
|
||
|
obconf.ui
|
||
|
)
|
||
|
|
||
|
-qt4_wrap_ui(obconf-qt_UI_H
|
||
|
- ${obconf-qt_UIS}
|
||
|
-)
|
||
|
+if(USE_QT5)
|
||
|
+ qt5_wrap_ui(obconf-qt_UI_H ${obconf-qt_UIS})
|
||
|
+else()
|
||
|
+ qt4_wrap_ui(obconf-qt_UI_H ${obconf-qt_UIS})
|
||
|
+endif()
|
||
|
|
||
|
# The ui code generated by Qt uic contains QMetaObject::connectSlotsByName()
|
||
|
# but we don't want that. Fix it with sed.
|
||
|
@@ -51,14 +57,25 @@ add_custom_command(
|
||
|
|
||
|
# add translation for obconf-qt
|
||
|
option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files")
|
||
|
-if (UPDATE_TRANSLATIONS)
|
||
|
- qt4_create_translation(QM_FILES
|
||
|
- ${obconf-qt_SRCS}
|
||
|
- ${obconf-qt_UI_H}
|
||
|
- ${TS_FILES})
|
||
|
-else (UPDATE_TRANSLATIONS)
|
||
|
- qt4_add_translation(QM_FILES ${TS_FILES})
|
||
|
-endif (UPDATE_TRANSLATIONS)
|
||
|
+if(USE_QT5)
|
||
|
+ if (UPDATE_TRANSLATIONS)
|
||
|
+ qt5_create_translation(QM_FILES
|
||
|
+ ${obconf-qt_SRCS}
|
||
|
+ ${obconf-qt_UI_H}
|
||
|
+ ${TS_FILES})
|
||
|
+ else (UPDATE_TRANSLATIONS)
|
||
|
+ qt5_add_translation(QM_FILES ${TS_FILES})
|
||
|
+ endif (UPDATE_TRANSLATIONS)
|
||
|
+else(USE_QT5) # use qt4
|
||
|
+ if (UPDATE_TRANSLATIONS)
|
||
|
+ qt4_create_translation(QM_FILES
|
||
|
+ ${obconf-qt_SRCS}
|
||
|
+ ${obconf-qt_UI_H}
|
||
|
+ ${TS_FILES})
|
||
|
+ else (UPDATE_TRANSLATIONS)
|
||
|
+ qt4_add_translation(QM_FILES ${TS_FILES})
|
||
|
+ endif (UPDATE_TRANSLATIONS)
|
||
|
+endif(USE_QT5)
|
||
|
add_custom_target (obconf-qt_translations DEPENDS ${QM_FILES})
|
||
|
install(FILES ${QM_FILES} DESTINATION share/obconf-qt/translations)
|
||
|
# prevent the generated files from being deleted during make clean
|
||
|
@@ -78,8 +95,7 @@ add_definitions(
|
||
|
)
|
||
|
|
||
|
target_link_libraries(obconf-qt
|
||
|
- ${QT_QTCORE_LIBRARY}
|
||
|
- ${QT_QTGUI_LIBRARY}
|
||
|
+ ${QTX_LIBRARIES}
|
||
|
${GLIB_LIBRARIES}
|
||
|
${OPENBOX_LIBRARIES}
|
||
|
)
|
||
|
diff --git a/src/appearance.cpp b/src/appearance.cpp
|
||
|
index 316455c..64d1cf3 100644
|
||
|
--- a/src/appearance.cpp
|
||
|
+++ b/src/appearance.cpp
|
||
|
@@ -79,7 +79,7 @@ void MainDialog::on_title_layout_textChanged(const QString& text) {
|
||
|
QByteArray layout;
|
||
|
// omit unknown chars
|
||
|
for(int i = 0; i < text.length(); ++i) {
|
||
|
- char ch = text.at(i).toUpper().toAscii();
|
||
|
+ char ch = text.at(i).toUpper().toLatin1();
|
||
|
if(strchr("NDSLIMC", ch))
|
||
|
layout += ch;
|
||
|
}
|