diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 73682d0e6..4b193d0bc 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -96,7 +96,8 @@ /** Constructor */ PeersDialog::PeersDialog(QWidget *parent) : RsAutoUpdatePage(1500,parent), - historyKeeper(Rshare::dataDirectory() + "/his1.xml") + historyKeeper(Rshare::dataDirectory() + "/his1.xml"), + smWidget(0) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -238,6 +239,7 @@ PeersDialog::~PeersDialog () delete (it->second); } } + delete smWidget; } void PeersDialog::pasteLink() @@ -1403,65 +1405,67 @@ void PeersDialog::loadEmoticonsgroupchat() void PeersDialog::smileyWidgetgroupchat() { qDebug("MainWindow::smileyWidget()"); - QWidget *smWidget = new QWidget(this , Qt::Popup ); - smWidget->setWindowTitle("Emoticons"); - smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png"))); - //smWidget->setFixedSize(256,256); + if(smWidget == 0) { + smWidget = new QWidget(this , Qt::Popup ); + smWidget->setWindowTitle("Emoticons"); + smWidget->setWindowIcon(QIcon(QString(":/images/rstray3.png"))); + //smWidget->setFixedSize(256,256); - smWidget->setBaseSize( 4*24, (smileys.size()/4)*24 ); + smWidget->setBaseSize( 4*24, (smileys.size()/4)*24 ); - //Warning: this part of code was taken from kadu instant messenger; - // It was EmoticonSelector::alignTo(QWidget* w) function there - // comments are Polish, I dont' know how does it work... - // oblicz pozycj� widgetu do kt�rego r�wnamy - QWidget* w = ui.emoticonBtn; - QPoint w_pos = w->mapToGlobal(QPoint(0,0)); - // oblicz rozmiar selektora - QSize e_size = smWidget->sizeHint(); - // oblicz rozmiar pulpitu - QSize s_size = QApplication::desktop()->size(); - // oblicz dystanse od widgetu do lewego brzegu i do prawego - int l_dist = w_pos.x(); - int r_dist = s_size.width() - (w_pos.x() + w->width()); - // oblicz pozycj� w zale�no�ci od tego czy po lewej stronie - // jest wi�cej miejsca czy po prawej - int x; - if (l_dist >= r_dist) - x = w_pos.x() - e_size.width(); - else - x = w_pos.x() + w->width(); - // oblicz pozycj� y - centrujemy w pionie - int y = w_pos.y() + w->height()/2 - e_size.height()/2; - // je�li wychodzi poza doln� kraw�d� to r�wnamy do niej - if (y + e_size.height() > s_size.height()) - y = s_size.height() - e_size.height(); - // je�li wychodzi poza g�rn� kraw�d� to r�wnamy do niej - if (y < 0) - y = 0; - // ustawiamy selektor na wyliczonej pozycji - smWidget->move(x, y); + //Warning: this part of code was taken from kadu instant messenger; + // It was EmoticonSelector::alignTo(QWidget* w) function there + // comments are Polish, I dont' know how does it work... + // oblicz pozycj� widgetu do kt�rego r�wnamy + QWidget* w = ui.emoticonBtn; + QPoint w_pos = w->mapToGlobal(QPoint(0,0)); + // oblicz rozmiar selektora + QSize e_size = smWidget->sizeHint(); + // oblicz rozmiar pulpitu + QSize s_size = QApplication::desktop()->size(); + // oblicz dystanse od widgetu do lewego brzegu i do prawego + int l_dist = w_pos.x(); + int r_dist = s_size.width() - (w_pos.x() + w->width()); + // oblicz pozycj� w zale�no�ci od tego czy po lewej stronie + // jest wi�cej miejsca czy po prawej + int x; + if (l_dist >= r_dist) + x = w_pos.x() - e_size.width(); + else + x = w_pos.x() + w->width(); + // oblicz pozycj� y - centrujemy w pionie + int y = w_pos.y() + w->height()/2 - e_size.height()/2; + // je�li wychodzi poza doln� kraw�d� to r�wnamy do niej + if (y + e_size.height() > s_size.height()) + y = s_size.height() - e_size.height(); + // je�li wychodzi poza g�rn� kraw�d� to r�wnamy do niej + if (y < 0) + y = 0; + // ustawiamy selektor na wyliczonej pozycji + smWidget->move(x, y); - x = 0; - y = 0; + x = 0; + y = 0; - QHashIterator i(smileys); - while(i.hasNext()) - { - i.next(); - QPushButton *smButton = new QPushButton("", smWidget); - smButton->setGeometry(x*24, y*24, 24,24); - smButton->setIconSize(QSize(24,24)); - smButton->setIcon(QPixmap(i.value())); - smButton->setToolTip(i.key()); - //smButton->setFixedSize(24,24); - ++x; - if(x > 4) + QHashIterator i(smileys); + while(i.hasNext()) { - x = 0; - y++; + i.next(); + QPushButton *smButton = new QPushButton("", smWidget); + smButton->setGeometry(x*24, y*24, 24,24); + smButton->setIconSize(QSize(24,24)); + smButton->setIcon(QPixmap(i.value())); + smButton->setToolTip(i.key()); + //smButton->setFixedSize(24,24); + ++x; + if(x > 4) + { + x = 0; + y++; + } + connect(smButton, SIGNAL(clicked()), this, SLOT(addSmileys())); + connect(smButton, SIGNAL(clicked()), smWidget, SLOT(close())); } - connect(smButton, SIGNAL(clicked()), this, SLOT(addSmileys())); - connect(smButton, SIGNAL(clicked()), smWidget, SLOT(close())); } smWidget->show(); diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index aca4dbc7c..65e19da1c 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -194,6 +194,7 @@ private: time_t last_status_send_time ; QHash smileys; + QWidget *smWidget; std::map chatDialogs;