kio Library API Documentation

skipdlg.cpp

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #include "kio/skipdlg.h"
00020 
00021 #include <stdio.h>
00022 #include <assert.h>
00023 
00024 #include <qmessagebox.h>
00025 #include <qwidget.h>
00026 #include <qlayout.h>
00027 #include <qlabel.h>
00028 
00029 #include <kapplication.h>
00030 #include <klocale.h>
00031 #include <kurl.h>
00032 #include <kwin.h>
00033 #include <kpushbutton.h>
00034 #include <kstdguiitem.h>
00035 
00036 using namespace KIO;
00037 
00038 SkipDlg::SkipDlg(QWidget *parent, bool _multi, const QString& _error_text, bool _modal ) :
00039   KDialog ( parent, "" , _modal )
00040 {
00041   // TODO : port to KDialogBase
00042   modal = _modal;
00043 
00044   // Set "StaysOnTop", because this dialog is typically used in kio_uiserver,
00045   // i.e. in a separate process.
00046 #ifndef Q_WS_QWS //FIXME(E): Implement for QT Embedded
00047   if (modal)
00048     KWin::setState( winId(), NET::StaysOnTop );
00049 #endif
00050 
00051   b0 = b1 = b2 = 0L;
00052 
00053   setCaption( i18n( "Information" ) );
00054 
00055   b0 = new KPushButton( KStdGuiItem::cancel(), this );
00056   connect(b0, SIGNAL(clicked()), this, SLOT(b0Pressed()));
00057 
00058   if ( _multi )
00059   {
00060     b1 = new QPushButton( i18n( "Skip" ), this );
00061     connect(b1, SIGNAL(clicked()), this, SLOT(b1Pressed()));
00062 
00063     b2 = new QPushButton( i18n( "Auto Skip" ), this );
00064     connect(b2, SIGNAL(clicked()), this, SLOT(b2Pressed()));
00065   }
00066 
00067   QVBoxLayout *vlayout = new QVBoxLayout( this, 10, 0 );
00068   // vlayout->addStrut( 360 );  makes dlg at least that wide
00069 
00070   QLabel * lb = new QLabel( _error_text, this );
00071   lb->setFixedHeight( lb->sizeHint().height() );
00072   lb->setMinimumWidth( lb->sizeHint().width() );
00073   vlayout->addWidget( lb );
00074 
00075   vlayout->addSpacing( 10 );
00076 
00077   QHBoxLayout* layout = new QHBoxLayout();
00078   vlayout->addLayout( layout );
00079   if ( b0 )
00080   {
00081     b0->setDefault( true );
00082     b0->setFixedSize( b0->sizeHint() );
00083     layout->addWidget( b0 );
00084     layout->addSpacing( 5 );
00085   }
00086   if ( b1 )
00087   {
00088     b1->setFixedSize( b1->sizeHint() );
00089     layout->addWidget( b1 );
00090     layout->addSpacing( 5 );
00091   }
00092   if ( b2 )
00093   {
00094     b2->setFixedSize( b2->sizeHint() );
00095     layout->addWidget( b2 );
00096     layout->addSpacing( 5 );
00097   }
00098 
00099   vlayout->addStretch( 10 );
00100   vlayout->activate();
00101   resize( sizeHint() );
00102 }
00103 
00104 SkipDlg::~SkipDlg()
00105 {
00106 }
00107 
00108 void SkipDlg::b0Pressed()
00109 {
00110   if ( modal )
00111     done( 0 );
00112   else
00113     emit result( this, 0 );
00114 }
00115 
00116 void SkipDlg::b1Pressed()
00117 {
00118   if ( modal )
00119     done( 1 );
00120   else
00121     emit result( this, 1 );
00122 }
00123 
00124 void SkipDlg::b2Pressed()
00125 {
00126   if ( modal )
00127     done( 2 );
00128   else
00129     emit result( this, 2 );
00130 }
00131 
00132 SkipDlg_Result KIO::open_SkipDlg( bool _multi, const QString& _error_text )
00133 {
00134   Q_ASSERT(kapp);
00135 
00136   SkipDlg dlg( 0L, _multi, _error_text, true );
00137   return (SkipDlg_Result) dlg.exec();
00138 }
00139 
00140 #include "skipdlg.moc"
KDE Logo
This file is part of the documentation for kio Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Nov 27 13:45:44 2004 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003