Kstars

addlinkdialog.h
1 /*
2  SPDX-FileCopyrightText: 2001 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ui_addlinkdialog.h"
10 
11 #include <klineedit.h>
12 #include <KLocalizedString>
13 
14 #include <QDialog>
15 #include <QVBoxLayout>
16 
17 class QString;
18 
19 class AddLinkDialogUI : public QFrame, public Ui::AddLinkDialog
20 {
21  Q_OBJECT
22  public:
23  explicit AddLinkDialogUI(QWidget *parent = nullptr);
24 };
25 
26 /**
27  * @class AddLinkDialog
28  * AddLinkDialog is a simple dialog for adding a custom URL to a popup menu.
29  *
30  * @author Jason Harris
31  * @version 1.0
32  */
33 class AddLinkDialog : public QDialog
34 {
35  Q_OBJECT
36  public:
37  /** Constructor */
38  explicit AddLinkDialog(QWidget *parent = nullptr, const QString &oname = i18n("object"));
39 
40  /** Destructor */
41  ~AddLinkDialog() override = default;
42 
43  /** @return QString of the entered URL */
44  QString url() const { return ald->URLBox->text(); }
45 
46  /**
47  * @short Set the URL text
48  * @param s the new URL text
49  */
50  void setURL(const QString &s) { ald->URLBox->setText(s); }
51 
52  /** @return QString of the entered menu entry text */
53  QString desc() const { return ald->DescBox->text(); }
54 
55  /**
56  * @short Set the Description text
57  * @param s the new description text
58  */
59  void setDesc(const QString &s) { ald->DescBox->setText(s); }
60 
61  /** @return true if user declared the link is an image */
62  bool isImageLink() const { return ald->ImageRadio->isChecked(); }
63 
64  /**
65  * @short Set the link type
66  * @param b if true, link is an image link.
67  */
68  void setImageLink(bool b) { ald->ImageRadio->setChecked(b); }
69 
70  private slots:
71  /** Open the entered URL in the web browser */
72  void checkURL(void);
73 
74  /**
75  * We provide a default menu text string; this function changes the
76  * default string if the link type (image/webpage) is changed. Note
77  * that if the user has changed the menu text, this function does nothing.
78  * @param imageEnabled if true, show image string; otherwise show webpage string.
79  */
80  void changeDefaultDescription(bool imageEnabled);
81 
82  private:
83  QString ObjectName;
84  AddLinkDialogUI *ald;
85 };
Q_OBJECTQ_OBJECT
QString desc() const
Definition: addlinkdialog.h:53
void setURL(const QString &s)
Set the URL text.
Definition: addlinkdialog.h:50
~AddLinkDialog() override=default
Destructor.
bool isImageLink() const
Definition: addlinkdialog.h:62
QString i18n(const char *text, const TYPE &arg...)
void setDesc(const QString &s)
Set the Description text.
Definition: addlinkdialog.h:59
void setImageLink(bool b)
Set the link type.
Definition: addlinkdialog.h:68
AddLinkDialog(QWidget *parent=nullptr, const QString &oname=i18n("object"))
Constructor.
QObject * parent() const const
QString url() const
Definition: addlinkdialog.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:13:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.