linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02810
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2366: rework user icons to be merged from base icons; dispatch away mode changes
------------------------------------------------------------
revno: 2366
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-12-26 23:20:59 +0100
message:
rework user icons to be merged from base icons; dispatch away mode changes
removed:
res/users.bmp
added:
res/User.ico
res/UserAway.ico
res/UserNoCon.ico
res/UserNoSlot.ico
res/UserOp.ico
modified:
changelog.txt
dcpp/Util.cpp
dcpp/Util.h
help/faq_different_icons.html
win32/DCPlusPlus.rc
win32/HubFrame.cpp
win32/HubFrame.h
win32/MainWindow.cpp
win32/MainWindow.h
win32/WinUtil.cpp
win32/WinUtil.h
win32/resource.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-12-22 18:35:14 +0000
+++ changelog.txt 2010-12-26 22:20:59 +0000
@@ -48,9 +48,9 @@
* [L#250149] Retry on more possible Coral errors (emtee)
* [L#260748] Really readded sfv check (was broken by segmented downloading) (emtee)
* Update bzip2 to version 1.0.6
-* Repurpose blue user icons to identify users with great ADC protocol support (poy)
* [ADC] Dispatch the amount of free slots with INF FS (poy)
-* Repurpose passive user icons to mean "no free slot" (when INF FS is available) (poy)
+* [ADC] Dispatch away mode changes (poy)
+* Add a user icon modifier for users with no free slot (when INF FS is available) (poy)
* [L#534242] Better looking settings dialog (fleetcommand, poy)
* Allow regular expressions in ADL searches (poy)
* [L#395464] [ADC] Send "000" as the STA success code
=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp 2010-12-26 17:45:12 +0000
+++ dcpp/Util.cpp 2010-12-26 22:20:59 +0000
@@ -20,14 +20,16 @@
#include "DCPlusPlus.h"
#include "Util.h"
+
+#include "CID.h"
+#include "ClientManager.h"
+#include "FastAlloc.h"
#include "File.h"
-
+#include "LogManager.h"
+#include "SettingsManager.h"
+#include "SimpleXML.h"
#include "StringTokenizer.h"
-#include "SettingsManager.h"
-#include "LogManager.h"
#include "version.h"
-#include "File.h"
-#include "SimpleXML.h"
#ifndef _WIN32
#include <sys/socket.h>
@@ -40,10 +42,6 @@
#endif
#include <locale.h>
-#include "CID.h"
-
-#include "FastAlloc.h"
-
namespace dcpp {
#ifndef _DEBUG
@@ -1006,5 +1004,23 @@
#endif // _WIN32
}
+bool Util::getAway() {
+ return away;
+}
+
+void Util::setAway(bool aAway) {
+ bool changed = aAway != away;
+
+ away = aAway;
+ if(away)
+ awayTime = time(NULL);
+
+ if(changed)
+ ClientManager::getInstance()->infoUpdated();
+}
+
+void Util::switchAway() {
+ setAway(!away);
+}
} // namespace dcpp
=== modified file 'dcpp/Util.h'
--- dcpp/Util.h 2010-12-26 17:45:12 +0000
+++ dcpp/Util.h 2010-12-26 22:20:59 +0000
@@ -414,15 +414,9 @@
static const string& getIpCountry(const string& IP);
- static bool getAway() { return away; }
- static void setAway(bool aAway) {
- away = aAway;
- if (away)
- awayTime = time(NULL);
- }
- static void switchAway() {
- setAway(!away);
- }
+ static bool getAway();
+ static void setAway(bool aAway);
+ static void switchAway();
static bool getManualAway() { return manualAway; }
static void setManualAway(bool aManualAway) { manualAway = aManualAway; }
=== modified file 'help/faq_different_icons.html'
--- help/faq_different_icons.html 2010-12-03 17:26:12 +0000
+++ help/faq_different_icons.html 2010-12-26 22:20:59 +0000
@@ -6,17 +6,22 @@
<link type="text/css" rel="stylesheet" href="style.css"/>
</head>
<body>
-<h1>What do the different user icons mean?</h1>
-<dl style="margin-left: 40px;">
- <dt>Green</dt>
- <dd>Standard user icon (no particular attribute).</dd>
- <dt>Blue</dt>
- <dd>The user has great ADC protocol support; it has at least all the features supported by this client.</dd>
- <dt>With bricks</dt>
- <dd>The user has no free slot available.</dd>
- <dt>With a yellow key</dt>
- <dd>The user is a hub operator.</dd>
-</dl>
-<img src="users.bmp" alt="User Icons"/>
+ <h1>What do the different user icons mean?</h1>
+ Base icons:
+ <dl style="margin-left: 40px;">
+ <dt><img src="User.ico" width="16" height="16" alt="Green"/> Green</dt>
+ <dd>Standard user icon (no particular attribute).</dd>
+ <dt><img src="UserAway.ico" width="16" height="16" alt="Grey"/> Grey</dt>
+ <dd>The user is in away mode.</dd>
+ </dl>
+ Icon modifiers:
+ <dl style="margin-left: 40px;">
+ <dt><img src="UserOp.ico" width="16" height="16" alt="Yellow key"/> Yellow key</dt>
+ <dd>The user is a hub operator.</dd>
+ <dt><img src="UserNoCon.ico" width="16" height="16" alt="Red bricks"/> Red bricks</dt>
+ <dd>The user cannot be connected to, for he is in passive mode and does not support NAT traversal.</dd>
+ <dt><img src="UserNoSlot.ico" width="16" height="16" alt="Red circle"/> Red circle</dt>
+ <dd>The user has no free slot available.</dd>
+ </dl>
</body>
</html>
=== added file 'res/User.ico'
Binary files res/User.ico 1970-01-01 00:00:00 +0000 and res/User.ico 2010-12-26 22:20:59 +0000 differ
=== added file 'res/UserAway.ico'
Binary files res/UserAway.ico 1970-01-01 00:00:00 +0000 and res/UserAway.ico 2010-12-26 22:20:59 +0000 differ
=== added file 'res/UserNoCon.ico'
Binary files res/UserNoCon.ico 1970-01-01 00:00:00 +0000 and res/UserNoCon.ico 2010-12-26 22:20:59 +0000 differ
=== added file 'res/UserNoSlot.ico'
Binary files res/UserNoSlot.ico 1970-01-01 00:00:00 +0000 and res/UserNoSlot.ico 2010-12-26 22:20:59 +0000 differ
=== added file 'res/UserOp.ico'
Binary files res/UserOp.ico 1970-01-01 00:00:00 +0000 and res/UserOp.ico 2010-12-26 22:20:59 +0000 differ
=== removed file 'res/users.bmp'
Binary files res/users.bmp 2009-11-03 17:20:32 +0000 and res/users.bmp 1970-01-01 00:00:00 +0000 differ
=== modified file 'win32/DCPlusPlus.rc'
--- win32/DCPlusPlus.rc 2010-12-20 17:19:41 +0000
+++ win32/DCPlusPlus.rc 2010-12-26 22:20:59 +0000
@@ -38,7 +38,6 @@
//
IDB_FOLDERS BITMAP "res/folders.bmp"
-IDB_USERS BITMAP "res/users.bmp"
/////////////////////////////////////////////////////////////////////////////
//
@@ -93,6 +92,11 @@
IDI_CANCEL ICON "res/Cancel.ico"
IDI_LEFT ICON "res/Left.ico"
IDI_RIGHT ICON "res/Right.ico"
+IDI_USER ICON "res/User.ico"
+IDI_USER_AWAY ICON "res/UserAway.ico"
+IDI_USER_OP ICON "res/UserOp.ico"
+IDI_USER_NOCON ICON "res/UserNoCon.ico"
+IDI_USER_NOSLOT ICON "res/UserNoSlot.ico"
/////////////////////////////////////////////////////////////////////////////
//
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2010-12-21 14:40:47 +0000
+++ win32/HubFrame.cpp 2010-12-26 22:20:59 +0000
@@ -703,18 +703,22 @@
}
int HubFrame::UserInfo::getImage() const {
- int image = identity.isOp() ? IMAGE_OP : IMAGE_USER;
+ int image = identity.isAway() ? WinUtil::USER_ICON_AWAY : WinUtil::USER_ICON;
+
+ if(identity.isOp()) {
+ image += 1 << (WinUtil::USER_ICON_OP - 1);
+ }
+
+ if(SETTING(INCOMING_CONNECTIONS) == SettingsManager::INCOMING_FIREWALL_PASSIVE &&
+ !identity.isTcpActive() && !identity.supports(AdcHub::NAT0_FEATURE))
+ {
+ // Users we can't connect to
+ image += 1 << (WinUtil::USER_ICON_NOCON - 1);
+ }
string freeSlots = identity.get("FS");
-
- if(!freeSlots.empty() && identity.supports(AdcHub::ADCS_FEATURE) && identity.supports(AdcHub::SEGA_FEATURE) &&
- ((identity.supports(AdcHub::TCP4_FEATURE) && identity.supports(AdcHub::UDP4_FEATURE)) || identity.supports(AdcHub::NAT0_FEATURE)))
- {
- image += 2;
- }
-
if(!freeSlots.empty() && Util::toUInt(freeSlots) == 0) {
- image += 4;
+ image += 1 << (WinUtil::USER_ICON_NOSLOT - 1);
}
return image;
@@ -1118,7 +1122,7 @@
MenuPtr menu = addChild(WinUtil::Seeds::menu);
menu->setTitle((sel.size() == 1) ? escapeMenu(getNick(sel[0]->getUser())) : str(TF_("%1% users") % sel.size()),
- WinUtil::userImages->getIcon(IMAGE_USER));
+ WinUtil::userImages->getIcon(0));
appendUserItems(getParent(), menu);
=== modified file 'win32/HubFrame.h'
--- win32/HubFrame.h 2010-12-21 14:40:47 +0000
+++ win32/HubFrame.h 2010-12-26 22:20:59 +0000
@@ -88,10 +88,6 @@
};
enum {
- IMAGE_USER = 0, IMAGE_OP
- };
-
- enum {
COLUMN_FIRST,
COLUMN_NICK = COLUMN_FIRST,
COLUMN_SHARED,
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2010-12-23 15:57:01 +0000
+++ win32/MainWindow.cpp 2010-12-26 22:20:59 +0000
@@ -92,7 +92,8 @@
stopperThread(NULL),
lastUp(0),
lastDown(0),
-lastTick(GET_TICK())
+lastTick(GET_TICK()),
+prevAway(false)
{
links.homepage = _T("http://dcplusplus.sourceforge.net/");
links.downloads = links.homepage + _T("download/");
@@ -441,11 +442,12 @@
slotsSpin->onUpdate(std::bind(&MainWindow::handleSlotsUpdate, this, _1, _2));
initStatus(true);
- status->setSize(STATUS_AWAY, status->getTextSize(T_("AWAY")).x + 12);
status->setSize(STATUS_SLOTS_SPIN, 22);
///@todo set to checkbox width + resizedrag width really
status->setSize(STATUS_DUMMY, 32);
+ updateAwayStatus();
+
status->setIcon(STATUS_COUNTS, WinUtil::statusIcon(IDI_HUB));
status->setIcon(STATUS_SLOTS, WinUtil::statusIcon(IDI_SLOTS));
{
@@ -910,7 +912,10 @@
if(!status)
return;
- status->setText(STATUS_AWAY, Util::getAway() ? T_("AWAY") : _T(""));
+ if(Util::getAway() != prevAway) {
+ prevAway = !prevAway;
+ updateAwayStatus();
+ }
tstring s = Text::toT(Client::getCounts());
status->setText(STATUS_COUNTS, s);
@@ -942,6 +947,12 @@
layoutSlotsSpin();
}
+void MainWindow::updateAwayStatus() {
+ status->setIcon(STATUS_AWAY, WinUtil::statusIcon(prevAway ? IDI_USER_AWAY : IDI_USER));
+ status->setToolTip(STATUS_AWAY, prevAway ? (T_("Status: Away - Double-click to switch to Available")) :
+ (T_("Status: Available - Double-click to switch to Away")));
+}
+
MainWindow::~MainWindow() {
dwt::Application::instance().removeFilter(filterIter);
}
=== modified file 'win32/MainWindow.h'
--- win32/MainWindow.h 2010-12-23 15:57:01 +0000
+++ win32/MainWindow.h 2010-12-26 22:20:59 +0000
@@ -131,6 +131,7 @@
int64_t lastUp;
int64_t lastDown;
uint64_t lastTick;
+ bool prevAway;
dwt::Application::FilterIter filterIter;
dwt::NotificationPtr notify;
@@ -188,6 +189,7 @@
void layout();
void layoutSlotsSpin();
void updateStatus();
+ void updateAwayStatus();
void showPortsError(const string& port);
void setSaveTimer();
void saveSettings();
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2010-12-20 17:19:41 +0000
+++ win32/WinUtil.cpp 2010-12-26 22:20:59 +0000
@@ -46,6 +46,7 @@
#include <dwt/DWTException.h>
#include <dwt/LibraryLoader.h>
+#include <dwt/util/GDI.h>
#ifdef HAVE_HTMLHELP_H
#include <htmlhelp.h>
@@ -158,8 +159,18 @@
{
userImages = dwt::ImageListPtr(new dwt::ImageList(dwt::Point(16, 16)));
- dwt::Bitmap tmp(IDB_USERS);
- userImages->add(tmp, RGB(255, 0, 255));
+ auto userIcon = [](unsigned id) { return createIcon(id, 16); };
+ dwt::IconPtr user = userIcon(IDI_USER), away = userIcon(IDI_USER_AWAY);
+ const unsigned modifierCount = USER_ICON_LAST - USER_ICON_MOD_START;
+ dwt::IconPtr modifiers[modifierCount] = { userIcon(IDI_USER_OP), userIcon(IDI_USER_NOCON), userIcon(IDI_USER_NOSLOT) };
+ for(size_t i = 0, n = USER_ICON_MOD_START * modifierCount * modifierCount; i < n; ++i) {
+ vector<dwt::IconPtr> icons;
+ icons.push_back((i & USER_ICON_AWAY) ? away : user);
+ for(size_t iMod = 0; iMod < modifierCount; ++iMod)
+ if(i & (1 << (iMod + 1)))
+ icons.push_back(modifiers[iMod]);
+ userImages->add(*dwt::util::merge(icons));
+ }
}
registerHubHandlers();
=== modified file 'win32/WinUtil.h'
--- win32/WinUtil.h 2010-12-20 17:19:41 +0000
+++ win32/WinUtil.h 2010-12-26 22:20:59 +0000
@@ -48,6 +48,20 @@
class WinUtil {
public:
+ enum {
+ // base icons
+ USER_ICON,
+ USER_ICON_AWAY,
+
+ // modifiers
+ USER_ICON_MOD_START,
+ USER_ICON_OP = USER_ICON_MOD_START,
+ USER_ICON_NOCON,
+ USER_ICON_NOSLOT,
+
+ USER_ICON_LAST
+ };
+
static tstring tth;
static dwt::BrushPtr bgBrush;
=== modified file 'win32/resource.h'
--- win32/resource.h 2010-12-20 17:19:41 +0000
+++ win32/resource.h 2010-12-26 22:20:59 +0000
@@ -51,9 +51,13 @@
#define IDI_CANCEL 143
#define IDI_LEFT 144
#define IDI_RIGHT 145
+#define IDI_USER 146
+#define IDI_USER_AWAY 147
+#define IDI_USER_OP 148
+#define IDI_USER_NOCON 149
+#define IDI_USER_NOSLOT 150
#define IDB_FOLDERS 151
-#define IDB_USERS 154
// Stuff that uses multiple id's