[Libreoffice-commits] core.git: vcl/inc vcl/source vcl/uiconfig

Katarina Behrens Katarina.Behrens at cib.de
Tue Feb 9 10:26:03 UTC 2016


 vcl/inc/printdlg.hxx           |    1 
 vcl/source/window/printdlg.cxx |   67 ++++++++++++++++++++++-------------------
 vcl/uiconfig/ui/printdialog.ui |   22 +------------
 3 files changed, 40 insertions(+), 50 deletions(-)

New commits:
commit 29b92329005eb2f31d2b76eafaa1ffff67387b8e
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Fri Jan 29 18:25:16 2016 +0100

    tdf#94097: Move 'Print to file' option to the front page
    
    Change-Id: I4acc09d0a46d82cfc9a63cbffe8e53a1b86f3acd
    Reviewed-on: https://gerrit.libreoffice.org/21908
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index d11a689..8c59965 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -163,7 +163,6 @@ namespace vcl
         class OutputOptPage
         {
         public:
-            VclPtr<CheckBox>                    mpToFileBox;
             VclPtr<CheckBox>                    mpCollateSingleJobsBox;
             VclPtr<CheckBox>                    mpPapersizeFromSetup;
 
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 5f1970b..67b0acd 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -484,7 +484,6 @@ PrintDialog::JobTabPage::JobTabPage( VclBuilder* pUIBuilder )
     , mnCollateUIMode( 0 )
 {
     pUIBuilder->get(mpPrinters, "printers");
-    mpPrinters->SetStyle(mpPrinters->GetStyle() | WB_SORT);
     pUIBuilder->get(mpStatusTxt, "status");
     pUIBuilder->get(mpLocationTxt, "location");
     pUIBuilder->get(mpCommentTxt, "comment");
@@ -535,7 +534,6 @@ void PrintDialog::JobTabPage::storeToSettings()
 
 PrintDialog::OutputOptPage::OutputOptPage( VclBuilder *pUIBuilder )
 {
-    pUIBuilder->get(mpToFileBox, "printtofile");
     pUIBuilder->get(mpCollateSingleJobsBox, "singleprintjob");
     pUIBuilder->get(mpPapersizeFromSetup, "papersizefromsetup");
 }
@@ -560,15 +558,18 @@ void PrintDialog::OutputOptPage::storeToSettings()
 {
     SettingsConfigItem* pItem = SettingsConfigItem::get();
     pItem->setValue( "PrintDialog",
-                     "ToFile",
-                     mpToFileBox->IsChecked() ? OUString("true")
-                                             : OUString("false") );
-    pItem->setValue( "PrintDialog",
                      "CollateSingleJobs",
                      mpCollateSingleJobsBox->IsChecked() ? OUString("true") :
                                                 OUString("false") );
 }
 
+namespace {
+   bool lcl_ListBoxCompare( const OUString& rStr1, const OUString& rStr2 )
+   {
+       return ListBox::NaturalSortCompare( rStr1, rStr2 ) < 0;
+   }
+}
+
 PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterController>& i_rController )
     : ModalDialog(i_pParent, "PrintDialog", "vcl/ui/printdialog.ui")
     , mpCustomOptionsUIBuilder(nullptr)
@@ -607,8 +608,10 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
 
     Printer::updatePrinters();
 
+    maJobPage.mpPrinters->InsertEntry( maPrintToFileText );
     // fill printer listbox
-    const std::vector< OUString >& rQueues( Printer::GetPrinterQueues() );
+    std::vector< OUString > rQueues( Printer::GetPrinterQueues() );
+    std::sort( rQueues.begin(), rQueues.end(), lcl_ListBoxCompare );
     for( std::vector< OUString >::const_iterator it = rQueues.begin();
          it != rQueues.end(); ++it )
     {
@@ -676,7 +679,6 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
     maJobPage.mpCollateBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
     maJobPage.mpSetupButton->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
     maNUpPage.mpBorderCB->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
-    maOptionsPage.mpToFileBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
     maOptionsPage.mpPapersizeFromSetup->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
     maJobPage.mpReverseOrderBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
     maOptionsPage.mpCollateSingleJobsBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
@@ -756,19 +758,12 @@ void PrintDialog::readFromSettings()
             break;
         }
     }
-    mpOKButton->SetText( maOptionsPage.mpToFileBox->IsChecked() ? maPrintToFileText : maPrintText );
 
     // persistent window state
     OUString aWinState( pItem->getValue( "PrintDialog",
                                               "WindowState" ) );
     if( !aWinState.isEmpty() )
         SetWindowState( OUStringToOString( aWinState, RTL_TEXTENCODING_UTF8 ) );
-
-    if( maOptionsPage.mpToFileBox->IsChecked() )
-    {
-        maPController->resetPrinterOptions( true );
-        preparePreview( true, true );
-    }
 }
 
 void PrintDialog::storeToSettings()
@@ -779,8 +774,13 @@ void PrintDialog::storeToSettings()
     // store last selected printer
     SettingsConfigItem* pItem = SettingsConfigItem::get();
     pItem->setValue( "PrintDialog",
+                     "ToFile",
+                      isPrintToFile() ? OUString("true")
+                                             : OUString("false") );
+    pItem->setValue( "PrintDialog",
                      "LastPrinter",
-                     maJobPage.mpPrinters->GetSelectEntry() );
+                      isPrintToFile() ? Printer::GetDefaultPrinterName()
+                                      : maJobPage.mpPrinters->GetSelectEntry() );
 
     pItem->setValue( "PrintDialog",
                      "LastPage",
@@ -794,7 +794,7 @@ void PrintDialog::storeToSettings()
 
 bool PrintDialog::isPrintToFile()
 {
-    return maOptionsPage.mpToFileBox->IsChecked();
+    return ( maJobPage.mpPrinters->GetSelectEntryPos() == 0 );
 }
 
 bool PrintDialog::isCollate()
@@ -1521,13 +1521,26 @@ IMPL_LINK_TYPED( PrintDialog, SelectHdl, ListBox&, rBox, void )
 {
     if(  &rBox == maJobPage.mpPrinters )
     {
-        OUString aNewPrinter( rBox.GetSelectEntry() );
-        // set new printer
-        maPController->setPrinter( VclPtrInstance<Printer>( aNewPrinter ) );
-        maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() );
-        // update text fields
-        updatePrinterText();
-        preparePreview();
+
+        if ( rBox.GetSelectEntryPos() != 0)
+        {
+            OUString aNewPrinter( rBox.GetSelectEntry() );
+            // set new printer
+            maPController->setPrinter( VclPtrInstance<Printer>( aNewPrinter ) );
+            maPController->resetPrinterOptions( false  );
+            // update text fields
+            mpOKButton->SetText( maPrintText );
+            updatePrinterText();
+            preparePreview();
+        }
+        else // print to file
+        {
+            // use the default printer or FIXME: the last used one?
+            maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
+            mpOKButton->SetText( maPrintToFileText );
+            maPController->resetPrinterOptions( true );
+            preparePreview( true, true );
+        }
     }
     else if( &rBox == maNUpPage.mpNupOrientationBox || &rBox == maNUpPage.mpNupOrderBox )
     {
@@ -1575,12 +1588,6 @@ IMPL_LINK_TYPED( PrintDialog, ClickHdl, Button*, pButton, void )
     {
         previewBackward();
     }
-    else if( pButton == maOptionsPage.mpToFileBox )
-    {
-        mpOKButton->SetText( maOptionsPage.mpToFileBox->IsChecked() ? maPrintToFileText : maPrintText );
-        maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() );
-        preparePreview( true, true );
-    }
     else if( pButton == maOptionsPage.mpPapersizeFromSetup )
     {
         bool bChecked = maOptionsPage.mpPapersizeFromSetup->IsChecked();
diff --git a/vcl/uiconfig/ui/printdialog.ui b/vcl/uiconfig/ui/printdialog.ui
index 16a5984..08e1173 100644
--- a/vcl/uiconfig/ui/printdialog.ui
+++ b/vcl/uiconfig/ui/printdialog.ui
@@ -1512,22 +1512,6 @@
                             <property name="can_focus">False</property>
                             <property name="row_spacing">6</property>
                             <child>
-                              <object class="GtkCheckButton" id="printtofile">
-                                <property name="label" translatable="yes">Print to file</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="xalign">0</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">0</property>
-                                <property name="top_attach">0</property>
-                                <property name="width">1</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                            <child>
                               <object class="GtkCheckButton" id="singleprintjob">
                                 <property name="label" translatable="yes">Create single print jobs for collated output</property>
                                 <property name="visible">True</property>
@@ -1538,7 +1522,7 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
-                                <property name="top_attach">1</property>
+                                <property name="top_attach">0</property>
                                 <property name="width">1</property>
                                 <property name="height">1</property>
                               </packing>
@@ -1553,7 +1537,7 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
-                                <property name="top_attach">2</property>
+                                <property name="top_attach">1</property>
                                 <property name="width">1</property>
                                 <property name="height">1</property>
                               </packing>
@@ -1570,7 +1554,7 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
-                                <property name="top_attach">3</property>
+                                <property name="top_attach">2</property>
                                 <property name="width">1</property>
                                 <property name="height">1</property>
                               </packing>


More information about the Libreoffice-commits mailing list