summaryrefslogtreecommitdiffstats
path: root/kompare/libdialogpages/viewpage.cpp
blob: 827e8a4dc074334510927e77a153e7dda15ae0c1 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/***************************************************************************
                                viewprefs.cpp  -  description
                                -------------------
        begin                   : Sun Mar 4 2001
        copyright               : (C) 2001-2002 by Otto Bruggeman
                                  and John Firebaugh
        email                   : otto.bruggeman@home.nl
                                  jfirebaugh@kde.org
****************************************************************************/

/***************************************************************************
**
**   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 <tqcheckbox.h>
#include <tqgroupbox.h>
#include <tqhgroupbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqspinbox.h>

#include <kapplication.h>
#include <kcolorbutton.h>
#include <kdialog.h>
#include <kfontcombo.h>
#include <klocale.h>

#include "viewpage.h"
#include "viewsettings.h"

ViewPage::ViewPage( TQWidget* parent ) : PageBase( parent )
{
	TQWidget*     page;
	TQVBoxLayout* tqlayout;
	TQGroupBox*   tqcolorGroupBox;
	TQHGroupBox*  snolGroupBox;
	TQHGroupBox*  tabGroupBox;
	TQLabel*      label;

	page   = new TQWidget( this );
	tqlayout = new TQVBoxLayout( page );
	tqlayout->setSpacing( KDialog::spacingHint() );
	tqlayout->setMargin( KDialog::marginHint() );

	// add a groupbox
	tqcolorGroupBox = new TQGroupBox( 2, Qt::Horizontal, i18n( "Colors" ), page );
	tqlayout->addWidget( tqcolorGroupBox );
	tqcolorGroupBox->setMargin( KDialog::marginHint() );

	// add the removeColor
	label = new TQLabel( i18n( "Removed color:" ), tqcolorGroupBox );
	m_removedColorButton = new KColorButton( tqcolorGroupBox );
	label->setBuddy( m_removedColorButton );

	// add the changeColor
	label = new TQLabel( i18n( "Changed color:" ), tqcolorGroupBox );
	m_changedColorButton = new KColorButton( tqcolorGroupBox );
	label->setBuddy( m_changedColorButton );

	// add the addColor
	label = new TQLabel( i18n( "Added color:" ), tqcolorGroupBox );
	m_addedColorButton = new KColorButton( tqcolorGroupBox );
	label->setBuddy( m_addedColorButton );

	// add the appliedColor
	label = new TQLabel( i18n( "Applied color:" ), tqcolorGroupBox );
	m_appliedColorButton = new KColorButton( tqcolorGroupBox );
	label->setBuddy( m_appliedColorButton );

	// scroll number of lines (snol)
	snolGroupBox = new TQHGroupBox( i18n( "Mouse Wheel" ), page );
	tqlayout->addWidget( snolGroupBox );
	snolGroupBox->setMargin( KDialog::marginHint() );

	label            = new TQLabel( i18n( "Number of lines:" ), snolGroupBox );
	m_snolSpinBox    = new TQSpinBox( 0, 50, 1, snolGroupBox );
	label->setBuddy( m_snolSpinBox );

	// Temporarily here for testing...
	// number of spaces for a tab character stuff
	tabGroupBox = new TQHGroupBox( i18n( "Tabs to Spaces" ), page );
	tqlayout->addWidget( tabGroupBox );
	tabGroupBox->setMargin( KDialog::marginHint() );

	label = new TQLabel( i18n( "Number of spaces to convert a tab character to:" ), tabGroupBox );
	m_tabSpinBox = new TQSpinBox( 1, 16, 1, tabGroupBox );
	label->setBuddy( m_tabSpinBox );

	tqlayout->addStretch( 1 );
	page->setMinimumSize( sizeHintForWidget( page ) );

	addTab( page, i18n( "A&ppearance" ) );

	page   = new TQWidget( this );
	tqlayout = new TQVBoxLayout( page );
	tqlayout->setSpacing( KDialog::spacingHint() );
	tqlayout->setMargin( KDialog::marginHint() );

	TQHGroupBox* gb = new TQHGroupBox( i18n( "Text Font" ), page );
	tqlayout->addWidget( gb );
	gb->setMargin( KDialog::marginHint() );

	label = new TQLabel( i18n( "Font:" ), gb );
	m_fontCombo = new KFontCombo( gb, "fontcombo" );
	label->setBuddy( m_fontCombo );

	label = new TQLabel( i18n( "Size:" ), gb );
	m_fontSizeSpinBox = new TQSpinBox( 6, 24, 1, gb, "fontsize" );
	label->setBuddy( m_fontSizeSpinBox );

	tqlayout->addStretch( 1 );
	page->setMinimumSize( sizeHintForWidget( page ) );

	addTab( page, i18n( "&Fonts" ) );
}

ViewPage::~ViewPage()
{

}

void ViewPage::setSettings( ViewSettings* setts )
{
	m_settings = setts;

	m_addedColorButton->setColor  ( m_settings->m_addColor );
	m_changedColorButton->setColor( m_settings->m_changeColor );
	m_removedColorButton->setColor( m_settings->m_removeColor );
	m_appliedColorButton->setColor( m_settings->m_appliedColor );
	m_snolSpinBox->setValue       ( m_settings->m_scrollNoOfLines );
	m_tabSpinBox->setValue        ( m_settings->m_tabToNumberOfSpaces );

	m_fontCombo->setCurrentFont   ( m_settings->m_font.family() );
	m_fontSizeSpinBox->setValue   ( m_settings->m_font.pointSize() );
}

ViewSettings* ViewPage::settings( void )
{
	return m_settings;
}

void ViewPage::restore()
{
}

void ViewPage::apply()
{
	m_settings->m_addColor            = m_addedColorButton->color();
	m_settings->m_changeColor         = m_changedColorButton->color();
	m_settings->m_removeColor         = m_removedColorButton->color();
	m_settings->m_appliedColor        = m_appliedColorButton->color();
	m_settings->m_scrollNoOfLines     = m_snolSpinBox->value();
	m_settings->m_tabToNumberOfSpaces = m_tabSpinBox->value();

	m_settings->m_font                = TQFont( m_fontCombo->currentFont() );
	m_settings->m_font.setPointSize( m_fontSizeSpinBox->value() );

	m_settings->saveSettings( kapp->config() );
}

void ViewPage::setDefaults()
{
	m_addedColorButton->setColor  ( ViewSettings::default_addColor );
	m_changedColorButton->setColor( ViewSettings::default_changeColor );
	m_removedColorButton->setColor( ViewSettings::default_removeColor );
	m_appliedColorButton->setColor( ViewSettings::default_appliedColor );
	m_snolSpinBox->setValue       ( 3 );
        m_tabSpinBox->setValue        ( 4 );

	m_fontCombo->setCurrentFont   ( KGlobalSettings::fixedFont().family() );
        m_fontSizeSpinBox->setValue   ( 10 );
}

#include "viewpage.moc"