Added setting for the count of messages to load from the history for group and private chat

Restore the last active page in MainWindow on startup
Removed not needed methods RshareSettings::getChatAvatar and RshareSettings::setChatAvatar


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3747 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-11-04 11:14:47 +00:00
parent 5a6456ebf1
commit ad6b10272b
11 changed files with 161 additions and 43 deletions

View File

@ -246,8 +246,10 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow())); addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
#endif #endif
/* Select the first action */ if (activatePage((Page) Settings->getLastPageInMainWindow()) == false) {
grp->actions()[0]->setChecked(true); /* Select the first action */
grp->actions()[0]->setChecked(true);
}
/** StatusBar section ********/ /** StatusBar section ********/
/* initialize combobox in status bar */ /* initialize combobox in status bar */
@ -306,6 +308,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
/** Destructor. */ /** Destructor. */
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
Settings->setLastPageInMainWindow(getActivatePage());
delete _bandwidthGraph; delete _bandwidthGraph;
delete _messengerwindowAct; delete _messengerwindowAct;
delete peerstatus; delete peerstatus;
@ -600,10 +604,10 @@ void MainWindow::addAction(QAction *action, const char *slot)
} }
/** Set focus to the given page. */ /** Set focus to the given page. */
/*static*/ void MainWindow::activatePage(Page page) /*static*/ bool MainWindow::activatePage(Page page)
{ {
if (_instance == NULL) { if (_instance == NULL) {
return; return false;
} }
MainPage *Page = NULL; MainPage *Page = NULL;
@ -648,7 +652,57 @@ void MainWindow::addAction(QAction *action, const char *slot)
if (Page) { if (Page) {
/* Set the focus to the specified page. */ /* Set the focus to the specified page. */
_instance->ui.stackPages->setCurrentPage(Page); _instance->ui.stackPages->setCurrentPage(Page);
return true;
} }
return false;
}
/** Get the active page. */
/*static*/ MainWindow::Page MainWindow::getActivatePage()
{
if (_instance == NULL) {
return Network;
}
QWidget *page = _instance->ui.stackPages->currentWidget();
if (page == _instance->networkDialog) {
return Network;
}
if (page == _instance->peersDialog) {
return Friends;
}
if (page == _instance->searchDialog) {
return Search;
}
if (page == _instance->transfersDialog) {
return Transfers;
}
if (page == _instance->sharedfilesDialog) {
return SharedDirectories;
}
if (page == _instance->messagesDialog) {
return Messages;
}
#ifndef RS_RELEASE_VERSION
if (page == _instance->linksDialog) {
return Links;
}
if (page == _instance->channelFeed) {
return Channels;
}
#endif
if (page == _instance->forumsDialog) {
return Forums;
}
#ifdef BLOGS
if (page == _instance->blogsFeed) {
return Blogs;
}
#endif
return Network;
} }
/** get page */ /** get page */

View File

@ -68,19 +68,20 @@ class MainWindow : public RWindow
public: public:
/** Main dialog pages. */ /** Main dialog pages. */
enum Page { enum Page {
Network = 0, /** Network page. */ /* Fixed numbers for load and save the last page */
Friends, /** Peers page. */ Network = 0, /** Network page. */
Search, /** Search page. */ Friends = 1, /** Peers page. */
Transfers, /** Transfers page. */ Search = 2, /** Search page. */
SharedDirectories, /** Shared Directories page. */ Transfers = 3, /** Transfers page. */
Messages, /** Messages page. */ SharedDirectories = 4, /** Shared Directories page. */
Channels, /** Channels page. */ Messages = 5, /** Messages page. */
Forums, /** Forums page. */ Channels = 6, /** Channels page. */
Forums = 7, /** Forums page. */
#ifdef BLOGS #ifdef BLOGS
Blogs, /** Blogs page. */ Blogs = 8, /** Blogs page. */
#endif #endif
#ifndef RS_RELEASE_VERSION #ifndef RS_RELEASE_VERSION
Links, /** Links page. */ Links = 9, /** Links page. */
#endif #endif
}; };
@ -94,7 +95,8 @@ public:
/** Shows the MainWindow dialog with focus set to the given page. */ /** Shows the MainWindow dialog with focus set to the given page. */
static void showWindow(Page page); static void showWindow(Page page);
/** Set focus to the given page. */ /** Set focus to the given page. */
static void activatePage (Page page); static bool activatePage (Page page);
static Page getActivatePage ();
/** get page */ /** get page */
static MainPage *getPage (Page page); static MainPage *getPage (Page page);

View File

@ -188,7 +188,7 @@ PeersDialog::PeersDialog(QWidget *parent)
historyKeeper.init(QString::fromStdString(RsInit::RsProfileConfigDirectory()) + "/chatPublic.xml"); historyKeeper.init(QString::fromStdString(RsInit::RsProfileConfigDirectory()) + "/chatPublic.xml");
QList<IMHistoryItem> historyItems; QList<IMHistoryItem> historyItems;
historyKeeper.getMessages(historyItems, 20); historyKeeper.getMessages(historyItems, Settings->getPublicChatHistoryCount());
foreach(IMHistoryItem item, historyItems) { foreach(IMHistoryItem item, historyItems) {
addChatMsg(item.incoming, true, item.name, item.recvTime, item.messageText); addChatMsg(item.incoming, true, item.name, item.recvTime, item.messageText);
} }

View File

@ -210,7 +210,7 @@ PopupChatDialog::PopupChatDialog(std::string id, const QString name, QWidget *pa
rsMsgs->getPrivateChatQueueCount(false) && rsMsgs->getPrivateChatQueue(false, dialogId, offlineChat); rsMsgs->getPrivateChatQueueCount(false) && rsMsgs->getPrivateChatQueue(false, dialogId, offlineChat);
QList<IMHistoryItem> historyItems; QList<IMHistoryItem> historyItems;
historyKeeper.getMessages(historyItems, 20); historyKeeper.getMessages(historyItems, Settings->getPrivateChatHistoryCount());
foreach(IMHistoryItem item, historyItems) { foreach(IMHistoryItem item, historyItems) {
for(offineChatIt = offlineChat.begin(); offineChatIt != offlineChat.end(); offineChatIt++) { for(offineChatIt = offlineChat.begin(); offineChatIt != offlineChat.end(); offineChatIt++) {
/* are they public? */ /* are they public? */

View File

@ -132,6 +132,11 @@ bool IMHistoryKeeper::getMessages(QList<IMHistoryItem> &historyItems, const int
historyItems.clear(); historyItems.clear();
if (messagesCount == 0) {
/* nothing to do */
return true;
}
QListIterator<IMHistoryItem> hii(hitems); QListIterator<IMHistoryItem> hii(hitems);
hii.toBack(); hii.toBack();
while (hii.hasPrevious()) { while (hii.hasPrevious()) {

View File

@ -113,6 +113,9 @@ ChatPage::save(QString &errmsg)
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
Settings->setPublicChatHistoryCount(ui.groupchatspinBox->value());
Settings->setPrivateChatHistoryCount(ui.privatchatspinBox->value());
ChatStyleInfo info; ChatStyleInfo info;
QListWidgetItem *item = ui.publicList->currentItem(); QListWidgetItem *item = ui.publicList->currentItem();
if (item) { if (item) {
@ -161,6 +164,9 @@ ChatPage::load()
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn()); ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
ui.groupchatspinBox->setValue(Settings->getPublicChatHistoryCount());
ui.privatchatspinBox->setValue(Settings->getPrivateChatHistoryCount());
ui.labelChatFontPreview->setText(fontTempChat.rawName()); ui.labelChatFontPreview->setText(fontTempChat.rawName());
ui.labelChatFontPreview->setFont(fontTempChat); ui.labelChatFontPreview->setFont(fontTempChat);

View File

@ -648,7 +648,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>0 = off</string> <string>Load number of messages (0 = off)</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -140,16 +140,6 @@ void RshareSettings::initSettings()
setDefault("AddFeedsAtEnd", false); setDefault("AddFeedsAtEnd", false);
} }
/** Gets/sets the currently saved chat avatar. */
QImage RshareSettings::getChatAvatar() const
{
return value(SETTING_CHAT_AVATAR).value<QImage>();
}
void RshareSettings::setChatAvatar(const QImage& I)
{
setValue(SETTING_CHAT_AVATAR,I) ;
}
/** Gets the currently preferred language code for Rshare. */ /** Gets the currently preferred language code for Rshare. */
QString RshareSettings::getLanguageCode() QString RshareSettings::getLanguageCode()
{ {
@ -356,6 +346,26 @@ void RshareSettings::setHistoryChatStyle(const QString &stylePath, const QString
setValueToGroup("Chat", "StylePrivateVariant", styleVariant); setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
} }
int RshareSettings::getPublicChatHistoryCount()
{
return valueFromGroup("Chat", "PublicChatHistoryCount", 0).toInt();
}
void RshareSettings::setPublicChatHistoryCount(int value)
{
setValueToGroup("Chat", "PublicChatHistoryCount", value);
}
int RshareSettings::getPrivateChatHistoryCount()
{
return valueFromGroup("Chat", "PrivateChatHistoryCount", 20).toInt();
}
void RshareSettings::setPrivateChatHistoryCount(int value)
{
setValueToGroup("Chat", "PrivateChatHistoryCount", value);
}
/** Returns true if RetroShare is set to run on system boot. */ /** Returns true if RetroShare is set to run on system boot. */
bool bool
RshareSettings::runRetroshareOnBoot() RshareSettings::runRetroshareOnBoot()
@ -445,6 +455,17 @@ void RshareSettings::loadWidgetInformation(QMainWindow *widget, QToolBar *toolBa
loadWidgetInformation(widget); loadWidgetInformation(widget);
} }
/* MainWindow */
int RshareSettings::getLastPageInMainWindow ()
{
return valueFromGroup("MainWindow", "LastPage", true).toInt();
}
void RshareSettings::setLastPageInMainWindow (int value)
{
setValueToGroup("MainWindow", "LastPage", value);
}
/* Messages */ /* Messages */
bool RshareSettings::getMsgSetToReadOnActivate () bool RshareSettings::getMsgSetToReadOnActivate ()
{ {

View File

@ -84,12 +84,6 @@ public:
/** Set whether to run RetroShare on system boot. */ /** Set whether to run RetroShare on system boot. */
void setRunRetroshareOnBoot(bool run); void setRunRetroshareOnBoot(bool run);
/** Returns the chat avatar. Returns a null image if no avatar is saved. */
QImage getChatAvatar() const ;
/** set the chat avatar. Returns a null image if no avatar is saved. */
void setChatAvatar(const QImage&) ;
/* Get the destination log file. */ /* Get the destination log file. */
QString getLogFile(); QString getLogFile();
/** Set the destination log file. */ /** Set the destination log file. */
@ -145,6 +139,13 @@ public:
void getHistoryChatStyle(QString &stylePath, QString &styleVariant); void getHistoryChatStyle(QString &stylePath, QString &styleVariant);
void setHistoryChatStyle(const QString &stylePath, const QString &styleVariant); void setHistoryChatStyle(const QString &stylePath, const QString &styleVariant);
/* Chat */
int getPublicChatHistoryCount();
void setPublicChatHistoryCount(int value);
int getPrivateChatHistoryCount();
void setPrivateChatHistoryCount(int value);
//! Save placement, state and size information of a window. //! Save placement, state and size information of a window.
void saveWidgetInformation(QWidget *widget); void saveWidgetInformation(QWidget *widget);
@ -157,6 +158,10 @@ public:
//! Method overload. Restore window and toolbar information. //! Method overload. Restore window and toolbar information.
void loadWidgetInformation(QMainWindow *widget, QToolBar *toolBar); void loadWidgetInformation(QMainWindow *widget, QToolBar *toolBar);
/* MainWindow */
int getLastPageInMainWindow ();
void setLastPageInMainWindow (int value);
/* Messages */ /* Messages */
bool getMsgSetToReadOnActivate (); bool getMsgSetToReadOnActivate ();
void setMsgSetToReadOnActivate (bool bValue); void setMsgSetToReadOnActivate (bool bValue);

View File

@ -147,7 +147,7 @@ p, li { white-space: pre-wrap; }
<translation>Abbrechen</translation> <translation>Abbrechen</translation>
</message> </message>
<message> <message>
<location filename="../gui/AddLinksDialog.cpp" line="+87"/> <location filename="../gui/AddLinksDialog.cpp" line="+86"/>
<source>Add Link Failure</source> <source>Add Link Failure</source>
<translation>Fehle beim Hinzufügen des Links</translation> <translation>Fehle beim Hinzufügen des Links</translation>
</message> </message>
@ -1221,7 +1221,27 @@ Verfügbar: %3</translation>
<translation>Emoticons für Gruppenchat</translation> <translation>Emoticons für Gruppenchat</translation>
</message> </message>
<message> <message>
<location line="+64"/> <location line="+34"/>
<source>Chat History</source>
<translation>Chat History</translation>
</message>
<message>
<location line="+6"/>
<source>Load number of messages (0 = off)</source>
<translation>Lade Anzahl von Nachrichten (0 = aus)</translation>
</message>
<message>
<location line="+9"/>
<source>Group Chat</source>
<translation>Gruppenchat</translation>
</message>
<message>
<location line="+20"/>
<source>Private Chat</source>
<translation>Privater Chat</translation>
</message>
<message>
<location line="+49"/>
<source>Group chat</source> <source>Group chat</source>
<translation>Gruppenchat</translation> <translation>Gruppenchat</translation>
</message> </message>
@ -1231,12 +1251,12 @@ Verfügbar: %3</translation>
<translation>Privater Chat</translation> <translation>Privater Chat</translation>
</message> </message>
<message> <message>
<location line="-300"/> <location line="-354"/>
<source>General</source> <source>General</source>
<translation>Allgemein</translation> <translation>Allgemein</translation>
</message> </message>
<message> <message>
<location line="+111"/> <location line="+118"/>
<source>Enable Group Chat History</source> <source>Enable Group Chat History</source>
<translation>Chat Verlauf für Gruppenchat</translation> <translation>Chat Verlauf für Gruppenchat</translation>
</message> </message>
@ -1246,12 +1266,12 @@ Verfügbar: %3</translation>
<translation>Sende Nachricht mit Strg+Enter</translation> <translation>Sende Nachricht mit Strg+Enter</translation>
</message> </message>
<message> <message>
<location line="+20"/> <location line="-17"/>
<source>Enable Private Chat History</source> <source>Enable Private Chat History</source>
<translation>Chat Verlauf für privaten Chat</translation> <translation>Chat Verlauf für privaten Chat</translation>
</message> </message>
<message> <message>
<location line="+11"/> <location line="+95"/>
<source>Style</source> <source>Style</source>
<translation>Stil</translation> <translation>Stil</translation>
</message> </message>
@ -1282,7 +1302,7 @@ Verfügbar: %3</translation>
<translation>Verlauf</translation> <translation>Verlauf</translation>
</message> </message>
<message> <message>
<location filename="../gui/settings/ChatPage.cpp" line="+197"/> <location filename="../gui/settings/ChatPage.cpp" line="+203"/>
<source>Incoming message in history</source> <source>Incoming message in history</source>
<translation>Eingehehende Nachricht aus dem Verlauf</translation> <translation>Eingehehende Nachricht aus dem Verlauf</translation>
</message> </message>
@ -4785,7 +4805,7 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>LinksDialog</name> <name>LinksDialog</name>
<message> <message>
<location filename="../gui/LinksDialog.cpp" line="+134"/> <location filename="../gui/LinksDialog.cpp" line="+137"/>
<source>Share Link Anonymously</source> <source>Share Link Anonymously</source>
<translation>Verknüpfung anonym teilen</translation> <translation>Verknüpfung anonym teilen</translation>
</message> </message>
@ -5006,7 +5026,12 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Verknüpfungs-Wolke&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation> &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Verknüpfungs-Wolke&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message> </message>
<message> <message>
<location line="-435"/> <location line="+28"/>
<source>Add new link</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-463"/>
<source>Combo</source> <source>Combo</source>
<translation>Kombiniert</translation> <translation>Kombiniert</translation>
</message> </message>