Exemplo n.º 1
0
void QSearchLineEdit::searchStop()
{
	searchStarted = false;
	if (cancelPointer)
		*cancelPointer = true;
	emit searchCanceled();
	delete sPbar;
	sPbar = 0;
	//delete stopButton;
	stopButton = 0;
	setSearchProgressText("");
}
Exemplo n.º 2
0
void QSearchLineEdit::searchStart(bool* canceled, int min, int max)
{
//  if (searchStarted)
//  {
//      setSearchProgressText(tr("Another search in progress!"));
//      return;
//  }
    cancelPointer = canceled;
    searchStarted = true;
    if (cancelPointer) {
        *cancelPointer = false;
    }

    if (!maybeFound) {
        searchStop();
        setSearchProgressText(tr("Please try with another phrase!"));
    }

    if (!sPbar) {
        sPbar = new QProgressBar(this);
    }
    sPbar->setRange(min, max);

    if (!stopButton) {
        stopButton = new QToolButton(sPbar);
    }

    QPixmap stopPixmap(cancelButtonIcon.isEmpty() ? ":/images/cancel.png" : cancelButtonIcon);
    stopPixmap = stopPixmap.scaledToHeight((height() * 5) / 6 , Qt::SmoothTransformation);
    stopButton->setIcon(QIcon(stopPixmap));
    stopButton->setIconSize(stopPixmap.size());
    stopButton->setCursor(Qt::ArrowCursor);
    stopButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");

    sPbar->setStyleSheet(QString(" QProgressBar { background: transparent; border: none; padding-top: %1px; }").arg(qMax((sizeHint().height() - sPbar->sizeHint().height()) / 2, 0)));
    sPbar->setFixedSize(width(), height());

    //stopButton->show();
    sPbar->show();

//  qDebug() << "sizeHint-TOP=" <<(sizeHint().height()-sPbar->sizeHint().height())/2;
//  qDebug() << "size-TOP=" <<(height()-sPbar->height())/2;
    sPbar->setStyleSheet(QString(" QProgressBar { background: transparent; padding-top: %1px; border: none; /* border-radius: 5px;*/}").arg(qMax((height() - sPbar->sizeHint().height()) / 2, 0)));
    sPbar->setFixedSize(width(), height());
//  qDebug() << "prog-height=" <<sPbar->height();
//  qDebug() << "prog-Hint-height=" <<sPbar->sizeHint().height();
//  qDebug() << "lineEdit-height=" <<height();
//  qDebug() << "lineEdit-Hint-height=" <<sizeHint().height();

    connect(stopButton, SIGNAL(clicked()), this, SLOT(searchStop()));
}