Menu

[c54480]: / findwidget.cpp  Maximize  Restore  History

Download this file

113 lines (89 with data), 2.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#include <QAction>
#include <QDebug>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
#include <QGroupBox>
#include <QLabel>
#include "findwidget.h"
#include "mainwindow.h"
extern Main *mainWindow;
FindWidget::FindWidget(QWidget *)
{
QVBoxLayout* mainLayout = new QVBoxLayout;
QHBoxLayout *row2Layout = new QHBoxLayout;
QLabel *label=new QLabel;
label->setText (tr("Find:","FindWidget"));
// Create LineEdit (here QComboBox)
findcombo = new QComboBox;
findcombo->setMinimumWidth(250);
findcombo->setEditable(true);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
findcombo->setSizePolicy(sizePolicy);
connect ( findcombo, SIGNAL( highlighted(int) ),
this, SLOT( nextPressed() ) );
connect ( findcombo, SIGNAL( editTextChanged(const QString &) ),
this, SLOT( findTextChanged(const QString&) ) );
nextButton = new QPushButton;
nextButton->setIcon (QPixmap(":/find.png"));
//nextButton->setText (tr("Find","Find widget"));
connect ( nextButton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
// QAction needed to only activate shortcut while FindWidget has focus
QAction *a=new QAction (nextButton->text(),this);
a->setShortcut (Qt::Key_Return);
a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
connect ( a, SIGNAL( triggered() ), this, SLOT( nextPressed() ) );
addAction (a);
filterNotesButton = new QPushButton;
filterNotesButton->setIcon (QPixmap(":/flag-note.png"));
filterNotesButton->setCheckable(true);
filterNotesButton->setChecked(true);
connect ( filterNotesButton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
row2Layout->addWidget (label);
row2Layout->addWidget(findcombo);
row2Layout->addWidget(nextButton);
row2Layout->addWidget(filterNotesButton);
mainLayout->addLayout (row2Layout);
setLayout (mainLayout);
status=Undefined;
}
QString FindWidget::getFindText()
{
return findcombo->currentText();
}
void FindWidget::cancelPressed()
{
hide();
emit (hideFindWidget() );//Restore focus
}
void FindWidget::nextPressed()
{
emit (nextButtonPressed(findcombo->currentText(), filterNotesButton->isChecked() ));
}
void FindWidget::findTextChanged(const QString&)
{
setStatus (Undefined);
}
void FindWidget::setFocus()
{
findcombo->lineEdit()->selectAll();
findcombo->lineEdit()->setFocus();
}
void FindWidget::setStatus (Status st)
{
if (st==status) return;
status=st;
QPalette p=palette();
QColor c;
switch (st)
{
case Success: c=QColor (120,255,120); break;
case Failed: c=QColor (255,120,120); break;
default: c=QColor (255,255,255);
}
p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);
findcombo->setPalette(p);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.