diff --git a/qt/about.cpp b/qt/about.cpp index 6183f204c7..d3eebb93e7 100644 --- a/qt/about.cpp +++ b/qt/about.cpp @@ -15,7 +15,7 @@ AboutDialog::AboutDialog(QWidget * parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) { - QIcon icon(":logo.png"); + QIcon icon(":/ui/logo.png"); setWindowIcon(icon); setWindowTitle(QMenuBar::tr("About")); diff --git a/qt/info_dialog.cpp b/qt/info_dialog.cpp index 4ee9c6c243..089c6d4e9a 100644 --- a/qt/info_dialog.cpp +++ b/qt/info_dialog.cpp @@ -15,7 +15,7 @@ namespace qt QStringList const & buttons) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) { - QIcon icon(":logo.png"); + QIcon icon(":/ui/logo.png"); setWindowIcon(icon); setWindowTitle(title); setFocusPolicy(Qt::StrongFocus); diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 1f2e56235d..d20e791e06 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -54,7 +54,7 @@ MainWindow::MainWindow() setCentralWidget(m_pDrawWidget); setWindowTitle(tr("MapsWithMe")); - setWindowIcon(QIcon(":logo.png")); + setWindowIcon(QIcon(":/ui/logo.png")); #ifndef OMIM_OS_WINDOWS QMenu * helpMenu = new QMenu(tr("Help"), this); diff --git a/qt/preferences_dialog.cpp b/qt/preferences_dialog.cpp index 4f2f7bde12..9df9671ad5 100644 --- a/qt/preferences_dialog.cpp +++ b/qt/preferences_dialog.cpp @@ -16,7 +16,7 @@ namespace qt : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), m_autoUpdatesEnabled(autoUpdatesEnabled) { - QIcon icon(":logo.png"); + QIcon icon(":/ui/logo.png"); setWindowIcon(icon); setWindowTitle(tr("Preferences")); diff --git a/qt/res/busy.png b/qt/res/busy.png new file mode 100644 index 0000000000..9a193e4ee5 Binary files /dev/null and b/qt/res/busy.png differ diff --git a/qt/res/resources.qrc b/qt/res/resources.qrc index 0d31f65562..4d87d25bb9 100644 --- a/qt/res/resources.qrc +++ b/qt/res/resources.qrc @@ -18,7 +18,9 @@ location-search.png location.png - + logo.png + busy.png + x.png - + \ No newline at end of file diff --git a/qt/res/x.png b/qt/res/x.png new file mode 100644 index 0000000000..83e2950ed6 Binary files /dev/null and b/qt/res/x.png differ diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 8c65edecf8..4a6b214e04 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -3,10 +3,13 @@ #include "../std/bind.hpp" +#include #include #include #include #include +#include +#include namespace qt { @@ -26,8 +29,18 @@ SearchPanel::SearchPanel(DrawWidget * drawWidget, QWidget * parent) m_pTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); connect(m_pTable, SIGNAL(cellClicked(int,int)), this, SLOT(OnSearchPanelItemClicked(int,int))); + m_pClearButton = new QPushButton(this); + connect(m_pClearButton, SIGNAL(pressed()), this, SLOT(OnClearButton())); + m_pClearButton->setVisible(false); + m_pClearButton->setFocusPolicy(Qt::NoFocus); + m_pAnimationTimer = new QTimer(this); + connect(m_pAnimationTimer, SIGNAL(timeout()), this, SLOT(OnAnimationTimer())); + + QHBoxLayout * horizontalLayout = new QHBoxLayout(); + horizontalLayout->addWidget(m_pEditor); + horizontalLayout->addWidget(m_pClearButton); QVBoxLayout * verticalLayout = new QVBoxLayout(); - verticalLayout->addWidget(m_pEditor); + verticalLayout->addLayout(horizontalLayout); verticalLayout->addWidget(m_pTable); setLayout(verticalLayout); @@ -62,7 +75,7 @@ void SearchPanel::OnSearchResult(search::Result * result, int queryId) if (queryId != m_queryId) return; - if (!result->GetString().empty()) // last element + if (!result->GetString().empty()) { int const rowCount = m_pTable->rowCount(); m_pTable->setRowCount(rowCount + 1); @@ -72,7 +85,12 @@ void SearchPanel::OnSearchResult(search::Result * result, int queryId) m_results.push_back(result); } else + { // last element delete result; + // stop search busy indicator + m_pAnimationTimer->stop(); + m_pClearButton->setIcon(QIcon(":/ui/x.png")); + } } void SearchPanel::OnSearchTextChanged(QString const & str) @@ -85,8 +103,20 @@ void SearchPanel::OnSearchTextChanged(QString const & str) QString const normalized = str.normalized(QString::NormalizationForm_KC); if (!normalized.isEmpty()) + { m_pDrawWidget->Search(normalized.toUtf8().constData(), bind(&SearchPanel::SearchResultThreadFunc, this, _1, m_queryId)); + // show busy indicator + if (!m_pAnimationTimer->isActive()) + m_pAnimationTimer->start(200); + OnAnimationTimer(); + m_pClearButton->setFlat(true); + m_pClearButton->setVisible(true); + } + else + { // hide X button + m_pClearButton->setVisible(false); + } } void SearchPanel::OnSearchPanelItemClicked(int row, int) @@ -122,4 +152,23 @@ void SearchPanel::OnViewportChanged() OnSearchTextChanged(txt); } +void SearchPanel::OnAnimationTimer() +{ + static int angle = 0; + QPixmap pixmap(":/ui/busy.png"); + QSize const oldSize = pixmap.size(); + QMatrix rm; + angle += 15; + if (angle >= 360) + angle = 0; + rm.rotate(angle); + pixmap = pixmap.transformed(rm); + m_pClearButton->setIcon(QIcon(pixmap)); +} + +void SearchPanel::OnClearButton() +{ + m_pEditor->setText(""); +} + } diff --git a/qt/search_panel.hpp b/qt/search_panel.hpp index 3540a17eeb..068eb1c7e9 100644 --- a/qt/search_panel.hpp +++ b/qt/search_panel.hpp @@ -8,6 +8,8 @@ class QTableWidget; class QLineEdit; +class QPushButton; +class QTimer; namespace qt { @@ -19,6 +21,8 @@ class SearchPanel : public QWidget DrawWidget * m_pDrawWidget; QTableWidget * m_pTable; QLineEdit * m_pEditor; + QPushButton * m_pClearButton; + QTimer * m_pAnimationTimer; /// Stores current search results vector m_results; @@ -38,12 +42,14 @@ public: explicit SearchPanel(DrawWidget * drawWidget, QWidget * parent); ~SearchPanel(); -protected slots: +private slots: void OnSearchPanelItemClicked(int row, int column); void OnSearchTextChanged(QString const &); /// Called via signal to support multithreading void OnSearchResult(search::Result * result, int queryId); void OnViewportChanged(); + void OnAnimationTimer(); + void OnClearButton(); }; }