Split account preferences into dedicated window
Found in the new "Accounts" menubar option.
This commit is contained in:
parent
a9022755ca
commit
2e746a975a
|
@ -8,6 +8,9 @@
|
||||||
//! Show settings window
|
//! Show settings window
|
||||||
const uint32 APP_SHOW_SETTINGS = 'RPST';
|
const uint32 APP_SHOW_SETTINGS = 'RPST';
|
||||||
|
|
||||||
|
//! Show accounts window
|
||||||
|
const uint32 APP_SHOW_ACCOUNTS = 'RPac';
|
||||||
|
|
||||||
//! Chat messages
|
//! Chat messages
|
||||||
const uint32 APP_CHAT = 'CYch';
|
const uint32 APP_CHAT = 'CYch';
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ SRCS = \
|
||||||
application/preferences/AccountListItem.cpp \
|
application/preferences/AccountListItem.cpp \
|
||||||
application/preferences/AppPreferences.cpp \
|
application/preferences/AppPreferences.cpp \
|
||||||
application/preferences/PreferencesChatWindow.cpp \
|
application/preferences/PreferencesChatWindow.cpp \
|
||||||
application/preferences/PreferencesAccounts.cpp \
|
|
||||||
application/preferences/PreferencesBehavior.cpp \
|
application/preferences/PreferencesBehavior.cpp \
|
||||||
application/preferences/PreferencesReplicant.cpp \
|
application/preferences/PreferencesReplicant.cpp \
|
||||||
application/views/AccountsMenu.cpp \
|
application/views/AccountsMenu.cpp \
|
||||||
|
@ -76,6 +75,7 @@ SRCS = \
|
||||||
application/views/UserListView.cpp \
|
application/views/UserListView.cpp \
|
||||||
application/views/UserPopUp.cpp \
|
application/views/UserPopUp.cpp \
|
||||||
application/windows/AboutWindow.cpp \
|
application/windows/AboutWindow.cpp \
|
||||||
|
application/windows/AccountsWindow.cpp \
|
||||||
application/windows/ConversationInfoWindow.cpp \
|
application/windows/ConversationInfoWindow.cpp \
|
||||||
application/windows/MainWindow.cpp \
|
application/windows/MainWindow.cpp \
|
||||||
application/windows/PreferencesWindow.cpp \
|
application/windows/PreferencesWindow.cpp \
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
* Jaidyn Levesque, jadedctrl@teknik.io
|
* Jaidyn Levesque, jadedctrl@teknik.io
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "AccountsWindow.h"
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
|
@ -23,7 +25,6 @@
|
||||||
#include "AccountListItem.h"
|
#include "AccountListItem.h"
|
||||||
#include "ChatProtocol.h"
|
#include "ChatProtocol.h"
|
||||||
#include "ChatProtocolMessages.h"
|
#include "ChatProtocolMessages.h"
|
||||||
#include "PreferencesAccounts.h"
|
|
||||||
#include "ProtocolManager.h"
|
#include "ProtocolManager.h"
|
||||||
#include "ProtocolSettings.h"
|
#include "ProtocolSettings.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "PreferencesAccounts"
|
#define B_TRANSLATION_CONTEXT "AccountsWindow"
|
||||||
|
|
||||||
|
|
||||||
const uint32 kAddAccount = 'adac';
|
const uint32 kAddAccount = 'adac';
|
||||||
|
@ -52,12 +53,16 @@ compare_by_name(const void* _item1, const void* _item2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PreferencesAccounts::PreferencesAccounts()
|
AccountsWindow::AccountsWindow()
|
||||||
: BView("Accounts", B_WILL_DRAW)
|
:
|
||||||
|
BWindow(BRect(200, 200, 300, 400),
|
||||||
|
B_TRANSLATE("Accounts"), B_TITLED_WINDOW,
|
||||||
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
fListView = new BListView("accountsListView");
|
fListView = new BListView("accountsListView");
|
||||||
fListView->SetInvocationMessage(new BMessage(kEditAccount));
|
fListView->SetInvocationMessage(new BMessage(kEditAccount));
|
||||||
fListView->SetSelectionMessage(new BMessage(kSelect));
|
fListView->SetSelectionMessage(new BMessage(kSelect));
|
||||||
|
fListView->SetExplicitMinSize(BSize(B_SIZE_UNSET, BFont().Size() * 20));
|
||||||
|
|
||||||
BScrollView* scrollView = new BScrollView("scrollView", fListView,
|
BScrollView* scrollView = new BScrollView("scrollView", fListView,
|
||||||
B_WILL_DRAW, false, true);
|
B_WILL_DRAW, false, true);
|
||||||
|
@ -80,6 +85,7 @@ PreferencesAccounts::PreferencesAccounts()
|
||||||
addOn->ProtoFriendlySignature(), msg, addOn->ProtoIcon());
|
addOn->ProtoFriendlySignature(), msg, addOn->ProtoIcon());
|
||||||
fProtosMenu->AddItem(item);
|
fProtosMenu->AddItem(item);
|
||||||
}
|
}
|
||||||
|
fProtosMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
MenuButton* proto = new MenuButton("addButton", B_TRANSLATE("Add"), NULL);
|
MenuButton* proto = new MenuButton("addButton", B_TRANSLATE("Add"), NULL);
|
||||||
proto->SetMenu(fProtosMenu);
|
proto->SetMenu(fProtosMenu);
|
||||||
|
@ -94,9 +100,9 @@ PreferencesAccounts::PreferencesAccounts()
|
||||||
fToggleButton->SetEnabled(false);
|
fToggleButton->SetEnabled(false);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.Add(scrollView)
|
.Add(scrollView)
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.SetInsets(B_USE_HALF_ITEM_SPACING)
|
|
||||||
.Add(proto)
|
.Add(proto)
|
||||||
.Add(fDelButton)
|
.Add(fDelButton)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
|
@ -108,18 +114,7 @@ PreferencesAccounts::PreferencesAccounts()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreferencesAccounts::AttachedToWindow()
|
AccountsWindow::MessageReceived(BMessage* msg)
|
||||||
{
|
|
||||||
fListView->SetTarget(this);
|
|
||||||
fProtosMenu->SetTargetForItems(this);
|
|
||||||
fDelButton->SetTarget(this);
|
|
||||||
fEditButton->SetTarget(this);
|
|
||||||
fToggleButton->SetTarget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PreferencesAccounts::MessageReceived(BMessage* msg)
|
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case kSelect: {
|
case kSelect: {
|
||||||
|
@ -254,13 +249,13 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreferencesAccounts::_LoadListView(ProtocolSettings* settings)
|
AccountsWindow::_LoadListView(ProtocolSettings* settings)
|
||||||
{
|
{
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return;
|
return;
|
||||||
|
@ -278,7 +273,7 @@ PreferencesAccounts::_LoadListView(ProtocolSettings* settings)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreferencesAccounts::_DisableAccount(const char* account, int64 instance)
|
AccountsWindow::_DisableAccount(const char* account, int64 instance)
|
||||||
{
|
{
|
||||||
BMessage* remove = new BMessage(IM_MESSAGE);
|
BMessage* remove = new BMessage(IM_MESSAGE);
|
||||||
remove->AddInt32("im_what", IM_PROTOCOL_DISABLE);
|
remove->AddInt32("im_what", IM_PROTOCOL_DISABLE);
|
||||||
|
@ -291,7 +286,7 @@ PreferencesAccounts::_DisableAccount(const char* account, int64 instance)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreferencesAccounts::_EnableAccount(const char* account,
|
AccountsWindow::_EnableAccount(const char* account,
|
||||||
ProtocolSettings* settings)
|
ProtocolSettings* settings)
|
||||||
{
|
{
|
||||||
ProtocolManager::Get()->AddAccount(settings->AddOn(), account,
|
ProtocolManager::Get()->AddAccount(settings->AddOn(), account,
|
||||||
|
@ -300,7 +295,7 @@ PreferencesAccounts::_EnableAccount(const char* account,
|
||||||
|
|
||||||
|
|
||||||
int64
|
int64
|
||||||
PreferencesAccounts::_AccountInstance(const char* account)
|
AccountsWindow::_AccountInstance(const char* account)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
AccountInstances accs =
|
AccountInstances accs =
|
|
@ -1,11 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
|
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
|
||||||
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PREFERENCES_ACCOUNTS_H
|
#ifndef _ACCOUNTS_WINDOW_H
|
||||||
#define _PREFERENCES_ACCOUNTS_H
|
#define _ACCOUNTS_WINDOW_H
|
||||||
|
|
||||||
#include <View.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BListView;
|
class BListView;
|
||||||
|
@ -14,11 +15,10 @@ class BPopUpMenu;
|
||||||
class ProtocolSettings;
|
class ProtocolSettings;
|
||||||
|
|
||||||
|
|
||||||
class PreferencesAccounts : public BView {
|
class AccountsWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
PreferencesAccounts();
|
AccountsWindow();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void MessageReceived(BMessage* msg);
|
virtual void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -37,4 +37,4 @@ private:
|
||||||
int64 _AccountInstance(const char* account);
|
int64 _AccountInstance(const char* account);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PREFERENCES_ACCOUNTS_H
|
#endif // _ACCOUNTS_WINDOW_H
|
|
@ -18,6 +18,7 @@
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
#include "AccountManager.h"
|
#include "AccountManager.h"
|
||||||
|
#include "AccountsWindow.h"
|
||||||
#include "AppMessages.h"
|
#include "AppMessages.h"
|
||||||
#include "AppPreferences.h"
|
#include "AppPreferences.h"
|
||||||
#include "Cardie.h"
|
#include "Cardie.h"
|
||||||
|
@ -110,6 +111,12 @@ MainWindow::MessageReceived(BMessage* message)
|
||||||
win->Show();
|
win->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case APP_SHOW_ACCOUNTS:
|
||||||
|
{
|
||||||
|
AccountsWindow* win = new AccountsWindow();
|
||||||
|
win->Show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case APP_NEW_CHAT:
|
case APP_NEW_CHAT:
|
||||||
{
|
{
|
||||||
BMessage* newMsg = new BMessage(IM_MESSAGE);
|
BMessage* newMsg = new BMessage(IM_MESSAGE);
|
||||||
|
@ -449,6 +456,13 @@ MainWindow::_CreateMenuBar()
|
||||||
new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY));
|
new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY));
|
||||||
programMenu->SetTargetForItems(this);
|
programMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
|
// Accounts
|
||||||
|
BMenu* accountsMenu = new BMenu(B_TRANSLATE("Accounts"));
|
||||||
|
accountsMenu->AddItem(
|
||||||
|
new BMenuItem(B_TRANSLATE("Manage accounts" B_UTF8_ELLIPSIS),
|
||||||
|
new BMessage(APP_SHOW_ACCOUNTS), '.', B_COMMAND_KEY));
|
||||||
|
accountsMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
// Chat
|
// Chat
|
||||||
BMenu* chatMenu = new BMenu(B_TRANSLATE("Chat"));
|
BMenu* chatMenu = new BMenu(B_TRANSLATE("Chat"));
|
||||||
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("Join room" B_UTF8_ELLIPSIS),
|
chatMenu->AddItem(new BMenuItem(B_TRANSLATE("Join room" B_UTF8_ELLIPSIS),
|
||||||
|
@ -478,6 +492,7 @@ MainWindow::_CreateMenuBar()
|
||||||
windowMenu->SetTargetForItems(this);
|
windowMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
menuBar->AddItem(programMenu);
|
menuBar->AddItem(programMenu);
|
||||||
|
menuBar->AddItem(accountsMenu);
|
||||||
menuBar->AddItem(chatMenu);
|
menuBar->AddItem(chatMenu);
|
||||||
menuBar->AddItem(rosterMenu);
|
menuBar->AddItem(rosterMenu);
|
||||||
menuBar->AddItem(windowMenu);
|
menuBar->AddItem(windowMenu);
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
|
|
||||||
#include "PreferencesAccounts.h"
|
|
||||||
#include "PreferencesBehavior.h"
|
#include "PreferencesBehavior.h"
|
||||||
#include "PreferencesChatWindow.h"
|
#include "PreferencesChatWindow.h"
|
||||||
#include "PreferencesReplicant.h"
|
#include "PreferencesReplicant.h"
|
||||||
|
@ -33,7 +32,6 @@ PreferencesWindow::PreferencesWindow()
|
||||||
| B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE)
|
| B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE)
|
||||||
{
|
{
|
||||||
BTabView* tabView = new BTabView("tabView", B_WIDTH_AS_USUAL);
|
BTabView* tabView = new BTabView("tabView", B_WIDTH_AS_USUAL);
|
||||||
tabView->AddTab(new PreferencesAccounts());
|
|
||||||
tabView->AddTab(new PreferencesBehavior());
|
tabView->AddTab(new PreferencesBehavior());
|
||||||
tabView->AddTab(new PreferencesChatWindow());
|
tabView->AddTab(new PreferencesChatWindow());
|
||||||
tabView->AddTab(new PreferencesReplicant());
|
tabView->AddTab(new PreferencesReplicant());
|
||||||
|
|
Ŝarĝante…
Reference in New Issue