• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

addlinkdialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           addlinkdialog.cpp  -  K Desktop Planetarium
00003                              -------------------
00004     begin                : Sun Oct 21 2001
00005     copyright            : (C) 2001 by Jason Harris
00006     email                : kstars@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
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     //connect signals to slots
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() ) {   //Is the string a valid URL?
00051         kapp->invokeBrowser( _url.url() );   //If so, launch the browser to see if it's the correct document
00052     } else {   //If not, print a warning message box that offers to open the browser to a search engine.
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 //If the user hasn't changed the default desc text, but the link type (image/webpage)
00063 //has been toggled, update the default desc text
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"

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal