summaryrefslogtreecommitdiffstats
path: root/part/kxeprintsettings.cpp
blob: 0a76e60d8dc778313521ec2161e685fb4e742152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/***************************************************************************
                           kxeprintsettings.cpp
                           --------------------
    begin                : Tue Dec 02 2003
    copyright            : (C) 2003 by The KXMLEditor Team
    email                : hartig@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "kxeprintsettings.h"
#include "kxeprintsettingspage.h"

#include <tdelocale.h>
#include <tdeconfig.h>
#include <tdefontcombo.h>

#include <tqframe.h>
#include <tqspinbox.h>
#include <tqcheckbox.h>

#define CONF_ENTRY_NAME_FONTFAMILY "Print font family"
#define DFLT_VALUE_FONTFAMILY "Courier"

#define CONF_ENTRY_NAME_FONTSIZE "Print font size"
#define DFLT_VALUE_FONTSIZE 10

#define CONF_ENTRY_NAME_INDENT_STEPS "Print indentation"
#define DFLT_VALUE_INDENT_STEPS 2

#define CONF_ENTRY_NAME_WITH_FOOTER "Print has footer"
#define DFLT_VALUE_WITH_FOOTER true

#define CONF_ENTRY_NAME_WITH_HEADER "Print has header"
#define DFLT_VALUE_WITH_HEADER true


KXEPrintSettings::KXEPrintSettings( TQObject * pParent, const char * pszName )
 : KXESettings( "Print Settings", pParent, pszName ),
   m_strFontFamily( DFLT_VALUE_FONTFAMILY ),
   m_iFontSize( DFLT_VALUE_FONTSIZE ),
   m_iIndentSteps( DFLT_VALUE_INDENT_STEPS ),
   m_bWithHeader( DFLT_VALUE_WITH_FOOTER ),
   m_bWithFooter( DFLT_VALUE_WITH_HEADER ),
   m_pDialogPage(0)
{
}


void KXEPrintSettings::write( TDEConfig * pConfig ) const
{
	pConfig->writeEntry( CONF_ENTRY_NAME_FONTFAMILY, m_strFontFamily );
	pConfig->writeEntry( CONF_ENTRY_NAME_FONTSIZE, m_iFontSize );
	pConfig->writeEntry( CONF_ENTRY_NAME_INDENT_STEPS, m_iIndentSteps );
	pConfig->writeEntry( CONF_ENTRY_NAME_WITH_FOOTER, m_bWithHeader );
	pConfig->writeEntry( CONF_ENTRY_NAME_WITH_HEADER, m_bWithFooter );
}


void KXEPrintSettings::read( const TDEConfig * pConfig )
{
	m_strFontFamily = pConfig->readEntry( CONF_ENTRY_NAME_FONTFAMILY, DFLT_VALUE_FONTFAMILY );
	m_iFontSize = pConfig->readNumEntry( CONF_ENTRY_NAME_FONTSIZE, DFLT_VALUE_FONTSIZE );
	m_iIndentSteps = pConfig->readNumEntry( CONF_ENTRY_NAME_INDENT_STEPS, DFLT_VALUE_INDENT_STEPS );
	m_bWithHeader = pConfig->readBoolEntry( CONF_ENTRY_NAME_WITH_FOOTER, DFLT_VALUE_WITH_FOOTER );
	m_bWithFooter = pConfig->readBoolEntry( CONF_ENTRY_NAME_WITH_HEADER, DFLT_VALUE_WITH_HEADER );
}

TQString KXEPrintSettings::dialogPageName() const
{
	return i18n( "Printing" );
}

TQString KXEPrintSettings::dialogPageHeader() const
{
	return i18n( "Print Settings" );
}

TQString KXEPrintSettings::dialogPageIcon() const
{
	return "printer";
}

TQWidget * KXEPrintSettings::dialogPage( TQFrame * pParent )
{
	if ( ! m_pDialogPage )
	{
		// create the page if necessary
		m_pDialogPage = new KXEPrintSettingsPage( pParent, "printing config.dialog page" );

		// and fill its widgets with the corresponding values
		updatePage();

		connect( m_pDialogPage->m_pFontFamily, TQ_SIGNAL(activated(int)), this, TQ_SIGNAL(sigDialogPageChanged()) );
		connect( m_pDialogPage->m_pFontSize, TQ_SIGNAL(valueChanged(int)), this, TQ_SIGNAL(sigDialogPageChanged()) );
		connect( m_pDialogPage->m_pIndentSteps, TQ_SIGNAL(valueChanged(int)), this, TQ_SIGNAL(sigDialogPageChanged()) );
		connect( m_pDialogPage->m_pWithHeader, TQ_SIGNAL(toggled(bool)), this, TQ_SIGNAL(sigDialogPageChanged()) );
		connect( m_pDialogPage->m_pWithFooter, TQ_SIGNAL(toggled(bool)), this, TQ_SIGNAL(sigDialogPageChanged()) );
	}

	return m_pDialogPage;
}


void KXEPrintSettings::setFromPage()
{
	if ( m_pDialogPage )
	{
		m_strFontFamily = m_pDialogPage->m_pFontFamily->currentText();
		m_iFontSize = m_pDialogPage->m_pFontSize->value();
		m_iIndentSteps = m_pDialogPage->m_pIndentSteps->value();
		m_bWithHeader = m_pDialogPage->m_pWithHeader->isChecked();
		m_bWithFooter = m_pDialogPage->m_pWithFooter->isChecked();
	}
}

void KXEPrintSettings::updatePage() const
{
	if ( m_pDialogPage )
	{
		m_pDialogPage->m_pFontFamily->setCurrentFont( m_strFontFamily );
		m_pDialogPage->m_pFontSize->setValue( m_iFontSize );
		m_pDialogPage->m_pIndentSteps->setValue( m_iIndentSteps );
		m_pDialogPage->m_pWithHeader->setChecked( m_bWithHeader );
		m_pDialogPage->m_pWithFooter->setChecked( m_bWithFooter );
	}
}