blob: a852a18ee727f391b5a571cb9eea384d451c5297 [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;
54}
55
56void
57MainWindow::mousePressEvent(QMouseEvent *evt)
58{
59 oldPos_ = evt->globalPos();
60}
61
62void
63MainWindow::mouseMoveEvent(QMouseEvent *evt)
64{
65 if(evt->buttons() & Qt::LeftButton) {
66 const auto delta = evt->globalPos() - oldPos_;
67 move(x() + delta.x(), y() + delta.y());
68 oldPos_ = evt->globalPos();
69 }
70}
71
72void
73MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) {
74 if (reason != QSystemTrayIcon::ActivationReason::Context)
75 this->show();
76}
Edric Milaret3a23e492015-04-29 14:23:48 -040077
Edric Milaret4bba46d2015-04-29 16:33:38 -040078void
79MainWindow::onIncomingCall(Call *call) {
Edric Milaret3a23e492015-04-29 14:23:48 -040080 Q_UNUSED(call);
81 QWidget::showNormal();
82}