[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Aug 11 01:59:06 UTC 2018


 vcl/inc/printdlg.hxx           |    2 
 vcl/source/window/printdlg.cxx |  105 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 106 insertions(+), 1 deletion(-)

New commits:
commit 40a482ebb79968763b70bd7fade583a26e2e3b52
Author:     Daniel <danielfaleirosilva at gmail.com>
AuthorDate: Fri Aug 10 05:12:18 2018 -0300
Commit:     Daniel Silva <danielfaleirosilva at gmail.com>
CommitDate: Sat Aug 11 03:58:44 2018 +0200

    Reinserts storeToSettings and readToSettings in print dialog
    
    Change-Id: I094439a677f8c30c45688fc879140177e3681559
    Reviewed-on: https://gerrit.libreoffice.org/58814
    Tested-by: Jenkins
    Reviewed-by: Daniel Silva <danielfaleirosilva at gmail.com>

diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 86b6cf6d1a07..3edc2ceb3c69 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -228,6 +228,8 @@ namespace vcl
 
         void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false );
         void setupPaperSidesBox();
+        void storeToSettings();
+        void readFromSettings();
         void setPreviewText();
         void updatePrinterText();
         void checkControlDependencies();
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index ddc8589fd23a..4546a8ff000f 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -665,6 +665,9 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo
     // hide layout frame if unwanted
     mpPageLayoutFrame->Show( mbShowLayoutFrame );
 
+    // restore settings from last run
+    readFromSettings();
+
     // setup click hdl
     mpOKButton->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
     mpCancelButton->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
@@ -772,6 +775,106 @@ void PrintDialog::setupPaperSidesBox()
     }
 }
 
+void PrintDialog::storeToSettings()
+{
+    SettingsConfigItem* pItem = SettingsConfigItem::get();
+
+    pItem->setValue( "PrintDialog",
+                     "LastPrinter",
+                      isPrintToFile() ? Printer::GetDefaultPrinterName()
+                                      : mpPrinters->GetSelectedEntry() );
+
+    pItem->setValue( "PrintDialog",
+                     "LastPage",
+                     mpTabCtrl->GetPageText( mpTabCtrl->GetCurPageId() ) );
+
+    pItem->setValue( "PrintDialog",
+                     "WindowState",
+                     OStringToOUString( GetWindowState(), RTL_TEXTENCODING_UTF8 ) );
+
+    pItem->setValue( "PrintDialog",
+                     "CopyCount",
+                     mpCopyCountField->GetText() );
+
+    pItem->setValue( "PrintDialog",
+                     "Collate",
+                     mpCollateBox->IsChecked() ? OUString("true") :
+                                                 OUString("false") );
+
+    pItem->setValue( "PrintDialog",
+                     "CollateSingleJobs",
+                     mbSingleJobs ? OUString("true") :
+                                    OUString("false") );
+
+    pItem->setValue( "PrintDialog",
+                     "HasPreview",
+                     hasPreview() ? OUString("true") :
+                                    OUString("false") );
+
+    pItem->Commit();
+}
+
+void PrintDialog::readFromSettings()
+{
+    SettingsConfigItem* pItem = SettingsConfigItem::get();
+    OUString aValue;
+
+    // read last selected tab page; if it exists, activate it
+    aValue = pItem->getValue( "PrintDialog",
+                              "LastPage" );
+    sal_uInt16 nCount = mpTabCtrl->GetPageCount();
+    for( sal_uInt16 i = 0; i < nCount; i++ )
+    {
+        sal_uInt16 nPageId = mpTabCtrl->GetPageId( i );
+
+        if( aValue == mpTabCtrl->GetPageText( nPageId ) )
+        {
+            mpTabCtrl->SelectTabPage( nPageId );
+            break;
+        }
+    }
+
+    // persistent window state
+    aValue = pItem->getValue( "PrintDialog",
+                              "WindowState" );
+    if( !aValue.isEmpty() )
+        SetWindowState( OUStringToOString( aValue, RTL_TEXTENCODING_UTF8 ) );
+
+    // collate
+    aValue = pItem->getValue( "PrintDialog",
+                              "CollateBox" );
+    if( aValue.equalsIgnoreAsciiCase("alwaysoff") )
+    {
+        mnCollateUIMode = 1;
+        mpCollateBox->Check( false );
+        mpCollateBox->Enable( false );
+    }
+    else
+    {
+        mnCollateUIMode = 0;
+        aValue = pItem->getValue( "PrintDialog",
+                                  "Collate" );
+        mpCollateBox->Check( aValue.equalsIgnoreAsciiCase("true") );
+    }
+
+    // collate single jobs
+    aValue = pItem->getValue( "PrintDialog",
+                              "CollateSingleJobs" );
+    if ( aValue.equalsIgnoreAsciiCase("true") )
+        mbSingleJobs = true;
+    else
+        mbSingleJobs = false;
+
+    // preview box
+    aValue = pItem->getValue( "PrintDialog",
+                              "HasPreview" );
+    if ( aValue.equalsIgnoreAsciiCase("true") )
+        mpPreviewBox->Check( true );
+    else
+        mpPreviewBox->Check( false );
+
+}
+
 void PrintDialog::setPaperSizes()
 {
     mpPaperSizeBox->Clear();
@@ -1680,7 +1783,7 @@ IMPL_LINK ( PrintDialog, ClickHdl, Button*, pButton, void )
 {
     if( pButton == mpOKButton || pButton == mpCancelButton )
     {
-        //storeToSettings();
+        storeToSettings();
         EndDialog( pButton == mpOKButton ? RET_OK : RET_CANCEL );
     }
     else if( pButton == mpHelpButton )


More information about the Libreoffice-commits mailing list