1 /* 2 * Copyright (C) 2010, 2013 Nicolas Bonnefon and other contributors 3 * 4 * This file is part of glogg. 5 * 6 * glogg is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * glogg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef QUICKFINDWIDGET_H 21 #define QUICKFINDWIDGET_H 22 23 #include <QWidget> 24 #include <QTimer> 25 26 class QHBoxLayout; 27 class QLineEdit; 28 class QToolButton; 29 class QLabel; 30 class QCheckBox; 31 class QFNotification; 32 33 enum QFDirection { 34 Forward, 35 Backward, 36 }; 37 38 class QuickFindWidget : public QWidget 39 { 40 Q_OBJECT 41 42 public: 43 QuickFindWidget( QWidget* parent = 0 ); 44 45 // Show the widget with the given direction 46 // when requested by the user (the widget won't timeout) 47 void userActivate(); 48 49 public slots: 50 // Instructs the widget to change the pattern displayed 51 void changeDisplayedPattern( const QString& newPattern ); 52 53 // Show the widget for a notification (will timeout) 54 void notify( const QFNotification& message ); 55 // Clear the notification 56 void clearNotification(); 57 58 private slots: 59 void doSearchForward(); 60 void doSearchBackward(); 61 void returnHandler(); 62 void closeHandler(); 63 void notificationTimeout(); 64 void textChanged(); 65 66 signals: 67 // Sent when Return is pressed to confirm the pattern 68 // (pattern and ignor_case flag) 69 void patternConfirmed( const QString&, bool ); 70 // Sent every time the pattern is modified 71 // (pattern and ignor_case flag) 72 void patternUpdated( const QString&, bool ); 73 void close(); 74 // Emitted when the user closes the window 75 void cancelSearch(); 76 void searchForward(); 77 void searchBackward(); 78 void searchNext(); 79 80 private: 81 const static int NOTIFICATION_TIMEOUT; 82 83 QHBoxLayout* layout_; 84 85 QToolButton* closeButton_; 86 QToolButton* nextButton_; 87 QToolButton* previousButton_; 88 QLineEdit* editQuickFind_; 89 QCheckBox* ignoreCaseCheck_; 90 QLabel* notificationText_; 91 92 QToolButton* setupToolButton(const QString &text, const QString &icon); 93 bool isIgnoreCase() const; 94 95 QTimer* notificationTimer_; 96 97 QFDirection direction_; 98 99 // Whether the user explicitely wants us on the screen 100 bool userRequested_; 101 }; 102 103 #endif 104