A Divendres, 24 de juliol de 2009, Kevin Ottens va escriure:
> On Monday 13 July 2009 23:44:23 Albert Astals Cid wrote:
> > Hi, following my quest to make Solid and its users nice regarding i18n
> > usage i've stumbled upon Solid::DeviceInterface::typeToString that
> > returns non translatable strings from the .moc autogenerated code
> >
> > That function is used in device notifier plasmoid (no idea if in more
> > places)
>
> I thought that Ben was the only one needing that in his KCM. And indeed
> he's not alone there... I missed the notifier case and there's probably
> more.
>
> > I'd suggest adding a new Solid::DeviceInterface::typeToTranslatedString
> > as the other function might still be useful for something that needs
> > stability when changing languages (like configuration keys).
> >
> > What do you think?
>
> Yes it has to be an extra static method. No I don't like the name though
> (surprise!). ;-)
>
> What about DeviceInterface::typeDescription(Type type) ?
> It'd map just nicely with the Device::description() you introduced earlier
> I think. Anyone committing to implementing it? Patch should be a no brainer
> to review. Bonus point to coordinate with Ben to reuse the strings he
> already has in the KCM. ;-)
Here it comes.
Albert
>
> Regards.
Index: solid/deviceinterface.cpp
===================================================================
--- solid/deviceinterface.cpp (revision 1001616)
+++ solid/deviceinterface.cpp (working copy)
@@ -60,6 +60,56 @@
return (Type)metaEnum.keyToValue(type.toUtf8());
}
+QString Solid::DeviceInterface::typeDescription(Type type)
+{
+ switch (type)
+ {
+ case Unknown:
+ return QObject::tr("Unknown", "Unknown device type");
+ case GenericInterface:
+ return QObject::tr("Generic Interface", "Generic Interface device type");
+ case Processor:
+ return QObject::tr("Processor", "Processor device type");
+ case Block:
+ return QObject::tr("Block", "Block device type");
+ case StorageAccess:
+ return QObject::tr("Storage Access", "Storage Access device type");
+ case StorageDrive:
+ return QObject::tr("Storage Drive", "Storage Drive device type");
+ case OpticalDrive:
+ return QObject::tr("Optical Drive", "Optical Drive device type");
+ case StorageVolume:
+ return QObject::tr("Storage Volume", "Storage Volume device type");
+ case OpticalDisc:
+ return QObject::tr("Optical Disc", "Optical Disc device type");
+ case Camera:
+ return QObject::tr("Camera", "Camera device type");
+ case PortableMediaPlayer:
+ return QObject::tr("Portable Media Player", "Portable Media Player device type");
+ case NetworkInterface:
+ return QObject::tr("Network Interface", "Network Interface device type");
+ case AcAdapter:
+ return QObject::tr("Ac Adapter", "Ac Adapter device type");
+ case Battery:
+ return QObject::tr("Battery", "Battery device type");
+ case Button:
+ return QObject::tr("Button", "Button device type");
+ case AudioInterface:
+ return QObject::tr("Audio Interface", "Audio Interface device type");
+ case DvbInterface:
+ return QObject::tr("Dvb Interface", "Dvb Interface device type");
+ case Video:
+ return QObject::tr("Video", "Video device type");
+ case SerialInterface:
+ return QObject::tr("Serial Interface", "Serial Interface device type");
+ case SmartCardReader:
+ return QObject::tr("Smart Card Reader", "Smart Card Reader device type");
+ case Last:
+ return QString();
+ }
+ return QString();
+}
+
Solid::DeviceInterfacePrivate::DeviceInterfacePrivate()
{
Index: solid/deviceinterface.h
===================================================================
--- solid/deviceinterface.h (revision 1001616)
+++ solid/deviceinterface.h (working copy)
@@ -85,16 +85,22 @@
/**
*
- * @return the name of the device interface type
+ * @return the non translated name of the device interface type
*/
static QString typeToString(Type type);
/**
*
- * @return the device interface type for the given name
+ * @return the device interface type for the non translated given name
*/
static Type stringToType(const QString &type);
+ /**
+ *
+ * @return the translated description of the device interface type
+ */
+ static QString typeDescription(Type type);
+
protected:
/**
* @internal
_______________________________________________
Kde-hardware-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-hardware-devel