Messagelib

templatesinsertcommandpushbutton.cpp
1/*
2 * SPDX-FileCopyrightText: 2006 Dmitry Morozhnikov <dmiceman@mail.ru>
3 * SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
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
13using namespace TemplateParser;
14
15TemplatesInsertCommandPushButton::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(QLatin1StringView("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
35TemplatesInsertCommandPushButton::~TemplatesInsertCommandPushButton() = default;
36
37TemplatesCommandMenu::MenuTypes TemplatesInsertCommandPushButton::type() const
38{
39 return mMenuCommand->type();
40}
41
42void TemplatesInsertCommandPushButton::setType(TemplatesCommandMenu::MenuTypes type)
43{
44 mMenuCommand->setType(type);
45 setMenu(mMenuCommand->menu());
46}
47
48#include "moc_templatesinsertcommandpushbutton.cpp"
The TemplatesCommandMenu class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void setMenu(QMenu *menu)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.