blob: 58716d36262721c84608d557d362717b0714e8e8 [file] [log] [blame]
Isa Nanic601de1d2018-10-23 11:37:26 -04001/***************************************************************************
Sébastien Blin68abac92019-01-02 17:41:31 -05002 * Copyright (C) 2019-2019 by Savoir-faire Linux *
Isa Nanic601de1d2018-10-23 11:37:26 -04003 * 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 Nanic37ccc1c2018-10-26 14:16:28 -040021#include <QLabel>
Isa Nanic601de1d2018-10-23 11:37:26 -040022#include "accountlistmodel.h"
23#include "accountitemdelegate.h"
24
25namespace Ui {
26 class CurrentAccountComboBox;
27}
28
29class CurrentAccountComboBox : public QComboBox
30{
31 Q_OBJECT
Isa Nanic1c20ef12018-10-25 11:49:30 -040032 CurrentAccountComboBox(const CurrentAccountComboBox& cpy);
Isa Nanic601de1d2018-10-23 11:37:26 -040033
34public:
35 explicit CurrentAccountComboBox(QWidget* parent = nullptr);
36 ~CurrentAccountComboBox();
Andreas Traczyk43c08232018-10-31 13:42:09 -040037 void accountListUpdate();
38 void setCurrentIndex(int index);
Isa Nanic6e4a39a2018-12-04 14:26:02 -050039 void updateComboBoxDisplay();
Isa Nanic37ccc1c2018-10-26 14:16:28 -040040
Andreas Traczyk43c08232018-10-31 13:42:09 -040041signals:
42 void settingsButtonClicked();
Andreas Traczyk6ace34f2018-12-14 14:31:23 -050043 void newAccountClicked();
Isa Nanic601de1d2018-10-23 11:37:26 -040044
Andreas Traczyk43c08232018-10-31 13:42:09 -040045protected:
Isa Nanic601de1d2018-10-23 11:37:26 -040046 void paintEvent(QPaintEvent* e);
Andreas Traczyk43c08232018-10-31 13:42:09 -040047 void resizeEvent(QResizeEvent *event);
Isa Nanic37ccc1c2018-10-26 14:16:28 -040048 void mousePressEvent(QMouseEvent* mouseEvent);
Andreas Traczyk43c08232018-10-31 13:42:09 -040049 void mouseMoveEvent(QMouseEvent* event);
Isa Nanic37ccc1c2018-10-26 14:16:28 -040050 void leaveEvent(QEvent * event);
Andreas Traczyk6ace34f2018-12-14 14:31:23 -050051 void showPopup();
52 void hidePopup();
Isa Nanic37ccc1c2018-10-26 14:16:28 -040053
Andreas Traczyk43c08232018-10-31 13:42:09 -040054private:
55 void importLabelPhoto(int index);
56 void setupSettingsButton();
Isa Nanic601de1d2018-10-23 11:37:26 -040057
58 AccountItemDelegate* accountItemDelegate_;
59 std::unique_ptr<AccountListModel> accountListModel_;
60
61 QPixmap currentAccountAvatarImage_;
Isa Nanic37ccc1c2018-10-26 14:16:28 -040062 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 Nanic37ccc1c2018-10-26 14:16:28 -040069 QLabel gearLabel_;
Isa Nanic6e4a39a2018-12-04 14:26:02 -050070};