Clean this up...

master
Ansariel 2025-06-07 17:44:38 +02:00
parent 1076d16efc
commit 83bd88c366
2 changed files with 65 additions and 61 deletions

View File

@ -77,7 +77,11 @@ FSPrimfeedPhotoPanel::FSPrimfeedPhotoPanel() :
mStoresComboBox(nullptr),
mPostButton(nullptr),
mBtnPreview(nullptr),
mBigPreviewFloater(nullptr)
mBigPreviewFloater(nullptr),
mCancelButton(nullptr),
mCommercialCheckbox(nullptr),
mFilterComboBox(nullptr),
mPublicGalleryCheckbox(nullptr)
{
mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", [this](LLUICtrl*, const LLSD&) { onSend(); });
mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", [this](LLUICtrl*, const LLSD&) { onClickNewSnapshot(); });
@ -92,13 +96,13 @@ FSPrimfeedPhotoPanel::FSPrimfeedPhotoPanel() :
FSPrimfeedAuth::sPrimfeedAuthPump->listen("FSPrimfeedPhotoPanel",
[this](const LLSD& data)
{
if ( data["responseType"].asString() == "primfeed_user_info" )
{
this->loadPrimfeedInfo(data);
return true;
}
return false;
});
if (data["responseType"].asString() == "primfeed_user_info")
{
this->loadPrimfeedInfo(data);
return true;
}
return false;
});
}
FSPrimfeedPhotoPanel::~FSPrimfeedPhotoPanel()
@ -203,7 +207,7 @@ void FSPrimfeedPhotoPanel::draw()
mDescriptionTextBox->setEnabled(can_post);
mRatingComboBox->setEnabled(can_post);
// If the stores combo box is present, enable it only if we have stores to select from
mStoresComboBox->setEnabled(can_post && ((LLComboBox*)mStoresComboBox)->getItemCount() > 1);
mStoresComboBox->setEnabled(can_post && mStoresComboBox->getItemCount() > 1);
mResolutionComboBox->setEnabled(can_post);
mFilterComboBox->setEnabled(can_post);
mRefreshBtn->setEnabled(can_post);
@ -364,10 +368,10 @@ void FSPrimfeedPhotoPanel::sendPhoto()
std::string description = mDescriptionTextBox->getValue().asString();
// Get the content rating
int content_rating = mRatingComboBox->getValue().asInteger();
bool post_to_public_gallery = mPublicGalleryCheckbox->getValue().asBoolean();
bool commercial_content = mCommercialCheckbox->getValue().asBoolean();
std::string store_id = mStoresComboBox->getValue().asString();
int content_rating = mRatingComboBox->getValue().asInteger();
bool post_to_public_gallery = mPublicGalleryCheckbox->getValue().asBoolean();
bool commercial_content = mCommercialCheckbox->getValue().asBoolean();
std::string store_id = mStoresComboBox->getValue().asString();
// Get the image
LLSnapshotLivePreview* previewp = getPreviewView();
@ -546,29 +550,30 @@ void FSPrimfeedPhotoPanel::checkAspectRatio(S32 index)
}
}
void FSPrimfeedPhotoPanel::loadPrimfeedInfo(LLSD const& data)
void FSPrimfeedPhotoPanel::loadPrimfeedInfo(const LLSD& data)
{
if (!mStoresComboBox) return;
if (!mStoresComboBox)
return;
// Clear any existing entries
mStoresComboBox->clearRows();
mStoresComboBox->add(LLTrans::getString("Personal"), LLSD(""));
// Read the saved stores array
LLSD stores = data["stores"];
const LLSD& stores = data["stores"];
if (!stores.isArray() || stores.size() == 0)
{
// No stores - disable the combobox
mStoresComboBox->setEnabled(FALSE);
mStoresComboBox->setEnabled(false);
return;
}
mStoresComboBox->setEnabled(TRUE);
mStoresComboBox->setEnabled(true);
for (S32 i = 0; i < stores.size(); ++i)
{
LLSD const& store = stores[i];
std::string id = store["id"].asString();
std::string name = store["name"].asString();
const LLSD& store = stores[i];
std::string id = store["id"].asString();
std::string name = store["name"].asString();
mStoresComboBox->add(name, LLSD(id));
}
mStoresComboBox->setCurrentByIndex(0);
@ -584,7 +589,7 @@ void FSPrimfeedPhotoPanel::onOpen(const LLSD& key)
// Reauthorise if necessary.
FSPrimfeedAuth::initiateAuthRequest();
LLSD dummy;
onPrimfeedConnectStateChange(dummy);
onPrimfeedConnectStateChange(dummy);
}
void FSPrimfeedPhotoPanel::uploadCallback(bool success, const LLSD& response)
@ -663,7 +668,6 @@ bool FSPrimfeedPhotoPanel::checkImageSize(LLSnapshotLivePreview* previewp, S32&
return (w != width || h != height);
}
///////////////////////////
// FSPrimfeedAccountPanel///
///////////////////////////
@ -682,24 +686,24 @@ FSPrimfeedAccountPanel::FSPrimfeedAccountPanel() :
FSPrimfeedAuth::sPrimfeedAuthPump->listen("FSPrimfeedAccountPanel",
[this](const LLSD& data)
{
if ( data.has("responseType"))
{
auto response_type = data["responseType"].asString();
if(response_type == "primfeed_auth_response")
{
bool success = data["success"].asBoolean();
primfeedAuthResponse(success, data);
return true;
}
if(response_type == "primfeed_auth_reset")
{
bool success = data["success"].asBoolean();
primfeedAuthResponse(success, data);
return true;
}
}
return false;
});
if (data.has("responseType"))
{
auto response_type = data["responseType"].asString();
if (response_type == "primfeed_auth_response")
{
bool success = data["success"].asBoolean();
primfeedAuthResponse(success, data);
return true;
}
if (response_type == "primfeed_auth_reset")
{
bool success = data["success"].asBoolean();
primfeedAuthResponse(success, data);
return true;
}
}
return false;
});
setVisibleCallback([this](LLUICtrl*, bool visible) { onVisibilityChange(visible); });
}
@ -720,8 +724,8 @@ bool FSPrimfeedAccountPanel::postBuild()
void FSPrimfeedAccountPanel::draw()
{
FSPrimfeedConnect::EConnectionState connection_state = FSPrimfeedConnect::instance().getConnectionState();
static FSPrimfeedConnect::EConnectionState last_state = FSPrimfeedConnect::PRIMFEED_DISCONNECTED;
FSPrimfeedConnect::EConnectionState connection_state = FSPrimfeedConnect::instance().getConnectionState();
static FSPrimfeedConnect::EConnectionState last_state = FSPrimfeedConnect::PRIMFEED_DISCONNECTED;
// Update the connection state if it has changed
if (connection_state != last_state)
@ -829,14 +833,14 @@ void FSPrimfeedAccountPanel::onConnect()
{
FSPrimfeedAuth::initiateAuthRequest();
LLSD dummy;
onPrimfeedConnectStateChange(dummy);
onPrimfeedConnectStateChange(dummy);
}
void FSPrimfeedAccountPanel::onDisconnect()
{
FSPrimfeedAuth::resetAuthStatus();
LLSD dummy;
onPrimfeedConnectStateChange(dummy);
onPrimfeedConnectStateChange(dummy);
}
FSPrimfeedAccountPanel::~FSPrimfeedAccountPanel()

View File

@ -53,7 +53,7 @@ public:
bool postBuild() override;
S32 notify(const LLSD& info);
void draw() override;
void loadPrimfeedInfo(LLSD const& data);
void loadPrimfeedInfo(const LLSD& data);
LLSnapshotLivePreview* getPreviewView();
void onVisibilityChange(bool new_visibility);
@ -82,23 +82,23 @@ private:
LLHandle<LLView> mPreviewHandle;
LLUICtrl * mResolutionComboBox;
LLUICtrl * mFilterComboBox;
LLUICtrl * mRefreshBtn;
LLUICtrl * mWorkingLabel;
LLUICtrl * mThumbnailPlaceholder;
LLUICtrl * mDescriptionTextBox;
LLUICtrl * mLocationCheckbox;
LLUICtrl* mResolutionComboBox;
LLUICtrl* mFilterComboBox;
LLUICtrl* mRefreshBtn;
LLUICtrl* mWorkingLabel;
LLUICtrl* mThumbnailPlaceholder;
LLUICtrl* mDescriptionTextBox;
LLUICtrl* mLocationCheckbox;
LLUICtrl * mCommercialCheckbox;
LLUICtrl * mPublicGalleryCheckbox;
LLUICtrl * mRatingComboBox;
LLUICtrl * mPostButton;
LLUICtrl * mCancelButton;
LLButton * mBtnPreview;
LLComboBox * mStoresComboBox;
LLUICtrl* mCommercialCheckbox;
LLUICtrl* mPublicGalleryCheckbox;
LLUICtrl* mRatingComboBox;
LLUICtrl* mPostButton;
LLUICtrl* mCancelButton;
LLButton* mBtnPreview;
LLComboBox* mStoresComboBox;
LLFloaterBigPreview * mBigPreviewFloater;
LLFloaterBigPreview* mBigPreviewFloater;
};
class FSPrimfeedAccountPanel : public LLPanel