Fix Save Preview As... for textures, now save as any type we can encode to!
Removes the previous method and condenses the menu entries back into one. - Translations have been updated except for German, German will need to update the translation for "Save Preview As..." since the name hasn't changed. Adds FFSAVE_IMAGE to the filepicker enums Crossplatformity: - The Windows version works nicely - The Linux version may not work or even compile but it should.. - The Mac version hasn't been added, instead it will default to accept any(all filter), should the provided file extension be invalid a notification will display.
This commit is contained in:
@@ -218,7 +218,6 @@ public:
|
|||||||
virtual BOOL canSaveAs() const { return FALSE; }
|
virtual BOOL canSaveAs() const { return FALSE; }
|
||||||
|
|
||||||
virtual void saveAs() {}
|
virtual void saveAs() {}
|
||||||
virtual void saveAsType(BOOL type=false) {}
|
|
||||||
|
|
||||||
void setSnapTarget(LLHandle<LLFloater> handle) { mSnappedTo = handle; }
|
void setSnapTarget(LLHandle<LLFloater> handle) { mSnappedTo = handle; }
|
||||||
void clearSnapTarget() { mSnappedTo.markDead(); }
|
void clearSnapTarget() { mSnappedTo.markDead(); }
|
||||||
|
|||||||
@@ -40,8 +40,7 @@
|
|||||||
#include "llcombobox.h"
|
#include "llcombobox.h"
|
||||||
#include "statemachine/aifilepicker.h"
|
#include "statemachine/aifilepicker.h"
|
||||||
#include "llfloaterinventory.h"
|
#include "llfloaterinventory.h"
|
||||||
#include "llimagepng.h"
|
#include "llimage.h"
|
||||||
#include "llimagetga.h"
|
|
||||||
#include "llinventory.h"
|
#include "llinventory.h"
|
||||||
#include "llnotificationsutil.h"
|
#include "llnotificationsutil.h"
|
||||||
#include "llresmgr.h"
|
#include "llresmgr.h"
|
||||||
@@ -377,27 +376,16 @@ BOOL LLPreviewTexture::canSaveAs() const
|
|||||||
return mIsCopyable && !mLoadingFullImage && mImage.notNull() && !mImage->isMissingAsset();
|
return mIsCopyable && !mLoadingFullImage && mImage.notNull() && !mImage->isMissingAsset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sPng(false);
|
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
void LLPreviewTexture::saveAsType(BOOL png)
|
void LLPreviewTexture::saveAs()
|
||||||
{
|
{
|
||||||
if( mLoadingFullImage )
|
if( mLoadingFullImage )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const LLViewerInventoryItem* item = getItem() ;
|
const LLViewerInventoryItem* item = getItem() ;
|
||||||
AIFilePicker* filepicker = AIFilePicker::create();
|
AIFilePicker* filepicker = AIFilePicker::create();
|
||||||
sPng = png;
|
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".png" : LLStringUtil::null, FFSAVE_IMAGE, "", "image");
|
||||||
if(png)
|
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
|
||||||
{
|
|
||||||
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".png" : LLStringUtil::null, FFSAVE_PNG, "", "image");
|
|
||||||
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".tga" : LLStringUtil::null, FFSAVE_TGA, "", "image");
|
|
||||||
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLPreviewTexture::saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker)
|
void LLPreviewTexture::saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker)
|
||||||
@@ -446,16 +434,14 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success,
|
|||||||
|
|
||||||
if( self && final && success )
|
if( self && final && success )
|
||||||
{
|
{
|
||||||
//FIXME: There has to be a better way
|
LLPointer<LLImageFormatted> image = LLImageFormatted::createFromExtension(self->mSaveFileName);
|
||||||
LLPointer<LLImagePNG> image_png = new LLImagePNG;
|
if (!image || !image->encode(src, 0.0))
|
||||||
LLPointer<LLImageTGA> image_tga = new LLImageTGA;
|
|
||||||
if( sPng ? !image_png->encode( src, 0.0 ) : !image_tga->encode( src ) )
|
|
||||||
{
|
{
|
||||||
LLSD args;
|
LLSD args;
|
||||||
args["FILE"] = self->mSaveFileName;
|
args["FILE"] = self->mSaveFileName;
|
||||||
LLNotificationsUtil::add("CannotEncodeFile", args);
|
LLNotificationsUtil::add("CannotEncodeFile", args);
|
||||||
}
|
}
|
||||||
else if( sPng ? !image_png->save( self->mSaveFileName ) : !image_tga->save( self->mSaveFileName ) )
|
else if (!image->save(self->mSaveFileName))
|
||||||
{
|
{
|
||||||
LLSD args;
|
LLSD args;
|
||||||
args["FILE"] = self->mSaveFileName;
|
args["FILE"] = self->mSaveFileName;
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ public:
|
|||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
|
||||||
virtual BOOL canSaveAs() const;
|
virtual BOOL canSaveAs() const;
|
||||||
virtual void saveAs(){ saveAsType(false); }
|
virtual void saveAs();
|
||||||
void saveAsType(BOOL png);
|
|
||||||
void saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker);
|
void saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker);
|
||||||
virtual LLUUID getItemID();
|
virtual LLUUID getItemID();
|
||||||
virtual std::string getItemCreatorName();
|
virtual std::string getItemCreatorName();
|
||||||
|
|||||||
@@ -541,19 +541,6 @@ class LLFileSavePreview : public view_listener_t
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LLFileSavePreviewPNG : public view_listener_t
|
|
||||||
{
|
|
||||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
|
||||||
{
|
|
||||||
LLFloater* top = gFloaterView->getFrontmost();
|
|
||||||
if (top)
|
|
||||||
{
|
|
||||||
top->saveAsType(true);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class LLFileTakeSnapshot : public view_listener_t
|
class LLFileTakeSnapshot : public view_listener_t
|
||||||
{
|
{
|
||||||
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
|
||||||
@@ -1384,7 +1371,6 @@ void init_menu_file()
|
|||||||
(new LLFileLocalAssetBrowser())->registerListener(gMenuHolder, "File.LocalAssetBrowser");
|
(new LLFileLocalAssetBrowser())->registerListener(gMenuHolder, "File.LocalAssetBrowser");
|
||||||
// </edit>
|
// </edit>
|
||||||
(new LLFileSavePreview())->registerListener(gMenuHolder, "File.SavePreview");
|
(new LLFileSavePreview())->registerListener(gMenuHolder, "File.SavePreview");
|
||||||
(new LLFileSavePreviewPNG())->registerListener(gMenuHolder, "File.SavePreviewPNG");
|
|
||||||
(new LLFileTakeSnapshot())->registerListener(gMenuHolder, "File.TakeSnapshot");
|
(new LLFileTakeSnapshot())->registerListener(gMenuHolder, "File.TakeSnapshot");
|
||||||
(new LLFileTakeSnapshotToDisk())->registerListener(gMenuHolder, "File.TakeSnapshotToDisk");
|
(new LLFileTakeSnapshotToDisk())->registerListener(gMenuHolder, "File.TakeSnapshotToDisk");
|
||||||
(new LLFileQuit())->registerListener(gMenuHolder, "File.Quit");
|
(new LLFileQuit())->registerListener(gMenuHolder, "File.Quit");
|
||||||
|
|||||||
@@ -67,16 +67,11 @@
|
|||||||
</menu_item_call>
|
</menu_item_call>
|
||||||
<menu_item_separator bottom="-121" enabled="true" height="8" label="-----------" left="0"
|
<menu_item_separator bottom="-121" enabled="true" height="8" label="-----------" left="0"
|
||||||
mouse_opaque="true" name="separator2" width="243" />
|
mouse_opaque="true" name="separator2" width="243" />
|
||||||
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As (TGA)..." left="0"
|
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As..." left="0"
|
||||||
mouse_opaque="true" name="Save Preview As..." width="243">
|
mouse_opaque="true" name="Save Preview As..." width="243">
|
||||||
<on_click function="File.SavePreview" userdata="" />
|
<on_click function="File.SavePreview" userdata="" />
|
||||||
<on_enable function="File.EnableSaveAs" />
|
<on_enable function="File.EnableSaveAs" />
|
||||||
</menu_item_call>
|
</menu_item_call>
|
||||||
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As (PNG)..." left="0"
|
|
||||||
mouse_opaque="true" name="Save Preview AsPNG..." width="243">
|
|
||||||
<on_click function="File.SavePreviewPNG" userdata="" />
|
|
||||||
<on_enable function="File.EnableSaveAs" />
|
|
||||||
</menu_item_call>
|
|
||||||
<menu_item_separator bottom="-148" enabled="true" height="8" label="-----------" left="0"
|
<menu_item_separator bottom="-148" enabled="true" height="8" label="-----------" left="0"
|
||||||
mouse_opaque="true" name="separator3" width="243" />
|
mouse_opaque="true" name="separator3" width="243" />
|
||||||
<menu_item_call bottom="-167" enabled="true" height="19" label="Take Snapshot" left="0"
|
<menu_item_call bottom="-167" enabled="true" height="19" label="Take Snapshot" left="0"
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
<menu_item_call label="Minimizar todas las Ventanas" name="Minimize All Windows"/>
|
<menu_item_call label="Minimizar todas las Ventanas" name="Minimize All Windows"/>
|
||||||
<menu_item_call label="Cerrar Ventana" name="Close Window"/>
|
<menu_item_call label="Cerrar Ventana" name="Close Window"/>
|
||||||
<menu_item_call label="Cerrar todas las Ventanas" name="Close All Windows"/>
|
<menu_item_call label="Cerrar todas las Ventanas" name="Close All Windows"/>
|
||||||
<menu_item_call label="Guardar Vista Previa Como (TGA)..." name="Save Preview As..."/>
|
<menu_item_call label="Guardar Vista Previa Como..." name="Save Preview As..."/>
|
||||||
<menu_item_call label="Guardar Vista Previa Como (PNG)..." name="Save Preview AsPNG..."/>
|
|
||||||
<menu_item_call label="Hacer una Foto" name="Take Snapshot"/>
|
<menu_item_call label="Hacer una Foto" name="Take Snapshot"/>
|
||||||
<menu_item_call label="Guardar Foto en Disco" name="Snapshot to Disk"/>
|
<menu_item_call label="Guardar Foto en Disco" name="Snapshot to Disk"/>
|
||||||
<menu_item_call label="Salir" name="Quit"/>
|
<menu_item_call label="Salir" name="Quit"/>
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
<menu_item_separator/>
|
<menu_item_separator/>
|
||||||
<menu_item_call label="Définir les droits par défaut " name="perm prefs"/>
|
<menu_item_call label="Définir les droits par défaut " name="perm prefs"/>
|
||||||
<menu_item_separator/>
|
<menu_item_separator/>
|
||||||
<menu_item_call label="Enregistrer la texture sur le disque dur en TGA" name="Save Preview As..."/>
|
<menu_item_call label="Enregistrer la texture sur le disque" name="Save Preview As..."/>
|
||||||
<menu_item_call label="Enregistrer la texture sur le disque dur en PNG" name="Save Preview AsPNG..."/>
|
|
||||||
|
|
||||||
<menu_item_separator/>
|
<menu_item_separator/>
|
||||||
<menu_item_call label="Minimiser toutes les fenêtres" name="Minimize All Windows"/>
|
<menu_item_call label="Minimiser toutes les fenêtres" name="Minimize All Windows"/>
|
||||||
|
|||||||
@@ -329,6 +329,9 @@ void AIFilePicker::open(std::string const& filename, ESaveFilter filter, std::st
|
|||||||
case FFSAVE_PHYSICS:
|
case FFSAVE_PHYSICS:
|
||||||
mFilter = "physics";
|
mFilter = "physics";
|
||||||
break;
|
break;
|
||||||
|
case FFSAVE_IMAGE:
|
||||||
|
mFilter = "image";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ enum ESaveFilter
|
|||||||
FFSAVE_LANDMARK,
|
FFSAVE_LANDMARK,
|
||||||
FFSAVE_AO,
|
FFSAVE_AO,
|
||||||
FFSAVE_BLACKLIST,
|
FFSAVE_BLACKLIST,
|
||||||
FFSAVE_PHYSICS
|
FFSAVE_PHYSICS,
|
||||||
|
FFSAVE_IMAGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ static LLFilePicker::ESaveFilter str2savefilter(std::string const& filter)
|
|||||||
return LLFilePicker::FFSAVE_BLACKLIST;
|
return LLFilePicker::FFSAVE_BLACKLIST;
|
||||||
else if (filter == "physics")
|
else if (filter == "physics")
|
||||||
return LLFilePicker::FFSAVE_PHYSICS;
|
return LLFilePicker::FFSAVE_PHYSICS;
|
||||||
|
else if (filter == "image")
|
||||||
|
return LLFilePicker::FFSAVE_IMAGE;
|
||||||
else
|
else
|
||||||
return LLFilePicker::FFSAVE_ALL;
|
return LLFilePicker::FFSAVE_ALL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -692,6 +692,18 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
|||||||
L"Landmarks (*.phy)\0*.phy\0" \
|
L"Landmarks (*.phy)\0*.phy\0" \
|
||||||
L"\0";
|
L"\0";
|
||||||
break;
|
break;
|
||||||
|
case FFSAVE_IMAGE:
|
||||||
|
mOFN.lpstrDefExt = NULL;
|
||||||
|
mOFN.lpstrFilter =
|
||||||
|
L"Image (*.bmp *.dxt *.jpg *.jpeg *.j2c *.mip *.png *.tga)\0*.bmp;*.dxt;*.jpg;*.jpeg;*.j2c;*.mip;*.png;*.tga\0" \
|
||||||
|
L"PNG Image (*.png)\0*.png\0" \
|
||||||
|
L"Targa Image (*.tga)\0*.tga\0" \
|
||||||
|
L"Bitmap Image (*.bmp)\0*.bmp\0" \
|
||||||
|
L"JPEG Image (*.jpg *.jpeg)\0*.jpg;*.jpeg\0" \
|
||||||
|
L"Compressed Image (*.j2c)\0*.j2c\0" \
|
||||||
|
L"DXT Image (*.dxt *.mip)\0*.dxt;*.mip\0" \
|
||||||
|
L"\0";
|
||||||
|
break;
|
||||||
// </edit>
|
// </edit>
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1423,6 +1435,21 @@ static std::string add_imageload_filter_to_gtkchooser(GtkWindow *picker)
|
|||||||
return filtername;
|
return filtername;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string add_imagesave_filter_to_gtkchooser(GTKWindow *picker)
|
||||||
|
{
|
||||||
|
GtkFileFilter *gfilter = gtk_file_filter_new();
|
||||||
|
gtk_file_filter_add_mime_type(gfilter, "image/bmp");
|
||||||
|
gtk_file_filter_add_pattern(gfilter, "*.dxt");
|
||||||
|
gtk_file_filter_add_mime_type(gfilter, "image/jpeg");
|
||||||
|
gtk_file_filter_add_pattern(gfilter, "*.j2c");
|
||||||
|
gtk_file_filter_add_pattern(gfilter, "*.mip");
|
||||||
|
gtk_file_filter_add_mime_type(gfilter, "image/png");
|
||||||
|
gtk_file_filter_add_pattern(gfilter, "*.tga");
|
||||||
|
std::string filtername = LLTrans::getString("image_files") + "(*.bmp; *.dxt; *.jpg; *.jpeg; *.j2c; *.mip; *.png; *.tga)";
|
||||||
|
add_common_filters_to_gtkchooser(gfilter, picker, filtername);
|
||||||
|
return filtername;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string add_script_filter_to_gtkchooser(GtkWindow *picker)
|
static std::string add_script_filter_to_gtkchooser(GtkWindow *picker)
|
||||||
{
|
{
|
||||||
return add_simple_mime_filter_to_gtkchooser(picker, "text/plain",
|
return add_simple_mime_filter_to_gtkchooser(picker, "text/plain",
|
||||||
@@ -1497,6 +1524,10 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
|||||||
caption += add_script_filter_to_gtkchooser(picker);
|
caption += add_script_filter_to_gtkchooser(picker);
|
||||||
suggest_ext = ".lsl";
|
suggest_ext = ".lsl";
|
||||||
break;
|
break;
|
||||||
|
case FFSAVE_IMAGE:
|
||||||
|
caption += add_imagesave_filter_to_gtkchooser(picker);
|
||||||
|
suggest_ext = ".png";
|
||||||
|
break;
|
||||||
default:;
|
default:;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ public:
|
|||||||
FFSAVE_AO = 35,
|
FFSAVE_AO = 35,
|
||||||
FFSAVE_BLACKLIST = 36,
|
FFSAVE_BLACKLIST = 36,
|
||||||
FFSAVE_PHYSICS = 37,
|
FFSAVE_PHYSICS = 37,
|
||||||
|
FFSAVE_IMAGE = 38,
|
||||||
// </edit>
|
// </edit>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user