Messagelib

templatesinsertcommandpushbutton.cpp
1 /*
2  * SPDX-FileCopyrightText: 2006 Dmitry Morozhnikov <[email protected]>
3  * SPDX-FileCopyrightText: 2018-2021 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 setText(const QString &text)
void setMenu(QMenu *menu)
void setToolTip(const QString &tip)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setObjectName(const QString &name)
The TemplatesCommandMenu class.
void setWhatsThis(const QString &what)
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Nov 30 2021 23:05:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.