Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Anthony LĂ©onard | 2fde81d | 2017-04-17 10:06:55 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015-2017 by Savoir-faire Linux * |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -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 | |
Edric Milaret | 5f316da | 2015-09-28 11:57:42 -0400 | [diff] [blame] | 19 | #pragma once |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 20 | |
| 21 | #include <QDialog> |
| 22 | #include <QSortFilterProxyModel> |
| 23 | |
| 24 | #include "callmodel.h" |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 25 | #include "recentmodel.h" |
| 26 | |
| 27 | #include "smartlistdelegate.h" |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 28 | |
Andreas Traczyk | e0a60b5 | 2018-07-10 18:16:15 -0400 | [diff] [blame^] | 29 | #include <ciso646> |
| 30 | |
Nicolas Jager | 0a9fc60 | 2016-03-11 18:35:42 -0500 | [diff] [blame] | 31 | class QPropertyAnimation; |
| 32 | class QGraphicsOpacityEffect; |
| 33 | |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 34 | namespace Ui { |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 35 | class CallUtilsDialog; |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 36 | } |
| 37 | |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 38 | class NotCurrentProxyModel : public QSortFilterProxyModel |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 39 | { |
| 40 | public: |
Edric Milaret | 74474f5 | 2016-05-16 13:36:23 -0400 | [diff] [blame] | 41 | explicit NotCurrentProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent) |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 42 | { |
| 43 | setSourceModel(parent); |
| 44 | } |
| 45 | virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const |
| 46 | { |
Edric Milaret | 4ba5c82 | 2015-10-06 16:27:33 -0400 | [diff] [blame] | 47 | if (not sourceModel() || source_parent.isValid()) |
| 48 | return false; |
| 49 | auto idx = sourceModel()->index(source_row,0,source_parent); |
| 50 | if (not idx.isValid()) |
| 51 | return false; |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 52 | auto call = RecentModel::instance().getActiveCall(idx); |
| 53 | return not call || not (call->state() == Call::State::CURRENT); |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 54 | } |
| 55 | }; |
| 56 | |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 57 | class CallUtilsDialog : public QDialog |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 58 | { |
| 59 | Q_OBJECT |
| 60 | |
| 61 | public: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 62 | explicit CallUtilsDialog(QWidget* parent = 0); |
| 63 | ~CallUtilsDialog(); |
| 64 | |
| 65 | void setConfMode(bool active); |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 66 | |
Nicolas Jager | 0a9fc60 | 2016-03-11 18:35:42 -0500 | [diff] [blame] | 67 | protected: |
| 68 | void enterEvent(QEvent* event); |
| 69 | void leaveEvent(QEvent* event); |
| 70 | |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 71 | //UI SLOTS |
| 72 | protected slots: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 73 | void showEvent(QShowEvent* event); |
| 74 | void closeEvent(QCloseEvent* event); |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 75 | private slots: |
Edric Milaret | 63c34b6 | 2016-01-15 11:52:47 -0500 | [diff] [blame] | 76 | void on_doTransferButton_clicked(); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 77 | void on_contactView_doubleClicked(const QModelIndex& index); |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 78 | |
| 79 | private: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 80 | Ui::CallUtilsDialog* ui; |
| 81 | bool confMode_; |
| 82 | SmartListDelegate* smartListDelegate_; |
| 83 | NotCurrentProxyModel* notCurrentProxyModel_; |
Nicolas Jager | 0a9fc60 | 2016-03-11 18:35:42 -0500 | [diff] [blame] | 84 | QPixmap* spikeMask_; |
| 85 | QPropertyAnimation* fadeAnim_; |
| 86 | constexpr static int fadeOverlayTime_ = 250; //msec |
| 87 | QGraphicsOpacityEffect* effect_; |
Edric Milaret | 4ba5c82 | 2015-10-06 16:27:33 -0400 | [diff] [blame] | 88 | |
| 89 | void removeProxyModel(); |
Nicolas Jager | 0a9fc60 | 2016-03-11 18:35:42 -0500 | [diff] [blame] | 90 | |
| 91 | signals: |
| 92 | void isVisible(bool visible); |
| 93 | |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 94 | }; |
| 95 | |