fixed default shortcut in findwindow
authorinsilmaril
Tue, 05 Sep 2006 11:53:54 +0000
changeset 37097f5d07bf47d
parent 369 1f6263d403a0
child 371 ebefeea77f2f
fixed default shortcut in findwindow
findwindow.cpp
     1.1 --- a/findwindow.cpp	Tue Sep 05 10:03:29 2006 +0000
     1.2 +++ b/findwindow.cpp	Tue Sep 05 11:53:54 2006 +0000
     1.3 @@ -1,77 +1,83 @@
     1.4 -#include <qlineedit.h>
     1.5 -//Added by qt3to4:
     1.6 -#include <Q3HBoxLayout>
     1.7 -#include <Q3VBoxLayout>
     1.8 +#include <QLineEdit>
     1.9 +#include <QVBoxLayout>
    1.10  #include <QLabel>
    1.11  
    1.12  #include "findwindow.h"
    1.13  #include "version.h"
    1.14  
    1.15  
    1.16 -FindWindow::FindWindow(QWidget* parent, const char* name) 
    1.17 -	: Q3GroupBox( 0, Qt::Horizontal, "Find", parent, name )
    1.18 +FindWindow::FindWindow(QWidget* parent)
    1.19 +	: QGroupBox( tr("Find"), parent )
    1.20  
    1.21  {
    1.22 -	setCaption (__VYM " - " +tr("Find Text"));
    1.23 +	setWindowTitle(__VYM " - " +tr("Find Text"));
    1.24  	//resize (180,130);
    1.25 -	move (130,130);
    1.26 +	//move (130,130);
    1.27  
    1.28 -	//FIXME not avail in QT4 setMargin( 100 );
    1.29 +    QVBoxLayout* mainLayout = new QVBoxLayout;
    1.30 +    
    1.31 +    QHBoxLayout *row1Layout = new QHBoxLayout;
    1.32 +    // Create a Label
    1.33 +    QLabel* label = new QLabel;
    1.34 +    label->setText( tr("Text to find:"));
    1.35 +    row1Layout->addWidget( label );
    1.36  
    1.37 -    Q3VBoxLayout* box = new Q3VBoxLayout( layout() );
    1.38 -    
    1.39 -    Q3HBoxLayout *row1 = new Q3HBoxLayout( box );
    1.40 -    row1->setMargin( 10 );
    1.41 -
    1.42 -    // Create a Label
    1.43 -    QLabel* label = new QLabel( "Text to find: ", this);
    1.44 -    row1->addWidget( label );
    1.45  
    1.46  	// Create LineEdit (here QComboBox)
    1.47 -    Q3HBoxLayout *row2 = new Q3HBoxLayout( box );
    1.48 -    row2->setMargin( 10 );
    1.49 -    findcombo = new QComboBox( true, this );
    1.50 +    QHBoxLayout *row2Layout = new QHBoxLayout;
    1.51 +    findcombo = new QComboBox;
    1.52  	findcombo->setMinimumWidth(150);
    1.53 -    row2->addWidget( findcombo );
    1.54 +	findcombo->setEditable(true);
    1.55  	connect ( findcombo, SIGNAL( highlighted(int) ), 
    1.56  		this, SLOT( findPressed() ) );
    1.57  	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
    1.58  		this, SLOT( findTextChanged(const QString&) ) );
    1.59      //findcombo->insertItem( "Normal", -1 );
    1.60  
    1.61 +	row2Layout->addWidget(findcombo);
    1.62 +
    1.63  	// Create Buttons
    1.64 -    Q3HBoxLayout *row3 = new Q3HBoxLayout( box );
    1.65 -    row3->setMargin( 10 );
    1.66 -	clearbutton = new QPushButton (tr("Clear"),this);
    1.67 -	connect ( clearbutton, SIGNAL( clicked() ), 
    1.68 -		findcombo, SLOT( clearEdit() ) );
    1.69 -	row3->addWidget (clearbutton);
    1.70 +    QHBoxLayout *row3Layout = new QHBoxLayout;
    1.71 +	clearbutton = new QPushButton;
    1.72 +	clearbutton->setText(tr("Clear"));
    1.73 +	connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
    1.74 +	row3Layout->addWidget (clearbutton);
    1.75  	
    1.76 +	/*
    1.77  	QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding );
    1.78 -	row3->addItem(si1);
    1.79 +	row3Layout->addItem(si1);
    1.80 +	*/
    1.81  	
    1.82 -	cancelbutton = new QPushButton (tr("Cancel"),this);
    1.83 -	cancelbutton->setAccel (Qt::Key_Escape);
    1.84 -	connect ( cancelbutton, SIGNAL( clicked() ), 
    1.85 -		this, SLOT( cancelPressed() ) );
    1.86 -	row3->addWidget (cancelbutton);
    1.87 +	cancelbutton = new QPushButton;
    1.88 +	cancelbutton->setText(tr("Cancel"));
    1.89 +	cancelbutton->setShortcut (Qt::Key_Escape);
    1.90 +	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
    1.91 +	row3Layout->addWidget (cancelbutton);
    1.92  
    1.93 +/*
    1.94  	QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed);
    1.95 -	row3->addItem(si2);
    1.96 +	row3Layout->addItem(si2);
    1.97 +	*/
    1.98  	
    1.99 -	findbutton = new QPushButton (tr("Find"),this);
   1.100 +	findbutton = new QPushButton;
   1.101 +	findbutton->setText (tr("Find"));
   1.102  	findbutton->setDefault (true);
   1.103 -	connect ( findbutton, SIGNAL( clicked() ), 
   1.104 -		this, SLOT( findPressed() ) );
   1.105 -	row3->add(findbutton);
   1.106 -	
   1.107 -	findcombo->setFocus();
   1.108 +	findbutton->setShortcut (Qt::Key_Return);
   1.109 +	connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
   1.110 +
   1.111 +	row3Layout->addWidget(findbutton);
   1.112 +
   1.113 +	mainLayout->addLayout (row1Layout);
   1.114 +	mainLayout->addLayout (row2Layout);
   1.115 +	mainLayout->addLayout (row3Layout);
   1.116 +	setLayout (mainLayout);
   1.117  }
   1.118  
   1.119  void FindWindow::popup()
   1.120  {
   1.121 +	show();
   1.122  	findcombo->lineEdit()->selectAll();
   1.123 -	show();
   1.124 +	findcombo->setFocus();
   1.125  }
   1.126  
   1.127  void FindWindow::cancelPressed()
   1.128 @@ -88,3 +94,8 @@
   1.129  {
   1.130  	emit (somethingChanged() );
   1.131  }
   1.132 +
   1.133 +void FindWindow::clearLineEdit()
   1.134 +{
   1.135 +	findcombo->lineEdit()->clear();
   1.136 +}