Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 006bc992 authored by Kåre Särs's avatar Kåre Särs

Port the twain wrapper to Qt5 and KF5

The twain wrapper seems to work on par with the Qt4/KDE4 version.
Both versions work with a twain test scanner, but fail with my
Canon MX455.

We still have to check translation.

BUG: 387268
parent c0f187be
......@@ -9,7 +9,9 @@ message(STATUS "-------------------------------------------")
message(STATUS "Starting CMake configuration for: libksane")
# ECM setup (Extended Cmake Modules)
find_package(ECM 1.1.0 REQUIRED NO_MODULE)
include(FeatureSummary)
find_package(ECM 5.30.0 REQUIRED NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules")
# ECM setup2 and include find same cmake module (copied from /usr/share/kde4/apps/cmake/modules/FindSane.cmake)
set(CMAKE_MODULE_PATH ${KSane_SOURCE_DIR}/cmake-modules ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
......@@ -41,19 +43,18 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets)
# Required KF5 frameworks
find_package(KF5I18n ${KF5_VERSION} REQUIRED)
find_package(KF5WidgetsAddons ${KF5_VERSION} REQUIRED)
find_package(KF5TextWidgets ${KF5_VERSION} REQUIRED)
# ...
# Optional KF5 frameworks
find_package(KF5Wallet ${KF5_VERSION})
set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "Safe desktop-wide storage for passwords"
TYPE OPTIONAL
PURPOSE "Required to have permanent storage of passwords for scanners"
)
# Check if sane API is available.
if (NOT WIN32)
find_package(KF5WidgetsAddons ${KF5_VERSION} REQUIRED)
find_package(KF5TextWidgets ${KF5_VERSION} REQUIRED)
# Optional KF5 frameworks
find_package(KF5Wallet ${KF5_VERSION})
set_package_properties(KF5Wallet PROPERTIES DESCRIPTION "Safe desktop-wide storage for passwords" TYPE OPTIONAL
PURPOSE "Required to have permanent storage of passwords for scanners"
)
# Check if sane API is available.
find_package(Sane)
message(STATUS "SANE_FOUND: ${SANE_FOUND}")
message(STATUS "SANE_INCLUDE_DIR: ${SANE_INCLUDE_DIR}")
......@@ -62,9 +63,13 @@ if (NOT WIN32)
endif (NOT WIN32)
# Subdirectories
add_subdirectory(src)
add_subdirectory(autotests)
add_subdirectory(tests)
if (SANE_FOUND)
add_subdirectory(src)
add_subdirectory(autotests)
add_subdirectory(tests)
else ()
add_subdirectory(ksanetwain)
endif()
# Create a Config.cmake and a ConfigVersion.cmake file and install them
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5Sane")
......@@ -154,11 +159,5 @@ ENDIF(WIN32 AND MSVC)
# =======================================================
#IF (SANE_FOUND)
# # ADD_SUBDIRECTORY(src) # old: was already done above
#ELSE (SANE_FOUND)
# ADD_SUBDIRECTORY(ksanetwain)
#.ENDIF (SANE_FOUND)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../libksane/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../src/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../libksane
${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_BINARY_DIR}
)
......@@ -13,31 +13,44 @@ ENDIF( WIN32 )
set(ktwain_src
twainiface.cpp
ktwain_widget.cpp
../src/ksanewidget.h
)
KDE4_ADD_LIBRARY(ksane SHARED ${ktwain_src})
add_library(KF5Sane ${ktwain_src})
generate_export_header(KF5Sane BASE_NAME KSane)
add_library(KF5::Sane ALIAS KF5Sane)
target_include_directories(KF5Sane INTERFACE "$<INSTALL_INTERFACE:${KF5_INCLUDE_INSTALL_DIR}/KSane>")
TARGET_LINK_LIBRARIES(ksane ${KDE4_KDEUI_LIBS})
target_link_libraries(KF5Sane
PUBLIC
Qt5::Widgets
PRIVATE
KF5::I18n
)
SET_TARGET_PROPERTIES(ksane PROPERTIES
VERSION ${KSANE_LIB_SO_VERSION_STRING}
SOVERSION ${KSANE_LIB_SO_CUR_VERSION}
LINK_FLAGS -Wl,-subsystem,console
set_target_properties(KF5Sane
PROPERTIES VERSION ${KSANE_VERSION_STRING}
SOVERSION ${KSANE_SOVERSION}
EXPORT_NAME "Sane"
)
install(TARGETS ksane ${INSTALL_TARGETS_DEFAULT_ARGS} )
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../libksane/ksane.h
${CMAKE_CURRENT_SOURCE_DIR}/../libksane/libksane_export.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION ${INCLUDE_INSTALL_DIR}/libksane COMPONENT Devel)
ecm_generate_headers(KSane_HEADERS
HEADER_NAMES
KSaneWidget
RELATIVE "../src/"
REQUIRED_HEADERS KSane_HEADERS
)
configure_file(
../KSaneConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KSaneConfig.cmake @ONLY
install(TARGETS KF5Sane
EXPORT KF5SaneTargets
${INSTALL_TARGETS_DEFAULT_ARGS}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/KSaneConfig.cmake
DESTINATION ${LIB_INSTALL_DIR}/cmake/KSane
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ksane_export.h
${KSane_HEADERS}
DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KSane
COMPONENT Devel
)
......@@ -5,7 +5,7 @@
* Date : 2009-05-11
* Description : Sane interface for KDE
*
* Copyright (C) 2009 by Kare Sars <kare dot sars at iki dot fi>
* Copyright (C) 2009,2017 by Kare Sars <kare dot sars at iki dot fi>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -25,7 +25,7 @@
*
* ============================================================ */
#include "../libksane/ksane.h"
#include "ksanewidget.h"
// Qt includes
#include <QMap>
......@@ -34,8 +34,8 @@
#include <QDebug>
// KDE includes
#include <klocalizedstring.h>
#include <kpushbutton.h>
#include <KLocalizedString>
#include <QPushButton>
// Local includes
#include "twainiface.h"
......@@ -46,7 +46,7 @@ namespace KSaneIface
KSaneWidget::KSaneWidget(QWidget *parent)
: QWidget(parent), d(new KSaneWidgetPrivate)
{
KPushButton *openDialog = new KPushButton;
QPushButton *openDialog = new QPushButton;
openDialog->setText(i18n("Open scan dialog"));
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(openDialog);
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
*
* Copyright (C) 2002-2003 Stephan Stapel <stephan dot stapel at web dot de>
* Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2009 by Kare Sars <kare dot sars at iki dot fi>
* Copyright (C) 2009,2017 by Kare Sars <kare dot sars at iki dot fi>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -54,7 +54,7 @@ public:
* @result One should return false to get the message being
* processed by the application (should return false by default!)
*/
bool winEvent(MSG *pMsg, long *result);
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
void CloseDSM();
QString SelectSource();
......@@ -75,7 +75,7 @@ private:
bool ProcessMessage(MSG msg);
bool SetImageCount(TW_INT16 nCount = 1);
bool DSOpen() const;
bool DSIsOpen() const;
bool CallTwainProc(pTW_IDENTITY pOrigin, pTW_IDENTITY pDest,
TW_UINT32 DG, TW_UINT16 DAT, TW_UINT16 MSG,
......
......@@ -69,6 +69,7 @@ ecm_generate_headers(KSane_HEADERS
HEADER_NAMES
KSaneWidget
REQUIRED_HEADERS KSane_HEADERS
RELATIVE "../src/"
)
# Install files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment