Esempio n. 1
0
void SearchLineEdit::searchFinished( int id, Okular::Document::SearchStatus endStatus )
{
    // ignore the searches not started by this search edit
    if ( id != m_id )
        return;

    // if not found, use warning colors
    if ( endStatus == Okular::Document::NoMatchFound )
    {
        QPalette pal = palette();
        const KColorScheme scheme( QPalette::Active, KColorScheme::View );
        pal.setBrush( QPalette::Base, scheme.background( KColorScheme::NegativeBackground ) );
        pal.setBrush( QPalette::Text, scheme.foreground( KColorScheme::NegativeText ) );
        setPalette( pal );
    }
    else
    {
        QPalette pal = palette();
        const QPalette qAppPalette = QApplication::palette();
        pal.setColor( QPalette::Base, qAppPalette.color( QPalette::Base ) );
        pal.setColor( QPalette::Text, qAppPalette.color( QPalette::Text ) );
        setPalette( pal );
    }

    if ( endStatus == Okular::Document::EndOfDocumentReached ) {
        const bool forward = m_searchType == Okular::Document::NextMatch;
        const QString question = forward ? i18n("End of document reached.\nContinue from the beginning?") : i18n("Beginning of document reached.\nContinue from the bottom?");
        if ( KMessageBox::questionYesNo(window(), question, QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::Yes ) {
            m_document->continueSearch( m_id, m_searchType );
            return;
        }
    }

    m_searchRunning = false;
    emit searchStopped();
}
Esempio n. 2
0
/* 
 *  Constructs a KBabelDictView which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 */
KBabelDictView::KBabelDictView( QWidget* parent,  const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    QVBoxLayout    *mainLayout = new QVBoxLayout(this);
    mainLayout->setSpacing(KDialog::spacingHint());
    mainLayout->setMargin(KDialog::marginHint());

    splitter = new QSplitter(this);
    mainLayout->addWidget(splitter);

    QWidget *w = new QWidget(splitter);
    QVBoxLayout *wLayout= new QVBoxLayout(w);
    wLayout->setSpacing(KDialog::spacingHint());
    wLayout->setMargin(KDialog::marginHint());
    
    QHBoxLayout *hbox = new QHBoxLayout(wLayout);
    QLabel *label = new QLabel(i18n("Search in module:"), w);
    hbox->addWidget(label);
    moduleCombo = new KComboBox(w);
    hbox->addWidget(moduleCombo);

    QWidget *temp = new QWidget(w);
    hbox->addWidget(temp);
    hbox->setStretchFactor(temp,2);
    editButton = new QPushButton(i18n("&Edit"),w);
    editButton->setEnabled(false);
    hbox->addWidget(editButton);

    // added a button "clear search" here
    hbox = new QHBoxLayout(wLayout);
    QPushButton* clearButton = new QPushButton(w);
    clearButton->setFlat(true);
    clearButton->setPixmap(SmallIcon("locationbar_erase"));
    hbox->addWidget(clearButton);
    textEdit = new KLineEdit(w,"textedit");
    textEdit->setFocus();
    hbox->addWidget(textEdit);

    hbox = new QHBoxLayout(wLayout);
    startButton = new QPushButton(i18n("&Start Search"),w);
    hbox->addWidget(startButton);
    inTransButton = new QCheckBox(i18n("Sea&rch in translations"),w);
    hbox->addWidget(inTransButton);
    hbox->addStretch(1);
    stopButton = new QPushButton(i18n("S&top"),w);
    stopButton->setEnabled(false);
    hbox->addWidget(stopButton);

    KSeparator *sep = new KSeparator(w);
    wLayout->addWidget(sep);
    dictBox = new KBabelDictBox(w,"kbabeldictbox");
    wLayout->addWidget(dictBox);

    prefWidget = new QWidget(splitter);
    QVBoxLayout *tempLayout= new QVBoxLayout(prefWidget);
    tempLayout->setSpacing(KDialog::spacingHint());
    tempLayout->setMargin(KDialog::marginHint());

    label = new QLabel(i18n("Settings:"),prefWidget);
    tempLayout->addWidget(label);
    
    prefStack = new QWidgetStack(prefWidget);
    tempLayout->addWidget(prefStack);
    tempLayout->addStretch(1);

    KConfig *config = KGlobal::config();
    dictBox->readSettings(config);
    dictBox->setAutoUpdateOptions(true);
           
    QStringList modules = dictBox->moduleNames();
    moduleCombo->insertStringList(modules);

    QPtrList<PrefWidget> prefs = dictBox->modPrefWidgets(prefStack);
    prefs.setAutoDelete(false);

    PrefWidget *p;
    int i=0;
    for(p = prefs.first(); p != 0; p=prefs.next())
    {
        prefStack->addWidget(p,i);
        i++;
    }

    int active=dictBox->activeModule();
    prefStack->raiseWidget(active);
    moduleCombo->setCurrentItem(active);


    QHBox *h = new QHBox(this);
    h->setSpacing(KDialog::spacingHint());
    mainLayout->addWidget(h);
    progressLabel = new QLabel(h);
    progressBar = new KProgress(h);

    connect(textEdit,SIGNAL(returnPressed()),startButton,SLOT(animateClick()));
    connect(startButton,SIGNAL(clicked()),this, SLOT(startSearch()));
    connect(stopButton, SIGNAL(clicked()), dictBox,SLOT(slotStopSearch()));
    connect(editButton, SIGNAL(clicked()), dictBox, SLOT(edit()));
    connect(dictBox, SIGNAL(searchStarted()), this, SLOT(searchStarted()));
    connect(dictBox, SIGNAL(searchStopped()), this, SLOT(searchStopped()));
    connect(dictBox, SIGNAL(progressed(int)), progressBar, SLOT(setProgress(int)));
    connect(dictBox, SIGNAL(activeModuleChanged(bool))
            , editButton, SLOT(setEnabled(bool)));
    
    connect(dictBox, SIGNAL(progressStarts(const QString&))
            , this, SLOT(progressStarted(const QString&)));
    connect(dictBox, SIGNAL(progressEnds()), this, SLOT(progressStopped()));
    
    connect(moduleCombo, SIGNAL(activated(int)), 
                    dictBox, SLOT(setActiveModule(int)));
    connect(dictBox, SIGNAL(activeModuleChanged(int))
                    , this, SLOT(switchModule(int)));
    connect(clearButton, SIGNAL(clicked()), this, SLOT(slotClearSearch()));
}