From 11b317808fdfe76f561ef065e555e872724d1f47 Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Mon, 25 Jul 2016 21:39:35 -0400 Subject: [PATCH] Qt Editor: Add toggle help button to "?" menu --- planet/System.ocg/LanguageDE.txt | 2 ++ planet/System.ocg/LanguageUS.txt | 2 ++ src/config/C4Config.cpp | 1 + src/config/C4Config.h | 1 + src/editor/C4ConsoleQtMainWindow.ui | 42 ++++++++++++++++++++--- src/editor/C4ConsoleQtPropListViewer.cpp | 21 +++++++----- src/editor/C4ConsoleQtState.cpp | 11 +++++- src/editor/C4ConsoleQtState.h | 1 + src/editor/resource.qrc | 1 + src/res/HelpOff.png | Bin 0 -> 1299 bytes 10 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 src/res/HelpOff.png diff --git a/planet/System.ocg/LanguageDE.txt b/planet/System.ocg/LanguageDE.txt index 0815ebfea..72bf3ad4b 100644 --- a/planet/System.ocg/LanguageDE.txt +++ b/planet/System.ocg/LanguageDE.txt @@ -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) diff --git a/planet/System.ocg/LanguageUS.txt b/planet/System.ocg/LanguageUS.txt index 2dc300cc4..21c7923a3 100644 --- a/planet/System.ocg/LanguageUS.txt +++ b/planet/System.ocg/LanguageUS.txt @@ -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) diff --git a/src/config/C4Config.cpp b/src/config/C4Config.cpp index 51f825d06..f94e59cc7 100644 --- a/src/config/C4Config.cpp +++ b/src/config/C4Config.cpp @@ -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)); } diff --git a/src/config/C4Config.h b/src/config/C4Config.h index aba301ad2..c8901c0e3 100644 --- a/src/config/C4Config.h +++ b/src/config/C4Config.h @@ -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); diff --git a/src/editor/C4ConsoleQtMainWindow.ui b/src/editor/C4ConsoleQtMainWindow.ui index b562a11b4..d139bad03 100644 --- a/src/editor/C4ConsoleQtMainWindow.ui +++ b/src/editor/C4ConsoleQtMainWindow.ui @@ -387,6 +387,7 @@ ? + @@ -1028,6 +1029,22 @@ IDS_MNU_CONTENTS + + + true + + + + :/editor/res/HelpOff.png + :/editor/res/Help.png:/editor/res/HelpOff.png + + + IDS_CNS_SHOWHELP + + + IDS_CNS_SHOWHELPTIP + + @@ -1552,8 +1569,8 @@ AddArrayElement() - 756 - 116 + 813 + 146 477 @@ -1568,8 +1585,8 @@ RemoveArrayElement() - 886 - 116 + 953 + 146 477 @@ -1641,6 +1658,22 @@ + + actionHelp + toggled(bool) + MainWindow + HelpToggle(bool) + + + -1 + -1 + + + 477 + 312 + + + PlayPressed(bool) @@ -1680,5 +1713,6 @@ SelectionDelete() SelectionDuplicate() SelectionEjectContents() + HelpToggle(bool) diff --git a/src/editor/C4ConsoleQtPropListViewer.cpp b/src/editor/C4ConsoleQtPropListViewer.cpp index e271d9d44..bf49b10ab 100644 --- a/src/editor/C4ConsoleQtPropListViewer.cpp +++ b/src/editor/C4ConsoleQtPropListViewer.cpp @@ -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(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(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"); diff --git a/src/editor/C4ConsoleQtState.cpp b/src/editor/C4ConsoleQtState.cpp index 6de9e6b89..d6d269049 100644 --- a/src/editor/C4ConsoleQtState.cpp +++ b/src/editor/C4ConsoleQtState.cpp @@ -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(); diff --git a/src/editor/C4ConsoleQtState.h b/src/editor/C4ConsoleQtState.h index aea95c1d3..4990dd503 100644 --- a/src/editor/C4ConsoleQtState.h +++ b/src/editor/C4ConsoleQtState.h @@ -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 diff --git a/src/editor/resource.qrc b/src/editor/resource.qrc index 7a68f40c0..f7eba30e4 100644 --- a/src/editor/resource.qrc +++ b/src/editor/resource.qrc @@ -1,5 +1,6 @@ + ../res/HelpOff.png ../res/Help.png ../res/StaticFlat_Trans.png ../res/CreateObj_Trans.png diff --git a/src/res/HelpOff.png b/src/res/HelpOff.png new file mode 100644 index 0000000000000000000000000000000000000000..5a0f368b5bdc75d1826b4cb337304af9745546df GIT binary patch literal 1299 zcmV+u1?>8XP)WFU8GbZ8()Nlj2>E@cM*00ehQL_t(o!=+cfODkCv zKX)=Q&P1<-z9Nt! z%@Y)hfQqOg31i|UlbbtRtP^hLBN^YjFwDL4aenul-#O==gTUrUBoczh=lLy!5R1_N zzaWG_n*#t4LVyqg00640;##eCTB%fyBaz6DpWZ+&mpkxyJiDr@c7$u-`k|_-=_N_h z;mXR&-lsN@OeW_7fxs!tvcC~RKvh*sV5<#K)_`WSnJ<^iTV~cUNW8eX_%c2|9w&r| znlLLs{hYqj8~9k4N~O|9I2`^?%VG4IkByDl0;ey7R+Oc*_YA{`qA13b$>bdUElV$^ zrlwBY?Y3wp@agFZuCK4*;o$))l?uqR41^Fs2m!+|;C8zq5D381(h>|051aFikm&RI zP66O|0|kXb;eg|~U5s&O=Ln(BeSd%7R=6UBV0n2N78e&g(V?fOR;wL`LZQ751*ueO z&h2*ZDvHu&Rt@|!LseDCX0vd6duyOcn+t-lt5LxM0Qmj>Si9Y}-BB`fB{@@*6r&-0e_=?5XC%3zF(W|~@U2ms*q_0=FO z91eranSAOF7sZt)$KWjT%j0J7Qa--00g)z1prI668q2#v*JmZ{iG zds&wM357ym82|uDl8$>7msU>NFL&s2e^<7Be}6yj)B}-7n!di{{*{HK~zp66p6$8G8R2))+2By%du@~<_g z`u3dTxDBV%8FV-t3l4{4l3|z;?Nq}U7YQMSR;%?*mSx-R`G28D>>RHKSy2E0002ov JPDHLkV1mM3W-kB$ literal 0 HcmV?d00001