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
|
/***************************************************************************
livejournalcfg.cpp - description
-------------------
begin : Sun Mar 17 2002
copyright : (C) 2002 by Vladimir Shutoff
email : vovan@shutoff.ru
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qspinbox.h>
#include <qtimer.h>
#include "linklabel.h"
#include "misc.h"
#include "livejournalcfg.h"
#include "livejournal.h"
using namespace SIM;
LiveJournalCfg::LiveJournalCfg(QWidget *parent, LiveJournalClient *client, bool bConfig)
: LiveJournalCfgBase(parent)
{
m_client = client;
m_bConfig = bConfig;
edtName->setText(client->data.owner.User.str());
if (bConfig){
edtPassword->setText(client->getPassword());
lblLnk->setText(i18n("Register new user"));
lblLnk->setUrl("http://www.livejournal.com/create.bml");
}else{
edtName->setReadOnly(true);
edtPassword->hide();
lblPassword->hide();
}
edtServer->setText(client->getServer());
edtPath->setText(client->getURL());
edtPort->setValue(client->getPort());
edtInterval->setValue(client->getInterval());
chkFastServer->setChecked(client->getFastServer());
chkUseFormatting->setChecked(client->getUseFormatting());
chkUseSignature->setChecked(client->getUseSignature());
edtSignature->setText(client->getSignatureText());
connect(edtName, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
connect(edtPassword, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
connect(chkUseSignature, SIGNAL(toggled(bool)), this, SLOT(useSigToggled(bool)));
useSigToggled(chkUseSignature->isChecked());
changed("");
QTimer::singleShot(0, this, SLOT(changed()));
}
void LiveJournalCfg::changed(const QString&)
{
changed();
}
void LiveJournalCfg::changed()
{
emit okEnabled(!edtName->text().isEmpty() && !edtPassword->text().isEmpty());
}
void LiveJournalCfg::apply()
{
if (m_bConfig){
m_client->data.owner.User.str() = edtName->text();
m_client->setPassword(edtPassword->text());
}
m_client->setServer(edtServer->text());
m_client->setURL(edtPath->text());
m_client->setPort(edtPort->text().toUShort());
m_client->setInterval(edtInterval->text().toULong());
m_client->setFastServer(chkFastServer->isChecked());
m_client->setUseFormatting(chkUseFormatting->isChecked());
m_client->setUseSignature(chkUseSignature->isChecked());
if (edtSignature->text() != m_client->getSignatureText())
m_client->setSignature(edtSignature->text());
}
void LiveJournalCfg::apply(Client*, void*)
{
}
void LiveJournalCfg::useSigToggled(bool value)
{
edtSignature->setEnabled(value);
}
#ifndef NO_MOC_INCLUDES
#include "livejournalcfg.moc"
#endif
|