Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -196,44 +196,32 @@ include(KDECompilerSettings) include(FeatureSummary) -find_package(KF5 5.7.0 REQUIRED COMPONENTS - Archive - Codecs +set(MINIMUM_KF5_VERSION 5.7.0) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS + Archive + Config Completion - Config - ConfigWidgets CoreAddons - Emoticons - GlobalAccel - GuiAddons - I18n - IconThemes - ItemModels - ItemViews + IconThemes + I18n KDELibs4Support - KIO - Kross - Parts - Sonnet - TextEditor - TextWidgets - ThreadWeaver - Wallet - WidgetsAddons - WindowSystem - XmlGui + KIO + WidgetsAddons + XmlGui OPTIONAL_COMPONENTS + Kross NotifyConfig Activities KHtml ) + if(KF5_Activities_FOUND) set(HAVE_KACTIVITIES TRUE) endif() - -find_package(Qt5 5.3.0 REQUIRED COMPONENTS Core Gui Widgets Xml Network PrintSupport - Script Svg Test Concurrent) -find_package(Qt5 5.3.0 COMPONENTS UiTools Sql WebKit WebKitWidgets DBus Declarative Qml Quick X11Extras) +set(REQUIRED_QT_VERSION 5.3.0) +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets Xml Network PrintSupport + Script Svg Test Concurrent) +find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS UiTools WebKit WebKitWidgets DBus Declarative Qml Quick) set(QT_QTDBUS_FOUND ${Qt5DBus_FOUND}) set(QT_QTWEBKIT_FOUND ${Qt5WebKit_FOUND}) @@ -243,13 +231,11 @@ set(QT_QTTEST_LIBRARY Qt5::Test) if (USEOPENGL) - find_package(Qt5 5.3.0 REQUIRED OpenGL) + find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED OpenGL) set(QT_QTOPENGL_FOUND ${Qt5OpenGL_FOUND}) endif () - - include (MacroLibrary) include (MacroAdditionalCleanFiles) include (MacroAddFileDependencies) @@ -269,13 +255,17 @@ macro_ensure_out_of_source_build("Compiling Calligra inside the source directory is not possible. Please refer to the build instruction http://community.kde.org/Calligra/Building/Building_Calligra") -find_package(X11) -if(X11_FOUND) - find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS - X11Extras - ) - set(HAVE_X11 TRUE) - add_definitions(-DHAVE_X11) +if(NOT WIN32 AND NOT APPLE) + find_package(X11) + if(X11_FOUND) + find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE + COMPONENTS X11Extras + ) + set(HAVE_X11 TRUE) + add_definitions(-DHAVE_X11) + else() + set(HAVE_X11 FALSE) + endif() else() set(HAVE_X11 FALSE) endif() @@ -1130,7 +1120,9 @@ add_subdirectory(flow) endif () -add_subdirectory(stage) +if(SHOULD_BUILD_APP_STAGE) + add_subdirectory(stage) +endif() if(SHOULD_BUILD_APP_KEXI) add_subdirectory(kexi) @@ -1140,7 +1132,9 @@ add_subdirectory(plan) endif() -add_subdirectory(sheets) +if(SHOULD_BUILD_APP_SHEETS) + add_subdirectory(sheets) +endif() if(SHOULD_BUILD_APP_KRITA) add_subdirectory(krita) Index: kexi/core/CMakeLists.txt =================================================================== --- kexi/core/CMakeLists.txt +++ kexi/core/CMakeLists.txt @@ -1,5 +1,7 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=44020) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS ItemViews ConfigWidgets) + set(kexicore_LIB_SRCS kexi_global.cpp kexi.cpp @@ -54,6 +56,7 @@ KF5::KIOWidgets KF5::CoreAddons KF5::XmlGui + KF5::IconThemes kexiutils kowidgetutils # KoGroupButton Index: kexi/formeditor/CMakeLists.txt =================================================================== --- kexi/formeditor/CMakeLists.txt +++ kexi/formeditor/CMakeLists.txt @@ -50,7 +50,7 @@ kexicore kexiextendedwidgets kundo2 - kowidgets # KoFileDialog + kowidgetutils # KoFileDialog KDb KProperty Index: kexi/kexiutils/CMakeLists.txt =================================================================== --- kexi/kexiutils/CMakeLists.txt +++ kexi/kexiutils/CMakeLists.txt @@ -1,5 +1,7 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=44024) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS ItemViews ConfigWidgets) + include_directories(completer) set(kexiutils_LIB_SRCS @@ -52,7 +54,6 @@ PUBLIC KF5::KIOWidgets #for KRun... KF5::IconThemes - KF5::WidgetsAddons KF5::ConfigWidgets # KStandardAction KColorScheme KF5::I18n KF5::ItemViews # KCategorizedView KCategoryDrawer Index: kexi/plugins/importexport/csv/CMakeLists.txt =================================================================== --- kexi/plugins/importexport/csv/CMakeLists.txt +++ kexi/plugins/importexport/csv/CMakeLists.txt @@ -1,5 +1,7 @@ include_directories(${CMAKE_SOURCE_DIR}/kexi/core ${CMAKE_SOURCE_DIR}/kexi/widget) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS Codecs) + # the main plugin set(kexi_csvimportexportplugin_SRCS KexiCsvImportExportPlugin.cpp Index: kexi/plugins/reports/CMakeLists.txt =================================================================== --- kexi/plugins/reports/CMakeLists.txt +++ kexi/plugins/reports/CMakeLists.txt @@ -38,11 +38,9 @@ KReport KProperty - KF5::KrossCore KF5::KDELibs4Support Qt5::Gui - Qt5::Script ) if (KEXI_MOBILE) Index: kexi/widget/CMakeLists.txt =================================================================== --- kexi/widget/CMakeLists.txt +++ kexi/widget/CMakeLists.txt @@ -2,6 +2,8 @@ add_subdirectory( dataviewcommon ) add_subdirectory( relations ) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS Codecs TextWidgets TextEditor) + if(KEXI_MOBILE) else() Index: krita/image/kis_cross_device_color_picker.h =================================================================== --- krita/image/kis_cross_device_color_picker.h +++ krita/image/kis_cross_device_color_picker.h @@ -122,8 +122,8 @@ Traits::template sampleData(m_accessor, m_data, m_srcCS); m_srcCS->convertPixelsTo(m_data, dst, m_dstCS, 1, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } private: Index: krita/image/kis_fixed_paint_device.h =================================================================== --- krita/image/kis_fixed_paint_device.h +++ krita/image/kis_fixed_paint_device.h @@ -113,8 +113,8 @@ * Converts the paint device to a different colorspace */ void convertTo(const KoColorSpace * dstColorSpace = 0, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()); /** * Fill this paint device with the data from image * @@ -134,8 +134,8 @@ * like sRGB). */ virtual QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags) const; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()) const; /** * Create an RGBA QImage from a rectangle in the paint device. The @@ -146,8 +146,8 @@ * like sRGB). */ virtual QImage convertToQImage(const KoColorProfile *dstProfile, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags) const; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()) const; /** * Clear the given rectangle to transparent black. Index: krita/image/kis_fixed_paint_device.cpp =================================================================== --- krita/image/kis_fixed_paint_device.cpp +++ krita/image/kis_fixed_paint_device.cpp @@ -127,8 +127,8 @@ KoColorSpaceRegistry::instance() ->colorSpace( RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), srcProfileName) ->convertPixelsTo(image.constBits(), data(), colorSpace(), image.width() * image.height(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } } Index: krita/image/kis_group_layer.cc =================================================================== --- krita/image/kis_group_layer.cc +++ krita/image/kis_group_layer.cc @@ -184,8 +184,8 @@ m_d->paintDevice->colorSpace()-> convertPixelsTo(m_d->paintDevice->defaultPixel(), defaultPixel, colorSpace, 1, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); dev->setDefaultPixel(defaultPixel); delete[] defaultPixel; m_d->paintDevice = dev; Index: krita/image/kis_image.cc =================================================================== --- krita/image/kis_image.cc +++ krita/image/kis_image.cc @@ -1353,8 +1353,8 @@ KisPaintDeviceSP dev = projection(); if (!dev) return QImage(); QImage image = dev->convertToQImage(const_cast(profile), x, y, w, h, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); return image; } @@ -1414,8 +1414,8 @@ delete [] imageRow; QImage image = colorSpace()->convertToQImage(scaledImageData, scaledRect.width(), scaledRect.height(), const_cast(profile), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); delete [] scaledImageData; Index: krita/image/kis_layer.cc =================================================================== --- krita/image/kis_layer.cc +++ krita/image/kis_layer.cc @@ -758,8 +758,8 @@ return originalDevice ? originalDevice->createThumbnail(w, h, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags) : QImage(); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()) : QImage(); } qint32 KisLayer::x() const Index: krita/image/kis_mask.cc =================================================================== --- krita/image/kis_mask.cc +++ krita/image/kis_mask.cc @@ -342,8 +342,8 @@ return originalDevice ? originalDevice->createThumbnail(w, h, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags) : QImage(); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()) : QImage(); } void KisMask::testingInitSelection(const QRect &rect) Index: krita/image/kis_paint_device.h =================================================================== --- krita/image/kis_paint_device.h +++ krita/image/kis_paint_device.h @@ -443,8 +443,8 @@ * @return a command that can be used to undo the conversion. */ KUndo2Command* convertTo(const KoColorSpace * dstColorSpace, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()); /** * Changes the profile of the colorspace of this paint device to the given @@ -470,16 +470,16 @@ * like sRGB). */ virtual QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags) const; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()) const; /** * Overridden method for convenience */ QImage convertToQImage(const KoColorProfile *dstProfile, const QRect &rc, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags) const; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()) const; /** * Create an RGBA QImage from a rectangle in the paint device. The @@ -490,8 +490,8 @@ * like sRGB). */ QImage convertToQImage(const KoColorProfile * dstProfile, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags) const; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()) const; /** * Creates a paint device thumbnail of the paint device, retaining @@ -515,15 +515,15 @@ * @param rect: only this rect will be used for the thumbnail */ QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()); /** * Cached version of createThumbnail(qint32 maxw, qint32 maxh, const KisSelection *selection, QRect rect) */ QImage createThumbnail(qint32 maxw, qint32 maxh, - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags()); /** * Fill c and opacity with the values found at x and y. Index: krita/image/kis_paint_device.cc =================================================================== --- krita/image/kis_paint_device.cc +++ krita/image/kis_paint_device.cc @@ -802,8 +802,8 @@ KoColorSpaceRegistry::instance() ->colorSpace(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), profile) ->convertPixelsTo(image.constBits(), dstData, colorSpace(), image.width() * image.height(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); writeBytes(dstData, offsetX, offsetY, image.width(), image.height()); delete[] dstData; @@ -1148,8 +1148,8 @@ KisPaintDeviceSP clone = new KisPaintDevice(*cloneSource); clone->setDefaultBounds(defaultBounds()); clone->convertTo(compositionSourceColorSpace(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); return clone; } @@ -1159,8 +1159,8 @@ clone->setDefaultBounds(defaultBounds()); clone->makeCloneFromRough(cloneSource, roughRect); clone->convertTo(compositionSourceColorSpace(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); return clone; } Index: krita/image/kis_painter.cc =================================================================== --- krita/image/kis_painter.cc +++ krita/image/kis_painter.cc @@ -170,8 +170,8 @@ d->mirrorVerticaly = false; d->isOpacityUnit = true; d->paramInfo = KoCompositeOp::ParameterInfo(); - d->renderingIntent = KoColorConversionTransformation::InternalRenderingIntent; - d->conversionFlags = KoColorConversionTransformation::InternalConversionFlags; + d->renderingIntent = KoColorConversionTransformation::internalRenderingIntent(); + d->conversionFlags = KoColorConversionTransformation::internalConversionFlags(); } KisPainter::~KisPainter() Index: krita/image/kis_selection_based_layer.cpp =================================================================== --- krita/image/kis_selection_based_layer.cpp +++ krita/image/kis_selection_based_layer.cpp @@ -262,8 +262,8 @@ return originalDevice && originalSelection ? originalDevice->createThumbnail(w, h, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags) : + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()) : QImage(); } Index: krita/image/tests/kis_colorspace_convert_visitor_test.cpp =================================================================== --- krita/image/tests/kis_colorspace_convert_visitor_test.cpp +++ krita/image/tests/kis_colorspace_convert_visitor_test.cpp @@ -36,8 +36,8 @@ KisImageSP image = new KisImage(0, 100, 100, lab, "test"); KisPaintLayerSP layer = new KisPaintLayer(image, "test", OPACITY_OPAQUE_U8, lab); KisColorSpaceConvertVisitor test(image, lab, rgb, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); layer->accept(test); QVERIFY(layer->colorSpace()->colorModelId() == rgb->colorModelId()); } Index: krita/image/tests/kis_image_test.cpp =================================================================== --- krita/image/tests/kis_image_test.cpp +++ krita/image/tests/kis_image_test.cpp @@ -74,8 +74,8 @@ const KoColorSpace *cs16 = KoColorSpaceRegistry::instance()->rgb16(); image->lock(); image->convertImageColorSpace(cs16, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); image->unlock(); QVERIFY(*cs16 == *image->colorSpace()); Index: krita/image/tests/kis_selection_test.cpp =================================================================== --- krita/image/tests/kis_selection_test.cpp +++ krita/image/tests/kis_selection_test.cpp @@ -59,14 +59,14 @@ quint8 color2[2] = {64,32}; csA->convertPixelsTo(color2, color1, csNoA, 1, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); QCOMPARE((int)color1[0], 8); csNoA->convertPixelsTo(color1, color2, csA, 1, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); QCOMPARE((int)color2[0], 8); QCOMPARE((int)color2[1], 255); @@ -105,17 +105,17 @@ params.flow = 1.0; csA->bitBlt(csA, params, csA->compositeOp(COMPOSITE_OVER), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); QCOMPARE((int)color0[0], 56); QCOMPARE((int)color0[1], 255); params.dstRowStart = color3; csNoA->bitBlt(csA, params, csNoA->compositeOp(COMPOSITE_OVER), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); QCOMPARE((int)color3[0], 56); } Index: krita/libbrush/kis_gbr_brush.cpp =================================================================== --- krita/libbrush/kis_gbr_brush.cpp +++ krita/libbrush/kis_gbr_brush.cpp @@ -304,7 +304,7 @@ { // Forcefully convert to RGBA8 // XXX profile and exposure? - setBrushTipImage(image->convertToQImage(0, x, y, w, h, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags)); + setBrushTipImage(image->convertToQImage(0, x, y, w, h, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags())); setName(image->objectName()); setHasColor(true); Index: krita/plugins/extensions/dockers/advancedcolorselector/kis_common_colors.cpp =================================================================== --- krita/plugins/extensions/dockers/advancedcolorselector/kis_common_colors.cpp +++ krita/plugins/extensions/dockers/advancedcolorselector/kis_common_colors.cpp @@ -131,7 +131,7 @@ KisImageWSP kisImage = m_canvas->image(); - QImage image = kisImage->projection()->createThumbnail(1024, 1024, kisImage->bounds(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + QImage image = kisImage->projection()->createThumbnail(1024, 1024, kisImage->bounds(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); KisCommonColorsRecalculationRunner* runner = new KisCommonColorsRecalculationRunner(image, patchCount(), this); QThreadPool::globalInstance()->start(runner); Index: krita/plugins/extensions/dockers/historydocker/KisUndoModel.cpp =================================================================== --- krita/plugins/extensions/dockers/historydocker/KisUndoModel.cpp +++ krita/plugins/extensions/dockers/historydocker/KisUndoModel.cpp @@ -255,8 +255,8 @@ KisImageWSP historyImage = m_canvas->viewManager()->image(); KisPaintDeviceSP paintDevice = historyImage->projection(); QImage image = paintDevice->createThumbnail(32, 32, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); m_imageMap[currentCommand] = image; } Index: krita/plugins/extensions/dockers/lut/tests/kis_ocio_display_filter_test.cpp =================================================================== --- krita/plugins/extensions/dockers/lut/tests/kis_ocio_display_filter_test.cpp +++ krita/plugins/extensions/dockers/lut/tests/kis_ocio_display_filter_test.cpp @@ -76,7 +76,7 @@ KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(), Float32BitsColorDepthID.id(), 0); KisImageSP image = utils::createImage(0, QSize(100, 100)); - image->convertImageColorSpace(paintingCS, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + image->convertImageColorSpace(paintingCS, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); image->waitForDone(); dbgKrita << ppVar(paintingCS) << ppVar(image->root()->firstChild()->colorSpace()); Index: krita/plugins/extensions/gmic/kis_gmic_simple_convertor.cpp =================================================================== --- krita/plugins/extensions/gmic/kis_gmic_simple_convertor.cpp +++ krita/plugins/extensions/gmic/kis_gmic_simple_convertor.cpp @@ -552,8 +552,8 @@ int blueOffset = greenOffset * 2; int alphaOffset = greenOffset * 3; - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent; - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(); + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags(); const KoColorSpace * colorSpace = dev->colorSpace(); KisRandomConstAccessorSP it = dev->createRandomConstAccessorNG(0,0); @@ -615,8 +615,8 @@ quint8 * floatRGBApixel = new quint8[rgbaFloat32bitcolorSpace->pixelSize() * optimalBufferSize]; quint32 pixelSize = rgbaFloat32bitcolorSpace->pixelSize(); - KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent; - KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::InternalConversionFlags; + KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(); + KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags(); // Krita needs rgba in 0.0...1.0 float multiplied = KoColorSpaceMathsTraits::unitValue / gmicMaxChannelValue; Index: krita/plugins/filters/fastcolortransfer/fastcolortransfer.cpp =================================================================== --- krita/plugins/filters/fastcolortransfer/fastcolortransfer.cpp +++ krita/plugins/filters/fastcolortransfer/fastcolortransfer.cpp @@ -98,7 +98,7 @@ const KoColorSpace* oldCS = device->colorSpace(); KisPaintDeviceSP srcLAB = new KisPaintDevice(*device.data()); dbgPlugins << "srcLab : " << srcLAB->extent(); - KUndo2Command* cmd = srcLAB->convertTo(labCS, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + KUndo2Command* cmd = srcLAB->convertTo(labCS, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); delete cmd; if (progressUpdater) { Index: krita/plugins/filters/fastcolortransfer/kis_wdg_fastcolortransfer.cpp =================================================================== --- krita/plugins/filters/fastcolortransfer/kis_wdg_fastcolortransfer.cpp +++ krita/plugins/filters/fastcolortransfer/kis_wdg_fastcolortransfer.cpp @@ -95,7 +95,7 @@ } dbgPlugins << "convert ref to lab"; - KUndo2Command* cmd = ref->convertTo(labCS, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + KUndo2Command* cmd = ref->convertTo(labCS, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); delete cmd; // Compute the means and sigmas of ref Index: krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp =================================================================== --- krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp +++ krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp @@ -177,7 +177,7 @@ KisPaintDeviceSP bumpmapPaintDevice = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb16()); bumpmapPaintDevice->writeBytes(bumpmap.data(), outputArea.x(), outputArea.y(), outputArea.width(), outputArea.height()); - KUndo2Command *leaker = bumpmapPaintDevice->convertTo(device->colorSpace(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + KUndo2Command *leaker = bumpmapPaintDevice->convertTo(device->colorSpace(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); KisPainter copier(device); copier.bitBlt(outputArea.x(), outputArea.y(), bumpmapPaintDevice, outputArea.x(), outputArea.y(), outputArea.width(), outputArea.height()); Index: krita/plugins/formats/bmp/kis_bmp_export.cpp =================================================================== --- krita/plugins/formats/bmp/kis_bmp_export.cpp +++ krita/plugins/formats/bmp/kis_bmp_export.cpp @@ -65,7 +65,7 @@ QRect rc = input->image()->bounds(); input->image()->refreshGraph(); input->image()->lock(); - QImage image = input->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + QImage image = input->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); input->image()->unlock(); image.save(url.toLocalFile()); return KisImportExportFilter::OK; Index: krita/plugins/formats/jpeg/kis_jpeg_converter.cc =================================================================== --- krita/plugins/formats/jpeg/kis_jpeg_converter.cc +++ krita/plugins/formats/jpeg/kis_jpeg_converter.cc @@ -209,7 +209,7 @@ KoColorTransformation* transform = 0; if (profile && !profile->isSuitableForOutput()) { - transform = KoColorSpaceRegistry::instance()->colorSpace(modelId, Integer8BitsColorDepthID.id(), profile)->createColorConverter(cs, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + transform = KoColorSpaceRegistry::instance()->colorSpace(modelId, Integer8BitsColorDepthID.id(), profile)->createColorConverter(cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } // Apparently an invalid transform was created from the profile. See bug https://bugs.kde.org/show_bug.cgi?id=255451. // After 2.3: warn the user! @@ -473,7 +473,7 @@ if (!m_batchMode) { QMessageBox::information(0, i18nc("@title:window", "Krita"), i18n("Cannot export images in %1.\nWill save as RGB.", cs->name())); } - KUndo2Command *tmp = layer->paintDevice()->convertTo(KoColorSpaceRegistry::instance()->rgb8(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + KUndo2Command *tmp = layer->paintDevice()->convertTo(KoColorSpaceRegistry::instance()->rgb8(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); delete tmp; cs = KoColorSpaceRegistry::instance()->rgb8(); color_type = JCS_RGB; Index: krita/plugins/formats/ppm/kis_ppm_export.cpp =================================================================== --- krita/plugins/formats/ppm/kis_ppm_export.cpp +++ krita/plugins/formats/ppm/kis_ppm_export.cpp @@ -198,10 +198,10 @@ if (((rgb && (pd->colorSpace()->id() != "RGBA" && pd->colorSpace()->id() != "RGBA16")) || (!rgb && (pd->colorSpace()->id() != "GRAYA" && pd->colorSpace()->id() != "GRAYA16" && pd->colorSpace()->id() != "GRAYAU16")))) { if (rgb) { - pd->convertTo(KoColorSpaceRegistry::instance()->rgb8(0), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + pd->convertTo(KoColorSpaceRegistry::instance()->rgb8(0), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } else { - pd->convertTo(KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), 0), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + pd->convertTo(KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), 0), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } } Index: krita/plugins/formats/tga/kis_tga_export.cpp =================================================================== --- krita/plugins/formats/tga/kis_tga_export.cpp +++ krita/plugins/formats/tga/kis_tga_export.cpp @@ -66,7 +66,7 @@ QRect rc = input->image()->bounds(); input->image()->refreshGraph(); input->image()->lock(); - QImage image = input->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + QImage image = input->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); input->image()->unlock(); QFile f(filename); Index: krita/plugins/formats/tiff/kis_tiff_converter.cc =================================================================== --- krita/plugins/formats/tiff/kis_tiff_converter.cc +++ krita/plugins/formats/tiff/kis_tiff_converter.cc @@ -313,7 +313,7 @@ KoColorTransformation* transform = 0; if (profile && !profile->isSuitableForOutput()) { dbgFile << "The profile can't be used in krita, need conversion"; - transform = KoColorSpaceRegistry::instance()->colorSpace(colorSpaceId.first, colorSpaceId.second, profile)->createColorConverter(cs, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + transform = KoColorSpaceRegistry::instance()->colorSpace(colorSpaceId.first, colorSpaceId.second, profile)->createColorConverter(cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } // Check if there is an alpha channel Index: krita/plugins/tools/tool_transform2/kis_tool_transform.cc =================================================================== --- krita/plugins/tools/tool_transform2/kis_tool_transform.cc +++ krita/plugins/tools/tool_transform2/kis_tool_transform.cc @@ -768,14 +768,14 @@ createThumbnail(thumbRect.width(), thumbRect.height(), srcRect, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); thumbToImageTransform = scaleTransform.inverted(); } else { origImg = m_selectedPortionCache->convertToQImage(0, x, y, w, h, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); thumbToImageTransform = QTransform(); } Index: krita/ui/CMakeLists.txt =================================================================== --- krita/ui/CMakeLists.txt +++ krita/ui/CMakeLists.txt @@ -27,6 +27,8 @@ find_library(FOUNDATION_LIBRARY Foundation) endif () +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS GlobalAccel) + set(kritaui_LIB_SRCS canvas/kis_canvas_widget_base.cpp canvas/kis_canvas2.cpp @@ -464,6 +466,9 @@ if(HAVE_OPENGL) target_link_libraries(kritaui ${OPENGL_LIBRARIES} Qt5::OpenGL ${OPENEXR_LIBRARIES}) + if(X11_FOUND) + target_link_libraries(kritaui Qt5::X11Extras) + endif() # Add VSync disable workaround if(NOT WIN32) Index: krita/ui/canvas/kis_display_color_converter.cpp =================================================================== --- krita/ui/canvas/kis_display_color_converter.cpp +++ krita/ui/canvas/kis_display_color_converter.cpp @@ -52,8 +52,8 @@ paintingColorSpace(0), monitorColorSpace(0), monitorProfile(0), - renderingIntent(KoColorConversionTransformation::InternalRenderingIntent), - conversionFlags(KoColorConversionTransformation::InternalConversionFlags), + renderingIntent(KoColorConversionTransformation::internalRenderingIntent()), + conversionFlags(KoColorConversionTransformation::internalConversionFlags()), displayFilter(0), intermediateColorSpace(0), displayRenderer(new DisplayRenderer(_q, _resourceManager)) Index: krita/ui/canvas/kis_image_pyramid.cpp =================================================================== --- krita/ui/canvas/kis_image_pyramid.cpp +++ krita/ui/canvas/kis_image_pyramid.cpp @@ -263,14 +263,14 @@ m_displayFilter->filter(originalBytes.data(), numPixels); } else { QScopedArrayPointer dst(new quint8[floatCs->pixelSize() * numPixels]); - projectionCs->convertPixelsTo(originalBytes.data(), dst.data(), floatCs, numPixels, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + projectionCs->convertPixelsTo(originalBytes.data(), dst.data(), floatCs, numPixels, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); m_displayFilter->filter(dst.data(), numPixels); originalBytes.swap(dst); } { QScopedArrayPointer dst(new quint8[modifiedMonitorCs->pixelSize() * numPixels]); - floatCs->convertPixelsTo(originalBytes.data(), dst.data(), modifiedMonitorCs, numPixels, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + floatCs->convertPixelsTo(originalBytes.data(), dst.data(), modifiedMonitorCs, numPixels, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); originalBytes.swap(dst); } #endif Index: krita/ui/kis_clipboard.cc =================================================================== --- krita/ui/kis_clipboard.cc +++ krita/ui/kis_clipboard.cc @@ -146,7 +146,7 @@ QImage qimage; KisConfig cfg; const KoColorProfile *monitorProfile = cfg.displayProfile(QApplication::desktop()->screenNumber(qApp->activeWindow())); - qimage = dev->convertToQImage(monitorProfile, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + qimage = dev->convertToQImage(monitorProfile, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); if (!qimage.isNull() && mimeData) { mimeData->setImageData(qimage); } Index: krita/ui/kis_custom_pattern.cc =================================================================== --- krita/ui/kis_custom_pattern.cc +++ krita/ui/kis_custom_pattern.cc @@ -168,8 +168,8 @@ QString dir = KoResourceServerProvider::instance()->patternServer()->saveLocation(); m_pattern = new KoPattern(dev->createThumbnail(size.width(), size.height(), rc, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags), name, dir); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()), name, dir); } Index: krita/ui/kis_mimedata.cpp =================================================================== --- krita/ui/kis_mimedata.cpp +++ krita/ui/kis_mimedata.cpp @@ -116,8 +116,8 @@ doc->image()->waitForDone(); return doc->image()->projection()->convertToQImage(cfg.displayProfile(QApplication::desktop()->screenNumber(qApp->activeWindow())), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } else if (mimetype == "application/x-krita-node" || mimetype == "application/zip") { Index: krita/ui/kis_png_converter.cpp =================================================================== --- krita/ui/kis_png_converter.cpp +++ krita/ui/kis_png_converter.cpp @@ -590,7 +590,7 @@ // Create the cmsTransform if needed KoColorTransformation* transform = 0; if (profile && !profile->isSuitableForOutput()) { - transform = KoColorSpaceRegistry::instance()->colorSpace(csName.first, csName.second, profile)->createColorConverter(cs, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + transform = KoColorSpaceRegistry::instance()->colorSpace(csName.first, csName.second, profile)->createColorConverter(cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } // Creating the KisImageWSP Index: krita/ui/tests/kis_prescaled_projection_test.cpp =================================================================== --- krita/ui/tests/kis_prescaled_projection_test.cpp +++ krita/ui/tests/kis_prescaled_projection_test.cpp @@ -178,8 +178,8 @@ converter.setImage(image); projection.setCoordinatesConverter(&converter); projection.setMonitorProfile(0, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); projection.setImage(image); // pixel-for-pixel, at 100% zoom @@ -213,8 +213,8 @@ converter.setImage(image); projection.setCoordinatesConverter(&converter); projection.setMonitorProfile(0, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); projection.setImage(image); testProjectionScenario(projection, &converter, "120dpi"); @@ -245,8 +245,8 @@ converter.setImage(image); projection.setCoordinatesConverter(&converter); projection.setMonitorProfile(0, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); projection.setImage(image); // Emulate "Use same aspect as pixels" @@ -302,8 +302,8 @@ projection.setCoordinatesConverter(&converter); projection.setMonitorProfile(0, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); projection.setImage(image); projection.notifyCanvasSizeChanged(QSize(100,100)); projection.notifyZoomChanged(); Index: krita/ui/widgets/kis_scratch_pad.cpp =================================================================== --- krita/ui/widgets/kis_scratch_pad.cpp +++ krita/ui/widgets/kis_scratch_pad.cpp @@ -307,8 +307,8 @@ alignedImageRect.y(), alignedImageRect.width(), alignedImageRect.height(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); QPainter gc(this); gc.fillRect(event->rect(), m_checkBrush); @@ -367,7 +367,7 @@ KisPaintDeviceSP paintDevice = m_paintLayer->paintDevice(); QRect rc = widgetToDocument().mapRect(m_cutoutOverlay); - QImage rawImage = paintDevice->convertToQImage(0, rc.x(), rc.y(), rc.width(), rc.height(), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + QImage rawImage = paintDevice->convertToQImage(0, rc.x(), rc.y(), rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); QImage scaledImage = rawImage.scaled(m_cutoutOverlay.size(), Qt::IgnoreAspectRatio, Index: libs/kotext/CMakeLists.txt =================================================================== --- libs/kotext/CMakeLists.txt +++ libs/kotext/CMakeLists.txt @@ -137,6 +137,8 @@ add_library(kotext SHARED ${kotext_LIB_SRCS}) generate_export_header(kotext BASE_NAME kotext) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS TextWidgets) + target_link_libraries(kotext flake KF5::TextWidgets KF5::XmlGui KF5::WindowSystem) if( SHOULD_BUILD_FEATURE_RDF ) target_link_libraries(kotext ${SOPRANO_LIBRARIES}) Index: libs/kundo2/CMakeLists.txt =================================================================== --- libs/kundo2/CMakeLists.txt +++ libs/kundo2/CMakeLists.txt @@ -12,6 +12,7 @@ add_library(kundo2 SHARED ${kundo2_LIB_SRCS}) generate_export_header(kundo2 BASE_NAME kundo2) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS ConfigWidgets) target_link_libraries(kundo2 KF5::IconThemes KF5::I18n KF5::XmlGui KF5::ConfigWidgets Qt5::Core Qt5::Widgets) set_target_properties(kundo2 PROPERTIES Index: libs/odf/CMakeLists.txt =================================================================== --- libs/odf/CMakeLists.txt +++ libs/odf/CMakeLists.txt @@ -1,6 +1,11 @@ add_subdirectory( tests ) add_subdirectory( writeodf ) +find_package(KF5 ${MINIMUM_KF5_VERSION} + REQUIRED COMPONENTS Sonnet + OPTIONAL_COMPONENTS Wallet +) + include_directories( ${KOODF_INCLUDES} ) ########### libkoodf ############### @@ -46,8 +51,15 @@ add_dependencies(koodf writeodf.h-target) generate_export_header(koodf BASE_NAME koodf) -target_link_libraries(koodf koversion kostore KF5::Archive KF5::Wallet KF5::KIOWidgets KF5::I18n Qt5::PrintSupport Qt5::Gui Qt5::Xml) +target_link_libraries(koodf koversion kostore KF5::Archive KF5::KIOWidgets KF5::I18n Qt5::PrintSupport Qt5::Gui Qt5::Xml) target_link_libraries(koodf LINK_INTERFACE_LIBRARIES kostore KF5::I18n Qt5::PrintSupport Qt5::Gui Qt5::Xml) +if( KF5Wallet_FOUND ) + target_link_libraries(koodf KF5::Wallet) + add_definitions( -DKF5Wallet ) +endif() +if( Qca-qt5_FOUND ) + target_link_libraries(koodf qca-qt5) +endif() set_target_properties(koodf PROPERTIES VERSION ${GENERIC_CALLIGRA_LIB_VERSION} SOVERSION ${GENERIC_CALLIGRA_LIB_SOVERSION} Index: libs/odf/KoEncryptionChecker.cpp =================================================================== --- libs/odf/KoEncryptionChecker.cpp +++ libs/odf/KoEncryptionChecker.cpp @@ -19,7 +19,7 @@ #include "KoEncryptionChecker.h" -#ifdef QCA2 +#if defined QCA2 && defined KF5Wallet // QCA headers have "slots" and "signals", which QT_NO_SIGNALS_SLOTS_KEYWORDS does not like #define slots Q_SLOTS Index: libs/odf/tests/TestStorage.cpp =================================================================== --- libs/odf/tests/TestStorage.cpp +++ libs/odf/tests/TestStorage.cpp @@ -59,7 +59,7 @@ QTest::newRow("tar") << (int) KoStore::Tar << "test.tgz"; QTest::newRow("directory") << (int) KoStore::Directory << "testdir"; QTest::newRow("zip") << (int) KoStore::Zip <<"test.zip"; -#ifdef QCA2 +#if defined QCA2 && defined KF5Wallet if (KoEncryptionChecker::isEncryptionSupported()) { QTest::newRow("Encrypted") << (int) KoStore::Encrypted << "testEncrypted.zip"; } Index: libs/pigment/KoColor.cpp =================================================================== --- libs/pigment/KoColor.cpp +++ libs/pigment/KoColor.cpp @@ -103,7 +103,7 @@ d->data = new quint8[colorSpace->pixelSize()]; memset(d->data, 0, d->colorSpace->pixelSize()); - src.colorSpace()->convertPixelsTo(src.d->data, d->data, colorSpace, 1, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + src.colorSpace()->convertPixelsTo(src.d->data, d->data, colorSpace, 1, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } KoColor::KoColor(const KoColor & rhs) @@ -161,8 +161,8 @@ void KoColor::convertTo(const KoColorSpace * cs) { convertTo(cs, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } void KoColor::setColor(const quint8 * data, const KoColorSpace * colorSpace) @@ -229,7 +229,7 @@ void KoColor::fromKoColor(const KoColor& src) { - src.colorSpace()->convertPixelsTo(src.d->data, d->data, colorSpace(), 1, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + src.colorSpace()->convertPixelsTo(src.d->data, d->data, colorSpace(), 1, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); } const KoColorProfile * KoColor::profile() const Index: libs/pigment/KoColorConversionSystem.cpp =================================================================== --- libs/pigment/KoColorConversionSystem.cpp +++ libs/pigment/KoColorConversionSystem.cpp @@ -289,10 +289,10 @@ } Q_ASSERT(bestPath); const KoColorSpace* endColorSpace = defaultColorSpaceForNode(bestPath->endNode()); - fromCS = createTransformationFromPath(bestPath, colorSpace, endColorSpace, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + fromCS = createTransformationFromPath(bestPath, colorSpace, endColorSpace, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); Path* returnPath = findBestPath(bestPath->endNode(), csNode); Q_ASSERT(returnPath); - toCS = createTransformationFromPath(returnPath, endColorSpace, colorSpace, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + toCS = createTransformationFromPath(returnPath, endColorSpace, colorSpace, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); Q_ASSERT(*toCS->dstColorSpace() == *fromCS->srcColorSpace()); Q_ASSERT(*fromCS->dstColorSpace() == *toCS->srcColorSpace()); } Index: libs/pigment/KoColorConversionTransformation.h =================================================================== --- libs/pigment/KoColorConversionTransformation.h +++ libs/pigment/KoColorConversionTransformation.h @@ -80,11 +80,11 @@ * following default values should be used. */ - static Intent InternalRenderingIntent; - static ConversionFlags InternalConversionFlags; + static Intent internalRenderingIntent() { return IntentPerceptual; } + static ConversionFlags internalConversionFlags() { return BlackpointCompensation; } - static Intent AdjustmentRenderingIntent; - static ConversionFlags AdjustmentConversionFlags; + static Intent adjustmentRenderingIntent() { return IntentPerceptual; } + static ConversionFlags adjustmentConversionFlags() { return ConversionFlags(BlackpointCompensation | NoWhiteOnWhiteFixup); } public: KoColorConversionTransformation(const KoColorSpace* srcCs, Index: libs/pigment/KoColorConversionTransformation.cpp =================================================================== --- libs/pigment/KoColorConversionTransformation.cpp +++ libs/pigment/KoColorConversionTransformation.cpp @@ -21,13 +21,6 @@ #include "KoColorSpace.h" -KoColorConversionTransformation::Intent KoColorConversionTransformation::InternalRenderingIntent = IntentPerceptual; -KoColorConversionTransformation::ConversionFlags KoColorConversionTransformation::InternalConversionFlags = BlackpointCompensation; - -KoColorConversionTransformation::Intent KoColorConversionTransformation::AdjustmentRenderingIntent = IntentPerceptual; -KoColorConversionTransformation::ConversionFlags KoColorConversionTransformation::AdjustmentConversionFlags = BlackpointCompensation | NoWhiteOnWhiteFixup; - - struct Q_DECL_HIDDEN KoColorConversionTransformation::Private { const KoColorSpace* srcColorSpace; const KoColorSpace* dstColorSpace; Index: libs/pigment/KoColorSpace.cpp =================================================================== --- libs/pigment/KoColorSpace.cpp +++ libs/pigment/KoColorSpace.cpp @@ -166,29 +166,29 @@ const KoColorConversionTransformation* KoColorSpace::toLabA16Converter() const { if (!d->transfoToLABA16) { - d->transfoToLABA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(this, KoColorSpaceRegistry::instance()->lab16(""), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags) ; + d->transfoToLABA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(this, KoColorSpaceRegistry::instance()->lab16(""), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()) ; } return d->transfoToLABA16; } const KoColorConversionTransformation* KoColorSpace::fromLabA16Converter() const { if (!d->transfoFromLABA16) { - d->transfoFromLABA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(KoColorSpaceRegistry::instance()->lab16(""), this, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags) ; + d->transfoFromLABA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(KoColorSpaceRegistry::instance()->lab16(""), this, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()) ; } return d->transfoFromLABA16; } const KoColorConversionTransformation* KoColorSpace::toRgbA16Converter() const { if (!d->transfoToRGBA16) { - d->transfoToRGBA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(this, KoColorSpaceRegistry::instance()->rgb16(""), KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags) ; + d->transfoToRGBA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(this, KoColorSpaceRegistry::instance()->rgb16(""), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()) ; } return d->transfoToRGBA16; } const KoColorConversionTransformation* KoColorSpace::fromRgbA16Converter() const { if (!d->transfoFromRGBA16) { - d->transfoFromRGBA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(KoColorSpaceRegistry::instance()->rgb16("") , this, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags) ; + d->transfoFromRGBA16 = KoColorSpaceRegistry::instance()->colorConversionSystem()->createColorConverter(KoColorSpaceRegistry::instance()->rgb16("") , this, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()) ; } return d->transfoFromRGBA16; } Index: libs/pigment/KoCopyColorConversionTransformation.cpp =================================================================== --- libs/pigment/KoCopyColorConversionTransformation.cpp +++ libs/pigment/KoCopyColorConversionTransformation.cpp @@ -23,7 +23,7 @@ // --- KoCopyColorConversionTransformation --- KoCopyColorConversionTransformation::KoCopyColorConversionTransformation(const KoColorSpace* cs) - : KoColorConversionTransformation(cs, cs, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags) + : KoColorConversionTransformation(cs, cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()) { } void KoCopyColorConversionTransformation::transform(const quint8 *srcU8, quint8 *dstU8, qint32 nPixels) const Index: libs/pigment/KoFallBackColorTransformation.cpp =================================================================== --- libs/pigment/KoFallBackColorTransformation.cpp +++ libs/pigment/KoFallBackColorTransformation.cpp @@ -41,9 +41,9 @@ KoFallBackColorTransformation::KoFallBackColorTransformation(const KoColorSpace* _cs, const KoColorSpace* _fallBackCS, KoColorTransformation* _transfo) : d(new Private) { d->fallBackColorSpace = _fallBackCS; - d->csToFallBackCache = new KoCachedColorConversionTransformation(KoColorSpaceRegistry::instance()->colorConversionCache()->cachedConverter(_cs, _fallBackCS, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags)); + d->csToFallBackCache = new KoCachedColorConversionTransformation(KoColorSpaceRegistry::instance()->colorConversionCache()->cachedConverter(_cs, _fallBackCS, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags())); d->csToFallBack = d->csToFallBackCache->transformation(); - d->fallBackToCsCache = new KoCachedColorConversionTransformation(KoColorSpaceRegistry::instance()->colorConversionCache()->cachedConverter(_fallBackCS, _cs, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags)); + d->fallBackToCsCache = new KoCachedColorConversionTransformation(KoColorSpaceRegistry::instance()->colorConversionCache()->cachedConverter(_fallBackCS, _cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags())); d->fallBackToCs = d->fallBackToCsCache->transformation(); d->colorTransformation = _transfo; d->buff = 0; Index: libs/pigment/KoScaleColorConversionTransformation.h =================================================================== --- libs/pigment/KoScaleColorConversionTransformation.h +++ libs/pigment/KoScaleColorConversionTransformation.h @@ -55,7 +55,7 @@ ((srcColorDepthId() == Float32BitsColorDepthID.id()) && (dstColorDepthId() == Float16BitsColorDepthID.id()))) { } - virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::InternalRenderingIntent) const { + virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent()) const { Q_UNUSED(renderingIntent); Q_ASSERT(canBeSource(srcColorSpace)); Q_ASSERT(canBeDestination(dstColorSpace)); Index: libs/pigment/colorspaces/KoSimpleColorSpace.h =================================================================== --- libs/pigment/colorspaces/KoSimpleColorSpace.h +++ libs/pigment/colorspaces/KoSimpleColorSpace.h @@ -132,8 +132,8 @@ } else { const KoColorSpace* dstCs = KoColorSpaceRegistry::instance()->lab16(); convertPixelsTo(src, dst, dstCs, nPixels, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } } @@ -143,8 +143,8 @@ } else { const KoColorSpace* srcCs = KoColorSpaceRegistry::instance()->lab16(); srcCs->convertPixelsTo(src, dst, this, nPixels, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } } @@ -154,8 +154,8 @@ } else { const KoColorSpace* dstCs = KoColorSpaceRegistry::instance()->rgb16(); convertPixelsTo(src, dst, dstCs, nPixels, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } } @@ -165,8 +165,8 @@ } else { const KoColorSpace* srcCs = KoColorSpaceRegistry::instance()->rgb16(); srcCs->convertPixelsTo(src, dst, this, nPixels, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); } } Index: libs/pigment/colorspaces/KoSimpleColorSpaceEngine.cpp =================================================================== --- libs/pigment/colorspaces/KoSimpleColorSpaceEngine.cpp +++ libs/pigment/colorspaces/KoSimpleColorSpaceEngine.cpp @@ -36,8 +36,8 @@ public: KoSimpleColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs) : KoColorConversionTransformation(srcCs, dstCs, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags) { + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()) { } ~KoSimpleColorConversionTransformation() { Index: libs/store/CMakeLists.txt =================================================================== --- libs/store/CMakeLists.txt +++ libs/store/CMakeLists.txt @@ -1,3 +1,7 @@ +find_package(KF5 ${MINIMUM_KF5_VERSION} + OPTIONAL_COMPONENTS Wallet +) + include_directories({KOVERSION_INCLUDES}) add_subdirectory(tests) @@ -25,8 +29,12 @@ add_library(kostore SHARED ${kostore_LIB_SRCS}) generate_export_header(kostore BASE_NAME kostore) -target_link_libraries(kostore Qt5::Xml Qt5::Gui KF5::Archive KF5::Wallet KF5::KIOWidgets KF5::I18n KF5::KIOCore) -#target_link_libraries(kostore LINK_INTERFACE_LIBRARIES KF5::I18n Qt5::PrintSupport Qt5::Gui Qt5::Xml) +target_link_libraries(kostore Qt5::Core Qt5::Xml Qt5::Gui KF5::Archive KF5::KIOWidgets KF5::I18n KF5::KIOCore) +target_link_libraries(kostore LINK_INTERFACE_LIBRARIES KF5::I18n Qt5::PrintSupport Qt5::Gui Qt5::Xml) +if( KF5Wallet_FOUND ) + target_link_libraries(kostore KF5::Wallet) + add_definitions( -DKF5Wallet ) +endif() if( Qca-qt5_FOUND ) target_link_libraries(kostore qca-qt5) endif() Index: libs/store/KoEncryptedStore.cpp =================================================================== --- libs/store/KoEncryptedStore.cpp +++ libs/store/KoEncryptedStore.cpp @@ -17,7 +17,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef QCA2 +#if defined QCA2 && defined KF5Wallet #include "KoEncryptedStore.h" #include "KoEncryptionChecker.h" @@ -848,4 +848,4 @@ return (entry && entry->isFile()) || (absPath == MANIFEST_FILE && !m_manifestBuffer.isNull()); } -#endif // QCA2 +#endif // QCA2 && KF5Wallet Index: libs/store/KoStore.cpp =================================================================== --- libs/store/KoStore.cpp +++ libs/store/KoStore.cpp @@ -25,8 +25,9 @@ #include "KoTarStore.h" #include "KoZipStore.h" #include "KoDirectoryStore.h" -#ifdef QCA2 -#include "KoEncryptedStore.h" +#if defined QCA2 && defined KF5Wallet +# define HAVE_KOENCRYPTEDSTORE +# include "KoEncryptedStore.h" #endif #include @@ -78,16 +79,16 @@ case Tar: return new KoTarStore(fileName, mode, appIdentification, writeMimetype); case Zip: -#ifdef QCA2 +#ifdef HAVE_KOENCRYPTEDSTORE if (automatic && mode == Read) { // When automatically detecting, this might as well be an encrypted file. We'll need to check anyway, so we'll just use the encrypted store. return new KoEncryptedStore(fileName, Read, appIdentification, writeMimetype); } #endif return new KoZipStore(fileName, mode, appIdentification, writeMimetype); case Directory: return new KoDirectoryStore(fileName /* should be a dir name.... */, mode, writeMimetype); -#ifdef QCA2 +#ifdef HAVE_KOENCRYPTEDSTORE case Encrypted: return new KoEncryptedStore(fileName, mode, appIdentification, writeMimetype); #endif @@ -118,14 +119,14 @@ errorStore << "Can't create a Directory store for a memory buffer!" << endl; // fallback case Zip: -#ifdef QCA2 +#ifdef HAVE_KOENCRYPTEDSTORE if (automatic && mode == Read) { // When automatically detecting, this might as well be an encrypted file. We'll need to check anyway, so we'll just use the encrypted store. return new KoEncryptedStore(device, Read, appIdentification, writeMimetype); } #endif return new KoZipStore(device, mode, appIdentification, writeMimetype); -#ifdef QCA2 +#ifdef HAVE_KOENCRYPTEDSTORE case Encrypted: return new KoEncryptedStore(device, mode, appIdentification, writeMimetype); #endif @@ -164,14 +165,14 @@ case Tar: return new KoTarStore(window, url, tmpFile, mode, appIdentification); case Zip: -#ifdef QCA2 +#ifdef HAVE_KOENCRYPTEDSTORE if (automatic && mode == Read) { // When automatically detecting, this might as well be an encrypted file. We'll need to check anyway, so we'll just use the encrypted store. return new KoEncryptedStore(window, url, tmpFile, Read, appIdentification, writeMimetype); } #endif return new KoZipStore(window, url, tmpFile, mode, appIdentification, writeMimetype); -#ifdef QCA2 +#ifdef HAVE_KOENCRYPTEDSTORE case Encrypted: return new KoEncryptedStore(window, url, tmpFile, mode, appIdentification, writeMimetype); #endif Index: libs/widgets/CMakeLists.txt =================================================================== --- libs/widgets/CMakeLists.txt +++ libs/widgets/CMakeLists.txt @@ -37,7 +37,6 @@ KoZoomMode.cpp KoDpi.cpp KoGlobal.cpp - KoFileDialog.cpp KoColorPatch.cpp KoColorPopupAction.cpp KoColorSetWidget.cpp @@ -147,7 +146,6 @@ KoZoomHandler.h KoZoomMode.h KoGlobal.h - KoFileDialog.h KoColorPatch.h KoStrokeConfigWidget.h KoFillConfigWidget.h @@ -176,14 +174,3 @@ DESTINATION ${INCLUDE_INSTALL_DIR}/calligra COMPONENT Devel) - -set(filedialogtester_SRCS - KoFileDialogTester.cpp - main.cpp -) -ki18n_wrap_ui(filedialogtester_SRCS - KoFileDialogTester.ui -) - -add_executable(filedialogtester ${filedialogtester_SRCS}) -target_link_libraries(filedialogtester kowidgets) Index: libs/widgets/KoFileDialog.h =================================================================== --- libs/widgets/KoFileDialog.h +++ /dev/null @@ -1,155 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2013 - 2014 Yue Liu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#ifndef KOFILEDIALOG_H -#define KOFILEDIALOG_H - -#include "kowidgets_export.h" - -#include -#include -#include -#include -#include - - -/** - * Wrapper around QFileDialog providing native file dialogs - * on KDE/Gnome/Windows/OSX/etc. - */ -class KOWIDGETS_EXPORT KoFileDialog : public QObject -{ - Q_OBJECT - -public: - enum DialogType { - OpenFile, - OpenFiles, - OpenDirectory, - ImportFile, - ImportFiles, - ImportDirectory, - SaveFile - }; - - /** - * @brief constructor - * @param parent The parent of the file dialog - * @param dialogType usage of the file dialog - * @param dialogName the name for the file dialog. This will be used to open - * the filedialog in the last open location, instead the specified directory. - * - * @return The name of the entry user selected in the file dialog - * - */ - KoFileDialog(QWidget *parent, - KoFileDialog::DialogType type, - const QString &dialogName); - - ~KoFileDialog(); - - void setCaption(const QString &caption); - - /** - * @brief setDefaultDir set the default directory to defaultDir - * - * @param defaultDir a path to a file or directory - */ - void setDefaultDir(const QString &defaultDir, bool override = false); - - /** - * @brief setOverrideDir override both the default dir and the saved dir found by dialogName - * @param overrideDir a path to a file or directory - */ - void setOverrideDir(const QString &overrideDir); - - /** - * @brief setImageFilters sets the name filters for the file dialog to all - * image formats Qt's QImageReader supports. - */ - void setImageFilters(); - - void setNameFilter(const QString &filter); - - /** - * @brief setNameFilters set a list of description/extension pairs. - * - * These are not registered mimetypes. In contrast with Qt's filedialog namefilters, - * you can only have _one_ pair per line. I.e. - * - * Gif Image (*gif) - * Tiff Image (*tif) - * - * And NOT Images (*gif *tif) - * - * @param filterList - * @param defaultFilter - */ - void setNameFilters(const QStringList &filterList, - QString defaultFilter = QString()); - void setMimeTypeFilters(const QStringList &filterList, - QString defaultFilter = QString()); - void setHideNameFilterDetailsOption(); - - QStringList nameFilters() const; - - QStringList filenames(); - QString filename(); - - /** - * @brief selectedNameFilter returns the name filter the user selected, either - * directory or by clicking on it. - * @return - */ - QString selectedNameFilter() const; - - QString selectedMimeType() const; - -private Q_SLOTS: - - void filterSelected(const QString &filter); - -private: - /** - * @brief splitNameFilter take a single line of a QDialog name filter and split it - * into several lines. This is needed because a single line name filter can contain - * more than one mimetype, making it impossible to figure out the correct extension. - * - * The methods takes care of some duplicated extensions, like jpeg and jpg. - * @param nameFilter the namefilter to be split - * @param mimeList a pointer to the list with mimes that shouldn't be added. - * @return a stringlist of all name filters. - */ - static QStringList splitNameFilter(const QString &nameFilter, QStringList *mimeList); - - void createFileDialog(); - - QString getUsedDir(const QString &dialogName); - void saveUsedDir(const QString &fileName, const QString &dialogName); - - const QStringList getFilterStringListFromMime(const QStringList &mimeList, - bool withAllSupportedEntry = false); - - - - class Private; - Private * const d; -}; - -#endif /* KOFILEDIALOG_H */ Index: libs/widgets/KoFileDialog.cpp =================================================================== --- libs/widgets/KoFileDialog.cpp +++ /dev/null @@ -1,502 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2013 - 2014 Yue Liu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#include "KoFileDialog.h" -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -class Q_DECL_HIDDEN KoFileDialog::Private -{ -public: - Private(QWidget *parent_, - KoFileDialog::DialogType dialogType_, - const QString caption_, - const QString defaultDir_, - const QString dialogName_) - : parent(parent_) - , type(dialogType_) - , dialogName(dialogName_) - , caption(caption_) - , defaultDirectory(defaultDir_) - , filterList(QStringList()) - , defaultFilter(QString()) - , useStaticForNative(false) - , hideDetails(false) - , swapExtensionOrder(false) - { - // Force the native file dialogs on Windows. Except for KDE, the native file dialogs are only possible - // using the static methods. The Qt documentation is wrong here, if it means what it says " By default, - // the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT - // macro." -#ifdef Q_OS_WIN - useStaticForNative = true; -#endif - // Non-static KDE file is broken when called with QFileDialog::AcceptSave: - // then the directory above defaultdir is opened, and defaultdir is given as the default file name... - // - // So: in X11, use static methods inside KDE, which give working native dialogs, but non-static outside - // KDE, which gives working Qt dialogs. - // - // Only show the GTK dialog in Gnome, where people deserve it -#ifdef HAVE_X11 - if (qgetenv("KDE_FULL_SESSION").size() > 0) { - useStaticForNative = true; - } - if (qgetenv("XDG_CURRENT_DESKTOP") == "GNOME") { - useStaticForNative = true; - QClipboard *cb = QApplication::clipboard(); - cb->blockSignals(true); - swapExtensionOrder = true; - } - -#endif - } - - ~Private() - { - if (qgetenv("XDG_CURRENT_DESKTOP") == "GNOME") { - useStaticForNative = true; - QClipboard *cb = QApplication::clipboard(); - cb->blockSignals(false); - } - } - - QWidget *parent; - KoFileDialog::DialogType type; - QString dialogName; - QString caption; - QString defaultDirectory; - QStringList filterList; - QString defaultFilter; - QScopedPointer fileDialog; - QMimeType mimeType; - bool useStaticForNative; - bool hideDetails; - bool swapExtensionOrder; -}; - -KoFileDialog::KoFileDialog(QWidget *parent, - KoFileDialog::DialogType type, - const QString &dialogName) - : d(new Private(parent, type, "", getUsedDir(dialogName), dialogName)) -{ -} - -KoFileDialog::~KoFileDialog() -{ - delete d; -} - -void KoFileDialog::setCaption(const QString &caption) -{ - d->caption = caption; -} - -void KoFileDialog::setDefaultDir(const QString &defaultDir, bool override) -{ - if (override || d->defaultDirectory.isEmpty() || !QFile(d->defaultDirectory).exists()) { - QFileInfo f(defaultDir); - d->defaultDirectory = f.absoluteFilePath(); - } -} - -void KoFileDialog::setOverrideDir(const QString &overrideDir) -{ - d->defaultDirectory = overrideDir; -} - -void KoFileDialog::setImageFilters() -{ - QStringList imageFilters; - // add filters for all formats supported by QImage - foreach(const QByteArray &format, QImageReader::supportedImageFormats()) { - imageFilters << QLatin1String("image/") + format; - } - setMimeTypeFilters(imageFilters); -} - -void KoFileDialog::setNameFilter(const QString &filter) -{ - d->filterList.clear(); - if (d->type == KoFileDialog::SaveFile) { - QStringList mimeList; - d->filterList << splitNameFilter(filter, &mimeList); - d->defaultFilter = d->filterList.first(); - } - else { - d->filterList << filter; - } -} - -void KoFileDialog::setNameFilters(const QStringList &filterList, - QString defaultFilter) -{ - d->filterList.clear(); - - if (d->type == KoFileDialog::SaveFile) { - QStringList mimeList; - foreach(const QString &filter, filterList) { - d->filterList << splitNameFilter(filter, &mimeList); - } - - if (!defaultFilter.isEmpty()) { - mimeList.clear(); - QStringList defaultFilters = splitNameFilter(defaultFilter, &mimeList); - if (defaultFilters.size() > 0) { - defaultFilter = defaultFilters.first(); - } - } - } - else { - d->filterList = filterList; - } - d->defaultFilter = defaultFilter; - -} - -void KoFileDialog::setMimeTypeFilters(const QStringList &filterList, - QString defaultFilter) -{ - d->filterList = getFilterStringListFromMime(filterList, true); - - if (!defaultFilter.isEmpty()) { - QStringList defaultFilters = getFilterStringListFromMime(QStringList() << defaultFilter, false); - if (defaultFilters.size() > 0) { - defaultFilter = defaultFilters.first(); - } - } - d->defaultFilter = defaultFilter; -} - -void KoFileDialog::setHideNameFilterDetailsOption() -{ - d->hideDetails = true; -} - -QStringList KoFileDialog::nameFilters() const -{ - return d->filterList; -} - -QString KoFileDialog::selectedNameFilter() const -{ - if (!d->useStaticForNative) { - return d->fileDialog->selectedNameFilter(); - } - else { - return d->defaultFilter; - } -} - -QString KoFileDialog::selectedMimeType() const -{ - if (d->mimeType.isValid()) { - return d->mimeType.name(); - } - else { - return ""; - } -} - -void KoFileDialog::createFileDialog() -{ - d->fileDialog.reset(new QFileDialog(d->parent, d->caption, d->defaultDirectory)); - - if (d->type == SaveFile) { - d->fileDialog->setAcceptMode(QFileDialog::AcceptSave); - d->fileDialog->setFileMode(QFileDialog::AnyFile); - } - else { // open / import - - d->fileDialog->setAcceptMode(QFileDialog::AcceptOpen); - - if (d->type == ImportDirectory - || d->type == OpenDirectory) - { - d->fileDialog->setFileMode(QFileDialog::Directory); - d->fileDialog->setOption(QFileDialog::ShowDirsOnly, true); - } - else { // open / import file(s) - if (d->type == OpenFile - || d->type == ImportFile) - { - d->fileDialog->setFileMode(QFileDialog::ExistingFile); - } - else { // files - d->fileDialog->setFileMode(QFileDialog::ExistingFiles); - } - } - } - - d->fileDialog->setNameFilters(d->filterList); - if (!d->defaultFilter.isEmpty()) { - d->fileDialog->selectNameFilter(d->defaultFilter); - } - - if (d->type == ImportDirectory || - d->type == ImportFile || d->type == ImportFiles || - d->type == SaveFile) { - d->fileDialog->setWindowModality(Qt::WindowModal); - } - - if (d->hideDetails) { - d->fileDialog->setOption(QFileDialog::HideNameFilterDetails); - } - - connect(d->fileDialog.data(), SIGNAL(filterSelected(QString)), this, SLOT(filterSelected(QString))); -} - -QString KoFileDialog::filename() -{ - QString url; - if (!d->useStaticForNative) { - - if (!d->fileDialog) { - createFileDialog(); - } - - if (d->fileDialog->exec() == QDialog::Accepted) { - url = d->fileDialog->selectedFiles().first(); - } - } - else { - switch (d->type) { - case OpenFile: - { - url = QFileDialog::getOpenFileName(d->parent, - d->caption, - d->defaultDirectory, - d->filterList.join(";;"), - &d->defaultFilter); - break; - } - case OpenDirectory: - { - url = QFileDialog::getExistingDirectory(d->parent, - d->caption, - d->defaultDirectory, - QFileDialog::ShowDirsOnly); - break; - } - case ImportFile: - { - url = QFileDialog::getOpenFileName(d->parent, - d->caption, - d->defaultDirectory, - d->filterList.join(";;"), - &d->defaultFilter); - break; - } - case ImportDirectory: - { - url = QFileDialog::getExistingDirectory(d->parent, - d->caption, - d->defaultDirectory, - QFileDialog::ShowDirsOnly); - break; - } - case SaveFile: - { - url = QFileDialog::getSaveFileName(d->parent, - d->caption, - d->defaultDirectory, - d->filterList.join(";;"), - &d->defaultFilter); - break; - } - default: - ; - } - } - - if (!url.isEmpty()) { - - if (d->type == SaveFile && QFileInfo(url).suffix().isEmpty()) { - int start = d->defaultFilter.lastIndexOf("*.") + 1; - int end = d->defaultFilter.lastIndexOf(" )"); - int n = end - start; - QString extension = d->defaultFilter.mid(start, n); - url.append(extension); - } - - QMimeDatabase db; - d->mimeType = db.mimeTypeForFile(url); - saveUsedDir(url, d->dialogName); - } - return url; -} - -QStringList KoFileDialog::filenames() -{ - QStringList urls; - - if (!d->useStaticForNative) { - if (!d->fileDialog) { - createFileDialog(); - } - if (d->fileDialog->exec() == QDialog::Accepted) { - urls = d->fileDialog->selectedFiles(); - } - } - else { - switch (d->type) { - case OpenFiles: - case ImportFiles: - { - urls = QFileDialog::getOpenFileNames(d->parent, - d->caption, - d->defaultDirectory, - d->filterList.join(";;"), - &d->defaultFilter); - break; - } - default: - ; - } - } - if (urls.size() > 0) { - saveUsedDir(urls.first(), d->dialogName); - } - return urls; -} - -void KoFileDialog::filterSelected(const QString &filter) -{ - // "Windows BMP image ( *.bmp )"; - int start = filter.lastIndexOf("*.") + 2; - int end = filter.lastIndexOf(" )"); - int n = end - start; - QString extension = filter.mid(start, n); - d->defaultFilter = filter; - d->fileDialog->setDefaultSuffix(extension); -} - -QStringList KoFileDialog::splitNameFilter(const QString &nameFilter, QStringList *mimeList) -{ - Q_ASSERT(mimeList); - - QStringList filters; - QString description; - - if (nameFilter.contains("(")) { - description = nameFilter.left(nameFilter.indexOf("(") -1).trimmed(); - } - - QStringList entries = nameFilter.mid(nameFilter.indexOf("(") + 1).split(" ",QString::SkipEmptyParts ); - - foreach(QString entry, entries) { - - entry = entry.remove("*"); - entry = entry.remove(")"); - - QMimeDatabase db; - QMimeType mime = db.mimeTypeForName("bla" + entry); - if (mime.name() != "application/octet-stream") { - if (!mimeList->contains(mime.name())) { - mimeList->append(mime.name()); - filters.append(mime.comment() + " ( *" + entry + " )"); - } - } - else { - filters.append(entry.remove(".").toUpper() + " " + description + " ( *." + entry + " )"); - } - } - - return filters; -} - -const QStringList KoFileDialog::getFilterStringListFromMime(const QStringList &mimeList, - bool withAllSupportedEntry) -{ - QStringList mimeSeen; - - QStringList ret; - if (withAllSupportedEntry) { - ret << QString(); - } - - for (QStringList::ConstIterator - it = mimeList.begin(); it != mimeList.end(); ++it) { - QMimeDatabase db; - QMimeType mimeType = db.mimeTypeForName(*it); - if (!mimeType.isValid()) { - continue; - } - if (!mimeSeen.contains(mimeType.name())) { - QString oneFilter; - QStringList patterns = mimeType.globPatterns(); - QStringList::ConstIterator jt; - for (jt = patterns.constBegin(); jt != patterns.constEnd(); ++jt) { - if (d->swapExtensionOrder) { - oneFilter.prepend(*jt + " "); - if (withAllSupportedEntry) { - ret[0].prepend(*jt + " "); - } - } - else { - oneFilter.append(*jt + " "); - if (withAllSupportedEntry) { - ret[0].append(*jt + " "); - } - } - } - oneFilter = mimeType.comment() + " ( " + oneFilter + ")"; - ret << oneFilter; - mimeSeen << mimeType.name(); - } - } - - if (withAllSupportedEntry) { - ret[0] = i18n("All supported formats") + " ( " + ret[0] + (")"); - } - return ret; -} - -QString KoFileDialog::getUsedDir(const QString &dialogName) -{ - if (dialogName.isEmpty()) return ""; - - KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); - QString dir = group.readEntry(dialogName); - - return dir; -} - -void KoFileDialog::saveUsedDir(const QString &fileName, - const QString &dialogName) -{ - - if (dialogName.isEmpty()) return; - - QFileInfo fileInfo(fileName); - KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); - group.writeEntry(dialogName, fileInfo.absolutePath()); - -} Index: libs/widgets/KoFileDialogTester.h =================================================================== --- libs/widgets/KoFileDialogTester.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) Boudewijn Rempt , (C) 2014 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifndef KOFILEDIALOGTESTER_H -#define KOFILEDIALOGTESTER_H - -#include - -namespace Ui { -class KoFileDialogTester; -} - -class KoFileDialogTester : public QWidget -{ - Q_OBJECT - -public: - explicit KoFileDialogTester(QWidget *parent = 0); - ~KoFileDialogTester(); - -private Q_SLOTS: - - void testOpenFile(); - void testOpenFiles(); - void testOpenDirectory(); - void testImportFile(); - void testImportFiles(); - void testImportDirectory(); - void testSaveFile(); - -private: - Ui::KoFileDialogTester *ui; - - QStringList m_nameFilters; - QStringList m_mimeFilter; -}; - -#endif // KOFILEDIALOGTESTER_H Index: libs/widgets/KoFileDialogTester.cpp =================================================================== --- libs/widgets/KoFileDialogTester.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) Boudewijn Rempt , (C) 2014 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#include "KoFileDialogTester.h" - -#include "ui_KoFileDialogTester.h" - -#include -#include -#include -#include - -#include - -KoFileDialogTester::KoFileDialogTester(QWidget *parent) : - QWidget(parent), - ui(new Ui::KoFileDialogTester) -{ - ui->setupUi(this); - - connect(ui->bnOpenFile, SIGNAL(clicked()), SLOT(testOpenFile())); - connect(ui->bnOpenFiles, SIGNAL(clicked()), SLOT(testOpenFiles())); - connect(ui->bnOpenDirectory, SIGNAL(clicked()), SLOT(testOpenDirectory())); - connect(ui->bnImportFile, SIGNAL(clicked()), SLOT(testImportFile())); - connect(ui->bnImportFiles, SIGNAL(clicked()), SLOT(testImportFiles())); - connect(ui->bnImportDirectory, SIGNAL(clicked()), SLOT(testImportDirectory())); - connect(ui->bnSaveFile, SIGNAL(clicked()), SLOT(testSaveFile())); - - m_nameFilters << "Documents (*.odt *.doc *.txt)" - << "Images (*.png *.jpg *.jpeg)" - << "Presentations (*.ppt *.odp)" - << "Patterns (*.pat *.jpg *.gif *.png *.tif *.xpm *.bmp)" - << "Palettes (*.gpl *.pal *.act *.aco *.colors)"; - - m_mimeFilter = QStringList() - << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop" - << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap" - << "image/x-portable-bitmap" << "image/png" << "image/jp2" - << "image/tiff" << "application/vnd.oasis.opendocument.graphics" - << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap" - << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook" - << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed" - << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript" - << "image/x-wmf" << "application/x-karbon" - << "image/tiff" << "application/vnd.oasis.opendocument.graphics" - ; -} - -KoFileDialogTester::~KoFileDialogTester() -{ - delete ui; -} - - - -void KoFileDialogTester::testOpenFile() -{ - ui->listResults->clear(); - KoFileDialog dlg(this, KoFileDialog::OpenFile, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: OpenFile")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - } - else { - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QString url = dlg.filename(); - ui->listResults->addItem(url); - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); - -} - -void KoFileDialogTester::testOpenFiles() -{ - ui->listResults->clear(); - KoFileDialog dlg(this, KoFileDialog::OpenFiles, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: OpenFile")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - - } - else { - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QStringList urls = dlg.filenames(); - foreach(const QString &url, urls) { - ui->listResults->addItem(url); - } - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); -} - -void KoFileDialogTester::testOpenDirectory() -{ - ui->listResults->clear(); - KoFileDialog dlg(this, KoFileDialog::OpenDirectory, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: OpenDirectory")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - - } - else { - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QString url = dlg.filename(); - ui->listResults->addItem(url); - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); -} - - -void KoFileDialogTester::testImportFile() -{ - ui->listResults->clear(); - - KoFileDialog dlg(this, KoFileDialog::ImportFile, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: ImportFile")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - - } - else { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QString url = dlg.filename(); - ui->listResults->addItem(url); - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); -} - -void KoFileDialogTester::testImportFiles() -{ - ui->listResults->clear(); - KoFileDialog dlg(this, KoFileDialog::ImportFiles, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: ImportFiles")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - - } - else { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QStringList urls = dlg.filenames(); foreach(const QString &url, urls) { - ui->listResults->addItem(url); - } - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); -} - -void KoFileDialogTester::testImportDirectory() -{ - ui->listResults->clear(); - KoFileDialog dlg(this, KoFileDialog::ImportDirectory, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: Import Directory")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - - } - else { - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QString url = dlg.filename(); - ui->listResults->addItem(url); - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); -} - -void KoFileDialogTester::testSaveFile() -{ - ui->listResults->clear(); - - KoFileDialog dlg(this, KoFileDialog::SaveFile, ui->txtUniqueKey->text()); - dlg.setCaption(i18n("Testing: SaveFile")); - dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - if (ui->radioName->isChecked()) { - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); - } - else { - dlg.setNameFilters(m_nameFilters); - } - } - else { - - if (ui->chkSetDefaultFilter->isChecked()) { - dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); - } - else { - dlg.setMimeTypeFilters(m_mimeFilter); - } - - } - - if (ui->chkHideNameFilterDetailsOption->isChecked()) { - dlg.setHideNameFilterDetailsOption(); - } - - QString url = dlg.filename(); - ui->listResults->addItem(url); - ui->lblMime->setText(dlg.selectedMimeType()); - ui->txtFilter->setText(dlg.selectedNameFilter()); -} Index: libs/widgets/KoFileDialogTester.ui =================================================================== --- libs/widgets/KoFileDialogTester.ui +++ /dev/null @@ -1,214 +0,0 @@ - - - KoFileDialogTester - - - - 0 - 0 - 355 - 396 - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Open File - - - - - - - Open Files - - - - - - - - - Unique key: - - - - - - - blablabla - - - - - - - - - - - - 0 - 0 - - - - Filter: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - TextLabel - - - Qt::PlainText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - false - - - - - - - - - - - Results: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - - - Filter Type - - - - - - Mime - - - - - - - Named - - - true - - - - - - - hide name filter details option - - - - - - - Set default filter - - - - - - - - - - Save File - - - - - - - Import Files - - - - - - - Import File - - - - - - - Open Directory - - - - - - - Import Directory - - - - - bnImportFile - bnOpenFile - bnOpenFiles - bnOpenDirectory - bnImportFiles - bnImportDirectory - bnSaveFile - groupBox - lblMime - - - - - Index: libs/widgets/main.cpp =================================================================== --- libs/widgets/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "KoFileDialogTester.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - KoFileDialogTester w; - w.show(); - - return a.exec(); -} Index: libs/widgets/tests/CMakeLists.txt =================================================================== --- libs/widgets/tests/CMakeLists.txt +++ libs/widgets/tests/CMakeLists.txt @@ -8,9 +8,11 @@ ########### next target ############### +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS ThreadWeaver) + set(zoomhandler_test_SRCS zoomhandler_test.cpp ) kde4_add_unit_test(zoomhandler_test TESTNAME libs-widgets-zoomhandler_test ${zoomhandler_test_SRCS}) -target_link_libraries(zoomhandler_test kowidgets Qt5::Test) +target_link_libraries(zoomhandler_test kowidgets Qt5::Test KF5::ThreadWeaver) ########### next target ############### Index: libs/widgetutils/CMakeLists.txt =================================================================== --- libs/widgetutils/CMakeLists.txt +++ libs/widgetutils/CMakeLists.txt @@ -7,6 +7,7 @@ KoUpdater.cpp KoUpdaterPrivate_p.cpp KoProperties.cpp + KoFileDialog.cpp ) @@ -30,7 +31,24 @@ KoProgressUpdater.h KoUpdater.h KoProperties.h + KoFileDialog.h ${CMAKE_CURRENT_BINARY_DIR}/kowidgetutils_export.h DESTINATION ${INCLUDE_INSTALL_DIR}/calligra COMPONENT Devel ) + +if(BUILD_TESTING) + # kofiledialogtester + + set(kofiledialogtester_SRCS + KoFileDialogTester.cpp + main.cpp + ) + + qt5_wrap_ui(kofiledialogtester_SRCS + KoFileDialogTester.ui + ) + + add_executable(kofiledialogtester ${kofiledialogtester_SRCS}) + target_link_libraries(kofiledialogtester kowidgetutils) +endif() Index: libs/widgetutils/KoFileDialog.h =================================================================== --- /dev/null +++ libs/widgetutils/KoFileDialog.h @@ -0,0 +1,155 @@ +/* This file is part of the KDE project + Copyright (C) 2013 - 2014 Yue Liu + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KOFILEDIALOG_H +#define KOFILEDIALOG_H + +#include "kowidgetutils_export.h" + +#include +#include +#include +#include +#include + + +/** + * Wrapper around QFileDialog providing native file dialogs + * on KDE/Gnome/Windows/OSX/etc. + */ +class KOWIDGETUTILS_EXPORT KoFileDialog : public QObject +{ + Q_OBJECT + +public: + enum DialogType { + OpenFile, + OpenFiles, + OpenDirectory, + ImportFile, + ImportFiles, + ImportDirectory, + SaveFile + }; + + /** + * @brief constructor + * @param parent The parent of the file dialog + * @param dialogType usage of the file dialog + * @param dialogName the name for the file dialog. This will be used to open + * the filedialog in the last open location, instead the specified directory. + * + * @return The name of the entry user selected in the file dialog + * + */ + KoFileDialog(QWidget *parent, + KoFileDialog::DialogType type, + const QString &dialogName); + + ~KoFileDialog(); + + void setCaption(const QString &caption); + + /** + * @brief setDefaultDir set the default directory to defaultDir + * + * @param defaultDir a path to a file or directory + */ + void setDefaultDir(const QString &defaultDir, bool override = false); + + /** + * @brief setOverrideDir override both the default dir and the saved dir found by dialogName + * @param overrideDir a path to a file or directory + */ + void setOverrideDir(const QString &overrideDir); + + /** + * @brief setImageFilters sets the name filters for the file dialog to all + * image formats Qt's QImageReader supports. + */ + void setImageFilters(); + + void setNameFilter(const QString &filter); + + /** + * @brief setNameFilters set a list of description/extension pairs. + * + * These are not registered mimetypes. In contrast with Qt's filedialog namefilters, + * you can only have _one_ pair per line. I.e. + * + * Gif Image (*gif) + * Tiff Image (*tif) + * + * And NOT Images (*gif *tif) + * + * @param filterList + * @param defaultFilter + */ + void setNameFilters(const QStringList &filterList, + QString defaultFilter = QString()); + void setMimeTypeFilters(const QStringList &filterList, + QString defaultFilter = QString()); + void setHideNameFilterDetailsOption(); + + QStringList nameFilters() const; + + QStringList filenames(); + QString filename(); + + /** + * @brief selectedNameFilter returns the name filter the user selected, either + * directory or by clicking on it. + * @return + */ + QString selectedNameFilter() const; + + QString selectedMimeType() const; + +private Q_SLOTS: + + void filterSelected(const QString &filter); + +private: + /** + * @brief splitNameFilter take a single line of a QDialog name filter and split it + * into several lines. This is needed because a single line name filter can contain + * more than one mimetype, making it impossible to figure out the correct extension. + * + * The methods takes care of some duplicated extensions, like jpeg and jpg. + * @param nameFilter the namefilter to be split + * @param mimeList a pointer to the list with mimes that shouldn't be added. + * @return a stringlist of all name filters. + */ + static QStringList splitNameFilter(const QString &nameFilter, QStringList *mimeList); + + void createFileDialog(); + + QString getUsedDir(const QString &dialogName); + void saveUsedDir(const QString &fileName, const QString &dialogName); + + const QStringList getFilterStringListFromMime(const QStringList &mimeList, + bool withAllSupportedEntry = false); + + + + class Private; + Private * const d; +}; + +#endif /* KOFILEDIALOG_H */ Index: libs/widgetutils/KoFileDialog.cpp =================================================================== --- /dev/null +++ libs/widgetutils/KoFileDialog.cpp @@ -0,0 +1,502 @@ +/* This file is part of the KDE project + Copyright (C) 2013 - 2014 Yue Liu + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "KoFileDialog.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +class Q_DECL_HIDDEN KoFileDialog::Private +{ +public: + Private(QWidget *parent_, + KoFileDialog::DialogType dialogType_, + const QString caption_, + const QString defaultDir_, + const QString dialogName_) + : parent(parent_) + , type(dialogType_) + , dialogName(dialogName_) + , caption(caption_) + , defaultDirectory(defaultDir_) + , filterList(QStringList()) + , defaultFilter(QString()) + , useStaticForNative(false) + , hideDetails(false) + , swapExtensionOrder(false) + { + // Force the native file dialogs on Windows. Except for KDE, the native file dialogs are only possible + // using the static methods. The Qt documentation is wrong here, if it means what it says " By default, + // the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT + // macro." +#ifdef Q_OS_WIN + useStaticForNative = true; +#endif + // Non-static KDE file is broken when called with QFileDialog::AcceptSave: + // then the directory above defaultdir is opened, and defaultdir is given as the default file name... + // + // So: in X11, use static methods inside KDE, which give working native dialogs, but non-static outside + // KDE, which gives working Qt dialogs. + // + // Only show the GTK dialog in Gnome, where people deserve it +#ifdef HAVE_X11 + if (qgetenv("KDE_FULL_SESSION").size() > 0) { + useStaticForNative = true; + } + if (qgetenv("XDG_CURRENT_DESKTOP") == "GNOME") { + useStaticForNative = true; + QClipboard *cb = QApplication::clipboard(); + cb->blockSignals(true); + swapExtensionOrder = true; + } + +#endif + } + + ~Private() + { + if (qgetenv("XDG_CURRENT_DESKTOP") == "GNOME") { + useStaticForNative = true; + QClipboard *cb = QApplication::clipboard(); + cb->blockSignals(false); + } + } + + QWidget *parent; + KoFileDialog::DialogType type; + QString dialogName; + QString caption; + QString defaultDirectory; + QStringList filterList; + QString defaultFilter; + QScopedPointer fileDialog; + QMimeType mimeType; + bool useStaticForNative; + bool hideDetails; + bool swapExtensionOrder; +}; + +KoFileDialog::KoFileDialog(QWidget *parent, + KoFileDialog::DialogType type, + const QString &dialogName) + : d(new Private(parent, type, "", getUsedDir(dialogName), dialogName)) +{ +} + +KoFileDialog::~KoFileDialog() +{ + delete d; +} + +void KoFileDialog::setCaption(const QString &caption) +{ + d->caption = caption; +} + +void KoFileDialog::setDefaultDir(const QString &defaultDir, bool override) +{ + if (override || d->defaultDirectory.isEmpty() || !QFile(d->defaultDirectory).exists()) { + QFileInfo f(defaultDir); + d->defaultDirectory = f.absoluteFilePath(); + } +} + +void KoFileDialog::setOverrideDir(const QString &overrideDir) +{ + d->defaultDirectory = overrideDir; +} + +void KoFileDialog::setImageFilters() +{ + QStringList imageFilters; + // add filters for all formats supported by QImage + foreach(const QByteArray &format, QImageReader::supportedImageFormats()) { + imageFilters << QLatin1String("image/") + format; + } + setMimeTypeFilters(imageFilters); +} + +void KoFileDialog::setNameFilter(const QString &filter) +{ + d->filterList.clear(); + if (d->type == KoFileDialog::SaveFile) { + QStringList mimeList; + d->filterList << splitNameFilter(filter, &mimeList); + d->defaultFilter = d->filterList.first(); + } + else { + d->filterList << filter; + } +} + +void KoFileDialog::setNameFilters(const QStringList &filterList, + QString defaultFilter) +{ + d->filterList.clear(); + + if (d->type == KoFileDialog::SaveFile) { + QStringList mimeList; + foreach(const QString &filter, filterList) { + d->filterList << splitNameFilter(filter, &mimeList); + } + + if (!defaultFilter.isEmpty()) { + mimeList.clear(); + QStringList defaultFilters = splitNameFilter(defaultFilter, &mimeList); + if (defaultFilters.size() > 0) { + defaultFilter = defaultFilters.first(); + } + } + } + else { + d->filterList = filterList; + } + d->defaultFilter = defaultFilter; + +} + +void KoFileDialog::setMimeTypeFilters(const QStringList &filterList, + QString defaultFilter) +{ + d->filterList = getFilterStringListFromMime(filterList, true); + + if (!defaultFilter.isEmpty()) { + QStringList defaultFilters = getFilterStringListFromMime(QStringList() << defaultFilter, false); + if (defaultFilters.size() > 0) { + defaultFilter = defaultFilters.first(); + } + } + d->defaultFilter = defaultFilter; +} + +void KoFileDialog::setHideNameFilterDetailsOption() +{ + d->hideDetails = true; +} + +QStringList KoFileDialog::nameFilters() const +{ + return d->filterList; +} + +QString KoFileDialog::selectedNameFilter() const +{ + if (!d->useStaticForNative) { + return d->fileDialog->selectedNameFilter(); + } + else { + return d->defaultFilter; + } +} + +QString KoFileDialog::selectedMimeType() const +{ + if (d->mimeType.isValid()) { + return d->mimeType.name(); + } + else { + return ""; + } +} + +void KoFileDialog::createFileDialog() +{ + d->fileDialog.reset(new QFileDialog(d->parent, d->caption, d->defaultDirectory)); + + if (d->type == SaveFile) { + d->fileDialog->setAcceptMode(QFileDialog::AcceptSave); + d->fileDialog->setFileMode(QFileDialog::AnyFile); + } + else { // open / import + + d->fileDialog->setAcceptMode(QFileDialog::AcceptOpen); + + if (d->type == ImportDirectory + || d->type == OpenDirectory) + { + d->fileDialog->setFileMode(QFileDialog::Directory); + d->fileDialog->setOption(QFileDialog::ShowDirsOnly, true); + } + else { // open / import file(s) + if (d->type == OpenFile + || d->type == ImportFile) + { + d->fileDialog->setFileMode(QFileDialog::ExistingFile); + } + else { // files + d->fileDialog->setFileMode(QFileDialog::ExistingFiles); + } + } + } + + d->fileDialog->setNameFilters(d->filterList); + if (!d->defaultFilter.isEmpty()) { + d->fileDialog->selectNameFilter(d->defaultFilter); + } + + if (d->type == ImportDirectory || + d->type == ImportFile || d->type == ImportFiles || + d->type == SaveFile) { + d->fileDialog->setWindowModality(Qt::WindowModal); + } + + if (d->hideDetails) { + d->fileDialog->setOption(QFileDialog::HideNameFilterDetails); + } + + connect(d->fileDialog.data(), SIGNAL(filterSelected(QString)), this, SLOT(filterSelected(QString))); +} + +QString KoFileDialog::filename() +{ + QString url; + if (!d->useStaticForNative) { + + if (!d->fileDialog) { + createFileDialog(); + } + + if (d->fileDialog->exec() == QDialog::Accepted) { + url = d->fileDialog->selectedFiles().first(); + } + } + else { + switch (d->type) { + case OpenFile: + { + url = QFileDialog::getOpenFileName(d->parent, + d->caption, + d->defaultDirectory, + d->filterList.join(";;"), + &d->defaultFilter); + break; + } + case OpenDirectory: + { + url = QFileDialog::getExistingDirectory(d->parent, + d->caption, + d->defaultDirectory, + QFileDialog::ShowDirsOnly); + break; + } + case ImportFile: + { + url = QFileDialog::getOpenFileName(d->parent, + d->caption, + d->defaultDirectory, + d->filterList.join(";;"), + &d->defaultFilter); + break; + } + case ImportDirectory: + { + url = QFileDialog::getExistingDirectory(d->parent, + d->caption, + d->defaultDirectory, + QFileDialog::ShowDirsOnly); + break; + } + case SaveFile: + { + url = QFileDialog::getSaveFileName(d->parent, + d->caption, + d->defaultDirectory, + d->filterList.join(";;"), + &d->defaultFilter); + break; + } + default: + ; + } + } + + if (!url.isEmpty()) { + + if (d->type == SaveFile && QFileInfo(url).suffix().isEmpty()) { + int start = d->defaultFilter.lastIndexOf("*.") + 1; + int end = d->defaultFilter.lastIndexOf(" )"); + int n = end - start; + QString extension = d->defaultFilter.mid(start, n); + url.append(extension); + } + + QMimeDatabase db; + d->mimeType = db.mimeTypeForFile(url); + saveUsedDir(url, d->dialogName); + } + return url; +} + +QStringList KoFileDialog::filenames() +{ + QStringList urls; + + if (!d->useStaticForNative) { + if (!d->fileDialog) { + createFileDialog(); + } + if (d->fileDialog->exec() == QDialog::Accepted) { + urls = d->fileDialog->selectedFiles(); + } + } + else { + switch (d->type) { + case OpenFiles: + case ImportFiles: + { + urls = QFileDialog::getOpenFileNames(d->parent, + d->caption, + d->defaultDirectory, + d->filterList.join(";;"), + &d->defaultFilter); + break; + } + default: + ; + } + } + if (urls.size() > 0) { + saveUsedDir(urls.first(), d->dialogName); + } + return urls; +} + +void KoFileDialog::filterSelected(const QString &filter) +{ + // "Windows BMP image ( *.bmp )"; + int start = filter.lastIndexOf("*.") + 2; + int end = filter.lastIndexOf(" )"); + int n = end - start; + QString extension = filter.mid(start, n); + d->defaultFilter = filter; + d->fileDialog->setDefaultSuffix(extension); +} + +QStringList KoFileDialog::splitNameFilter(const QString &nameFilter, QStringList *mimeList) +{ + Q_ASSERT(mimeList); + + QStringList filters; + QString description; + + if (nameFilter.contains("(")) { + description = nameFilter.left(nameFilter.indexOf("(") -1).trimmed(); + } + + QStringList entries = nameFilter.mid(nameFilter.indexOf("(") + 1).split(" ",QString::SkipEmptyParts ); + + foreach(QString entry, entries) { + + entry = entry.remove("*"); + entry = entry.remove(")"); + + QMimeDatabase db; + QMimeType mime = db.mimeTypeForName("bla" + entry); + if (mime.name() != "application/octet-stream") { + if (!mimeList->contains(mime.name())) { + mimeList->append(mime.name()); + filters.append(mime.comment() + " ( *" + entry + " )"); + } + } + else { + filters.append(entry.remove(".").toUpper() + " " + description + " ( *." + entry + " )"); + } + } + + return filters; +} + +const QStringList KoFileDialog::getFilterStringListFromMime(const QStringList &mimeList, + bool withAllSupportedEntry) +{ + QStringList mimeSeen; + + QStringList ret; + if (withAllSupportedEntry) { + ret << QString(); + } + + for (QStringList::ConstIterator + it = mimeList.begin(); it != mimeList.end(); ++it) { + QMimeDatabase db; + QMimeType mimeType = db.mimeTypeForName(*it); + if (!mimeType.isValid()) { + continue; + } + if (!mimeSeen.contains(mimeType.name())) { + QString oneFilter; + QStringList patterns = mimeType.globPatterns(); + QStringList::ConstIterator jt; + for (jt = patterns.constBegin(); jt != patterns.constEnd(); ++jt) { + if (d->swapExtensionOrder) { + oneFilter.prepend(*jt + " "); + if (withAllSupportedEntry) { + ret[0].prepend(*jt + " "); + } + } + else { + oneFilter.append(*jt + " "); + if (withAllSupportedEntry) { + ret[0].append(*jt + " "); + } + } + } + oneFilter = mimeType.comment() + " ( " + oneFilter + ")"; + ret << oneFilter; + mimeSeen << mimeType.name(); + } + } + + if (withAllSupportedEntry) { + ret[0] = i18n("All supported formats") + " ( " + ret[0] + (")"); + } + return ret; +} + +QString KoFileDialog::getUsedDir(const QString &dialogName) +{ + if (dialogName.isEmpty()) return ""; + + KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); + QString dir = group.readEntry(dialogName); + + return dir; +} + +void KoFileDialog::saveUsedDir(const QString &fileName, + const QString &dialogName) +{ + + if (dialogName.isEmpty()) return; + + QFileInfo fileInfo(fileName); + KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs"); + group.writeEntry(dialogName, fileInfo.absolutePath()); + +} Index: libs/widgetutils/KoFileDialogTester.h =================================================================== --- /dev/null +++ libs/widgetutils/KoFileDialogTester.h @@ -0,0 +1,53 @@ +/* This file is part of the KDE project + * Copyright (C) Boudewijn Rempt , (C) 2014 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#ifndef KOFILEDIALOGTESTER_H +#define KOFILEDIALOGTESTER_H + +#include + +namespace Ui { +class KoFileDialogTester; +} + +class KoFileDialogTester : public QWidget +{ + Q_OBJECT + +public: + explicit KoFileDialogTester(QWidget *parent = 0); + ~KoFileDialogTester(); + +private Q_SLOTS: + + void testOpenFile(); + void testOpenFiles(); + void testOpenDirectory(); + void testImportFile(); + void testImportFiles(); + void testImportDirectory(); + void testSaveFile(); + +private: + Ui::KoFileDialogTester *ui; + + QStringList m_nameFilters; + QStringList m_mimeFilter; +}; + +#endif // KOFILEDIALOGTESTER_H Index: libs/widgetutils/KoFileDialogTester.cpp =================================================================== --- /dev/null +++ libs/widgetutils/KoFileDialogTester.cpp @@ -0,0 +1,328 @@ +/* This file is part of the KDE project + * Copyright (C) Boudewijn Rempt , (C) 2014 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#include "KoFileDialogTester.h" + +#include "ui_KoFileDialogTester.h" + +#include +#include +#include +#include + +#include + +KoFileDialogTester::KoFileDialogTester(QWidget *parent) : + QWidget(parent), + ui(new Ui::KoFileDialogTester) +{ + ui->setupUi(this); + + connect(ui->bnOpenFile, SIGNAL(clicked()), SLOT(testOpenFile())); + connect(ui->bnOpenFiles, SIGNAL(clicked()), SLOT(testOpenFiles())); + connect(ui->bnOpenDirectory, SIGNAL(clicked()), SLOT(testOpenDirectory())); + connect(ui->bnImportFile, SIGNAL(clicked()), SLOT(testImportFile())); + connect(ui->bnImportFiles, SIGNAL(clicked()), SLOT(testImportFiles())); + connect(ui->bnImportDirectory, SIGNAL(clicked()), SLOT(testImportDirectory())); + connect(ui->bnSaveFile, SIGNAL(clicked()), SLOT(testSaveFile())); + + m_nameFilters << "Documents (*.odt *.doc *.txt)" + << "Images (*.png *.jpg *.jpeg)" + << "Presentations (*.ppt *.odp)" + << "Patterns (*.pat *.jpg *.gif *.png *.tif *.xpm *.bmp)" + << "Palettes (*.gpl *.pal *.act *.aco *.colors)"; + + m_mimeFilter = QStringList() + << "application/x-krita" << "image/x-exr" << "image/openraster" << "image/x-tga" << "image/vnd.adobe.photoshop" + << "image/x-xcf" << "image/x-portable-pixmap" << "image/x-portable-graymap" + << "image/x-portable-bitmap" << "image/png" << "image/jp2" + << "image/tiff" << "application/vnd.oasis.opendocument.graphics" + << "application/pdf" << "image/jpeg" << "image/bmp" << "image/x-xpixmap" + << "image/gif" << "image/x-xbitmap" << "application/x-krita-flipbook" + << "image/x-adobe-dng" << "image/x-xfig" << "image/svg+xml" << "image/svg+xml-compressed" + << "image/x-eps" << "image/eps" << "application/eps" << "application/x-eps" << "application/postscript" + << "image/x-wmf" << "application/x-karbon" + << "image/tiff" << "application/vnd.oasis.opendocument.graphics" + ; +} + +KoFileDialogTester::~KoFileDialogTester() +{ + delete ui; +} + + + +void KoFileDialogTester::testOpenFile() +{ + ui->listResults->clear(); + KoFileDialog dlg(this, KoFileDialog::OpenFile, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: OpenFile"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + } + else { + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QString url = dlg.filename(); + ui->listResults->addItem(url); + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); + +} + +void KoFileDialogTester::testOpenFiles() +{ + ui->listResults->clear(); + KoFileDialog dlg(this, KoFileDialog::OpenFiles, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: OpenFile"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + + } + else { + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QStringList urls = dlg.filenames(); + foreach(const QString &url, urls) { + ui->listResults->addItem(url); + } + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); +} + +void KoFileDialogTester::testOpenDirectory() +{ + ui->listResults->clear(); + KoFileDialog dlg(this, KoFileDialog::OpenDirectory, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: OpenDirectory"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + + } + else { + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QString url = dlg.filename(); + ui->listResults->addItem(url); + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); +} + + +void KoFileDialogTester::testImportFile() +{ + ui->listResults->clear(); + + KoFileDialog dlg(this, KoFileDialog::ImportFile, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: ImportFile"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + + } + else { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QString url = dlg.filename(); + ui->listResults->addItem(url); + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); +} + +void KoFileDialogTester::testImportFiles() +{ + ui->listResults->clear(); + KoFileDialog dlg(this, KoFileDialog::ImportFiles, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: ImportFiles"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + + } + else { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QStringList urls = dlg.filenames(); foreach(const QString &url, urls) { + ui->listResults->addItem(url); + } + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); +} + +void KoFileDialogTester::testImportDirectory() +{ + ui->listResults->clear(); + KoFileDialog dlg(this, KoFileDialog::ImportDirectory, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: Import Directory"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + + } + else { + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QString url = dlg.filename(); + ui->listResults->addItem(url); + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); +} + +void KoFileDialogTester::testSaveFile() +{ + ui->listResults->clear(); + + KoFileDialog dlg(this, KoFileDialog::SaveFile, ui->txtUniqueKey->text()); + dlg.setCaption("Testing: SaveFile"); + dlg.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + if (ui->radioName->isChecked()) { + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setNameFilters(m_nameFilters, m_nameFilters.last()); + } + else { + dlg.setNameFilters(m_nameFilters); + } + } + else { + + if (ui->chkSetDefaultFilter->isChecked()) { + dlg.setMimeTypeFilters(m_mimeFilter, m_mimeFilter[4]); + } + else { + dlg.setMimeTypeFilters(m_mimeFilter); + } + + } + + if (ui->chkHideNameFilterDetailsOption->isChecked()) { + dlg.setHideNameFilterDetailsOption(); + } + + QString url = dlg.filename(); + ui->listResults->addItem(url); + ui->lblMime->setText(dlg.selectedMimeType()); + ui->txtFilter->setText(dlg.selectedNameFilter()); +} Index: libs/widgetutils/KoFileDialogTester.ui =================================================================== --- /dev/null +++ libs/widgetutils/KoFileDialogTester.ui @@ -0,0 +1,214 @@ + + + KoFileDialogTester + + + + 0 + 0 + 355 + 396 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Open File + + + + + + + Open Files + + + + + + + + + Unique key: + + + + + + + blablabla + + + + + + + + + + + + 0 + 0 + + + + Filter: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + TextLabel + + + Qt::PlainText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + false + + + + + + + + + + + Results: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + + + Filter Type + + + + + + Mime + + + + + + + Named + + + true + + + + + + + Hide name filter details option + + + + + + + Set default filter + + + + + + + + + + Save File + + + + + + + Import Files + + + + + + + Import File + + + + + + + Open Directory + + + + + + + Import Directory + + + + + bnImportFile + bnOpenFile + bnOpenFiles + bnOpenDirectory + bnImportFiles + bnImportDirectory + bnSaveFile + groupBox + lblMime + + + + + Index: libs/widgetutils/main.cpp =================================================================== --- /dev/null +++ libs/widgetutils/main.cpp @@ -0,0 +1,11 @@ +#include "KoFileDialogTester.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + KoFileDialogTester w; + w.show(); + + return a.exec(); +} Index: plan/CMakeLists.txt =================================================================== --- plan/CMakeLists.txt +++ plan/CMakeLists.txt @@ -4,6 +4,8 @@ # set kplato debug area add_definitions( -DKDE_DEFAULT_DEBUG_AREA=42000 ) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS GuiAddons Parts) + if (KF5AkonadiContact_FOUND) add_definitions(-DPLAN_KDEPIMLIBS_FOUND) endif () Index: plugins/colorengines/lcms2/LcmsColorSpace.h =================================================================== --- plugins/colorengines/lcms2/LcmsColorSpace.h +++ plugins/colorengines/lcms2/LcmsColorSpace.h @@ -201,15 +201,15 @@ TYPE_BGR_8, d->profile->lcmsProfile(), this->colorSpaceType(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); Q_ASSERT(d->defaultTransformations->fromRGB); d->defaultTransformations->toRGB = cmsCreateTransform(d->profile->lcmsProfile(), this->colorSpaceType(), KoLcmsDefaultTransformations::s_RGBProfile, TYPE_BGR_8, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); Q_ASSERT(d->defaultTransformations->toRGB); KoLcmsDefaultTransformations::s_transformations[ this->id()][ d->profile ] = d->defaultTransformations; } @@ -247,8 +247,8 @@ TYPE_BGR_8, d->profile->lcmsProfile(), this->colorSpaceType(), - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); d->lastRGBProfile = profile->lcmsProfile(); } @@ -268,8 +268,8 @@ if (d->lastToRGB == 0 || (d->lastToRGB != 0 && d->lastRGBProfile != profile->lcmsProfile())) { d->lastToRGB = cmsCreateTransform(d->profile->lcmsProfile(), this->colorSpaceType(), profile->lcmsProfile(), TYPE_BGR_8, - KoColorConversionTransformation::InternalRenderingIntent, - KoColorConversionTransformation::InternalConversionFlags); + KoColorConversionTransformation::internalRenderingIntent(), + KoColorConversionTransformation::internalConversionFlags()); d->lastRGBProfile = profile->lcmsProfile(); } cmsDoTransform(d->lastToRGB, const_cast (src), d->qcolordata, 1); @@ -293,8 +293,8 @@ adj->profiles[0] = d->profile->lcmsProfile(); adj->profiles[2] = d->profile->lcmsProfile(); adj->cmstransform = cmsCreateMultiprofileTransform(adj->profiles, 3, this->colorSpaceType(), this->colorSpaceType(), - KoColorConversionTransformation::AdjustmentRenderingIntent, - KoColorConversionTransformation::AdjustmentConversionFlags); + KoColorConversionTransformation::adjustmentRenderingIntent(), + KoColorConversionTransformation::adjustmentConversionFlags()); adj->csProfile = d->profile->lcmsProfile(); return adj; } @@ -322,12 +322,12 @@ adj->profiles[2] = NULL; adj->csProfile = d->profile->lcmsProfile(); adj->cmstransform = cmsCreateTransform(adj->profiles[0], this->colorSpaceType(), NULL, this->colorSpaceType(), - KoColorConversionTransformation::AdjustmentRenderingIntent, - KoColorConversionTransformation::AdjustmentConversionFlags); + KoColorConversionTransformation::adjustmentRenderingIntent(), + KoColorConversionTransformation::adjustmentConversionFlags()); adj->cmsAlphaTransform = cmsCreateTransform(adj->profiles[1], TYPE_GRAY_DBL, NULL, TYPE_GRAY_DBL, - KoColorConversionTransformation::AdjustmentRenderingIntent, - KoColorConversionTransformation::AdjustmentConversionFlags); + KoColorConversionTransformation::adjustmentRenderingIntent(), + KoColorConversionTransformation::adjustmentConversionFlags()); delete [] transferFunctions; delete [] alphaTransferFunctions; Index: plugins/colorengines/lcms2/tests/TestKoCompositeOps.cpp =================================================================== --- plugins/colorengines/lcms2/tests/TestKoCompositeOps.cpp +++ plugins/colorengines/lcms2/tests/TestKoCompositeOps.cpp @@ -1189,7 +1189,7 @@ } // full white image - //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("0dst.png"); + //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("0dst.png"); // src quint8 * dab = new quint8[pixelCount * pixelSize]; @@ -1200,7 +1200,7 @@ } // full black image - //cs->convertToQImage(dab, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("1src.png"); + //cs->convertToQImage(dab, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("1src.png"); // selection @@ -1219,7 +1219,7 @@ } // white rectangle at 128,128 - //KoColorSpaceRegistry::instance()->alpha8()->convertToQImage(selection, w, h, 0, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("1mask.png"); + //KoColorSpaceRegistry::instance()->alpha8()->convertToQImage(selection, w, h, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("1mask.png"); copy->composite(layer,w * pixelSize, dab, w * pixelSize, @@ -1230,7 +1230,7 @@ // full black image - //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("2result.png"); + //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("2result.png"); copy->composite(layer,w * pixelSize, opaque.data(), 0, @@ -1241,7 +1241,7 @@ ); // full opaque image - //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags).save("3result.png"); + //cs->convertToQImage(layer, w, h, 0,KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()).save("3result.png"); copy->composite(layer,w * pixelSize, dab, w * pixelSize, @@ -1252,7 +1252,7 @@ ); // black rectangle on opaque background - QImage result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + QImage result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); QImage expectedResult(QString(FILES_DATA_DIR) + QDir::separator() + "CopyWithSelectionExpectedResult.png"); bool testOk = (result == expectedResult); @@ -1271,7 +1271,7 @@ QBitArray()); - result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags); + result = cs->convertToQImage(layer, w, h, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); expectedResult = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "CopySingleWithSelectionExpectedResult.png"); testOk = (result == expectedResult); Index: plugins/textediting/spellcheck/CMakeLists.txt =================================================================== --- plugins/textediting/spellcheck/CMakeLists.txt +++ plugins/textediting/spellcheck/CMakeLists.txt @@ -4,6 +4,8 @@ add_subdirectory( tests ) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS Sonnet) + include_directories( ${TEXTLAYOUT_INCLUDES} ${FLAKE_INCLUDES} ) set(spellcheck_SRCS Index: sheets/CMakeLists.txt =================================================================== --- sheets/CMakeLists.txt +++ sheets/CMakeLists.txt @@ -1,5 +1,8 @@ project(calligra-sheets) +find_package(KF5 ${MINIMUM_KF5_VERSION} REQUIRED COMPONENTS ThreadWeaver Sonnet) +find_package(Qt5 ${REQUIRED_QT_VERSION} OPTIONAL_COMPONENTS Sql) + include_directories( ${CMAKE_SOURCE_DIR}/interfaces ${KOMAIN_INCLUDES} ${KOTEXT_INCLUDES}