Moved checkbox for news feed sort order from settings to NewsFeed

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7852 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-01-20 18:06:56 +00:00
parent 2b0bdc73bb
commit 32c9fe7eca
7 changed files with 41 additions and 37 deletions

View File

@ -108,10 +108,14 @@ NewsFeed::NewsFeed(QWidget *parent) :
ui->feedWidget->enableRemove(true); ui->feedWidget->enableRemove(true);
ui->sortComboBox->addItem(tr("Newest on top"), Qt::DescendingOrder);
ui->sortComboBox->addItem(tr("Oldest on top"), Qt::AscendingOrder);
connect(ui->sortComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sortChanged(int)));
connect(ui->removeAllButton, SIGNAL(clicked()), ui->feedWidget, SLOT(clear())); connect(ui->removeAllButton, SIGNAL(clicked()), ui->feedWidget, SLOT(clear()));
connect(ui->feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions())); connect(ui->feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
connect(ui->feedWidget, SIGNAL(feedCountChanged()), this, SLOT(sendNewsFeedChanged())); connect(ui->feedWidget, SIGNAL(feedCountChanged()), this, SLOT(sendNewsFeedChanged()));
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
QString hlp_str = tr( QString hlp_str = tr(
" <h1><img width=\"32\" src=\":/images/64px_help.png\">&nbsp;&nbsp;News Feed</h1> \ " <h1><img width=\"32\" src=\":/images/64px_help.png\">&nbsp;&nbsp;News Feed</h1> \
@ -129,11 +133,15 @@ QString hlp_str = tr(
registerHelpButton(ui->helpButton,hlp_str) ; registerHelpButton(ui->helpButton,hlp_str) ;
settingsChanged(); // load settings
processSettings(true);
} }
NewsFeed::~NewsFeed() NewsFeed::~NewsFeed()
{ {
// save settings
processSettings(false);
if (instance == this) { if (instance == this) {
instance = NULL; instance = NULL;
} }
@ -154,9 +162,31 @@ UserNotify *NewsFeed::getUserNotify(QObject *parent)
return new NewsFeedUserNotify(this, parent); return new NewsFeedUserNotify(this, parent);
} }
void NewsFeed::settingsChanged() void NewsFeed::processSettings(bool load)
{ {
ui->feedWidget->setSortRole(ROLE_RECEIVED, Settings->getAddFeedsAtEnd() ? Qt::AscendingOrder : Qt::DescendingOrder); Settings->beginGroup("NewsFeed");
if (load) {
// load settings
// state of sort order
Qt::SortOrder sortOrder = (Qt::SortOrder) Settings->value("SortOrder", Qt::AscendingOrder).toInt();
ui->sortComboBox->setCurrentIndex(ui->sortComboBox->findData(sortOrder));
sortChanged(ui->sortComboBox->currentIndex());
} else {
// save settings
// state of sort order
Settings->setValue("SortOrder", ui->sortComboBox->itemData(ui->sortComboBox->currentIndex()).toInt());
}
Settings->endGroup();
}
void NewsFeed::sortChanged(int index)
{
Qt::SortOrder sortOrder = (Qt::SortOrder) ui->sortComboBox->itemData(index).toInt();
ui->feedWidget->setSortRole(ROLE_RECEIVED, sortOrder);
} }
void NewsFeed::updateDisplay() void NewsFeed::updateDisplay()
@ -735,7 +765,7 @@ void NewsFeed::addFeedItem(FeedItem *item)
// costly, but not really a problem here // costly, but not really a problem here
int feedItemCount; int feedItemCount;
bool fromTop = Settings->getAddFeedsAtEnd(); bool fromTop = (ui->sortComboBox->itemData(ui->sortComboBox->currentIndex()).toInt() == Qt::AscendingOrder);
while ((feedItemCount = ui->feedWidget->feedItemCount()) >= MAX_FEEDITEM_COUNT) { while ((feedItemCount = ui->feedWidget->feedItemCount()) >= MAX_FEEDITEM_COUNT) {
FeedItem *feedItem = ui->feedWidget->feedItem(fromTop ? 0 : feedItemCount - 1); FeedItem *feedItem = ui->feedWidget->feedItem(fromTop ? 0 : feedItemCount - 1);

View File

@ -69,13 +69,15 @@ signals:
void newsFeedChanged(int count); void newsFeedChanged(int count);
protected: protected:
void processSettings(bool load);
/* TokenResponse */ /* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots: private slots:
// void toggleChanMsgItems(bool on); // void toggleChanMsgItems(bool on);
void feedoptions(); void feedoptions();
void settingsChanged(); void sortChanged(int index);
void sendNewsFeedChanged(); void sendNewsFeedChanged();

View File

@ -77,6 +77,9 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QComboBox" name="sortComboBox"/>
</item>
<item> <item>
<widget class="QPushButton" name="feedOptionsButton"> <widget class="QPushButton" name="feedOptionsButton">
<property name="text"> <property name="text">

View File

@ -198,8 +198,6 @@ NotifyPage::save(QString &/*errmsg*/)
MainWindow::installGroupChatNotifier(); MainWindow::installGroupChatNotifier();
MainWindow::installNotifyIcons(); MainWindow::installNotifyIcons();
Settings->setAddFeedsAtEnd(ui.addFeedsAtEnd->isChecked());
int index = ui.comboBoxToasterPosition->currentIndex(); int index = ui.comboBoxToasterPosition->currentIndex();
if (index != -1) { if (index != -1) {
Settings->setToasterPosition((RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(index).toInt()); Settings->setToasterPosition((RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(index).toInt());
@ -244,8 +242,6 @@ void NotifyPage::load()
ui.systray_GroupChat->setChecked(Settings->getDisplayTrayGroupChat()); ui.systray_GroupChat->setChecked(Settings->getDisplayTrayGroupChat());
ui.systray_ChatLobby->setChecked(Settings->getDisplayTrayChatLobby()); ui.systray_ChatLobby->setChecked(Settings->getDisplayTrayChatLobby());
ui.addFeedsAtEnd->setChecked(Settings->getAddFeedsAtEnd());
ui.pushButtonDisableAll->setChecked(NotifyQt::isAllDisable()); ui.pushButtonDisableAll->setChecked(NotifyQt::isAllDisable());
RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition(); RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition();

View File

@ -86,20 +86,6 @@
<item> <item>
<layout class="QVBoxLayout" name="feedLayout"/> <layout class="QVBoxLayout" name="feedLayout"/>
</item> </item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="addFeedsAtEnd">
<property name="text">
<string>Add feeds at end</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -486,16 +486,6 @@ void RshareSettings::setDisplayTrayGroupChat(bool bValue)
setValue("DisplayTrayGroupChat", bValue); setValue("DisplayTrayGroupChat", bValue);
} }
bool RshareSettings::getAddFeedsAtEnd()
{
return value("AddFeedsAtEnd").toBool();
}
void RshareSettings::setAddFeedsAtEnd(bool bValue)
{
setValue("AddFeedsAtEnd", bValue);
}
bool RshareSettings::getChatSendMessageWithCtrlReturn() bool RshareSettings::getChatSendMessageWithCtrlReturn()
{ {
return valueFromGroup("Chat", "SendMessageWithCtrlReturn", false).toBool(); return valueFromGroup("Chat", "SendMessageWithCtrlReturn", false).toBool();

View File

@ -199,9 +199,6 @@ public:
bool getDisplayTrayGroupChat(); bool getDisplayTrayGroupChat();
void setDisplayTrayGroupChat(bool bValue); void setDisplayTrayGroupChat(bool bValue);
bool getAddFeedsAtEnd();
void setAddFeedsAtEnd(bool bValue);
bool getChatSendMessageWithCtrlReturn(); bool getChatSendMessageWithCtrlReturn();
void setChatSendMessageWithCtrlReturn(bool bValue); void setChatSendMessageWithCtrlReturn(bool bValue);