1
/***************************************************************************
2
* Copyright (C) 2010 by Kai Dombrowe <just89@gmx.de> *
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 of the License, or *
7
* (at your option) any later version. *
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. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
23
#include "devicesearchdialog.h"
24
#include "keymonmanager.h"
27
#include <klocalizedstring.h>
28
#include <kmessagebox.h>
31
#include <QtGui/QTreeWidgetItem>
34
DeviceSearchDialog::DeviceSearchDialog(const KeyMon::DeviceInfo::DeviceType &type, QWidget *parent)
38
QWidget *main = new QWidget(this);
42
setAttribute(Qt::WA_DeleteOnClose);
46
case KeyMon::DeviceInfo::MouseType:
47
case KeyMon::DeviceInfo::KeyboardType: {
48
foreach (const KeyMon::DeviceInfo &info, KeyMonManager::self()->getInputDeviceList()) {
49
if (info.type != type) {
52
QTreeWidgetItem *item = new QTreeWidgetItem;
53
if (!info.icon.isEmpty()) {
54
item->setIcon(0, KIcon(info.icon));
56
item->setText(0, info.name);
57
item->setText(1, info.file);
58
item->setText(2, info.uuid);
59
treeWidget->addTopLevelItem(item);
66
case KeyMon::DeviceInfo::MouseType: setWindowTitle(i18n("Mouse")); break;
67
case KeyMon::DeviceInfo::KeyboardType: setWindowTitle(i18n("Keyboard")); break;
71
connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int)));
72
treeWidget->header()->setResizeMode(QHeaderView::ResizeToContents);
75
if (treeWidget->topLevelItemCount() == 0) {
76
KMessageBox::information(this, i18n("No devices found."));
83
void DeviceSearchDialog::dialogFinished(const int &ret)
86
if (ret == KDialog::Accepted) {
87
QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
88
if (items.isEmpty()) {
91
emit deviceSelected(items.first()->text(2));
97
#include "devicesearchdialog.moc"