• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • dialogs
addlinkdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  addlinkdialog.cpp - K Desktop Planetarium
3  -------------------
4  begin : Sun Oct 21 2001
5  copyright : (C) 2001 by Jason Harris
6  email : kstars@30doradus.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "addlinkdialog.h"
19 
20 #include <kurl.h>
21 #include <kmessagebox.h>
22 #include <kpushbutton.h>
23 #include <ktoolinvocation.h>
24 
25 #include "skyobjects/skyobject.h"
26 
27 AddLinkDialogUI::AddLinkDialogUI( QWidget *parent ) : QFrame( parent ) {
28  setupUi(this);
29 }
30 
31 AddLinkDialog::AddLinkDialog( QWidget *parent, const QString &oname )
32  : KDialog( parent ), ObjectName( oname )
33 {
34  ald = new AddLinkDialogUI(this);
35  setMainWidget( ald );
36  setCaption( i18n( "Add Custom URL to %1", oname ) );
37  setButtons( KDialog::Ok|KDialog::Cancel );
38 
39  //connect signals to slots
40  connect( ald->URLButton, SIGNAL( clicked() ), this, SLOT( checkURL() ) );
41  connect( ald->TypeBox, SIGNAL( clicked( int ) ), this, SLOT( changeDefaultDescription( int ) ) );
42 
43  ald->ImageRadio->setChecked(true);
44  ald->DescBox->setText( i18n( "Show image of " ) + ObjectName );
45 }
46 
47 void AddLinkDialog::checkURL( void ) {
48  KUrl _url ( url() );
49  if ( _url.isValid() ) { //Is the string a valid URL?
50  KToolInvocation::invokeBrowser( _url.url() ); //If so, launch the browser to see if it's the correct document
51  } else { //If not, print a warning message box that offers to open the browser to a search engine.
52  QString message = i18n( "The URL is not valid. Would you like to open a browser window\nto the Google search engine?" );
53  QString caption = i18n( "Invalid URL" );
54  if ( KMessageBox::warningYesNo( 0, message, caption, KGuiItem(i18n("Browse Google")), KGuiItem(i18n("Do Not Browse")) )==KMessageBox::Yes ) {
55  KToolInvocation::invokeBrowser( "http://www.google.com" );
56  }
57  }
58 }
59 
60 void AddLinkDialog::changeDefaultDescription( int id ) {
61  //If the user hasn't changed the default desc text, but the link type (image/webpage)
62  //has been toggled, update the default desc text
63  if ( id==1 && desc().startsWith( i18n( "Show image of " ) ) ) {
64  ald->DescBox->setText( i18n( "Show webpage about " ) + ObjectName );
65  }
66 
67  if ( id==0 && desc().startsWith( i18n( "Show webpage about " ) ) ) {
68  ald->DescBox->setText( i18n( "Show image of " ) + ObjectName );
69  }
70 }
71 
72 #include "addlinkdialog.moc"
skyobject.h
AddLinkDialogUI::AddLinkDialogUI
AddLinkDialogUI(QWidget *parent=0)
Definition: addlinkdialog.cpp:27
QWidget
KDialog
AddLinkDialog::AddLinkDialog
AddLinkDialog(QWidget *parent=0, const QString &oname=i18n("object"))
Constructor.
Definition: addlinkdialog.cpp:31
addlinkdialog.h
AddLinkDialogUI
Definition: addlinkdialog.h:30
QFrame
AddLinkDialog::url
QString url() const
Definition: addlinkdialog.h:57
AddLinkDialog::desc
QString desc() const
Definition: addlinkdialog.h:68
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal