Add readme
[groove] / topbar.cpp
1 #include "topbar.h"
2 #include "ui_topbar.h"
3
4 topBar::topBar(QWidget *parent) :
5     QWidget(parent),
6     ui(new Ui::topBar)
7 {
8     ui->setupUi(this);
9     kb = NULL;
10     ui->sBox->installEventFilter(this);
11 }
12
13 topBar::~topBar()
14 {
15     delete ui;
16 }
17 void topBar::on_taskSwitch_clicked()
18 {
19     emit this->changeTask();
20 }
21 void topBar::on_sButton_clicked()
22 {
23     emit this->searchRequest(ui->sBox->text());
24 }
25 void topBar::on_closeButton_clicked()
26 {
27     emit this->closeApp();
28 }
29
30 void topBar::changeEvent(QEvent *e)
31 {
32     QWidget::changeEvent(e);
33     switch (e->type()) {
34     case QEvent::LanguageChange:
35         ui->retranslateUi(this);
36         break;
37     default:
38         break;
39     }
40 }
41 void topBar::resizeEvent(QResizeEvent *e)
42 {
43     if(e->type() == QEvent::Resize)
44     {
45 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
46         if(((QWidget *)this->parent())->testAttribute(Qt::WA_Maemo5PortraitOrientation))
47         {
48             ui->sBox->setReadOnly(true);
49             //ui->sBox->setText("Portrait");
50         }
51         else
52             ui->sBox->setReadOnly(false);
53 #endif
54     }
55 }
56
57 bool topBar::eventFilter(QObject *obj, QEvent *e)
58 {
59     if(obj == ui->sBox && ui->sBox->isReadOnly() && e->type() == QEvent::MouseButtonRelease)
60     {
61         if(!kb)
62         {
63             this->kb = new vkb(this);
64             connect(kb,SIGNAL(submitText(QString)),ui->sBox,SLOT(setText(QString)));
65         }
66         kb->setText(ui->sBox->text());
67         kb->show();
68     }
69     else
70         return QWidget::eventFilter(obj,e);
71     return true;
72 }