EncryptioNgSimliteDecryptor::EncryptioNgSimliteDecryptor(const Account &account, EncryptionProvider *provider, QObject *parent) :
		Decryptor(provider, parent), MyAccount(account)
{
	connect(KeysManager::instance(), SIGNAL(keyAdded(Key)), this, SLOT(keyUpdated(Key)));
	connect(KeysManager::instance(), SIGNAL(keyUpdated(Key)), this, SLOT(keyUpdated(Key)));
	connect(KeysManager::instance(), SIGNAL(keyRemoved(Key)), this, SLOT(keyUpdated(Key)));

	updateKey();
}
EncryptioNgSimliteDecryptor::~EncryptioNgSimliteDecryptor()
{
	disconnect(KeysManager::instance(), SIGNAL(keyAdded(Key)), this, SLOT(keyUpdated(Key)));
	disconnect(KeysManager::instance(), SIGNAL(keyUpdated(Key)), this, SLOT(keyUpdated(Key)));
	disconnect(KeysManager::instance(), SIGNAL(keyRemoved(Key)), this, SLOT(keyUpdated(Key)));
}
예제 #3
0
TestWidget::TestWidget() : QWidget(0), m_lock(this)
{
    QMap<Qt::Key, QString> mods;
    mods.insert(Qt::Key_Shift, "Shift");
    mods.insert(Qt::Key_Control, "Ctrl");
    mods.insert(Qt::Key_Alt, "Alt");
    mods.insert(Qt::Key_Meta, "Meta");
    mods.insert(Qt::Key_Super_L, "Super");
    mods.insert(Qt::Key_Hyper_L, "Hyper");
    mods.insert(Qt::Key_AltGr, "AltGr");
    mods.insert(Qt::Key_NumLock, "NumLock");
    mods.insert(Qt::Key_CapsLock, "CapsLock");
    mods.insert(Qt::Key_ScrollLock, "ScrollLock");

    QMap<Qt::MouseButton, QString> buttons;
    buttons.insert(Qt::LeftButton, "Left Button");
    buttons.insert(Qt::RightButton, "Right Button");
    buttons.insert(Qt::MidButton, "Middle Button");
    buttons.insert(Qt::XButton1, "First X Button");
    buttons.insert(Qt::XButton2, "Second X Button");

    QVBoxLayout *layout = new QVBoxLayout(this);
    
    QMap<Qt::Key, QString>::const_iterator it;
    QMap<Qt::Key, QString>::const_iterator end = mods.constEnd();
    for (it = mods.constBegin(); it != end; ++it) {
        if (m_lock.knowsKey(it.key())) {
            QHBoxLayout *hlayout = new QHBoxLayout;
            KLed *pressed = new KLed(this);
            KLed *latched = new KLed(this);
            KLed *locked = new KLed(this);
            QPushButton *latch = new QPushButton("latch", this);
            latch->setProperty("modifier", it.key());
            connect(latch, SIGNAL(clicked()), SLOT(latch()));
            QPushButton *lock = new QPushButton("lock", this);
            lock->setProperty("modifier", it.key());
            connect(lock, SIGNAL(clicked()), SLOT(lock()));
            pressed->setState(m_lock.isKeyPressed(it.key()) ? KLed::On : KLed::Off);
            latched->setState(m_lock.isKeyLatched(it.key()) ? KLed::On : KLed::Off);
            locked->setState(m_lock.isKeyLocked(it.key()) ? KLed::On : KLed:: Off);
            m_leds.insert(it.key(), Triple<KLed*,KLed*,KLed*>(pressed, latched, locked));
            hlayout->addWidget(pressed);
            hlayout->addWidget(latched);
            hlayout->addWidget(locked);
            hlayout->addWidget(new QLabel(it.value()));
            hlayout->addWidget(latch);
            hlayout->addWidget(lock);
            layout->addLayout(hlayout);
        }
    }

    QMap<Qt::MouseButton, QString>::const_iterator it2;
    QMap<Qt::MouseButton, QString>::const_iterator end2 = buttons.constEnd();
    for (it2 = buttons.constBegin(); it2 != end2; ++it2) {
        QHBoxLayout *hlayout = new QHBoxLayout;
        KLed *pressed = new KLed(this);
        pressed->setState(m_lock.isButtonPressed(it2.key()) ? KLed::On : KLed::Off);
        m_mouseLeds.insert(it2.key(), pressed);
        hlayout->addWidget(pressed);
        hlayout->addWidget(new QLabel(it2.value()));
        layout->addLayout(hlayout);
    }
    
    setLayout(layout);

    connect(&m_lock, SIGNAL(keyPressed(Qt::Key, bool)), SLOT(keyPressed(Qt::Key, bool)));
    connect(&m_lock, SIGNAL(keyLatched(Qt::Key, bool)), SLOT(keyLatched(Qt::Key, bool)));
    connect(&m_lock, SIGNAL(keyLocked(Qt::Key, bool)), SLOT(keyLocked(Qt::Key, bool)));
    connect(&m_lock, SIGNAL(buttonPressed(Qt::MouseButton, bool)),
                     SLOT(mouseButtonPressed(Qt::MouseButton, bool)));
    connect(&m_lock, SIGNAL(keyAdded(Qt::Key)), SLOT(keyAdded(Qt::Key)));
    connect(&m_lock, SIGNAL(keyRemoved(Qt::Key)), SLOT(keyRemoved(Qt::Key)));
}