blob: 0cd33f09b9f99d8690d13a1551805cf4625df6e0 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Edric Milaret4bba46d2015-04-29 16:33:38 -04002 * Copyright (C) 2015 by Savoir-Faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * 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 "mainwindow.h"
20#include "ui_mainwindow.h"
21
22#include <QSizeGrip>
23
24MainWindow::MainWindow(QWidget *parent) :
25 QMainWindow(parent),
26 ui(new Ui::MainWindow)
27{
28 ui->setupUi(this);
29
30 this->setWindowFlags(Qt::CustomizeWindowHint);
31 this->setWindowFlags(Qt::FramelessWindowHint);
32
Edric Milaret18e81842015-04-29 13:51:36 -040033 QIcon icon(":images/ring.png");
Edric Milaret627500d2015-03-27 16:41:40 -040034
35 this->setWindowIcon(icon);
36
37 sysIcon_.setIcon(icon);
38 sysIcon_.show();
39
40 connect(&sysIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
41 this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
42
Edric Milaret3a23e492015-04-29 14:23:48 -040043 connect(CallModel::instance(), SIGNAL(incomingCall(Call*)),
44 this, SLOT(onIncomingCall(Call*)));
45
Edric Milaret627500d2015-03-27 16:41:40 -040046 navStack_ = new NavStack(ui->bar, ui->stackedWidgetView, this);
47 ui->verticalLayout_2->addWidget(
48 new QSizeGrip(this), 0, Qt::AlignBottom | Qt::AlignRight);
49}
50
51MainWindow::~MainWindow()
52{
53 delete ui;
Edric Milaret01f23842015-06-22 14:46:01 -040054 delete navStack_;
Edric Milaret627500d2015-03-27 16:41:40 -040055}
56
57void
58MainWindow::mousePressEvent(QMouseEvent *evt)
59{
60 oldPos_ = evt->globalPos();
61}
62
63void
64MainWindow::mouseMoveEvent(QMouseEvent *evt)
65{
66 if(evt->buttons() & Qt::LeftButton) {
67 const auto delta = evt->globalPos() - oldPos_;
68 move(x() + delta.x(), y() + delta.y());
69 oldPos_ = evt->globalPos();
70 }
71}
72
73void
74MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) {
75 if (reason != QSystemTrayIcon::ActivationReason::Context)
76 this->show();
77}
Edric Milaret3a23e492015-04-29 14:23:48 -040078
Edric Milaret4bba46d2015-04-29 16:33:38 -040079void
80MainWindow::onIncomingCall(Call *call) {
Edric Milaret3a23e492015-04-29 14:23:48 -040081 Q_UNUSED(call);
82 QWidget::showNormal();
83}