In desktop version added history as popup window not dialog
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 30 Aug 2010 09:22:29 +0000 (11:22 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 30 Aug 2010 09:22:29 +0000 (11:22 +0200)
trunk/src/base/gui/HistoryListDialog.cpp
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MainWindow.h
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/gui/SearchBarWidget.h
trunk/src/includes/GUIInterface.h

index 8905578..ad2ffd9 100644 (file)
@@ -29,6 +29,12 @@ HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
     verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
+    #ifndef Q_WS_MAEMO_5
+        setWindowFlags(Qt::Popup);
+        QLabel* title = new QLabel(tr("History"));
+        verticalLayout->addWidget(title,0, Qt::AlignCenter);
+    #endif
+
     oryginalList = words;
 
     historyListWidget = new QListWidget(this);
index aa48cc2..349c5e4 100644 (file)
@@ -310,8 +310,18 @@ void MainWindow::enableMenu() {
     #endif
 }
 
-void MainWindow::showHistory() {
-    HistoryListDialog historyDialog(backbone->history()->list(), this);
+void MainWindow::showHistory(QPoint p) {
+    HistoryListDialog historyDialog(backbone->history()->list(), searchBarWidget);
+
+    #ifndef Q_WS_MAEMO_5
+        QPoint newPos = mapFromGlobal(p);
+        newPos.setY(searchBarWidget->pos().y() -
+                    historyDialog.sizeHint().height());
+        newPos.setX(width() - historyDialog.sizeHint().width());
+
+        historyDialog.move(newPos);
+    #endif
+
     if(historyDialog.exec() == QDialog::Accepted) {
         backbone->history()->setCurrentElement(historyDialog.selectedRow());
         searchExact(historyDialog.selectedWord());
@@ -443,8 +453,8 @@ void MainWindow::connectSearchBar() {
     connect(searchBarWidget, SIGNAL(historyPrev()),
             this, SLOT(historyPrev()));
 
-    connect(searchBarWidget, SIGNAL(historyShow()),
-            this, SLOT(showHistory()));
+    connect(searchBarWidget, SIGNAL(historyShow(QPoint)),
+            this, SLOT(showHistory(QPoint)));
 
     connect(searchBarWidget, SIGNAL(refreshHistoryButtons()),
             backbone->history(), SLOT(refreshStatus()));
index e65769b..1046fde 100644 (file)
@@ -155,7 +155,7 @@ public:
     void addToHistory(QList<Translation*>);
 
     //! Shows history dialog
-    void showHistory();
+    void showHistory(QPoint);
 
     //! Shows translation of next word in history
     /*!
index b8c823a..4f4f84a 100644 (file)
@@ -49,7 +49,7 @@ SearchBarWidget::SearchBarWidget(QWidget *parent) :
             this, SIGNAL(historyPrev()));
 
     connect(historyShowToolButton, SIGNAL(clicked()),
-            this, SIGNAL(historyShow()));
+            this, SLOT(showHistoryButtonClicked()));
 
     connect(clearSearchWordToolButton, SIGNAL(clicked()),
             this, SLOT(clearSearchWordToolButtonClicked()));
@@ -303,3 +303,13 @@ void SearchBarWidget::updateHistoryButtons(bool prev, bool next, bool list) {
         historyShowToolButton->setEnabled(list);
     }
 }
+
+void SearchBarWidget::showHistoryButtonClicked() {
+    #ifndef Q_WS_MAEMO_5
+        QPoint p = historyShowToolButton->pos();
+        p.setY(p.y());
+        emit historyShow(mapToGlobal(p));
+    #else
+        emit historyShow();
+    #endif
+}
index 388c468..25eed8b 100644 (file)
@@ -60,7 +60,7 @@ Q_SIGNALS:
     void historyNext();
 
     //! Requests to show history list
-    void historyShow();
+    void historyShow(QPoint p = QPoint(-1,-1));
 
     //! Requests to refresh state of history buttons
     void refreshHistoryButtons();
@@ -108,6 +108,7 @@ private Q_SLOTS:
     void clearSearchWordToolButtonClicked();
     void searchPushButtonClicked();
     void delaySearchTimeout();
+    void showHistoryButtonClicked();
 
 
 private:
index 8eb4934..ad92b37 100644 (file)
@@ -100,7 +100,7 @@ public Q_SLOTS:
     virtual void addToHistory(QList<Translation*>) = 0;
 
     //! Shows history dialog
-    virtual void showHistory() = 0;
+    virtual void showHistory(QPoint) = 0;
 
     //! Shows translation of next word in history
     /*!