Add Vision-like Window menu, conversation list tweaks
ALT-↑ and ALT-↓ change the active conversation, based on its position in the main window's ConversationListView. If a conversation is registered by the main window, and no other conversation is selected, it is automatically selected.
This commit is contained in:
parent
71ae1456c6
commit
70c6001189
|
@ -32,4 +32,10 @@ const uint32 CAYA_REPLICANT_EXIT = 'RPEX';
|
|||
//! Show main window replicant notification
|
||||
const uint32 CAYA_REPLICANT_SHOW_WINDOW = 'CYSW';
|
||||
|
||||
//! Select the upward conversation
|
||||
const uint32 CAYA_MOVE_UP = 'CYmu';
|
||||
|
||||
//! Select the downward conversation
|
||||
const uint32 CAYA_MOVE_DOWN = 'CYmd';
|
||||
|
||||
#endif // _CAYA_MESSAGES_H
|
||||
|
|
|
@ -99,13 +99,6 @@ Conversation::ObserveInteger(int32 what, int32 val)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
Conversation::ShowView(bool typing, bool userAction)
|
||||
{
|
||||
((TheApp*)be_app)->GetMainWindow()->SetConversation(this);
|
||||
}
|
||||
|
||||
|
||||
BMessenger
|
||||
Conversation::Messenger() const
|
||||
{
|
||||
|
@ -134,13 +127,6 @@ Conversation::SetProtocolLooper(ProtocolLooper* looper)
|
|||
}
|
||||
|
||||
|
||||
ConversationItem*
|
||||
Conversation::GetConversationItem()
|
||||
{
|
||||
return fConversationItem;
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
Conversation::GetName() const
|
||||
{
|
||||
|
@ -172,6 +158,13 @@ Conversation::AddUser(User* user)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
Conversation::ShowView(bool typing, bool userAction)
|
||||
{
|
||||
((TheApp*)be_app)->GetMainWindow()->SetConversation(this);
|
||||
}
|
||||
|
||||
|
||||
ConversationView*
|
||||
Conversation::GetView()
|
||||
{
|
||||
|
@ -193,6 +186,13 @@ Conversation::GetView()
|
|||
}
|
||||
|
||||
|
||||
ConversationItem*
|
||||
Conversation::GetListItem()
|
||||
{
|
||||
return fConversationItem;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Conversation::_LogChatMessage(BMessage* msg)
|
||||
{
|
||||
|
|
|
@ -39,17 +39,16 @@ public:
|
|||
void ObserveInteger(int32 what, int32 value);
|
||||
void ObservePointer(int32 what, void* ptr);
|
||||
|
||||
ConversationView* GetView();
|
||||
|
||||
void ShowView(bool typing, bool userAction);
|
||||
|
||||
BMessenger Messenger() const;
|
||||
void SetMessenger(BMessenger messenger);
|
||||
|
||||
ProtocolLooper* GetProtocolLooper() const;
|
||||
void SetProtocolLooper(ProtocolLooper* looper);
|
||||
|
||||
ConversationItem* GetConversationItem();
|
||||
void ShowView(bool typing, bool userAction);
|
||||
|
||||
ConversationView* GetView();
|
||||
ConversationItem* GetListItem();
|
||||
|
||||
BString GetName() const;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ MainWindow::MainWindow()
|
|||
:
|
||||
BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
|
||||
fWorkspaceChanged(false),
|
||||
fConversation(NULL),
|
||||
fRosterWindow(NULL)
|
||||
{
|
||||
_InitInterface();
|
||||
|
@ -110,6 +111,29 @@ MainWindow::MessageReceived(BMessage* message)
|
|||
break;
|
||||
}
|
||||
|
||||
case CAYA_MOVE_UP:
|
||||
{
|
||||
if (fConversation == NULL)
|
||||
return;
|
||||
|
||||
int32 index = fListView->IndexOf(fConversation->GetListItem());
|
||||
if (index > 0)
|
||||
fListView->Select(index - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case CAYA_MOVE_DOWN:
|
||||
{
|
||||
if (fConversation == NULL)
|
||||
return;
|
||||
|
||||
int32 index = fListView->IndexOf(fConversation->GetListItem());
|
||||
int32 count = fListView->CountItems();
|
||||
if (index < (count - 1))
|
||||
fListView->Select(index + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case CAYA_REPLICANT_STATUS_SET:
|
||||
{
|
||||
int32 status;
|
||||
|
@ -256,8 +280,10 @@ MainWindow::SetConversation(Conversation* chat)
|
|||
fRightView->RemoveChild(fRightView->FindView("chatView"));
|
||||
fRightView->RemoveChild(fRightView->FindView("fSendScroll"));
|
||||
|
||||
if (chat != NULL)
|
||||
if (chat != NULL) {
|
||||
fChatView = chat->GetView();
|
||||
fConversation = chat;
|
||||
}
|
||||
|
||||
fRightView->AddChild(fChatView, 9);
|
||||
fRightView->AddChild(fSendScroll, 1);
|
||||
|
@ -323,8 +349,15 @@ MainWindow::_CreateMenuBar()
|
|||
new BMessage(CAYA_NEW_CHAT), 'M', B_COMMAND_KEY));
|
||||
chatMenu->SetTargetForItems(this);
|
||||
|
||||
BMenu* windowMenu = new BMenu("Window");
|
||||
windowMenu->AddItem(new BMenuItem("Up",
|
||||
new BMessage(CAYA_MOVE_UP), B_UP_ARROW, B_COMMAND_KEY));
|
||||
windowMenu->AddItem(new BMenuItem("Down",
|
||||
new BMessage(CAYA_MOVE_DOWN), B_DOWN_ARROW, B_COMMAND_KEY));
|
||||
|
||||
menuBar->AddItem(programMenu);
|
||||
menuBar->AddItem(chatMenu);
|
||||
menuBar->AddItem(windowMenu);
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
|
@ -338,13 +371,16 @@ MainWindow::_EnsureConversationItem(BMessage* msg)
|
|||
Conversation* chat = fServer->ConversationById(chat_id);
|
||||
|
||||
if (chat != NULL) {
|
||||
ConversationItem* item = chat->GetConversationItem();
|
||||
ConversationItem* item = chat->GetListItem();
|
||||
if (fListView->HasItem(item)) {
|
||||
_UpdateListItem(item);
|
||||
}
|
||||
else if (item != NULL) {
|
||||
fListView->AddItem(item);
|
||||
}
|
||||
|
||||
if (fListView->CountItems() == 1)
|
||||
fListView->Select(0);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ private:
|
|||
BScrollView* fSendScroll;
|
||||
BTextView* fSendView;
|
||||
ConversationView* fChatView;
|
||||
Conversation* fConversation;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -52,9 +52,6 @@ ConversationListView::MouseDown(BPoint where)
|
|||
uint32 buttons = 0;
|
||||
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
|
||||
|
||||
if (buttons & B_PRIMARY_MOUSE_BUTTON)
|
||||
MessageReceived(new BMessage(kOpenSelectedChat));
|
||||
|
||||
if (!(buttons & B_SECONDARY_MOUSE_BUTTON))
|
||||
return;
|
||||
|
||||
|
@ -65,6 +62,13 @@ ConversationListView::MouseDown(BPoint where)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
ConversationListView::SelectionChanged()
|
||||
{
|
||||
MessageReceived(new BMessage(kOpenSelectedChat));
|
||||
}
|
||||
|
||||
|
||||
BPopUpMenu*
|
||||
ConversationListView::_ConversationPopUp()
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
ConversationListView(const char* name);
|
||||
|
||||
void MessageReceived(BMessage* msg);
|
||||
void SelectionChanged();
|
||||
void MouseDown(BPoint where);
|
||||
|
||||
private:
|
||||
|
|
Ŝarĝante…
Reference in New Issue