From 5559f838744422ccdaa6841357fd08060ef8bb6d Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Thu, 27 Apr 2017 12:18:03 +0300 Subject: [PATCH] [assessment-tool] Added spinner. --- qt/qt_common/CMakeLists.txt | 2 + qt/qt_common/qt_common.pro | 2 + qt/qt_common/res/resources_common.qrc | 16 +++++- qt/qt_common/res/spinner1.png | Bin 0 -> 488 bytes qt/qt_common/res/spinner10.png | Bin 0 -> 489 bytes qt/qt_common/res/spinner11.png | Bin 0 -> 488 bytes qt/qt_common/res/spinner12.png | Bin 0 -> 491 bytes qt/qt_common/res/spinner2.png | Bin 0 -> 488 bytes qt/qt_common/res/spinner3.png | Bin 0 -> 495 bytes qt/qt_common/res/spinner4.png | Bin 0 -> 486 bytes qt/qt_common/res/spinner5.png | Bin 0 -> 488 bytes qt/qt_common/res/spinner6.png | Bin 0 -> 492 bytes qt/qt_common/res/spinner7.png | Bin 0 -> 490 bytes qt/qt_common/res/spinner8.png | Bin 0 -> 487 bytes qt/qt_common/res/spinner9.png | Bin 0 -> 493 bytes qt/qt_common/spinner.cpp | 53 ++++++++++++++++++ qt/qt_common/spinner.hpp | 23 ++++++++ .../assessment_tool/main_model.cpp | 2 + .../assessment_tool/main_view.cpp | 6 +- .../assessment_tool/main_view.hpp | 2 + .../assessment_tool/sample_view.cpp | 15 ++++- .../assessment_tool/sample_view.hpp | 5 ++ .../search_quality/assessment_tool/view.hpp | 2 + 23 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 qt/qt_common/res/spinner1.png create mode 100644 qt/qt_common/res/spinner10.png create mode 100644 qt/qt_common/res/spinner11.png create mode 100644 qt/qt_common/res/spinner12.png create mode 100644 qt/qt_common/res/spinner2.png create mode 100644 qt/qt_common/res/spinner3.png create mode 100644 qt/qt_common/res/spinner4.png create mode 100644 qt/qt_common/res/spinner5.png create mode 100644 qt/qt_common/res/spinner6.png create mode 100644 qt/qt_common/res/spinner7.png create mode 100644 qt/qt_common/res/spinner8.png create mode 100644 qt/qt_common/res/spinner9.png create mode 100644 qt/qt_common/spinner.cpp create mode 100644 qt/qt_common/spinner.hpp diff --git a/qt/qt_common/CMakeLists.txt b/qt/qt_common/CMakeLists.txt index 04c98fc873..3786734096 100644 --- a/qt/qt_common/CMakeLists.txt +++ b/qt/qt_common/CMakeLists.txt @@ -16,6 +16,8 @@ set( qtoglcontextfactory.hpp scale_slider.cpp scale_slider.hpp + spinner.cpp + spinner.hpp ) add_library(${PROJECT_NAME} ${SRC} ${RESOURCES}) diff --git a/qt/qt_common/qt_common.pro b/qt/qt_common/qt_common.pro index b3026b6571..01bc692a81 100644 --- a/qt/qt_common/qt_common.pro +++ b/qt/qt_common/qt_common.pro @@ -17,6 +17,7 @@ SOURCES += \ qtoglcontext.cpp \ qtoglcontextfactory.cpp \ scale_slider.cpp \ + spinner.cpp \ HEADERS += \ helpers.hpp \ @@ -25,5 +26,6 @@ HEADERS += \ qtoglcontext.hpp \ qtoglcontextfactory.hpp \ scale_slider.hpp \ + spinner.hpp \ RESOURCES += res/resources_common.qrc diff --git a/qt/qt_common/res/resources_common.qrc b/qt/qt_common/res/resources_common.qrc index 9db3deeeb5..8a672ea200 100644 --- a/qt/qt_common/res/resources_common.qrc +++ b/qt/qt_common/res/resources_common.qrc @@ -1,6 +1,18 @@ - - plus.png + minus.png + plus.png + spinner1.png + spinner2.png + spinner3.png + spinner4.png + spinner5.png + spinner6.png + spinner7.png + spinner8.png + spinner9.png + spinner10.png + spinner11.png + spinner12.png diff --git a/qt/qt_common/res/spinner1.png b/qt/qt_common/res/spinner1.png new file mode 100644 index 0000000000000000000000000000000000000000..66bf27aaa3f6429c811fe893e7121df76393c246 GIT binary patch literal 488 zcmVP)68Ep+k)X*_!&y8Dmj&%G}vfwy6Fs<+>g*lh*qYcSl6xJO@bFzOa zEW7jIQ033Nw;kHoG>ndGk1kaFB3W}_OVzOI&OJGn{K&k0yQ)S}ck9`fAC&g(DUGV* z$+NC+*6f)!jx{gN0orzL%f?Z-_i6@MwySSkOJ1ErVJFJQRq^Ugm5yyoCUNH7JoC2o zOk&x)LzZkQO=94~1*db0(3aM7A1b<4TGs!JHLs&mK$p#VG%(90000q2wr$(<{x7xp7YD<}-tVvw`c`4qo-=nI6bPb_8pxDWFJ4n`-aY*{ zP%2ABed#*&Eak+aaV?pEkV*r|rG6VM*zoAdtp)ivUqnT!lncI*JM`$mip)=fOerPs zS?`WQH)?~5TB!_x1Gg3pqtMa> z7E zhEZgCYEGrAH;P~^_5TgD?`-6)jq9=HRL3X^6S}N8HDweH6FQ7Lv0)TllPYp2j%0=v zO_>y7!?8)jYMRmmdXDUgh7nAeRsn1{G-DWTGsXdEIdq_9P^Fnv2>^2r>?+W|%(PiG z01&L&x1rGgFjMA?3!h(X+Ow^xAEjCIrbRx>tk|_(-V@;))Dm2t)EL%!VtMsK~(U#5BhV|51YSl_=*^H)vWNNb(EK7q} fGG|I#^o_p&)Rr4-Ngkeh00000NkvXXu0mjf*mK(~ literal 0 HcmV?d00001 diff --git a/qt/qt_common/res/spinner11.png b/qt/qt_common/res/spinner11.png new file mode 100644 index 0000000000000000000000000000000000000000..6f2007338f6d692d00beb760f3bd316e4070a36d GIT binary patch literal 488 zcmVP) zwVLfV07lUz**?s4VVHU5GSmCNN6Ijxqb_*RYkz8gHzsq{+;iy03$MLQJ#lQNVUFOx zf}xp#AjRKKz!yGCX9XSCUP?Lh&_G?TP}jHX+Iyc;ccO)&JukfU*nNfnQ`qy;ScYJZ z%$et@9hpU<3_%q9kKCna9%)%k5dUu~IQP_zI%^DNsQ>^xlx7sx5oA&T(D5YIv92Ib zMF7q{_P{1Gg0A}G{E;Lsy8o66J_P;=)-W>Y~u6&Sj8po&669<`LdS4D{! zHK{xl1kT+kR1vkbqTmmuDoV%&l&T3tzav(ifqj=cs>pP-c;LcV6?I*W=qEH)k>Pi8 z=cy`>NG}y(+nJ$F)%CQA_!>iT<3~3783^{An%YFuKo@|9lT_Wh3PS@q0L+{?P*_Ja zFwz77f-OgOwGByzXkIc412Zn-0f{sb5FPI}3I!Nv4i*w&S z6Ejm?Ve$V_!$=K(_|ea)-%tt)nOcg{Z@%>_i-(}8r;btzlqpL5EL}ipWx2MY`yNQS eZ=$ayGsmA@1~+d{bPurr0000d=~@N=u zM~9M2lx}(Ai8bLWh28&CkCZM@IP%y%12-}7#wX8J&Pet>a!1Qeb-Z%ynE(JbJakuO z7L_+X+XsNI2OjF0)x;N{i~+)d`&QMlMN$bGjYb%YiG+wPfHUkFO2K7MMJAsON) zQ*~va)Rz6Gi7b&+_)}9+s^rF@pcJx`=Aq;Sp{Zydf*_g7T1_)@@`tRWi6mg?z?vp1 z9R)21_7v(0U0nfd_D$4P>S_aBd$vXGpPm9>!>&1XRC+oBpkvprj#(A@`U(J;*tMxJ zi==O$4FH5y+t!scWCn(M!Wo5CTh>)>qBJzp7cP)2+q7vcxk~65|DQ=N5$0^#uxcQ= zNculAG1d_P5YDPhl*s<@m#L|Ykd#U-WK+MJa&?H%(NoDXGO`S^>~DYg+YAalBlDIm hS+rncpsjF;e*mhIJ@KvZ5()qS002ovPDHLkV1ljx-hTi9 literal 0 HcmV?d00001 diff --git a/qt/qt_common/res/spinner2.png b/qt/qt_common/res/spinner2.png new file mode 100644 index 0000000000000000000000000000000000000000..dcd31a993319a18450d64ebf5a3d73c490cb25e1 GIT binary patch literal 488 zcmVP)zkv{M~&z1W#parcDfS#Bu2hDc48)SKy2<^ zXeh>Ek*O1>K1%J8Sa@Tr>?In$IrUlMKO$kqO6H|9-<gE+D&ngLBN7wiLchqJ2NmcVtI2Ea(Kn!CWFV49?82iS5a}6d$RpAB1AxrX zK$>$Z27so4p2TZJLjEJt*4GukVkQ>aH`US8k-cyx3GJDISW8b=RrKsgDhWjnh*Wh# zEoITckt~!Ro&iWTg{e?Y`S;ro#S*DZSt*o?y-2FAr5S3dhiaj!N~kOoroBQeQ&IbC eDBO$m@Wd~Vu^VUn&->y40000g3}9 literal 0 HcmV?d00001 diff --git a/qt/qt_common/res/spinner3.png b/qt/qt_common/res/spinner3.png new file mode 100644 index 0000000000000000000000000000000000000000..f4efa27da3bc40cea679c5591ebba7e12943d356 GIT binary patch literal 495 zcmV?T)B59W7<0EL-}*e)V>p0$9!nTB0Wyf}r#G!)xa>dA`=H4|NBoO;!#Wvs4@ zsaN~-j8&D<^u`UNP@;^Aw;mZ9iItIg>zRRJ$)UtMuk;N{KiWGlbPQz5=y>m%x`9F& zGanpL)z?(Ug^$K0dZE~^G9P?Yfu^3k#Djfu1!TI~BD+Yu@yP(7sUx?GL!Uj008;Hx zYFiDTebMwExt6BbHgfNMaq1h9x|W7`tH0_m?!~?(R@YRQZ2W8f)r-_mL~0u9Dk7^y z4*c#n&nlLPRMpiK(j{XNGWULQEV5D}7p6iLsaW)1;!uRDwhcrQRfSwtC6t9yiR9m* lt%NyY;_s<2B#bPd`3f$+8+#$ZMXmq<002ovPDHLkV1hK(>lgq4 literal 0 HcmV?d00001 diff --git a/qt/qt_common/res/spinner4.png b/qt/qt_common/res/spinner4.png new file mode 100644 index 0000000000000000000000000000000000000000..9a9ff62dcc3c22caaf7dbc9f6a088b9ae687203a GIT binary patch literal 486 zcmV@P)sgED6^2o_>%jK!p@K;ZW~7Fd+j3}K;H$QIvr?nT?K`sIi^5#2Fsgo_LY6}w6W+cXyI&mhWG_9kGEoUZanNm~5 zjB{&rOvzQza&CvNNvSGoE*vru3#v$6I{zOBYU@_s+LdEkIxhDYf)HUSBvFzT_*Kr%MWQ>cybFb}- zLOm9YqIB)ShOY#rno<~k80Q`x3j7`_CNYe*TTd=zeiIa8Qb9kdHBX)$%k&Ur3VAH) zF<55Fy%*261brnkF{wm|5u_R>Ej#ln=3K{65@{@n1>|0Q`tTlmb8f~+g79ykCl4+h cnwRV0KbH?1Yc)fnqW}N^07*qoM6N<$g3FWEa{vGU literal 0 HcmV?d00001 diff --git a/qt/qt_common/res/spinner5.png b/qt/qt_common/res/spinner5.png new file mode 100644 index 0000000000000000000000000000000000000000..240614ef91600bcab2039c88f53acdca59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^65b|jbPTi z25{!nhH14d7(&B`H>GJs3l=37d^lCb(4rQ*-mR;mZAqVNZ~CfeSTf6lH+5Ac%NBX? zs#Ha^Vu>fO3RNU|Anv`WQ+=Q_F9xcpTeZlxXUnSSSuf5vcj6ArKOe0vcsR;z99;}(h(3WKYI_}+R`K^YnTmt|$+__Zu8-;b-h5$fx z;MSSaPnFi~SQY$7a_q*Lj-RO8l82FuQ8;wt+LD0DqB(oH710F2vTIk)%uB{ehPLh7 zGcUko9fvM+XSU31D;1Jb$H=Nf2e}OmKhm}B!nrd!CvuJ*)(mEZFqwREpsL2@?4zH6_6UnM?0JtO-~w$kfzT1^-9l%A0#_ z-w~^6sEPcO$f;MiGT#-cYpMzUVcUy)Wj_&VXet9h!;5EiKb2_ZB>=&>XX}1r9u!SXNnA12T^uq?Q%w=EaOW+EYYBPl*i=CW@%&t8wUFTM?1>FNSSb#+Fq#)dQL?od}i@8JnsA?7J|rjFy?908n?~T-{G)=6M+aOq@HE`iaEU zT*p5IyUy&(d{=C0#Zd515<5;EsQ8Yuxm9D4|0A~PByTLT7(vH+-dJpb$jq@LySftp zPpoZKK1N%x7%H|LIn0~us!2p*iHeSi4VyO1lzl_cwCW&lKX1>jJUg~+ + +#include +#include +#include + +namespace +{ +int constexpr kMinSpinnerPixmap = 1; +int constexpr kMaxSpinnerPixmap = 12; +int constexpr kTimeoutMs = 100; +} // namespace + +Spinner::Spinner() +{ + for (int i = kMinSpinnerPixmap; i <= kMaxSpinnerPixmap; ++i) + { + auto const path = ":common/spinner" + std::to_string(i) + ".png"; + m_pixmaps.emplace_back(QString::fromStdString(path)); + } + + setEnabled(false); + setAlignment(Qt::AlignCenter); + + QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::Fixed); + policy.setRetainSizeWhenHidden(true); + setSizePolicy(policy); + + setMinimumSize(m_pixmaps.front().size()); + setPixmap(m_pixmaps.front()); + + m_timer = new QTimer(this /* parent */); + connect(m_timer, &QTimer::timeout, [this]() { + m_progress = (m_progress + 1) % m_pixmaps.size(); + setPixmap(m_pixmaps[m_progress]); + }); +} + +void Spinner::Show() +{ + m_progress = 0; + setPixmap(m_pixmaps[m_progress]); + m_timer->start(kTimeoutMs); + show(); +} + +void Spinner::Hide() +{ + m_timer->stop(); + hide(); +} diff --git a/qt/qt_common/spinner.hpp b/qt/qt_common/spinner.hpp new file mode 100644 index 0000000000..129420c2d5 --- /dev/null +++ b/qt/qt_common/spinner.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include +#include + +#include +#include + +class Spinner : private QLabel +{ +public: + Spinner(); + + void Show(); + void Hide(); + + QLabel & AsWidget() { return static_cast(*this); } + +private: + std::vector m_pixmaps; + QTimer * m_timer = nullptr; + size_t m_progress = 0; +}; diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp index 1945133404..14466dedd1 100644 --- a/search/search_quality/assessment_tool/main_model.cpp +++ b/search/search_quality/assessment_tool/main_model.cpp @@ -169,6 +169,7 @@ void MainModel::OnSampleSelected(int index) }; m_queryHandle = engine.Search(params, sample.m_viewport); + m_view->OnSearchStarted(); } } @@ -286,6 +287,7 @@ void MainModel::OnResults(uint64_t timestamp, size_t sampleIndex, search::Result m_view->OnSampleChanged(sampleIndex, context.HasChanges()); m_view->EnableSampleEditing(sampleIndex, context.m_foundResultsEdits, context.m_nonFoundResultsEdits); + m_view->OnSearchCompleted(); } void MainModel::ResetSearch() diff --git a/search/search_quality/assessment_tool/main_view.cpp b/search/search_quality/assessment_tool/main_view.cpp index a9dec4bc8f..5cfab27a69 100644 --- a/search/search_quality/assessment_tool/main_view.cpp +++ b/search/search_quality/assessment_tool/main_view.cpp @@ -60,6 +60,10 @@ void MainView::SetSamples(ContextList::SamplesSlice const & samples) m_sampleView->Clear(); } +void MainView::OnSearchStarted() { m_sampleView->OnSearchStarted(); } + +void MainView::OnSearchCompleted() { m_sampleView->OnSearchCompleted(); } + void MainView::ShowSample(size_t sampleIndex, search::Sample const & sample, bool positionAvailable, bool hasEdits) { @@ -269,7 +273,7 @@ void MainView::InitDocks() } m_samplesDock = CreateDock(*m_samplesView); - addDockWidget(Qt::RightDockWidgetArea, m_samplesDock); + addDockWidget(Qt::LeftDockWidgetArea, m_samplesDock); SetSamplesDockTitle(false /* hasEdits */); m_sampleView = new SampleView(this /* parent */, m_framework); diff --git a/search/search_quality/assessment_tool/main_view.hpp b/search/search_quality/assessment_tool/main_view.hpp index 2d368f55e1..faecaef037 100644 --- a/search/search_quality/assessment_tool/main_view.hpp +++ b/search/search_quality/assessment_tool/main_view.hpp @@ -28,6 +28,8 @@ public: // View overrides: void SetSamples(ContextList::SamplesSlice const & samples) override; + void OnSearchStarted() override; + void OnSearchCompleted() override; void ShowSample(size_t sampleIndex, search::Sample const & sample, bool positionAvailable, bool hasEdits) override; void ShowFoundResults(search::Results::ConstIter begin, search::Results::ConstIter end) override; diff --git a/search/search_quality/assessment_tool/sample_view.cpp b/search/search_quality/assessment_tool/sample_view.cpp index 6b1fe73943..31fd0a6548 100644 --- a/search/search_quality/assessment_tool/sample_view.cpp +++ b/search/search_quality/assessment_tool/sample_view.cpp @@ -1,5 +1,7 @@ #include "search/search_quality/assessment_tool/sample_view.hpp" +#include "qt/qt_common/spinner.hpp" + #include "map/bookmark_manager.hpp" #include "map/framework.hpp" #include "map/user_mark.hpp" @@ -75,7 +77,13 @@ SampleView::SampleView(QWidget * parent, Framework & framework) { auto * layout = BuildSubLayout(*mainLayout, *this /* parent */); - layout->addWidget(new QLabel(tr("Found results"))); + { + auto * subLayout = BuildSubLayout(*layout, *this /* parent */); + subLayout->addWidget(new QLabel(tr("Found results"))); + + m_spinner = new Spinner(); + subLayout->addWidget(&m_spinner->AsWidget()); + } m_foundResults = new ResultsView(*this /* parent */); layout->addWidget(m_foundResults); @@ -106,6 +114,10 @@ void SampleView::SetContents(search::Sample const & sample, bool positionAvailab ClearAllResults(); } +void SampleView::OnSearchStarted() { m_spinner->Show(); } + +void SampleView::OnSearchCompleted() { m_spinner->Hide(); } + void SampleView::ShowFoundResults(search::Results::ConstIter begin, search::Results::ConstIter end) { for (auto it = begin; it != end; ++it) @@ -150,6 +162,7 @@ void SampleView::Clear() m_showViewport->setEnabled(false); m_showPosition->setEnabled(false); ClearAllResults(); + OnSearchCompleted(); } void SampleView::EnableEditing(ResultsView & results, Edits & edits) diff --git a/search/search_quality/assessment_tool/sample_view.hpp b/search/search_quality/assessment_tool/sample_view.hpp index 692de06591..0c2c88d2b1 100644 --- a/search/search_quality/assessment_tool/sample_view.hpp +++ b/search/search_quality/assessment_tool/sample_view.hpp @@ -11,6 +11,7 @@ class LanguagesList; class QLineEdit; class QPushButton; class ResultsView; +class Spinner; class SampleView : public QWidget { @@ -22,6 +23,8 @@ public: SampleView(QWidget * parent, Framework & framework); void SetContents(search::Sample const & sample, bool positionAvailable); + void OnSearchStarted(); + void OnSearchCompleted(); void ShowFoundResults(search::Results::ConstIter begin, search::Results::ConstIter end); void ShowNonFoundResults(std::vector const & results); @@ -42,6 +45,8 @@ private: Framework & m_framework; + Spinner * m_spinner = nullptr; + QLineEdit * m_query = nullptr; LanguagesList * m_langs = nullptr; QPushButton * m_showViewport = nullptr; diff --git a/search/search_quality/assessment_tool/view.hpp b/search/search_quality/assessment_tool/view.hpp index 2ece040476..9b876ca052 100644 --- a/search/search_quality/assessment_tool/view.hpp +++ b/search/search_quality/assessment_tool/view.hpp @@ -28,6 +28,8 @@ public: void SetModel(Model & model) { m_model = &model; } virtual void SetSamples(ContextList::SamplesSlice const & samples) = 0; + virtual void OnSearchStarted() = 0; + virtual void OnSearchCompleted() = 0; virtual void ShowSample(size_t index, search::Sample const & sample, bool positionAvailable, bool hasEdits) = 0; virtual void ShowFoundResults(search::Results::ConstIter begin,