SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) {
+ qDebug()<<"test1";
#ifndef Q_WS_MAEMO_5
this->setMaximumHeight(50);
+ busyTimer=new QTimer;
+
+ progressBar = new QDeclarativeView();
+ progressBar->setSource(QUrl("src/mdictionary/qml/ProgressBar.qml"));
+ progressBar->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ progressBar->setAlignment(Qt::AlignCenter);
+ progressBar->hide();
view= new QDeclarativeView();
view->setSource(QUrl("src/mdictionary/qml/SearchBarWidget.qml"));
view->show();
mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(progressBar);
mainLayout->addWidget(view);
setLayout(mainLayout);
QGraphicsObject *rootObject = view->rootObject();
+ QGraphicsObject *rootObject2 = progressBar->rootObject();
connect(rootObject, SIGNAL(searchButtonClicked(QString)),
this, SLOT(searchButtonClicked(QString)));
connect(rootObject, SIGNAL(historyPrevToolButtonClicked()),
this, SIGNAL(historyPrev()));
connect(rootObject, SIGNAL(historyShowToolButtonClicked()),
- this, SIGNAL(historyShow()));
+ this, SLOT(showHistoryButtonClicked()));
+
+ connect(this, SIGNAL(progresSetMax(QVariant)),
+ rootObject2, SLOT(setMax(QVariant)));
+ connect(this, SIGNAL(progresSetMin(QVariant)),
+ rootObject2, SLOT(setMin(QVariant)));
+ connect(this, SIGNAL(progresSetValue(QVariant)),
+ rootObject2, SLOT(setValue(QVariant)));
+ connect(this, SIGNAL(progresSetValue2(QVariant)),
+ rootObject2, SLOT(setValue2(QVariant)));
connect(this, SIGNAL(setEnableHistoryNext(QVariant)),
rootObject, SLOT(setEnableHistoryNext(QVariant)));
connect(this, SIGNAL(setLineEditEnables(QVariant)),
rootObject, SLOT(setEnableLineEdit(QVariant)));
+ connect(busyTimer, SIGNAL(timeout()),
+ this, SLOT(updateBusyTimer()));
+
emit setEnableHistoryNext(false);
emit setEnableHistoryShow(false);
emit setEnableHistoryPrev(false);
completerModel = new QStringListModel(this);
- connect(&delayTimer, SIGNAL(timeout()),
- this, SLOT(delaySearchTimeout()));
+ // connect(&delayTimer, SIGNAL(timeout()),
+ // this, SLOT(delaySearchTimeout()));
+
+ view->setFocus();
+
#else
initializeUI();
connect(searchPushButton, SIGNAL(clicked()),
}
QIcon SearchBarWidget::generateIcon(QIcon original, qreal rotation) {
+ qDebug()<<"test2";
QPixmap p = original.pixmap(64);
if(rotation != 0) {
}
void SearchBarWidget::setFocus() {
-#ifdef Q_WS_MAEMO_5
+ qDebug()<<"test3";
+#ifndef Q_WS_MAEMO_5
+ view->setFocus();
+#else
searchWordLineEdit->setFocus();
#endif
}
void SearchBarWidget::initializeUI() {
+ qDebug()<<"test4";
#ifdef Q_WS_MAEMO_5
setMaximumHeight(150);
}
void SearchBarWidget::searchButtonClicked(QString text) {
+ qDebug()<<"test5";
if(busy)
Q_EMIT stopSearching();
else
}
void SearchBarWidget::searchPushButtonClicked() {
+ qDebug()<<"test6";
#ifdef Q_WS_MAEMO_5
if(busy) {
Q_EMIT stopSearching();
}
void SearchBarWidget::search(QString word) {
+ qDebug()<<"test7";
qDebug()<<word;
if(!busy && !word.isEmpty()) {
completerModel->insertRow(completerModel->rowCount());
}
void SearchBarWidget::searchDelay(QString word) {
+ qDebug()<<"test8";
if(!busy && !word.isEmpty()) {
#ifndef Q_WS_MAEMO_5
emit setLineEditText(word);
}
void SearchBarWidget::delaySearchTimeout() {
+ qDebug()<<"test9";
delayTimer.stop();
if(!busy) {
Q_EMIT searchForTranslations(delayString);
}
void SearchBarWidget::setEnabled(bool enabled) {
+ qDebug()<<"test10";
#ifndef Q_WS_MAEMO_5
emit setLineEditEnables(enabled);
if(!enabled) {
+ qDebug()<<"tu???";
emit setEnableHistoryNext(false);
emit setEnableHistoryShow(false);
emit setEnableHistoryPrev(false);
}
void SearchBarWidget::setBusy() {
+ qDebug()<<"test11";
if(busy) return;
#ifndef Q_WS_MAEMO_5
+ busyTimer->start(500);
emit setButtonText(tr("Stop"));
-// searchingProgressBar->show();
+ this->setMaximumHeight(88);
+ progressBar->show();
+ emit progresSetMax(100);
+ emit progresSetMin(0);
+ emit progresSetValue(-1);
+ emit progresSetValue2(100);
+ progressMax=true;
#else
searchingProgressBar->show();
searchPushButton->setText(tr("Stop"));
busy = true;
}
+void SearchBarWidget::updateBusyTimer(){
+ // qDebug()<<"test12";
+ if(progressMax==true){
+ emit progresSetValue2(0);
+ progressMax=false;
+ }
+ else{
+ emit progresSetValue2(100);
+ progressMax=true;
+ }
+ busyTimer->start(500);
+}
+
void SearchBarWidget::setIdle() {
+ qDebug()<<"test13";
if(!busy) return;
#ifndef Q_WS_MAEMO_5
-// searchingProgressBar->hide();
+ progressBar->hide();
+ busyTimer->stop();
+ emit progresSetValue2(0);
+ this->setMaximumHeight(50);
emit setButtonText(tr("Search"));
#else
searchingProgressBar->hide();
void SearchBarWidget::clearSearchWordToolButtonClicked() {
+ qDebug()<<"test14";
#ifdef Q_WS_MAEMO_5
searchWordLineEdit->clear();
#endif
void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool list) {
+ qDebug()<<"test15";
if(!busy) {
#ifndef Q_WS_MAEMO_5
emit setEnableHistoryNext(next);
}
void SearchBarWidget::showHistoryButtonClicked() {
+ qDebug()<<"test16";
#ifndef Q_WS_MAEMO_5
QPoint p=view->pos(); // = historyShowToolButton->pos();
- p.setY(p.y());
- emit historyShow(mapToGlobal(p));
- #else
+ p=mapToGlobal(p);
+ p.setX(p.x()+view->width());
+ emit historyShow(p);
+#else
emit historyShow();
#endif
}
import Qt 4.7
-Item {
+Rectangle {
id: progressBar
property int minimum: 0
property int maximum: 100
- property int value: 0
- property alias color: gradient1.color
- property alias secondColor: gradient2.color
+ property int value: -1
+ property int value2: 50
function setMax(intiger) { maximum=intiger }
function setMin(intiger) { minimum=intiger }
function setValue(intiger) { value= intiger }
+ function setValue2(intiger) { value2= intiger }
width: 250;
height: 23
clip: true
BorderImage {
- source: "background.png"
+ source: "qrc:/progressBar/background.png"
width: parent.width; height: parent.height
border { left: 4; top: 4; right: 4; bottom: 4 }
}
+
Rectangle {
id: highlight
+ z: 1;
+
+ property int widthDest: (progressBar.width * (value - minimum)) / (maximum - minimum) - 6
+ property int position: (progressBar.width * (value2 - minimum)) / (maximum - minimum)
- property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
+ width: (value>-1) ? (highlight.widthDest) : (90)
+ anchors.leftMargin: (value>-1) ? (0) : (highlight.position)
- width: highlight.widthDest
- Behavior on width { SmoothedAnimation { velocity: 1200 } }
+ Behavior on width {
+ SmoothedAnimation {
+ velocity: 1200
+ }
+ }
+
+ Behavior on anchors.leftMargin {
+ SequentialAnimation{
+ loops: Animation.Infinite
+ SmoothedAnimation { velocity: 450; to: progressBar.width - 96}
+ SmoothedAnimation { velocity: 450; to: 0 }
+ }
+ }
- anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
radius: 1
+ anchors.top: parent.top
+ anchors.left: parent.left
+
+ anchors.bottom: parent.bottom
+ anchors.margins: 3
+
gradient: Gradient {
- GradientStop { id: gradient1; position: 0.0 }
- GradientStop { id: gradient2; position: 1.0 }
+ GradientStop {color:"#0510a0"; position: 0.0 }
+ GradientStop {color:"#6b98f7"; position: 1.0 }
}
}
Text {
- anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ z: 1;
+ anchors.right: highlight.right
+ anchors.rightMargin: (value>-1) ? 6 : 35;
+ anchors.verticalCenter: parent.verticalCenter
color: "white"
font.bold: true
- text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
+ text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("???");
}
}