blob: 5da664326366f87bb0728aeb08b306547d633e9b [file] [log] [blame]
Edric Milaret5cbf2b62015-07-09 11:36:53 -04001/***************************************************************************
Anthony LĂ©onard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2015-2017 by Savoir-faire Linux *
Edric Milaret5cbf2b62015-07-09 11:36:53 -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
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret5cbf2b62015-07-09 11:36:53 -040020
21#include <QDialog>
22#include <QSortFilterProxyModel>
23
24#include "callmodel.h"
Edric Milaret80e0b212015-10-16 10:07:43 -040025#include "recentmodel.h"
26
27#include "smartlistdelegate.h"
Edric Milaret5cbf2b62015-07-09 11:36:53 -040028
Nicolas Jager0a9fc602016-03-11 18:35:42 -050029class QPropertyAnimation;
30class QGraphicsOpacityEffect;
31
Edric Milaret5cbf2b62015-07-09 11:36:53 -040032namespace Ui {
Edric Milaret80e0b212015-10-16 10:07:43 -040033 class CallUtilsDialog;
Edric Milaret5cbf2b62015-07-09 11:36:53 -040034}
35
Edric Milaret80e0b212015-10-16 10:07:43 -040036class NotCurrentProxyModel : public QSortFilterProxyModel
Edric Milaret5cbf2b62015-07-09 11:36:53 -040037{
38public:
Edric Milaret74474f52016-05-16 13:36:23 -040039 explicit NotCurrentProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
Edric Milaret5cbf2b62015-07-09 11:36:53 -040040 {
41 setSourceModel(parent);
42 }
43 virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
44 {
Edric Milaret4ba5c822015-10-06 16:27:33 -040045 if (not sourceModel() || source_parent.isValid())
46 return false;
47 auto idx = sourceModel()->index(source_row,0,source_parent);
48 if (not idx.isValid())
49 return false;
Edric Milaret80e0b212015-10-16 10:07:43 -040050 auto call = RecentModel::instance().getActiveCall(idx);
51 return not call || not (call->state() == Call::State::CURRENT);
Edric Milaret5cbf2b62015-07-09 11:36:53 -040052 }
53};
54
Edric Milaret80e0b212015-10-16 10:07:43 -040055class CallUtilsDialog : public QDialog
Edric Milaret5cbf2b62015-07-09 11:36:53 -040056{
57 Q_OBJECT
58
59public:
Edric Milaret80e0b212015-10-16 10:07:43 -040060 explicit CallUtilsDialog(QWidget* parent = 0);
61 ~CallUtilsDialog();
62
63 void setConfMode(bool active);
Edric Milaret5cbf2b62015-07-09 11:36:53 -040064
Nicolas Jager0a9fc602016-03-11 18:35:42 -050065protected:
66 void enterEvent(QEvent* event);
67 void leaveEvent(QEvent* event);
68
Edric Milaret5cbf2b62015-07-09 11:36:53 -040069//UI SLOTS
70protected slots:
Edric Milaret80e0b212015-10-16 10:07:43 -040071 void showEvent(QShowEvent* event);
72 void closeEvent(QCloseEvent* event);
Edric Milaret5cbf2b62015-07-09 11:36:53 -040073private slots:
Edric Milaret63c34b62016-01-15 11:52:47 -050074 void on_doTransferButton_clicked();
Edric Milaret80e0b212015-10-16 10:07:43 -040075 void on_contactView_doubleClicked(const QModelIndex& index);
Edric Milaret5cbf2b62015-07-09 11:36:53 -040076
77private:
Edric Milaret80e0b212015-10-16 10:07:43 -040078 Ui::CallUtilsDialog* ui;
79 bool confMode_;
80 SmartListDelegate* smartListDelegate_;
81 NotCurrentProxyModel* notCurrentProxyModel_;
Nicolas Jager0a9fc602016-03-11 18:35:42 -050082 QPixmap* spikeMask_;
83 QPropertyAnimation* fadeAnim_;
84 constexpr static int fadeOverlayTime_ = 250; //msec
85 QGraphicsOpacityEffect* effect_;
Edric Milaret4ba5c822015-10-06 16:27:33 -040086
87 void removeProxyModel();
Nicolas Jager0a9fc602016-03-11 18:35:42 -050088
89signals:
90 void isVisible(bool visible);
91
Edric Milaret5cbf2b62015-07-09 11:36:53 -040092};
93