Beispiel #1
0
MainWindow::MainWindow()
{
    setUnifiedTitleAndToolBarOnMac( true );

    r = new Comms();

    createActions();
    createToolBars();
    createDocks();

    contactsList = new QListWidget();
    contactsList->setMinimumWidth( 150 );
    contactsList->setMinimumHeight( 250 );
    contactsList->setUniformItemSizes( true );
    contactsList->setSpacing( 3 );
    contactsList->setWordWrap( true );

    connectBox = new ConnectBox();
    setCentralWidget( connectBox );

    QObject::connect( r, SIGNAL( sigConnected() ), this, SLOT( slotConnected() ) );
    QObject::connect( r, SIGNAL( sigRoster( QStringList* ) ), this, SLOT( slotRoster( QStringList* ) ) );
    QObject::connect( r, SIGNAL( sigRosterPresence(QString, QString) ), this, SLOT( slotRosterPresence(QString, QString) ) );
    QObject::connect( r, SIGNAL( sigVCardReceived(QString,QString) ), this, SLOT( slotVCardReceived(QString,QString) ) );
    QObject::connect( r, SIGNAL( sigMessage(QString,QString) ), this, SLOT( slotMessage(QString,QString) ) );

    QObject::connect( connectBox, SIGNAL( tryConnection(QString,QString) ), this, SLOT( setIdents(QString,QString) ) );

    timer = new QTimer( this );
    QObject::connect( timer, SIGNAL( timeout() ), r, SLOT( slotReceive() ) );

    QObject::connect( contactsList, SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( slotLocalSession(QListWidgetItem*) ) );
}
GatewayTask::GatewayTask(ComponentStream *stream)
    : QObject(stream), d(new Private)
{
    d->stream = stream;
    QObject::connect( stream, SIGNAL(stanzaIQ(XMPP::IQ)),
                      SLOT(slotRegister(XMPP::IQ)) );
    QObject::connect( stream, SIGNAL(stanzaMessage(XMPP::Message)),
                      SLOT(slotMessage(XMPP::Message)) );
    QObject::connect( stream, SIGNAL(stanzaPresence(XMPP::Presence)),
                      SLOT(slotGatewaySubscribe(XMPP::Presence)) );
    QObject::connect( stream, SIGNAL(stanzaPresence(XMPP::Presence)),
                      SLOT(slotSubscription(XMPP::Presence)) );
    QObject::connect( stream, SIGNAL(stanzaPresence(XMPP::Presence)),
                      SLOT(slotPresence(XMPP::Presence)) );
}
Beispiel #3
0
void Test::startTest()
{
    redis = new QtRedis("localhost",6379);
    connect(redis, SIGNAL(returnData(QtRedis::Reply)), this, SLOT(slotMessage(QtRedis::Reply)));

    QtRedis::Reply reply;

    if (!redis->openConnection())
    {
        qDebug() << "Could not connect to server...";
        exit(0);
    }

    qDebug() << "Connected to server...";

    //qDebug() << "AUTH:" << redis->auth("redisZzZ");

    // Set and Get example
    qDebug() << "SET:" << redis->set("key", "\"Hello World\"");
    qDebug() << "GET:" << redis->get("key");

    // Append to Key example
    qDebug() << "SET:" << redis->set("key", "\"Hello\"");
    qDebug() << "EXISTS:" << redis->exists("key");
    qDebug() << "GET:" << redis->get("key");
    qDebug() << "APPEND:" << redis->append("key", "\" World\"");
    qDebug() << "GET:" << redis->get("key");

    // Multi Set and Get example
    QMap<QString,QVariant> keypairs;
    keypairs["key1"] = QString("\"Hello\"");
    keypairs["key2"] = QString("\" world\"");
    qDebug() << "MSET:" << redis->mset(keypairs);
    qDebug() << "MGET:" << redis->mget("key1 key2 nonexisting");

    // Incr, incrby decr, decrby example.
    qDebug() << "SET:" << redis->set("count", "10");
    qDebug() << "INCR:" << redis->incr("count");
    qDebug() << "GET:" << redis->get("count");

    qDebug() << "INCRBY:" << redis->incrby("count",5);
    qDebug() << "GET:" << redis->get("count");

    qDebug() << "DECR:" << redis->decr("count");
    qDebug() << "GET:" << redis->get("count");

    qDebug() << "DECRBY:" << redis->decrby("count",5);
    qDebug() << "GET:" << redis->get("count");

    // SET and GET Range examples
    qDebug() << "SETRANGE:" << redis->setrange("key",6 ,"Redis");
    qDebug() << "GET:" << redis->get("key");

    qDebug() << "GETRANGE:" << redis->getrange("key",-5 ,-1);
    qDebug() << "GETRANGE:" << redis->getrange("key",0 ,4);
    qDebug() << "GETRANGE:" << redis->getrange("key",0 ,-1);


    //Hashmap example
    qDebug() << "HSET:" << redis->hset("hashmap","key1" ,"value1");
    qDebug() << "HSET:" << redis->hset("hashmap","key2" ,"value2");
    qDebug() << "HSET:" << redis->hset("hashmap","key3" ,"value3");
    qDebug() << "HGETALL:";

    QMap<QString,QVariant> hashmap = redis->hgetall("hashmap");
    QMapIterator<QString, QVariant> mi(hashmap);
    while (mi.hasNext())
    {
        mi.next();
        qDebug() << mi.key() << "=" << mi.value().toString();
    }

    qDebug() << "HVALS:" << redis->hvals("hashmap");


    // Raw Command example
    reply = redis->command("GET key");
    qDebug() << "RAW:" << "("<< reply.type << ")" << reply.value.toString();

    redis->subscribe("notifications");

    redis->psubscribe("news.*");

    //reply = redis->command("SUBSCRIBE notifications");
    //qDebug() << "("<< reply.type << ")" << reply.value.toStringList();

}
Beispiel #4
0
KBannerSetup::KBannerSetup( QWidget *parent )
	: KDialog( parent)
	  , saver( 0 ), ed(0), speed( 50 )
{
	setButtons(Ok|Cancel|Help);
	setDefaultButton(Ok);
	setCaption(i18n( "Setup Banner Screen Saver" ));
	setModal(true);
	setButtonText( Help, i18n( "A&bout" ) );
	readSettings();

        QWidget *main = new QWidget(this);
	setMainWidget(main);

	QLabel *label;

	QVBoxLayout *tl = new QVBoxLayout( main );
	QHBoxLayout *tl1 = new QHBoxLayout();
	tl->addLayout(tl1);
	QVBoxLayout *tl11 = new QVBoxLayout();
	tl1->addLayout(tl11);

	QGroupBox *group = new QGroupBox( i18n("Font"), main );
        QVBoxLayout *vbox = new QVBoxLayout;
        group->setLayout(vbox);
        QGridLayout *gl = new QGridLayout();
        vbox->addLayout(gl);
        gl->setSpacing(spacingHint());

	label = new QLabel( i18n("Family:"), group );
	gl->addWidget(label, 1, 0);

	KFontComboBox* comboFonts = new KFontComboBox( group );
	comboFonts->setCurrentFont( fontFamily );
	gl->addWidget(comboFonts, 1, 1);
	connect( comboFonts, SIGNAL(currentFontChanged(QFont)),
			SLOT(slotFamily(QFont)) );

	label = new QLabel( i18n("Size:"), group );
	gl->addWidget(label, 2, 0);

	comboSizes = new QComboBox( group );
        comboSizes->setEditable( true );
        fillFontSizes();
	gl->addWidget(comboSizes, 2, 1);
	connect( comboSizes, SIGNAL(activated(int)), SLOT(slotSize(int)) );
	connect( comboSizes, SIGNAL(editTextChanged(QString)),
			SLOT(slotSizeEdit(QString)) );

	QCheckBox *cb = new QCheckBox( i18n("Bold"),
				       group );
	cb->setChecked( bold );
	connect( cb, SIGNAL(toggled(bool)), SLOT(slotBold(bool)) );
	gl->addWidget(cb, 3, 0);

	cb = new QCheckBox( i18n("Italic"), group );
	cb->setChecked( italic );
	gl->addWidget(cb, 3, 1);
	connect( cb, SIGNAL(toggled(bool)), SLOT(slotItalic(bool)) );

	label = new QLabel( i18n("Color:"), group );
	gl->addWidget(label, 4, 0);

	colorPush = new KColorButton( fontColor, group );
	gl->addWidget(colorPush, 4, 1);
	connect( colorPush, SIGNAL(changed(QColor)),
		 SLOT(slotColor(QColor)) );

        QCheckBox *cyclingColorCb=new QCheckBox(i18n("Cycling color"),group);
        cyclingColorCb->setMinimumSize(cyclingColorCb->sizeHint());
        gl->addWidget(cyclingColorCb, 5, 0,5,1);
        connect(cyclingColorCb,SIGNAL(toggled(bool)),this,SLOT(slotCyclingColor(bool)));
        cyclingColorCb->setChecked(cyclingColor);

	preview = new QWidget( main );
	preview->setFixedSize( 220, 170 );
        {
            QPalette palette;
            palette.setColor( preview->backgroundRole(), Qt::black );
            preview->setPalette( palette );
	    preview->setAutoFillBackground(true);
        }
	preview->show();    // otherwise saver does not get correct size
	saver = new KBannerSaver( preview->winId() );
	tl1->addWidget(preview);

	tl11->addWidget(group);

	label = new QLabel( i18n("Speed:"), main );
	tl11->addStretch(1);
	tl11->addWidget(label);

	QSlider *sb = new QSlider( Qt::Horizontal, main );
        sb->setMinimum(0);
        sb->setMaximum(100);
        sb->setPageStep(10);
        sb->setValue(speed);
	sb->setMinimumWidth( 180);
	sb->setFixedHeight(20);
        sb->setTickPosition(QSlider::TicksBelow);
        sb->setTickInterval(10);
	tl11->addWidget(sb);
	connect( sb, SIGNAL(valueChanged(int)), SLOT(slotSpeed(int)) );

	QHBoxLayout *tl2 = new QHBoxLayout;
	tl->addLayout(tl2);

	label = new QLabel( i18n("Message:"), main );
	tl2->addWidget(label);

	ed = new QLineEdit( main );
	tl2->addWidget(ed);
	ed->setText( message );
	connect( ed, SIGNAL(textChanged(QString)),
			SLOT(slotMessage(QString)) );

   QCheckBox *timeCb=new QCheckBox( i18n("Show current time"), main);
   timeCb->setFixedSize(timeCb->sizeHint());
   tl->addWidget(timeCb,0,Qt::AlignLeft);
   connect(timeCb,SIGNAL(toggled(bool)),this,SLOT(slotTimeToggled(bool)));
   timeCb->setChecked(showTime);
   connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
   connect(this,SIGNAL(helpClicked()),this,SLOT(slotHelp()));
   tl->addStretch();
}