[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kate/utils
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2010-08-11 18:54:08
Message-ID: 20100811185408.CD89BAC80E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1162261 by cullmann:

Christian Loose <christian.loose@hamburg.de>:

BUG 246647    
Save print options in config file katerc


 M  +181 -2    kateprinter.cpp  
 M  +14 -4     kateprinter.h  


--- trunk/KDE/kdelibs/kate/utils/kateprinter.cpp #1162260:1162261
@@ -79,7 +79,7 @@
   if ( !parentWidget )
     parentWidget=QApplication::activeWindow();
 
-  QPrintDialog *printDialog = KdePrint::createPrintDialog(&printer, \
KdePrint::SystemSelectsPages, tabs, parentWidget); +  QScopedPointer<QPrintDialog> \
printDialog(KdePrint::createPrintDialog(&printer, KdePrint::SystemSelectsPages, tabs, \
parentWidget));  
   if ( doc->activeView()->selection() )
     printDialog->addEnabledOption(QAbstractPrintDialog::PrintSelection);
@@ -672,8 +672,15 @@
   cbGuide->setWhatsThis(i18n(
         "<p>Print a box displaying typographical conventions for the document type, \
as "  "defined by the syntax highlighting being used.</p>") );
+  
+  readSettings();
 }
 
+KatePrintTextSettings::~KatePrintTextSettings()
+{
+  writeSettings();
+}
+
 // bool KatePrintTextSettings::printSelection()
 // {
 //     return cbSelection->isChecked();
@@ -694,6 +701,31 @@
 //   cbSelection->setEnabled( enable );
 // }
 
+void KatePrintTextSettings::readSettings()
+{
+  KSharedConfigPtr config = KGlobal::config();
+  KConfigGroup printGroup( config, "Kate Print Settings" );
+  
+  KConfigGroup textGroup( &printGroup, "Text" );
+  bool isLineNumbersChecked = textGroup.readEntry( "LineNumbers", false );
+  cbLineNumbers->setChecked( isLineNumbersChecked );
+
+  bool isLegendChecked = textGroup.readEntry( "Legend", false );
+  cbGuide->setChecked( isLegendChecked );
+}
+    
+void KatePrintTextSettings::writeSettings()
+{
+  KSharedConfigPtr config = KGlobal::config();
+  KConfigGroup printGroup( config, "Kate Print Settings" );
+  
+  KConfigGroup textGroup( &printGroup, "Text" );
+  textGroup.writeEntry( "LineNumbers", printLineNumbers() );
+  textGroup.writeEntry( "Legend", printGuide() );
+  
+  config->sync();
+}
+
 //END KatePrintTextSettings
 
 //BEGIN KatePrintHeaderFooter
@@ -826,8 +858,15 @@
   leFooterRight->setWhatsThis(s + s1 );
   leFooterCenter->setWhatsThis(s + s1 );
   leFooterLeft->setWhatsThis(s + s1 );
+  
+  readSettings();
 }
 
+KatePrintHeaderFooter::~KatePrintHeaderFooter()
+{
+  writeSettings();
+}
+
 QFont KatePrintHeaderFooter::font()
 {
     return lFontPreview->font();
@@ -899,6 +938,96 @@
   }
 }
 
+void KatePrintHeaderFooter::readSettings()
+{
+  KSharedConfigPtr config = KGlobal::config();
+  KConfigGroup printGroup( config, "Kate Print Settings" );
+  
+  // Header
+  KConfigGroup headerFooterGroup( &printGroup, "HeaderFooter" );
+  bool isHeaderEnabledChecked = headerFooterGroup.readEntry( "HeaderEnabled", true \
); +  cbEnableHeader->setChecked( isHeaderEnabledChecked );
+
+  QString headerFormatLeft = headerFooterGroup.readEntry( "HeaderFormatLeft", "%y" \
); +  leHeaderLeft->setText( headerFormatLeft );
+
+  QString headerFormatCenter = headerFooterGroup.readEntry( "HeaderFormatCenter", \
"%f" ); +  leHeaderCenter->setText( headerFormatCenter );
+
+  QString headerFormatRight = headerFooterGroup.readEntry( "HeaderFormatRight", "%p" \
); +  leHeaderRight->setText( headerFormatRight );
+
+  QColor headerForeground = headerFooterGroup.readEntry( "HeaderForeground", \
QColor("black") ); +  kcbtnHeaderFg->setColor( headerForeground );
+
+  bool isHeaderBackgroundChecked = headerFooterGroup.readEntry( \
"HeaderBackgroundEnabled", false ); +  cbHeaderEnableBgColor->setChecked( \
isHeaderBackgroundChecked ); +
+  QColor headerBackground = headerFooterGroup.readEntry( "HeaderBackground", \
QColor("lightgrey") ); +  kcbtnHeaderBg->setColor( headerBackground );
+  
+  // Footer
+  bool isFooterEnabledChecked = headerFooterGroup.readEntry( "FooterEnabled", true \
); +  cbEnableFooter->setChecked( isFooterEnabledChecked );
+
+  QString footerFormatLeft = headerFooterGroup.readEntry( "FooterFormatLeft", \
QString() ); +  leFooterLeft->setText( footerFormatLeft );
+
+  QString footerFormatCenter = headerFooterGroup.readEntry( "FooterFormatCenter", \
QString() ); +  leFooterCenter->setText( footerFormatCenter );
+
+  QString footerFormatRight = headerFooterGroup.readEntry( "FooterFormatRight", "%U" \
); +  leFooterRight->setText( footerFormatRight );
+
+  QColor footerForeground = headerFooterGroup.readEntry( "FooterForeground", \
QColor("black") ); +  kcbtnFooterFg->setColor( footerForeground );
+
+  bool isFooterBackgroundChecked = headerFooterGroup.readEntry( \
"FooterBackgroundEnabled", false ); +  cbFooterEnableBgColor->setChecked( \
isFooterBackgroundChecked ); +
+  QColor footerBackground = headerFooterGroup.readEntry( "FooterBackground", \
QColor("lightgrey") ); +  kcbtnFooterBg->setColor( footerBackground );
+
+  // Font
+  QFont headerFooterFont = headerFooterGroup.readEntry( "HeaderFooterFont", QFont() \
); +  lFontPreview->setFont( headerFooterFont );
+  lFontPreview->setText( QString(headerFooterFont.family() + ", %1pt").arg( \
headerFooterFont.pointSize() ) ); +}
+    
+void KatePrintHeaderFooter::writeSettings()
+{
+  KSharedConfigPtr config = KGlobal::config();
+  KConfigGroup printGroup( config, "Kate Print Settings" );
+  
+  // Header
+  KConfigGroup headerFooterGroup( &printGroup, "HeaderFooter" );
+  headerFooterGroup.writeEntry( "HeaderEnabled", useHeader() );
+
+  QStringList format = headerFormat();
+  headerFooterGroup.writeEntry( "HeaderFormatLeft", format[0] );
+  headerFooterGroup.writeEntry( "HeaderFormatCenter", format[1] );
+  headerFooterGroup.writeEntry( "HeaderFormatRight", format[2] );
+  headerFooterGroup.writeEntry( "HeaderForeground", headerForeground() );
+  headerFooterGroup.writeEntry( "HeaderBackgroundEnabled", useHeaderBackground() );
+  headerFooterGroup.writeEntry( "HeaderBackground", headerBackground() );
+  
+  // Footer
+  headerFooterGroup.writeEntry( "FooterEnabled", useFooter() );
+
+  format = footerFormat();
+  headerFooterGroup.writeEntry( "FooterFormatLeft", format[0] );
+  headerFooterGroup.writeEntry( "FooterFormatCenter", format[1] );
+  headerFooterGroup.writeEntry( "FooterFormatRight", format[2] );
+  headerFooterGroup.writeEntry( "FooterForeground", footerForeground() );
+  headerFooterGroup.writeEntry( "FooterBackgroundEnabled", useFooterBackground() );
+  headerFooterGroup.writeEntry( "FooterBackground", footerBackground() );
+
+  // Font
+  headerFooterGroup.writeEntry( "HeaderFooterFont", font() );
+
+  config->sync();
+}
+
 //END KatePrintHeaderFooter
 
 //BEGIN KatePrintLayout
@@ -913,7 +1042,7 @@
   KHBox *hb = new KHBox( this );
   lo->addWidget( hb );
   QLabel *lSchema = new QLabel( i18n("&Schema:"), hb );
-  cmbSchema = new QComboBox( hb );
+  cmbSchema = new KComboBox( hb );
   cmbSchema->setEditable( false );
   lSchema->setBuddy( cmbSchema );
 
@@ -975,8 +1104,15 @@
         "The margin inside boxes, in pixels") );
   kcbtnBoxColor->setWhatsThis(i18n(
         "The line color to use for boxes") );
+  
+  readSettings();
 }
 
+KatePrintLayout::~KatePrintLayout()
+{
+  writeSettings();
+}
+
 QString KatePrintLayout::colorScheme()
 {
   return cmbSchema->currentText();
@@ -1006,6 +1142,49 @@
 {
   return kcbtnBoxColor->color();
 }
+
+void KatePrintLayout::readSettings()
+{
+  KSharedConfigPtr config = KGlobal::config();
+  KConfigGroup printGroup(config, "Kate Print Settings");
+  
+  KConfigGroup layoutGroup(&printGroup, "Layout");
+
+  QString colorScheme = layoutGroup.readEntry( "ColorScheme", \
KateGlobal::self()->schemaManager()->name(1) ); +  cmbSchema->setCurrentItem( \
colorScheme ); +
+  bool isBackgroundChecked = layoutGroup.readEntry( "BackgroundColorEnabled", false \
); +  cbDrawBackground->setChecked( isBackgroundChecked );
+
+  bool isBoxChecked = layoutGroup.readEntry( "BoxEnabled", false );
+  cbEnableBox->setChecked( isBoxChecked );
+
+  int boxWidth = layoutGroup.readEntry( "BoxWidth", 1 );
+  sbBoxWidth->setValue( boxWidth );
+
+  int boxMargin = layoutGroup.readEntry( "BoxMargin", 6 );
+  sbBoxMargin->setValue( boxMargin );
+
+  QColor boxColor = layoutGroup.readEntry( "BoxColor", QColor() );
+  kcbtnBoxColor->setColor( boxColor );
+}
+    
+void KatePrintLayout::writeSettings()
+{
+  KSharedConfigPtr config = KGlobal::config();
+  KConfigGroup printGroup(config, "Kate Print Settings");
+  
+  KConfigGroup layoutGroup(&printGroup, "Layout");
+  layoutGroup.writeEntry( "ColorScheme", colorScheme() );
+  layoutGroup.writeEntry( "BackgroundColorEnabled", useBackground() );
+  layoutGroup.writeEntry( "BoxEnabled", useBox() );
+  layoutGroup.writeEntry( "BoxWidth", boxWidth() );
+  layoutGroup.writeEntry( "BoxMargin", boxMargin() );
+  layoutGroup.writeEntry( "BoxColor", boxColor() );
+  
+  config->sync();
+}
+
 //END KatePrintLayout
 
 #include "kateprinter.moc"
--- trunk/KDE/kdelibs/kate/utils/kateprinter.h #1162260:1162261
@@ -34,6 +34,7 @@
 class QLabel;
 class KLineEdit;
 class KIntSpinBox;
+class KComboBox;
 
 class KatePrinter
 {
@@ -53,7 +54,7 @@
   Q_OBJECT
   public:
     explicit KatePrintTextSettings( QWidget *parent=0 );
-    ~KatePrintTextSettings(){}
+    ~KatePrintTextSettings();
 
 //     bool printSelection();
     bool printLineNumbers();
@@ -63,6 +64,9 @@
 //     void enableSelection( bool );
 
   private:
+    void readSettings();
+    void writeSettings();
+    
     QCheckBox /* *cbSelection,*/ *cbLineNumbers, *cbGuide;
 };
 //END Text Settings
@@ -81,7 +85,7 @@
   Q_OBJECT
   public:
     explicit KatePrintHeaderFooter( QWidget *parent=0 );
-    ~KatePrintHeaderFooter(){}
+    ~KatePrintHeaderFooter();
 
     QFont font();
 
@@ -101,6 +105,9 @@
     void setHFFont();
 
   private:
+    void readSettings();
+    void writeSettings();
+    
     QCheckBox *cbEnableHeader, *cbEnableFooter;
     QLabel *lFontPreview;
     QGroupBox *gbHeader, *gbFooter;
@@ -129,7 +136,7 @@
   Q_OBJECT
   public:
     explicit KatePrintLayout( QWidget *parent=0 );
-    ~KatePrintLayout(){}
+    ~KatePrintLayout();
 
     QString colorScheme();
     bool useBackground();
@@ -139,7 +146,10 @@
     QColor boxColor();
 
   private:
-    QComboBox *cmbSchema;
+    void readSettings();
+    void writeSettings();
+    
+    KComboBox *cmbSchema;
     QCheckBox *cbEnableBox, *cbDrawBackground;
     QGroupBox *gbBoxProps;
     KIntSpinBox *sbBoxWidth, *sbBoxMargin;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic