Compare commits
2 Commits
fd48860131
...
e24f5d53f7
Author | SHA1 | Date |
---|---|---|
Pascal Abresch | e24f5d53f7 | |
Pascal Abresch | c5d81e0923 |
|
@ -22,19 +22,19 @@
|
|||
#include "JabberSpeak.h"
|
||||
#include "Messages.h"
|
||||
|
||||
CustomStatusWindow *CustomStatusWindow::_instance = NULL;
|
||||
CustomStatusWindow *CustomStatusWindow::fInstance = NULL;
|
||||
|
||||
CustomStatusWindow *CustomStatusWindow::Instance() {
|
||||
if (_instance == NULL) {
|
||||
if (fInstance == NULL) {
|
||||
float main_window_width = 410;
|
||||
float main_window_height = 100;
|
||||
|
||||
BRect frame(GenericFunctions::CenteredFrame(main_window_width, main_window_height));
|
||||
|
||||
_instance = new CustomStatusWindow(frame);
|
||||
fInstance = new CustomStatusWindow(frame);
|
||||
}
|
||||
|
||||
return _instance;
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,51 +46,51 @@ CustomStatusWindow::CustomStatusWindow(BRect frame)
|
|||
B_NOT_RESIZABLE)
|
||||
{
|
||||
|
||||
_chat = new BRadioButton("status", "Chat", NULL);
|
||||
fChatRadio = new BRadioButton("status", "Chat", NULL);
|
||||
|
||||
_away = new BRadioButton("status", "Away", NULL);
|
||||
fAwayRadio = new BRadioButton("status", "Away", NULL);
|
||||
|
||||
_xa = new BRadioButton("status", "Extended Away", NULL);
|
||||
fExtendedAwayRadio = new BRadioButton("status", "Extended Away", NULL);
|
||||
|
||||
_dnd = new BRadioButton("status", "Do Not Disturb", NULL);
|
||||
fDoNotDisturbRadio = new BRadioButton("status", "Do Not Disturb", NULL);
|
||||
|
||||
|
||||
BStringView *query = new BStringView(NULL, "Please provide your detailed status:");
|
||||
BStringView *queryString = new BStringView(NULL, "Please provide your detailed status:");
|
||||
|
||||
// handle
|
||||
_handle = new BTextControl(NULL, NULL, "", NULL);
|
||||
_handle->SetDivider(0);
|
||||
fStatus = new BTextControl(NULL, NULL, "", NULL);
|
||||
fStatus->SetDivider(0);
|
||||
|
||||
if (BlabberSettings::Instance()->Data("last-custom-more-exact-status")) {
|
||||
_handle->SetText(BlabberSettings::Instance()->Data("last-custom-more-exact-status"));
|
||||
fStatus->SetText(BlabberSettings::Instance()->Data("last-custom-more-exact-status"));
|
||||
} else {
|
||||
_handle->SetText("I'm at my computer.");
|
||||
fStatus->SetText("I'm at my computer.");
|
||||
}
|
||||
|
||||
BButton *cancel = new BButton("cancel", "Nevermind", new BMessage(JAB_CANCEL));
|
||||
cancel->SetTarget(this);
|
||||
BButton *cancelButton = new BButton("cancel", "Nevermind", new BMessage(JAB_CANCEL));
|
||||
cancelButton->SetTarget(this);
|
||||
|
||||
BButton *ok = new BButton("ok", "OK", new BMessage(JAB_OK));
|
||||
BButton *okButton = new BButton("ok", "OK", new BMessage(JAB_OK));
|
||||
|
||||
ok->MakeDefault(true);
|
||||
ok->SetTarget(this);
|
||||
okButton->MakeDefault(true);
|
||||
okButton->SetTarget(this);
|
||||
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.SetInsets(B_USE_WINDOW_SPACING)
|
||||
.AddGroup(B_VERTICAL, B_USE_HALF_ITEM_SPACING, 0)
|
||||
.Add(_chat)
|
||||
.Add(_away)
|
||||
.Add(_xa)
|
||||
.Add(_dnd)
|
||||
.Add(fChatRadio)
|
||||
.Add(fAwayRadio)
|
||||
.Add(fExtendedAwayRadio)
|
||||
.Add(fDoNotDisturbRadio)
|
||||
.End()
|
||||
.AddGroup(B_VERTICAL, B_USE_ITEM_SPACING, 2)
|
||||
.Add(query)
|
||||
.Add(_handle)
|
||||
.Add(queryString)
|
||||
.Add(fStatus)
|
||||
.AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING, 0)
|
||||
.AddGlue()
|
||||
.Add(cancel)
|
||||
.Add(ok)
|
||||
.Add(cancelButton)
|
||||
.Add(okButton)
|
||||
.End()
|
||||
.End()
|
||||
.End();
|
||||
|
@ -104,50 +104,50 @@ CustomStatusWindow::CustomStatusWindow(BRect frame)
|
|||
|
||||
// map to radio buttons
|
||||
if (exact_status == "away") {
|
||||
_away->SetValue(1);
|
||||
fAwayRadio->SetValue(1);
|
||||
} else if (exact_status == "xa") {
|
||||
_xa->SetValue(1);
|
||||
fExtendedAwayRadio->SetValue(1);
|
||||
} else if (exact_status == "dnd") {
|
||||
_dnd->SetValue(1);
|
||||
fDoNotDisturbRadio->SetValue(1);
|
||||
} else {
|
||||
_chat->SetValue(1);
|
||||
fChatRadio->SetValue(1);
|
||||
}
|
||||
} else {
|
||||
_chat->SetValue(1);
|
||||
fChatRadio->SetValue(1);
|
||||
}
|
||||
|
||||
// focus
|
||||
_handle->MakeFocus(true);
|
||||
fStatus->MakeFocus(true);
|
||||
}
|
||||
|
||||
CustomStatusWindow::~CustomStatusWindow() {
|
||||
_instance = NULL;
|
||||
fInstance = NULL;
|
||||
}
|
||||
|
||||
void CustomStatusWindow::MessageReceived(BMessage *msg) {
|
||||
switch (msg->what) {
|
||||
//// JAB_OK
|
||||
case JAB_OK: {
|
||||
if (_chat->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::Chat, _handle->Text());
|
||||
if (fChatRadio->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::Chat, fStatus->Text());
|
||||
BlabberSettings::Instance()->SetData("last-custom-exact-status", "chat");
|
||||
} else if (_away->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::Away, _handle->Text());
|
||||
} else if (fAwayRadio->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::Away, fStatus->Text());
|
||||
BlabberSettings::Instance()->SetData("last-custom-exact-status", "away");
|
||||
} else if (_xa->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::XA, _handle->Text());
|
||||
} else if (fExtendedAwayRadio->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::XA, fStatus->Text());
|
||||
BlabberSettings::Instance()->SetData("last-custom-exact-status", "xa");
|
||||
} else if (_dnd->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::DND, _handle->Text());
|
||||
} else if (fDoNotDisturbRadio->Value()) {
|
||||
JabberSpeak::Instance()->SendPresence(gloox::Presence::DND, fStatus->Text());
|
||||
BlabberSettings::Instance()->SetData("last-custom-exact-status", "dnd");
|
||||
}
|
||||
|
||||
BlabberSettings::Instance()->SetTag("last-used-custom-status", true);
|
||||
BlabberSettings::Instance()->SetData("last-custom-more-exact-status", _handle->Text());
|
||||
BlabberSettings::Instance()->SetData("last-custom-more-exact-status", fStatus->Text());
|
||||
BlabberSettings::Instance()->WriteToFile();
|
||||
|
||||
// update menu
|
||||
BlabberMainWindow::Instance()->SetCustomStatus(_handle->Text());
|
||||
BlabberMainWindow::Instance()->SetCustomStatus(fStatus->Text());
|
||||
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
|
||||
|
|
|
@ -33,17 +33,15 @@ public:
|
|||
void MessageReceived(BMessage *msg);
|
||||
|
||||
private:
|
||||
static CustomStatusWindow *_instance;
|
||||
static CustomStatusWindow *fInstance;
|
||||
|
||||
private:
|
||||
BBox *_surrounding;
|
||||
BTextControl *_handle;
|
||||
BView *_full_view;
|
||||
BTextControl *fStatus;
|
||||
|
||||
BRadioButton *_chat;
|
||||
BRadioButton *_away;
|
||||
BRadioButton *_xa;
|
||||
BRadioButton *_dnd;
|
||||
BRadioButton *fChatRadio;
|
||||
BRadioButton *fAwayRadio;
|
||||
BRadioButton *fExtendedAwayRadio;
|
||||
BRadioButton *fDoNotDisturbRadio;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
class WindowPreferences : public BArchivable
|
||||
{
|
||||
public:
|
||||
WindowPreferences(BString path);
|
||||
~WindowPreferences()
|
||||
status_t Save(BString path);
|
||||
|
||||
BPoint fLastWindowPosition;
|
||||
BRect fLastWindowRect;
|
||||
// What does this do?
|
||||
//bool fEnableDoubleClick;
|
||||
bool fEnableTimestamp;
|
||||
}
|
||||
|
||||
|
||||
WindowPreferences::WindowPreferences(BString path) {
|
||||
BPath* settings;
|
||||
status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &settings)
|
||||
if (error == B_OK)
|
||||
error = settings->Append(path);
|
||||
|
||||
if (error != B_OK)
|
||||
debugger("Incorrect settings file passed?");
|
||||
|
||||
BFile file = new BFile(settings, B_READ_ONLY);
|
||||
BMessage preferences;
|
||||
error = preferences.Unflatten(file);
|
||||
WindowPreferences instance = Instantiate(preferences);
|
||||
|
||||
if (instance == NULL) {
|
||||
//Make some defaults instead
|
||||
fLastWindowPosition = BPoint(0,0);
|
||||
fLastWindowRect = BRect(640, 480);
|
||||
fEnableTimeSteamp = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
WindowPreferences::WriteMessage(BString path) {
|
||||
BPath* settings;
|
||||
status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &settings)
|
||||
if (error == B_OK)
|
||||
error = settings->Append(path);
|
||||
|
||||
if (error != B_OK)
|
||||
debugger("Incorrect settings file passed?");
|
||||
|
||||
BMessage archive = new BMessage();
|
||||
WindowPreferences::Archive(archive)
|
||||
|
||||
BFile file = new BFile(settings, B_CREATE_FILE & B_ERASE_FILE & B_WRITE_ONLY)
|
||||
// write message to disk
|
||||
archive.Flatten(file);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
WindowPreferences::Archive(BMessage* data, bool deep) {
|
||||
data.AddPoint("LastWindowPosition", fLastWindowPosition);
|
||||
data.AddRect("LastWindowRect", fLastWindowRect);
|
||||
// What does this do?
|
||||
//settings.AddBool("EnableDoubleClick", fEnableDoubleClick);
|
||||
data.AddBool("EnableTimestamp", fEnableTimestamp);
|
||||
|
||||
return B_OK;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef PREFERENCES_H
|
||||
#define PREFERENCES_H
|
||||
|
||||
class WindowPreferences : public BArchivable
|
||||
{
|
||||
public:
|
||||
WindowPreferences(BString path);
|
||||
~WindowPreferences()
|
||||
status_t Save(BString path);
|
||||
|
||||
BPoint fLastWindowPosition;
|
||||
BRect fLastWindowRect;
|
||||
// What does this do?
|
||||
//bool fEnableDoubleClick;
|
||||
bool fEnableTimestamp;
|
||||
}
|
||||
|
||||
|
||||
class AccountPreferences : public BArchivable {
|
||||
public:
|
||||
WindowPreferences(BString path);
|
||||
~WindowPreferences()
|
||||
status_t Save(BString path);
|
||||
|
||||
BString fKeyStoreName;
|
||||
BString fStatus;
|
||||
BString fStatusMessage;
|
||||
BString fRealName;
|
||||
bool fAutoLogin;
|
||||
|
||||
// UI Defaults
|
||||
BString fLastGroupJoined;
|
||||
BString fLastTalkSendTo;
|
||||
BString fLastGroupUsername;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue