kstars
addlinkdialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <kapplication.h>
00019 #include <kurl.h>
00020 #include <kmessagebox.h>
00021 #include <kpushbutton.h>
00022 #include <qbuttongroup.h>
00023 #include <qlayout.h>
00024
00025 #include "addlinkdialog.h"
00026 #include "skyobject.h"
00027
00028 AddLinkDialog::AddLinkDialog( QWidget *parent, const QString &oname )
00029 : KDialogBase( KDialogBase::Plain, i18n( "Add Custom URL to %1" ).arg( oname ), Ok|Cancel, Ok, parent ), ObjectName( oname ) {
00030
00031 QFrame *page = plainPage();
00032 setMainWidget(page);
00033
00034 vlay = new QVBoxLayout( page, 0, spacingHint() );
00035 ald = new AddLinkDialogUI(page);
00036
00037 vlay->addWidget( ald );
00038 vlay->activate();
00039
00040
00041 connect( ald->URLButton, SIGNAL( clicked() ), this, SLOT( checkURL() ) );
00042 connect( ald->TypeBox, SIGNAL( clicked( int ) ), this, SLOT( changeDefaultDescription( int ) ) );
00043
00044 ald->ImageRadio->setChecked(true);
00045 ald->DescBox->setText( i18n( "Show image of " ) + ObjectName );
00046 }
00047
00048 void AddLinkDialog::checkURL( void ) {
00049 KURL _url ( url() );
00050 if ( _url.isValid() ) {
00051 kapp->invokeBrowser( _url.url() );
00052 } else {
00053 QString message = i18n( "The URL is not valid. Would you like to open a browser window\nto the Google search engine?" );
00054 QString caption = i18n( "Invalid URL" );
00055 if ( KMessageBox::warningYesNo( 0, message, caption, i18n("Browse Google"), i18n("Do Not Browse") )==KMessageBox::Yes ) {
00056 kapp->invokeBrowser( "http://www.google.com" );
00057 }
00058 }
00059 }
00060
00061 void AddLinkDialog::changeDefaultDescription( int id ) {
00062
00063
00064 if ( id==1 && desc().startsWith( i18n( "Show image of " ) ) ) {
00065 ald->DescBox->setText( i18n( "Show webpage about " ) + ObjectName );
00066 }
00067
00068 if ( id==0 && desc().startsWith( i18n( "Show webpage about " ) ) ) {
00069 ald->DescBox->setText( i18n( "Show image of " ) + ObjectName );
00070 }
00071 }
00072
00073 #include "addlinkdialog.moc"