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