ForumsDialog

- Enable the button for new messages only when a thread is selected.

ForumsDialog & CreateForumMsg
- Now using embedded emoticons.

Fixed german translation.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3483 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-13 23:35:21 +00:00
parent 36d690448f
commit 671e3e71a6
6 changed files with 17 additions and 198 deletions

View File

@ -215,7 +215,7 @@ ForumsDialog::ForumsDialog(QWidget *parent)
ui.forumName->setFont(m_ForumNameFont);
ui.threadTitle->setFont(m_ForumNameFont);
loadForumEmoticons();
style.loadEmoticons();
QMenu *forummenu = new QMenu();
forummenu->addAction(ui.actionCreate_Forum);
@ -433,6 +433,9 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
if (nCount == 1) {
replyAct->setEnabled (true);
replyauthorAct->setEnabled (true);
} else {
replyAct->setDisabled (true);
replyauthorAct->setDisabled (true);
}
} else {
markMsgAsRead->setDisabled(true);
@ -1371,6 +1374,7 @@ void ForumsDialog::insertPost()
ui.threadTitle->setText("");
ui.previousButton->setEnabled(false);
ui.nextButton->setEnabled(false);
ui.newmessageButton->setEnabled (false);
return;
}
@ -1387,6 +1391,8 @@ void ForumsDialog::insertPost()
ui.nextButton->setEnabled(false);
}
ui.newmessageButton->setEnabled (m_bIsForumSubscribed && mCurrThreadId.empty() == false);
/* get the Post */
ForumMsgInfo msg;
if (!rsForums->getForumMessage(mCurrForumId, mCurrThreadId, msg))
@ -1418,7 +1424,7 @@ void ForumsDialog::insertPost()
QString extraTxt;
extraTxt += QString::fromStdWString(msg.msg);
QHashIterator<QString, QString> i(smileys);
QHashIterator<QString, QString> i(style.smileys);
while(i.hasNext())
{
i.next();
@ -1678,68 +1684,6 @@ void ForumsDialog::showForumDetails()
fui.exec ();
}
void ForumsDialog::loadForumEmoticons()
{
QString sm_codes;
#if defined(Q_OS_WIN32)
QFile sm_file(QApplication::applicationDirPath() + "/emoticons/emotes.acs");
#else
QFile sm_file(QString(":/smileys/emotes.acs"));
#endif
if(!sm_file.open(QIODevice::ReadOnly))
{
std::cerr << "Could not open resouce file :/emoticons/emotes.acs" << std::endl ;
return ;
}
sm_codes = sm_file.readAll();
sm_file.close();
sm_codes.remove("\n");
sm_codes.remove("\r");
int i = 0;
QString smcode;
QString smfile;
while(sm_codes[i] != '{')
{
i++;
}
while (i < sm_codes.length()-2)
{
smcode = "";
smfile = "";
while(sm_codes[i] != '\"')
{
i++;
}
i++;
while (sm_codes[i] != '\"')
{
smcode += sm_codes[i];
i++;
}
i++;
while(sm_codes[i] != '\"')
{
i++;
}
i++;
while(sm_codes[i] != '\"' && sm_codes[i+1] != ';')
{
smfile += sm_codes[i];
i++;
}
i++;
if(!smcode.isEmpty() && !smfile.isEmpty())
#if defined(Q_OS_WIN32)
smileys.insert(smcode, smfile);
#else
smileys.insert(smcode, ":/"+smfile);
#endif
}
}
void ForumsDialog::replytomessage()
{
if (mCurrForumId.empty()) {

View File

@ -24,6 +24,7 @@
#include "mainpage.h"
#include "RsAutoUpdatePage.h"
#include "chat/ChatStyle.h"
#include "ui_ForumsDialog.h"
class ForumsDialog : public RsAutoUpdatePage
@ -85,8 +86,6 @@ private:
void insertPost();
void updateMessageSummaryList(std::string forumId);
void loadForumEmoticons();
void forumSubscribe(bool subscribe);
void FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &ChildList);
void FillThreads(QList<QTreeWidgetItem *> &ThreadList, bool bExpandNewMessages, std::list<QTreeWidgetItem*> &itemToExpand);
@ -120,7 +119,7 @@ private:
int m_LastViewType;
std::string m_LastForumID;
QHash<QString, QString> smileys;
ChatStyle style;
/** Qt Designer generated object */
Ui::ForumsDialog ui;

View File

@ -60,7 +60,7 @@ CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
newMsg();
loadEmoticonsForums();
style.loadEmoticons();
}
/** context menu searchTablewidget2 **/
@ -187,138 +187,14 @@ void CreateForumMsg::cancelMsg()
close();
}
void CreateForumMsg::loadEmoticonsForums()
{
QString sm_codes;
#if defined(Q_OS_WIN32)
QFile sm_file(QApplication::applicationDirPath() + "/emoticons/emotes.acs");
#else
QFile sm_file(QString(":/smileys/emotes.acs"));
#endif
if(!sm_file.open(QIODevice::ReadOnly))
{
std::cerr << "Could not open resouce file :/emoticons/emotes.acs" << std::endl ;
return ;
}
sm_codes = sm_file.readAll();
sm_file.close();
sm_codes.remove("\n");
sm_codes.remove("\r");
int i = 0;
QString smcode;
QString smfile;
while(sm_codes[i] != '{')
{
i++;
}
while (i < sm_codes.length()-2)
{
smcode = "";
smfile = "";
while(sm_codes[i] != '\"')
{
i++;
}
i++;
while (sm_codes[i] != '\"')
{
smcode += sm_codes[i];
i++;
}
i++;
while(sm_codes[i] != '\"')
{
i++;
}
i++;
while(sm_codes[i] != '\"' && sm_codes[i+1] != ';')
{
smfile += sm_codes[i];
i++;
}
i++;
if(!smcode.isEmpty() && !smfile.isEmpty())
#if defined(Q_OS_WIN32)
smileys.insert(smcode, smfile);
#else
smileys.insert(smcode, ":/"+smfile);
#endif
}
}
void CreateForumMsg::smileyWidgetForums()
{
qDebug("MainWindow::smileyWidget()");
QWidget *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 );
//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.emoticonButton;
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;
QHashIterator<QString, QString> 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)
{
x = 0;
y++;
}
connect(smButton, SIGNAL(clicked()), this, SLOT(addSmileys()));
connect(smButton, SIGNAL(clicked()), smWidget, SLOT(close()));
}
smWidget->show();
style.showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()));
}
void CreateForumMsg::addSmileys()
{
ui.forumMessage->setText(ui.forumMessage->toHtml() + qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
ui.forumMessage->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
}
void CreateForumMsg::addFile()

View File

@ -25,6 +25,8 @@
#include "ui_CreateForumMsg.h"
#include "gui/chat/ChatStyle.h"
class AttachFileItem;
class CreateForumMsg : public QMainWindow
@ -36,8 +38,6 @@ public:
void newMsg(); /* cleanup */
void loadEmoticonsForums();
private slots:
/** Create the context popup menu and it's submenus */
void forumMessageCostumPopupMenu( QPoint point );
@ -64,7 +64,7 @@ private:
std::string mForumId;
std::string mParentId;
QHash<QString, QString> smileys;
ChatStyle style;
/** Qt Designer generated object */
Ui::CreateForumMsg ui;

View File

@ -4684,7 +4684,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+8"/>
<source>Transfers</source>
<translation>Transfers</translation>
<translation>Übertragungen</translation>
</message>
<message>
<location line="+8"/>