summaryrefslogtreecommitdiffstats
path: root/kpager/config.cpp
blob: 12e6386886d6e4fe76ecde285faaa1b4266a523f (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
180
/**************************************************************************

    config.cpp  - KPager config dialog
    Copyright (C) 2000  Antonio Larrosa Jimenez

    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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

    Send comments and bug fixes to larrosa@kde.org

***************************************************************************/

#include <tqcheckbox.h>
#include <tqradiobutton.h>
#include <tqbuttongroup.h>
#include <tqwidget.h>
#include <tqvbox.h>
#include <tqhbox.h>
#include <tqlayout.h>

#include <kdialogbase.h>
#include <klocale.h>
#include <kconfig.h>
#include <kseparator.h>
#include <kapplication.h>
#include <kdebug.h>

#include "config.h"
#include "config.moc"
#include "desktop.h"
#include "kpager.h"


KPagerConfigDialog::KPagerConfigDialog (TQWidget *parent)
 : KDialogBase ( parent, "configdialog", true, i18n("Configuration"), Ok|Cancel, Ok, true )
{
    TQVBox *box = new TQVBox( this );
    m_chkWindowDragging=new TQCheckBox(i18n("Enable window dragging"),box,0);
    (void ) new KSeparator( box );
    connect(m_chkWindowDragging, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(enableWindowDragging(bool)));

    TQHBox *page = new TQHBox( box );
    TQVBox *lpage = new TQVBox( page );
    setMainWidget(box);

    m_chkShowName=new TQCheckBox(i18n("Show name"),lpage,0);
    connect(m_chkShowName, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowName(bool)));
    m_chkShowNumber=new TQCheckBox(i18n("Show number"),lpage,0);
    connect(m_chkShowNumber, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowNumber(bool)));
    m_chkShowBackground=new TQCheckBox(i18n("Show background"),lpage,0);
    connect(m_chkShowBackground, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowBackground(bool)));
    m_chkShowWindows=new TQCheckBox(i18n("Show windows"),lpage,0);
    connect(m_chkShowWindows, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowWindows(bool)));

    m_grpWindowDrawMode=new TQButtonGroup(i18n("Type of Window"),page);
    m_grpWindowDrawMode->setExclusive(true);
    TQVBoxLayout *vbox = new TQVBoxLayout(m_grpWindowDrawMode, KDialog::marginHint(),
					KDialog::spacingHint());
    vbox->addSpacing(fontMetrics().lineSpacing());
    vbox->addWidget(new TQRadioButton(i18n("Plain"),m_grpWindowDrawMode));
    vbox->addWidget(new TQRadioButton(i18n("Icon"),m_grpWindowDrawMode));

    TQRadioButton *rbpix = new TQRadioButton(i18n("Pixmap"),m_grpWindowDrawMode);
//    rbpix->setEnabled(false);
    vbox->addWidget(rbpix);

    connect(m_grpWindowDrawMode, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(setWindowDrawMode(int)));

    m_grpLayoutType=new TQButtonGroup(i18n("Layout"),page);
    m_grpLayoutType->setExclusive(true);
    vbox = new TQVBoxLayout(m_grpLayoutType, KDialog::marginHint(), KDialog::spacingHint());
    vbox->addSpacing(fontMetrics().lineSpacing());
    vbox->addWidget(new TQRadioButton(i18n("Classical"),m_grpLayoutType));
    vbox->addWidget(new TQRadioButton(i18n("Horizontal"),m_grpLayoutType));
    vbox->addWidget(new TQRadioButton(i18n("Vertical"),m_grpLayoutType));

    connect(m_grpLayoutType, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(setLayout(int)));
    connect(this,TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotOk()));
    loadConfiguration();
    setMinimumSize(360, 160);
}

void KPagerConfigDialog::setShowName(bool show)
{
    m_tmpShowName=show;
}

void KPagerConfigDialog::setShowNumber(bool show)
{
    m_tmpShowNumber=show;
}

void KPagerConfigDialog::setShowBackground(bool show)
{
    m_tmpShowBackground=show;
}

void KPagerConfigDialog::setShowWindows(bool show)
{
    m_tmpShowWindows=show;
}

void KPagerConfigDialog::enableWindowDragging(bool enable)
{
    m_tmpWindowDragging = enable;
}

void KPagerConfigDialog::setWindowDrawMode(int type)
{
    m_tmpWindowDrawMode=type;
}

void KPagerConfigDialog::setLayout(int tqlayout)
{
    m_tmpLayoutType=tqlayout;
}

void KPagerConfigDialog::loadConfiguration()
{
    m_chkShowName->setChecked(m_showName);
    m_chkShowNumber->setChecked(m_showNumber);
    m_chkShowBackground->setChecked(m_showBackground);
    m_chkShowWindows->setChecked(m_showWindows);
    m_grpWindowDrawMode->setButton(m_windowDrawMode);
    m_grpLayoutType->setButton(m_tqlayoutType);
    m_chkWindowDragging->setChecked( m_windowDragging );
    m_tmpShowName=m_showName;
    m_tmpShowNumber=m_showNumber;
    m_tmpShowBackground=m_showBackground;
    m_tmpShowWindows=m_showWindows;
    m_tmpWindowDrawMode=m_windowDrawMode;
    m_tmpLayoutType=m_tqlayoutType;
    m_tmpWindowDragging=m_windowDragging;
}

void KPagerConfigDialog::initConfiguration(void)
{
  KConfig *cfg= kapp->config();
  cfg->setGroup("KPager");

  m_windowDrawMode=cfg->readNumEntry("windowDrawMode", Desktop::c_defWindowDrawMode);
  m_showName=cfg->readBoolEntry("showName", Desktop::c_defShowName);
  m_showNumber=cfg->readBoolEntry("showNumber", Desktop::c_defShowNumber);
  m_showBackground=cfg->readBoolEntry("showBackground", Desktop::c_defShowBackground);
  m_showWindows=cfg->readBoolEntry("showWindows", Desktop::c_defShowWindows);
  m_tqlayoutType=cfg->readNumEntry("tqlayoutType", KPager::c_defLayout);
  m_windowDragging=cfg->readBoolEntry("windowDragging", true );
}

void KPagerConfigDialog::slotOk()
{
  m_showName=m_tmpShowName;
  m_showNumber=m_tmpShowNumber;
  m_showBackground=m_tmpShowBackground;
  m_showWindows=m_tmpShowWindows;
  m_windowDrawMode=m_tmpWindowDrawMode;
  m_tqlayoutType=m_tmpLayoutType;
  m_windowDragging=m_tmpWindowDragging;  
  accept();
}

bool KPagerConfigDialog::m_showName=Desktop::c_defShowName;
bool KPagerConfigDialog::m_showNumber=Desktop::c_defShowNumber;
bool KPagerConfigDialog::m_showBackground=Desktop::c_defShowBackground;
bool KPagerConfigDialog::m_showWindows=Desktop::c_defShowWindows;
bool KPagerConfigDialog::m_windowDragging=Desktop::c_defWindowDragging;
int  KPagerConfigDialog::m_windowDrawMode=Desktop::c_defWindowDrawMode;
int  KPagerConfigDialog::m_tqlayoutType=KPager::c_defLayout;