diff options
-rw-r--r-- | src/findbar.cpp | 34 | ||||
-rw-r--r-- | src/findbar.h | 12 | ||||
-rw-r--r-- | src/mainwindow.cpp | 26 | ||||
-rw-r--r-- | src/mainwindow.h | 1 |
4 files changed, 57 insertions, 16 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp index 514ec56f..1c98fc41 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -26,22 +26,22 @@ #include <KLineEdit> #include <KAction> #include <KIcon> -#include <KToolBar> -#include <KDialog> #include <KPushButton> +#include <klocalizedstring.h> // Qt Includes #include <QtGui> FindBar::FindBar(KXmlGuiWindow *mainwindow) - : QWidget() - , m_lineEdit(0) + : QWidget(mainwindow) + , m_lineEdit(new KLineEdit(this)) + , m_matchCase(new QCheckBox(i18n("&Match case"), this)) { QHBoxLayout *layout = new QHBoxLayout; // cosmetic - layout->setMargin(2); + layout->setContentsMargins(2, 0, 2, 0); // hide button QToolButton *hideButton = new QToolButton(this); @@ -52,24 +52,28 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); // label - QLabel *label = new QLabel("Find: "); + QLabel *label = new QLabel(i18n("Find: ")); layout->addWidget(label); // lineEdit, focusProxy - m_lineEdit = new KLineEdit(this); setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); connect(m_lineEdit, SIGNAL(textChanged(const QString &)), mainwindow, SLOT(slotFind(const QString &))); layout->addWidget(m_lineEdit); // buttons - KPushButton *findNext = new KPushButton(KIcon("go-down"), "&Next", this); - KPushButton *findPrev = new KPushButton(KIcon("go-up"), "&Previous", this); + KPushButton *findNext = new KPushButton(KIcon("go-down"), i18n("&Next"), this); + KPushButton *findPrev = new KPushButton(KIcon("go-up"), i18n("&Previous"), this); connect(findNext, SIGNAL(clicked()), mainwindow, SLOT(slotFindNext())); connect(findPrev, SIGNAL(clicked()), mainwindow, SLOT(slotFindPrevious())); layout->addWidget(findNext); layout->addWidget(findPrev); + // Case sensitivity. Deliberately set so this is off by default. + m_matchCase->setCheckState(Qt::Unchecked); + m_matchCase->setTristate(false); + layout->addWidget(m_matchCase); + // stretching widget on the left layout->addStretch(); @@ -82,16 +86,21 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) FindBar::~FindBar() { - delete m_lineEdit; } -KLineEdit *FindBar::lineEdit() +KLineEdit *FindBar::lineEdit() const { return m_lineEdit; } +bool FindBar::matchCase() const +{ + return m_matchCase->isChecked(); +} + + void FindBar::clear() { m_lineEdit->setText(QString()); @@ -100,10 +109,12 @@ void FindBar::clear() void FindBar::showFindBar() { + // show findbar if not visible if (!isVisible()) { show(); } + // set focus to findbar if user select showFindBar shortcut m_lineEdit->setFocus(); m_lineEdit->selectAll(); } @@ -123,3 +134,4 @@ void FindBar::keyPressEvent(QKeyEvent* event) } QWidget::keyPressEvent(event); } + diff --git a/src/findbar.h b/src/findbar.h index 66286cec..dd42c7d9 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -27,14 +27,20 @@ #include <KToolBar> #include <KXmlGuiWindow> -class FindBar : public QWidget // KateViewHelpers.h +// Qt Includes +#include <QtCore> +#include <QtGui> + + +class FindBar : public QWidget { Q_OBJECT public: FindBar(KXmlGuiWindow *mainwindow); ~FindBar(); - KLineEdit *lineEdit(); + KLineEdit *lineEdit() const; + bool matchCase() const; public slots: void clear(); @@ -48,6 +54,8 @@ signals: private: KLineEdit *m_lineEdit; + QCheckBox *m_matchCase; }; + #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c074d667..2d959034 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -566,7 +566,18 @@ void MainWindow::slotFindNext() { if (!currentTab() && m_lastSearch.isEmpty()) return; - if (!currentTab()->findText(m_lastSearch, QWebPage::FindWrapsAroundDocument)) + + QWebPage::FindFlags options; + if(m_findBar->matchCase()) + { + options = QWebPage::FindCaseSensitively | QWebPage::FindWrapsAroundDocument; + } + else + { + options = QWebPage::FindWrapsAroundDocument; + } + + if (!currentTab()->findText(m_lastSearch, options)) { slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } @@ -577,7 +588,18 @@ void MainWindow::slotFindPrevious() { if (!currentTab() && m_lastSearch.isEmpty()) return; - if (!currentTab()->findText(m_lastSearch, QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument)) + + QWebPage::FindFlags options; + if(m_findBar->matchCase()) + { + options = QWebPage::FindCaseSensitively | QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; + } + else + { + options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; + } + + if (!currentTab()->findText(m_lastSearch, options)) { slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 1c65c5d7..a9363d8a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -89,7 +89,6 @@ private slots: void slotOpenNext(); // File Menu slots -// void slotFileNew(); void slotFileOpen(); void slotFilePrintPreview(); void slotFilePrint(); |