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()));
#endif
/* Select the first action */
grp->actions()[0]->setChecked(true);
if (activatePage((Page) Settings->getLastPageInMainWindow()) == false) {
/* Select the first action */
grp->actions()[0]->setChecked(true);
}
/** StatusBar section ********/
/* initialize combobox in status bar */
@ -306,6 +308,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
/** Destructor. */
MainWindow::~MainWindow()
{
Settings->setLastPageInMainWindow(getActivatePage());
delete _bandwidthGraph;
delete _messengerwindowAct;
delete peerstatus;
@ -600,10 +604,10 @@ void MainWindow::addAction(QAction *action, const char *slot)
}
/** Set focus to the given page. */
/*static*/ void MainWindow::activatePage(Page page)
/*static*/ bool MainWindow::activatePage(Page page)
{
if (_instance == NULL) {
return;
return false;
}
MainPage *Page = NULL;
@ -648,7 +652,57 @@ void MainWindow::addAction(QAction *action, const char *slot)
if (Page) {
/* Set the focus to the specified 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 */

View File

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

View File

@ -188,7 +188,7 @@ PeersDialog::PeersDialog(QWidget *parent)
historyKeeper.init(QString::fromStdString(RsInit::RsProfileConfigDirectory()) + "/chatPublic.xml");
QList<IMHistoryItem> historyItems;
historyKeeper.getMessages(historyItems, 20);
historyKeeper.getMessages(historyItems, Settings->getPublicChatHistoryCount());
foreach(IMHistoryItem item, historyItems) {
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);
QList<IMHistoryItem> historyItems;
historyKeeper.getMessages(historyItems, 20);
historyKeeper.getMessages(historyItems, Settings->getPrivateChatHistoryCount());
foreach(IMHistoryItem item, historyItems) {
for(offineChatIt = offlineChat.begin(); offineChatIt != offlineChat.end(); offineChatIt++) {
/* are they public? */

View File

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

View File

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

View File

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

View File

@ -140,16 +140,6 @@ void RshareSettings::initSettings()
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. */
QString RshareSettings::getLanguageCode()
{
@ -356,6 +346,26 @@ void RshareSettings::setHistoryChatStyle(const QString &stylePath, const QString
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. */
bool
RshareSettings::runRetroshareOnBoot()
@ -445,6 +455,17 @@ void RshareSettings::loadWidgetInformation(QMainWindow *widget, QToolBar *toolBa
loadWidgetInformation(widget);
}
/* MainWindow */
int RshareSettings::getLastPageInMainWindow ()
{
return valueFromGroup("MainWindow", "LastPage", true).toInt();
}
void RshareSettings::setLastPageInMainWindow (int value)
{
setValueToGroup("MainWindow", "LastPage", value);
}
/* Messages */
bool RshareSettings::getMsgSetToReadOnActivate ()
{

View File

@ -84,12 +84,6 @@ public:
/** Set whether to run RetroShare on system boot. */
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. */
QString getLogFile();
/** Set the destination log file. */
@ -145,6 +139,13 @@ public:
void getHistoryChatStyle(QString &stylePath, 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.
void saveWidgetInformation(QWidget *widget);
@ -157,6 +158,10 @@ public:
//! Method overload. Restore window and toolbar information.
void loadWidgetInformation(QMainWindow *widget, QToolBar *toolBar);
/* MainWindow */
int getLastPageInMainWindow ();
void setLastPageInMainWindow (int value);
/* Messages */
bool getMsgSetToReadOnActivate ();
void setMsgSetToReadOnActivate (bool bValue);

View File

@ -147,7 +147,7 @@ p, li { white-space: pre-wrap; }
<translation>Abbrechen</translation>
</message>
<message>
<location filename="../gui/AddLinksDialog.cpp" line="+87"/>
<location filename="../gui/AddLinksDialog.cpp" line="+86"/>
<source>Add Link Failure</source>
<translation>Fehle beim Hinzufügen des Links</translation>
</message>
@ -1221,7 +1221,27 @@ Verfügbar: %3</translation>
<translation>Emoticons für Gruppenchat</translation>
</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>
<translation>Gruppenchat</translation>
</message>
@ -1231,12 +1251,12 @@ Verfügbar: %3</translation>
<translation>Privater Chat</translation>
</message>
<message>
<location line="-300"/>
<location line="-354"/>
<source>General</source>
<translation>Allgemein</translation>
</message>
<message>
<location line="+111"/>
<location line="+118"/>
<source>Enable Group Chat History</source>
<translation>Chat Verlauf für Gruppenchat</translation>
</message>
@ -1246,12 +1266,12 @@ Verfügbar: %3</translation>
<translation>Sende Nachricht mit Strg+Enter</translation>
</message>
<message>
<location line="+20"/>
<location line="-17"/>
<source>Enable Private Chat History</source>
<translation>Chat Verlauf für privaten Chat</translation>
</message>
<message>
<location line="+11"/>
<location line="+95"/>
<source>Style</source>
<translation>Stil</translation>
</message>
@ -1282,7 +1302,7 @@ Verfügbar: %3</translation>
<translation>Verlauf</translation>
</message>
<message>
<location filename="../gui/settings/ChatPage.cpp" line="+197"/>
<location filename="../gui/settings/ChatPage.cpp" line="+203"/>
<source>Incoming message in history</source>
<translation>Eingehehende Nachricht aus dem Verlauf</translation>
</message>
@ -4785,7 +4805,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>LinksDialog</name>
<message>
<location filename="../gui/LinksDialog.cpp" line="+134"/>
<location filename="../gui/LinksDialog.cpp" line="+137"/>
<source>Share Link Anonymously</source>
<translation>Verknüpfung anonym teilen</translation>
</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>
</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>
<translation>Kombiniert</translation>
</message>