Index: src/mainwindow.cpp
===================================================================
--- src/mainwindow.cpp	(revision 144fbe6b96273f8852656cced066823758dfbae7)
+++ src/mainwindow.cpp	(revision 20e8115ceecc73713fd788f9758b7ade5c216818)
@@ -62,11 +62,18 @@
     printer = new QPrinter(QPrinter::HighResolution);
     settings->beginGroup("Printer");
-    printer->setPaperSize(qvariant_cast<QPrinter::PaperSize>(settings->value("PaperSize", DEF_PAGE_SIZE)));
+QPrinter::PaperSize size = qvariant_cast<QPrinter::PaperSize>(settings->value("PaperSize", DEF_PAGE_SIZE));
+    if (size != QPrinter::Custom) {
+        printer->setPaperSize(size);
+    } else {
+        printer->setPaperSize(QSizeF(settings->value("PaperWidth").toReal(), settings->value("PaperHeight").toReal()),
+                              QPrinter::Millimeter);
+    }
+
     printer->setOrientation(qvariant_cast<QPrinter::Orientation>(settings->value("PageOrientation", DEF_PAGE_ORIENTATION)));
     printer->setPageMargins(
-        settings->value("MarginLeft", DEF_MARGIN_LEFT).toDouble(),
-        settings->value("MarginTop", DEF_MARGIN_TOP).toDouble(),
-        settings->value("MarginRight", DEF_MARGIN_RIGHT).toDouble(),
-        settings->value("MarginBottom", DEF_MARGIN_BOTTOM).toDouble(),
+        settings->value("MarginLeft", DEF_MARGIN_LEFT).toReal(),
+        settings->value("MarginTop", DEF_MARGIN_TOP).toReal(),
+        settings->value("MarginRight", DEF_MARGIN_RIGHT).toReal(),
+        settings->value("MarginBottom", DEF_MARGIN_BOTTOM).toReal(),
         QPrinter::Millimeter);
     settings->endGroup();
@@ -85,4 +92,5 @@
 #ifndef QT_NO_PRINTER
     connect(actionFilePrintPreview, SIGNAL(triggered()), SLOT(actionFilePrintPreviewTriggered()));
+    connect(actionFilePageSetup, SIGNAL(triggered()), SLOT(actionFilePageSetupTriggered()));
     connect(actionFilePrint, SIGNAL(triggered()), SLOT(actionFilePrintTriggered()));
 #endif // QT_NO_PRINTER
@@ -363,4 +371,33 @@
     settings->beginGroup("Printer");
     settings->setValue("PaperSize", printer->paperSize());
+    if (printer->paperSize() == QPrinter::Custom) {
+QSizeF size(printer->paperSize(QPrinter::Millimeter));
+        settings->setValue("PaperWidth", size.width());
+        settings->setValue("PaperHeight", size.height());
+    }
+    settings->setValue("PageOrientation", printer->orientation());
+    settings->setValue("MarginLeft", l);
+    settings->setValue("MarginTop", t);
+    settings->setValue("MarginRight", r);
+    settings->setValue("MarginBottom", b);
+    settings->endGroup();
+}
+
+void MainWindow::actionFilePageSetupTriggered()
+{
+QPageSetupDialog psd(printer, this);
+    if (psd.exec() != QDialog::Accepted)
+        return;
+
+qreal l, t, r ,b;
+    printer->getPageMargins(&l, &t, &r, &b, QPrinter::Millimeter);
+
+    settings->beginGroup("Printer");
+    settings->setValue("PaperSize", printer->paperSize());
+    if (printer->paperSize() == QPrinter::Custom) {
+QSizeF size(printer->paperSize(QPrinter::Millimeter));
+        settings->setValue("PaperWidth", size.width());
+        settings->setValue("PaperHeight", size.height());
+    }
     settings->setValue("PageOrientation", printer->orientation());
     settings->setValue("MarginLeft", l);
@@ -784,8 +821,10 @@
         pic.begin(&graph);
         pic.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
-QFont font = qvariant_cast<QFont>(settings->value("Output/Font", QFont(DEF_FONT_FACE, 9)));
+QFont font = qvariant_cast<QFont>(settings->value("Output/Font", QFont(DEF_FONT_FACE)));
+        //! \todo FIXME: Get rid of the "magic number" in the code.
+        font.setPixelSize(logicalDpiX() / 7);
         if (settings->value("Output/HQGraph", DEF_HQ_GRAPH).toBool()) {
             font.setWeight(QFont::DemiBold);
-            font.setPointSizeF(font.pointSizeF() * 2);
+            font.setPixelSize(font.pixelSize() * 2);
         }
         pic.setFont(font);
@@ -1129,4 +1168,5 @@
 {
 qreal r;
+    //! \todo FIXME: Get rid of the "magic numbers" in the code.
     if (settings->value("Output/HQGraph", DEF_HQ_GRAPH).toBool())
         r = logicalDpiX() / 1.27;
@@ -1478,5 +1518,12 @@
 #ifndef QT_NO_STATUSTIP
     actionFilePrintPreview->setStatusTip(tr("Preview current solution results before printing"));
-    actionFileExit->setStatusTip(tr("Exit %1").arg(QCoreApplication::applicationName()));
+#endif // QT_NO_STATUSTIP
+
+    actionFilePageSetup->setText(tr("Pa&ge Setup..."));
+#ifndef QT_NO_TOOLTIP
+    actionFilePageSetup->setToolTip(tr("Setup print options"));
+#endif // QT_NO_TOOLTIP
+#ifndef QT_NO_STATUSTIP
+    actionFilePageSetup->setStatusTip(tr("Setup page-related options for printing"));
 #endif // QT_NO_STATUSTIP
 
@@ -1490,4 +1537,8 @@
     actionFilePrint->setShortcut(tr("Ctrl+P"));
 #endif // QT_NO_PRINTER
+
+#ifndef QT_NO_STATUSTIP
+    actionFileExit->setStatusTip(tr("Exit %1").arg(QCoreApplication::applicationName()));
+#endif // QT_NO_STATUSTIP
 
 #ifndef HANDHELD
@@ -1640,4 +1691,13 @@
     actionFilePrintPreview->setIcon(GET_ICON("document-print-preview"));
 
+    actionFilePageSetup = new QAction(this);
+    actionFilePageSetup->setObjectName("actionFilePrintSetup");
+//    actionFilePageSetup->setEnabled(false);
+#if QT_VERSION >= 0x040600
+    actionFilePageSetup->setIcon(QIcon::fromTheme("document-page-setup", QIcon(":/trolltech/dialogs/qprintpreviewdialog/images/page-setup-32.png")));
+#else
+    actionFilePageSetup->setIcon(QIcon(":/trolltech/dialogs/qprintpreviewdialog/images/page-setup-32.png"));
+#endif
+
     actionFilePrint = new QAction(this);
     actionFilePrint->setObjectName("actionFilePrint");
@@ -1645,6 +1705,7 @@
     actionFilePrint->setIcon(GET_ICON("document-print"));
 
-    menuFile->insertAction(actionFileExit,actionFilePrintPreview);
-    menuFile->insertAction(actionFileExit,actionFilePrint);
+    menuFile->insertAction(actionFileExit, actionFilePrintPreview);
+    menuFile->insertAction(actionFileExit, actionFilePageSetup);
+    menuFile->insertAction(actionFileExit, actionFilePrint);
     menuFile->insertSeparator(actionFileExit);
 
@@ -1684,5 +1745,5 @@
 
 #ifndef HANDHELD
-    toolBarManager = new QtToolBarManager;
+    toolBarManager = new QtToolBarManager(this);
     toolBarManager->setMainWindow(this);
 QString cat = toolBarMain->windowTitle();
@@ -1690,8 +1751,8 @@
 #ifndef QT_NO_PRINTER
     toolBarManager->addAction(actionFilePrintPreview, cat);
+    toolBarManager->addAction(actionFilePageSetup, cat);
 #endif // QT_NO_PRINTER
     toolBarManager->addAction(actionHelpContents, cat);
     toolBarManager->addAction(actionHelpContextual, cat);
-//	toolBarManager->addAction(action, cat);
     toolBarManager->restoreState(settings->value("MainWindow/Toolbars").toByteArray());
 #else
