Ejemplo n.º 1
0
/** Constructor */
PeersDialog::PeersDialog(QWidget *parent)
            : RsAutoUpdatePage(1000,parent),
              historyKeeper(Rshare::dataDirectory() + "/his1.xml")
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) );
  connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend()));

  /* hide the Tree +/- */
  ui.peertreeWidget -> setRootIsDecorated( false );
  
    /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.peertreeWidget->header () ;
   	_header->setResizeMode (0, QHeaderView::Custom);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);
	/*_header->setResizeMode (3, QHeaderView::Interactive);
	_header->setResizeMode (4, QHeaderView::Interactive);
	_header->setResizeMode (5, QHeaderView::Interactive);
	_header->setResizeMode (6, QHeaderView::Interactive);
	_header->setResizeMode (7, QHeaderView::Interactive);*/

    
	_header->resizeSection ( 0, 25 );
	_header->resizeSection ( 1, 100 );
	_header->resizeSection ( 2, 100 );
	/*_header->resizeSection ( 3, 120 );
	_header->resizeSection ( 4, 100 );
	_header->resizeSection ( 5, 230 );
	_header->resizeSection ( 6, 120 );
	_header->resizeSection ( 7, 220 );*/
	
    // set header text aligment
	QTreeWidgetItem * headerItem = ui.peertreeWidget->headerItem();
	headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);

	
	  
  loadEmoticonsgroupchat();
  
  //setWindowIcon(QIcon(QString(":/images/rstray3.png")));

  connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
  connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
  connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));

   
  //connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
  connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
 
  connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));  
  connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont()));  
  connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
  connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont()));  
  connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor()));
   
  ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png")));
  
  _currentColor = Qt::black;
  QPixmap pxm(16,16);
  pxm.fill(_currentColor);
  ui.colorChatButton->setIcon(pxm);
  
  mCurrentFont = QFont("Comic Sans MS", 12);
  ui.lineEdit->setFont(mCurrentFont);
  
  setChatInfo(tr("Welcome to RetroShare's group chat."),
              QString::fromUtf8("blue"));

  QStringList him;
  historyKeeper.getMessages(him, "", "THIS", 8);
  foreach(QString mess, him)
      ui.msgText->append(mess);
      //setChatInfo(mess,  "green");
              
  
  QMenu * grpchatmenu = new QMenu();
  grpchatmenu->addAction(ui.actionClearChat);
  ui.menuButton->setMenu(grpchatmenu);
  
  _underline = false;

  QTimer *timer = new QTimer(this);
  timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertChat()));
  timer->start(500); /* half a second */

	ui.peertreeWidget->sortItems( 1, Qt::AscendingOrder );


  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Ejemplo n.º 2
0
/** Constructor */
FriendsDialog::FriendsDialog(QWidget *parent)
            : RsAutoUpdatePage(1500,parent)
{
    /* Invoke the Qt Designer generated object setup routine */
    ui.setupUi(this);

    if (instance == NULL) {
        instance = this;
    }

    last_status_send_time = 0 ;
    inChatCharFormatChanged = false;

    connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage()));
    connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar()));
    connect( ui.actionSet_your_Personal_Message, SIGNAL(triggered()), this, SLOT(statusmessage()));
    connect( ui.addfileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
    connect( ui.actionAdd_Friend, SIGNAL(triggered()), this, SLOT(addFriend()));
	 connect( ui.actionFriendRecommendations, SIGNAL(triggered()), this, SLOT(recommendFriends()));
    connect( ui.actionServicePermission, SIGNAL(triggered()), this, SLOT(servicePermission()));
    connect( ui.filter_lineEdit, SIGNAL(textChanged(QString)), ui.friendList, SLOT(filterItems(QString)));

    ui.filter_lineEdit->setPlaceholderText(tr("Search")) ;
    ui.filter_lineEdit->showFilterIcon();

    ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME);
    ui.avatar->setOwnId();

    ui.tabWidget->setTabPosition(QTabWidget::North);
    ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Local network"));
    ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Known people"));

    //ui.tabWidget->addTab(new ProfileWidget(), tr("Profile"));
    //newsFeed = new NewsFeed();
    //int newsFeedTabIndex = ui.tabWidget->insertTab(0, newsFeed, tr("News Feed"));
    //ui.tabWidget->setCurrentIndex(newsFeedTabIndex);

    ui.tabWidget->hideCloseButton(0);
    ui.tabWidget->hideCloseButton(1);
    ui.tabWidget->hideCloseButton(2);
    ui.tabWidget->hideCloseButton(3);

    /* get the current text and text color of the tab bar */
    //newsFeedTabColor = ui.tabWidget->tabBar()->tabTextColor(newsFeedTabIndex);
    //newsFeedText = ui.tabWidget->tabBar()->tabText(newsFeedTabIndex);

    //connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)));

    connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
    connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));

    connect(ui.msgText,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenuMsgText(QPoint)));

    connect(ui.lineEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
    // reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear
    connect(ui.lineEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged()));

    connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
    connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
    connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
    connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(chooseFont()));
    connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(chooseColor()));
    connect(ui.actionSave_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));

    connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));

    ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png")));

    mCurrentColor = Qt::black;
    mCurrentFont.fromString(Settings->getChatScreenFont());

    colorChanged();
    fontChanged();
    setColorAndFont();

    style.setStyleFromSettings(ChatStyle::TYPE_PUBLIC);

    setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue"));

    if (rsHistory->getEnable(true)) {
        int messageCount = Settings->getPublicChatHistoryCount();
        if (messageCount > 0) {
            std::list<HistoryMsg> historyMsgs;
            rsHistory->getMessages("", historyMsgs, messageCount);

            std::list<HistoryMsg>::iterator it;
            for (it = historyMsgs.begin(); it != historyMsgs.end(); it++) {
                addChatMsg(it->incoming, true, QString::fromUtf8(it->peerName.c_str()), QDateTime::fromTime_t(it->sendTime), QDateTime::fromTime_t(it->recvTime), QString::fromUtf8(it->message.c_str()));
            }
        }
    }

    QMenu *menu = new QMenu();
    menu->addAction(ui.actionClear_Chat_History);
    menu->addAction(ui.actionDelete_Chat_History);
    menu->addAction(ui.actionSave_History);
    menu->addAction(ui.actionMessageHistory);
    ui.menuButton->setMenu(menu);

    menu = new QMenu();
    menu->addAction(ui.actionAdd_Friend);
    menu->addAction(ui.actionAdd_Group);
    menu->addAction(ui.actionCreate_new_Chat_lobby);
    menu->addAction(ui.actionFriendRecommendations);
    menu->addAction(ui.actionServicePermission);

    menu->addSeparator();
    menu->addAction(ui.actionSet_your_Avatar);
    menu->addAction(ui.actionSet_your_Personal_Message);

    ui.menutoolButton->setMenu(menu);

    setAcceptDrops(true);
    ui.lineEdit->setAcceptDrops(false);
    ui.hashBox->setDropWidget(this);
    ui.hashBox->setAutoHide(true);

    /* Set initial size the splitter */
    QList<int> sizes;
    sizes << height() << 100; // Qt calculates the right sizes
    ui.splitter_2->setSizes(sizes);

    loadmypersonalstatus();
    ui.displayButton->setMenu(ui.friendList->createDisplayMenu());

    // load settings
    RsAutoUpdatePage::lockAllEvents();
    ui.friendList->setShowStatusColumn(true);
    ui.friendList->setShowLastContactColumn(false);
    ui.friendList->setShowAvatarColumn(false);
    ui.friendList->setRootIsDecorated(true);
    ui.friendList->setShowGroups(true);
    processSettings(true);
    RsAutoUpdatePage::unlockAllEvents();

    ui.lineEdit->installEventFilter(this);

    // add self nick and Avatar to Friends.
    RsPeerDetails pd ;
    if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
        ui.nicknameLabel->setText(PeerDefs::nameWithLocation(pd));
    }

    /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}