File indexing completed on 2024-04-28 11:31:05

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // The code in this file is largely based on KDE's KLineEdit class
0004 // as included in KDE 4.5. See there for its authors:
0005 // https://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/klineedit_8cpp.html
0006 //
0007 // SPDX-FileCopyrightText: 2010, 2012 Dennis Nienhüser <nienhueser@kde.org>
0008 //
0009 
0010 #ifndef MARBLE_MARBLELINEEDIT_H
0011 #define MARBLE_MARBLELINEEDIT_H
0012 
0013 #include "marble_export.h"
0014 
0015 #include <QLineEdit>
0016 
0017 namespace Marble
0018 {
0019 
0020 class MarbleLineEditPrivate;
0021 
0022 /**
0023   * A QLineEdit with an embedded clear button. The clear button removes any input
0024   * in the line edit when clicked with the left mouse button. It replaces the line
0025   * edit input with the current clipboard content on a middle mouse button click.
0026   */
0027 class MARBLE_EXPORT MarbleLineEdit : public QLineEdit
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     /** Constructor */
0033     explicit MarbleLineEdit( QWidget *parent = nullptr );
0034 
0035     /** Destructor */
0036     ~MarbleLineEdit() override;
0037 
0038     void setDecorator( const QPixmap &decorator );
0039 
0040     void setBusy( bool busy );
0041 
0042 Q_SIGNALS:
0043     /** The clear button was clicked with the left mouse button */
0044     void clearButtonClicked();
0045 
0046     void decoratorButtonClicked();
0047 
0048 protected:
0049     void mouseReleaseEvent( QMouseEvent* event ) override;
0050 
0051     void resizeEvent( QResizeEvent* event ) override;
0052 
0053 private Q_SLOTS:
0054     void updateClearButtonIcon( const QString& text );
0055 
0056     void updateClearButton();
0057 
0058     void updateProgress();
0059 
0060 private:
0061     MarbleLineEditPrivate* const d;
0062 };
0063 
0064 } // namespace Marble
0065 
0066 #endif // MARBLE_MARBLELINEEDIT_H