File indexing completed on 2024-04-21 09:42:46

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2007 Dominik Seichter <domseichter@web.de>
0003 
0004 #ifndef SELECTIONSAFELINEEDIT_H
0005 #define SELECTIONSAFELINEEDIT_H
0006 
0007 #include <QLineEdit>
0008 
0009 /** A QLineEdit that does not loose its selection
0010  *  on focusout events
0011  */
0012 class SelectionSafeLineEdit : public QLineEdit
0013 {
0014 public:
0015     /** Create a SeletionSafeLineEdit that keeps its selection
0016      *  even when the widget does not have the current keyboard focus.
0017      *
0018      *  @param parent parent widget
0019      */
0020     explicit SelectionSafeLineEdit(QWidget *parent = nullptr)
0021         : QLineEdit(parent)
0022     {
0023 
0024     }
0025 
0026 protected:
0027     void focusOutEvent(QFocusEvent *) override
0028     {
0029         // ignore
0030     }
0031 
0032 };
0033 
0034 #endif // SELECTIONSAFELINEEDIT_H