summaryrefslogtreecommitdiffstats
path: root/kpager/config.cpp
blob: 60aa85f2a50166ff7d102dff02376ca4fe7dee57 (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 <qcheckbox.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <qwidget.h>
#include <qvbox.h>
#include <qhbox.h>
#include <qlayout.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 (QWidget *parent)
 : KDialogBase ( parent, "configdialog", true, i18n("Configuration"), Ok|Cancel, Ok, true )
{
    QVBox *box = new QVBox( this );
    m_chkWindowDragging=new QCheckBox(i18n("Enable window dragging"),box,0);
    (void ) new KSeparator( box );
    connect(m_chkWindowDragging, SIGNAL(toggled(bool)), this, SLOT(enableWindowDragging(bool)));

    QHBox *page = new QHBox( box );
    QVBox *lpage = new QVBox( page );
    setMainWidget(box);

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

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

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

    connect(m_grpWindowDrawMode, SIGNAL(clicked(int)), this, SLOT(setWindowDrawMode(int)));

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

    connect(m_grpLayoutType, SIGNAL(clicked(int)), this, SLOT(setLayout(int)));
    connect(this,SIGNAL(okClicked()),this,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 layout)
{
    m_tmpLayoutType=layout;
}

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_layoutType);
    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_layoutType;
    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_layoutType=cfg->readNumEntry("layoutType", 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_layoutType=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_layoutType=KPager::c_defLayout;