Another port from CoolViewer of the notecard floater, featuring a menu and search/replace.
This commit is contained in:
@@ -35,12 +35,14 @@
|
||||
#include "llpreviewnotecard.h"
|
||||
|
||||
#include "llinventory.h"
|
||||
#include "llmenugl.h"
|
||||
|
||||
#include "llagent.h"
|
||||
#include "llagentcamera.h"
|
||||
#include "llassetuploadresponders.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llbutton.h"
|
||||
#include "llfloatersearchreplace.h"
|
||||
#include "llinventorymodel.h"
|
||||
#include "lllineeditor.h"
|
||||
#include "llnotify.h"
|
||||
@@ -111,7 +113,6 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
|
||||
else
|
||||
{
|
||||
LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml");
|
||||
childSetAction("Save",onClickSave,this);
|
||||
// <edit>
|
||||
childSetAction("Get Items", onClickGetItems, this);
|
||||
// </edit>
|
||||
@@ -125,6 +126,7 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
|
||||
}
|
||||
}
|
||||
}
|
||||
childSetAction("Save",onClickSave,this);
|
||||
|
||||
// only assert shape if not hosted in a multifloater
|
||||
if (!getHost())
|
||||
@@ -153,6 +155,8 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
|
||||
editor->setHandleEditKeysDirectly(TRUE);
|
||||
}
|
||||
|
||||
initMenu();
|
||||
|
||||
gAgentCamera.changeCameraToDefault();
|
||||
}
|
||||
|
||||
@@ -222,6 +226,12 @@ BOOL LLPreviewNotecard::handleKeyHere(KEY key, MASK mask)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ('F' == key && (mask & MASK_CONTROL) && !(mask & (MASK_SHIFT | MASK_ALT)))
|
||||
{
|
||||
LLFloaterSearchReplace::show(getChild<LLViewerTextEditor>("Notecard Editor"));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return LLPreview::handleKeyHere(key, mask);
|
||||
}
|
||||
|
||||
@@ -775,4 +785,221 @@ LLTextEditor* LLPreviewNotecard::getEditor()
|
||||
return getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
}
|
||||
|
||||
void LLPreviewNotecard::initMenu()
|
||||
{
|
||||
LLMenuItemCallGL* menuItem = getChild<LLMenuItemCallGL>("Undo");
|
||||
menuItem->setMenuCallback(onUndoMenu, this);
|
||||
menuItem->setEnabledCallback(enableUndoMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Redo");
|
||||
menuItem->setMenuCallback(onRedoMenu, this);
|
||||
menuItem->setEnabledCallback(enableRedoMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Cut");
|
||||
menuItem->setMenuCallback(onCutMenu, this);
|
||||
menuItem->setEnabledCallback(enableCutMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Copy");
|
||||
menuItem->setMenuCallback(onCopyMenu, this);
|
||||
menuItem->setEnabledCallback(enableCopyMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Paste");
|
||||
menuItem->setMenuCallback(onPasteMenu, this);
|
||||
menuItem->setEnabledCallback(enablePasteMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Select All");
|
||||
menuItem->setMenuCallback(onSelectAllMenu, this);
|
||||
menuItem->setEnabledCallback(enableSelectAllMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Deselect");
|
||||
menuItem->setMenuCallback(onDeselectMenu, this);
|
||||
menuItem->setEnabledCallback(enableDeselectMenu);
|
||||
|
||||
menuItem = getChild<LLMenuItemCallGL>("Search / Replace...");
|
||||
menuItem->setMenuCallback(onSearchMenu, this);
|
||||
menuItem->setEnabledCallback(NULL);
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onSearchMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
LLFloaterSearchReplace::show(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onUndoMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->undo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onRedoMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->redo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onCutMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->cut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onCopyMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onPasteMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->paste();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onSelectAllMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->selectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLPreviewNotecard::onDeselectMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (self)
|
||||
{
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (editor)
|
||||
{
|
||||
editor->deselect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enableUndoMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canUndo();
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enableRedoMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canRedo();
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enableCutMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canCut();
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enableCopyMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canCopy();
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enablePasteMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canPaste();
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enableSelectAllMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canSelectAll();
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLPreviewNotecard::enableDeselectMenu(void* userdata)
|
||||
{
|
||||
LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
|
||||
if (!self) return FALSE;
|
||||
LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
|
||||
if (!editor) return FALSE;
|
||||
return editor->canDeselect();
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
Reference in New Issue
Block a user