Add disable tool preference

This commit is contained in:
manongjohn 2019-01-31 06:35:38 -05:00
parent 290f2aa809
commit d754974e14
5 changed files with 36 additions and 24 deletions

View file

@ -401,8 +401,8 @@ public:
void enableCursorOutline(bool on);
bool isCursorOutlineEnabled() const { return m_cursorOutlineEnabled; }
void enableShowLevelBasedTools(bool on);
bool isShowLevelBasedToolsEnabled() const { return m_showLevelBasedTools; }
void setLevelBasedToolsDisplay(int displayType);
int getLevelBasedToolsDisplay() const { return m_levelBasedToolsDisplay; }
// Xsheet tab
void setXsheetStep(int step); //!< Sets the step used for the <I>next/prev
@ -727,7 +727,7 @@ private:
bool m_enableWinInk = false;
bool m_useOnionColorsForShiftAndTraceGhosts = false;
bool m_showLevelBasedTools = false;
int m_levelBasedToolsDisplay;
private:
Preferences();

View file

@ -1254,8 +1254,8 @@ void PreferencesPopup::onRasterBackgroundColorChanged(const TPixel32 &color,
//-----------------------------------------------------------------------------
void PreferencesPopup::onShowLevelBasedToolsChanged(int index) {
m_pref->enableShowLevelBasedTools(index == Qt::Checked);
void PreferencesPopup::onLevelBasedToolsDisplayChanged(int index) {
m_pref->setLevelBasedToolsDisplay(index);
TApp::instance()->getCurrentLevel()->notifyLevelChange();
}
@ -1488,8 +1488,12 @@ PreferencesPopup::PreferencesPopup()
CheckBox *cursorOutlineCB =
new CheckBox(tr("Show Cursor Size Outlines"), this);
CheckBox *showLevelBasedToolsCB =
new CheckBox(tr("Show Only Level-Based Tools In Toolbar"), this);
QStringList leveBasedToolsDisplayTypes;
leveBasedToolsDisplayTypes << tr("Default")
<< tr("Enable Tools For Level Only")
<< tr("Show Tools For Level Only");
m_levelBasedToolsDisplayCB = new QComboBox(this);
m_levelBasedToolsDisplayCB->addItems(leveBasedToolsDisplayTypes);
//--- Xsheet ------------------------------
categoryList->addItem(tr("Xsheet"));
@ -1888,7 +1892,8 @@ PreferencesPopup::PreferencesPopup()
m_cursorBrushStyle->findData(m_pref->getCursorBrushStyle()));
cursorOutlineCB->setChecked(m_pref->isCursorOutlineEnabled());
showLevelBasedToolsCB->setChecked(m_pref->isShowLevelBasedToolsEnabled());
m_levelBasedToolsDisplayCB->setCurrentIndex(
m_pref->getLevelBasedToolsDisplay());
//--- Xsheet ------------------------------
xsheetAutopanDuringPlaybackCB->setChecked(m_pref->isXsheetAutopanEnabled());
@ -2473,7 +2478,9 @@ PreferencesPopup::PreferencesPopup()
}
ToolsTopLay->addWidget(cursorStyleGroupBox, 3, 0, 1, 3);
ToolsTopLay->addWidget(showLevelBasedToolsCB, 4, 0, 1, 3);
ToolsTopLay->addWidget(new QLabel(tr("Toolbar Display Behaviour:")), 4,
0, Qt::AlignRight | Qt::AlignVCenter);
ToolsTopLay->addWidget(m_levelBasedToolsDisplayCB, 4, 1);
}
toolsFrameLay->addLayout(ToolsTopLay, 0);
@ -2963,8 +2970,9 @@ PreferencesPopup::PreferencesPopup()
this, SLOT(onCursorBrushStyleChanged(int)));
ret = ret && connect(cursorOutlineCB, SIGNAL(stateChanged(int)), this,
SLOT(onCursorOutlineChanged(int)));
ret = ret && connect(showLevelBasedToolsCB, SIGNAL(stateChanged(int)),
SLOT(onShowLevelBasedToolsChanged(int)));
ret = ret &&
connect(m_levelBasedToolsDisplayCB, SIGNAL(currentIndexChanged(int)),
SLOT(onLevelBasedToolsDisplayChanged(int)));
//--- Xsheet ----------------------
ret = ret && connect(xsheetAutopanDuringPlaybackCB, SIGNAL(stateChanged(int)),

View file

@ -57,7 +57,8 @@ private:
*m_columnIconOm, *m_unitOm, *m_cameraUnitOm, *m_importPolicy,
*m_vectorSnappingTargetCB, *m_dropdownShortcutsCycleOptionsCB,
*m_guidedDrawingStyle, *m_functionEditorToggle, *m_cursorBrushType,
*m_cursorBrushStyle, *m_xsheetLayout, *m_interfaceFontStyle;
*m_cursorBrushStyle, *m_xsheetLayout, *m_interfaceFontStyle,
*m_levelBasedToolsDisplayCB;
QFontComboBox *m_interfaceFont;
@ -83,8 +84,7 @@ private:
*m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB,
*m_syncLevelRenumberWithXsheet, *m_downArrowInLevelStripCreatesNewFrame,
*m_enableAutoStretch, *m_enableWinInk,
*m_useOnionColorsForShiftAndTraceCB,
*m_showLevelBasedTools;
*m_useOnionColorsForShiftAndTraceCB;
DVGui::FileField *m_customProjectRootFileField;
@ -222,7 +222,7 @@ private slots:
void onCurrentColumnDataChanged(const TPixel32 &, bool isDragging);
void onEnableWinInkChanged(int index);
void onRasterBackgroundColorChanged(const TPixel32 &, bool isDragging);
void onShowLevelBasedToolsChanged(int);
void onLevelBasedToolsDisplayChanged(int);
};
//**********************************************************************************

View file

@ -157,7 +157,7 @@ void Toolbar::updateToolbar(bool forceReset) {
removeAction(m_expandAction);
bool showLevelBased = Preferences::instance()->isShowLevelBasedToolsEnabled();
int levelBasedDisplay = Preferences::instance()->getLevelBasedToolsDisplay();
bool actionEnabled = false;
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
@ -167,7 +167,7 @@ void Toolbar::updateToolbar(bool forceReset) {
if (tool) tool->updateEnabled(rowIndex, colIndex);
bool isSeparator = !strncmp(buttonLayout[idx].toolName, "Separator", 9);
bool enable =
!showLevelBased ? true : (!tool ? actionEnabled : tool->isEnabled());
!levelBasedDisplay ? true : (!tool ? actionEnabled : tool->isEnabled());
// Plastic tool should always be available so you can create a mesh
if (!enable && !strncmp(buttonLayout[idx].toolName, T_Plastic, 9) &&
@ -182,8 +182,12 @@ void Toolbar::updateToolbar(bool forceReset) {
CommandManager::instance()->getAction(buttonLayout[idx].toolName);
}
// Unhide if it meets the criteria for showing
if (!enable || (!m_isExpanded && buttonLayout[idx].collapsable)) continue;
if (!m_isExpanded && buttonLayout[idx].collapsable) continue;
if (levelBasedDisplay != 2)
buttonLayout[idx].action->setEnabled(enable);
else if (!enable)
continue;
actionEnabled = addAction(buttonLayout[idx].action) || actionEnabled;

View file

@ -348,7 +348,7 @@ Preferences::Preferences()
, m_enableWinInk(false)
, m_useOnionColorsForShiftAndTraceGhosts(false)
, m_rasterBackgroundColor(TPixel::White)
, m_showLevelBasedTools(false) {
, m_levelBasedToolsDisplay(0) {
TCamera camera;
m_defLevelType = PLI_XSHLEVEL;
m_defLevelWidth = camera.getSize().lx;
@ -728,7 +728,7 @@ Preferences::Preferences()
getValue(*m_settings, "rasterBackgroundColor", m_rasterBackgroundColor);
TImageWriter::setBackgroundColor(m_rasterBackgroundColor);
getValue(*m_settings, "showLevelBasedTools", m_showLevelBasedTools);
getValue(*m_settings, "levelBasedToolsDisplay", m_levelBasedToolsDisplay);
}
//-----------------------------------------------------------------
@ -1777,7 +1777,7 @@ void Preferences::setRasterBackgroundColor(const TPixel32 &color) {
QString::number((int)color.m));
}
void Preferences::enableShowLevelBasedTools(bool on) {
m_showLevelBasedTools = on;
m_settings->setValue("showLevelBasedTools", on ? "1" : "0");
void Preferences::setLevelBasedToolsDisplay(int displayType) {
m_levelBasedToolsDisplay = displayType;
m_settings->setValue("levelBasedToolsDisplay", displayType);
}