Commit 94a23e39 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

try to make it compile

parent 9984fd97
#
# Copyright (c) 2010-2014, Gilles Caulier, <caulier dot gilles at gmail dot com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wizard
${CMAKE_CURRENT_SOURCE_DIR}/tools
${CMAKE_CURRENT_SOURCE_DIR}/plugin
)
set(kipiplugin_printimages_PART_SRCS
plugin/plugin_printimages.cpp
tools/tphoto.cpp
tools/utils.cpp
tools/atkinspagelayout.cpp
tools/templateicon.cpp
tools/layouttree.cpp
wizard/cropframe.cpp
wizard/wizard.cpp
wizard/printoptionspage.cpp
wizard/printhelper.cpp
wizard/customdlg.cpp
)
ki18n_wrap_ui(kipiplugin_printimages_PART_SRCS
ui/photopage.ui
ui/croppage.ui
ui/customlayout.ui
ui/printoptionspage.ui
)
kconfig_add_kcfg_files(kipiplugin_printimages_PART_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/wizard/printimagesconfig.kcfgc
)
add_library(kipiplugin_printimages MODULE ${kipiplugin_printimages_PART_SRCS})
target_link_libraries(kipiplugin_printimages
KF5::KDELibs4Support
KF5::KIOCore
Qt5::Core
Qt5::Gui
KF5::Kipi
KF5::KDcraw
KF5::KExiv2
kipiplugins
)
configure_file(plugin/kipiplugin_printimages.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/plugin/kipiplugin_printimages.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugin/kipiplugin_printimages.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(TARGETS kipiplugin_printimages DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plugin/kipiplugin_printimagesui.rc DESTINATION ${DATA_INSTALL_DIR}/kipi)
install(FILES TEMPLATE_HOWTO DESTINATION ${DATA_INSTALL_DIR}/kipiplugin_printimages)
install(DIRECTORY templates DESTINATION ${DATA_INSTALL_DIR}/kipiplugin_printimages)
#! /bin/sh
$EXTRACTRC `find . -name "*.ui" -o -name "*.rc" -o -name "*.kcfg" ` >> rc.cpp
$XGETTEXT `find . -name "*.cpp" -o -name "*.h"` -o $podir/kipiplugin_printimages.pot
rm -f rc.cpp
# Print Assistant Plugin Template Howto
The Print Assistant plugin allows to ad new templates to
manage new page layouts easily.
This document explains how to create templates.
*This document can be converted to HTML using
[Markdown](http://www.daringfireball.net/projects/markdown).*
## Getting started
A template is at least one file with xml extension (for instance my-templates.xml),
if you want it to be included however you need another file that allows translations,
e.g. a desktop file (see below).
When the plugin is run it does the following:
- Wait for you to choose page size
- Look for files describing templates (xml files)
- for file look for templates:
- for each template:
- if layout fits into choosen page size add it and load desktop file if exists.
- show templates with a preview icon in a list box.
## Presentation of the xml file
The xml file is used to describe template layouts, once it was a
real page layout, but now you can add a fake page size to make it
available for all those pages in which your new template fits.
An example of template (already included into default templates.xml)
is a layout containing six passport size photos (35x40mm) is the following:
<templates>
<paper name="passport-photos" width="90" height="130" unit="mm" >
<template name="6_photos_3.5x4cm" dpi="0" autorotate="true">
<photo x="10" y="3" width="35" height="40" />
<photo x="55" y="3" width="35" height="40" />
<photo x="10" y="45" width="35" height="40" />
<photo x="55" y="45" width="35" height="40" />
<photo x="10" y="87" width="35" height="40" />
<photo x="55" y="87" width="35" height="40" />
</template>
</paper>
</templates>
- paper element
Represents the template layout, important attributes are width, height
and unit.
- width attribute
Represents the layout width
- height attribute
Represents the layout height
- unit attribute
Explains in which units width and height are, it can be:
- inches or inch
- mm
- cm
- template element
It is the real template definition and contains the photo positions
- name attribute
It is the template's name, it is used to get translations to be used,
it is the desktop fileName, "6_photos_3.5x4cm.desktop" in the example.
If the desktop fileName does not exist name attribute is shown.
- autorotate attribute
Explains if autorotation must be done.
- photo element
Explains photo position (x and y attributes) and size (width and height attributes).
Another example for A6 page size:
<paper name="A6" width="105" height="148" unit="mm" >
<template name="1_photo_9x13cm" dpi="0" autorotate="true">
<photo x="5" y="10" width="90" height="130" />
</template>
<template name="1_photo_10.5x14.8cm" dpi="0" autorotate="true">
<photo x="0" y="0" width="105" height="148" />
</template>
</paper>
## Presentation of the desktop file
The desktop file is needed for translations. If you use your
templates for your own, you don't really need it.
It's a .ini-style file and looks like this (for instance 1_photo_9x13cm):
[Desktop Entry]
Name=9x13 cm (1 photo)
Name[da]=9x13 cm (1 foto)
Name[de]=9x13 cm (1 Foto)
Name[en_GB]=9x13 cm (1 photo)
Name[et]=9x13 cm (1 foto)
Name[gl]=9x13 cm (1 foto)
Name[it]=9×13 cm (1 foto)
Name[nb]=9x13 cm (1 bilde)
Name[nl]=9x13 cm (1 foto)
Name[pt]=9x13 cm (1 fotografia)
Name[pt_BR]=9x13 cm (1 foto)
Name[sv]=9 x 13 cm (1 foto)
Name[uk]=9x13 ?? (1 ??????????)
Name[x-test]=xx9x13 cm (1 photo)xx
The nice thing is that when your layout get integrated into Print Assistant
Plugin default templates, KDE translators will translate the desktop file for you.
## Getting started: creating one theme from another
The easiest way to get started is to copy templates.xml file and modify it.
Templates folder can be found in $KDEDIR/share/apps/kipiplugin_printimages/templates/,
where $KDEDIR is the install folder of KDE on your machine (usually /usr).
Writing in this folder requires root access, so we will not create our template
there, instead do the following:
Create a theme folder in your home:
mkdir -p ~/.kde4/share/apps/kipiplugin_printimages/templates/
Cd to it:
cd ~/.kde4/share/apps/kipiplugin_printimages/templates/
Copy the templates.xml to my_templates.xml for instance:
cp -r $KDEDIR/share/apps/~/.kde4/share/apps/kipiplugin_printimages/templates/templates.xml my_templates.xml
Remove all pages and add yours then create the desktop file accordingly.
You are done, you can now open your favorite KIPI enabled application and start the
Print Assistant plugin, your new templates should appear in the Layouts list
(into "Select page layout" dialog).
## Final words
This is the end of this howto, now is the time for you to get creative and
add new templates!
When you are done, do not hesitate to contact the kde-imaging mailing
list (<kde-imaging@kde.org>). If you want to get your layout included in the
official template list!
- Get printers from QPrinterInfo interface DONE
- Get page size from QPrinSetup interface DONE
- Using QPrintDialog with QPrinter settings almost DONE
- Fix photgrid if page size is in inches DONE
- check update on size, sometimes it's not as expected DONE
- add template icons (Andreas Trink's code) DONE
- manage again "Print to JPG" DONE
- print to JPG and bad path behaviour DONE
- cancel printing should terminate wizard DONE
- move number of copies to first page DONE
- remove number of copies from second page DONE
- add caption per page DONE
- show caption into info page preview DONE
- set caption data when new photo is selected DONE
- add a template how-to file DONE
- add fit as many option DONE
- FIX custom layout icon almost DONE
- save custom layout data into config file DONE
- add tool tips some
- add an attribute for desktop file
- add Atckin's layout to p.a.
- fix UIs some
- first assistant page should be a choice between
"one photo per page" aka p.i.
"more photos per page" aka p.a.
- clean code
- evaluate if removing p.i. after merging.
Found QT odd behaviors
- QPageSetupDialog::open does not set QPrinter correctly (Unix?) -> used exec
- QPrinter Custom page size (HP CUPS settings) is restored as custom 0,0
- QPrintDialog(Qprinter*) does not care QPrinter margins if OutputFormat
is set as PdfFormat or PostScriptFormat
- QPrinterInfo::availablePrinters() seems to be usefull for PageSizes
only for default in case of printers :(
[Desktop Entry]
UntranslatedGenericName=Print images
Name=Print images
Name[ast]=Imprentar imáxenes
Name[bg]=Отпечатване на изображения
Name[bs]=Štampaj slike
Name[ca]=Impressió d'imatges
Name[ca@valencia]=Impressió d'imatges
Name[cs]=Vytisknout obrázky
Name[da]=Udskriv billeder
Name[de]=Bilder drucken
Name[el]=Εκτύπωση εικόνων
Name[en_GB]=Print images
Name[es]=Imprimir imágenes
Name[et]=Piltide trükkimine
Name[eu]=Inprimatu irudiak
Name[fi]=Kuvien tulostus
Name[fr]=Imprimer des images
Name[ga]=Priontáil íomhánna
Name[gl]=Imprimir imaxes
Name[hu]=Képek nyomtatása
Name[is]=Prenta myndir
Name[it]=Stampa immagini
Name[ja]=画像の印刷
Name[km]=បោះពុម្ព​រូបភាព
Name[lt]=Spausdinti paveikslėlius
Name[lv]=Drukāt attēlus
Name[mai]=छवि छापू
Name[mr]=प्रतिमा छापा
Name[nb]=Bildeutskrift
Name[nds]=Biller drucken
Name[nl]=Afbeeldingen afdrukken
Name[pa]=ਚਿੱਤਰ ਪਰਿੰਟ ਕਰੋ
Name[pl]=Drukuj obrazy
Name[pt]=Imprimir as imagens
Name[pt_BR]=Imprimir imagens
Name[ro]=Tipărește imaginile
Name[ru]=Печать изображений
Name[sk]=Vytlačiť obrázky
Name[sl]=Natisni slike
Name[sq]=Printo imazhet
Name[sv]=Skriv ut bilder
Name[th]=พิมพ์ภาพต่าง ๆ
Name[tr]=Resimleri Yazdır
Name[ug]=سۈرەت باس
Name[uk]=Друк зображень
Name[x-test]=xxPrint imagesxx
Name[zh_CN]=打印图像
Name[zh_TW]=列印影像
Comment=A tool to print images in various formats
Comment[ast]=Una ferramienta pa imprentar imáxenes en dellos formatos
Comment[bg]=Инструмент за отпечатване на изображения в различни формати
Comment[bs]=Alat za štampanje slika u različitim formatima
Comment[ca]=Una eina per a imprimir imatges en diversos formats
Comment[ca@valencia]=Una eina per a imprimir imatges en diversos formats
Comment[cs]=Nástroj pro tisk obrázků v různých formátech
Comment[da]=Et værktøj til at udskrive billeder i forskellige formater
Comment[de]=Ein Werkzeug, um Bilder in verschiedenen Formaten zu drucken
Comment[el]=Εργαλείο εκτύπωσης εικόνων σε διάφορες μορφές
Comment[en_GB]=A tool to print images in various formats
Comment[es]=Una herramienta para imprimir imágenes en varios formatos
Comment[et]=Tööriist piltide trükkimiseks mitmesuguses suuruses
Comment[eu]=Irudiak hainbat formatutan inprimatzeko tresna
Comment[fi]=Kuvien tulostus eri muodoissa
Comment[fr]=Un outil d'impression d'images dans différents formats
Comment[ga]=Uirlis a phriontálann íomhánna i bhformáidí éagsúla
Comment[gl]=Unha ferramenta para imprimir imaxes en distintos formatos
Comment[hu]=Egy eszköz képek különféle formátumokba történő nyomtatásához
Comment[is]=Verkfæri til að prenta myndir í ýmsum stærðum
Comment[it]=Uno strumento per stampare immagini in diversi formati
Comment[km]=ឧបករណ៍​ត្រូវ​បោះពុម្ព​រូបភាព​ជា​ទ្រង់ទ្រាយ​ផ្សេងៗ
Comment[lv]=Rīks attēlu drukāšanai dažādos formātos
Comment[nb]=Et verktøy for å skrive ut bilder i forskjellige formater
Comment[nds]=En Warktüüch, mit dat sik Biller in verscheden Formaten utdrucken laat
Comment[nl]=Een hulpmiddel om afbeeldingen af te drukken in verschillende formaten
Comment[pa]=ਚਿੱਤਰਾਂ ਨੂੰ ਕਈ ਫਾਰਮੈਟਾਂ ਵਿੱਚ ਪਰਿੰਟ ਕਰਨ ਲਈ ਇੱਕ ਟੂਲ
Comment[pl]=Narzędzie do drukowani obrazów w różnych formatach
Comment[pt]=Uma ferramenta para imprimir imagens em vários formatos
Comment[pt_BR]=Uma ferramenta para imprimir imagens em vários formatos
Comment[ro]=O unealtă de tipărit imagini în diverse formate
Comment[ru]=Инструмент для печати изображений в различных форматах
Comment[sk]=Nástroj na tlač obrázkov v rôznych formátoch
Comment[sl]=Orodje za tiskanje slik v različnih oblikah
Comment[sq]=Një mjet për të printuar imazhet në formate të ndryshme
Comment[sv]=Ett verktyg för att skriva ut bilder med diverse format
Comment[th]=เครื่องมือพิมพ์ภาพต่าง ๆ ที่มีรูปแบบหลากหลาย
Comment[tr]=Çeşitli biçimlerdeki resimleri yazdırmak için bir araç
Comment[uk]=Інструмент для друку зображень у різних форматах
Comment[x-test]=xxA tool to print images in various formatsxx
Comment[zh_CN]=一个以多种格式打印图像的工具
Comment[zh_TW]=用各種格式列印影像的工具
Type=Service
Icon=document-print
ServiceTypes=KIPI/Plugin
X-KDE-Library=kipiplugin_printimages
X-KIPI-MergeMenu=true
X-KIPI-PluginCategories=Image
X-KIPI-BinaryVersion=${KIPI_SO_VERSION}
author=Angelo Naselli, anaselli at linux dot it
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<!-- NOTE: don't forget to increase version ID when this file is modified -->
<gui version="1" name="kipiplugin_printimages" >
<MenuBar>
<Menu name="Image"><text>&amp;Image</text>
<Action name="printimages" group="kipi_image_group" />
<Action name="printassistant" group="kipi_image_group" />
</Menu>
</MenuBar>
<ToolBar name="mainToolBar"><text>Main Toolbar</text>
</ToolBar>
</gui>
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.digikam.org
*
* Date : 2009-02-08
* Description : a kipi plugin to print images
*
* Copyright 2009-2012 by Angelo Naselli <anaselli at linux dot it>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* ============================================================ */
// To disable warnings under MSVC2008 about POSIX methods().
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
#include "plugin_printimages.h"
// C ANSI includes
extern "C"
{
#include <unistd.h>
}
// Qt includes
#include <QWidget>
#include <QPrinter>
// KDE includes
#include <QAction>
#include <kactioncollection.h>
#include <kapplication.h>
#include <kgenericfactory.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
// LibKIPI includes
#include <imagecollection.h>
#include <interface.h>
#include <plugin.h>
// Local includes
#include "printhelper.h"
#include "wizard.h"
namespace KIPIPrintImagesPlugin
{
K_PLUGIN_FACTORY ( PrintImagesFactory, registerPlugin<Plugin_PrintImages>(); )
K_EXPORT_PLUGIN ( PrintImagesFactory ( "kipiplugin_printimages" ) )
Plugin_PrintImages::Plugin_PrintImages ( QObject* const parent, const QVariantList& /*args*/ )
: Plugin ( /*PrintImagesFactory::componentData(),*/ parent, "PrintImages" )
{
//PORT QT5 kDebug(AREA_CODE_LOADING) << "Plugin_PrintImages plugin loaded" ;
setUiBaseName("kipiplugin_printimagesui.rc");
setupXML();
}
Plugin_PrintImages::~Plugin_PrintImages()
{
}
void Plugin_PrintImages::setup(QWidget* const widget)
{
Plugin::setup ( widget );
setupActions();
m_interface = interface();
if ( !m_interface )
{
kError() << "Kipi interface is null!";
return;
}
ImageCollection selection = m_interface->currentSelection();
m_printImagesAction->setEnabled ( selection.isValid() && !selection.images().isEmpty() );
m_printAssistantAction->setEnabled ( selection.isValid() && !selection.images().isEmpty() );
connect ( m_interface, SIGNAL (selectionChanged(bool)),
m_printImagesAction, SLOT (setEnabled(bool)) );
connect ( m_interface, SIGNAL (selectionChanged(bool)),
m_printAssistantAction, SLOT (setEnabled(bool)) );
}
void Plugin_PrintImages::setupActions()
{
setDefaultCategory(ImagesPlugin);
m_printImagesAction = new QAction(this);
m_printImagesAction->setText ( i18n ( "Print images" ) );
m_printImagesAction->setIcon ( QIcon::fromTheme( "document-print" ) );
m_printImagesAction->setEnabled(false);
connect ( m_printImagesAction, SIGNAL (triggered(bool)),
this, SLOT (slotPrintImagesActivate()) );
addAction("printimages", m_printImagesAction);
m_printAssistantAction = new QAction(this);
m_printAssistantAction->setText ( i18n ( "Print Assistant..." ) );
m_printAssistantAction->setIcon ( QIcon::fromTheme( "document-print" ) );
m_printAssistantAction->setEnabled(false);
connect ( m_printAssistantAction, SIGNAL (triggered(bool)),
this, SLOT (slotPrintAssistantActivate()) );
addAction("printassistant", m_printAssistantAction);
}
void Plugin_PrintImages::slotPrintImagesActivate()
{
ImageCollection album = m_interface->currentSelection();
if ( !album.isValid() )
return;
KUrl::List fileList = album.images();
if ( fileList.isEmpty() )
{
KMessageBox::sorry ( kapp->activeWindow(), i18n ( "Please select one or more photos to print." ),
i18n ( "Print images" ) );
return;
}
QWidget* const parent = QApplication::activeWindow();
PrintHelper printPlugin(parent);
printPlugin.print(fileList);
}
void Plugin_PrintImages::slotPrintAssistantActivate()
{
ImageCollection album = m_interface->currentSelection();
if ( !album.isValid() )
return;
KUrl::List fileList = album.images();
if (fileList.isEmpty())
{
KMessageBox::sorry(kapp->activeWindow(), i18n("Please select one or more photos to print."),
i18n("Print assistant"));
return;
}
QWidget* const parent = QApplication::activeWindow();
Wizard printAssistant(parent);
KStandardDirs dir;
QString tempPath = dir.saveLocation("tmp", "kipi-printassistantdplugin-" + QString::number(getpid()) + '/');
printAssistant.print(fileList, tempPath);
if (printAssistant.exec() == QDialog::Rejected)
return;
}
} // namespace KIPIPrintImagesPlugin
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.digikam.org
*
* Date : 2009-02-08
* Description : a kipi plugin to print images
*
* Copyright 2009-2012 by Angelo Naselli <anaselli at linux dot it>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* ============================================================ */
#ifndef PLUGIN_PRINTIMAGES_H
#define PLUGIN_PRINTIMAGES_H
// Qt includes
#include <QVariant>
// LibKIPI includes
#include <plugin.h>
class QAction;
namespace KIPI
{
class Interface;
}
using namespace KIPI;
namespace KIPIPrintImagesPlugin
{
class Plugin_PrintImages : public Plugin
{
Q_OBJECT
public:
Plugin_PrintImages(QObject* const parent, const QVariantList& args);
~Plugin_PrintImages();
void setup(QWidget* const widget);
public Q_SLOTS:
void slotPrintImagesActivate();
void slotPrintAssistantActivate();
private:
void setupActions();
private:
QAction * m_printImagesAction;
QAction * m_printAssistantAction;
Interface* m_interface;
};
} // namespace KIPIPrintImagesPlugin
#endif // PLUGIN_PRINTIMAGES_H