Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on KDE6 #226

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
39 changes: 24 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.20)

project(lightly)
set(PROJECT_VERSION "0.43")
set(PROJECT_VERSION_MAJOR 5)
set(PROJECT_VERSION "0.44")
set(PROJECT_VERSION_MAJOR 6)

set(KF5_MIN_VERSION "5.78.0")
set(KF6_MIN_VERSION "6.0.0")
set(QT_MIN_VERSION "6.4.0")

include(GenerateExportHeader)
include(WriteBasicConfigVersionFile)
include(FeatureSummary)

find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake)

include(CMakePackageConfigHelpers)
include(ECMInstallIcons)
include(KDEInstallDirs)
include(KDEInstallDirs6)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEClangFormat)

include(GtkUpdateIconCache)


find_package(KF6FrameworkIntegration ${KF6_MIN_VERSION} CONFIG )
set_package_properties(KF${QT_MAJOR_VERSION}FrameworkIntegration PROPERTIES
DESCRIPTION "KF6 Framework Integration"
URL "https://projects.kde.org/projects/frameworks/frameworkintegration"
TYPE OPTIONAL
PURPOSE "Required to use KStyle convenience functionalities in style")

option(WITH_DECORATIONS "Build Lightly window decorations for KWin" ON)
if(WITH_DECORATIONS)
find_package(KDecoration2 REQUIRED)
Expand All @@ -31,20 +42,18 @@ add_subdirectory(liblightlycommon)
add_subdirectory(kstyle)
add_subdirectory(misc)


include(ECMSetupVersion)
ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LIGHTLY
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LightlyConfigVersion.cmake"
)
)

# create a Config.cmake and a ConfigVersion.cmake file and install them
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/Lightly")
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/Lightly")

ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/LightlyConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/LightlyConfig.cmake"
PATH_VARS KDE_INSTALL_FULL_DATADIR
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/LightlyConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/LightlyConfig.cmake"
PATH_VARS KDE_INSTALL_FULL_DATADIR
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})

# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
Expand All @@ -54,6 +63,6 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LightlyConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LightlyConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
)

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
2 changes: 1 addition & 1 deletion colors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
install(FILES Lightly.colors
DESTINATION ${DATA_INSTALL_DIR}/color-schemes/)
DESTINATION ${KDE_INSTALL_DATADIR}/color-schemes/)
81 changes: 22 additions & 59 deletions kdecoration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
add_definitions(-DTRANSLATION_DOMAIN="lightly_kwin_deco")

find_package(KF5 REQUIRED COMPONENTS CoreAddons GuiAddons ConfigWidgets WindowSystem I18n IconThemes)
find_package(Qt5 CONFIG REQUIRED COMPONENTS DBus)
find_package(KF6 REQUIRED COMPONENTS CoreAddons GuiAddons ConfigWidgets WindowSystem I18n IconThemes)
find_package(Qt6 CONFIG REQUIRED COMPONENTS DBus)

### XCB
find_package(XCB COMPONENTS XCB)
set_package_properties(XCB PROPERTIES
DESCRIPTION "X protocol C-language Binding"
URL "https://xcb.freedesktop.org"
TYPE OPTIONAL
PURPOSE "Required to pass style properties to native Windows on X11 Platform"
)

if(UNIX AND NOT APPLE)

set(LIGHTLY_HAVE_X11 ${XCB_XCB_FOUND})
if (XCB_XCB_FOUND)
find_package(Qt5 REQUIRED CONFIG COMPONENTS X11Extras)
endif()

else()

set(LIGHTLY_HAVE_X11 FALSE)

endif()
set(LIGHTLY_HAVE_X11 FALSE)

################# configuration #################
configure_file(config-lightly.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-lightly.h )
Expand All @@ -41,57 +21,40 @@ set(lightlydecoration_SRCS
lightlysettingsprovider.cpp
lightlysizegrip.cpp)

kconfig_add_kcfg_files(lightlydecoration_SRCS lightlysettings.kcfgc)

### config classes
### they are kept separately because they might move in a separate library in the future
set(lightlydecoration_config_SRCS
config/lightlyconfigwidget.cpp
config/lightlydetectwidget.cpp
config/lightlyexceptiondialog.cpp
config/lightlyexceptionlistwidget.cpp
config/lightlyexceptionmodel.cpp
config/lightlyitemmodel.cpp
)

set(lightlydecoration_config_PART_FORMS
config/ui/lightlyconfigurationui.ui
config/ui/lightlydetectwidget.ui
config/ui/lightlyexceptiondialog.ui
config/ui/lightlyexceptionlistwidget.ui
)

ki18n_wrap_ui(lightlydecoration_config_PART_FORMS_HEADERS ${lightlydecoration_config_PART_FORMS})
# Bring back QString(char *)
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
remove_definitions(-DQT_NO_KEYWORDS)

### build library
kconfig_add_kcfg_files(lightlydecoration_SRCS lightlysettings.kcfgc)
add_library(lightlydecoration MODULE
${lightlydecoration_SRCS}
${lightlydecoration_config_SRCS}
${lightlydecoration_config_PART_FORMS_HEADERS})

set_target_properties(lightlydecoration PROPERTIES
OUTPUT_NAME org.kde.lightly)

target_link_libraries(lightlydecoration
PUBLIC
Qt5::Core
Qt5::Gui
Qt5::DBus
PRIVATE
lightlycommon5
lightlycommon6
Qt6::DBus
Qt6::Widgets
KF6::CoreAddons
KF6::ConfigGui
KF6::GuiAddons
KF6::I18n
KF6::IconThemes
KDecoration2::KDecoration
KF5::ConfigCore
KF5::CoreAddons
KF5::ConfigWidgets
KF5::GuiAddons
KF5::I18n
KF5::IconThemes
KF5::WindowSystem)
)

if(LIGHTLY_HAVE_X11)
target_link_libraries(lightlydecoration
PUBLIC
Qt5::X11Extras
XCB::XCB)
endif()


install(TARGETS lightlydecoration DESTINATION ${PLUGIN_INSTALL_DIR}/org.kde.kdecoration2)
install(FILES config/lightlydecorationconfig.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(TARGETS lightlydecoration DESTINATION ${KDE_INSTALL_PLUGINDIR}/${KDECORATION_PLUGIN_DIR})

add_subdirectory(config)
39 changes: 39 additions & 0 deletions kdecoration/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
### config classes
### they are kept separately because they might move in a separate library in the future
find_package(KF6KCMUtils)

set(lightlydecoration_config_SRCS
../lightlyexceptionlist.cpp
lightlyconfigwidget.cpp
lightlydetectwidget.cpp
lightlyexceptiondialog.cpp
lightlyexceptionlistwidget.cpp
lightlyexceptionmodel.cpp
lightlyitemmodel.cpp
)
ki18n_wrap_ui(lightlydecoration_config_SRCS
ui/lightlyconfigurationui.ui
ui/lightlydetectwidget.ui
ui/lightlyexceptiondialog.ui
ui/lightlyexceptionlistwidget.ui
)


kcoreaddons_add_plugin(kcm_lightlydecoration SOURCES kcm_lightlydecoration.cpp ${lightlydecoration_config_SRCS} INSTALL_NAMESPACE "${KDECORATION_KCM_PLUGIN_DIR}")
kconfig_add_kcfg_files(kcm_lightlydecoration ../lightlysettings.kcfgc)
target_include_directories(kcm_lightlydecoration PRIVATE ${CMAKE_SOURCE_DIR}/kdecoration ${CMAKE_BINARY_DIR}/kdecoration/)
target_link_libraries(kcm_lightlydecoration
PUBLIC
Qt6::Core
Qt6::Gui
Qt6::DBus
PRIVATE
KF6::ConfigCore
KF6::CoreAddons
KF6::GuiAddons
KF6::I18n
KF6::IconThemes
KF6::WindowSystem
KF6::KCMUtils
)
kcmutils_generate_desktop_file(kcm_lightlydecoration)
6 changes: 6 additions & 0 deletions kdecoration/config/kcm_lightlydecoration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "lightlyconfigwidget.h"
#include <KPluginFactory>

K_PLUGIN_CLASS_WITH_JSON(Lightly::ConfigWidget, "kcm_lightlydecoration.json")

#include "kcm_lightlydecoration.moc"
11 changes: 11 additions & 0 deletions kdecoration/config/kcm_lightlydecoration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"KPlugin": {
"Description": "Modify the appearance of window decorations",
"ServiceTypes": [
"KCModule"
]
},
"X-KDE-Keywords": "lightly,decoration",
"X-KDE-ParentApp": "kcontrol",
"X-KDE-Weight": 60
}
10 changes: 5 additions & 5 deletions kdecoration/config/lightlyconfigwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
namespace Lightly
{

//_________________________________________________________
ConfigWidget::ConfigWidget( QWidget* parent, const QVariantList &args ):
KCModule(parent, args),
//_________________________________________________________
ConfigWidget::ConfigWidget( QObject* parent, const KPluginMetaData &data, const QVariantList & /*args*/ ):
KCModule(parent, data),
m_configuration( KSharedConfig::openConfig( QStringLiteral( "lightlyrc" ) ) ),
m_changed( false )
{

// configuration
m_ui.setupUi( this );
m_ui.setupUi( widget() );

// track ui changes
connect( m_ui.titleAlignment, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
Expand Down Expand Up @@ -212,7 +212,7 @@ namespace Lightly
//_______________________________________________
void ConfigWidget::setChanged( bool value )
{
emit changed( value );
setNeedsSave( value );
}

}
9 changes: 5 additions & 4 deletions kdecoration/config/lightlyconfigwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////

#include "ui_lightlyconfigurationui.h"
#include "lightly.h"
#include "lightlyexceptionlistwidget.h"
#include "lightlysettings.h"
#include "lightly.h"
#include "ui_lightlyconfigurationui.h"


#include <KCModule>
#include <KSharedConfig>

#include <QWidget>
#include <QSharedPointer>
#include <QWidget>

namespace Lightly
{
Expand All @@ -48,7 +49,7 @@ namespace Lightly
public:

//* constructor
explicit ConfigWidget( QWidget*, const QVariantList& );
explicit ConfigWidget( QObject *parent, const KPluginMetaData &data, const QVariantList &args);

//* destructor
virtual ~ConfigWidget() = default;
Expand Down
6 changes: 3 additions & 3 deletions kdecoration/config/lightlydetectwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ namespace Lightly

if( window == 0 )
{
emit detectionDone( false );
Q_EMIT detectionDone( false );
return;
}

m_info.reset(new KWindowInfo( window, NET::WMAllProperties, NET::WM2AllProperties ));
if( !m_info->valid())
{
emit detectionDone( false );
Q_EMIT detectionDone( false );
return;
}

Expand All @@ -97,7 +97,7 @@ namespace Lightly

m_ui.windowClass->setText( QStringLiteral( "%1 (%2 %3)" ).arg( wmClassClass ).arg( wmClassName ).arg( wmClassClass ) );
m_ui.windowTitle->setText( m_info->name() );
emit detectionDone( exec() == QDialog::Accepted );
Q_EMIT detectionDone( exec() == QDialog::Accepted );

}

Expand Down
1 change: 1 addition & 0 deletions kdecoration/config/lightlydetectwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <QLabel>

#include <kwindowsystem.h>
#include <kwindowinfo.h>

namespace Lightly
{
Expand Down
3 changes: 2 additions & 1 deletion kdecoration/config/lightlyexceptionlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QMessageBox>
#include <QPointer>
#include <QIcon>
#include <QRegularExpression>

//__________________________________________________________
namespace Lightly
Expand Down Expand Up @@ -323,7 +324,7 @@ namespace Lightly
bool ExceptionListWidget::checkException( InternalSettingsPtr exception )
{

while( exception->exceptionPattern().isEmpty() || !QRegExp( exception->exceptionPattern() ).isValid() )
while( exception->exceptionPattern().isEmpty() || !QRegularExpression( exception->exceptionPattern() ).isValid() )
{

QMessageBox::warning( this, i18n( "Warning - Lightly Settings" ), i18n("Regular Expression syntax is incorrect") );
Expand Down
Loading