UBPlatformUtils.h 2.74 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

#ifndef UBPLATFORMUTILS_H_
#define UBPLATFORMUTILS_H_

#include <QtCore>
#include <QIcon>

class QMainWindow;

#define SYMBOL_KEYS_COUNT 47

struct KEYBT
{
	const QChar symbol1;
	const int code1;
	const QChar symbol2;
    const int code2;

	KEYBT(unsigned int _symbol1,
		unsigned int _symbol2):
        symbol1(_symbol1),
        code1(_symbol1),
        symbol2(_symbol2),
        code2(_symbol2){}


    KEYBT(QChar _symbol1,
		int _code1,
		QChar _symbol2,
		int _code2):
			symbol1(_symbol1),
            code1(_code1),
            symbol2(_symbol2),
            code2(_code2){}
    };

	class UBKeyboardLocale
	{
	public:
		UBKeyboardLocale(const QString& _fullName,
			const QString& _name,
			const QString& _id,
			QIcon* _icon,
			KEYBT** _symbols)
			:fullName(_fullName),name(_name), id(_id), icon(_icon),
                        constSymbols(NULL), varSymbols(_symbols)
		{}
		UBKeyboardLocale(const QString& _fullName,
			const QString& _name,
			const QString& _id,
			QIcon* _icon,
			const KEYBT _symbols[])
			:fullName(_fullName),name(_name),  id(_id), icon(_icon),
                        constSymbols(_symbols), varSymbols(NULL)
		{}

		~UBKeyboardLocale();

		const QString fullName;
		const QString name;
		const QString id;
		QIcon* icon;
		const KEYBT* operator[] (int index) const
		{
			return (varSymbols==NULL)? constSymbols + index : varSymbols[index];
		}
	private:
		const KEYBT* constSymbols;
		KEYBT** varSymbols;
	};


class UBPlatformUtils
{
    private:
        UBPlatformUtils();
        virtual ~UBPlatformUtils();

		static void initializeKeyboardLayouts();
		static int nKeyboardLayouts;
		static UBKeyboardLocale** keyboardLayouts;

    public:
        static void init();
		static void destroy();

        static QString applicationResourcesDirectory();

        static void hideFile(const QString &filePath);
        static void setFileType(const QString &filePath, unsigned long fileType);

        static void fadeDisplayOut();
        static void fadeDisplayIn();

        static QString preferredTranslation();
        static QString preferredLanguage();

        static void disableShadow(QWidget *widget);

        static bool hasVirtualKeyboard();
        //static void showVirtualKeyboard();

        static void runInstaller(const QString &installerFilePath);

        static void bringPreviousProcessToFront();

        static QString osUserLoginName();

        static void setDesktopMode(bool desktop);

		static void setWindowNonActivableFlag(QWidget* widget, bool nonAcivable);

        static QString computerName();

		static UBKeyboardLocale** getKeyboardLayouts(int& nCount);


};



#endif /* UBPLATFORMUTILS_H_ */