forked from amazingfate/loongoffice
add context menu for comments & some other changes
Besides adding a context menu for comments in the comments panel, this commit adds the ability to make comments editable only when needed (through the context menu) Change-Id: I208a6531ce56d7ee2d7ed50703178babda9c5a31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170996 Tested-by: Jenkins Reviewed-by: Sarper Akdemir <sarper.akdemir@allotropia.de>
This commit is contained in:
committed by
Sarper Akdemir
parent
1efe756d46
commit
1bc03ef24f
@ -288,6 +288,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
|
||||
sw/uiconfig/swriter/ui/commentspanel \
|
||||
sw/uiconfig/swriter/ui/commentsthread \
|
||||
sw/uiconfig/swriter/ui/commentwidget \
|
||||
sw/uiconfig/swriter/ui/commentcontextmenu \
|
||||
sw/uiconfig/swriter/ui/a11ycheckissuespanel \
|
||||
sw/uiconfig/swriter/ui/poseditbox \
|
||||
sw/uiconfig/swriter/ui/sidebarwrap \
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
#include <editeng/outliner.hxx>
|
||||
#include <editeng/editeng.hxx>
|
||||
#include <svtools/ctrlbox.hxx>
|
||||
#include <vcl/event.hxx>
|
||||
|
||||
#include <strings.hrc>
|
||||
#include <cmdid.h>
|
||||
@ -61,6 +62,7 @@ namespace sw::sidebar
|
||||
Comment::Comment(weld::Container* pParent, CommentsPanel& rCommentsPanel)
|
||||
: mxBuilder(Application::CreateBuilder(pParent, "modules/swriter/ui/commentwidget.ui"))
|
||||
, mxContainer(mxBuilder->weld_container("Comment"))
|
||||
, mxExpander(mxBuilder->weld_expander("expander"))
|
||||
, mxAuthor(mxBuilder->weld_label("authorlabel"))
|
||||
, mxDate(mxBuilder->weld_label("datelabel"))
|
||||
, mxTime(mxBuilder->weld_label("timelabel"))
|
||||
@ -72,9 +74,43 @@ Comment::Comment(weld::Container* pParent, CommentsPanel& rCommentsPanel)
|
||||
, maTime(tools::Time::EMPTY)
|
||||
, mbResolved(false)
|
||||
{
|
||||
mxTextView->set_editable(false);
|
||||
mxTextView->set_tooltip_text("View Mode");
|
||||
mxTextView->connect_focus_out(LINK(this, Comment, OnFocusOut));
|
||||
mxResolve->connect_toggled(LINK(this, Comment, ResolveClicked));
|
||||
mxReply->connect_clicked(LINK(this, Comment, ReplyClicked));
|
||||
mxExpander->connect_mouse_press(LINK(this, Comment, ContextMenuHdl));
|
||||
}
|
||||
|
||||
IMPL_LINK(Comment, ContextMenuHdl, const MouseEvent&, rMEvt, bool)
|
||||
{
|
||||
if (rMEvt.IsRight())
|
||||
{
|
||||
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(
|
||||
mxExpander.get(), u"modules/swriter/ui/commentcontextmenu.ui"_ustr));
|
||||
std::unique_ptr<weld::Menu> xPopMenu(xBuilder->weld_menu(u"contextmenu"_ustr));
|
||||
Point aPos = rMEvt.GetPosPixel();
|
||||
OUString sId
|
||||
= xPopMenu->popup_at_rect(mxExpander.get(), tools::Rectangle(aPos, Size(1, 1)));
|
||||
|
||||
if (sId == "edit")
|
||||
{
|
||||
this->makeEditable();
|
||||
getTextView()->set_tooltip_text("Edit Mode");
|
||||
}
|
||||
else if (sId == "reply")
|
||||
mrCommentsPanel.ReplyComment(this);
|
||||
else if (sId == "delete")
|
||||
mrCommentsPanel.DeleteComment(this);
|
||||
else if (sId == "toggle_resolved")
|
||||
mrCommentsPanel.ToggleResolved(this);
|
||||
else if (sId == "delete_thread")
|
||||
mrCommentsPanel.DeleteThread(this);
|
||||
else if (sId == "resolve_thread")
|
||||
mrCommentsPanel.ResolveThread(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
OUString CommentsPanel::getReferenceText(SwTextNode* pTextNode, sw::mark::AnnotationMark* pMark)
|
||||
@ -119,7 +155,11 @@ void Comment::InitControls(const SwPostItField* pPostItField)
|
||||
mxTextView->set_text(msText);
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(Comment, OnFocusOut, weld::Widget&, void) { mrCommentsPanel.EditComment(this); }
|
||||
IMPL_LINK_NOARG(Comment, OnFocusOut, weld::Widget&, void)
|
||||
{
|
||||
mrCommentsPanel.EditComment(this);
|
||||
getTextView()->set_tooltip_text("View Mode");
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(Comment, ResolveClicked, weld::Toggleable&, void)
|
||||
{
|
||||
@ -457,6 +497,7 @@ void CommentsPanel::addComment(const SwFormatField* pField)
|
||||
pThread->getCommentBoxWidget()->reorder_child(pComment->get_widget(),
|
||||
pThread->mnComments++);
|
||||
pComment->InitControls(pNote->GetPostItField());
|
||||
pComment->getTextView()->set_tooltip_text("Edit Mode");
|
||||
mpAuthorSet.insert(pComment->GetAuthor());
|
||||
mpCommentsMap[nNoteId] = std::move(pComment);
|
||||
}
|
||||
@ -471,6 +512,7 @@ void CommentsPanel::addComment(const SwFormatField* pField)
|
||||
mpThreadsMap[nRootId] = std::move(pThread);
|
||||
setReferenceText(nRootId);
|
||||
pComment->InitControls(pNote->GetPostItField());
|
||||
pComment->getTextView()->set_tooltip_text("Edit Mode");
|
||||
mpAuthorSet.insert(pComment->GetAuthor());
|
||||
mpCommentsMap[nNoteId] = std::move(pComment);
|
||||
}
|
||||
@ -559,12 +601,15 @@ void CommentsPanel::EditComment(Comment* pComment)
|
||||
{
|
||||
if (!pComment)
|
||||
return;
|
||||
if (!pComment->mxTextView->get_editable())
|
||||
return;
|
||||
const OUString sText = pComment->mxTextView->get_text();
|
||||
|
||||
sw::annotation::SwAnnotationWin* pWin = getAnnotationWin(pComment);
|
||||
Outliner* pOutliner = pWin->GetOutliner();
|
||||
pOutliner->Clear();
|
||||
pOutliner->SetText(sText, pOutliner->GetParagraph(0));
|
||||
pComment->mxTextView->set_editable(false);
|
||||
}
|
||||
|
||||
void CommentsPanel::ToggleResolved(Comment* pComment)
|
||||
@ -583,6 +628,30 @@ void CommentsPanel::ReplyComment(Comment* pComment)
|
||||
pWin->ExecuteCommand(FN_REPLY);
|
||||
}
|
||||
|
||||
void CommentsPanel::DeleteComment(Comment* pComment)
|
||||
{
|
||||
if (!pComment)
|
||||
return;
|
||||
sw::annotation::SwAnnotationWin* pWin = getAnnotationWin(pComment);
|
||||
pWin->ExecuteCommand(FN_DELETE_COMMENT);
|
||||
}
|
||||
|
||||
void CommentsPanel::DeleteThread(Comment* pComment)
|
||||
{
|
||||
if (!pComment)
|
||||
return;
|
||||
sw::annotation::SwAnnotationWin* pWin = getAnnotationWin(pComment);
|
||||
pWin->ExecuteCommand(FN_DELETE_COMMENT_THREAD);
|
||||
}
|
||||
|
||||
void CommentsPanel::ResolveThread(Comment* pComment)
|
||||
{
|
||||
if (!pComment)
|
||||
return;
|
||||
sw::annotation::SwAnnotationWin* pWin = getAnnotationWin(pComment);
|
||||
pWin->ExecuteCommand(FN_RESOLVE_NOTE_THREAD);
|
||||
}
|
||||
|
||||
void CommentsPanel::populateAuthorComboBox()
|
||||
{
|
||||
mxFilterAuthor->clear();
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vcl/event.hxx>
|
||||
#include <annotationmark.hxx>
|
||||
#include <svtools/ctrlbox.hxx>
|
||||
#include <rtl/ustring.hxx>
|
||||
@ -57,6 +58,7 @@ class Comment final
|
||||
private:
|
||||
std::unique_ptr<weld::Builder> mxBuilder;
|
||||
std::unique_ptr<weld::Container> mxContainer;
|
||||
std::unique_ptr<weld::Expander> mxExpander;
|
||||
std::unique_ptr<weld::Label> mxAuthor;
|
||||
std::unique_ptr<weld::Label> mxDate;
|
||||
std::unique_ptr<weld::Label> mxTime;
|
||||
@ -72,14 +74,18 @@ private:
|
||||
Date maDate;
|
||||
tools::Time maTime;
|
||||
|
||||
void makeEditable() { mxTextView->set_editable(true); }
|
||||
|
||||
public:
|
||||
Comment(weld::Container* pParent, CommentsPanel& rCommentsPanel);
|
||||
~Comment();
|
||||
weld::Widget* get_widget() const { return mxContainer.get(); }
|
||||
weld::TextView* getTextView() const { return mxTextView.get(); }
|
||||
|
||||
DECL_LINK(ReplyClicked, weld::Button&, void);
|
||||
DECL_LINK(ResolveClicked, weld::Toggleable&, void);
|
||||
DECL_LINK(OnFocusOut, weld::Widget&, void);
|
||||
DECL_LINK(ContextMenuHdl, const MouseEvent&, bool);
|
||||
|
||||
bool mbResolved;
|
||||
|
||||
@ -127,10 +133,11 @@ public:
|
||||
void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
|
||||
|
||||
void EditComment(Comment* pComment);
|
||||
|
||||
void ToggleResolved(Comment* pComment);
|
||||
|
||||
void ReplyComment(Comment* pComment);
|
||||
void DeleteComment(Comment* pComment);
|
||||
void DeleteThread(Comment* pComment);
|
||||
void ResolveThread(Comment* pComment);
|
||||
|
||||
DECL_LINK(FilterByAuthor, weld::ComboBox&, void);
|
||||
DECL_LINK(FilterByDate, SvtCalendarBox&, void);
|
||||
|
||||
63
sw/uiconfig/swriter/ui/commentcontextmenu.ui
Normal file
63
sw/uiconfig/swriter/ui/commentcontextmenu.ui
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface domain="sw">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkMenu" id="contextmenu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="edit">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="contextmenu|edit">Edit</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="reply">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="contextmenu|reply">Reply</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="delete">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="contextmenu|delete">Delete</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="toggle_resolved">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="contextmenu|toggle_resolved">Toggle Resolved</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="delete_thread">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="contextmenu|delete_thread">Delete Thread</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="resolve_thread">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="contextmenu|resolve_thread">Resolve Thread</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@ -6,6 +6,7 @@
|
||||
<object class="GtkGrid" id="Thread">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<child>
|
||||
<object class="GtkExpander">
|
||||
<property name="visible">True</property>
|
||||
|
||||
@ -4,10 +4,12 @@
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<!-- n-columns=1 n-rows=1 -->
|
||||
<object class="GtkGrid" id="Comment">
|
||||
<property name="height-request">10</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<child>
|
||||
<object class="GtkExpander">
|
||||
<object class="GtkExpander" id="expander">
|
||||
<property name="height-request">-1</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
|
||||
Reference in New Issue
Block a user