Added code that allow the deskbar replicant to be disabled/enabled from the preferences
This commit is contained in:
parent
cf7646fb00
commit
8d04f539c2
|
@ -93,13 +93,13 @@ AccountManager::SetStatus(CayaStatus status, const char* str)
|
|||
// Notify status change
|
||||
fStatus = status;
|
||||
NotifyInteger(INT_ACCOUNT_STATUS, (int32)fStatus);
|
||||
_ReplicantStatusNotify((CayaStatus)status);
|
||||
ReplicantStatusNotify((CayaStatus)status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountManager::_ReplicantStatusNotify(CayaStatus status)
|
||||
AccountManager::ReplicantStatusNotify(CayaStatus status, bool wait)
|
||||
{
|
||||
if(fReplicantMessenger != NULL && fReplicantMessenger->IsValid()) {
|
||||
printf("notification sent\n");
|
||||
|
|
|
@ -22,12 +22,12 @@ public:
|
|||
const char* str = NULL);
|
||||
|
||||
void SetReplicantMessenger(BMessenger* messenger);
|
||||
void ReplicantStatusNotify(CayaStatus status,
|
||||
bool wait = false);
|
||||
private:
|
||||
AccountManager();
|
||||
~AccountManager();
|
||||
|
||||
void _ReplicantStatusNotify(CayaStatus status);
|
||||
|
||||
CayaStatus fStatus;
|
||||
BMessenger* fReplicantMessenger;
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <Alert.h>
|
||||
#include <Button.h>
|
||||
#include <CardLayout.h>
|
||||
#include <Deskbar.h>
|
||||
#include <ListView.h>
|
||||
#include <Box.h>
|
||||
#include <CheckBox.h>
|
||||
|
@ -109,7 +108,7 @@ MainWindow::MainWindow()
|
|||
CenterOnScreen();
|
||||
|
||||
//TODO check for errors here
|
||||
_InstallReplicant();
|
||||
ReplicantStatusView::InstallReplicant();
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +126,7 @@ MainWindow::QuitRequested()
|
|||
fListView->MakeEmpty();
|
||||
fServer->Quit();
|
||||
CayaPreferences::Get()->Save();
|
||||
_RemoveReplicant();
|
||||
ReplicantStatusView::RemoveReplicant();
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
@ -403,26 +402,3 @@ MainWindow::WorkspaceActivated(int32 workspace, bool active)
|
|||
else
|
||||
fWorkspaceChanged = true;
|
||||
}
|
||||
|
||||
|
||||
// The following methods install
|
||||
// and remove the Caya's replicant
|
||||
// from Deskbar.
|
||||
status_t
|
||||
MainWindow::_InstallReplicant()
|
||||
{
|
||||
BDeskbar deskbar;
|
||||
if (deskbar.HasItem("ReplicantStatusView")) {
|
||||
_RemoveReplicant();
|
||||
}
|
||||
ReplicantStatusView* view = new ReplicantStatusView();
|
||||
return deskbar.AddItem(view);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MainWindow::_RemoveReplicant()
|
||||
{
|
||||
BDeskbar deskbar;
|
||||
return deskbar.RemoveItem("ReplicantStatusView");
|
||||
}
|
||||
|
|
|
@ -45,9 +45,6 @@ public:
|
|||
void RemoveItem(RosterItem*);
|
||||
|
||||
private:
|
||||
status_t _InstallReplicant();
|
||||
status_t _RemoveReplicant();
|
||||
|
||||
StatusView* fStatusView;
|
||||
RosterListView* fListView;
|
||||
Server* fServer;
|
||||
|
|
|
@ -166,6 +166,7 @@ Server::Filter(BMessage* message, BHandler **target)
|
|||
}
|
||||
AccountManager* accountManager = AccountManager::Get();
|
||||
accountManager->SetReplicantMessenger(messenger);
|
||||
accountManager->ReplicantStatusNotify(accountManager->Status());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,16 @@ typedef struct _CayaPreferencesData
|
|||
bool MoveToCurrentWorkspace;
|
||||
bool ActivateWindow;
|
||||
bool IgnoreEmoticons;
|
||||
bool HideCayaDeskbar;
|
||||
bool DisableReplicant;
|
||||
|
||||
_CayaPreferencesData()
|
||||
:
|
||||
MoveToCurrentWorkspace(true),
|
||||
ActivateWindow(true),
|
||||
IgnoreEmoticons(false)
|
||||
IgnoreEmoticons(false),
|
||||
HideCayaDeskbar(false),
|
||||
DisableReplicant(false)
|
||||
{
|
||||
}
|
||||
} CayaPreferencesData;
|
||||
|
|
|
@ -7,24 +7,27 @@
|
|||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <ControlLook.h>
|
||||
#include <Deskbar.h>
|
||||
#include <GroupLayout.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <ScrollView.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include "AccountManager.h"
|
||||
#include "CayaProtocol.h"
|
||||
#include "PreferencesBehavior.h"
|
||||
#include "CayaPreferences.h"
|
||||
#include "ProtocolManager.h"
|
||||
#include "ProtocolSettings.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ReplicantStatusView.h"
|
||||
#include "TheApp.h"
|
||||
|
||||
const uint32 kToCurrentWorkspace = 'CBcw';
|
||||
const uint32 kActivateChatWindow = 'CBac';
|
||||
const uint32 kDisableReplicant = 'DSrp';
|
||||
const uint32 kPermanentReplicant ='PRpt';
|
||||
const uint32 kHideCayaTracker = 'HCtk';
|
||||
const uint32 kHideCayaDeskbar = 'HCtk';
|
||||
|
||||
|
||||
|
||||
|
@ -51,23 +54,25 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
fMarkUnreadWindow = new BCheckBox("MarkUnreadWindow",
|
||||
"Mark unread window chat", NULL);
|
||||
fMarkUnreadWindow->SetEnabled(false);
|
||||
|
||||
fMarkUnreadReplicant = new BCheckBox("MarkUnreadReplicant",
|
||||
"Mark unread the Deskbar Replicant", NULL);
|
||||
fMarkUnreadReplicant->SetEnabled(false);
|
||||
// not implemented
|
||||
|
||||
fReplicantString = new BStringView("ReplicantString", "Replicant");
|
||||
fReplicantString = new BStringView("ReplicantString", "Deskbar Replicant");
|
||||
fReplicantString->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||
fReplicantString->SetFont(be_bold_font);
|
||||
|
||||
fDisableReplicant = new BCheckBox("DisableReplicant",
|
||||
"Disable Deskbar replicant", NULL);
|
||||
fDisableReplicant->SetEnabled(true);
|
||||
"Disable Deskbar replicant", new BMessage(kDisableReplicant));
|
||||
|
||||
fPermanentReplicant = new BCheckBox("PermanentReplicant",
|
||||
"Permanent Deskbar Replicant", NULL);
|
||||
fPermanentReplicant->SetEnabled(false);
|
||||
|
||||
fHideCayaDeskbar = new BCheckBox("HideCayaDeskbar",
|
||||
"Hide Caya field in Deskbar", NULL);
|
||||
fHideCayaDeskbar->SetEnabled(true);
|
||||
"Hide Caya field in Deskbar", new BMessage(kHideCayaDeskbar));
|
||||
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
|
@ -78,6 +83,7 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
.Add(fToCurrentWorkspace)
|
||||
.Add(fActivateChatWindow)
|
||||
.Add(fMarkUnreadWindow)
|
||||
.Add(fMarkUnreadReplicant)
|
||||
.Add(fPlaySoundOnMessageReceived)
|
||||
.SetInsets(spacing * 2, spacing, spacing, spacing)
|
||||
.End()
|
||||
|
@ -100,11 +106,17 @@ PreferencesBehavior::AttachedToWindow()
|
|||
{
|
||||
fToCurrentWorkspace->SetTarget(this);
|
||||
fActivateChatWindow->SetTarget(this);
|
||||
fHideCayaDeskbar->SetTarget(this);
|
||||
fDisableReplicant->SetTarget(this);
|
||||
|
||||
fToCurrentWorkspace->SetValue(
|
||||
CayaPreferences::Item()->MoveToCurrentWorkspace);
|
||||
fActivateChatWindow->SetValue(
|
||||
CayaPreferences::Item()->ActivateWindow);
|
||||
fHideCayaDeskbar->SetValue(
|
||||
CayaPreferences::Item()->HideCayaDeskbar);
|
||||
fDisableReplicant->SetValue(
|
||||
CayaPreferences::Item()->DisableReplicant);
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,6 +132,20 @@ PreferencesBehavior::MessageReceived(BMessage* message)
|
|||
CayaPreferences::Item()->ActivateWindow
|
||||
= fActivateChatWindow->Value();
|
||||
break;
|
||||
case kHideCayaDeskbar:
|
||||
CayaPreferences::Item()->HideCayaDeskbar
|
||||
= fHideCayaDeskbar->Value();
|
||||
break;
|
||||
case kDisableReplicant:
|
||||
CayaPreferences::Item()->DisableReplicant
|
||||
= fDisableReplicant->Value();
|
||||
|
||||
if (fDisableReplicant->Value() == true)
|
||||
ReplicantStatusView::RemoveReplicant();
|
||||
else
|
||||
ReplicantStatusView::InstallReplicant();
|
||||
|
||||
break;
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ private:
|
|||
BCheckBox* fActivateChatWindow;
|
||||
BCheckBox* fPlaySoundOnMessageReceived;
|
||||
BCheckBox* fMarkUnreadWindow;
|
||||
BCheckBox* fMarkUnreadReplicant;
|
||||
|
||||
BStringView* fReplicantString;
|
||||
BCheckBox* fDisableReplicant;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <Application.h>
|
||||
#include <AppFileInfo.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Deskbar.h>
|
||||
#include <IconUtils.h>
|
||||
#include <Message.h>
|
||||
#include <MenuField.h>
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "BitmapView.h"
|
||||
#include "Caya.h"
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaPreferences.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "CayaUtils.h"
|
||||
#include "NicknameTextControl.h"
|
||||
|
@ -353,3 +355,29 @@ instantiate_deskbar_item(void)
|
|||
{
|
||||
return new ReplicantStatusView();
|
||||
}
|
||||
|
||||
|
||||
// The following methods install
|
||||
// and remove the Caya's replicant
|
||||
// from Deskbar.
|
||||
status_t
|
||||
ReplicantStatusView::InstallReplicant()
|
||||
{
|
||||
if (CayaPreferences::Item()->DisableReplicant == true)
|
||||
return B_OK;
|
||||
|
||||
BDeskbar deskbar;
|
||||
if (deskbar.HasItem("ReplicantStatusView")) {
|
||||
ReplicantStatusView::RemoveReplicant();
|
||||
}
|
||||
ReplicantStatusView* view = new ReplicantStatusView();
|
||||
return deskbar.AddItem(view);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ReplicantStatusView::RemoveReplicant()
|
||||
{
|
||||
BDeskbar deskbar;
|
||||
return deskbar.RemoveItem("ReplicantStatusView");
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ public:
|
|||
static ReplicantStatusView* Instantiate(BMessage* archive);
|
||||
|
||||
void MouseDown(BPoint point);
|
||||
|
||||
|
||||
static status_t InstallReplicant();
|
||||
static status_t RemoveReplicant();
|
||||
private:
|
||||
void _Init();
|
||||
void _BuildMenu();
|
||||
|
|
Ŝarĝante…
Reference in New Issue