Basic functionality and look of SearchBarWidget
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 3 Aug 2010 09:22:49 +0000 (11:22 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 3 Aug 2010 09:22:49 +0000 (11:22 +0200)
12 files changed:
trunk/src/base/mDictionary/MainWindow.cpp [new file with mode: 0644]
trunk/src/base/mDictionary/MainWindow.h [new file with mode: 0644]
trunk/src/base/mDictionary/MainWindow.ui [new file with mode: 0644]
trunk/src/base/mDictionary/gui/SearchBarWidget.cpp [new file with mode: 0644]
trunk/src/base/mDictionary/gui/SearchBarWidget.h [new file with mode: 0644]
trunk/src/base/mDictionary/gui/searchbarwidget.cpp [deleted file]
trunk/src/base/mDictionary/gui/searchbarwidget.h [deleted file]
trunk/src/base/mDictionary/mDictionary.pro
trunk/src/base/mDictionary/main.cpp
trunk/src/base/mDictionary/mainwindow.cpp [deleted file]
trunk/src/base/mDictionary/mainwindow.h [deleted file]
trunk/src/base/mDictionary/mainwindow.ui [deleted file]

diff --git a/trunk/src/base/mDictionary/MainWindow.cpp b/trunk/src/base/mDictionary/MainWindow.cpp
new file mode 100644 (file)
index 0000000..7cc8e85
--- /dev/null
@@ -0,0 +1,14 @@
+#include "MainWindow.h"
+#include "ui_MainWindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
diff --git a/trunk/src/base/mDictionary/MainWindow.h b/trunk/src/base/mDictionary/MainWindow.h
new file mode 100644 (file)
index 0000000..c9fd6a9
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+    class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+private:
+    Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H
diff --git a/trunk/src/base/mDictionary/MainWindow.ui b/trunk/src/base/mDictionary/MainWindow.ui
new file mode 100644 (file)
index 0000000..1de7966
--- /dev/null
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <property name="palette">
+    <palette>
+     <active>
+      <colorrole role="Base">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>255</red>
+         <green>255</green>
+         <blue>255</blue>
+        </color>
+       </brush>
+      </colorrole>
+      <colorrole role="Window">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>0</red>
+         <green>0</green>
+         <blue>0</blue>
+        </color>
+       </brush>
+      </colorrole>
+     </active>
+     <inactive>
+      <colorrole role="Base">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>255</red>
+         <green>255</green>
+         <blue>255</blue>
+        </color>
+       </brush>
+      </colorrole>
+      <colorrole role="Window">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>0</red>
+         <green>0</green>
+         <blue>0</blue>
+        </color>
+       </brush>
+      </colorrole>
+     </inactive>
+     <disabled>
+      <colorrole role="Base">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>0</red>
+         <green>0</green>
+         <blue>0</blue>
+        </color>
+       </brush>
+      </colorrole>
+      <colorrole role="Window">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>0</red>
+         <green>0</green>
+         <blue>0</blue>
+        </color>
+       </brush>
+      </colorrole>
+     </disabled>
+    </palette>
+   </property>
+   <property name="autoFillBackground">
+    <bool>true</bool>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>800</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <widget class="SearchBarWidget" name="widget" native="true">
+      <property name="enabled">
+       <bool>true</bool>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>400</width>
+     <height>23</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+  <customwidget>
+   <class>SearchBarWidget</class>
+   <extends>QWidget</extends>
+   <header>gui/SearchBarWidget.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/trunk/src/base/mDictionary/gui/SearchBarWidget.cpp b/trunk/src/base/mDictionary/gui/SearchBarWidget.cpp
new file mode 100644 (file)
index 0000000..343caab
--- /dev/null
@@ -0,0 +1,175 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+
+#include "SearchBarWidget.h"
+#include <QDebug>
+
+
+
+SearchBarWidget::SearchBarWidget(QWidget *parent) :
+    QWidget(parent) {
+
+    initializeUI();
+
+    setMaximumHeight(150);
+
+    isSearching = false;
+
+    connect(searchPushButton, SIGNAL(clicked()),
+            this, SLOT(searchPushButtonClicked()));
+
+    connect(historyNextToolButton, SIGNAL(clicked()),
+            this, SLOT(historyNextToolButtonClicked()));
+
+    connect(historyPrevToolButton, SIGNAL(clicked()),
+            this, SLOT(historyPrevToolButtonClicked()));
+
+    connect(historyShowToolButton, SIGNAL(clicked()),
+            this, SLOT(historyShowToolButtonClicked()));
+
+    connect(clearSearchWordToolButton, SIGNAL(clicked()),
+            this, SLOT(clearSearchWordToolButtonClicked()));
+
+}
+
+SearchBarWidget::~SearchBarWidget() {
+
+}
+
+
+void SearchBarWidget::initializeUI() {
+    horizontalLayout = new QHBoxLayout();
+    verticalLayout = new QVBoxLayout();
+
+
+    searchPushButton = new QPushButton(tr("Search"));
+    searchPushButton->setMinimumWidth(200);
+
+
+    searchWordLineEdit = new QLineEdit();
+    searchWordLineEdit->setMinimumWidth(350);
+    //create layout for lineEdit to have clear button on it
+    QHBoxLayout* lineEditLayout = new QHBoxLayout;
+    searchWordLineEdit->setLayout(lineEditLayout);
+
+
+    clearSearchWordToolButton = new QToolButton();
+    clearSearchWordToolButton->setIcon(QIcon("sowa.svg"));
+    //tool buttons will have size 2 times smaller
+    clearSearchWordToolButton->setMaximumSize(
+            clearSearchWordToolButton->sizeHint().width()/2,
+            clearSearchWordToolButton->sizeHint().height()/2);
+
+
+    historyNextToolButton = new QToolButton();
+    historyNextToolButton->setIcon(QIcon("sowa.svg"));
+    historyNextToolButton->setMaximumSize(
+            historyNextToolButton->sizeHint().width()/2,
+            historyNextToolButton->sizeHint().height()/2);
+
+
+    historyPrevToolButton = new QToolButton();
+    historyPrevToolButton->setIcon(QIcon("sowa.svg"));
+    historyPrevToolButton->setMaximumSize(
+            historyPrevToolButton->sizeHint().width()/2,
+            historyPrevToolButton->sizeHint().height()/2);
+
+
+    historyShowToolButton = new QToolButton();
+    historyShowToolButton->setIcon(QIcon("sowa.svg"));
+    historyShowToolButton->setMaximumSize(
+            historyShowToolButton->sizeHint().width()/2,
+            historyShowToolButton->sizeHint().height()/2);
+
+
+    searchingProgressBar = new QProgressBar();
+    searchingProgressBar->setMinimum(0);
+    searchingProgressBar->setMaximum(0);
+    searchingProgressBar->hide();
+    searchingProgressBar->setMaximumHeight(50);
+
+
+
+    setLayout(verticalLayout);
+
+    verticalLayout->addWidget(searchingProgressBar);
+
+    //adding widgets to layout
+    horizontalLayout->addWidget(searchWordLineEdit);
+    horizontalLayout->addWidget(searchPushButton);
+    horizontalLayout->addWidget(historyPrevToolButton);
+    horizontalLayout->addWidget(historyShowToolButton);
+    horizontalLayout->addWidget(historyNextToolButton);
+
+    //adding clear toolButton to textEdit with right alignment
+    lineEditLayout->addWidget(clearSearchWordToolButton, 0,
+                              Qt::AlignRight | Qt::AlignVCenter);
+
+    verticalLayout->addLayout(horizontalLayout);
+}
+
+
+void SearchBarWidget::searchPushButtonClicked() {
+    if(isSearching) {
+        emit stopSearching();
+        searchingProgressBar->hide();
+        searchPushButton->setText(tr("Search"));
+        setEnabled(true);
+        isSearching = false;
+    }
+    else {
+        emit searchForTranslations(searchWordLineEdit->text());
+        searchingProgressBar->show();
+        searchPushButton->setText(tr("Stop"));
+        setEnabled(false);
+        isSearching = true;
+    }
+}
+
+void SearchBarWidget::setEnabled(bool enabled) {
+    searchWordLineEdit->setEnabled(enabled);
+    historyNextToolButton->setEnabled(enabled);
+    historyPrevToolButton->setEnabled(enabled);
+    historyShowToolButton->setEnabled(enabled);
+}
+
+void SearchBarWidget::historyNextToolButtonClicked() {
+
+}
+
+void SearchBarWidget::historyPrevToolButtonClicked() {
+
+}
+
+void SearchBarWidget::historyShowToolButtonClicked() {
+
+}
+
+void SearchBarWidget::clearSearchWordToolButtonClicked() {
+    searchWordLineEdit->clear();
+}
+
+void SearchBarWidget::showHistoryListDialog() {
+
+}
diff --git a/trunk/src/base/mDictionary/gui/SearchBarWidget.h b/trunk/src/base/mDictionary/gui/SearchBarWidget.h
new file mode 100644 (file)
index 0000000..712220d
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+
+#ifndef SEARCHBARWIDGET_H
+#define SEARCHBARWIDGET_H
+
+#include <QWidget>
+#include <QtGui>
+
+
+//! Displays search bar
+/*!
+    Contains line edit field to input word which user would to find, and buttons
+    to browse search history
+*/
+class SearchBarWidget : public QWidget {
+    Q_OBJECT
+public:
+    explicit SearchBarWidget(QWidget *parent = 0);
+    ~SearchBarWidget();
+
+Q_SIGNALS:
+    void searchForTranslations(QString);
+    void stopSearching();
+
+public Q_SLOTS:
+    //! Enable or disable search word line edit and history buttons
+    /*!
+      While searching it disables only history button and line edit.
+      Search/Stop button is always enabled
+    */
+    void setEnabled(bool);
+
+private Q_SLOTS:
+    void clearSearchWordToolButtonClicked();
+    void searchPushButtonClicked();
+    void historyPrevToolButtonClicked();
+    void historyNextToolButtonClicked();
+    void historyShowToolButtonClicked();
+
+private:
+    QLineEdit* searchWordLineEdit;
+    QToolButton* clearSearchWordToolButton;
+    QPushButton* searchPushButton;
+    QToolButton* historyPrevToolButton;
+    QToolButton* historyNextToolButton;
+    QToolButton* historyShowToolButton;
+    QHBoxLayout* horizontalLayout;
+    QProgressBar* searchingProgressBar;
+
+    QVBoxLayout* verticalLayout;
+
+    bool isSearching;
+
+    void initializeUI();
+    void showHistoryListDialog();
+};
+
+#endif // SEARCHBARWIDGET_H
diff --git a/trunk/src/base/mDictionary/gui/searchbarwidget.cpp b/trunk/src/base/mDictionary/gui/searchbarwidget.cpp
deleted file mode 100644 (file)
index 37f1798..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
-
-    This file is part of mDictionary.
-
-    mDictionary is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    mDictionary is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
-
-    Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-#include "searchbarwidget.h"
-
-SearchBarWidget::SearchBarWidget(QWidget *parent) :
-    QWidget(parent)
-{
-}
diff --git a/trunk/src/base/mDictionary/gui/searchbarwidget.h b/trunk/src/base/mDictionary/gui/searchbarwidget.h
deleted file mode 100644 (file)
index 1564315..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
-
-    This file is part of mDictionary.
-
-    mDictionary is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    mDictionary is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
-
-    Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-
-#ifndef SEARCHBARWIDGET_H
-#define SEARCHBARWIDGET_H
-
-#include <QWidget>
-
-class SearchBarWidget : public QWidget
-{
-    Q_OBJECT
-public:
-    explicit SearchBarWidget(QWidget *parent = 0);
-
-signals:
-
-public slots:
-
-};
-
-#endif // SEARCHBARWIDGET_H
index 1d600aa..fd1e6d9 100644 (file)
@@ -11,10 +11,10 @@ TEMPLATE = app
 
 
 SOURCES += main.cpp\
-        mainwindow.cpp \
-    gui/searchbarwidget.cpp
+        MainWindow.cpp \
+    gui/SearchBarWidget.cpp
 
-HEADERS  += mainwindow.h \
-    gui/searchbarwidget.h
+HEADERS  += MainWindow.h \
+    gui/SearchBarWidget.h
 
-FORMS    += mainwindow.ui
+FORMS    += MainWindow.ui
index 9ae175b..b632575 100644 (file)
@@ -1,11 +1,12 @@
 #include <QtGui/QApplication>
-#include "mainwindow.h"
+#include "MainWindow.h"
 
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
     MainWindow w;
     w.show();
+    w.resize(800,480);
 
     return a.exec();
 }
diff --git a/trunk/src/base/mDictionary/mainwindow.cpp b/trunk/src/base/mDictionary/mainwindow.cpp
deleted file mode 100644 (file)
index 49d64fc..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-MainWindow::MainWindow(QWidget *parent) :
-    QMainWindow(parent),
-    ui(new Ui::MainWindow)
-{
-    ui->setupUi(this);
-}
-
-MainWindow::~MainWindow()
-{
-    delete ui;
-}
diff --git a/trunk/src/base/mDictionary/mainwindow.h b/trunk/src/base/mDictionary/mainwindow.h
deleted file mode 100644 (file)
index c9fd6a9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-namespace Ui {
-    class MainWindow;
-}
-
-class MainWindow : public QMainWindow
-{
-    Q_OBJECT
-
-public:
-    explicit MainWindow(QWidget *parent = 0);
-    ~MainWindow();
-
-private:
-    Ui::MainWindow *ui;
-};
-
-#endif // MAINWINDOW_H
diff --git a/trunk/src/base/mDictionary/mainwindow.ui b/trunk/src/base/mDictionary/mainwindow.ui
deleted file mode 100644 (file)
index 6050363..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
-  <property name="geometry" >
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>400</width>
-    <height>300</height>
-   </rect>
-  </property>
-  <property name="windowTitle" >
-   <string>MainWindow</string>
-  </property>
-  <widget class="QMenuBar" name="menuBar" />
-  <widget class="QToolBar" name="mainToolBar" />
-  <widget class="QWidget" name="centralWidget" />
-  <widget class="QStatusBar" name="statusBar" />
- </widget>
- <layoutDefault spacing="6" margin="11" />
- <pixmapfunction></pixmapfunction>
- <resources/>
- <connections/>
-</ui>