void lmcMainWindow::init(User* pLocalUser, QList<Group>* pGroupList, bool connected) { setWindowIcon(QIcon(IDR_APPICON)); setWindowFlags(windowFlags() & Qt::FramelessWindowHint); setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint); setMinimumSize(270, 260); setMaximumSize(300, 760); this->pLocalUser = pLocalUser; createMainMenu(); createToolBar(); createStatusMenu(); createAvatarMenu(); createTrayMenu(); createTrayIcon(); connectionStateChanged(connected); createGroupMenu(); createUserMenu(); ui.lblDividerTop->setBackgroundRole(QPalette::Highlight); ui.lblDividerTop->setAutoFillBackground(true); ui.tvUserList->setIconSize(QSize(16, 16)); ui.tvUserList->header()->setSectionsMovable(false); ui.tvUserList->header()->setStretchLastSection(false); ui.tvUserList->header()->setSectionResizeMode(0, QHeaderView::Stretch); btnStatus->setIconSize(QSize(20, 20)); int index = Helper::statusIndexFromCode(pLocalUser->status); // if status is not recognized, default to available index = qMax(index, 0); btnStatus->setIcon(QIcon(QPixmap(statusPic[index], "PNG"))); statusGroup->actions()[index]->setChecked(true); QFont font = ui.lblUserName->font(); int fontSize = ui.lblUserName->fontInfo().pixelSize(); fontSize += (fontSize * 0.1); font.setPixelSize(fontSize); font.setBold(true); ui.lblUserName->setFont(font); ui.lblStatus->setText(statusGroup->checkedAction()->text()); nAvatar = pLocalUser->avatar; ui.txtNote->setText(pLocalUser->note); pSoundPlayer = new lmcSoundPlayer(); pSettings = new lmcSettings(); restoreGeometry(pSettings->value(IDS_WINDOWMAIN).toByteArray()); // get saved settings settingsChanged(true); setUIText(); initGroups(pGroupList); }
void lmcChatRoomWindow::init(User* pLocalUser, bool connected, QString thread) { localId = pLocalUser->id; localName = pLocalUser->name; this->pLocalUser = pLocalUser; pMessageLog->localId = localId; // get the avatar image for the users from the cache folder QDir cacheDir(StdLocation::cacheDir()); QString fileName = "avt_" + localId + ".png"; QString filePath = cacheDir.absoluteFilePath(fileName); pMessageLog->participantAvatars.insert(localId, filePath); threadId = thread; groupMode = !threadId.isNull(); createUserMenu(); createSmileyMenu(); createToolBar(); bConnected = connected; if ( !bConnected ) showStatus( IT_Disconnected, true ); pSoundPlayer = new lmcSoundPlayer(); ui.tvUserList->setIconSize(QSize(16, 16)); ui.tvUserList->header()->setSectionsMovable(false); ui.tvUserList->header()->setStretchLastSection(false); ui.tvUserList->header()->setSectionResizeMode(0, QHeaderView::Stretch); lmcUserTreeWidgetGroupItem *pItem = new lmcUserTreeWidgetGroupItem(); pItem->setData(0, IdRole, GroupId); pItem->setData(0, TypeRole, "Group"); pItem->setText(0, "Participants"); pItem->setSizeHint(0, QSize(0, 22)); ui.tvUserList->addTopLevelItem(pItem); ui.tvUserList->expandAll(); pSettings = new lmcSettings(); showSmiley = pSettings->value(IDS_EMOTICON, IDS_EMOTICON_VAL).toBool(); pMessageLog->showSmiley = showSmiley; pMessageLog->autoFile = pSettings->value(IDS_AUTOFILE, IDS_AUTOFILE_VAL).toBool(); pMessageLog->fontSizeVal = pSettings->value(IDS_FONTSIZE, IDS_FONTSIZE_VAL).toInt(); pMessageLog->messageTime = pSettings->value(IDS_MESSAGETIME, IDS_MESSAGETIME_VAL).toBool(); pMessageLog->messageDate = pSettings->value(IDS_MESSAGEDATE, IDS_MESSAGEDATE_VAL).toBool(); pMessageLog->allowLinks = pSettings->value(IDS_ALLOWLINKS, IDS_ALLOWLINKS_VAL).toBool(); pMessageLog->pathToLink = pSettings->value(IDS_PATHTOLINK, IDS_PATHTOLINK_VAL).toBool(); pMessageLog->trimMessage = pSettings->value(IDS_TRIMMESSAGE, IDS_TRIMMESSAGE_VAL).toBool(); QFont font = QApplication::font(); font.fromString(pSettings->value(IDS_FONT, IDS_FONT_VAL).toString()); messageColor = QApplication::palette().text().color(); messageColor.setNamedColor(pSettings->value(IDS_COLOR, IDS_COLOR_VAL).toString()); sendKeyMod = pSettings->value(IDS_SENDKEYMOD, IDS_SENDKEYMOD_VAL).toBool(); if ( !groupMode ) { restoreGeometry(pSettings->value(IDS_WINDOWPUBLICCHAT).toByteArray()); ui.vSplitter->restoreState(pSettings->value(IDS_SPLITTERPUBLICCHATV).toByteArray()); ui.hSplitter->restoreState(pSettings->value(IDS_SPLITTERPUBLICCHATH).toByteArray()); } setUIText(); setMessageFont( font ); ui.txtMessage->setStyleSheet( "QTextEdit {color: " + messageColor.name() + ";}" ); ui.txtMessage->setFocus(); QString themePath = pSettings->value(IDS_THEME, IDS_THEME_VAL).toString(); pMessageLog->initMessageLog(themePath); int viewType = pSettings->value(IDS_USERLISTVIEW, IDS_USERLISTVIEW_VAL).toInt(); ui.tvUserList->setView((UserListView)viewType); // Destroy the window when it closes if in group mode setAttribute(Qt::WA_DeleteOnClose, groupMode); // Add the local user as a participant addUser(pLocalUser); }