comparison widgets/PropertyBox.cpp @ 1380:78eecb19e688

Make the context help for custom controls explain how to reset them
author Chris Cannam
date Tue, 06 Nov 2018 15:42:06 +0000
parents d18ca558049e
children c8a6fd3f9dff
comparison
equal deleted inserted replaced
1378:f08a3b8cdb9d 1380:78eecb19e688
800 800
801 if (!m_container) return; 801 if (!m_container) return;
802 QString cname = m_container->getPropertyContainerName(); 802 QString cname = m_container->getPropertyContainerName();
803 if (cname == "") return; 803 if (cname == "") return;
804 804
805 QString help;
806 QString mainText;
807 QString extraText;
808 QString editText;
809
810 QString wname = w->objectName();
811 QString propertyLabel;
812 if (wname != "") {
813 propertyLabel = m_container->getPropertyLabel(wname);
814 }
815
805 LevelPanToolButton *lp = qobject_cast<LevelPanToolButton *>(w); 816 LevelPanToolButton *lp = qobject_cast<LevelPanToolButton *>(w);
817 AudioDial *dial = qobject_cast<AudioDial *>(w);
818
806 if (lp) { 819 if (lp) {
807 emit contextHelpChanged(tr("Adjust playback level and pan of %1").arg(cname)); 820
808 return; 821 mainText = tr("Adjust playback level and pan of %1").arg(cname);
809 } 822 editText = tr("click then drag to adjust, ctrl+click to reset");
810 823
811 QString wname = w->objectName(); 824 } else if (wname == "playParamButton") {
812 825
813 if (wname == "playParamButton") {
814 PlayParameters *params = m_container->getPlayParameters(); 826 PlayParameters *params = m_container->getPlayParameters();
815 if (params) { 827 if (params) {
816 emit contextHelpChanged 828 help = tr("Change sound used for playback (currently \"%1\")")
817 (tr("Change sound used for playback (currently \"%1\")") 829 .arg(params->getPlayClipId());
818 .arg(params->getPlayClipId())); 830 }
819 return; 831
820 } 832 } else if (dial) {
821 } 833
822
823 QString extraText;
824
825 AudioDial *dial = qobject_cast<AudioDial *>(w);
826 if (dial) {
827 double mv = dial->mappedValue(); 834 double mv = dial->mappedValue();
828 QString unit = ""; 835 QString unit = "";
829 if (dial->rangeMapper()) unit = dial->rangeMapper()->getUnit(); 836 if (dial->rangeMapper()) unit = dial->rangeMapper()->getUnit();
830 if (unit != "") { 837 if (unit != "") {
831 extraText = tr(" (current value: %1%2)").arg(mv).arg(unit); 838 extraText = tr(" (current value: %1%2)").arg(mv).arg(unit);
832 } else { 839 } else {
833 extraText = tr(" (current value: %1)").arg(mv); 840 extraText = tr(" (current value: %1)").arg(mv);
834 } 841 }
835 } 842 editText = tr("drag up/down to adjust, ctrl+click to reset");
836 843
837 QString propertyLabel; 844 } else if (w == m_showButton) {
838 if (wname != "") { 845 help = tr("Toggle Visibility of %1").arg(cname);
839 propertyLabel = m_container->getPropertyLabel(wname); 846
840 }
841
842 if (w == m_showButton) {
843 emit contextHelpChanged(tr("Toggle Visibility of %1").arg(cname));
844 } else if (w == m_playButton) { 847 } else if (w == m_playButton) {
845 emit contextHelpChanged(tr("Toggle Playback of %1").arg(cname)); 848 help = tr("Toggle Playback of %1").arg(cname);
846 } else if (wname == "") { 849
847 return; 850 }
848 } else if (qobject_cast<QAbstractButton *>(w)) { 851
849 emit contextHelpChanged(tr("Toggle %1 property of %2") 852 if (help == "" && wname != "") {
850 .arg(propertyLabel).arg(cname)); 853
851 } else { 854 if (qobject_cast<QAbstractButton *>(w)) {
852 emit contextHelpChanged(tr("Adjust %1 property of %2%3") 855 mainText = tr("Toggle %1 property of %2")
853 .arg(propertyLabel).arg(cname).arg(extraText)); 856 .arg(propertyLabel).arg(cname);
857
858 } else {
859
860 // Last param empty for historical reasons, to avoid
861 // changing tr() string
862 mainText = tr("Adjust %1 property of %2%3")
863 .arg(propertyLabel).arg(cname).arg("");
864 }
865 }
866
867 if (help == "") {
868 if (mainText != "") {
869 if (editText != "") {
870 help = tr("%1%2: %3")
871 .arg(mainText).arg(extraText).arg(editText);
872 } else {
873 help = tr("%1%2")
874 .arg(mainText).arg(extraText);
875 }
876 }
877 }
878
879 if (help != "") {
880 emit contextHelpChanged(help);
854 } 881 }
855 } 882 }
856 883
857 void 884 void
858 PropertyBox::mouseLeftWidget() 885 PropertyBox::mouseLeftWidget()