GUI: resolved issue #358 (feature requests for search in the SearchListView), added a menu item that makes the search bar flicker with a red border three times
This commit is contained in:
parent
cd6c113b0f
commit
9ad616a546
|
|
@ -1,5 +1,6 @@
|
|||
#include "SearchListView.h"
|
||||
#include "ui_SearchListView.h"
|
||||
#include "FlickerThread.h"
|
||||
|
||||
SearchListView::SearchListView(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
|
|
@ -49,6 +50,10 @@ SearchListView::SearchListView(QWidget* parent) :
|
|||
for(int i = 0; i < ui->mainSplitter->count(); i++)
|
||||
ui->mainSplitter->handle(i)->setEnabled(false);
|
||||
|
||||
// Setup search menu action
|
||||
mSearchAction = new QAction("Search...", this);
|
||||
connect(mSearchAction, SIGNAL(triggered()), this, SLOT(searchSlot()));
|
||||
|
||||
// Setup signals
|
||||
connect(mList, SIGNAL(keyPressedSignal(QKeyEvent*)), this, SLOT(listKeyPressed(QKeyEvent*)));
|
||||
connect(mList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
|
||||
|
|
@ -172,13 +177,12 @@ void SearchListView::listContextMenu(const QPoint & pos)
|
|||
{
|
||||
QMenu* wMenu = new QMenu(this);
|
||||
emit listContextMenuSignal(wMenu);
|
||||
wMenu->addSeparator();
|
||||
wMenu->addAction(mSearchAction);
|
||||
QMenu wCopyMenu("&Copy", this);
|
||||
mCurList->setupCopyMenu(&wCopyMenu);
|
||||
if(wCopyMenu.actions().length())
|
||||
{
|
||||
wMenu->addSeparator();
|
||||
wMenu->addMenu(&wCopyMenu);
|
||||
}
|
||||
wMenu->exec(mCurList->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
|
@ -192,3 +196,10 @@ void SearchListView::on_checkBoxRegex_toggled(bool checked)
|
|||
Q_UNUSED(checked);
|
||||
searchTextChanged(ui->searchBox->text());
|
||||
}
|
||||
|
||||
void SearchListView::searchSlot()
|
||||
{
|
||||
FlickerThread* thread = new FlickerThread(ui->searchBox, this);
|
||||
connect(thread, SIGNAL(setStyleSheet(QString)), ui->searchBox, SLOT(setStyleSheet(QString)));
|
||||
thread->start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ private slots:
|
|||
void listKeyPressed(QKeyEvent* event);
|
||||
void listContextMenu(const QPoint & pos);
|
||||
void doubleClickedSlot();
|
||||
void searchSlot();
|
||||
void on_checkBoxRegex_toggled(bool checked);
|
||||
|
||||
signals:
|
||||
|
|
@ -44,7 +45,7 @@ private:
|
|||
Ui::SearchListView* ui;
|
||||
QVBoxLayout* mListLayout;
|
||||
QWidget* mListPlaceHolder;
|
||||
|
||||
QAction* mSearchAction;
|
||||
};
|
||||
|
||||
#endif // SEARCHLISTVIEW_H
|
||||
|
|
|
|||
|
|
@ -59,7 +59,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="searchBox"/>
|
||||
<widget class="QLineEdit" name="searchBox">
|
||||
<property name="placeholderText">
|
||||
<string>Type here to filter results...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxRegex">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
#include "FlickerThread.h"
|
||||
#include <QStyle>
|
||||
#include <Windows.h>
|
||||
|
||||
FlickerThread::FlickerThread(QWidget* widget, QObject* parent) : QThread(parent)
|
||||
{
|
||||
mWidget = widget;
|
||||
}
|
||||
|
||||
void FlickerThread::run()
|
||||
{
|
||||
QString oldStyle = mWidget->styleSheet();
|
||||
int delay = 300;
|
||||
for(int i = 0; i < 3 ; i++)
|
||||
{
|
||||
emit setStyleSheet("QWidget { border: 2px solid red; }");
|
||||
Sleep(delay);
|
||||
emit setStyleSheet(oldStyle);
|
||||
Sleep(delay);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef FLICKERTHREAD_H
|
||||
#define FLICKERTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
|
||||
class FlickerThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlickerThread(QWidget* widget, QObject* parent = 0);
|
||||
|
||||
signals:
|
||||
void setStyleSheet(QString style);
|
||||
|
||||
private:
|
||||
void run();
|
||||
QWidget* mWidget;
|
||||
};
|
||||
|
||||
#endif // FLICKERTHREAD_H
|
||||
|
|
@ -93,7 +93,8 @@ SOURCES += \
|
|||
Src/Gui/SourceView.cpp \
|
||||
Src/Utils/ValidateExpressionThread.cpp \
|
||||
Src/Utils/MainWindowCloseThread.cpp \
|
||||
Src/Gui/TimeWastedCounter.cpp
|
||||
Src/Gui/TimeWastedCounter.cpp \
|
||||
Src/Utils/FlickerThread.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
|
|
@ -166,7 +167,8 @@ HEADERS += \
|
|||
Src/Utils/StringUtil.h \
|
||||
Src/Utils/ValidateExpressionThread.h \
|
||||
Src/Utils/MainWindowCloseThread.h \
|
||||
Src/Gui/TimeWastedCounter.h
|
||||
Src/Gui/TimeWastedCounter.h \
|
||||
Src/Utils/FlickerThread.h
|
||||
|
||||
|
||||
INCLUDEPATH += \
|
||||
|
|
|
|||
Loading…
Reference in New Issue