File: rpreferencesdialog.cpp

package info (click to toggle)
qcad 1.3.3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,504 kB
  • ctags: 2,449
  • sloc: cpp: 29,400; makefile: 49; sh: 15
file content (195 lines) | stat: -rw-r--r-- 4,999 bytes parent folder | download
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/***************************************************************************
                          rpreferencesdialog.cpp  -  description
                             -------------------
    begin                : Tue Nov 23 1999
    copyright            : (C) 1999 by Andrew Mustun
    email                : andrew@qcad.org
 ***************************************************************************/

#include "rpreferencesdialog.h"

#include <qlayout.h>
#include <qmessagebox.h>

#include "rappwin.h"
#include "rcombobox.h"
#include "rconfig.h"
#include "rlabel.h"
#include "rlineedit.h"
#include "rprgdef.h"
#include "rstatuspanel.h"


/*! \class RPreferencesDialog
    \author Andrew Mustun
    \brief Provides the preferences dialog called from "Options" -> "Preferences" menu.
*/

/*! Constructor
*/
RPreferencesDialog::RPreferencesDialog(QWidget * parent, const char * name, bool modal, WFlags f)
  : QTabDialog(parent,name,modal,f)
{
  setFixedSize(350, 194);

  setCaption( DEF_APPNAME );

  QGridLayout *gl;

  // Language Tab:
  //
  QWidget *wLanguage = new QWidget( this, "wLanguage" );
  gl = new QGridLayout( wLanguage, 5, 2, 1 );
  gl->setRowStretch(0, 3);
  gl->setRowStretch(1, 6);
  gl->setRowStretch(2, 6);
  gl->setRowStretch(3, 6);
  gl->setRowStretch(4, 3);

    // Language:
    //
    RLabel *lLanguage = new RLabel( RMES(484), wLanguage );
    gl->addWidget( lLanguage, 1, 0, AlignRight );
    cbLanguage = new RComboBox( wLanguage, "cbLanguage" );
    for(int i=0; i<RCONFIG->getLanguageNum(); ++i) {
      cbLanguage->insertItem( RCONFIG->getLanguage(i) );
    }
    cbLanguage->setEditText( RCONFIG->getLanguageName( RCONFIG->getSetting("Language:Language") ) );
    gl->addWidget( cbLanguage, 1, 1, AlignLeft );

  addTab( wLanguage, RMES(483) );


  // Layout:
  //
  QWidget *wLayout = new QWidget( this, "wLayout" );
  gl = new QGridLayout( wLayout, 5, 2, 1 );
  gl->setRowStretch(0, 3);
  gl->setRowStretch(1, 6);
  gl->setRowStretch(2, 6);
  gl->setRowStretch(3, 6);
  gl->setRowStretch(4, 3);

    // Font size for GUI elements:
    //
    RLabel *lFontSize0 = new RLabel( RMES(485), wLayout );
    gl->addWidget( lFontSize0, 1, 0, AlignRight );

    cbFontSize0 = new RComboBox( true, wLayout, "cbLayout" );
    cbFontSize0->insertItem( "8" );
    cbFontSize0->insertItem( "10" );
    cbFontSize0->insertItem( "12" );
    cbFontSize0->setEditText( RCONFIG->getSetting("Application:FontSize0") );
    gl->addWidget( cbFontSize0, 1, 1, AlignLeft );

    // Font size for Grid width:
    //
    RLabel *lFontSize1 = new RLabel( RMES(486), wLayout );
    gl->addWidget( lFontSize1, 2, 0, AlignRight );

    cbFontSize1 = new RComboBox( true, wLayout, "cbLayout" );
    cbFontSize1->insertItem( "8" );
    cbFontSize1->insertItem( "10" );
    cbFontSize1->insertItem( "12" );
    cbFontSize1->setEditText( RCONFIG->getSetting("Application:FontSize1") );
    gl->addWidget( cbFontSize1, 2, 1, AlignLeft );

    // Font size for Status panel:
    //
    RLabel *lFontSize2 = new RLabel( RMES(487), wLayout );
    gl->addWidget( lFontSize2, 3, 0, AlignRight );

    cbFontSize2 = new RComboBox( true, wLayout, "cbLayout" );
    cbFontSize2->insertItem( "8" );
    cbFontSize2->insertItem( "10" );
    cbFontSize2->insertItem( "12" );
    cbFontSize2->setEditText( RCONFIG->getSetting("Application:FontSize2") );
    gl->addWidget( cbFontSize2, 3, 1, AlignLeft );

  addTab( wLayout, RMES(488) );


  // Paths Tab:
  //
  QWidget *wPaths = new QWidget( this, "wPaths" );
  gl = new QGridLayout( wPaths, 5, 2, 1 );
  gl->setRowStretch(0, 3);
  gl->setRowStretch(1, 6);
  gl->setRowStretch(2, 6);
  gl->setRowStretch(3, 6);
  gl->setRowStretch(4, 3);

    // Browser Path:
    //
    RLabel *lBrowser = new RLabel( RMES(489), wPaths );
    gl->addWidget( lBrowser, 1, 0, AlignRight );
    eBrowserPath = new RLineEdit( wPaths, "eBrowserPath" );

    eBrowserPath->setText( RCONFIG->getSetting( "Paths:BrowserPath") );
    gl->addWidget( eBrowserPath, 1, 1, AlignLeft );

  addTab( wPaths, RMES(490) );

  setOkButton( RMES(46) );
  setCancelButton( RMES(47) );
}


/*! Destructor
*/
RPreferencesDialog::~RPreferencesDialog()
{
}



/*! Slot accept.
*/
void
RPreferencesDialog::accept()
{
  // Language:
  //
  RCONFIG->addSetting( "Language:Language",
                       RCONFIG->getLanguageSign(cbLanguage->currentText()) );

  // Layout:
  //
  RCONFIG->addSetting( "Application:FontSize0",
                       cbFontSize0->currentText() );
  RCONFIG->addSetting( "Application:FontSize1",
                       cbFontSize1->currentText() );
  RCONFIG->addSetting( "Application:FontSize2",
                       cbFontSize2->currentText() );

  // Paths:
  //
  RCONFIG->addSetting( "Paths:BrowserPath",
                       eBrowserPath->text() );

  // Please restart...:
  //
  QMessageBox::information( this, DEF_APPNAME, RMES(491), RMES(46) );

  RAppWin::getRAppWin()->getStatusPanel()->reinit();

  QTabDialog::accept();
}



// EOF