From 5ee94eef10bcfe943293b8db7d0ab73ba15dbcde Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 5 Oct 2000 14:01:06 +0000 Subject: [PATCH] KDE formprint patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1085 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 28 + config/kde.m4 | 5 +- src/frontends/kde/FormPrint.C | 142 ++++ src/frontends/kde/FormPrint.h | 65 ++ src/frontends/kde/Makefile.am | 85 +- src/frontends/kde/dlg/README | 61 ++ src/frontends/kde/dlg/checkinitorder.pl | 24 + src/frontends/kde/dlg/formindexdialog.dlg | 37 +- src/frontends/kde/dlg/formprintdialog.dlg | 943 ++++++++++++++++++++++ src/frontends/kde/formindexdialog.C | 4 +- src/frontends/kde/formindexdialogdata.C | 54 +- src/frontends/kde/formindexdialogdata.h | 2 +- src/frontends/kde/formprintdialog.C | 30 + src/frontends/kde/formprintdialog.h | 131 +++ src/frontends/kde/formprintdialogdata.C | 610 ++++++++++++++ src/frontends/kde/formprintdialogdata.h | 76 ++ 16 files changed, 2243 insertions(+), 54 deletions(-) create mode 100644 src/frontends/kde/FormPrint.C create mode 100644 src/frontends/kde/FormPrint.h create mode 100644 src/frontends/kde/dlg/README create mode 100644 src/frontends/kde/dlg/checkinitorder.pl create mode 100644 src/frontends/kde/dlg/formprintdialog.dlg create mode 100644 src/frontends/kde/formprintdialog.C create mode 100644 src/frontends/kde/formprintdialog.h create mode 100644 src/frontends/kde/formprintdialogdata.C create mode 100644 src/frontends/kde/formprintdialogdata.h diff --git a/ChangeLog b/ChangeLog index 0c5c697279..bfec58d0b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2000-10-03 John Levon + + * config/kde.m4: fix consecutive ./configure runs, + look for qtarch, fix library order + + * src/frontends/kde/Makefile.am: tidy up, + add Print dialog, add .dlg dependencies + + * src/frontends/kde/FormPrint.C: + * src/frontends/kde/FormPrint.h: + * src/frontends/kde/formprintdialog.C: + * src/frontends/kde/formprintdialog.h: + * src/frontends/kde/formprintdialogdata.C: + * src/frontends/kde/formprintdialogdata.h: + * src/frontends/kde/dlg/formprintdialog.dlg: add + print dialog + + * src/frontends/kde/dlg/README: Added explanatory readme + + * src/frontends/kde/dlg/checkinitorder.pl: small perl + script to double-check qtarch's output + + * src/frontends/kde/formindexdialog.C: + * src/frontends/kde/formindexdialogdata.C: + * src/frontends/kde/formindexdialogdata.h: + * src/frontends/kde/dlg/formindexdialog.dlg: update + for qtarch, minor fixes + 2000-10-05 Allan Rae * src/BufferView_pimpl.C (buffer): don't hide all buffer dependent diff --git a/config/kde.m4 b/config/kde.m4 index f79a9fed8d..1d4744782f 100644 --- a/config/kde.m4 +++ b/config/kde.m4 @@ -633,6 +633,8 @@ dnl should check it's not Qt2, so it will fail now, rather than in KDE check SAVE_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -I$qt_includes -L$qt_libraries" +dnl specify we are definitely C++ compiling first +AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include ], @@ -836,7 +838,7 @@ AC_DEFUN(KDE_CREATE_LIBS_ALIASES, [ AC_REQUIRE([KDE_MISC_TESTS]) - KDE_LIBS='-lqt -lkdecore -lkdeui -lkfm -lkfile' + KDE_LIBS='-lkfile -lkfm -lkdeui -lkdecore -lqt' AC_SUBST(KDE_LIBS) # LIB_X11='-lX11 $(LIBSOCKET)' # AC_SUBST(LIB_X11) @@ -1230,6 +1232,7 @@ AC_DEFUN(KDE_DO_IT_ALL, AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde}) KDE_PROG_LIBTOOL AC_PATH_KDE +AC_PATH_PROG(QTARCH, "qtarch",qtarch-notinstalled) ]) AC_DEFUN(AC_CHECK_RPATH, diff --git a/src/frontends/kde/FormPrint.C b/src/frontends/kde/FormPrint.C new file mode 100644 index 0000000000..8fd3d612f2 --- /dev/null +++ b/src/frontends/kde/FormPrint.C @@ -0,0 +1,142 @@ +/* + * FormPrint.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include "formprintdialog.h" +#include "Dialogs.h" +#include "FormPrint.h" +#include "gettext.h" +#include "buffer.h" +#include "lyxrc.h" +#include "QtLyXView.h" +#include "PrinterParams.h" +#include "Liason.h" +#include "BufferView.h" +#include "support/lstrings.h" + +#include + +#ifdef SIGC_CXX_NAMESPACES +using SigC::slot; +#endif + +#ifdef CXX_WORKING_NAMESPACES +using Liason::printBuffer; +using Liason::getPrinterParams; +#endif + +FormPrint::FormPrint(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), h_(0), u_(0) +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showPrint.connect(slot(this, &FormPrint::show)); +} + +FormPrint::~FormPrint() +{ + delete dialog_; +} + +void FormPrint::update() +{ + if (!lv_->view()->available()) + return; + + PrinterParams pp(getPrinterParams(lv_->buffer())); + + dialog_->setTarget(pp.target); + dialog_->setPrinter(pp.printer_name.c_str()); + dialog_->setFile(pp.file_name.c_str()); + dialog_->setWhichPages(pp.which_pages); + dialog_->setReverse(pp.reverse_order); + dialog_->setSort(pp.unsorted_copies); + dialog_->setCount(tostr(pp.count_copies).c_str()); + + if (!pp.from_page.empty()) { + dialog_->setFrom(pp.from_page.c_str()); + if (pp.to_page) + dialog_->setTo(tostr(pp.to_page).c_str()); + else + dialog_->setTo(""); + } else { + dialog_->setFrom(""); + dialog_->setTo(""); + } +} + +void FormPrint::print() +{ + if (!lv_->view()->available()) + return; + + string from; + int to(0); + + if (strlen(dialog_->getFrom())) { + from = dialog_->getFrom(); + if (strlen(dialog_->getTo())) + to = strToInt(dialog_->getTo()); + } + + int retval; + retval = printBuffer(lv_->buffer(), PrinterParams(dialog_->getTarget(), + string(dialog_->getPrinter()), string(dialog_->getFile()), + dialog_->getWhichPages(), from, to, dialog_->getReverse(), + dialog_->getSort(), strToInt(dialog_->getCount()))); + + if (retval!=0) { + // FIXME: should have a utility class for this + string message(_("The error :\n\n")); + message += strerror(retval); + message += _("\n\noccurred while printing.\n"); + message += _("Check the parameters are correct.\n"); + KMsgBox msg(0, _("LyX: Print Error"), message.c_str(), KMsgBox::EXCLAMATION, _("&OK")); + msg.raise(); + msg.setActiveWindow(); + msg.show(); + } +} + +void FormPrint::show() +{ + if (!dialog_) + dialog_ = new FormPrintDialog(this, 0, _("LyX: Print")); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormPrint::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormPrint::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormPrint::close() +{ + h_.disconnect(); + u_.disconnect(); +} + +void FormPrint::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/kde/FormPrint.h b/src/frontends/kde/FormPrint.h new file mode 100644 index 0000000000..12a50a0f04 --- /dev/null +++ b/src/frontends/kde/FormPrint.h @@ -0,0 +1,65 @@ +/* FormPrint.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * 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 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FORMPRINT_H +#define FORMPRINT_H + +#include "DialogBase.h" +#include "boost/utility.hpp" + +class Dialogs; +class LyXView; +class FormPrintDialog; + +class FormPrint : public DialogBase, public noncopyable { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormPrint(LyXView *, Dialogs *); + /// + ~FormPrint(); + //@} + + /// start print + void print(); + /// close + void close(); + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + /// Update the dialog. + void update(); + + /// Real GUI implementation. + FormPrintDialog * dialog_; + + /// the LyXView we belong to + LyXView * lv_; + + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; + + /// Hide connection. + SigC::Connection h_; + /// Update connection. + SigC::Connection u_; +}; + +#endif diff --git a/src/frontends/kde/Makefile.am b/src/frontends/kde/Makefile.am index 473d530912..37d18157c0 100644 --- a/src/frontends/kde/Makefile.am +++ b/src/frontends/kde/Makefile.am @@ -7,13 +7,15 @@ INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ \ -I${top_srcdir}/src/frontends/xforms # just to make sure, automake makes them -BUILTSOURCES = formcopyrightdialog_moc.C \ - formurldialog_moc.C \ +BUILTSOURCES = formcitationdialog_moc.C \ + formcopyrightdialog_moc.C \ formindexdialog_moc.C \ formindexdialogdata_moc.C \ - formcitationdialog_moc.C \ + formprintdialog_moc.C \ + formprintdialogdata_moc.C \ + formrefdialog_moc.C \ formtocdialog_moc.C \ - formrefdialog_moc.C + formurldialog_moc.C DISTCLEANFILES = $(BUILTSOURCES) *.orig *.rej *~ *.bak core @@ -30,8 +32,6 @@ libkde_la_OBJADD = \ ../xforms/form_paragraph.lo \ ../xforms/FormPreferences.lo \ ../xforms/form_preferences.lo \ - ../xforms/FormPrint.lo \ - ../xforms/form_print.lo \ ../xforms/FormTabular.lo \ ../xforms/form_tabular.lo \ ../xforms/input_validators.lo \ @@ -47,33 +47,39 @@ libkde_la_SOURCES = \ Dialogs.C \ GUIRunTime.C \ QtLyXView.h \ + FormCitation.C \ + FormCitation.h \ FormCopyright.C \ FormCopyright.h \ + FormIndex.C \ + FormIndex.h \ + FormPrint.C \ + FormPrint.h \ + FormRef.C \ + FormRef.h \ + FormToc.C \ + FormToc.h \ + FormUrl.C \ + FormUrl.h \ + formcitationdialog.C \ + formcitationdialog.h \ formcopyrightdialog.C \ formcopyrightdialog.h \ formcopyrightdialogdata.C \ - FormUrl.C \ - FormUrl.h \ - formurldialog.C \ - formurldialog.h \ - FormIndex.C \ - FormIndex.h \ formindexdialog.C \ formindexdialog.h \ formindexdialogdata.C \ formindexdialogdata.h \ - FormCitation.C \ - FormCitation.h \ - formcitationdialog.C \ - formcitationdialog.h \ - FormToc.C \ - FormToc.h \ - formtocdialog.C \ - formtocdialog.h \ - FormRef.C \ - FormRef.h \ + formprintdialog.C \ + formprintdialog.h \ + formprintdialogdata.C \ + formprintdialogdata.h \ formrefdialog.C \ formrefdialog.h \ + formtocdialog.C \ + formtocdialog.h \ + formurldialog.C \ + formurldialog.h \ $(BUILTSOURCES) # These still have to be added. Sooner or later. ARRae-20000129 @@ -97,31 +103,44 @@ dist-hook: done ; \ done +# dialog file dependencies + +formindexdialogdata.C formindexdialogdata.h: dlg/formindexdialog.dlg + $(QTARCH) -g dlg/formindexdialog.dlg +formprintdialogdata.C formprintdialogdata.h: dlg/formprintdialog.dlg + $(QTARCH) -g dlg/formprintdialog.dlg + # add a dependency for every moc file to be full portable # I've added a key binding to emacs for this. +formcitationdialog.C: formcitationdialog_moc.C +formcitationdialog_moc.C: formcitationdialog.h + $(MOC) formcitationdialog.h -o formcitationdialog_moc.C + formcopyrightdialog.C: formcopyrightdialog_moc.C formcopyrightdialog_moc.C: formcopyrightdialog.h $(MOC) formcopyrightdialog.h -o formcopyrightdialog_moc.C -formurldialog.C: formurldialog_moc.C -formurldialog_moc.C: formurldialog.h - $(MOC) formurldialog.h -o formurldialog_moc.C - formindexdialog.C: formindexdialog_moc.C formindexdialog_moc.C: formindexdialog.h $(MOC) formindexdialog.h -o formindexdialog_moc.C formindexdialogdata_moc.C: formindexdialogdata.h $(MOC) formindexdialogdata.h -o formindexdialogdata_moc.C -formcitationdialog.C: formcitationdialog_moc.C -formcitationdialog_moc.C: formcitationdialog.h - $(MOC) formcitationdialog.h -o formcitationdialog_moc.C - -formtocdialog.C: formtocdialog_moc.C -formtocdialog_moc.C: formtocdialog.h - $(MOC) formtocdialog.h -o formtocdialog_moc.C +formprintdialog.C: formprintdialog_moc.C +formprintdialog_moc.C: formprintdialog.h + $(MOC) formprintdialog.h -o formprintdialog_moc.C +formprintdialogdata_moc.C: formprintdialogdata.h + $(MOC) formprintdialogdata.h -o formprintdialogdata_moc.C formrefdialog.C: formrefdialog_moc.C formrefdialog_moc.C: formrefdialog.h $(MOC) formrefdialog.h -o formrefdialog_moc.C + +formtocdialog.C: formtocdialog_moc.C +formtocdialog_moc.C: formtocdialog.h + $(MOC) formtocdialog.h -o formtocdialog_moc.C + +formurldialog.C: formurldialog_moc.C +formurldialog_moc.C: formurldialog.h + $(MOC) formurldialog.h -o formurldialog_moc.C diff --git a/src/frontends/kde/dlg/README b/src/frontends/kde/dlg/README new file mode 100644 index 0000000000..ddefb80c75 --- /dev/null +++ b/src/frontends/kde/dlg/README @@ -0,0 +1,61 @@ +These files are generated with qtarch-1.4-5 which can be downloaded +from + +http://qtarch.sourceforge.net/ + +FIXME. Note this is *not* the latest version, as they only +support Qt 2.0. + +You should compile in the KDE module when you compile qtarch-1.4. +For me this was just a case of a make in the module/kde/ directory, +and then you can add the .so library file in the qtarch GUI. + +Note that the formsomethingdialogdata.* files are automatically +generated, but the derived class files are *not* (i.e. they have +been edited by hand). So you should only ever generate the base +class files, and then propogate any changes into the derived class +by hand. + +Some tips and guidelines for qtarch and the KDE frontend : + +o the default button should be the one that causes least harm, unless + the action can be undone. So Print should default to cancel, whereas + insert index entry can be undone, so should default to OK + +o the dialog should derive from QWidget (set in Properties) + +o the dialog should always have the gettext option set + +o give every widget a name - useful for the geometry layouts later + +o don't bother setting min/max sizes for anything, but do set the size Hint + stuff appropriately. e.g. QLineEdit's should have a max height specified by + size Hint, but variable width + +o if you map a variable make it the same as the widget name + +o radio groups are done automagically based on positioning + +o grid units are 5 pixels + +o set alignment before placing a widget inside a layout, it doesn't seem to + update properly. Alternatively you can just edit the .dlg file directly + +o push buttons are arranged symmetrically across the dialog e.g. + <1 stretch>