Messagelib

templatesinsertcommandpushbutton.cpp
1 /*
2  * SPDX-FileCopyrightText: 2006 Dmitry Morozhnikov <[email protected]>
3  * SPDX-FileCopyrightText: 2018-2023 Laurent Montel <[email protected]>
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  */
7 
8 #include "templatesinsertcommandpushbutton.h"
9 
10 #include "templateparser_debug.h"
11 #include <KLocalizedString>
12 
13 using namespace TemplateParser;
14 
15 TemplatesInsertCommandPushButton::TemplatesInsertCommandPushButton(QWidget *parent, const QString &name)
16  : QPushButton(parent)
17  , mMenuCommand(new TemplatesCommandMenu(this))
18 {
19  setObjectName(name);
20  setText(i18n("&Insert Command"));
21 
22  mMenuCommand->setObjectName(QStringLiteral("templatescommandmenu"));
23  mMenuCommand->fillMenu();
24  mMenuCommand->fillSubMenus();
25  setMenu(mMenuCommand->menu());
26  connect(mMenuCommand, qOverload<const QString &, int>(&TemplatesCommandMenu::insertCommand), this, &TemplatesInsertCommandPushButton::insertCommand);
27 
28  setToolTip(i18nc("@info:tooltip", "Select a command to insert into the template"));
29  setWhatsThis(i18nc("@info:whatsthis",
30  "Traverse this menu to find a command to insert into the current template "
31  "being edited. The command will be inserted at the cursor location, "
32  "so you want to move your cursor to the desired insertion point first."));
33 }
34 
35 TemplatesInsertCommandPushButton::~TemplatesInsertCommandPushButton() = default;
36 
37 TemplatesCommandMenu::MenuTypes TemplatesInsertCommandPushButton::type() const
38 {
39  return mMenuCommand->type();
40 }
41 
42 void TemplatesInsertCommandPushButton::setType(TemplatesCommandMenu::MenuTypes type)
43 {
44  mMenuCommand->setType(type);
45  setMenu(mMenuCommand->menu());
46 }
void setMenu(QMenu *menu)
void setMenu(QMenu *menu)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString i18n(const char *text, const TYPE &arg...)
void setText(const QString &text)
void setWhatsThis(const QString &what)
void setToolTip(const QString &tip)
void setObjectName(const QString &name)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
The TemplatesCommandMenu class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:07:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.