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 <qpushbutton.h>
00026 #include <qwidget.h>
00027 #include <qlayout.h>
00028 #include <qlabel.h>
00029 
00030 #include <kapplication.h>
00031 #include <klocale.h>
00032 #include <kurl.h>
00033 #include <kwin.h>
00034 
00035 using namespace KIO;
00036 
00037 SkipDlg::SkipDlg(QWidget *parent, bool _multi, const QString& _error_text, bool _modal ) :
00038   KDialog ( parent, "" , _modal )
00039 {
00040   // TODO : port to KDialogBase
00041   modal = _modal;
00042 
00043   // Set "StaysOnTop", because this dialog is typically used in kio_uiserver,
00044   // i.e. in a separate process.
00045 #ifndef Q_WS_QWS //FIXME(E): Implement for QT Embedded
00046   if (modal)
00047     KWin::setState( winId(), NET::StaysOnTop );
00048 #endif
00049 
00050   b0 = b1 = b2 = 0L;
00051 
00052   setCaption( i18n( "Information" ) );
00053 
00054   b0 = new QPushButton( i18n( "Cancel" ), this );
00055   connect(b0, SIGNAL(clicked()), this, SLOT(b0Pressed()));
00056 
00057   b1 = new QPushButton( i18n( "Skip" ), this );
00058   connect(b1, SIGNAL(clicked()), this, SLOT(b1Pressed()));
00059 
00060   if ( _multi )
00061   {
00062     b2 = new QPushButton( i18n( "Auto Skip" ), this );
00063     connect(b2, SIGNAL(clicked()), this, SLOT(b2Pressed()));
00064   }
00065 
00066   QVBoxLayout *vlayout = new QVBoxLayout( this, 10, 0 );
00067   // vlayout->addStrut( 360 );  makes dlg at least that wide
00068 
00069   QLabel * lb = new QLabel( _error_text, this );
00070   lb->setFixedHeight( lb->sizeHint().height() );
00071   lb->setMinimumWidth( lb->sizeHint().width() );
00072   vlayout->addWidget( lb );
00073 
00074   vlayout->addSpacing( 10 );
00075 
00076   QHBoxLayout* layout = new QHBoxLayout();
00077   vlayout->addLayout( layout );
00078   if ( b0 )
00079   {
00080     b0->setDefault( true );
00081     b0->setFixedSize( b0->sizeHint() );
00082     layout->addWidget( b0 );
00083     layout->addSpacing( 5 );
00084   }
00085   if ( b1 )
00086   {
00087     b1->setFixedSize( b1->sizeHint() );
00088     layout->addWidget( b1 );
00089     layout->addSpacing( 5 );
00090   }
00091   if ( b2 )
00092   {
00093     b2->setFixedSize( b2->sizeHint() );
00094     layout->addWidget( b2 );
00095     layout->addSpacing( 5 );
00096   }
00097 
00098   vlayout->addStretch( 10 );
00099   vlayout->activate();
00100   resize( sizeHint() );
00101 }
00102 
00103 SkipDlg::~SkipDlg()
00104 {
00105 }
00106 
00107 void SkipDlg::b0Pressed()
00108 {
00109   if ( modal )
00110     done( 0 );
00111   else
00112     emit result( this, 0 );
00113 }
00114 
00115 void SkipDlg::b1Pressed()
00116 {
00117   if ( modal )
00118     done( 1 );
00119   else
00120     emit result( this, 1 );
00121 }
00122 
00123 void SkipDlg::b2Pressed()
00124 {
00125   if ( modal )
00126     done( 2 );
00127   else
00128     emit result( this, 2 );
00129 }
00130 
00131 SkipDlg_Result KIO::open_SkipDlg( bool _multi, const QString& _error_text )
00132 {
00133   Q_ASSERT(kapp);
00134 
00135   SkipDlg dlg( 0L, _multi, _error_text, true );
00136   return (SkipDlg_Result) dlg.exec();
00137 }
00138 
00139 #include "skipdlg.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:33 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001