• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • 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 "addlinkdialog.h"
00019 
00020 #include <kurl.h>
00021 #include <kmessagebox.h>
00022 #include <kpushbutton.h>
00023 #include <ktoolinvocation.h>
00024 
00025 #include "skyobject.h"
00026 
00027 AddLinkDialogUI::AddLinkDialogUI( QWidget *parent ) : QFrame( parent ) {
00028     setupUi(this);
00029 }
00030 
00031 AddLinkDialog::AddLinkDialog( QWidget *parent, const QString &oname )
00032         : KDialog( parent ),  ObjectName( oname )
00033 {
00034     ald = new AddLinkDialogUI(this);
00035     setMainWidget( ald );
00036     setCaption( i18n( "Add Custom URL to %1", oname ) );
00037     setButtons( KDialog::Ok|KDialog::Cancel );
00038 
00039     //connect signals to slots
00040     connect( ald->URLButton, SIGNAL( clicked() ), this, SLOT( checkURL() ) );
00041     connect( ald->TypeBox, SIGNAL( clicked( int ) ), this, SLOT( changeDefaultDescription( int ) ) );
00042 
00043     ald->ImageRadio->setChecked(true);
00044     ald->DescBox->setText( i18n( "Show image of " ) + ObjectName );
00045 }
00046 
00047 void AddLinkDialog::checkURL( void ) {
00048     KUrl _url ( url() );
00049     if ( _url.isValid() ) {   //Is the string a valid URL?
00050         KToolInvocation::invokeBrowser( _url.url() );   //If so, launch the browser to see if it's the correct document
00051     } else {   //If not, print a warning message box that offers to open the browser to a search engine.
00052         QString message = i18n( "The URL is not valid. Would you like to open a browser window\nto the Google search engine?" );
00053         QString caption = i18n( "Invalid URL" );
00054         if ( KMessageBox::warningYesNo( 0, message, caption, KGuiItem(i18n("Browse Google")), KGuiItem(i18n("Do Not Browse")) )==KMessageBox::Yes ) {
00055             KToolInvocation::invokeBrowser( "http://www.google.com" );
00056         }
00057     }
00058 }
00059 
00060 void AddLinkDialog::changeDefaultDescription( int id ) {
00061     //If the user hasn't changed the default desc text, but the link type (image/webpage)
00062     //has been toggled, update the default desc text
00063     if ( id==1 && desc().startsWith( i18n( "Show image of " ) ) ) {
00064         ald->DescBox->setText( i18n( "Show webpage about " ) + ObjectName );
00065     }
00066 
00067     if ( id==0 && desc().startsWith( i18n( "Show webpage about " ) ) ) {
00068         ald->DescBox->setText( i18n( "Show image of " ) + ObjectName );
00069     }
00070 }
00071 
00072 #include "addlinkdialog.moc"

kstars

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

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
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