Kstars

addlinkdialog.h
1/*
2 SPDX-FileCopyrightText: 2001 Jason Harris <kstars@30doradus.org>
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
17class QString;
18
19class AddLinkDialogUI : public QFrame, public Ui::AddLinkDialog
20{
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 */
33class AddLinkDialog : public QDialog
34{
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};
AddLinkDialog is a simple dialog for adding a custom URL to a popup menu.
void setDesc(const QString &s)
Set the Description text.
~AddLinkDialog() override=default
Destructor.
QString desc() const
QString url() const
void setURL(const QString &s)
Set the URL text.
bool isImageLink() const
void setImageLink(bool b)
Set the link type.
AddLinkDialog(QWidget *parent=nullptr, const QString &oname=i18n("object"))
Constructor.
QString i18n(const char *text, const TYPE &arg...)
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.