00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 00004 * Copyright (C) 2010 Keith Rusler <xzekecomax@gmail.com> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include "openprojectdialogpage.h" 00022 00023 #include <QtGui/QWidget> 00024 #include <QtGui/QVBoxLayout> 00025 00026 #include <KDE/KFile> 00027 #include <KDE/KFileWidget> 00028 #include <KDE/KIcon> 00029 #include <KDE/KLocale> 00030 00031 #include <core/debughelper.h> 00032 00033 using namespace GluonCreator; 00034 00035 class OpenProjectDialogPage::OpenProjectDialogPagePrivate 00036 { 00037 public: 00038 explicit OpenProjectDialogPagePrivate( OpenProjectDialogPage* qq ) 00039 : fileWidget( 0 ), 00040 q( qq ) 00041 { 00042 } 00043 00044 void projectSelected( const KUrl& url ) 00045 { 00046 fileWidget->accept(); 00047 emit q->projectRequested( url.url().remove( "file://" ) ); 00048 } 00049 public: 00050 KFileWidget* fileWidget; 00051 private: 00052 OpenProjectDialogPage* q; 00053 }; 00054 00055 OpenProjectDialogPage::OpenProjectDialogPage() 00056 : KPageWidgetItem( new QWidget(), i18n( "Open Project" ) ), 00057 d( new OpenProjectDialogPagePrivate( this ) ) 00058 { 00059 setIcon( KIcon( "document-open" ) ); 00060 00061 d->fileWidget = new KFileWidget( KUrl( "kfiledialog:///OpenDialog" ), widget() ); 00062 connect( d->fileWidget, SIGNAL( fileHighlighted( KUrl ) ), 00063 SLOT( projectSelected( KUrl ) ) ); 00064 00065 d->fileWidget->setOperationMode( KFileWidget::Opening ); 00066 d->fileWidget->setFilter( "*.gluon|Gluon Project Files" ); 00067 d->fileWidget->setMode( KFile::File | KFile::ExistingOnly ); 00068 d->fileWidget->setLocationLabel( i18n( "Project" ) ); 00069 00070 QVBoxLayout* layout = new QVBoxLayout; 00071 widget()->setLayout( layout ); 00072 layout->addWidget( d->fileWidget ); 00073 } 00074 00075 OpenProjectDialogPage::~OpenProjectDialogPage() 00076 { 00077 delete d; 00078 } 00079 00080 #include "creator/dialogs/openprojectdialogpage.moc"