Qt Editor: Add toggle help button to "?" menu

qteditor
Sven Eberhardt 2016-07-25 21:39:35 -04:00
parent 5f9259c27f
commit 11b317808f
10 changed files with 68 additions and 14 deletions

View File

@ -89,6 +89,8 @@ IDS_CNS_SCRIPT=Script
IDS_CNS_SCRIPTCREATEDOBJECTS=Das Script dieses Szenarios hat beim Start der Runde Objekte erschaffen.
IDS_CNS_SELECTNEARBYOBJECTS=Objekt auswählen
IDS_CNS_SELECTCONTENTS=%s Inhalt...
IDS_CNS_SHOWHELP=Hilfetexte anzeigen
IDS_CNS_SHOWHELPTIP=Aktiviert oder deaktiviert Objektbeschreibungen und Tooltip-Marker (?) im Objekteigenschaftsdialog.
IDS_CNS_TITLE=Titel
IDS_CNS_TRUE=Ja
IDS_CNS_TYPE=Typ: %s (%s)

View File

@ -89,6 +89,8 @@ IDS_CNS_SCRIPT=Script
IDS_CNS_SCRIPTCREATEDOBJECTS=This scenario's script has created objects on initialization.
IDS_CNS_SELECTNEARBYOBJECTS=Select object
IDS_CNS_SELECTCONTENTS=%s contents...
IDS_CNS_SHOWHELP=Show help texts
IDS_CNS_SHOWHELPTIP=Activates or deactivates object descriptions and tooltip markers (?) in the object property dialogue.
IDS_CNS_TITLE=Title
IDS_CNS_TRUE=Yes
IDS_CNS_TYPE=Type: %s (%s)

View File

@ -86,6 +86,7 @@ void C4ConfigDeveloper::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(s(AltTodoFilename), "AltTodoFilename2", "{USERPATH}/TODO.txt", false, true));
pComp->Value(mkNamingAdapt(MaxScriptMRU, "MaxScriptMRU", 30 , false, false));
pComp->Value(mkNamingAdapt(DebugShapeTextures, "DebugShapeTextures", 0 , false, true));
pComp->Value(mkNamingAdapt(ShowHelp, "ShowHelp", true , false, false));
for (int32_t i = 0; i < CFG_MaxEditorMRU; ++i)
pComp->Value(mkNamingAdapt(s(RecentlyEditedSzenarios[i]), FormatString("EditorMRU%02d", (int)i).getData(), "", false, false));
}

View File

@ -87,6 +87,7 @@ public:
char AltTodoFilename[CFG_MaxString + 1];
int32_t MaxScriptMRU; // maximum number of remembered elements in recently used scripts
int32_t DebugShapeTextures; // if nonzero, show messages about loaded shape textures
bool ShowHelp; // show help buttons and descriptions in editor
char RecentlyEditedSzenarios[CFG_MaxEditorMRU][CFG_MaxString + 1];
void CompileFunc(StdCompiler *pComp);
void AddRecentlyEditedScenario(const char *fn);

View File

@ -387,6 +387,7 @@
<property name="title">
<string comment="res">?</string>
</property>
<addaction name="actionHelp"/>
<addaction name="actionHelpAbout"/>
</widget>
<widget class="QMenu" name="menuWindows">
@ -1028,6 +1029,22 @@
<string comment="res">IDS_MNU_CONTENTS</string>
</property>
</action>
<action name="actionHelp">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="resource.qrc">
<normaloff>:/editor/res/HelpOff.png</normaloff>
<normalon>:/editor/res/Help.png</normalon>:/editor/res/HelpOff.png</iconset>
</property>
<property name="text">
<string comment="res">IDS_CNS_SHOWHELP</string>
</property>
<property name="toolTip">
<string comment="res">IDS_CNS_SHOWHELPTIP</string>
</property>
</action>
</widget>
<resources>
<include location="resource.qrc"/>
@ -1552,8 +1569,8 @@
<slot>AddArrayElement()</slot>
<hints>
<hint type="sourcelabel">
<x>756</x>
<y>116</y>
<x>813</x>
<y>146</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
@ -1568,8 +1585,8 @@
<slot>RemoveArrayElement()</slot>
<hints>
<hint type="sourcelabel">
<x>886</x>
<y>116</y>
<x>953</x>
<y>146</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
@ -1641,6 +1658,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionHelp</sender>
<signal>toggled(bool)</signal>
<receiver>MainWindow</receiver>
<slot>HelpToggle(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
<y>312</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>PlayPressed(bool)</slot>
@ -1680,5 +1713,6 @@
<slot>SelectionDelete()</slot>
<slot>SelectionDuplicate()</slot>
<slot>SelectionEjectContents()</slot>
<slot>HelpToggle(bool)</slot>
</slots>
</ui>

View File

@ -558,18 +558,21 @@ QColor C4PropertyDelegateColor::GetDisplayBackgroundColor(const C4Value &val, cl
bool C4StyledItemDelegateWithHelpButton::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
// Mouse move over a cell: Display tooltip if over help button
if (event->type() == QEvent::MouseMove)
if (Config.Developer.ShowHelp)
{
QVariant help_btn = model->data(index, Qt::DecorationRole);
if (!help_btn.isNull())
if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mevent = static_cast<QMouseEvent *>(event);
if (option.rect.contains(mevent->localPos().toPoint()))
QVariant help_btn = model->data(index, Qt::DecorationRole);
if (!help_btn.isNull())
{
if (mevent->localPos().x() >= option.rect.x() + option.rect.width() - option.rect.height())
QMouseEvent *mevent = static_cast<QMouseEvent *>(event);
if (option.rect.contains(mevent->localPos().toPoint()))
{
QString tooltip_text = model->data(index, Qt::ToolTipRole).toString();
QToolTip::showText(mevent->globalPos(), tooltip_text);
if (mevent->localPos().x() >= option.rect.x() + option.rect.width() - option.rect.height())
{
QString tooltip_text = model->data(index, Qt::ToolTipRole).toString();
QToolTip::showText(mevent->globalPos(), tooltip_text);
}
}
}
}
@ -2055,7 +2058,7 @@ QVariant C4ConsoleQtPropListModel::data(const QModelIndex & index, int role) con
QColor txtclr = prop->delegate->GetDisplayTextColor(v, target_value.getObj());
if (txtclr.isValid()) return txtclr;
}
else if (role == Qt::DecorationRole && index.column() == 0 && prop->help_text)
else if (role == Qt::DecorationRole && index.column() == 0 && prop->help_text && Config.Developer.ShowHelp)
{
// Help icons in left column
return QIcon(":/editor/res/Help.png");

View File

@ -288,6 +288,13 @@ void C4ConsoleQtMainWindow::ViewportNew() { ::Console.ViewportNew(); }
// Help menu
void C4ConsoleQtMainWindow::HelpAbout() { ::Console.HelpAbout(); }
void C4ConsoleQtMainWindow::HelpToggle(bool enabled)
{
::Config.Developer.ShowHelp = enabled;
::Console.EditCursor.InvalidateSelection();
repaint();
}
// Script enter
void C4ConsoleQtMainWindow::MainConsoleEditEnter()
{
@ -528,6 +535,8 @@ bool C4ConsoleGUIState::CreateConsoleWindow(C4AbstractApp *app)
QWidget *foo = new QWidget(viewport_area);
viewport_area->setCentralWidget(foo);
foo->hide();
// Default action state
ui.actionHelp->setChecked(::Config.Developer.ShowHelp);
// Property editor
property_delegate_factory.reset(new C4PropertyDelegateFactory());
@ -755,7 +764,7 @@ void C4ConsoleGUIState::PropertyDlgUpdate(C4EditCursorSelection &rSelection, boo
}
ui.selectionInfoLabel->setText(property_model->GetTargetPathText());
const char *help_text = property_model->GetTargetPathHelp();
if (help_text)
if (help_text && ::Config.Developer.ShowHelp)
{
ui.selectionHelpLabel->setText(FormatString("%s: %s", LoadResStr("IDS_CNS_DESCRIPTION"), help_text).getData());
ui.selectionHelpLabel->show();

View File

@ -123,6 +123,7 @@ public slots:
void ViewportNew();
// Help menu
void HelpAbout();
void HelpToggle(bool enabled);
// Console edits enter pressed events
void MainConsoleEditEnter(); // console edit below log
void PropertyConsoleEditEnter(); // console edit of property window

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/editor">
<file>../res/HelpOff.png</file>
<file>../res/Help.png</file>
<file>../res/StaticFlat_Trans.png</file>
<file>../res/CreateObj_Trans.png</file>

BIN
src/res/HelpOff.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB