UI: Cleanup Dialog to Manage Orphaned Data #106653
|
@ -12,6 +12,7 @@ set(INC
|
|||
../../makesrna
|
||||
../../sequencer
|
||||
../../windowmanager
|
||||
../../../../extern/fmtlib/include
|
||||
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
|
@ -137,6 +138,7 @@ set(LIB
|
|||
bf_editor_undo
|
||||
PRIVATE bf::intern::clog
|
||||
PRIVATE bf::intern::guardedalloc
|
||||
extern_fmtlib
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@
|
|||
#include "tree/tree_element_rna.hh"
|
||||
#include "tree/tree_iterator.hh"
|
||||
|
||||
#include "wm_window.hh"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
using namespace blender::ed::outliner;
|
||||
|
||||
namespace blender::ed::outliner {
|
||||
|
@ -2322,18 +2326,17 @@ static std::string orphan_desc(bContext *C, bool local, bool linked, bool recurs
|
|||
bool is_first = true;
|
||||
for (int i = 0; i < INDEX_ID_MAX - 2; i++) {
|
||||
if (num_tagged[i] != 0) {
|
||||
if (!is_first) {
|
||||
desc.append(", ");
|
||||
}
|
||||
else {
|
||||
is_first = false;
|
||||
}
|
||||
desc.append<>(std::to_string(num_tagged[i]) + " ");
|
||||
desc.append(num_tagged[i] > 1 ?
|
||||
TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) :
|
||||
TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i))));
|
||||
desc += fmt::format(
|
||||
"{}{} {}",
|
||||
(is_first) ? "" : ", ",
|
||||
Harley marked this conversation as resolved
Outdated
|
||||
num_tagged[i],
|
||||
(num_tagged[i] > 1) ?
|
||||
TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) :
|
||||
TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i))));
|
||||
is_first = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (desc.empty()) {
|
||||
desc = "Nothing";
|
||||
}
|
||||
|
@ -2460,16 +2463,23 @@ void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot)
|
|||
ot->exec = outliner_orphans_cleanup_exec;
|
||||
Harley marked this conversation as resolved
Bastien Montagne
commented
Missing Missing `OPTYPE_UNDO` I think? Otherwise, a comment explaining why it's not needed would be good to have.
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
Harley marked this conversation as resolved
Outdated
Bastien Montagne
commented
Would be better to adjust these default values to the available screen space? On some modern screens, 500x500 is a fairly small window... Would be better to adjust these default values to the available screen space? On some modern screens, 500x500 is a fairly small window...
|
||||
static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
int width = 800;
|
||||
int height = 500;
|
||||
if (wm_get_screensize(&width, &height)) {
|
||||
width /= 2;
|
||||
height /= 2;
|
||||
}
|
||||
|
||||
const rcti window_rect = {
|
||||
/*xmin*/ 0,
|
||||
/*xmax*/ 500,
|
||||
/*xmax*/ width,
|
||||
/*ymin*/ 0,
|
||||
/*ymax*/ 500,
|
||||
/*ymax*/ height,
|
||||
};
|
||||
|
||||
if (WM_window_open(C,
|
||||
|
@ -2485,8 +2495,9 @@ static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/)
|
|||
{
|
||||
SpaceOutliner *soutline = (SpaceOutliner *)CTX_wm_area(C)->spacedata.first;
|
||||
soutline->outlinevis = SO_ID_ORPHANS;
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void OUTLINER_OT_orphans_manage(wmOperatorType *ot)
|
||||
|
|
Loading…
Reference in New Issue
No reason to use
append
on strings afaik, just use+=
operator?That kind of formatting could also benefit from using
fmt::format
from ourextern/fmtlib
library.