Eventviews

todoviewquickaddline.cpp
1/*
2 This file is part of KOrganizer.
3
4 SPDX-FileCopyrightText: 2008 Thomas Thrainer <tom_t@gmx.at>
5
6 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
7*/
8
9#include "todoviewquickaddline.h"
10
11#include <KLocalizedString>
12
13#include <QKeyEvent>
14
15TodoViewQuickAddLine::TodoViewQuickAddLine(QWidget *parent)
16 : KLineEdit(parent)
17 , mClickMessage(i18n("Enter a summary to create a new to-do"))
18{
19 connect(this, &QLineEdit::returnPressed, this, &TodoViewQuickAddLine::returnPressedSlot);
20
21 setToolTip(mClickMessage);
22}
23
24void TodoViewQuickAddLine::keyPressEvent(QKeyEvent *event)
25{
26 if (event->key() == Qt::Key_Return) {
27 mModifiers = event->modifiers();
28 }
29
31}
32
33void TodoViewQuickAddLine::returnPressedSlot()
34{
35 // Workaround bug #217592 (disappearing cursor)
37
38 Q_EMIT returnPressed(mModifiers);
39}
40
41void TodoViewQuickAddLine::resizeEvent(QResizeEvent *event)
42{
44
45 setPlaceholderText(fontMetrics().elidedText(mClickMessage, Qt::ElideRight, width() - clearButtonUsedSize().width()));
46}
47
48#include "moc_todoviewquickaddline.cpp"
bool event(QEvent *) override
QSize clearButtonUsedSize() const
void keyPressEvent(QKeyEvent *) override
void resizeEvent(QResizeEvent *) override
QString i18n(const char *text, const TYPE &arg...)
void setPlaceholderText(const QString &)
void returnPressed()
Q_EMITQ_EMIT
Key_Return
ElideRight
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void unsetCursor()
QFontMetrics fontMetrics() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.