Skip to content

Commit 66dbdcf

Browse files
committed
issue-81 added option to hide path in tooltips
1 parent b9e14c3 commit 66dbdcf

9 files changed

+103
-29
lines changed

src/config.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const QString Config::KEY_ELEMENT_ELEMENTFONTSIZE("element/elementFontSize");
5252
const QString Config::KEY_ELEMENT_ELEMENTFONTITALIC("element/elementFontItalic");
5353
const QString Config::KEY_ELEMENT_ELEMENTFONTBOLD("element/elementFontBold");
5454
const QString Config::KEY_ELEMENT_TEXT_TOOLTIP_IMAGE("element/showImagesOnTextTooltip");
55+
const QString Config::KEY_ELEMENT_TEXT_TOOLTIP_PATH("element/showPathOnTextTooltip");
5556

5657
// mainview
5758
const QString Config::KEY_MAIN_COMPACTVIEW("main/compactView");

src/config/configurationgeneraloptions.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void ConfigurationGeneralOptions::init(ApplicationData* data)
8888
ui->cbShowTagComplex->setChecked(Config::getBool(Config::KEY_MAIN_SHOWLTONTAGS, Config::ShowLOOnTagsDefault));
8989
ui->cbEnableMultiThreading->setChecked(_data->isMtEnabled());
9090
ui->cbLightTheme->setChecked(Config::getBool(Config::KEY_INFO_SHORTCUT_LIGHT_THEME, false));
91+
ui->cbShowPathInElementTooltip->setChecked(Config::getBool(Config::KEY_ELEMENT_TEXT_TOOLTIP_PATH, true));
9192
updateStatus();
9293
_started = true ;
9394
}
@@ -287,6 +288,14 @@ void ConfigurationGeneralOptions::on_cbLightTheme_stateChanged(int /*state*/)
287288
Config::saveBool(Config::KEY_INFO_SHORTCUT_LIGHT_THEME, ui->cbLightTheme->isChecked());
288289
}
289290

291+
void ConfigurationGeneralOptions::on_cbShowPathInElementTooltip_stateChanged(int /*state*/)
292+
{
293+
if(!_started) {
294+
return ;
295+
}
296+
Config::saveBool(Config::KEY_ELEMENT_TEXT_TOOLTIP_PATH, ui->cbShowPathInElementTooltip->isChecked());
297+
}
298+
290299
void ConfigurationGeneralOptions::on_cbEnableMultiThreading_stateChanged(int /*state*/)
291300
{
292301
if(!_started) {

src/config/configurationgeneraloptions.h

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ private slots:
7575
void on_cbShowTagComplex_stateChanged(int /*state*/);
7676
void on_cbEnableMultiThreading_stateChanged(int /*state*/);
7777
void on_cbLightTheme_stateChanged(int /*state*/);
78+
void on_cbShowPathInElementTooltip_stateChanged(int /*state*/);
7879
void on_cmdResetBehavior_clicked();
7980
};
8081

src/config/configurationgeneraloptions.ui

+41-27
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>799</width>
10-
<height>470</height>
10+
<height>486</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -204,13 +204,6 @@
204204
</item>
205205
<item>
206206
<layout class="QGridLayout" name="gridLayout_2">
207-
<item row="0" column="0">
208-
<widget class="QCheckBox" name="expandTreeAfterLoad">
209-
<property name="text">
210-
<string>Automatically expand editor tree when loading data</string>
211-
</property>
212-
</widget>
213-
</item>
214207
<item row="0" column="1">
215208
<layout class="QHBoxLayout" name="horizontalLayout_3">
216209
<item>
@@ -244,21 +237,56 @@
244237
</item>
245238
</layout>
246239
</item>
240+
<item row="3" column="1">
241+
<widget class="QCheckBox" name="cbShowTagComplex">
242+
<property name="text">
243+
<string>Show decorated element Tags</string>
244+
</property>
245+
</widget>
246+
</item>
247+
<item row="5" column="1">
248+
<widget class="QCheckBox" name="cbEnableMultiThreading">
249+
<property name="text">
250+
<string>Enable multithreading</string>
251+
</property>
252+
</widget>
253+
</item>
254+
<item row="4" column="1">
255+
<widget class="QToolButton" name="toolButton">
256+
<property name="text">
257+
<string>...</string>
258+
</property>
259+
</widget>
260+
</item>
261+
<item row="0" column="0">
262+
<widget class="QCheckBox" name="expandTreeAfterLoad">
263+
<property name="text">
264+
<string>Automatically expand editor tree when loading data</string>
265+
</property>
266+
</widget>
267+
</item>
268+
<item row="4" column="0">
269+
<widget class="QCheckBox" name="cbLightTheme">
270+
<property name="text">
271+
<string>Light theme</string>
272+
</property>
273+
</widget>
274+
</item>
247275
<item row="1" column="0">
248276
<widget class="QCheckBox" name="cbShowImagesInTextTooltip">
249277
<property name="text">
250278
<string>Show images in text tooltip</string>
251279
</property>
252280
</widget>
253281
</item>
254-
<item row="2" column="0">
282+
<item row="3" column="0">
255283
<widget class="QCheckBox" name="cbOpenFilesInNewWindow">
256284
<property name="text">
257285
<string>Open files in new window</string>
258286
</property>
259287
</widget>
260288
</item>
261-
<item row="4" column="0">
289+
<item row="5" column="0">
262290
<widget class="QCheckBox" name="cbSingleInstance">
263291
<property name="text">
264292
<string>Single instance application</string>
@@ -272,24 +300,10 @@
272300
</property>
273301
</widget>
274302
</item>
275-
<item row="2" column="1">
276-
<widget class="QCheckBox" name="cbShowTagComplex">
277-
<property name="text">
278-
<string>Show decorated element Tags</string>
279-
</property>
280-
</widget>
281-
</item>
282-
<item row="4" column="1">
283-
<widget class="QCheckBox" name="cbEnableMultiThreading">
284-
<property name="text">
285-
<string>Enable multithreading</string>
286-
</property>
287-
</widget>
288-
</item>
289-
<item row="3" column="0">
290-
<widget class="QCheckBox" name="cbLightTheme">
303+
<item row="2" column="0">
304+
<widget class="QCheckBox" name="cbShowPathInElementTooltip">
291305
<property name="text">
292-
<string>Light theme</string>
306+
<string>Show path in element tooltip</string>
293307
</property>
294308
</widget>
295309
</item>

src/element.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,12 @@ QVariant Element::columnViewTooltipData(QHash<void *, QString> *mapDataAnon)
520520
attributesLabel += tr(" Attributes:\n");
521521
}
522522

523-
QString tooltip = tr("%1\npath: %2\n%3").arg(theTag).arg(thePath).arg(attributesLabel);
523+
QString tooltip ;
524+
if(Config::getBool(Config::KEY_ELEMENT_TEXT_TOOLTIP_PATH, true)) {
525+
tooltip = tr("%1\npath: %2\n%3").arg(theTag).arg(thePath).arg(attributesLabel);
526+
} else {
527+
tooltip = tr("%1\n%2").arg(theTag).arg(attributesLabel);
528+
}
524529
// sort case insensitive
525530
QList<Attribute*> attributesList = Element::sortAttributesList(this->attributes);
526531
QString imageData ;

src/qxmleditconfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class LIBQXMLEDITSHARED_EXPORT Config
6161
static const QString KEY_ELEMENT_ELEMENTFONTITALIC;
6262
static const QString KEY_ELEMENT_ELEMENTFONTBOLD;
6363
static const QString KEY_ELEMENT_TEXT_TOOLTIP_IMAGE;
64+
static const QString KEY_ELEMENT_TEXT_TOOLTIP_PATH;
6465
// mainview
6566
static const QString KEY_MAIN_COMPACTVIEW;
6667
static const QString KEY_MAIN_ONEATTRLINE;

test/testelement.cpp

+41-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TestElement::~TestElement()
3838

3939
bool TestElement::testFast()
4040
{
41-
return testHasText();
41+
return testConfigTooltip();
4242
}
4343

4444

@@ -133,9 +133,49 @@ bool TestElement::testTooltip()
133133
if(!testSingleTooltip("11", 11, true)) {
134134
return false;
135135
}
136+
if(!testConfigTooltip()) {
137+
return false;
138+
}
139+
return true;
140+
}
141+
142+
bool TestElement::testConfigTooltip()
143+
{
144+
if(!testConfigTooltipInner(false, false, true)) {
145+
return false;
146+
}
147+
148+
if(!testConfigTooltipInner(true, false, false)) {
149+
return false;
150+
}
151+
if(!testConfigTooltipInner(true, true, true)) {
152+
return false;
153+
}
136154
return true;
137155
}
138156

157+
bool TestElement::testConfigTooltipInner(const bool setValue, const bool usePath, const bool expectedFoundPath)
158+
{
159+
App app;
160+
app.initNoWindow();
161+
// setup data
162+
Element element("A", "", NULL, NULL);
163+
Element *elementB = new Element("B", "", NULL, &element);
164+
element.addChild(elementB);
165+
// setup config
166+
if(setValue) {
167+
Config::saveBool(Config::KEY_ELEMENT_TEXT_TOOLTIP_PATH, usePath);
168+
}
169+
QVariant toolTip = elementB->columnViewTooltipData(NULL);
170+
const bool foundPath = toolTip.toString().contains("/A/B", Qt::CaseSensitive);
171+
if(foundPath!=expectedFoundPath) {
172+
return error(QString("Error tooltip inner for setValue:%1 usePath:%2 expectedFoundPath:%3")
173+
.arg(setValue).arg(usePath).arg(expectedFoundPath));
174+
}
175+
return true ;
176+
}
177+
178+
139179
static bool probeForImageData(const QString &data)
140180
{
141181
if(!data.startsWith("<html>")) {

test/testelement.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class TestElement : public TestBase
3636
bool testNotHasTextComplex();
3737
bool testNotHasTextSingle();
3838
bool testParentPath();
39+
bool testConfigTooltipInner(const bool setValue, const bool usePath, const bool expectedPath);
40+
bool testConfigTooltip();
3941
public:
4042
TestElement();
4143
~TestElement();

test/tst_qxmledit.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,7 @@ void TestQXmlEdit::testNew()
16671667
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
16681668
qInstallMessageHandler(msgHandler);
16691669
#endif
1670+
testElement();
16701671
}
16711672

16721673
QTEST_MAIN(TestQXmlEdit)

0 commit comments

Comments
 (0)