]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrint.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / GuiPrint.cpp
index f54cde7fe4e3367835e8eaf29b2cd4762646ffaf..b0fd8718aa2233ea73d627a9b7b921a27f3eae8a 100644 (file)
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "FuncRequest.h"
-#include "support/gettext.h"
+#include "LyXRC.h"
 
 #include "support/convert.h"
-#include "support/FileFilterList.h"
 #include "support/filetools.h"
 #include "support/os.h"
 
 #include <QPushButton>
 
 using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
 
-using support::FileFilterList;
-
 
 GuiPrint::GuiPrint(GuiView & lv)
-       : GuiDialog(lv, "print")
+       : GuiDialog(lv, "print", qt_("Print Document"))
 {
        setupUi(this);
-       setViewTitle(_("Print Document"));
 
        connect(printPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@@ -59,13 +56,13 @@ GuiPrint::GuiPrint(GuiView & lv)
        connect(allRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(reverseCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(collateCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-       connect(fromED, SIGNAL(textChanged(const QString&)),
+       connect(fromED, SIGNAL(textChanged(QString)),
                this, SLOT(pagerangeChanged()));
-       connect(fromED, SIGNAL(textChanged(const QString&)),
+       connect(fromED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
-       connect(toED, SIGNAL(textChanged(const QString&)),
+       connect(toED, SIGNAL(textChanged(QString)),
                this, SLOT(pagerangeChanged()));
-       connect(toED, SIGNAL(textChanged(const QString&)),
+       connect(toED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
        connect(fileRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(printerRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
@@ -86,13 +83,10 @@ void GuiPrint::change_adaptor()
 
 void GuiPrint::browseClicked()
 {
-       docstring name =
-               browseRelFile(docstring(), from_utf8(buffer().filePath()),
-                            _("Print to file"),
-                            FileFilterList(_("PostScript files (*.ps)")),
-                            true);
-       QString file = toqstr(name);
-       if (!file.isNull()) {
+       QString file =
+               browseRelToParent(QString(), bufferFilePath(), qt_("Print to file"),
+                            QStringList(qt_("PostScript files (*.ps)")), true);
+       if (!file.isEmpty()) {
                fileED->setText(file);
                changed();
        }
@@ -150,9 +144,9 @@ void GuiPrint::updateContents()
 
        collateCB->setChecked(params_.sorted_copies);
 
-       if (params_.all_pages) {
+       if (params_.all_pages)
                allRB->setChecked(true);
-       else {
+       else {
                rangeRB->setChecked(true);
                fromED->setText(QString::number(params_.from_page));
                toED->setText(QString::number(params_.to_page));
@@ -162,31 +156,27 @@ void GuiPrint::updateContents()
 
 void GuiPrint::applyView()
 {
-       PrinterParams::Target t = PrinterParams::PRINTER;
-       if (fileRB->isChecked())
-               t = PrinterParams::FILE;
-
-       params_ = PrinterParams(t,
-               fromqstr(printerED->text()),
-               support::os::internal_path(fromqstr(fileED->text())),
-               allRB->isChecked(),
-               fromED->text().toUInt(),
-               toED->text().toUInt(),
-               oddCB->isChecked(),
-               evenCB->isChecked(),
-               copiesSB->text().toUInt(),
-               collateCB->isChecked(),
-               reverseCB->isChecked()
-       );
+       params_.target        = fileRB->isChecked()
+               ?  PrinterParams::FILE : PrinterParams::PRINTER;
+       params_.printer_name  = fromqstr(printerED->text());
+       params_.file_name     = os::internal_path(fromqstr(fileED->text()));
+       params_.all_pages     = allRB->isChecked();
+       params_.from_page     = fromED->text().toUInt();
+       params_.to_page       = toED->text().toUInt();
+       params_.odd_pages     = oddCB->isChecked();
+       params_.even_pages    = evenCB->isChecked();
+       params_.count_copies  = copiesSB->text().toUInt();
+       params_.sorted_copies = collateCB->isChecked();
+       params_.reverse_order = reverseCB->isChecked();
 }
 
 
-bool GuiPrint::initialiseParams(std::string const &)
+bool GuiPrint::initialiseParams(string const &)
 {
        /// get global printer parameters
-       string const name = support::changeExtension(buffer().absFileName(),
+       params_ = PrinterParams();
+       params_.file_name = support::changeExtension(buffer().absFileName(),
                                        lyxrc.print_file_extension);
-       params_ = PrinterParams(PrinterParams::PRINTER, lyxrc.printer, name);
 
        setButtonsValid(true); // so that the user can press Ok
        return true;
@@ -262,4 +252,4 @@ Dialog * createGuiPrint(GuiView & lv) { return new GuiPrint(lv); }
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiPrint_moc.cpp"
+#include "moc_GuiPrint.cpp"