void DBusTabletService::onTabletAdded(const TabletInformation& info) { Q_D ( DBusTabletService ); d->tabletInformationList.insert(info.get(TabletInfo::TabletId), info); emit tabletAdded(info.get(TabletInfo::TabletId)); }
void TabletHandler::onTabletRemoved( const TabletInformation& info ) { Q_D( TabletHandler ); TabletBackendInterface *tbi = d->tabletBackendList.value(info.get(TabletInfo::TabletId)); TabletInformation ti = d->tabletInformationList.value(info.get(TabletInfo::TabletId)); if ( tbi && ti.getTabletSerial() == info.getTabletSerial() ) { emit notify( QLatin1String("tabletRemoved"), i18n("Tablet removed"), i18n("Tablet %1 removed", ti.get(TabletInfo::TabletName) )); QString tabletId = info.get(TabletInfo::TabletId); d->tabletBackendList.remove(tabletId); d->tabletInformationList.remove(tabletId); delete tbi; ProfileManager *pm = d->profileManagerList.take(tabletId); delete pm; emit tabletRemoved(tabletId); } }
void TabletHandler::onTabletAdded( const TabletInformation& info ) { Q_D( TabletHandler ); // if we already have a device ... skip this step QString tabletId = info.get(TabletInfo::TabletId); if(d->tabletBackendList.contains(tabletId)) { kDebug() << QString::fromLatin1("Ignoring tablet '%1' as another one with same name is already connected.") .arg(info.get(TabletInfo::TabletId)); return; } kDebug() << "Taking control of new tablet" << info.get(TabletInfo::TabletName) << "(" << info.get(TabletInfo::TabletId) << ") [" << (info.hasDevice(DeviceType::Stylus) ? "stylus" : "") << (info.hasDevice(DeviceType::Eraser) ? "eraser" : "") << (info.hasDevice(DeviceType::Pad) ? "pad" : "") << (info.hasDevice(DeviceType::Touch) ? "touch" : "") << (info.hasDevice(DeviceType::Cursor) ? "cursor" : "") << "]"; // create tablet backend TabletBackendInterface *tbi = TabletBackendFactory::createBackend(info); if (tbi == NULL) { kError() << "Could not create tablet backend interface. Ignoring Tablet"; return; // no valid backend found } d->tabletBackendList.insert(tabletId, tbi); // update tablet information d->profileManagerList.insert(tabletId, new ProfileManager(d->profileFile)); d->tabletInformationList.insert(tabletId, info); // if we found something notify about it and set the default profile to it emit notify( QLatin1String("tabletAdded"), i18n("Tablet Connected"), i18n("New tablet '%1' connected.", info.get(TabletInfo::TabletName) )); // set profile which was last used setProfile(tabletId, d->mainConfig.getLastProfile(info.get(TabletInfo::TabletName))); // notify everyone else about the new tablet emit tabletAdded(info); }