source: trunk/tools/assistant/settingsdialogimpl.cpp@ 203

Last change on this file since 203 was 191, checked in by rudi, 14 years ago

Qt Assistant added

File size: 3.2 KB
Line 
1/**********************************************************************
2** Copyright (C) 2000-2007 Trolltech ASA. All rights reserved.
3**
4** This file is part of Qt Assistant.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#include "settingsdialogimpl.h"
28#include "docuparser.h"
29#include "config.h"
30
31#include <qapplication.h>
32#include <qpushbutton.h>
33#include <qcheckbox.h>
34#include <qcolordialog.h>
35#include <qdir.h>
36#include <qfiledialog.h>
37#include <qfileinfo.h>
38#include <qlineedit.h>
39#include <qlistbox.h>
40#include <qlistview.h>
41#include <qmessagebox.h>
42#include <qptrstack.h>
43#include <qsettings.h>
44#include <qtimer.h>
45#include <qtoolbutton.h>
46#include <qtabwidget.h>
47#include <qmap.h>
48
49
50SettingsDialog::SettingsDialog( QWidget *parent, const char* name )
51 : SettingsDialogBase( parent, name )
52{
53 init();
54}
55
56void SettingsDialog::init()
57{
58 Config *config = Config::configuration();
59
60 browserApp->setText( config->webBrowser() );
61 homePage->setText( config->homePage() );
62 pdfApp->setText( config->pdfReader() );
63}
64
65void SettingsDialog::selectColor()
66{
67 QColor c = QColorDialog::getColor( colorButton->paletteBackgroundColor(), this );
68 colorButton->setPaletteBackgroundColor( c );
69}
70
71void SettingsDialog::browseWebApp()
72{
73 setFile( browserApp, tr( "Qt Assistant - Set Web Browser" ) );
74}
75
76void SettingsDialog::browsePDFApplication()
77{
78 setFile( pdfApp, tr( "Qt Assistant - Set PDF Browser" ) );
79}
80
81void SettingsDialog::browseHomepage()
82{
83 setFile( homePage, tr( "Qt Assistant - Set Homepage" ) );
84}
85
86void SettingsDialog::setFile( QLineEdit *le, const QString &caption )
87{
88 QFileDialog *fd = new QFileDialog( this );
89 fd->setCaption( caption );
90 fd->setMode( QFileDialog::AnyFile );
91 fd->setDir( QDir::homeDirPath() );
92
93 if ( fd->exec() == QDialog::Accepted ) {
94 if ( !fd->selectedFile().isEmpty() )
95 le->setText( fd->selectedFile() );
96 }
97}
98
99void SettingsDialog::accept()
100{
101 Config *config = Config::configuration();
102
103 config->setWebBrowser( browserApp->text() );
104 config->setHomePage( homePage->text() );
105 config->setPdfReader( pdfApp->text() );
106
107 hide();
108 done( Accepted );
109}
110
111void SettingsDialog::reject()
112{
113 init();
114 done( Rejected );
115}
Note: See TracBrowser for help on using the repository browser.