OpenToonz - An open-source full-featured 2D animation creation software
C
Customize Command Bar and XSheet Toolbar (#1448)
Jeremy Bullock0ff1b687b06d
diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xmlindex 56c209b52..637efbfe5 100644--- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml+++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml@@ -125,6 +125,7 @@<command>MI_Resequence</command><command>MI_CloneChild</command><command>MI_ExplodeChild</command>+ <command>MI_ToggleEditInPlace</command><separator/><command>MI_ApplyMatchLines</command><command>MI_MergeCmapped</command>diff --git a/stuff/profiles/layouts/settings/commandbar.xml b/stuff/profiles/layouts/settings/commandbar.xmlnew file mode 100644index 000000000..ef79a8fbc--- /dev/null+++ b/stuff/profiles/layouts/settings/commandbar.xml@@ -0,0 +1,19 @@+ <commandbar>++ <command>MI_NewVectorLevel</command>+ <command>MI_NewToonzRasterLevel</command>+ <command>MI_NewRasterLevel</command>+ <separator/>+ <command>MI_Reframe1</command>+ <command>MI_Reframe2</command>+ <command>MI_Reframe3</command>+ <separator/>+ <command>MI_Dup</command>+ <separator/>+ <command>MI_Collapse</command>+ <command>MI_OpenChild</command>+ <command>MI_CloseChild</command>+ <command>MI_ToggleEditInPlace</command>++ </commandbar>+diff --git a/stuff/profiles/layouts/settings/xsheettoolbar.xml b/stuff/profiles/layouts/settings/xsheettoolbar.xmlnew file mode 100644index 000000000..ef79a8fbc--- /dev/null+++ b/stuff/profiles/layouts/settings/xsheettoolbar.xml@@ -0,0 +1,19 @@+ <commandbar>++ <command>MI_NewVectorLevel</command>+ <command>MI_NewToonzRasterLevel</command>+ <command>MI_NewRasterLevel</command>+ <separator/>+ <command>MI_Reframe1</command>+ <command>MI_Reframe2</command>+ <command>MI_Reframe3</command>+ <separator/>+ <command>MI_Dup</command>+ <separator/>+ <command>MI_Collapse</command>+ <command>MI_OpenChild</command>+ <command>MI_CloseChild</command>+ <command>MI_ToggleEditInPlace</command>++ </commandbar>+diff --git a/toonz/sources/include/toonz/childstack.h b/toonz/sources/include/toonz/childstack.hindex 8981fe747..031c4c5d6 100644--- a/toonz/sources/include/toonz/childstack.h+++ b/toonz/sources/include/toonz/childstack.h@@ -43,7 +43,6 @@ class DVAPI ChildStack {std::vector<Node *> m_stack;TXsheet *m_xsheet;ToonzScene *m_scene;- bool m_editInPlace;public:/*!@@ -115,9 +114,6 @@ visibile in \b row.*/bool getAncestorAffine(TAffine &aff, int row) const;- bool getEditInPlace() const { return m_editInPlace; }- void setEditInPlace(bool editInPlace);-private:// not implementedChildStack(const ChildStack &);diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txtindex 5de78c02e..e169bab57 100644--- a/toonz/sources/toonz/CMakeLists.txt+++ b/toonz/sources/toonz/CMakeLists.txt@@ -30,6 +30,7 @@ set(MOC_HEADERScolumncommand.hcolumnselection.hcommandbar.h+ commandbarpopup.hconvertpopup.hcurveio.hdrawingdata.h@@ -167,6 +168,7 @@ set(SOURCESfloatingpanelcommand.cppcanvassizepopup.cppcommandbar.cpp+ commandbarpopup.cpphistory.cpploadfoldercommand.cpploadfolderpopup.cppdiff --git a/toonz/sources/toonz/Resources/edit_in_place.svg b/toonz/sources/toonz/Resources/edit_in_place.svgnew file mode 100644index 000000000..5190190e9--- /dev/null+++ b/toonz/sources/toonz/Resources/edit_in_place.svg@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="UTF-8" standalone="no"?>+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">+<svg width="100%" height="100%" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">+ <g id="g4392" transform="matrix(0.752672,0,0,0.752672,-340.802,-358.087)">+ <g id="rect4141" transform="matrix(1,0,0,1,0,1.3286)">+ <path d="M462.089,477.083L462.089,483.726L467.403,483.726L467.403,477.083L462.089,477.083ZM462.089,490.369L462.089,491.698L458.103,491.698L464.746,497.012L471.389,491.698L467.403,491.698L467.403,490.369L462.089,490.369Z" style="fill:rgb(225,225,225);fill-rule:nonzero;"/>+ <path d="M467.503,489.044L467.601,489.055L467.699,489.074L467.795,489.099L467.889,489.132L467.98,489.172L468.068,489.218L468.152,489.271L468.232,489.33L468.307,489.395L468.377,489.465L468.442,489.541L468.501,489.621L468.554,489.705L468.6,489.793L468.64,489.884L468.673,489.977L468.699,490.073L468.717,490.171L468.728,490.27L468.732,490.369C468.732,490.369 471.389,490.369 471.389,490.369L471.491,490.373L471.593,490.385L471.694,490.404L471.792,490.432L471.889,490.467L471.982,490.509L472.072,490.558L472.158,490.614L472.239,490.676L472.315,490.745L472.386,490.819L472.45,490.898L472.509,490.982L472.56,491.071L472.605,491.163L472.643,491.258L472.673,491.356L472.695,491.456L472.71,491.557L472.717,491.659L472.716,491.761L472.707,491.863L472.691,491.965L472.666,492.064L472.634,492.161L472.595,492.256L472.548,492.347L472.495,492.434L472.435,492.517L472.369,492.595L472.297,492.668L472.219,492.735L465.576,498.049L465.496,498.109L465.412,498.162L465.324,498.208L465.233,498.248L465.139,498.281L465.042,498.307L464.945,498.326L464.846,498.337L464.746,498.341L464.647,498.337L464.548,498.326L464.45,498.307L464.354,498.281L464.26,498.248L464.168,498.208L464.08,498.162L463.996,498.109L463.916,498.049L457.273,492.735L457.196,492.668L457.124,492.595L457.057,492.517L456.997,492.434L456.944,492.347L456.897,492.256L456.858,492.161L456.826,492.064L456.802,491.965L456.785,491.863L456.776,491.761L456.775,491.659L456.782,491.557L456.797,491.456L456.819,491.356L456.849,491.258L456.887,491.163L456.932,491.071L456.984,490.982L457.042,490.898L457.107,490.819L457.177,490.745L457.254,490.676L457.335,490.614L457.42,490.558L457.51,490.509L457.604,490.467L457.7,490.432L457.799,490.404L457.899,490.385L458.001,490.373L458.103,490.369L460.76,490.369C460.76,490.369 460.764,490.27 460.764,490.27L460.775,490.171L460.794,490.073L460.819,489.977L460.852,489.884L460.892,489.793L460.938,489.705L460.991,489.621L461.05,489.541L461.115,489.465L461.185,489.395L461.261,489.33L461.341,489.271L461.425,489.218L461.512,489.172L461.604,489.132L461.697,489.099L461.793,489.074L461.891,489.055L461.99,489.044L462.089,489.04L467.403,489.04L467.503,489.044ZM462.089,490.369L462.089,491.698L458.103,491.698L464.746,497.012L471.389,491.698L467.403,491.698L467.403,490.369L462.089,490.369ZM467.503,475.758L467.601,475.769L467.699,475.788L467.795,475.813L467.889,475.846L467.98,475.886L468.068,475.932L468.152,475.985L468.232,476.044L468.307,476.109L468.377,476.179L468.442,476.255L468.501,476.335L468.554,476.419L468.6,476.507L468.64,476.598L468.673,476.691L468.699,476.787L468.717,476.885L468.728,476.984L468.732,477.083L468.732,483.726L468.728,483.825L468.717,483.924L468.699,484.022L468.673,484.118L468.64,484.211L468.6,484.302L468.554,484.39L468.501,484.474L468.442,484.554L468.377,484.63L468.307,484.7L468.232,484.765L468.152,484.824L468.068,484.877L467.98,484.923L467.889,484.963L467.795,484.996L467.699,485.021L467.601,485.04L467.503,485.051L467.403,485.055L462.089,485.055L461.99,485.051L461.891,485.04L461.793,485.021L461.697,484.996L461.604,484.963L461.512,484.923L461.425,484.877L461.341,484.824L461.261,484.765L461.185,484.7L461.115,484.63L461.05,484.554L460.991,484.474L460.938,484.39L460.892,484.302L460.852,484.211L460.819,484.118L460.794,484.022L460.775,483.924L460.764,483.825L460.76,483.726L460.76,477.083L460.764,476.984L460.775,476.885L460.794,476.787L460.819,476.691L460.852,476.598L460.892,476.507L460.938,476.419L460.991,476.335L461.05,476.255L461.115,476.179L461.185,476.109L461.261,476.044L461.341,475.985L461.425,475.932L461.512,475.886L461.604,475.846L461.697,475.813L461.793,475.788L461.891,475.769L461.99,475.758L462.089,475.754L467.403,475.754L467.503,475.758ZM462.089,477.083L462.089,483.726L467.403,483.726L467.403,477.083L462.089,477.083Z" style="fill:rgb(22,22,22);"/>+ </g>+ <g transform="matrix(1,0,0,1,0,1.3286)">+ <path d="M470.165,481.741C470.239,481.758 470.308,481.776 470.376,481.813C470.434,481.844 470.446,481.857 470.498,481.897L474.484,486.548C474.573,486.635 474.643,486.73 474.681,486.85C474.77,487.137 474.65,487.457 474.394,487.614C474.286,487.68 474.171,487.705 474.046,487.712L455.446,487.712C455.321,487.705 455.206,487.68 455.098,487.614C454.843,487.457 454.722,487.137 454.812,486.85C454.849,486.73 454.919,486.635 455.008,486.548L458.994,481.897C459.095,481.819 459.2,481.762 459.327,481.741C459.401,481.73 459.476,481.73 459.55,481.744C459.878,481.803 460.117,482.109 460.095,482.442C460.086,482.566 460.043,482.687 459.969,482.787C459.93,482.841 459.916,482.851 459.869,482.897L457.214,486.383L472.278,486.383L469.623,482.897C469.532,482.808 469.461,482.712 469.424,482.588C469.336,482.295 469.467,481.97 469.733,481.819C469.823,481.769 469.915,481.747 470.016,481.735C470.091,481.734 470.09,481.734 470.165,481.741Z" style="fill:rgb(225,225,225);fill-rule:nonzero;"/>+ <path d="M459.536,480.407L459.62,480.413L459.703,480.423L459.788,480.436L459.879,480.455L459.971,480.479L460.061,480.506L460.148,480.538L460.234,480.573L460.317,480.612L460.398,480.655L460.476,480.701L460.551,480.75L460.624,480.802L460.694,480.857L460.761,480.915L460.826,480.975L460.887,481.039L460.946,481.104L461.001,481.172L461.054,481.243L461.103,481.316L461.15,481.391L461.193,481.468L461.233,481.547L461.269,481.628L461.302,481.712L461.331,481.797L461.357,481.884L461.378,481.972L461.396,482.062L461.41,482.154L461.419,482.247L461.424,482.34L461.425,482.435L461.42,482.538L461.407,482.67L461.383,482.808L461.349,482.943L461.306,483.076L461.255,483.204L461.194,483.33L461.124,483.451L461.05,483.562L460.971,483.665L460.89,483.757L460.83,483.817L460.865,483.782L459.896,485.055L469.596,485.055L468.616,483.768L468.62,483.772L468.546,483.689L468.47,483.595L468.396,483.49L468.324,483.374L468.258,483.248L468.199,483.112L468.154,482.98L468.128,482.885L468.109,482.8L468.093,482.715L468.081,482.63L468.073,482.545L468.069,482.461L468.068,482.377L468.071,482.293L468.077,482.21L468.087,482.128L468.1,482.047L468.116,481.966L468.136,481.887L468.158,481.808L468.184,481.731L468.213,481.655L468.245,481.58L468.28,481.506L468.318,481.434L468.359,481.363L468.403,481.294L468.45,481.226L468.5,481.16L468.552,481.096L468.608,481.033L468.667,480.973L468.729,480.915L468.793,480.859L468.86,480.806L468.93,480.756L469.003,480.708L469.084,480.66L469.187,480.605L469.297,480.557L469.404,480.516L469.507,480.484L469.604,480.459L469.695,480.44L469.777,480.426L469.836,480.418L469.921,480.409L470.006,480.406L470.068,480.406L470.151,480.407L470.234,480.413L470.296,480.419L470.382,480.431L470.468,480.448L470.554,480.468L470.672,480.502L470.756,480.531L470.837,480.562L470.921,480.599L471.006,480.643L471.113,480.704L471.215,480.772L471.282,480.823L471.322,480.855L471.387,480.91L471.449,480.97L471.507,481.033L475.463,485.648L475.484,485.67L475.558,485.752L475.632,485.844L475.706,485.946L475.777,486.06L475.843,486.184L475.901,486.316L475.947,486.445L475.973,486.538L475.993,486.621L476.01,486.704L476.022,486.788L476.031,486.871L476.037,486.954L476.039,487.036L476.037,487.118L476.033,487.2L476.025,487.281L476.013,487.361L475.999,487.44L475.981,487.518L475.961,487.596L475.937,487.673L475.911,487.748L475.881,487.822L475.848,487.895L475.813,487.967L475.774,488.038L475.733,488.107L475.689,488.175L475.641,488.241L475.591,488.306L475.538,488.368L475.482,488.429L475.424,488.488L475.362,488.544L475.298,488.599L475.231,488.65L475.161,488.7L475.08,488.752L474.961,488.819L474.829,488.881L474.698,488.93L474.57,488.969L474.447,488.998L474.33,489.018L474.222,489.031L474.096,489.04L455.396,489.04L455.271,489.031L455.162,489.018L455.045,488.998L454.922,488.969L454.794,488.93L454.663,488.881L454.532,488.819L454.412,488.752L454.331,488.7L454.261,488.65L454.194,488.599L454.13,488.544L454.069,488.488L454.01,488.429L453.954,488.368L453.901,488.306L453.851,488.241L453.804,488.175L453.759,488.107L453.718,488.038L453.679,487.967L453.644,487.896L453.611,487.822L453.582,487.748L453.555,487.673L453.531,487.596L453.511,487.518L453.493,487.44L453.479,487.361L453.468,487.281L453.46,487.2L453.455,487.118L453.453,487.036L453.456,486.954L453.461,486.871L453.47,486.788L453.483,486.704L453.499,486.621L453.519,486.538L453.546,486.445L453.591,486.316L453.65,486.184L453.716,486.06L453.786,485.946L453.86,485.844L453.935,485.752L454.008,485.67L454.029,485.648L457.986,481.033L458.051,480.961L458.123,480.895L458.198,480.834L458.26,480.787L458.353,480.725L458.455,480.662L458.569,480.602L458.694,480.547L458.828,480.498L458.971,480.458L459.107,480.431L459.202,480.418L459.285,480.41L459.369,480.405L459.453,480.404L459.536,480.407ZM459.411,481.733L459.383,481.735L459.355,481.738L459.327,481.741L459.281,481.751L459.236,481.763L459.192,481.779L459.151,481.798L459.11,481.819L459.071,481.843L459.032,481.869L458.994,481.897L455.008,486.548L454.976,486.581L454.945,486.615L454.917,486.65L454.891,486.686L454.867,486.724L454.846,486.764L454.827,486.806L454.812,486.85L454.804,486.877L454.797,486.904L454.792,486.932L454.788,486.959L454.785,486.986L454.783,487.014L454.782,487.041L454.783,487.068L454.784,487.096L454.787,487.123L454.791,487.15L454.796,487.176L454.802,487.203L454.809,487.229L454.817,487.255L454.826,487.281L454.836,487.306L454.847,487.331L454.859,487.355L454.872,487.379L454.886,487.402L454.901,487.425L454.916,487.447L454.933,487.468L454.951,487.489L454.969,487.509L454.989,487.529L455.009,487.548L455.03,487.565L455.052,487.582L455.075,487.598L455.098,487.614L455.139,487.637L455.181,487.656L455.223,487.672L455.266,487.685L455.31,487.695L455.354,487.703L455.4,487.708L455.446,487.712L474.046,487.712L474.093,487.708L474.138,487.703L474.183,487.695L474.226,487.685L474.269,487.672L474.312,487.656L474.353,487.637L474.394,487.614L474.417,487.598L474.44,487.582L474.462,487.565L474.483,487.548L474.504,487.529L474.523,487.509L474.542,487.489L474.559,487.468L474.576,487.447L474.592,487.425L474.607,487.402L474.621,487.379L474.634,487.355L474.646,487.331L474.657,487.306L474.667,487.281L474.676,487.255L474.684,487.229L474.691,487.203L474.697,487.176L474.701,487.15L474.705,487.123L474.708,487.096L474.709,487.068L474.71,487.041L474.709,487.014L474.707,486.986L474.704,486.959L474.7,486.932L474.695,486.904L474.688,486.877L474.681,486.85L474.665,486.806L474.647,486.764L474.625,486.724L474.602,486.686L474.575,486.65L474.547,486.615L474.516,486.581L474.484,486.548L470.498,481.897L470.465,481.872L470.439,481.852L470.412,481.834L470.376,481.813L470.35,481.8L470.325,481.788L470.299,481.778L470.273,481.769L470.22,481.754L470.165,481.741L470.121,481.737L470.091,481.735L470.06,481.734L470.016,481.735L469.979,481.74L469.942,481.746L469.906,481.754L469.87,481.763L469.835,481.774L469.801,481.787L469.767,481.802L469.733,481.819L469.709,481.834L469.685,481.85L469.662,481.866L469.64,481.884L469.619,481.902L469.598,481.921L469.579,481.941L469.56,481.962L469.542,481.983L469.526,482.005L469.51,482.028L469.495,482.052L469.481,482.075L469.468,482.1L469.457,482.125L469.446,482.15L469.436,482.176L469.427,482.202L469.42,482.229L469.413,482.256L469.408,482.283L469.403,482.31L469.4,482.338L469.398,482.365L469.397,482.393L469.397,482.421L469.399,482.449L469.401,482.477L469.405,482.505L469.41,482.533L469.417,482.56L469.424,482.588L469.44,482.633L469.458,482.676L469.479,482.717L469.503,482.756L469.53,482.793L469.559,482.829L469.59,482.864L469.623,482.897L472.278,486.383L457.214,486.383L459.869,482.897L459.899,482.868L459.922,482.845L459.944,482.821L459.969,482.787L459.995,482.749L460.019,482.708L460.039,482.667L460.056,482.623L460.071,482.579L460.082,482.534L460.09,482.488L460.095,482.442L460.096,482.41L460.096,482.38L460.094,482.349L460.091,482.318L460.087,482.288L460.081,482.259L460.073,482.229L460.065,482.2L460.055,482.172L460.044,482.144L460.032,482.117L460.019,482.09L460.004,482.064L459.988,482.039L459.972,482.014L459.954,481.99L459.935,481.967L459.915,481.945L459.894,481.923L459.872,481.903L459.85,481.883L459.826,481.865L459.802,481.847L459.777,481.831L459.751,481.816L459.724,481.802L459.697,481.789L459.668,481.777L459.64,481.767L459.61,481.758L459.58,481.75L459.55,481.744L459.522,481.739L459.494,481.736L459.467,481.734L459.439,481.733L459.411,481.733Z" style="fill:rgb(22,22,22);"/>+ </g>+ </g>+</svg>diff --git a/toonz/sources/toonz/castviewer.cpp b/toonz/sources/toonz/castviewer.cppindex ef776bab3..78182bc77 100644--- a/toonz/sources/toonz/castviewer.cpp+++ b/toonz/sources/toonz/castviewer.cpp@@ -743,8 +743,8 @@ QMenu *CastBrowser::getContextMenu(QWidget *parent, int index) {levelSelectedCount++;if (sl->getType() == PLI_XSHLEVEL)vectorLevelSelected = true;- else if(sl->getType() == MESH_XSHLEVEL)- meshLevelSelected = true;+ else if (sl->getType() == MESH_XSHLEVEL)+ meshLevelSelected = true;elseotherFileSelected = true;}@@ -755,8 +755,8 @@ QMenu *CastBrowser::getContextMenu(QWidget *parent, int index) {menu->addAction(cm->getAction(MI_ExposeResource));menu->addAction(cm->getAction(MI_ShowFolderContents));- if(!audioSelected && !paletteSelected && !meshLevelSelected)- menu->addAction(cm->getAction(MI_ViewFile));+ if (!audioSelected && !paletteSelected && !meshLevelSelected)+ menu->addAction(cm->getAction(MI_ViewFile));menu->addAction(cm->getAction(MI_FileInfo));// MI_EditLevel solo se e' stato selezionato un singolo diverso da livellidiff --git a/toonz/sources/toonz/commandbar.cpp b/toonz/sources/toonz/commandbar.cppindex ceea7fbfb..75a5f969a 100644--- a/toonz/sources/toonz/commandbar.cpp+++ b/toonz/sources/toonz/commandbar.cpp@@ -1,21 +1,28 @@-+#include "commandbar.h"// Tnz6 includes#include "tapp.h"#include "menubarcommandids.h"+#include "tsystem.h"+#include "commandbarpopup.h"+// TnzQt includes+#include "toonzqt/menubarcommand.h"#include "toonzqt/gutil.h"// TnzLib includes-#include "toonz/preferences.h"#include "toonz/tscenehandle.h"-#include "toonzqt/menubarcommand.h"-+#include "toonz/toonzscene.h"+#include "toonz/childstack.h"+#include "toonz/toonzfolders.h"// Qt includes#include <QWidgetAction>-+#include <QXmlStreamReader>+#include <QtDebug>+#include <QMenuBar>+#include <QContextMenuEvent>//=============================================================================// Toolbar@@ -23,62 +30,132 @@#if QT_VERSION >= 0x050500CommandBar::CommandBar(QWidget *parent, Qt::WindowFlags flags,- bool isCollapsible)+ bool isCollapsible, bool isXsheetToolbar)#else-CommandBar::CommandBar(XsheetViewer *parent, Qt::WFlags flags)+CommandBar::CommandBar(QWidget *parent, Qt::WFlags flags)#endif: QToolBar(parent), m_isCollapsible(isCollapsible) {setObjectName("cornerWidget");setObjectName("CommandBar");+ fillToolbar(this, isXsheetToolbar);+}++//-----------------------------------------------------------------------------++void CommandBar::fillToolbar(CommandBar *toolbar, bool isXsheetToolbar) {+ toolbar->clear();+ TFilePath personalPath;+ if (isXsheetToolbar) {+ personalPath =+ ToonzFolder::getMyModuleDir() + TFilePath("xsheettoolbar.xml");+ } else {+ personalPath = ToonzFolder::getMyModuleDir() + TFilePath("commandbar.xml");+ }+ if (!TSystem::doesExistFileOrLevel(personalPath)) {+ if (isXsheetToolbar) {+ personalPath =+ ToonzFolder::getTemplateModuleDir() + TFilePath("xsheettoolbar.xml");+ } else {+ personalPath =+ ToonzFolder::getTemplateModuleDir() + TFilePath("commandbar.xml");+ }+ }+ QFile file(toQString(personalPath));+ if (!file.open(QFile::ReadOnly | QFile::Text)) {+ qDebug() << "Cannot read file" << file.errorString();+ buildDefaultToolbar(toolbar);+ return;+ }++ QXmlStreamReader reader(&file);++ if (reader.readNextStartElement()) {+ if (reader.name() == "commandbar") {+ while (reader.readNextStartElement()) {+ if (reader.name() == "command") {+ QString cmdName = reader.readElementText();+ std::string cmdStr = cmdName.toStdString();+ QAction *action =+ CommandManager::instance()->getAction(cmdStr.c_str());+ if (action) toolbar->addAction(action);+ } else if (reader.name() == "separator") {+ toolbar->addSeparator();+ reader.skipCurrentElement();+ } else+ reader.skipCurrentElement();+ }+ } else+ reader.raiseError(QObject::tr("Incorrect file"));+ } else {+ reader.raiseError(QObject::tr("Cannot Read XML File"));+ }- TApp *app = TApp::instance();- m_keyFrameButton = new ViewerKeyframeNavigator(this, app->getCurrentFrame());- m_keyFrameButton->setObjectHandle(app->getCurrentObject());- m_keyFrameButton->setXsheetHandle(app->getCurrentXsheet());+ if (reader.hasError()) {+ buildDefaultToolbar(toolbar);+ return;+ }+}- QWidgetAction *keyFrameAction = new QWidgetAction(this);- keyFrameAction->setDefaultWidget(m_keyFrameButton);+//-----------------------------------------------------------------------------+void CommandBar::buildDefaultToolbar(CommandBar *toolbar) {+ toolbar->clear();+ TApp *app = TApp::instance();{QAction *newVectorLevel =CommandManager::instance()->getAction("MI_NewVectorLevel");- addAction(newVectorLevel);+ toolbar->addAction(newVectorLevel);QAction *newToonzRasterLevel =CommandManager::instance()->getAction("MI_NewToonzRasterLevel");- addAction(newToonzRasterLevel);+ toolbar->addAction(newToonzRasterLevel);QAction *newRasterLevel =CommandManager::instance()->getAction("MI_NewRasterLevel");- addAction(newRasterLevel);- addSeparator();+ toolbar->addAction(newRasterLevel);+ toolbar->addSeparator();QAction *reframeOnes = CommandManager::instance()->getAction("MI_Reframe1");- addAction(reframeOnes);+ toolbar->addAction(reframeOnes);QAction *reframeTwos = CommandManager::instance()->getAction("MI_Reframe2");- addAction(reframeTwos);+ toolbar->addAction(reframeTwos);QAction *reframeThrees =CommandManager::instance()->getAction("MI_Reframe3");- addAction(reframeThrees);+ toolbar->addAction(reframeThrees);- addSeparator();+ toolbar->addSeparator();QAction *repeat = CommandManager::instance()->getAction("MI_Dup");- addAction(repeat);+ toolbar->addAction(repeat);- addSeparator();+ toolbar->addSeparator();QAction *collapse = CommandManager::instance()->getAction("MI_Collapse");- addAction(collapse);+ toolbar->addAction(collapse);QAction *open = CommandManager::instance()->getAction("MI_OpenChild");- addAction(open);+ toolbar->addAction(open);QAction *leave = CommandManager::instance()->getAction("MI_CloseChild");- addAction(leave);-- addSeparator();- addAction(keyFrameAction);+ toolbar->addAction(leave);+ QAction *editInPlace =+ CommandManager::instance()->getAction("MI_ToggleEditInPlace");+ toolbar->addAction(editInPlace);}}+//-----------------------------------------------------------------------------+void CommandBar::contextMenuEvent(QContextMenuEvent *event) {+ QMenu *menu = new QMenu(this);+ QAction *customizeCommandBar = menu->addAction(tr("Customize Command Bar"));+ connect(customizeCommandBar, SIGNAL(triggered()),+ SLOT(doCustomizeCommandBar()));+ menu->exec(event->globalPos());+}+//-----------------------------------------------------------------------------+void CommandBar::doCustomizeCommandBar() {+ CommandBarPopup *cbPopup = new CommandBarPopup();-+ if (cbPopup->exec()) {+ fillToolbar(this);+ }+ delete cbPopup;+}\ No newline at end of filediff --git a/toonz/sources/toonz/commandbar.h b/toonz/sources/toonz/commandbar.hindex 12262d71e..5bf520a9f 100644--- a/toonz/sources/toonz/commandbar.h+++ b/toonz/sources/toonz/commandbar.h@@ -6,7 +6,6 @@#include <memory>#include "toonz/txsheet.h"-#include "toonz/txshleveltypes.h"#include "toonzqt/keyframenavigator.h"#include <QToolBar>@@ -14,31 +13,34 @@//-----------------------------------------------------------------------------// forward declaration-class XsheetViewer;-class QPushButton;+class QAction;//=============================================================================-// XSheet Toolbar+// CommandBar//------------------------------------------------------------------------------class CommandBar final : public QToolBar {+class CommandBar : public QToolBar {Q_OBJECT-- //XsheetViewer *m_viewer;- ViewerKeyframeNavigator *m_keyFrameButton;bool m_isCollapsible;public:#if QT_VERSION >= 0x050500CommandBar(QWidget *parent = 0, Qt::WindowFlags flags = 0,- bool isCollapsible = false);+ bool isCollapsible = false, bool isXsheetToolbar = false);#else- CommandBar(XsheetViewer *parent = 0, Qt::WFlags flags = 0);+ CommandBar(QWidget *parent = 0, Qt::WFlags flags = 0);#endif-+signals:void updateVisibility();-++protected:+ static void fillToolbar(CommandBar *toolbar, bool isXsheetToolbar = false);+ static void buildDefaultToolbar(CommandBar *toolbar);+ void contextMenuEvent(QContextMenuEvent *event) override;++protected slots:+ void doCustomizeCommandBar();};#endif // COMMANDBAR_Hdiff --git a/toonz/sources/toonz/commandbarpopup.cpp b/toonz/sources/toonz/commandbarpopup.cppnew file mode 100644index 000000000..8d0a9032a--- /dev/null+++ b/toonz/sources/toonz/commandbarpopup.cpp@@ -0,0 +1,480 @@+#include "commandbarpopup.h"++// Tnz includes+#include "tapp.h"+#include "menubar.h"+#include "shortcutpopup.h"++// TnzQt includes+#include "toonzqt/gutil.h"++// TnzLib includes+#include "toonz/toonzfolders.h"++// TnzCore includes+#include "tsystem.h"++// Qt includes+#include <QMainWindow>+#include <QPushButton>+#include <QVBoxLayout>+#include <QHBoxLayout>+#include <QGridLayout>+#include <QHeaderView>+#include <QtDebug>+#include <QXmlStreamReader>+#include <QXmlStreamWriter>+#include <QDataStream>+#include <QMimeData>+#include <QDrag>+#include <QMouseEvent>+#include <QPainter>+#include <QApplication>+#include <QLabel>++//=============================================================================+// CommandBarCommandItem+//-----------------------------------------------------------------------------++class CommandBarCommandItem final : public QTreeWidgetItem {+ QAction* m_action;++public:+ CommandBarCommandItem(QTreeWidgetItem* parent, QAction* action)+ : QTreeWidgetItem(parent, UserType), m_action(action) {+ setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled |+ Qt::ItemNeverHasChildren);+ setText(0, m_action->text().remove("&"));+ setToolTip(0, QObject::tr("[Drag] to move position"));+ }+ QAction* getAction() const { return m_action; }+};++//=============================================================================+// CommandBarSeparatorItem+//-----------------------------------------------------------------------------++class CommandBarSeparatorItem final : public QTreeWidgetItem {+public:+ CommandBarSeparatorItem(QTreeWidgetItem* parent)+ : QTreeWidgetItem(parent, UserType) {+ setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled |+ Qt::ItemNeverHasChildren);+ setText(0, QObject::tr("----Separator----"));+ setToolTip(0, QObject::tr("[Drag] to move position"));+ }+};++//=============================================================================+// CommandBarTree+//-----------------------------------------------------------------------------++CommandBarTree::CommandBarTree(TFilePath& path, QWidget* parent)+ : QTreeWidget(parent) {+ setObjectName("SolidLineFrame");+ setAlternatingRowColors(true);+ setDragEnabled(true);+ setDropIndicatorShown(true);+ setDefaultDropAction(Qt::MoveAction);+ setDragDropMode(QAbstractItemView::DragDrop);+ setIconSize(QSize(21, 17));++ setColumnCount(1);+ header()->close();++ /*- Load path if it does exist. If not, then load from the template. -*/+ TFilePath fp;+ if (TFileStatus(path).isWritable())+ fp = path;+ else {+ if (path.getName() == "xsheettoolbar") {+ fp = ToonzFolder::getTemplateModuleDir() + TFilePath("xsheettoolbar.xml");+ } else {+ fp = ToonzFolder::getTemplateModuleDir() + TFilePath("commandbar.xml");+ }+ }++ loadMenuTree(fp);+}++//-----------------------------------------------------------------------------++void CommandBarTree::loadMenuTree(const TFilePath& fp) {+ QFile file(toQString(fp));+ if (!file.open(QFile::ReadOnly | QFile::Text)) {+ qDebug() << "Cannot read file" << file.errorString();+ return;+ }++ QXmlStreamReader reader(&file);++ if (reader.readNextStartElement()) {+ if (reader.name() == "commandbar") {+ while (reader.readNextStartElement()) {+ if (reader.name() == "command") {+ QString cmdName = reader.readElementText();++ QAction* action = CommandManager::instance()->getAction(+ cmdName.toStdString().c_str());+ if (action) {+ CommandBarCommandItem* item = new CommandBarCommandItem(0, action);+ addTopLevelItem(item);+ }+ } else if (reader.name() == "separator") {+ CommandBarSeparatorItem* sep = new CommandBarSeparatorItem(0);+ addTopLevelItem(sep);+ reader.skipCurrentElement();+ } else+ reader.skipCurrentElement();+ }+ } else+ reader.raiseError(QObject::tr("Incorrect file"));+ }++ if (reader.hasError()) {+ qDebug() << "Cannot read menubar xml";+ }+}++//-----------------------------------------------------------------------------++void CommandBarTree::loadMenuRecursive(QXmlStreamReader& reader,+ QTreeWidgetItem* parentItem) {+ while (reader.readNextStartElement()) {+ if (reader.name() == "command") {+ QString cmdName = reader.readElementText();+ QAction* action =+ CommandManager::instance()->getAction(cmdName.toStdString().c_str());+ if (action)+ CommandBarCommandItem* item =+ new CommandBarCommandItem(parentItem, action);+ } else if (reader.name() == "command_debug") {+#ifndef NDEBUG+ QString cmdName = reader.readElementText();+ QAction* action =+ CommandManager::instance()->getAction(cmdName.toStdString().c_str());+ if (action)+ CommandBarCommandItem* item =+ new CommandBarCommandItem(parentItem, action);+#else+ reader.skipCurrentElement();+#endif+ } else if (reader.name() == "separator") {+ CommandBarSeparatorItem* sep = new CommandBarSeparatorItem(parentItem);+ reader.skipCurrentElement();+ } else+ reader.skipCurrentElement();+ }+}++//-----------------------------------------------------------------------------++void CommandBarTree::saveMenuTree(TFilePath& path) {+ QFile file(toQString(path));+ if (!file.open(QFile::WriteOnly | QFile::Text)) {+ qDebug() << "Cannot read file" << file.errorString();+ return;+ }++ QXmlStreamWriter writer(&file);+ writer.setAutoFormatting(true);+ writer.writeStartDocument();++ writer.writeStartElement("commandbar");+ { saveMenuRecursive(writer, invisibleRootItem()); }+ writer.writeEndElement();++ writer.writeEndDocument();+}++//-----------------------------------------------------------------------------++void CommandBarTree::saveMenuRecursive(QXmlStreamWriter& writer,+ QTreeWidgetItem* parentItem) {+ for (int c = 0; c < parentItem->childCount(); c++) {+ CommandBarCommandItem* command =+ dynamic_cast<CommandBarCommandItem*>(parentItem->child(c));+ CommandBarSeparatorItem* sep =+ dynamic_cast<CommandBarSeparatorItem*>(parentItem->child(c));++ if (command)+ writer.writeTextElement(+ "command",+ QString::fromStdString(CommandManager::instance()->getIdFromAction(+ command->getAction())));+ else if (sep)+ writer.writeEmptyElement("separator");+ }+}++//-----------------------------------------------------------------------------++bool CommandBarTree::dropMimeData(QTreeWidgetItem* parent, int index,+ const QMimeData* data,+ Qt::DropAction action) {+ if (data->hasText()) {+ QString txt = data->text();+ QTreeWidgetItem* item;+ if (txt == "separator")+ item = new CommandBarSeparatorItem(0);+ else {+ QAction* act =+ CommandManager::instance()->getAction(txt.toStdString().c_str());+ if (!act) return false;+ item = new CommandBarCommandItem(0, act);+ }++ if (parent)+ parent->insertChild(index, item);+ else+ insertTopLevelItem(index, item);++ return true;+ }++ return false;+}++//-----------------------------------------------------------------------------++QStringList CommandBarTree::mimeTypes() const {+ QStringList qstrList;+ qstrList.append("text/plain");+ return qstrList;+}++//-----------------------------------------------------------------------------++void CommandBarTree::contextMenuEvent(QContextMenuEvent* event) {+ QTreeWidgetItem* item = itemAt(event->pos());+ if (item != currentItem()) setCurrentItem(item);+ QMenu* menu = new QMenu(this);+ QAction* action;++ if (item) {+ action = menu->addAction(tr("Remove \"%1\"").arg(item->text(0)));+ connect(action, SIGNAL(triggered()), this, SLOT(removeItem()));+ }++ menu->exec(event->globalPos());+ delete menu;+}++//-----------------------------------------------------------------------------++void CommandBarTree::removeItem() {+ QTreeWidgetItem* item = currentItem();+ if (!item) return;++ if (indexOfTopLevelItem(item) >= 0)+ takeTopLevelItem(indexOfTopLevelItem(item));+ else+ item->parent()->removeChild(item);++ delete item;+}++//=============================================================================+// CommandListTree+//-----------------------------------------------------------------------------++CommandBarListTree::CommandBarListTree(QWidget* parent) : QTreeWidget(parent) {+ setObjectName("SolidLineFrame");+ setAlternatingRowColors(true);+ setDragEnabled(true);+ setDragDropMode(QAbstractItemView::DragOnly);+ setColumnCount(1);+ setIconSize(QSize(21, 17));+ header()->close();++ QIcon menuFolderIcon(":Resources/browser_project_close.svg");+ menuFolderIcon.addFile(":Resources/browser_project_open.svg", QSize(),+ QIcon::Normal, QIcon::On);+ invisibleRootItem()->setIcon(0, menuFolderIcon);++ QTreeWidgetItem* menuCommandFolder = new QTreeWidgetItem(this);+ menuCommandFolder->setFlags(Qt::ItemIsEnabled);+ menuCommandFolder->setText(0, ShortcutTree::tr("Menu Commands"));+ menuCommandFolder->setExpanded(true);+ menuCommandFolder->setIcon(0, invisibleRootItem()->icon(0));++ addFolder(ShortcutTree::tr("File"), MenuFileCommandType, menuCommandFolder);+ addFolder(ShortcutTree::tr("Edit"), MenuEditCommandType, menuCommandFolder);+ addFolder(ShortcutTree::tr("Scan & Cleanup"), MenuScanCleanupCommandType,+ menuCommandFolder);+ addFolder(ShortcutTree::tr("Level"), MenuLevelCommandType, menuCommandFolder);+ addFolder(ShortcutTree::tr("Xsheet"), MenuXsheetCommandType,+ menuCommandFolder);+ addFolder(ShortcutTree::tr("Cells"), MenuCellsCommandType, menuCommandFolder);+ addFolder(ShortcutTree::tr("View"), MenuViewCommandType, menuCommandFolder);+ addFolder(ShortcutTree::tr("Windows"), MenuWindowsCommandType,+ menuCommandFolder);++ addFolder(ShortcutTree::tr("Tools"), ToolCommandType);+ addFolder(ShortcutTree::tr("Playback"), PlaybackCommandType);+ addFolder(ShortcutTree::tr("Fill"), FillCommandType);+ addFolder(ShortcutTree::tr("Right-click Menu Commands"),+ RightClickMenuCommandType);+ addFolder(ShortcutTree::tr("Tool Modifiers"), ToolModifierCommandType);+ addFolder(ShortcutTree::tr("Visualization"), ZoomCommandType);+ addFolder(ShortcutTree::tr("Misc"), MiscCommandType);+ addFolder(ShortcutTree::tr("RGBA Channels"), RGBACommandType);++ CommandBarSeparatorItem* sep = new CommandBarSeparatorItem(0);+ sep->setToolTip(0, QObject::tr("[Drag&Drop] to copy separator to menu bar"));+ addTopLevelItem(sep);+}++//-----------------------------------------------------------------------------++void CommandBarListTree::addFolder(const QString& title, int commandType,+ QTreeWidgetItem* parentFolder) {+ QTreeWidgetItem* folder;+ if (!parentFolder)+ folder = new QTreeWidgetItem(this);+ else+ folder = new QTreeWidgetItem(parentFolder);+ assert(folder);+ folder->setText(0, title);+ folder->setIcon(0, invisibleRootItem()->icon(0));++ std::vector<QAction*> actions;+ CommandManager::instance()->getActions((CommandType)commandType, actions);+ for (int i = 0; i < (int)actions.size(); i++) {+ CommandBarCommandItem* item = new CommandBarCommandItem(folder, actions[i]);+ item->setToolTip(0, QObject::tr("[Drag&Drop] to copy command to menu bar"));+ }+}++//-----------------------------------------------------------------------------++void CommandBarListTree::mousePressEvent(QMouseEvent* event) {+ setCurrentItem(itemAt(event->pos()));+ CommandBarCommandItem* commandItem =+ dynamic_cast<CommandBarCommandItem*>(itemAt(event->pos()));+ CommandBarSeparatorItem* separatorItem =+ dynamic_cast<CommandBarSeparatorItem*>(itemAt(event->pos()));++ if (commandItem || separatorItem) {+ std::string dragStr;+ QString dragPixmapTxt;+ if (commandItem) {+ dragStr =+ CommandManager::instance()->getIdFromAction(commandItem->getAction());+ dragPixmapTxt = commandItem->getAction()->text();+ dragPixmapTxt.remove("&");+ } else {+ dragStr = "separator";+ dragPixmapTxt = tr("----Separator----");+ }++ QMimeData* mimeData = new QMimeData;+ mimeData->setText(QString::fromStdString(dragStr));++ QFontMetrics fm(QApplication::font());+ QPixmap pix(fm.boundingRect(dragPixmapTxt).adjusted(-2, -2, 2, 2).size());+ QPainter painter(&pix);+ painter.fillRect(pix.rect(), Qt::white);+ painter.setPen(Qt::black);+ painter.drawText(pix.rect(), Qt::AlignCenter, dragPixmapTxt);++ QDrag* drag = new QDrag(this);+ drag->setMimeData(mimeData);+ drag->setPixmap(pix);++ drag->exec(Qt::CopyAction);+ }++ QTreeWidget::mousePressEvent(event);+}++//=============================================================================+// CommandBarPopup+//-----------------------------------------------------------------------------++CommandBarPopup::CommandBarPopup(bool isXsheetToolbar)+ : Dialog(TApp::instance()->getMainWindow(), true, false,+ "CustomizeCommandBar") {+ QLabel* commandBarLabel;+ if (isXsheetToolbar) {+ m_path = ToonzFolder::getMyModuleDir() + TFilePath("xsheettoolbar.xml");+ commandBarLabel = new QLabel(tr("XSheet Toolbar"));+ setWindowTitle(tr("Customize XSheet Toolbar"));+ } else {+ m_path = ToonzFolder::getMyModuleDir() + TFilePath("commandbar.xml");+ commandBarLabel = new QLabel(tr("Command Bar"));+ setWindowTitle(tr("Customize Command Bar"));+ }++ m_commandListTree = new CommandBarListTree(this);+ m_menuBarTree = new CommandBarTree(m_path, this);++ QPushButton* okBtn = new QPushButton(tr("OK"), this);+ QPushButton* cancelBtn = new QPushButton(tr("Cancel"), this);++ okBtn->setFocusPolicy(Qt::NoFocus);+ cancelBtn->setFocusPolicy(Qt::NoFocus);++ QLabel* commandItemListLabel = new QLabel(tr("Toolbar Items"), this);++ QFont f("Arial", 15, QFont::Bold);+ commandBarLabel->setFont(f);+ commandItemListLabel->setFont(f);++ QLabel* noticeLabel =+ new QLabel(tr("Duplicated commands will be ignored. Only "+ "the last one will appear in the menu bar."),+ this);+ QFont nf("Arial", 9, QFont::Normal);+ nf.setItalic(true);+ noticeLabel->setFont(nf);++ //--- layout+ QVBoxLayout* mainLay = new QVBoxLayout();+ m_topLayout->setMargin(0);+ m_topLayout->setSpacing(0);+ {+ QGridLayout* mainUILay = new QGridLayout();+ mainUILay->setMargin(5);+ mainUILay->setHorizontalSpacing(8);+ mainUILay->setVerticalSpacing(5);+ {+ mainUILay->addWidget(commandBarLabel, 0, 0);+ mainUILay->addWidget(commandItemListLabel, 0, 1);+ mainUILay->addWidget(m_menuBarTree, 1, 0);+ mainUILay->addWidget(m_commandListTree, 1, 1);++ mainUILay->addWidget(noticeLabel, 2, 0, 1, 2);+ }+ mainUILay->setRowStretch(0, 0);+ mainUILay->setRowStretch(1, 1);+ mainUILay->setRowStretch(2, 0);+ mainUILay->setColumnStretch(0, 1);+ mainUILay->setColumnStretch(1, 1);++ m_topLayout->addLayout(mainUILay, 1);+ }++ m_buttonLayout->setMargin(0);+ m_buttonLayout->setSpacing(30);+ {+ m_buttonLayout->addStretch(1);+ m_buttonLayout->addWidget(okBtn, 0);+ m_buttonLayout->addWidget(cancelBtn, 0);+ m_buttonLayout->addStretch(1);+ }++ //--- signal/slot connections++ bool ret = connect(okBtn, SIGNAL(clicked()), this, SLOT(onOkPressed()));+ ret = ret && connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));+ assert(ret);+}++//-----------------------------------------------------------------------------++void CommandBarPopup::onOkPressed() {+ m_menuBarTree->saveMenuTree(m_path);++ accept();+}\ No newline at end of filediff --git a/toonz/sources/toonz/commandbarpopup.h b/toonz/sources/toonz/commandbarpopup.hnew file mode 100644index 000000000..ac56c740e--- /dev/null+++ b/toonz/sources/toonz/commandbarpopup.h@@ -0,0 +1,73 @@+#pragma once++#ifndef COMMANDBARPOPUP_H+#define COMMANDBARPOPUP_H++#include <QTreeWidget>+#include <QTreeWidgetItem>+#include <QAction>++#include "toonzqt/dvdialog.h"+#include "tfilepath.h"++class QXmlStreamReader;+class QXmlStreamWriter;++//=============================================================================+// CommandBarTree+//-----------------------------------------------------------------------------++class CommandBarTree final : public QTreeWidget {+ Q_OBJECT++ void loadMenuTree(const TFilePath& fp);+ void loadMenuRecursive(QXmlStreamReader& reader, QTreeWidgetItem* parentItem);+ void saveMenuRecursive(QXmlStreamWriter& writer, QTreeWidgetItem* parentItem);++public:+ CommandBarTree(TFilePath& path, QWidget* parent = 0);+ void saveMenuTree(TFilePath& path);++protected:+ bool dropMimeData(QTreeWidgetItem* parent, int index, const QMimeData* data,+ Qt::DropAction action) override;+ QStringList mimeTypes() const override;+ void contextMenuEvent(QContextMenuEvent* event) override;+protected slots:+ void removeItem();+};++//=============================================================================+// CommandBarListTree+//-----------------------------------------------------------------------------++class CommandBarListTree final : public QTreeWidget {+ Q_OBJECT++ void addFolder(const QString& title, int commandType,+ QTreeWidgetItem* parentFolder = 0);++public:+ CommandBarListTree(QWidget* parent = 0);++protected:+ void mousePressEvent(QMouseEvent*) override;+};++//=============================================================================+// CommandBarPopup+//-----------------------------------------------------------------------------++class CommandBarPopup final : public DVGui::Dialog {+ Q_OBJECT+ CommandBarListTree* m_commandListTree;+ CommandBarTree* m_menuBarTree;+ TFilePath m_path;++public:+ CommandBarPopup(bool isXsheetToolbar = false);+protected slots:+ void onOkPressed();+};++#endif\ No newline at end of filediff --git a/toonz/sources/toonz/levelsettingspopup.cpp b/toonz/sources/toonz/levelsettingspopup.cppindex 28b844e57..b9466717f 100644--- a/toonz/sources/toonz/levelsettingspopup.cpp+++ b/toonz/sources/toonz/levelsettingspopup.cpp@@ -1191,7 +1191,7 @@ public:if (!simpleLevels.size()) return;for (i = 0; i < simpleLevels.size(); i++) {- if (!(simpleLevels[i]->getType() & LEVELCOLUMN_XSHLEVEL)) continue;+ if (!(simpleLevels[i]->getType() & LEVELCOLUMN_XSHLEVEL)) continue;TFilePath path = simpleLevels[i]->getPath();path = simpleLevels[i]->getScene()->decodeFilePath(path);diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex 95f3be551..a14fa2808 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -31,6 +31,7 @@#include "toonz/stylemanager.h"#include "toonz/tscenehandle.h"#include "toonz/toonzscene.h"+#include "toonz/txshleveltypes.h"// TnzBase includes#include "tenv.h"@@ -62,6 +63,7 @@ TEnv::IntVar ViewCameraToggleAction("ViewCameraToggleAction", 1);TEnv::IntVar ViewTableToggleAction("ViewTableToggleAction", 1);TEnv::IntVar FieldGuideToggleAction("FieldGuideToggleAction", 0);TEnv::IntVar ViewBBoxToggleAction("ViewBBoxToggleAction1", 1);+TEnv::IntVar EditInPlaceToggleAction("EditInPlaceToggleAction", 0);#ifdef LINETESTTEnv::IntVar CapturePanelFieldGuideToggleAction("CapturePanelFieldGuideToggleAction", 0);@@ -1248,6 +1250,8 @@ void MainWindow::onMenuCheckboxChanged() {ViewCameraToggleAction = isChecked;else if (cm->getAction(MI_ViewTable) == action)ViewTableToggleAction = isChecked;+ else if (cm->getAction(MI_ToggleEditInPlace) == action)+ EditInPlaceToggleAction = isChecked;else if (cm->getAction(MI_ViewBBox) == action)ViewBBoxToggleAction = isChecked;else if (cm->getAction(MI_FieldGuide) == action)@@ -1784,7 +1788,11 @@ void MainWindow::defineActions() {collapseAction->setIconText("Collapse");collapseAction->setIcon(createQIconOnOffPNG("collapse"));- createMenuXsheetAction(MI_ToggleEditInPlace, tr("Toggle Edit in Place"), "");+ toggle = createToggle(MI_ToggleEditInPlace, tr("&Toggle Edit In Place"), "",+ EditInPlaceToggleAction ? 1 : 0, MenuViewCommandType);+ toggle->setIconText(tr("Toggle Edit in Place"));+ toggle->setIcon(QIcon(":Resources/edit_in_place.svg"));+createMenuXsheetAction(MI_SaveSubxsheetAs, tr("&Save Sub-xsheet As..."), "");createMenuXsheetAction(MI_Resequence, tr("Resequence"), "");createMenuXsheetAction(MI_CloneChild, tr("Clone Sub-xsheet"), "");@@ -2349,9 +2357,9 @@ RecentFiles::~RecentFiles() {}void RecentFiles::addFilePath(QString path, FileType fileType) {QList<QString> files =- (fileType == Scene)- ? m_recentScenes- : (fileType == Level) ? m_recentLevels : m_recentFlipbookImages;+ (fileType == Scene) ? m_recentScenes : (fileType == Level)+ ? m_recentLevels+ : m_recentFlipbookImages;int i;for (i = 0; i < files.size(); i++)if (files.at(i) == path) files.removeAt(i);@@ -2476,9 +2484,9 @@ void RecentFiles::saveRecentFiles() {QList<QString> RecentFiles::getFilesNameList(FileType fileType) {QList<QString> files =- (fileType == Scene)- ? m_recentScenes- : (fileType == Level) ? m_recentLevels : m_recentFlipbookImages;+ (fileType == Scene) ? m_recentScenes : (fileType == Level)+ ? m_recentLevels+ : m_recentFlipbookImages;QList<QString> names;int i;for (i = 0; i < files.size(); i++) {@@ -2505,9 +2513,9 @@ void RecentFiles::refreshRecentFilesMenu(FileType fileType) {menu->setEnabled(false);else {CommandId clearActionId =- (fileType == Scene)- ? MI_ClearRecentScene- : (fileType == Level) ? MI_ClearRecentLevel : MI_ClearRecentImage;+ (fileType == Scene) ? MI_ClearRecentScene : (fileType == Level)+ ? MI_ClearRecentLevel+ : MI_ClearRecentImage;menu->setActions(names);menu->addSeparator();QAction *clearAction = CommandManager::instance()->getAction(clearActionId);diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cppindex 4d68975ec..0d8b597ef 100644--- a/toonz/sources/toonz/menubar.cpp+++ b/toonz/sources/toonz/menubar.cpp@@ -1218,6 +1218,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {addMenuItem(xsheetMenu, MI_Resequence);addMenuItem(xsheetMenu, MI_CloneChild);addMenuItem(xsheetMenu, MI_ExplodeChild);+ addMenuItem(xsheetMenu, MI_ToggleEditInPlace);xsheetMenu->addSeparator();addMenuItem(xsheetMenu, MI_ApplyMatchLines);addMenuItem(xsheetMenu, MI_MergeCmapped);diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cppindex e63e27a2f..b0153edf9 100644--- a/toonz/sources/toonz/sceneviewer.cpp+++ b/toonz/sources/toonz/sceneviewer.cpp@@ -278,6 +278,7 @@ void ToggleCommandHandler::execute() {//-----------------------------------------------------------------------------ToggleCommandHandler viewTableToggle(MI_ViewTable, false);+ToggleCommandHandler editInPlaceToggle(MI_ToggleEditInPlace, false);ToggleCommandHandler fieldGuideToggle(MI_FieldGuide, false);ToggleCommandHandler safeAreaToggle(MI_SafeArea, false);ToggleCommandHandler rasterizePliToggle(MI_RasterizePli, false);@@ -1587,8 +1588,8 @@ void SceneViewer::drawScene() {clipRect += TPoint(width() * 0.5, height() * 0.5);ChildStack *childStack = scene->getChildStack();- bool editInPlace =- childStack->getEditInPlace() && !app->getCurrentFrame()->isEditingLevel();+ bool editInPlace = editInPlaceToggle.getStatus() &&+ !app->getCurrentFrame()->isEditingLevel();bool fillFullColorRaster = TXshSimpleLevel::m_fillFullColorRaster;TXshSimpleLevel::m_fillFullColorRaster = false;diff --git a/toonz/sources/toonz/subscenecommand.cpp b/toonz/sources/toonz/subscenecommand.cppindex 07ab17f5d..c3cc04069 100644--- a/toonz/sources/toonz/subscenecommand.cpp+++ b/toonz/sources/toonz/subscenecommand.cpp@@ -1071,19 +1071,6 @@ void closeSubXsheet(int dlevel) {//=============================================================================-void toggleEditInPlace() {- TApp *app = TApp::instance();- ToonzScene *scene = app->getCurrentScene()->getScene();- int ancestorCount = scene->getChildStack()->getAncestorCount();- if (ancestorCount == 0) return;- scene->getChildStack()->setEditInPlace(- !scene->getChildStack()->getEditInPlace());- /*- Notify the change in order to update the viewer -*/- app->instance()->getCurrentXsheet()->notifyXsheetChanged();-}--//=============================================================================-void bringPegbarsInsideChildXsheet(TXsheet *xsh, TXsheet *childXsh) {// retrieve all pegbars used from copied columnsstd::set<TStageObjectId> pegbarIds;@@ -2114,16 +2101,6 @@ public:void execute() override { closeSubXsheet(1); }} closeChildCommand;-//=============================================================================-// ToggleEditInPlaceCommand-//-------------------------------------------------------------------------------class ToggleEditInPlaceCommand final : public MenuItemHandler {-public:- ToggleEditInPlaceCommand() : MenuItemHandler(MI_ToggleEditInPlace) {}- void execute() override { toggleEditInPlace(); }-} toggleEditInPlaceCommand;-//=============================================================================// collapseColumns//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrcindex a199c33aa..b76e317e2 100644--- a/toonz/sources/toonz/toonz.qrc+++ b/toonz/sources/toonz/toonz.qrc@@ -72,6 +72,7 @@<file>Resources/desktop.svg</file><file>Resources/downTitle.png</file><file>Resources/edit.svg</file>+ <file>Resources/edit_in_place.svg</file><file>Resources/edit_rollover.svg</file><file>Resources/emptychip.png</file><file>Resources/eraser.png</file>diff --git a/toonz/sources/toonz/xshtoolbar.cpp b/toonz/sources/toonz/xshtoolbar.cppindex eafafb5b4..f75047940 100644--- a/toonz/sources/toonz/xshtoolbar.cpp+++ b/toonz/sources/toonz/xshtoolbar.cpp@@ -1,21 +1,18 @@--#include "xshtoolbar.h"// Tnz6 includes#include "xsheetviewer.h"#include "tapp.h"#include "menubarcommandids.h"-// TnzQt includes-#include "toonzqt/gutil.h"+#include "commandbarpopup.h"// TnzLib includes#include "toonz/preferences.h"+#include "toonz/toonzscene.h"#include "toonz/tscenehandle.h"-#include "toonzqt/menubarcommand.h"+#include "toonz/childstack.h"// Qt includes-#include <QPushButton>#include <QWidgetAction>//=============================================================================@@ -32,60 +29,12 @@ XSheetToolbar::XSheetToolbar(XsheetViewer *parent, Qt::WindowFlags flags,#elseXSheetToolbar::XSheetToolbar(XsheetViewer *parent, Qt::WFlags flags)#endif- : QToolBar(parent), m_viewer(parent), m_isCollapsible(isCollapsible) {+ : CommandBar(parent, flags, isCollapsible, true)+ , m_viewer(parent)+ , m_isCollapsible(isCollapsible) {setObjectName("cornerWidget");setFixedHeight(30);setObjectName("XSheetToolbar");-- TApp *app = TApp::instance();- m_keyFrameButton = new ViewerKeyframeNavigator(this, app->getCurrentFrame());- m_keyFrameButton->setObjectHandle(app->getCurrentObject());- m_keyFrameButton->setXsheetHandle(app->getCurrentXsheet());-- QWidgetAction *keyFrameAction = new QWidgetAction(this);- keyFrameAction->setDefaultWidget(m_keyFrameButton);-- {- QAction *newVectorLevel =- CommandManager::instance()->getAction("MI_NewVectorLevel");- addAction(newVectorLevel);- QAction *newToonzRasterLevel =- CommandManager::instance()->getAction("MI_NewToonzRasterLevel");- addAction(newToonzRasterLevel);- QAction *newRasterLevel =- CommandManager::instance()->getAction("MI_NewRasterLevel");- addAction(newRasterLevel);- addSeparator();- QAction *reframeOnes = CommandManager::instance()->getAction("MI_Reframe1");- addAction(reframeOnes);- QAction *reframeTwos = CommandManager::instance()->getAction("MI_Reframe2");- addAction(reframeTwos);- QAction *reframeThrees =- CommandManager::instance()->getAction("MI_Reframe3");- addAction(reframeThrees);-- addSeparator();-- QAction *repeat = CommandManager::instance()->getAction("MI_Dup");- addAction(repeat);-- addSeparator();-- QAction *collapse = CommandManager::instance()->getAction("MI_Collapse");- addAction(collapse);- QAction *open = CommandManager::instance()->getAction("MI_OpenChild");- addAction(open);- QAction *leave = CommandManager::instance()->getAction("MI_CloseChild");- addAction(leave);-- addSeparator();- addAction(keyFrameAction);-- if (!Preferences::instance()->isShowXSheetToolbarEnabled() &&- m_isCollapsible) {- hide();- }- }}//-----------------------------------------------------------------------------@@ -113,6 +62,28 @@ void XSheetToolbar::showEvent(QShowEvent *e) {emit updateVisibility();}+//-----------------------------------------------------------------------------++void XSheetToolbar::contextMenuEvent(QContextMenuEvent *event) {+ QMenu *menu = new QMenu(this);+ QAction *customizeCommandBar =+ menu->addAction(tr("Customize XSheet Toolbar"));+ connect(customizeCommandBar, SIGNAL(triggered()),+ SLOT(doCustomizeCommandBar()));+ menu->exec(event->globalPos());+}++//-----------------------------------------------------------------------------++void XSheetToolbar::doCustomizeCommandBar() {+ CommandBarPopup *cbPopup = new CommandBarPopup(true);++ if (cbPopup->exec()) {+ fillToolbar(this, true);+ }+ delete cbPopup;+}+//============================================================class ToggleXSheetToolbarCommand final : public MenuItemHandler {diff --git a/toonz/sources/toonz/xshtoolbar.h b/toonz/sources/toonz/xshtoolbar.hindex 0ca8690f8..5437fdb68 100644--- a/toonz/sources/toonz/xshtoolbar.h+++ b/toonz/sources/toonz/xshtoolbar.h@@ -6,17 +6,16 @@#include <memory>#include "toonz/txsheet.h"-#include "toonz/txshleveltypes.h"+#include "commandbar.h"#include "toonzqt/keyframenavigator.h"-#include <QFrame>#include <QToolBar>//-----------------------------------------------------------------------------// forward declarationclass XsheetViewer;-class QPushButton;+class QAction;//-----------------------------------------------------------------------------@@ -26,11 +25,10 @@ namespace XsheetGUI {// XSheet Toolbar//------------------------------------------------------------------------------class XSheetToolbar final : public QToolBar {+class XSheetToolbar final : public CommandBar {Q_OBJECTXsheetViewer *m_viewer;- ViewerKeyframeNavigator *m_keyFrameButton;bool m_isCollapsible;public:@@ -47,6 +45,10 @@ signals:protected:void showEvent(QShowEvent *e) override;+ void contextMenuEvent(QContextMenuEvent *event) override;++protected slots:+ void doCustomizeCommandBar();};} // namespace XsheetGUI;diff --git a/toonz/sources/toonzlib/childstack.cpp b/toonz/sources/toonzlib/childstack.cppindex 2e1af159e..587e7916e 100644--- a/toonz/sources/toonzlib/childstack.cpp+++ b/toonz/sources/toonzlib/childstack.cpp@@ -32,7 +32,7 @@ public:// ChildStackChildStack::ChildStack(ToonzScene *scene)- : m_scene(scene), m_xsheet(new TXsheet()), m_editInPlace(false) {+ : m_scene(scene), m_xsheet(new TXsheet()) {m_xsheet->setScene(m_scene);m_xsheet->addRef();}@@ -177,9 +177,3 @@ bool ChildStack::getAncestorAffine(TAffine &aff, int row) const {}return true;}--//-------------------------------------------------------------------------------void ChildStack::setEditInPlace(bool editInPlace) {- m_editInPlace = editInPlace;-}