Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Edric Milaret | 4bba46d | 2015-04-29 16:33:38 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015 by Savoir-Faire Linux * |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 3 | * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 3 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | **************************************************************************/ |
| 18 | |
| 19 | #include "mainbar.h" |
| 20 | #include "ui_mainbar.h" |
| 21 | |
| 22 | #include "callmodel.h" |
| 23 | #include "aboutdialog.h" |
| 24 | |
| 25 | MainBar::MainBar(QWidget *parent) : |
| 26 | NavWidget(END, parent), |
| 27 | ui(new Ui::MainBar), |
| 28 | menu_(new QMenu()) |
| 29 | { |
| 30 | ui->setupUi(this); |
| 31 | |
| 32 | auto aboutAction = new QAction("About", this); |
| 33 | menu_->addAction(aboutAction); |
| 34 | connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog())); |
| 35 | |
| 36 | auto exitAction = new QAction("Exit", this); |
| 37 | menu_->addAction(exitAction); |
| 38 | connect(exitAction, SIGNAL(triggered()), this, SLOT(on_exitButton_clicked())); |
| 39 | |
| 40 | ui->logoToolButton->setMenu(menu_); |
| 41 | ui->logoToolButton->setPopupMode(QToolButton::InstantPopup); |
| 42 | } |
| 43 | |
| 44 | MainBar::~MainBar() |
| 45 | { |
| 46 | delete ui; |
| 47 | } |
| 48 | |
| 49 | void |
| 50 | MainBar::on_confButton_clicked() |
| 51 | { |
| 52 | emit NavigationRequested(ScreenEnum::ConfScreen); |
| 53 | } |
| 54 | |
| 55 | void |
| 56 | MainBar::on_callLineEdit_returnPressed() |
| 57 | { |
| 58 | callAction(); |
| 59 | } |
| 60 | |
| 61 | void |
| 62 | MainBar::on_callButton_clicked() |
| 63 | { |
| 64 | callAction(); |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | MainBar::callAction() { |
| 69 | if (ui->callLineEdit->text().isEmpty()) |
| 70 | return; |
| 71 | auto outCall = CallModel::instance()->dialingCall(ui->callLineEdit->text()); |
| 72 | outCall->setDialNumber(ui->callLineEdit->text()); |
| 73 | outCall->performAction(Call::Action::ACCEPT); |
| 74 | } |
| 75 | |
| 76 | void |
| 77 | MainBar::showAboutDialog() { |
| 78 | AboutDialog *aboutDialog = new AboutDialog(); |
| 79 | |
| 80 | aboutDialog->exec(); |
| 81 | |
| 82 | delete aboutDialog; |
| 83 | } |
| 84 | |
| 85 | void |
| 86 | MainBar::on_exitButton_clicked() |
| 87 | { |
| 88 | QCoreApplication::exit(); |
| 89 | } |
| 90 | |
| 91 | void |
| 92 | MainBar::on_minimizeButton_clicked() |
| 93 | { |
| 94 | emit minimize(); |
| 95 | } |
| 96 | |
| 97 | void |
| 98 | MainBar::atExit() { |
| 99 | |
| 100 | } |