예제 #1
0
파일: rc.c 프로젝트: galexcode/w3m
void
sync_with_option(void)
{
    if (PagerMax < LINES)
	PagerMax = LINES;
    WrapSearch = WrapDefault;
    parse_proxy();
#ifdef USE_COOKIE
    parse_cookie();
#endif
    initMailcap();
    initMimeTypes();
#ifdef USE_EXTERNAL_URI_LOADER
    initURIMethods();
#endif
#ifdef USE_MIGEMO
    init_migemo();
#endif
#ifdef USE_IMAGE
    if (fmInitialized && displayImage)
	initImage();
#else
    displayImage = FALSE;	/* XXX */
#endif
    loadPasswd();
    loadPreForm();

    if (AcceptLang == NULL || *AcceptLang == '\0') {
	/* TRANSLATORS: 
	 * AcceptLang default: this is used in Accept-Language: HTTP request 
	 * header. For example, ja.po should translate it as
	 * "ja;q=1.0, en;q=0.5" like that.
	 */
	AcceptLang = _("en;q=1.0");
    }
    if (AcceptEncoding == NULL || *AcceptEncoding == '\0')
	AcceptEncoding = acceptableEncoding();
    if (AcceptMedia == NULL || *AcceptMedia == '\0')
	AcceptMedia = acceptableMimeTypes();
    if (fmInitialized) {
	initKeymap(FALSE);
#ifdef USE_MOUSE
	initMouseAction();
#endif				/* MOUSE */
#ifdef USE_MENU
	initMenu();
#endif				/* MENU */
    }
}
예제 #2
0
KfindTabWidget::KfindTabWidget(TQWidget *parent, const char *name)
  : TQTabWidget( parent, name ), regExpDialog(0)
{
    // This validator will be used for all numeric edit fields
    //KDigitValidator *digitV = new KDigitValidator(this);

    // ************ Page One ************

    pages[0] = new TQWidget( this, "page1" );

    nameBox = new KComboBox(TRUE, pages[0], "combo1");
    nameBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed);  // allow smaller than widest entry
    TQLabel * namedL = new TQLabel(nameBox, i18n("&Named:"), pages[0], "named");
    TQToolTip::add( namedL, i18n("You can use wildcard matching and \";\" for separating multiple names") );
    dirBox  = new KComboBox(TRUE, pages[0], "combo2");
    dirBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed);  // allow smaller than widest entry
    TQLabel * lookinL = new TQLabel(dirBox, i18n("Look &in:"), pages[0], "named");
    subdirsCb  = new TQCheckBox(i18n("Include &subfolders"), pages[0]);
    caseSensCb  = new TQCheckBox(i18n("Case s&ensitive search"), pages[0]);
    browseB    = new TQPushButton(i18n("&Browse..."), pages[0]);
    useLocateCb = new TQCheckBox(i18n("&Use files index"), pages[0]);

    // Setup

    subdirsCb->setChecked(true);
    caseSensCb->setChecked(false);
    useLocateCb->setChecked(false);
    if(TDEStandardDirs::findExe("locate")==NULL)
    	useLocateCb->setEnabled(false);

    nameBox->setDuplicatesEnabled(FALSE);
    nameBox->setFocus();
    dirBox->setDuplicatesEnabled(FALSE);

    nameBox->setInsertionPolicy(TQComboBox::AtTop);
    dirBox->setInsertionPolicy(TQComboBox::AtTop);

    const TQString nameWhatsThis
      = i18n("<qt>Enter the filename you are looking for. <br>"
	     "Alternatives may be separated by a semicolon \";\".<br>"
	     "<br>"
	     "The filename may contain the following special characters:"
	     "<ul>"
	     "<li><b>?</b> matches any single character</li>"
	     "<li><b>*</b> matches zero or more of any characters</li>"
	     "<li><b>[...]</b> matches any of the characters in braces</li>"
	     "</ul>"
	     "<br>"
	     "Example searches:"
	     "<ul>"
	     "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>"
	     "<li><b>go[dt]</b> finds god and got</li>"
	     "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", "
	     "having one character in between</li>"
	     "<li><b>My Document.kwd</b> finds a file of exactly that name</li>"
	     "</ul></qt>");
    TQWhatsThis::add(nameBox,nameWhatsThis);
    TQWhatsThis::add(namedL,nameWhatsThis);
    const TQString whatsfileindex
        = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> "
               "package to speed-up the search; remember to update the index from time to time "
               "(using <i>updatedb</i>)."
               "</qt>");
    TQWhatsThis::add(useLocateCb,whatsfileindex);

    // Layout

    TQGridLayout *grid = new TQGridLayout( pages[0], 3, 2,
					 KDialog::marginHint(),
					 KDialog::spacingHint() );
    TQBoxLayout *subgrid = new TQVBoxLayout( -1 , "subgrid" );
    grid->addWidget( namedL, 0, 0 );
    grid->addMultiCellWidget( nameBox, 0, 0, 1, 2 );
    grid->addWidget( lookinL, 1, 0 );
    grid->addWidget( dirBox, 1, 1 );
    grid->addWidget( browseB, 1, 2);
    grid->setColStretch(1,1);
    grid->addMultiCellLayout( subgrid, 2, 2, 1, 2 );
    subgrid->addWidget( subdirsCb );
    subgrid->addWidget( caseSensCb);
    subgrid->addWidget( useLocateCb );
    subgrid->addStretch(1);

    // Signals

    connect( browseB, TQT_SIGNAL(clicked()),
             this, TQT_SLOT(getDirectory()) );

    connect( nameBox, TQT_SIGNAL(activated(int)),
             this, TQT_SIGNAL(startSearch()));

    // ************ Page Two

    pages[1] = new TQWidget( this, "page2" );

    findCreated =  new TQCheckBox(i18n("Find all files created or &modified:"), pages[1]);
    bg  = new TQButtonGroup();
    rb[0] = new TQRadioButton(i18n("&between"), pages[1] );
    rb[1] = new TQRadioButton(i18n("&during the previous"), pages[1] );
    TQLabel * andL   = new TQLabel(i18n("and"), pages[1], "and");
    betweenType = new KComboBox(FALSE, pages[1], "comboBetweenType");
    betweenType->insertItem(i18n("minute(s)"));
    betweenType->insertItem(i18n("hour(s)"));
    betweenType->insertItem(i18n("day(s)"));
    betweenType->insertItem(i18n("month(s)"));
    betweenType->insertItem(i18n("year(s)"));
    betweenType->setCurrentItem(1);


    TQDate dt = TDEGlobal::locale()->calendar()->addYears(TQDate::currentDate(), -1);

    fromDate = new KDateCombo(dt, pages[1], "fromDate");
    toDate = new KDateCombo(pages[1], "toDate");
    timeBox = new TQSpinBox(1, 60, 1, pages[1], "timeBox");

    sizeBox =new KComboBox(FALSE, pages[1], "sizeBox");
    TQLabel * sizeL   =new TQLabel(sizeBox,i18n("File &size is:"), pages[1],"size");
    sizeEdit=new TQSpinBox(0, INT_MAX, 1, pages[1], "sizeEdit" );
    sizeEdit->setValue(1);
    sizeUnitBox =new KComboBox(FALSE, pages[1], "sizeUnitBox");

    m_usernameBox = new KComboBox( true, pages[1], "m_combo1");
    TQLabel *usernameLabel= new TQLabel(m_usernameBox,i18n("Files owned by &user:"******"m_combo2");
    TQLabel *groupLabel= new TQLabel(m_groupBox,i18n("Owned by &group:"),pages[1]);

    sizeBox ->insertItem( i18n("(none)") );
    sizeBox ->insertItem( i18n("At Least") );
    sizeBox ->insertItem( i18n("At Most") );
    sizeBox ->insertItem( i18n("Equal To") );

    sizeUnitBox ->insertItem( i18n("Bytes") );
    sizeUnitBox ->insertItem( i18n("KB") );
    sizeUnitBox ->insertItem( i18n("MB") );
    sizeUnitBox ->insertItem( i18n("GB") );
    sizeUnitBox ->setCurrentItem(1);

    int tmp = sizeEdit->fontMetrics().width(" 000000000 ");
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    m_usernameBox->setDuplicatesEnabled(FALSE);
    m_groupBox->setDuplicatesEnabled(FALSE);
    m_usernameBox->setInsertionPolicy(TQComboBox::AtTop);
    m_groupBox->setInsertionPolicy(TQComboBox::AtTop);


    // Setup
    timeBox->setButtonSymbols(TQSpinBox::PlusMinus);
    rb[0]->setChecked(true);
    bg->insert( rb[0] );
    bg->insert( rb[1] );

    // Layout

    TQGridLayout *grid1 = new TQGridLayout( pages[1], 5,  6,
					  KDialog::marginHint(),
					  KDialog::spacingHint() );

    grid1->addMultiCellWidget(findCreated, 0, 0, 0, 3 );
    grid1->addColSpacing(0, KDialog::spacingHint());

    grid1->addWidget(rb[0], 1, 1 );
    grid1->addWidget(fromDate, 1, 2 );
    grid1->addWidget(andL, 1, 3, Qt::AlignHCenter );
    grid1->addWidget(toDate, 1, 4 );

    grid1->addWidget(rb[1], 2, 1 );
    grid1->addMultiCellWidget(timeBox, 2, 2, 2, 3);
    grid1->addWidget(betweenType, 2, 4 );

    grid1->addMultiCellWidget(sizeL,3,3,0,1);
    grid1->addWidget(sizeBox,3,2);
    grid1->addWidget(sizeEdit,3,3);
    grid1->addWidget(sizeUnitBox,3,4);

    grid1->addMultiCellWidget(usernameLabel,4,4,0,1);
    grid1->addWidget(m_usernameBox,4,2);
    grid1->addWidget(groupLabel,4,3);
    grid1->addWidget(m_groupBox,4,4);

    for (int c=1; c<=4; c++)
       grid1->setColStretch(c,1);

    grid1->setRowStretch(6,1);

    // Connect
    connect( findCreated,  TQT_SIGNAL(toggled(bool)),   TQT_SLOT(fixLayout()) );
    connect( bg,  TQT_SIGNAL(clicked(int)), this,   TQT_SLOT(fixLayout()) );
    connect( sizeBox, TQT_SIGNAL(highlighted(int)), this, TQT_SLOT(slotSizeBoxChanged(int)));


    // ************ Page Three

    pages[2] = new TQWidget( this, "page3" );

    typeBox =new KComboBox(FALSE, pages[2], "typeBox");
    typeBox->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Fixed);  // allow smaller than widest entry
    TQLabel * typeL   =new TQLabel(typeBox, i18n("File &type:"), pages[2], "type");
    textEdit=new KLineEdit(pages[2], "textEdit" );
    TQLabel * textL   =new TQLabel(textEdit, i18n("C&ontaining text:"), pages[2], "text");

    connect( textEdit, TQT_SIGNAL(returnPressed(const TQString &)), TQT_SIGNAL( startSearch()));

    const TQString containingtext
      = i18n("<qt>If specified, only files that contain this text"
	      " are found. Note that not all file types from the list"
		  " above are supported. Please refer to the documentation"
		  " for a list of supported file types."
	      "</qt>");
    TQToolTip::add(textEdit,containingtext);
    TQWhatsThis::add(textL,containingtext);

    caseContextCb  =new TQCheckBox(i18n("Case s&ensitive"), pages[2]);
    binaryContextCb  =new TQCheckBox(i18n("Include &binary files"), pages[2]);
    regexpContentCb  =new TQCheckBox(i18n("Regular e&xpression"), pages[2]);

    const TQString binaryTooltip
      = i18n("<qt>This lets you search in any type of file, "
       "even those that usually do not contain text (for example "
	   "program files and images).</qt>");
    TQToolTip::add(binaryContextCb,binaryTooltip);

    TQPushButton* editRegExp = 0;
    if ( !TDETrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() ) {
      // The editor is available, so lets use it.
      editRegExp = new TQPushButton(i18n("&Edit..."), pages[2], "editRegExp");
    }

    metainfokeyEdit=new KLineEdit(pages[2], "textEdit" );
    metainfoEdit=new KLineEdit(pages[2], "textEdit" );
    TQLabel * textMetaInfo = new TQLabel(metainfoEdit, i18n("fo&r:"), pages[2], "text");
    TQLabel * textMetaKey = new TQLabel(metainfokeyEdit, i18n("Search &metainfo sections:"), pages[2], "text");

    // Setup
    typeBox->insertItem(i18n("All Files & Folders"));
    typeBox->insertItem(i18n("Files"));
    typeBox->insertItem(i18n("Folders"));
    typeBox->insertItem(i18n("Symbolic Links"));
    typeBox->insertItem(i18n("Special Files (Sockets, Device Files, ...)"));
    typeBox->insertItem(i18n("Executable Files"));
    typeBox->insertItem(i18n("SUID Executable Files"));
    typeBox->insertItem(i18n("All Images"));
    typeBox->insertItem(i18n("All Video"));
    typeBox->insertItem(i18n("All Sounds"));

    initMimeTypes();
    initSpecialMimeTypes();

    for ( KMimeType::List::ConstIterator it = m_types.begin();
          it != m_types.end(); ++it )
    {
      KMimeType::Ptr typ = *it;
      typeBox->insertItem(typ->pixmap( TDEIcon::Small ), typ->comment());
    }

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      connect( regexpContentCb, TQT_SIGNAL(toggled(bool) ), editRegExp, TQT_SLOT(setEnabled(bool)) );
      editRegExp->setEnabled(false);
      connect( editRegExp, TQT_SIGNAL(clicked()), this, TQT_SLOT( slotEditRegExp() ) );
    }
    else
        regexpContentCb->hide();

    // Layout
    tmp = sizeEdit->fontMetrics().width(" 00000 ");
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    TQGridLayout *grid2 = new TQGridLayout( pages[2], 5, 4,
					  KDialog::marginHint(),
					  KDialog::spacingHint() );
    grid2->addWidget( typeL, 0, 0 );
    grid2->addWidget( textL, 1, 0 );
    grid2->addMultiCellWidget( typeBox, 0, 0, 1, 3 );
    grid2->addMultiCellWidget( textEdit, 1, 1, 1, 3 );
    grid2->addWidget( regexpContentCb, 2, 2);
    grid2->addWidget( caseContextCb, 2, 1 );
    grid2->addWidget( binaryContextCb, 3, 1);

    grid2->addWidget( textMetaKey, 4, 0 );
    grid2->addWidget( metainfokeyEdit, 4, 1 );
    grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter  );
    grid2->addWidget( metainfoEdit, 4, 3 );

    metainfokeyEdit->setText("*");

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      grid2->addWidget( editRegExp, 2, 3 );
    }

    addTab( pages[0], i18n("Name/&Location") );
    addTab( pages[2], i18n("C&ontents") );
    addTab( pages[1], i18n("&Properties") );


    // Setup
    const TQString whatsmetainfo
      = i18n("<qt>Search within files' specific comments/metainfo<br>"
	     "These are some examples:<br>"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>"
	     "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>"
	     "</ul>"
	     "</qt>");
    const TQString whatsmetainfokey
      = i18n("<qt>If specified, search only in this field<br>"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>"
	     "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>"
	     "</ul>"
	     "</qt>");
    TQWhatsThis::add(textMetaInfo,whatsmetainfo);
    TQToolTip::add(metainfoEdit,whatsmetainfo);
    TQWhatsThis::add(textMetaKey,whatsmetainfokey);
    TQToolTip::add(metainfokeyEdit,whatsmetainfokey);


    fixLayout();
    loadHistory();
}
예제 #3
0
KfindTabWidget::KfindTabWidget(QWidget *parent)
  : KTabWidget( parent ), regExpDialog(0)
{
    // This validator will be used for all numeric edit fields
    //KDigitValidator *digitV = new KDigitValidator(this);

    // ************ Page One ************

    pages[0] = new QWidget;
    pages[0]->setObjectName( QLatin1String( "page1" ) );

    nameBox = new KComboBox(pages[0]);
    nameBox->setEditable( true );
    nameBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);  // allow smaller than widest entry
    QLabel * namedL = new QLabel(i18nc("this is the label for the name textfield","&Named:"), pages[0]);
    namedL->setBuddy( nameBox );
    namedL->setObjectName( QLatin1String( "named" ) );
    namedL->setToolTip( i18n("You can use wildcard matching and \";\" for separating multiple names") );
    dirBox  = new KUrlComboBox(KUrlComboBox::Directories, pages[0]);
    dirBox->setEditable( true );
    dirBox->setCompletionObject(new KUrlCompletion(KUrlCompletion::DirCompletion));
    dirBox->setAutoDeleteCompletionObject(true);
    dirBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);  // allow smaller than widest entry
    QLabel * lookinL = new QLabel(i18n("Look &in:"), pages[0]);
    lookinL->setBuddy( dirBox );
    lookinL->setObjectName( QLatin1String( "lookin" ) );
    subdirsCb  = new QCheckBox(i18n("Include &subfolders"), pages[0]);
    caseSensCb  = new QCheckBox(i18n("Case s&ensitive search"), pages[0]);
    browseB    = new QPushButton(i18n("&Browse..."), pages[0]);
    useLocateCb = new QCheckBox(i18n("&Use files index"), pages[0]);
    hiddenFilesCb = new QCheckBox(i18n("Show &hidden files"), pages[0]);
    // Setup

    subdirsCb->setChecked(true);
    caseSensCb->setChecked(false);
    useLocateCb->setChecked(false);
    hiddenFilesCb->setChecked(false);
    if(KStandardDirs::findExe(QLatin1String("locate")).isEmpty())
        useLocateCb->setEnabled(false);

    nameBox->setDuplicatesEnabled(false);
    nameBox->setFocus();
    dirBox->setDuplicatesEnabled(false);

    nameBox->setInsertPolicy(QComboBox::InsertAtTop);
    dirBox->setInsertPolicy(QComboBox::InsertAtTop);

    const QString nameWhatsThis
      = i18n("<qt>Enter the filename you are looking for. <br />"
	     "Alternatives may be separated by a semicolon \";\".<br />"
	     "<br />"
	     "The filename may contain the following special characters:"
	     "<ul>"
	     "<li><b>?</b> matches any single character</li>"
	     "<li><b>*</b> matches zero or more of any characters</li>"
	     "<li><b>[...]</b> matches any of the characters between the braces</li>"
	     "</ul>"
	     "<br />"
	     "Example searches:"
	     "<ul>"
	     "<li><b>*.kwd;*.txt</b> finds all files ending with .kwd or .txt</li>"
	     "<li><b>go[dt]</b> finds god and got</li>"
	     "<li><b>Hel?o</b> finds all files that start with \"Hel\" and end with \"o\", "
	     "having one character in between</li>"
	     "<li><b>My Document.kwd</b> finds a file of exactly that name</li>"
	     "</ul></qt>");
    nameBox->setWhatsThis(nameWhatsThis);
    namedL->setWhatsThis(nameWhatsThis);
    const QString whatsfileindex
        = i18n("<qt>This lets you use the files' index created by the <i>slocate</i> "
               "package to speed-up the search; remember to update the index from time to time "
               "(using <i>updatedb</i>)."
               "</qt>");
    useLocateCb->setWhatsThis(whatsfileindex);

    // Layout

    QGridLayout *grid = new QGridLayout( pages[0] );
    grid->setMargin( KDialog::marginHint() );
    grid->setSpacing( KDialog::spacingHint() );
    QVBoxLayout *subgrid = new QVBoxLayout();
    grid->addWidget( namedL, 0, 0 );
    grid->addWidget( nameBox, 0, 1, 1, 3 );
    grid->addWidget( lookinL, 1, 0 );
    grid->addWidget( dirBox, 1, 1 );
    grid->addWidget( browseB, 1, 2);
    grid->setColumnStretch(1,1);
    grid->addLayout( subgrid, 2, 1, 1, 2 );
    
    QHBoxLayout * layoutOne = new QHBoxLayout();
    layoutOne->addWidget( subdirsCb );
    layoutOne->addWidget( hiddenFilesCb );
    
    QHBoxLayout * layoutTwo = new QHBoxLayout();
    layoutTwo->addWidget( caseSensCb);
    layoutTwo->addWidget( useLocateCb );
    
    subgrid->addLayout( layoutOne );
    subgrid->addLayout( layoutTwo );
    
    subgrid->addStretch(1);

    // Signals

    connect(browseB, &QPushButton::clicked, this, &KfindTabWidget::getDirectory);

    connect(nameBox, static_cast<void (KComboBox::*)()>(&KComboBox::returnPressed), this, &KfindTabWidget::startSearch);

    connect(dirBox, static_cast<void (KUrlComboBox::*)()>(&KUrlComboBox::returnPressed), this, &KfindTabWidget::startSearch);
    
    // ************ Page Two

    pages[1] = new QWidget;
    pages[1]->setObjectName( QLatin1String( "page2" ) );

    findCreated =  new QCheckBox(i18n("Find all files created or &modified:"), pages[1]);
    bg  = new QButtonGroup();
    rb[0] = new QRadioButton(i18n("&between"), pages[1] );
    rb[1] = new QRadioButton(pages[1]); // text set in updateDateLabels
    andL = new QLabel(i18n("and"), pages[1]);
    andL->setObjectName( QLatin1String( "and" ) );
    betweenType = new KComboBox( pages[1] );
    betweenType->setObjectName( QLatin1String( "comboBetweenType" ) );
    betweenType->addItems(QVector<QString>(5).toList()); // texts set in updateDateLabels
    betweenType->setCurrentIndex(1);
    updateDateLabels(1, 1);

    QDate dt = KLocale::global()->calendar()->addYears(QDate::currentDate(), -1);

    fromDate = new KDateCombo(dt, pages[1] );
    fromDate->setObjectName( QLatin1String( "fromDate" ) );
    toDate = new KDateCombo(pages[1] );
    toDate->setObjectName( QLatin1String( "toDate" ) );
    timeBox = new KIntSpinBox( pages[1] );
    timeBox->setRange( 1, 60 );
    timeBox->setSingleStep( 1 );
    timeBox->setObjectName( QLatin1String( "timeBox" ) );

    sizeBox =new KComboBox( pages[1] );
    sizeBox->setObjectName( QLatin1String( "sizeBox" ) );
    QLabel * sizeL   =new QLabel(i18n("File &size is:"), pages[1]);
    sizeL->setBuddy( sizeBox );
    sizeEdit=new KIntSpinBox(pages[1] );
    sizeEdit->setRange( 0, INT_MAX );
    sizeEdit->setSingleStep( 1 );
    sizeEdit->setObjectName( QLatin1String( "sizeEdit" ) );
    sizeEdit->setValue(1);
    sizeUnitBox =new KComboBox( pages[1] );
    sizeUnitBox->setObjectName( QLatin1String( "sizeUnitBox" ) );

    m_usernameBox = new KComboBox( pages[1] );
    m_usernameBox->setEditable( true );
    m_usernameBox->setObjectName( QLatin1String( "m_combo1" ));
    QLabel *usernameLabel= new QLabel(i18n("Files owned by &user:"******"m_combo2" ) );
    QLabel *groupLabel= new QLabel(i18n("Owned by &group:"),pages[1]);
    groupLabel->setBuddy( m_groupBox );

    sizeBox ->addItem( i18nc("file size isn't considered in the search","(none)") );
    sizeBox ->addItem( i18n("At Least") );
    sizeBox ->addItem( i18n("At Most") );
    sizeBox ->addItem( i18n("Equal To") );

    sizeUnitBox ->addItem( i18np("Byte", "Bytes", 1) );
    sizeUnitBox ->addItem( i18n("KiB") );
    sizeUnitBox ->addItem( i18n("MiB") );
    sizeUnitBox ->addItem( i18n("GiB") );
    sizeUnitBox ->setCurrentIndex(1);

    int tmp = sizeEdit->fontMetrics().width(QLatin1String(" 000000000 "));
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    m_usernameBox->setDuplicatesEnabled(false);
    m_groupBox->setDuplicatesEnabled(false);
    m_usernameBox->setInsertPolicy(QComboBox::InsertAtTop);
    m_groupBox->setInsertPolicy(QComboBox::InsertAtTop);


    // Setup
    rb[0]->setChecked(true);
    bg->addButton( rb[0] );
    bg->addButton( rb[1] );

    // Layout

    QGridLayout *grid1 = new QGridLayout( pages[1] );
    grid1->setMargin( KDialog::marginHint() );
    grid1->setSpacing( KDialog::spacingHint() );

    grid1->addWidget(findCreated, 0, 0, 1, 3 );
    grid1->addItem( new QSpacerItem(KDialog::spacingHint(), 0), 0, 0 );

    grid1->addWidget(rb[0], 1, 1 );
    grid1->addWidget(fromDate, 1, 2 );
    grid1->addWidget(andL, 1, 3, Qt::AlignHCenter );
    grid1->addWidget(toDate, 1, 4 );

    grid1->addWidget(rb[1], 2, 1 );
    grid1->addWidget(timeBox, 2, 2, 1, 2);
    grid1->addWidget(betweenType, 2, 4 );

    grid1->addWidget(sizeL,3,0,1,2);
    grid1->addWidget(sizeBox,3,2);
    grid1->addWidget(sizeEdit,3,3);
    grid1->addWidget(sizeUnitBox,3,4);

    grid1->addWidget(usernameLabel,4,0,1,2);
    grid1->addWidget(m_usernameBox,4,2);
    grid1->addWidget(groupLabel,4,3);
    grid1->addWidget(m_groupBox,4,4);

    for (int c=1; c<=4; c++)
       grid1->setColumnStretch(c,1);

    grid1->setRowStretch(6,1);

    // Connect
    connect(findCreated, &QCheckBox::toggled, this, &KfindTabWidget::fixLayout);
    connect(bg, static_cast<void (QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), this, &KfindTabWidget::fixLayout);
    connect(sizeBox, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &KfindTabWidget::slotSizeBoxChanged);
    connect(timeBox, static_cast<void (KIntSpinBox::*)(int)>(&KIntSpinBox::valueChanged), this, &KfindTabWidget::slotUpdateDateLabelsForNumber);
    connect(betweenType, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &KfindTabWidget::slotUpdateDateLabelsForType);
    connect(sizeEdit, static_cast<void (KIntSpinBox::*)(int)>(&KIntSpinBox::valueChanged), this, &KfindTabWidget::slotUpdateByteComboBox);


    // ************ Page Three

    pages[2] = new QWidget;
    pages[2]->setObjectName( QLatin1String( "page3" ) );

    typeBox =new KComboBox( pages[2] );
    typeBox->setObjectName( QLatin1String( "typeBox" ) );
    typeBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);  // allow smaller than widest entry
    QLabel * typeL   =new QLabel( i18nc("label for the file type combobox","File &type:"), pages[2] );
    typeL->setBuddy( typeBox );
    textEdit=new KLineEdit(pages[2]);
    textEdit->setClearButtonShown(true);
    textEdit->setObjectName( QLatin1String( "textEdit" ) );
    QLabel * textL   =new QLabel(i18n("C&ontaining text:"), pages[2]);
    textL->setBuddy( textEdit );

    connect(textEdit, &KLineEdit::returnPressed, this, &KfindTabWidget::startSearch);

    const QString containingtext
      = i18n("<qt>If specified, only files that contain this text"
	      " are found. Note that not all file types from the list"
		  " above are supported. Please refer to the documentation"
		  " for a list of supported file types."
	      "</qt>");
    textEdit->setToolTip(containingtext);
    textL->setWhatsThis(containingtext);

    caseContextCb  =new QCheckBox(i18n("Case s&ensitive"), pages[2]);
    binaryContextCb  =new QCheckBox(i18n("Include &binary files"), pages[2]);
    regexpContentCb  =new QCheckBox(i18n("Regular e&xpression"), pages[2]);

    const QString binaryTooltip
      = i18n("<qt>This lets you search in any type of file, "
       "even those that usually do not contain text (for example "
	   "program files and images).</qt>");
    binaryContextCb->setToolTip(binaryTooltip);

    QPushButton* editRegExp = 0;
    if ( !KServiceTypeTrader::self()->query(QStringLiteral("KRegExpEditor/KRegExpEditor")).isEmpty() ) {
        // The editor is available, so lets use it.
        editRegExp = new QPushButton(i18n("&Edit..."), pages[2]);
        editRegExp->setObjectName( QLatin1String( "editRegExp" ) );
    }

    metainfokeyEdit=new KLineEdit(pages[2]);
    metainfoEdit=new KLineEdit(pages[2]);
    QLabel * textMetaInfo = new QLabel(i18nc("as in search for", "fo&r:"), pages[2]);
    textMetaInfo->setBuddy( metainfoEdit );
    QLabel * textMetaKey = new QLabel(i18n("Search &metainfo sections:"), pages[2]);
    textMetaKey->setBuddy( metainfokeyEdit );

    // Setup
    typeBox->addItem(i18n("All Files & Folders"));
    typeBox->addItem(i18n("Files"));
    typeBox->addItem(i18n("Folders"));
    typeBox->addItem(i18n("Symbolic Links"));
    typeBox->addItem(i18n("Special Files (Sockets, Device Files, ...)"));
    typeBox->addItem(i18n("Executable Files"));
    typeBox->addItem(i18n("SUID Executable Files"));
    typeBox->addItem(i18n("All Images"));
    typeBox->addItem(i18n("All Video"));
    typeBox->addItem(i18n("All Sounds"));

    initMimeTypes();
    initSpecialMimeTypes();

    for ( KMimeType::List::ConstIterator it = m_types.constBegin();
          it != m_types.constEnd(); ++it )
    {
      KMimeType::Ptr typ = *it;
// TODO: needs to move to thread (increases startup time to bizzare amount)
//       and replaced with a better concept 16x16 icons don't cut the cheese
//       typeBox->addItem(KIconLoader::global()->loadMimeTypeIcon( typ->iconName(), KIconLoader::Small ), typ->comment());
      typeBox->addItem(typ->comment());
    }

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      connect(regexpContentCb, &QCheckBox::toggled, editRegExp, &QPushButton::setEnabled);
      editRegExp->setEnabled(false);
      connect(editRegExp, &QPushButton::clicked, this, &KfindTabWidget::slotEditRegExp);
    }
    else
        regexpContentCb->hide();

    // Layout
    tmp = sizeEdit->fontMetrics().width(QLatin1String(" 00000 "));
    sizeEdit->setMinimumSize(tmp, sizeEdit->sizeHint().height());

    QGridLayout *grid2 = new QGridLayout( pages[2] );
    grid2->setMargin( KDialog::marginHint() );
    grid2->setSpacing( KDialog::spacingHint() );
    grid2->addWidget( typeL, 0, 0 );
    grid2->addWidget( textL, 1, 0 );
    grid2->addWidget( typeBox, 0, 1, 1, 3 );
    grid2->addWidget( textEdit, 1, 1, 1, 3 );
    grid2->addWidget( regexpContentCb, 2, 2);
    grid2->addWidget( caseContextCb, 2, 1 );
    grid2->addWidget( binaryContextCb, 3, 1);

    grid2->addWidget( textMetaKey, 4, 0 );
    grid2->addWidget( metainfokeyEdit, 4, 1 );
    grid2->addWidget( textMetaInfo, 4, 2, Qt::AlignHCenter  );
    grid2->addWidget( metainfoEdit, 4, 3 );

    metainfokeyEdit->setText(QLatin1String("*"));

    if ( editRegExp ) {
      // The editor was available, so lets use it.
      grid2->addWidget( editRegExp, 2, 3 );
    }

    addTab( pages[0], i18n("Name/&Location") );
    addTab( pages[2], i18nc("tab name: search by contents","C&ontents") );
    addTab( pages[1], i18n("&Properties") );


    // Setup
    const QString whatsmetainfo
      = i18n("<qt>Search within files' specific comments/metainfo<br />"
	     "These are some examples:<br />"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> Search in id3 tag for a title, an album</li>"
	     "<li><b>Images (png...)</b> Search images with a special resolution, comment...</li>"
	     "</ul>"
	     "</qt>");
    const QString whatsmetainfokey
      = i18n("<qt>If specified, search only in this field<br />"
	     "<ul>"
	     "<li><b>Audio files (mp3...)</b> This can be Title, Album...</li>"
	     "<li><b>Images (png...)</b> Search only in Resolution, Bitdepth...</li>"
	     "</ul>"
	     "</qt>");
    textMetaInfo->setWhatsThis(whatsmetainfo);
    metainfoEdit->setToolTip(whatsmetainfo);
    textMetaKey->setWhatsThis(whatsmetainfokey);
    metainfokeyEdit->setToolTip(whatsmetainfokey);


    fixLayout();
    loadHistory();
}