New UI, Vkbd and unicode support
[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(((QWidget *)this->parent())->testAttribute(Qt::WA_Maemo5PortraitOrientation))
46         {
47             ui->sBox->setReadOnly(true);
48             //ui->sBox->setText("Portrait");
49         }
50         else
51             ui->sBox->setReadOnly(false);
52     }
53 }
54
55 bool topBar::eventFilter(QObject *obj, QEvent *e)
56 {
57     if(obj == ui->sBox && ui->sBox->isReadOnly() && e->type() == QEvent::MouseButtonRelease)
58     {
59         if(!kb)
60         {
61             this->kb = new vkb(this);
62             connect(kb,SIGNAL(submitText(QString)),ui->sBox,SLOT(setText(QString)));
63         }
64         kb->setText(ui->sBox->text());
65         kb->show();
66     }
67     else
68         return QWidget::eventFilter(obj,e);
69 }