linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02458
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2294: Add a menu to change the group of a fav hub more easily
------------------------------------------------------------
revno: 2294
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2010-11-13 18:50:36 +0100
message:
Add a menu to change the group of a fav hub more easily
modified:
changelog.txt
help/window_favorite_hubs.html
win32/FavHubsFrame.cpp
win32/FavHubsFrame.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2010-11-11 22:21:17 +0000
+++ changelog.txt 2010-11-13 17:50:36 +0000
@@ -30,6 +30,7 @@
* Don't close the net stats window when double-clicking on the status bar (poy)
* Fix a random crash when reconnecting hubs and being unlucky (poy)
* Added notice about the original C implementation of Tiger (you must include this in mods!) (ullner)
+* Add a menu to change the group of a fav hub more easily (poy)
-- 0.770 2010-07-05 --
* [L#550300] Catch more potential file corruptions (thanks bigmuscle)
=== modified file 'help/window_favorite_hubs.html'
--- help/window_favorite_hubs.html 2010-01-16 15:01:05 +0000
+++ help/window_favorite_hubs.html 2010-11-13 17:50:36 +0000
@@ -45,7 +45,9 @@
<dt>Move down</dt>
<dd cshelp="IDH_FAVORITE_HUBS_MOVE_DOWN">Move down selected hubs in the list.</dd>
<dt>Remove</dt>
- <dd cshelp="IDH_FAVORITE_HUBS_REMOVE">Removes selected hubs from the favorite hubs list.</dd>
+ <dd cshelp="IDH_FAVORITE_HUBS_REMOVE">Remove selected hubs from the favorite hubs list.</dd>
+ <dt>Group</dt>
+ <dd cshelp="IDH_FAVORITE_HUBS_GROUP">Open a menu with the available favorite hub groups in order to move the selected hubs to the choosen group.</dd>
<dt>Manage groups</dt>
<dd cshelp="IDH_FAVORITE_HUBS_MANAGE_GROUPS">
<div>Open the <placeholder><a href="dialog_fav_hub_groups.html">Favorite hub groups</a></placeholder> dialog where you can add, edit, remove groups.</div>
=== modified file 'win32/FavHubsFrame.cpp'
--- win32/FavHubsFrame.cpp 2010-07-10 14:36:48 +0000
+++ win32/FavHubsFrame.cpp 2010-11-13 17:50:36 +0000
@@ -45,7 +45,7 @@
grid(0),
hubs(0)
{
- grid = addChild(Grid::Seed(2, 7));
+ grid = addChild(Grid::Seed(2, 8));
grid->column(0).mode = GridInfo::FILL;
grid->column(1).mode = GridInfo::FILL;
grid->column(2).mode = GridInfo::FILL;
@@ -53,6 +53,7 @@
grid->column(4).mode = GridInfo::FILL;
grid->column(5).mode = GridInfo::FILL;
grid->column(6).mode = GridInfo::FILL;
+ grid->column(7).mode = GridInfo::FILL;
grid->row(0).mode = GridInfo::FILL;
grid->row(0).align = GridInfo::STRETCH;
@@ -60,7 +61,7 @@
Table::Seed cs = WinUtil::Seeds::table;
cs.style |= LVS_NOSORTHEADER;
hubs = grid->addChild(cs);
- grid->setWidget(hubs, 0, 0, 1, 7);
+ grid->setWidget(hubs, 0, 0, 1, 8);
addWidget(hubs, false, true, false); /// @todo group headers never change colors so for now, we keep default Win colors
WinUtil::makeColumns(hubs, hubsColumns, COLUMN_LAST, SETTING(FAVHUBSFRAME_ORDER), SETTING(FAVHUBSFRAME_WIDTHS));
@@ -110,7 +111,13 @@
button->onClicked(std::bind(&FavHubsFrame::handleRemove, this));
addWidget(button);
- cs.caption = T_("Manage &groups");
+ cs.caption = T_("&Group");
+ button = grid->addChild(cs);
+ button->setHelpId(IDH_FAVORITE_HUBS_GROUP);
+ button->onClicked([this] { handleGroup(); });
+ addWidget(button);
+
+ cs.caption = T_("&Manage groups");
button = grid->addChild(cs);
button->setHelpId(IDH_FAVORITE_HUBS_MANAGE_GROUPS);
button->onClicked(std::bind(&FavHubsFrame::handleGroups, this));
@@ -265,6 +272,19 @@
}
}
+void FavHubsFrame::handleGroup() {
+ MenuPtr menu = addChild(WinUtil::Seeds::menu);
+ fillGroupMenu(menu);
+ menu->open(dwt::ScreenCoordinate(dwt::Point::fromLParam(::GetMessagePos())));
+}
+
+void FavHubsFrame::handleGroup(const string& group) {
+ StateKeeper keeper(hubs);
+ const FavoriteHubEntryList& selected = keeper.getSelection();
+ for_each(selected.cbegin(), selected.cend(), [group](FavoriteHubEntryPtr entry) { entry->setGroup(group); });
+ refresh();
+}
+
void FavHubsFrame::handleGroups() {
FavHubGroupsDlg(this).run();
@@ -312,7 +332,13 @@
menu->appendSeparator();
menu->appendItem(T_("&Remove"), std::bind(&FavHubsFrame::handleRemove, this), dwt::IconPtr(), selected);
menu->appendSeparator();
- menu->appendItem(T_("Manage &groups"), std::bind(&FavHubsFrame::handleGroups, this));
+ if(selected) {
+ MenuPtr group = menu->appendPopup(T_("&Group"));
+ fillGroupMenu(group);
+ } else {
+ menu->appendItem(T_("&Group"), 0, dwt::IconPtr(), selected);
+ }
+ menu->appendItem(T_("&Manage groups"), std::bind(&FavHubsFrame::handleGroups, this));
menu->open(pt);
return true;
@@ -329,6 +355,14 @@
return groups;
}
+void FavHubsFrame::fillGroupMenu(MenuPtr menu) {
+ TStringList groups(getSortedGroups());
+ for(auto i = groups.cbegin(), iend = groups.cend(); i != iend; ++i) {
+ const tstring& group = i->empty() ? T_("Default group") : *i;
+ menu->appendItem(group, [this, group] { handleGroup(Text::fromT(group)); });
+ }
+}
+
void FavHubsFrame::fillList() {
TStringList groups(getSortedGroups());
hubs->setGroups(groups);
=== modified file 'win32/FavHubsFrame.h'
--- win32/FavHubsFrame.h 2010-02-11 21:44:13 +0000
+++ win32/FavHubsFrame.h 2010-11-13 17:50:36 +0000
@@ -83,12 +83,15 @@
void handleProperties();
void handleMove(bool up);
void handleRemove();
+ void handleGroup();
+ void handleGroup(const string& group);
void handleGroups();
void handleDoubleClick();
bool handleKeyDown(int c);
bool handleContextMenu(dwt::ScreenCoordinate pt);
TStringList getSortedGroups() const;
+ void fillGroupMenu(MenuPtr menu);
void fillList();
void refresh();
FavoriteHubEntryList getSelection() const;