Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Sébastien Blin | 68abac9 | 2019-01-02 17:41:31 -0500 | [diff] [blame] | 2 | * Copyright (C) 2019-2019 by Savoir-faire Linux * |
Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 3 | * Author: Isa Nanic <isa.nanic@savoirfairelinux.com> * |
| 4 | * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> * |
| 5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 3 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 18 | **************************************************************************/ |
| 19 | #pragma once |
| 20 | #include <QComboBox> |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 21 | #include <QLabel> |
Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 22 | #include "accountlistmodel.h" |
| 23 | #include "accountitemdelegate.h" |
| 24 | |
| 25 | namespace Ui { |
| 26 | class CurrentAccountComboBox; |
| 27 | } |
| 28 | |
| 29 | class CurrentAccountComboBox : public QComboBox |
| 30 | { |
| 31 | Q_OBJECT |
Isa Nanic | 1c20ef1 | 2018-10-25 11:49:30 -0400 | [diff] [blame] | 32 | CurrentAccountComboBox(const CurrentAccountComboBox& cpy); |
Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 33 | |
| 34 | public: |
| 35 | explicit CurrentAccountComboBox(QWidget* parent = nullptr); |
| 36 | ~CurrentAccountComboBox(); |
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 37 | void accountListUpdate(); |
| 38 | void setCurrentIndex(int index); |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 39 | void updateComboBoxDisplay(); |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 40 | |
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 41 | signals: |
| 42 | void settingsButtonClicked(); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 43 | void newAccountClicked(); |
Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 44 | |
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 45 | protected: |
Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 46 | void paintEvent(QPaintEvent* e); |
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 47 | void resizeEvent(QResizeEvent *event); |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 48 | void mousePressEvent(QMouseEvent* mouseEvent); |
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 49 | void mouseMoveEvent(QMouseEvent* event); |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 50 | void leaveEvent(QEvent * event); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 51 | void showPopup(); |
| 52 | void hidePopup(); |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 53 | |
Andreas Traczyk | 43c0823 | 2018-10-31 13:42:09 -0400 | [diff] [blame] | 54 | private: |
| 55 | void importLabelPhoto(int index); |
| 56 | void setupSettingsButton(); |
Isa Nanic | 601de1d | 2018-10-23 11:37:26 -0400 | [diff] [blame] | 57 | |
| 58 | AccountItemDelegate* accountItemDelegate_; |
| 59 | std::unique_ptr<AccountListModel> accountListModel_; |
| 60 | |
| 61 | QPixmap currentAccountAvatarImage_; |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 62 | int cellHeight_ = 50; // [screen awareness] |
| 63 | const int elidConst = 35; // [screen awareness] |
| 64 | const int gearBorder_ = 4; |
| 65 | const int gearSize_ = 24; |
| 66 | bool popupPresent = false; |
| 67 | |
| 68 | QPoint gearPoint_; |
Isa Nanic | 37ccc1c | 2018-10-26 14:16:28 -0400 | [diff] [blame] | 69 | QLabel gearLabel_; |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 70 | }; |