keepassxc

Форк
0
/
WindowSelectComboBox.cpp 
68 строк · 1.9 Кб
1
/*
2
 *  Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
3
 *
4
 *  This program is free software: you can redistribute it and/or modify
5
 *  it under the terms of the GNU General Public License as published by
6
 *  the Free Software Foundation, either version 2 or (at your option)
7
 *  version 3 of the License.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU General Public License
15
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18
#include "WindowSelectComboBox.h"
19

20
#include <QLineEdit>
21

22
#include "autotype/AutoType.h"
23

24
WindowSelectComboBox::WindowSelectComboBox(QWidget* parent)
25
    : QComboBox(parent)
26
{
27
    setEditable(true);
28
    setInsertPolicy(QComboBox::NoInsert);
29
    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::ComboBox));
30

31
    // first item is always the current content of the line edit
32
    insertItem(0, "");
33
}
34

35
void WindowSelectComboBox::refreshWindowList()
36
{
37
    model()->setData(model()->index(0, 0), lineEdit()->text());
38

39
    while (count() > 1) {
40
        removeItem(1);
41
    }
42
    insertItems(1, autoType()->windowTitles());
43
}
44

45
void WindowSelectComboBox::showPopup()
46
{
47
    if (lineEdit()->isReadOnly()) {
48
        return;
49
    }
50

51
    refreshWindowList();
52

53
    QComboBox::showPopup();
54
}
55

56
QSize WindowSelectComboBox::sizeHint() const
57
{
58
    QSize size = lineEdit()->sizeHint();
59
    size.setHeight(qMax(size.height(), QComboBox::sizeHint().height()));
60
    return size;
61
}
62

63
QSize WindowSelectComboBox::minimumSizeHint() const
64
{
65
    QSize size = lineEdit()->minimumSizeHint();
66
    size.setHeight(qMax(size.height(), QComboBox::minimumSizeHint().height()));
67
    return size;
68
}
69

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.