OwnerEditDlg::OwnerEditDlg(const Licq::UserId& ownerId, unsigned setStatus, const QString& autoMessage, QWidget* parent) : QDialog(parent), myOwnerId(ownerId), myPpid(ownerId.protocolId()), myNewOwner(false), mySetStatus(setStatus), myAutoMessage(autoMessage) { init(); { Licq::OwnerReadGuard o(myOwnerId); if (!o.isLocked()) { close(); return; } edtId->setText(o->accountId().c_str()); edtId->setEnabled(false); edtPassword->setText(QString::fromLocal8Bit(o->password().c_str())); chkSave->setChecked(o->SavePassword()); myHostEdit->setText(QString::fromLocal8Bit(o->serverHost().c_str())); myPortSpin->setValue(o->serverPort()); } show(); }
UserEventCommon::UserEventCommon(const Licq::UserId& userId, QWidget* parent, const char* name) : QWidget(parent), myPpid(userId.protocolId()), myHighestEventId(-1) { Support::setWidgetProps(this, name); setAttribute(Qt::WA_DeleteOnClose, true); myUsers.push_back(userId); // Find out what's supported for the protocol mySendFuncs = 0; Licq::ProtocolPlugin::Ptr protocol = Licq::gPluginManager.getProtocolPlugin(myPpid); if (protocol.get() != NULL) mySendFuncs = protocol->capabilities(); myIsOwner = myUsers.front().isOwner(); myDeleteUser = false; myConvoId = 0; myTophLayout = new QHBoxLayout(this); myTopLayout = new QVBoxLayout(); myTophLayout->addLayout(myTopLayout); myTophLayout->setStretchFactor(myTopLayout, 1); QHBoxLayout* layt = new QHBoxLayout(); myTopLayout->addLayout(layt); myToolBar = new QToolBar(); myToolBar->setIconSize(QSize(16, 16)); layt->addWidget(myToolBar); layt->addStretch(1); myTimezone = new InfoField(true); myTimezone->setToolTip(tr("User's current local time")); int timezoneWidth = qMax(myTimezone->fontMetrics().width("88:88:88"), myTimezone->fontMetrics().width(tr("Unknown"))) + 10; myTimezone->setFixedWidth(timezoneWidth); myTimezone->setAlignment(Qt::AlignCenter); myTimezone->setFocusPolicy(Qt::ClickFocus); layt->addWidget(myTimezone); myMenu = myToolBar->addAction(tr("Menu"), this, SLOT(showUserMenu())); myMenu->setMenu(gUserMenu); if (myIsOwner) myMenu->setEnabled(false); myHistory = myToolBar->addAction(tr("History..."), this, SLOT(showHistory())); myInfo = myToolBar->addAction(tr("User Info..."), this, SLOT(showUserInfo())); myEncodingsMenu = new QMenu(this); myEncoding = myToolBar->addAction(tr("Encoding"), this, SLOT(showEncodingsMenu())); myEncoding->setMenu(myEncodingsMenu); if (!(mySendFuncs & Licq::ProtocolPlugin::CanVaryEncoding)) myEncoding->setVisible(false); myToolBar->addSeparator(); mySecure = myToolBar->addAction(tr("Secure Channel"), this, SLOT(switchSecurity())); if (!(mySendFuncs & Licq::ProtocolPlugin::CanSendSecure)) mySecure->setEnabled(false); myTimeTimer = NULL; QString userEncoding; { Licq::UserReadGuard u(myUsers.front()); if (u.isLocked()) { if (u->NewMessages() == 0) setWindowIcon(IconManager::instance()->iconForUser(*u)); else { setWindowIcon(IconManager::instance()->iconForEvent(Licq::UserEvent::TypeMessage)); flashTaskbar(); } updateWidgetInfo(*u); // restore prefered encoding userEncoding = u->userEncoding().c_str(); setTyping(u->isTyping()); } else { userEncoding = Licq::gUserManager.defaultUserEncoding().c_str(); } } myEncodingsGroup = new QActionGroup(this); connect(myEncodingsGroup, SIGNAL(triggered(QAction*)), SLOT(setEncoding(QAction*))); // populate the popup menu for (int i = 0; UserCodec::m_encodings[i].encoding != NULL; ++i) { UserCodec::encoding_t* it = &UserCodec::m_encodings[i]; bool currentCodec = it->encoding == userEncoding; if (!currentCodec && !Config::Chat::instance()->showAllEncodings() && !it->isMinimal) continue; QAction* a = new QAction(UserCodec::nameForEncoding(i), myEncodingsGroup); a->setCheckable(true); a->setData(i); if (currentCodec) a->setChecked(true); if (currentCodec && !Config::Chat::instance()->showAllEncodings() && !it->isMinimal) { // if the current encoding does not appear in the minimal list myEncodingsMenu->insertSeparator(myEncodingsMenu->actions()[0]); myEncodingsMenu->insertAction(myEncodingsMenu->actions()[0], a); } else { myEncodingsMenu->addAction(a); } } myPopupNextMessage = new QAction("Popup Next Message", this); addAction(myPopupNextMessage); connect(myPopupNextMessage, SIGNAL(triggered()), gLicqGui, SLOT(showNextEvent())); // We might be called from a slot so connect the signal only after all the // existing signals are handled. QTimer::singleShot(0, this, SLOT(connectSignal())); myMainWidget = new QVBoxLayout(); myMainWidget->setContentsMargins(0, 0, 0, 0); myTopLayout->addLayout(myMainWidget); updateIcons(); updateShortcuts(); connect(IconManager::instance(), SIGNAL(generalIconsChanged()), SLOT(updateIcons())); connect(Config::Shortcuts::instance(), SIGNAL(shortcutsChanged()), SLOT(updateShortcuts())); // Check if we want the window sticky if (!Config::Chat::instance()->tabbedChatting() && Config::Chat::instance()->msgWinSticky()) QTimer::singleShot(100, this, SLOT(setMsgWinSticky())); }
AuthDlg::AuthDlg(enum AuthDlgType type, const Licq::UserId& userId, QWidget* parent) : QDialog(parent), myType(type), myUserId(userId) { Support::setWidgetProps(this, "AuthDialog"); setAttribute(Qt::WA_DeleteOnClose, true); QString messageTitle; switch (myType) { default: case RequestAuth: setWindowTitle(tr("Licq - Request Authorization")); messageTitle = tr("Request"); break; case GrantAuth: setWindowTitle(tr("Licq - Grant Authorization")); messageTitle = tr("Response"); break; case RefuseAuth: setWindowTitle(tr("Licq - Refuse Authorization")); messageTitle = tr("Response"); break; } QVBoxLayout* dialogLayout = new QVBoxLayout(this); QHBoxLayout* userIdLayout = new QHBoxLayout(); QLabel* protocolLabel = new QLabel(this); protocolLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); protocolLabel->setText(tr("&Protocol:")); myProtocolCombo = new ProtoComboBox(ProtoComboBox::FilterOwnersOnly); protocolLabel->setBuddy(myProtocolCombo); userIdLayout->addWidget(protocolLabel); userIdLayout->addWidget(myProtocolCombo); QLabel* accountIdLabel = new QLabel(this); accountIdLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); accountIdLabel->setText(tr("&User Id:")); myAccountIdEdit = new QLineEdit(this); myAccountIdEdit->setMinimumWidth(90); accountIdLabel->setBuddy(myAccountIdEdit); connect(myAccountIdEdit, SIGNAL(returnPressed()), SLOT(send()) ); userIdLayout->addWidget(accountIdLabel); userIdLayout->addWidget(myAccountIdEdit); dialogLayout->addLayout(userIdLayout); dialogLayout->addSpacing(6); QGroupBox* messageBox = new QGroupBox(messageTitle, this); dialogLayout->addWidget(messageBox); dialogLayout->setStretchFactor(messageBox, 2); QVBoxLayout* messageLayout = new QVBoxLayout(messageBox); myMessageEdit = new MLEdit(true); myMessageEdit->setSizeHintLines(5); messageLayout->addWidget(myMessageEdit); QDialogButtonBox* buttons = new QDialogButtonBox(); QPushButton* okButton = buttons->addButton(QDialogButtonBox::Ok); QPushButton* cancelButton = buttons->addButton(QDialogButtonBox::Cancel); connect(myMessageEdit, SIGNAL(ctrlEnterPressed()), this, SLOT(send())); connect(okButton, SIGNAL(clicked()), SLOT(send()) ); connect(cancelButton, SIGNAL(clicked()), SLOT(close()) ); dialogLayout->addWidget(buttons); if (userId.isValid()) { myProtocolCombo->setCurrentPpid(userId.protocolId()); myProtocolCombo->setEnabled(false); myAccountIdEdit->setText(userId.accountId().c_str()); myAccountIdEdit->setEnabled(false); myMessageEdit->setFocus(); } else { myProtocolCombo->setFocus(); } show(); }