File indexing completed on 2025-02-16 04:47:58
0001 /* 0002 This file is part of KOrganizer. 0003 0004 SPDX-FileCopyrightText: 2008 Thomas Thrainer <tom_t@gmx.at> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0007 */ 0008 0009 #include "todoviewquickaddline.h" 0010 0011 #include <KLocalizedString> 0012 0013 #include <QKeyEvent> 0014 0015 TodoViewQuickAddLine::TodoViewQuickAddLine(QWidget *parent) 0016 : KLineEdit(parent) 0017 , mClickMessage(i18n("Enter a summary to create a new to-do")) 0018 { 0019 connect(this, &QLineEdit::returnPressed, this, &TodoViewQuickAddLine::returnPressedSlot); 0020 0021 setToolTip(mClickMessage); 0022 } 0023 0024 void TodoViewQuickAddLine::keyPressEvent(QKeyEvent *event) 0025 { 0026 if (event->key() == Qt::Key_Return) { 0027 mModifiers = event->modifiers(); 0028 } 0029 0030 KLineEdit::keyPressEvent(event); 0031 } 0032 0033 void TodoViewQuickAddLine::returnPressedSlot() 0034 { 0035 // Workaround bug #217592 (disappearing cursor) 0036 unsetCursor(); 0037 0038 Q_EMIT returnPressed(mModifiers); 0039 } 0040 0041 void TodoViewQuickAddLine::resizeEvent(QResizeEvent *event) 0042 { 0043 KLineEdit::resizeEvent(event); 0044 0045 setPlaceholderText(fontMetrics().elidedText(mClickMessage, Qt::ElideRight, width() - clearButtonUsedSize().width())); 0046 } 0047 0048 #include "moc_todoviewquickaddline.cpp"