blob: 93f85965ee0c9b9fb88471f3b847b522080111ba [file] [log] [blame]
Isa Nanic601de1d2018-10-23 11:37:26 -04001/***************************************************************************
2 * Copyright (C) 2018 by Savoir-faire Linux *
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 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();
Isa Nanic601de1d2018-10-23 11:37:26 -040043
Andreas Traczyk43c08232018-10-31 13:42:09 -040044protected:
Isa Nanic601de1d2018-10-23 11:37:26 -040045 void paintEvent(QPaintEvent* e);
Andreas Traczyk43c08232018-10-31 13:42:09 -040046 void resizeEvent(QResizeEvent *event);
Isa Nanic37ccc1c2018-10-26 14:16:28 -040047 void mousePressEvent(QMouseEvent* mouseEvent);
Andreas Traczyk43c08232018-10-31 13:42:09 -040048 void mouseMoveEvent(QMouseEvent* event);
Isa Nanic37ccc1c2018-10-26 14:16:28 -040049 void leaveEvent(QEvent * event);
50
Andreas Traczyk43c08232018-10-31 13:42:09 -040051private:
52 void importLabelPhoto(int index);
53 void setupSettingsButton();
Isa Nanic37ccc1c2018-10-26 14:16:28 -040054 void showPopup();
55 void hidePopup();
Isa Nanic601de1d2018-10-23 11:37:26 -040056
57 AccountItemDelegate* accountItemDelegate_;
58 std::unique_ptr<AccountListModel> accountListModel_;
59
60 QPixmap currentAccountAvatarImage_;
Isa Nanic37ccc1c2018-10-26 14:16:28 -040061 int cellHeight_ = 50; // [screen awareness]
62 const int elidConst = 35; // [screen awareness]
63 const int gearBorder_ = 4;
64 const int gearSize_ = 24;
65 bool popupPresent = false;
66
67 QPoint gearPoint_;
Isa Nanic37ccc1c2018-10-26 14:16:28 -040068 QLabel gearLabel_;
Isa Nanic6e4a39a2018-12-04 14:26:02 -050069};