<file>button/buttonCenter.png</file>
<file>button/buttonLeft.png</file>
<file>button/buttonR.png</file>
+ <file>button/go-previous.png</file>
</qresource>
</RCC>
QGraphicsObject *rootObject = view->rootObject();
connect(rootObject, SIGNAL(linkClicked(QString)), this, SLOT(openUrl(QString)));
this->setLayout(mainLayout);
+
#else
setModal(true);
QString infoNote, licenseNote, comarchNote;
private:
QDeclarativeView *view;
-
QVBoxLayout* mainLayout;
+
QVBoxLayout *scrollLayout;
QLabel* mainLabel, * licenseLabel, *imageLabel;
QScrollArea* scroll;
splitter->setStretchFactor(1, 150);
mainLayout->addWidget(splitter, 1);
- mainLayout->addWidget(searchBarWidget, 0, Qt::AlignBottom);
+
+ mainLayout->addWidget(searchBarWidget,0, Qt::AlignBottom);
#endif
}
return backbone->getDictionaries();
}
-
+/**/
void MainWindow::search(QString word) {
setExactSearch(false);
searchBarWidget->search(word);
SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) {
+#ifndef Q_WS_MAEMO_5
+ this->setMaximumHeight(50);
- initializeUI();
+ view= new QDeclarativeView();
+ view->setSource(QUrl("src/mdictionary/qml/SearchBarWidget.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
- busy = false;
+ QGraphicsObject *rootObject = view->rootObject();
+ connect(rootObject, SIGNAL(searchButtonClicked(QString)),
+ this, SLOT(searchButtonClicked(QString)));
+ connect(rootObject, SIGNAL(historyNextToolButtonClicked()),
+ this, SIGNAL(historyNext()));
+ connect(rootObject, SIGNAL(historyPrevToolButtonClicked()),
+ this, SIGNAL(historyPrev()));
+ connect(rootObject, SIGNAL(historyShowToolButtonClicked()),
+ this, SIGNAL(historyShow()));
+
+ connect(this, SIGNAL(setEnableHistoryNext(QVariant)),
+ rootObject, SLOT(setEnableHistoryNext(QVariant)));
+ connect(this, SIGNAL(setEnableHistoryShow(QVariant)),
+ rootObject, SLOT(setEnableHistoryShow(QVariant)));
+ connect(this, SIGNAL(setEnableHistoryPrev(QVariant)),
+ rootObject, SLOT(setEnableHistoryPrev(QVariant)));
+ connect(this, SIGNAL(setButtonText(QVariant)),
+ rootObject, SLOT(setButtonText(QVariant)));
+ connect(this, SIGNAL(setLineEditText(QVariant)),
+ rootObject, SLOT(setLineEditText(QVariant)));
+ connect(this, SIGNAL(setLineEditEnables(QVariant)),
+ rootObject, SLOT(setEnableLineEdit(QVariant)));
+
+ emit setEnableHistoryNext(false);
+ emit setEnableHistoryShow(false);
+ emit setEnableHistoryPrev(false);
+
+ completerModel = new QStringListModel(this);
+ connect(&delayTimer, SIGNAL(timeout()),
+ this, SLOT(delaySearchTimeout()));
+#else
+ initializeUI();
connect(searchPushButton, SIGNAL(clicked()),
this, SLOT(searchPushButtonClicked()));
-
connect(searchWordLineEdit, SIGNAL(returnPressed()),
this, SLOT(searchPushButtonClicked()));
-
connect(historyNextToolButton, SIGNAL(clicked()),
this, SIGNAL(historyNext()));
-
connect(historyPrevToolButton, SIGNAL(clicked()),
this, SIGNAL(historyPrev()));
-
connect(historyShowToolButton, SIGNAL(clicked()),
this, SLOT(showHistoryButtonClicked()));
-
connect(clearSearchWordToolButton, SIGNAL(clicked()),
this, SLOT(clearSearchWordToolButtonClicked()));
-
-
connect(&delayTimer, SIGNAL(timeout()),
this, SLOT(delaySearchTimeout()));
searchWordLineEdit->setFocus();
+#endif
- historyPrevToolButton->setEnabled(false);
- historyNextToolButton->setEnabled(false);
- historyShowToolButton->setEnabled(false);
-
+ busy = false;
setEnabled(true);
+ updateHistoryButtons(false,false,false);
}
SearchBarWidget::~SearchBarWidget() {
QIcon SearchBarWidget::generateIcon(QIcon original, qreal rotation) {
QPixmap p = original.pixmap(64);
-
if(rotation != 0) {
QMatrix m;
m.rotate(rotation);
return newIcon;
}
-
void SearchBarWidget::setFocus() {
- searchWordLineEdit->setFocus();
+#ifdef Q_WS_MAEMO_5
+ searchWordLineEdit->setFocus();
+#endif
}
void SearchBarWidget::initializeUI() {
-
- #ifdef Q_WS_MAEMO_5
- setMaximumHeight(150);
- #else
- setMaximumHeight(100);
- #endif
-
+#ifdef Q_WS_MAEMO_5
+ setMaximumHeight(150);
horizontalLayout = new QHBoxLayout;
verticalLayout = new QVBoxLayout;
-
searchPushButton = new QPushButton(tr("Search"));
searchPushButton->setMinimumWidth(125);
-
searchWordLineEdit = new QLineEdit;
searchWordLineEdit->setMinimumWidth(250);
-
-
completerModel = new QStringListModel(this);
-
lineEditCompleter = new QCompleter(searchWordLineEdit);
lineEditCompleter->setModel(completerModel);
lineEditCompleter->setCaseSensitivity(Qt::CaseInsensitive);
lineEditCompleter->setCompletionMode(QCompleter::InlineCompletion);
searchWordLineEdit->setCompleter(lineEditCompleter);
-
#ifndef Q_WS_MAEMO_5
searchWordLineEdit->setMinimumHeight(
searchWordLineEdit->sizeHint().height()*3/2);
#endif
-
//create layout for lineEdit to have clear button on it
QHBoxLayout* lineEditLayout = new QHBoxLayout;
searchWordLineEdit->setLayout(lineEditLayout);
#endif
searchingProgressBar->hide();
-
setLayout(verticalLayout);
verticalLayout->addWidget(searchingProgressBar);
//adding clear toolButton to textEdit with right alignment
lineEditLayout->addWidget(clearSearchWordToolButton, 0, Qt::AlignRight);
-
verticalLayout->addLayout(horizontalLayout);
+#endif
}
+void SearchBarWidget::searchButtonClicked(QString text) {
+ if(busy)
+ Q_EMIT stopSearching();
+ else
+ search(text);
+}
void SearchBarWidget::searchPushButtonClicked() {
+#ifdef Q_WS_MAEMO_5
if(busy) {
Q_EMIT stopSearching();
}
else {
search(searchWordLineEdit->text());
}
+#endif
}
-
void SearchBarWidget::search(QString word) {
+ qDebug()<<word;
if(!busy && !word.isEmpty()) {
completerModel->insertRow(completerModel->rowCount());
- QModelIndex index =
- completerModel->index(completerModel->rowCount() -1);
-
+ QModelIndex index=completerModel->index(completerModel->rowCount() -1);
completerModel->setData(index, word);
-
+#ifndef Q_WS_MAEMO_5
+ emit setLineEditText(word);
+#else
searchWordLineEdit->setText(word);
+#endif
Q_EMIT searchForTranslations(word);
}
}
void SearchBarWidget::searchDelay(QString word) {
if(!busy && !word.isEmpty()) {
- searchWordLineEdit->setText(word);
+ #ifndef Q_WS_MAEMO_5
+ emit setLineEditText(word);
+ #else
+ searchWordLineEdit->setText(word);
+ #endif
+ if(delayTimer.isActive())
+ delayTimer.stop();
+ delayString = word;
+ delayTimer.start(500);
-
- if(delayTimer.isActive()) {
- delayTimer.stop();
- }
-
- delayString = word;
- delayTimer.start(500);
}
}
}
void SearchBarWidget::setEnabled(bool enabled) {
+#ifndef Q_WS_MAEMO_5
+ emit setLineEditEnables(enabled);
+ if(!enabled) {
+ emit setEnableHistoryNext(false);
+ emit setEnableHistoryShow(false);
+ emit setEnableHistoryPrev(false);
+ }
+#else
searchWordLineEdit->setEnabled(enabled);
-
if(!enabled) {
historyPrevToolButton->setEnabled(false);
historyNextToolButton->setEnabled(false);
historyShowToolButton->setEnabled(false);
}
+#endif
}
void SearchBarWidget::setBusy() {
if(busy) return;
+
+#ifndef Q_WS_MAEMO_5
+ emit setButtonText(tr("Stop"));
+// searchingProgressBar->show();
+#else
searchingProgressBar->show();
searchPushButton->setText(tr("Stop"));
+#endif
+
setEnabled(false);
busy = true;
}
void SearchBarWidget::setIdle() {
if(!busy) return;
+#ifndef Q_WS_MAEMO_5
+// searchingProgressBar->hide();
+ emit setButtonText(tr("Search"));
+#else
searchingProgressBar->hide();
searchPushButton->setText(tr("Search"));
+#endif
setEnabled(true);
busy = false;
Q_EMIT refreshHistoryButtons();
void SearchBarWidget::clearSearchWordToolButtonClicked() {
+#ifdef Q_WS_MAEMO_5
searchWordLineEdit->clear();
+#endif
}
void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool list) {
if(!busy) {
- historyPrevToolButton->setEnabled(prev);
- historyNextToolButton->setEnabled(next);
- historyShowToolButton->setEnabled(list);
+ #ifndef Q_WS_MAEMO_5
+ emit setEnableHistoryNext(next);
+ emit setEnableHistoryShow(list);
+ emit setEnableHistoryPrev(prev);
+ #else
+ historyPrevToolButton->setEnabled(prev);
+ historyNextToolButton->setEnabled(next);
+ historyShowToolButton->setEnabled(list);
+ #endif
}
}
void SearchBarWidget::showHistoryButtonClicked() {
- #ifdef Q_WS_MAEMO_5
- emit historyShow();
- #else
- QPoint p = historyShowToolButton->pos();
- p.setY(p.y());
- emit historyShow(mapToGlobal(p));
- #endif
+#ifndef Q_WS_MAEMO_5
+ QPoint p=view->pos(); // = historyShowToolButton->pos();
+ p.setY(p.y());
+ emit historyShow(mapToGlobal(p));
+ #else
+ emit historyShow();
+#endif
}
#include <QWidget>
#include <QtGui>
+#include <QDeclarativeView>
+
#include "../backbone/backbone.h"
#include "../../include/History.h"
~SearchBarWidget();
Q_SIGNALS:
+
+ void setEnableHistoryNext(QVariant enable);
+ void setEnableHistoryShow(QVariant enable);
+ void setEnableHistoryPrev(QVariant enable);
+ void setButtonText(QVariant text);
+ void setLineEditText(QVariant text);
+ void setLineEditEnables(QVariant enabled);
+
//! Requests to search for a list of words matching a word passed as
//! a parameter
void searchForTranslations(QString);
void refreshHistoryButtons();
public Q_SLOTS:
+
+ void searchButtonClicked(QString text);
+
//! Enables or disables search word line edit and history buttons
/*!
While searching it disables only history button and line edit.
private:
+
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
QLineEdit* searchWordLineEdit;
QCompleter* lineEditCompleter;
QStringListModel* completerModel;
qml/AboutWidget.qml \
qml/SearchBarWidget.qml \
qml/IconButton.qml \
- qml/MyTextLineEdit.qml
+ qml/MyTextLineEdit.qml \
+ qml/ProgressBar.qml
target.path = $$BIN_DIR
INSTALLS += target
css_images.files += ../../data/css_meego/images/shadow-white-bg.png
css_images.files += ../../data/css_meego/images/tab-background.png
css_images.files += ../../data/css_meego/images/key-background.png
- css_images.files += ../../data/css_meego/images/shadow-transparent-bg. png
- css_images.files += ../../data/css_meego/images/splash2.png
+ css_images.files += ../../data/css_meego/images/shadow-transparent-bg. png
+ css_images.files += ../../data/css_meego/images/splash2.png
}
else:maemo5 {
css.path = $$DATA_DIR/css
qmls.files += ./qml/SearchBarWidget.qml
qmls.files += ./qml/IconButton.qml
qmls.files += ./qml/MyTextLineEdit.qml
+ qmls.files += ./qml/ProgressBar.qml
}
INSTALLS += desktop icon64 shared service css css_images qmls
Rectangle {
id: item
- //width: 400;
- // height: 400;
opacity: 1
anchors.fill: parent
anchors.horizontalCenterOffset: 0
onLinkActivated: linkClicked(link);
}
-
- Button{
- x:100;
- y:100;
- width: 500
- height: 30
- textInButton: "ala ma kota"
- }
-
- SearchBarWidget {
- id: searchbarwidget1
- y:50;
- width: item.width;
- height: 30;
- }
}
signal clicked
opacity: 1
+ function setText(string) { textInButton = string; }
border { left: 10; top: 10; right: 10; bottom: 10 }
MouseArea {
id: mouseArea
anchors.centerIn: parent;
+ width: parent.width;
+ height: parent.height;
+ onClicked: {
+ button.clicked();
+ }
+ }
+
+ Text {
+ z:1
+ id: buttonText
+ anchors.centerIn: parent;
+ font.pixelSize: parent.height * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ Rectangle {
+ id: shade
+ anchors.centerIn: parent;
+ radius: parent.height*.4;
+ color: "black";
+ opacity: 0
+ width: parent.width;
+ height: parent.height;
+ }
+
+ Image {
+ id: image1
+ width: (35*parent.height)/107 +1
+ height: parent.height
+ anchors.left: parent.left
+ source: "qrc:/button/buttonLeft.png"
+ }
+
+ Image {
+ id: image3
+ smooth: true
+ width: parent.width - ((70*parent.height)/107) +1;
+ height: parent.height
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "qrc:/button/buttonCenter.png"
+ }
+
+ Image {
+ id: image2
+ smooth: true
+ width: (35*parent.height)/107 +1
+ height: parent.height
+ anchors.right: parent.right
+ source: "qrc:/button/buttonR.png"
+ }
+
+ states: [
+ State {
+ name: "pressed"; when: mouseArea.pressed == true
+ PropertyChanges { target: shade; opacity: 0.4 }
+ PropertyChanges { target: image1; opacity: 0.5 }
+ PropertyChanges { target: image3; opacity: 0.5 }
+ PropertyChanges { target: image2; opacity: 0.5 }
+ }
+ ]
+
+
+
+/* MouseArea {
+ id: mouseArea
+ anchors.centerIn: parent;
width: ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107)
height: parent.height
onClicked: {
anchors.centerIn: parent;
font.pixelSize: parent.height * .5
style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ PropertyChanges {
+ target: button;
+ width: (button.width> buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.8)
+ }
}
Rectangle {
Image {
id: image1
- smooth: true
width: (35*parent.height)/107 +1
height: parent.height
anchors.left: parent.left
PropertyChanges { target: image2; opacity: 0.5 }
}
]
+ */
}
id: rectangle1
radius: 10
border.color: "#000666";
+ property alias textInLineEdit:text_input1.text
+
+ signal enterPressed(string text);
+
+ function setText(string) { textInLineEdit = string; }
TextInput {
id: text_input1
selectByMouse: true;
font.pixelSize: rectangle1.height * .5;
onCursorPositionChanged: moveCursorSelection(cursorPosition);
+ activeFocusOnPress: true;
+ Keys.onPressed: {
+ if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
+ rectangle1.enterPressed(text_input1.text)
+ }
}
+
+ Rectangle {
+ id: shadeDisable
+ anchors.centerIn: parent;
+ radius: parent.radius
+ color: "grey";
+ opacity: 0
+ width: parent.width;
+ height: parent.height;
+ }
+
+ states: [
+ State {
+ name: "FokusState"; when: text_input1.focus==true && rectangle1.enabled==true;
+ PropertyChanges {
+ target: rectangle1
+ border.width: 3
+ }
+ },
+ State {
+ name: "DisableState"; when: rectangle1.enabled==false;
+ PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
+ }
+ ]
}
--- /dev/null
+import Qt 4.7
+
+Item {
+ id: progressBar
+
+ property int minimum: 0
+ property int maximum: 100
+ property int value: 0
+ property alias color: gradient1.color
+ property alias secondColor: gradient2.color
+
+ function setMax(intiger) { maximum=intiger }
+ function setMin(intiger) { minimum=intiger }
+ function setValue(intiger) { value= intiger }
+
+ width: 250;
+ height: 23
+ clip: true
+
+ BorderImage {
+ source: "background.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ Rectangle {
+ id: highlight
+
+ property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
+
+ width: highlight.widthDest
+ Behavior on width { SmoothedAnimation { velocity: 1200 } }
+
+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
+ radius: 1
+ gradient: Gradient {
+ GradientStop { id: gradient1; position: 0.0 }
+ GradientStop { id: gradient2; position: 1.0 }
+ }
+ }
+
+ Text {
+ anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ color: "white"
+ font.bold: true
+ text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
+ }
+}
Rectangle {
id: searchBarWidget
-
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
color : myPalette.window;
+ property alias enableLineEdit: inputSearchText.enabled;
+
+ function setButtonText(string) { searchButton.setText(string) }
+ function setEnableHistoryPrev(Boolean) { historyPrevToolButton.enabled = Boolean }
+ function setEnableHistoryNext(Boolean) { historyNextToolButton.enabled = Boolean }
+ function setEnableHistoryShow(Boolean) { historyShowToolButton.enabled = Boolean }
+ function setEnableLineEdit(Boolean) { enableLineEdit = Boolean }
+ function setLineEditText(string) { inputSearchText.setText(string) }
+
+ signal searchButtonClicked(string text);
+ signal historyNextToolButtonClicked;
+ signal historyShowToolButtonClicked;
+ signal historyPrevToolButtonClicked;
+
MyTextLineEdit{
id: inputSearchText
width: (searchBarWidget.width - (searchBarWidget.height*3.5 + searchButton.width + 9));
- height: searchBarWidget.height
- anchors.left: searchBarWidget.left
+ height: searchBarWidget.height -1;
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ onEnterPressed: searchBarWidget.searchButtonClicked(text);
IconButton {
id: clearButton;
width: inputSearchText.height-6;
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
enabled: true;
- pathToIcon: "/home/jakub/go-previous.png";
+ pathToIcon: "qrc:/button/go-previous.png";
}
}
width: 100
height: searchBarWidget.height;
anchors.rightMargin: 3
- anchors.right: historyButton3.left
+ anchors.right: historyPrevToolButton.left
anchors.verticalCenter: parent.verticalCenter
textInButton: "Search"
+ onClicked: searchBarWidget.searchButtonClicked(inputSearchText.textInLineEdit);
}
IconButton {
- id: historyButton1;
+ id: historyNextToolButton;
width: searchBarWidget.height
height: searchBarWidget.height
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
enabled: true;
- pathToIcon: "/home/jakub/go-previous.png";
+ pathToIcon: "qrc:/button/go-previous.png";
+ onClicked: searchBarWidget.historyNextToolButtonClicked();
}
IconButton {
- id: historyButton2;
+ id: historyShowToolButton;
width: searchBarWidget.height
height: searchBarWidget.height
anchors.rightMargin: 3
- anchors.right: historyButton1.left
+ anchors.right: historyNextToolButton.left
anchors.verticalCenter: parent.verticalCenter
enabled: true;
- pathToIcon: "/home/jakub/go-previous.png";
+ pathToIcon: "qrc:/button/go-previous.png";
+ onClicked: searchBarWidget.historyShowToolButtonClicked();
}
IconButton {
- id: historyButton3;
+ id: historyPrevToolButton;
width: searchBarWidget.height
height: searchBarWidget.height
anchors.rightMargin: 3
- anchors.right: historyButton2.left
+ anchors.right: historyShowToolButton.left
anchors.verticalCenter: parent.verticalCenter
enabled: true;
- pathToIcon: "/home/jakub/go-previous.png";
+ pathToIcon: "qrc:/button/go-previous.png";
+ onClicked: searchBarWidget.historyPrevToolButtonClicked();
}
}
}
}
QString text = QString::fromUtf8(http->readAll());
+// qDebug()<<"google test"<<text;
text=jsonParse(text);
if(text!="") {
text="<key>" + word + "</key>" + "<t>" + text + "</t>";