1 /*
2  * Copyright (C) Pedram Pourang (aka Tsu Jan) 2014-2019 <tsujan2000@gmail.com>
3  *
4  * FeatherPad is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * FeatherPad is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  * @license GPL-3.0+ <https://spdx.org/licenses/GPL-3.0+.html>
18  */
19 
20 #include <QGridLayout>
21 #include "tabpage.h"
22 
23 namespace FeatherPad {
24 
TabPage(int bgColorValue,const QList<QKeySequence> & searchShortcuts,QWidget * parent)25 TabPage::TabPage (int bgColorValue,
26                   const QList<QKeySequence> &searchShortcuts,
27                   QWidget *parent)
28     : QWidget (parent)
29 {
30     textEdit_ = new TextEdit (this, bgColorValue);
31     searchBar_ = new SearchBar (this, searchShortcuts);
32 
33     QGridLayout *mainGrid = new QGridLayout;
34     mainGrid->setVerticalSpacing (4);
35     mainGrid->setContentsMargins (0, 0, 0, 0);
36     mainGrid->addWidget (textEdit_, 0, 0);
37     mainGrid->addWidget (searchBar_, 1, 0);
38     setLayout (mainGrid);
39 
40     connect (searchBar_, &SearchBar::find, this, &TabPage::find);
41     connect (searchBar_, &SearchBar::searchFlagChanged, this, &TabPage::searchFlagChanged);
42 }
43 /*************************/
setSearchBarVisible(bool visible)44 void TabPage::setSearchBarVisible (bool visible)
45 {
46     searchBar_->setVisible (visible);
47 }
48 /*************************/
isSearchBarVisible() const49 bool TabPage::isSearchBarVisible() const
50 {
51     return searchBar_->isVisible();
52 }
53 /*************************/
focusSearchBar()54 void TabPage::focusSearchBar()
55 {
56     searchBar_->focusLineEdit();
57 }
58 /*************************/
searchBarHasFocus() const59 bool TabPage::searchBarHasFocus() const
60 {
61     return searchBar_->lineEditHasFocus();
62 }
63 /*************************/
searchEntry() const64 QString TabPage::searchEntry() const
65 {
66     return searchBar_->searchEntry();
67 }
68 /*************************/
clearSearchEntry()69 void TabPage::clearSearchEntry()
70 {
71     return searchBar_->clearSearchEntry();
72 }
73 /*************************/
matchCase() const74 bool TabPage::matchCase() const
75 {
76     return searchBar_->matchCase();
77 }
78 /*************************/
matchWhole() const79 bool TabPage::matchWhole() const
80 {
81     return searchBar_->matchWhole();
82 }
83 /*************************/
matchRegex() const84 bool TabPage::matchRegex() const
85 {
86     return searchBar_->matchRegex();
87 }
88 /*************************/
hasPopup() const89 bool TabPage::hasPopup() const
90 {
91     return searchBar_->hasPopup();
92 }
93 /*************************/
updateShortcuts(bool disable)94 void TabPage::updateShortcuts (bool disable)
95 {
96     searchBar_->updateShortcuts (disable);
97 }
98 /*************************/
lockPage(bool lock)99 void TabPage::lockPage (bool lock)
100 {
101     searchBar_->setEnabled (!lock);
102     textEdit_->setEnabled (!lock);
103 }
104 
105 }
106