← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2730: move the pm hub selection box out of the status bar

 

------------------------------------------------------------
revno: 2730
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2011-12-18 18:30:57 +0100
message:
  move the pm hub selection box out of the status bar
modified:
  help/window_pm.html
  win32/PrivateFrame.cpp
  win32/PrivateFrame.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 'help/window_pm.html'
--- help/window_pm.html	2010-01-04 19:21:14 +0000
+++ help/window_pm.html	2011-12-18 17:30:57 +0000
@@ -10,6 +10,14 @@
 		<img src="UserOn.ico" width="16" height="16" alt="Private Message"/>
 		Private Message
 	</h1>
+
+	<h2>[Optional] Hub selection box (top)</h2>
+	<p cshelp="IDH_PM_HUB">
+	When a user is online in multiple hubs, this box can be used to select the hub through which
+	chat messages will be sent in order to reach the user. This can be particularly useful when
+	transmitting sensitive information, as hubs are able to read any private message being sent.
+	</p>
+
 <h2>Private chat window (top)</h2>
 <p cshelp="IDH_PM_CHAT">
 The private chat window displays messages sent during your private conversation with a specific user (to know which one, take a look at the title bar of the main DC++ window). You can chat with the other user in this "private area" by writing a message in the field below the private chat and pressing either Enter or Alt+S to send your message. You may also use <a href="chat_commands.html">/commands</a> (send /help to list those available).

=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp	2011-12-17 14:08:57 +0000
+++ win32/PrivateFrame.cpp	2011-12-18 17:30:57 +0000
@@ -17,9 +17,9 @@
  */
 
 #include "stdafx.h"
+#include "PrivateFrame.h"
 
 #include <boost/range/algorithm/for_each.hpp>
-#include "PrivateFrame.h"
 
 #include "HoldRedraw.h"
 #include "MainWindow.h"
@@ -119,11 +119,32 @@
 
 PrivateFrame::PrivateFrame(TabViewPtr parent, const HintedUser& replyTo_, const string& logPath) :
 BaseType(parent, _T(""), IDH_PM, IDI_PRIVATE, false),
+grid(0),
+hubGrid(0),
+hubBox(0),
 replyTo(replyTo_),
 priv(FavoriteManager::getInstance()->isPrivate(replyTo.getUser().hint)),
 online(replyTo.getUser().user->isOnline())
 {
-	createChat(this);
+	grid = addChild(Grid::Seed(2, 1));
+	grid->column(0).mode = GridInfo::FILL;
+	grid->row(1).mode = GridInfo::FILL;
+	grid->row(1).align = GridInfo::STRETCH;
+
+	hubGrid = grid->addChild(Grid::Seed(1, 2));
+	hubGrid->setHelpId(IDH_PM_HUB);
+	{
+		auto seed = WinUtil::Seeds::label;
+		seed.caption = T_("Hub to send messages through:");
+		hubGrid->addChild(seed);
+	}
+	hubBox = hubGrid->addChild(WinUtil::Seeds::comboBox);
+	addWidget(hubBox);
+
+	hubGrid->setEnabled(false);
+	hubGrid->setVisible(false);
+
+	createChat(grid);
 	chat->setHelpId(IDH_PM_CHAT);
 	addWidget(chat);
 	chat->onContextMenu([this](const dwt::ScreenCoordinate &sc) { return handleChatContextMenu(sc); });
@@ -136,14 +157,6 @@
 
 	initStatus();
 
-	hubGrid = addChild(Grid::Seed(1, 2));
-	{
-		auto seed = WinUtil::Seeds::label;
-		seed.caption = T_("Hub to send messages through:");
-		hubGrid->addChild(seed);
-	}
-	hubBox = hubGrid->addChild(WinUtil::Seeds::comboBox);
-
 	status->onDblClicked(STATUS_STATUS, [this] { openLog(); });
 
 	initAccels();
@@ -233,7 +246,7 @@
 	message->resize(rm);
 
 	r.size.y -= rm.size.y + border;
-	chat->resize(r);
+	grid->resize(r);
 }
 
 void PrivateFrame::updateOnlineStatus() {
@@ -250,10 +263,13 @@
 	hubs = ClientManager::getInstance()->getHubs(cid, hint, priv);
 	hubBox->clear();
 
-	if(hubs.empty()) {
-		hubBox->setEnabled(false);
-	} else {
-		hubBox->setEnabled(true);
+	if(online && !replyTo.getUser().user->isNMDC() && !hubs.empty()) {
+		if(!hubGrid->hasStyle(WS_VISIBLE)) {
+			hubGrid->setEnabled(true);
+			hubGrid->setVisible(true);
+
+			grid->layout();
+		}
 
 		for_each(hubs, [&](const StringPair &hub) {
 			auto idx = hubBox->addValue(Text::toT(hub.second));
@@ -265,15 +281,15 @@
 		if(hubBox->getSelected() == -1) {
 			hubBox->setSelected(0);
 		}
-	}
-
-	status->setWidget(STATUS_HUBS, hubGrid);
-
-	if(!online || replyTo.getUser().user->isNMDC()) {
-		status->setSize(STATUS_HUBS, 0);
-	}
-
-	status->refresh();
+
+		hubGrid->layout();
+
+	} else if(hubGrid->hasStyle(WS_VISIBLE)) {
+		hubGrid->setEnabled(false);
+		hubGrid->setVisible(false);
+
+		grid->layout();
+	}
 }
 
 void PrivateFrame::enterImpl(const tstring& s) {

=== modified file 'win32/PrivateFrame.h'
--- win32/PrivateFrame.h	2011-12-05 22:02:01 +0000
+++ win32/PrivateFrame.h	2011-12-18 17:30:57 +0000
@@ -48,7 +48,6 @@
 
 public:
 	enum Status {
-		STATUS_HUBS,
 		STATUS_STATUS,
 		STATUS_LAST
 	};
@@ -71,8 +70,10 @@
 	void sendMessage(const tstring& msg, bool thirdPerson = false);
 
 private:
+	GridPtr grid;
 	GridPtr hubGrid;
 	ComboBoxPtr hubBox;
+
 	StringPairList hubs;
 	ParamMap ucLineParams;