NOISSUE implement basic search in Other Logs page
This commit is contained in:
		@@ -22,6 +22,7 @@
 | 
			
		||||
#include "RecursiveFileSystemWatcher.h"
 | 
			
		||||
#include <GZip.h>
 | 
			
		||||
#include <FileSystem.h>
 | 
			
		||||
#include <QShortcut>
 | 
			
		||||
 | 
			
		||||
OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget *parent)
 | 
			
		||||
	: QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), m_fileFilter(fileFilter),
 | 
			
		||||
@@ -35,6 +36,17 @@ OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget
 | 
			
		||||
 | 
			
		||||
	connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this, &OtherLogsPage::populateSelectLogBox);
 | 
			
		||||
	populateSelectLogBox();
 | 
			
		||||
 | 
			
		||||
	auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this);
 | 
			
		||||
	connect(findShortcut, &QShortcut::activated, this, &OtherLogsPage::findActivated);
 | 
			
		||||
 | 
			
		||||
	auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this);
 | 
			
		||||
	connect(findNextShortcut, &QShortcut::activated, this, &OtherLogsPage::findNextActivated);
 | 
			
		||||
 | 
			
		||||
	auto findPreviousShortcut = new QShortcut(QKeySequence(QKeySequence::FindPrevious), this);
 | 
			
		||||
	connect(findPreviousShortcut, &QShortcut::activated, this, &OtherLogsPage::findPreviousActivated);
 | 
			
		||||
 | 
			
		||||
	connect(ui->searchBar, &QLineEdit::returnPressed, this, &OtherLogsPage::on_findButton_clicked);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
OtherLogsPage::~OtherLogsPage()
 | 
			
		||||
@@ -253,3 +265,36 @@ void OtherLogsPage::setControlsEnabled(const bool enabled)
 | 
			
		||||
	ui->text->setEnabled(enabled);
 | 
			
		||||
	ui->btnClean->setEnabled(enabled);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FIXME: HACK, use LogView instead?
 | 
			
		||||
static void findNext(QPlainTextEdit * _this, const QString& what, bool reverse)
 | 
			
		||||
{
 | 
			
		||||
	_this->find(what, reverse ? QTextDocument::FindFlag::FindBackward : QTextDocument::FindFlag(0));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OtherLogsPage::on_findButton_clicked()
 | 
			
		||||
{
 | 
			
		||||
	auto modifiers = QApplication::keyboardModifiers();
 | 
			
		||||
	bool reverse = modifiers & Qt::ShiftModifier;
 | 
			
		||||
	findNext(ui->text, ui->searchBar->text(), reverse);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OtherLogsPage::findNextActivated()
 | 
			
		||||
{
 | 
			
		||||
	findNext(ui->text, ui->searchBar->text(), false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OtherLogsPage::findPreviousActivated()
 | 
			
		||||
{
 | 
			
		||||
	findNext(ui->text, ui->searchBar->text(), true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OtherLogsPage::findActivated()
 | 
			
		||||
{
 | 
			
		||||
	// focus the search bar if it doesn't have focus
 | 
			
		||||
	if (!ui->searchBar->hasFocus())
 | 
			
		||||
	{
 | 
			
		||||
		ui->searchBar->setFocus();
 | 
			
		||||
		ui->searchBar->selectAll();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -64,6 +64,11 @@ private slots:
 | 
			
		||||
	void on_btnDelete_clicked();
 | 
			
		||||
	void on_btnClean_clicked();
 | 
			
		||||
 | 
			
		||||
	void on_findButton_clicked();
 | 
			
		||||
	void findActivated();
 | 
			
		||||
	void findNextActivated();
 | 
			
		||||
	void findPreviousActivated();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	void setControlsEnabled(const bool enabled);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,8 +32,34 @@
 | 
			
		||||
      <attribute name="title">
 | 
			
		||||
       <string notr="true">Tab 1</string>
 | 
			
		||||
      </attribute>
 | 
			
		||||
      <layout class="QVBoxLayout" name="verticalLayout">
 | 
			
		||||
       <item>
 | 
			
		||||
      <layout class="QGridLayout" name="gridLayout_2">
 | 
			
		||||
       <item row="2" column="1">
 | 
			
		||||
        <widget class="QLineEdit" name="searchBar"/>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="2" column="2">
 | 
			
		||||
        <widget class="QPushButton" name="findButton">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Find</string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="1" column="0" colspan="4">
 | 
			
		||||
        <widget class="QPlainTextEdit" name="text">
 | 
			
		||||
         <property name="enabled">
 | 
			
		||||
          <bool>false</bool>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="verticalScrollBarPolicy">
 | 
			
		||||
          <enum>Qt::ScrollBarAlwaysOn</enum>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="readOnly">
 | 
			
		||||
          <bool>true</bool>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="textInteractionFlags">
 | 
			
		||||
          <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="0" column="0" colspan="4">
 | 
			
		||||
        <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
         <item row="3" column="1">
 | 
			
		||||
          <widget class="QPushButton" name="btnCopy">
 | 
			
		||||
@@ -65,6 +91,16 @@
 | 
			
		||||
           </property>
 | 
			
		||||
          </widget>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item row="3" column="4">
 | 
			
		||||
          <widget class="QPushButton" name="btnClean">
 | 
			
		||||
           <property name="toolTip">
 | 
			
		||||
            <string>Clear the log</string>
 | 
			
		||||
           </property>
 | 
			
		||||
           <property name="text">
 | 
			
		||||
            <string>Clean</string>
 | 
			
		||||
           </property>
 | 
			
		||||
          </widget>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item row="3" column="0">
 | 
			
		||||
          <widget class="QPushButton" name="btnReload">
 | 
			
		||||
           <property name="text">
 | 
			
		||||
@@ -82,31 +118,12 @@
 | 
			
		||||
           </property>
 | 
			
		||||
          </widget>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item row="3" column="4">
 | 
			
		||||
          <widget class="QPushButton" name="btnClean">
 | 
			
		||||
           <property name="toolTip">
 | 
			
		||||
            <string>Clear the log</string>
 | 
			
		||||
           </property>
 | 
			
		||||
           <property name="text">
 | 
			
		||||
            <string>Clean</string>
 | 
			
		||||
           </property>
 | 
			
		||||
          </widget>
 | 
			
		||||
         </item>
 | 
			
		||||
        </layout>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item>
 | 
			
		||||
        <widget class="QPlainTextEdit" name="text">
 | 
			
		||||
         <property name="enabled">
 | 
			
		||||
          <bool>false</bool>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="verticalScrollBarPolicy">
 | 
			
		||||
          <enum>Qt::ScrollBarAlwaysOn</enum>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="readOnly">
 | 
			
		||||
          <bool>true</bool>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="textInteractionFlags">
 | 
			
		||||
          <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
 | 
			
		||||
       <item row="2" column="0">
 | 
			
		||||
        <widget class="QLabel" name="label">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Search:</string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
@@ -117,7 +134,16 @@
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <tabstops>
 | 
			
		||||
  <tabstop>tabWidget</tabstop>
 | 
			
		||||
  <tabstop>selectLogBox</tabstop>
 | 
			
		||||
  <tabstop>btnReload</tabstop>
 | 
			
		||||
  <tabstop>btnCopy</tabstop>
 | 
			
		||||
  <tabstop>btnPaste</tabstop>
 | 
			
		||||
  <tabstop>btnDelete</tabstop>
 | 
			
		||||
  <tabstop>btnClean</tabstop>
 | 
			
		||||
  <tabstop>text</tabstop>
 | 
			
		||||
  <tabstop>searchBar</tabstop>
 | 
			
		||||
  <tabstop>findButton</tabstop>
 | 
			
		||||
 </tabstops>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user