1 /* Copyright (C) 2003-2006 Jesper K Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "WelcomeDialog.h"
21 #include "FeatureDialog.h"
23 #include <QHBoxLayout>
24 #include <QVBoxLayout>
26 #include <qpushbutton.h>
28 #include <kfiledialog.h>
29 #include <kstandarddirs.h>
30 #include "Utilities/Util.h"
31 #include <klineedit.h>
32 #include <kmessagebox.h>
34 #include <kapplication.h>
37 using namespace MainWindow
;
39 WelcomeDialog::WelcomeDialog( QWidget
* parent
)
43 QVBoxLayout
* lay1
= new QVBoxLayout( this );
44 QHBoxLayout
* lay2
= new QHBoxLayout
;
45 lay1
->addLayout( lay2
);
47 QLabel
* image
= new QLabel( this );
48 image
->setMinimumSize( QSize( 273, 204 ) );
49 image
->setMaximumSize( QSize( 273, 204 ) );
50 image
->setPixmap(Utilities::locateDataFile(QString::fromLatin1("pics/splash.png")));
51 lay2
->addWidget( image
);
53 QLabel
* textLabel2
= new QLabel( this );
54 lay2
->addWidget( textLabel2
);
55 textLabel2
->setText( i18n( "<h1>Welcome to KPhotoAlbum</h1>"
56 "<p>If you are interested in trying out KPhotoAlbum with a prebuilt set of images, "
57 "then simply choose the <b>Load Demo</b> "
58 "button. You may get to this demo at a later time from the <b>Help</b> menu.</p>"
59 "<p>Alternatively you may start making you own database of images, simply by pressing the "
60 "<b>Create my own database</b> button.") );
61 textLabel2
->setWordWrap( true );
63 QHBoxLayout
* lay3
= new QHBoxLayout
;
64 lay1
->addLayout( lay3
);
65 lay3
->addStretch( 1 );
67 QPushButton
* loadDemo
= new QPushButton( i18n("Load Demo") );
68 lay3
->addWidget( loadDemo
);
70 QPushButton
* createSetup
= new QPushButton( i18n("Create My Own Database..."), this );
71 lay3
->addWidget( createSetup
);
73 QPushButton
* checkFeatures
= new QPushButton( i18n("Check My Feature Set") );
74 lay3
->addWidget( checkFeatures
);
76 connect( loadDemo
, SIGNAL( clicked() ), this, SLOT( slotLoadDemo() ) );
77 connect( createSetup
, SIGNAL( clicked() ), this, SLOT( createSetup() ) );
78 connect( checkFeatures
, SIGNAL( clicked() ), this, SLOT( checkFeatures() ) );
82 void WelcomeDialog::slotLoadDemo()
84 _configFile
= Utilities::setupDemo();
88 void WelcomeDialog::createSetup()
90 FileDialog
dialog( this );
91 _configFile
= dialog
.getFileName();
92 if ( !_configFile
.isNull() )
96 QString
WelcomeDialog::configFileName() const
101 FileDialog::FileDialog( QWidget
* parent
) :KDialog( parent
)
103 setButtons( Cancel
| Ok
);
105 QWidget
* top
= new QWidget
;
106 QVBoxLayout
* lay1
= new QVBoxLayout( top
);
107 setMainWidget( top
);
109 QLabel
* label
= new QLabel( i18n("<p>KPhotoAlbum requires that all your images and videos are stored with a common root directory. "
110 "You are allowed to store your images in a directory tree under this directory. "
111 "KPhotoAlbum will not modify or edit any of your images, so you can simply point KPhotoAlbum to the "
112 "directory where you already have all your images located.</p>" ), top
);
113 label
->setWordWrap( true );
114 lay1
->addWidget( label
);
116 QHBoxLayout
* lay2
= new QHBoxLayout
;
117 lay1
->addLayout( lay2
);
118 label
= new QLabel( i18n("Image/Video root directory: "), top
);
119 lay2
->addWidget( label
);
121 _lineEdit
= new KLineEdit( top
);
122 _lineEdit
->setText( QString::fromLatin1( "~/Images" ) );
123 lay2
->addWidget( _lineEdit
);
125 QPushButton
* button
= new QPushButton( QString::fromLatin1("..."), top
);
126 button
->setMaximumWidth( 30 );
127 lay2
->addWidget( button
);
128 connect( button
, SIGNAL( clicked() ), this, SLOT( slotBrowseForDirecory() ) );
131 void FileDialog::slotBrowseForDirecory()
133 QString dir
= KFileDialog::getExistingDirectory( _lineEdit
->text(), this );
134 if ( ! dir
.isNull() )
135 _lineEdit
->setText( dir
);
138 QString
FileDialog::getFileName()
143 if ( exec() == Rejected
)
146 dir
= KShell::tildeExpand( _lineEdit
->text() );
147 if ( !QFileInfo( dir
).exists() ) {
148 int create
= KMessageBox::questionYesNo( this, i18n("Directory does not exist, create it?") );
149 if ( create
== KMessageBox::Yes
) {
150 bool ok2
= QDir().mkdir( dir
);
152 KMessageBox::sorry( this, i18n("Could not create directory %1",dir
) );
158 else if ( !QFileInfo( dir
).isDir() ) {
159 KMessageBox::sorry( this, i18n("%1 exists, but is not a directory",dir
) );
165 QString file
= dir
+ QString::fromLatin1("/index.xml");
166 KConfigGroup group
= KGlobal::config()->group(QString());
167 group
.writeEntry( QString::fromLatin1("configfile"), file
);
174 void MainWindow::WelcomeDialog::checkFeatures()
176 if ( !FeatureDialog::hasAllFeaturesAvailable() ) {
178 i18n("<p>KPhotoAlbum does not seem to be build with support for all its features. The following is a list "
179 "indicating to you what you may miss:<ul>%1</ul></p>"
180 "<p>For details on how to solve this problem, please choose <b>Help</b>|<b>KPhotoAlbum Feature Status</b> "
181 "from the menus.</p>", FeatureDialog::featureString() );
182 KMessageBox::information( this, msg
, i18n("Feature Check") );
185 KMessageBox::information( this, i18n("Congratulations: all dynamic features have been enabled."),
186 i18n("Feature Check" ) );
190 #include "WelcomeDialog.moc"