[krusader] krusader/Konfigurator: Konfigurator: Ease management of tooltips and “What's This” texts by changing create* functions. Add a tooltip also useful as a test item
Toni Asensi Esteve
null at kde.org
Fri May 15 00:55:13 BST 2020
Git commit 596dd0b2f0f374b75645049ce780ead201328305 by Toni Asensi Esteve.
Committed on 14/05/2020 at 23:43.
Pushed by asensi into branch 'master'.
Konfigurator: Ease management of tooltips and “What's This” texts by changing create* functions. Add a tooltip also useful as a test item
Add inside some `create*` methods the `setWhatsThis()` and `setToolTip()`
callings. That way the management of tooltips and “What's This” help is
facilitated.
Note: The parameter `const QString &toolTip` was already used in:
KonfiguratorCheckBox *createCheckBox(QString configGroup, QString name, bool defaultValue,
QString text, QWidget *parent = nullptr, bool restart = false,
const QString &toolTip = QString(), int page = FIRST_PAGE);
A tooltip (related to Krusader lister) was added, with the text "If a text file
is bigger than this size then lister will be used". That tooltip is also useful
as an example and in order to perform tests with it.
GUI: A new translation string was added, which is visible on a tooltip and a “What's This” help.
Differential Revision: https://phabricator.kde.org/D29545
M +1 -1 krusader/Konfigurator/kgdependencies.cpp
M +6 -3 krusader/Konfigurator/kggeneral.cpp
M +29 -15 krusader/Konfigurator/kgpanel.cpp
M +27 -6 krusader/Konfigurator/konfiguratorpage.cpp
M +13 -7 krusader/Konfigurator/konfiguratorpage.h
https://commits.kde.org/krusader/596dd0b2f0f374b75645049ce780ead201328305
diff --git a/krusader/Konfigurator/kgdependencies.cpp b/krusader/Konfigurator/kgdependencies.cpp
index 9cd07a1e..74c74124 100644
--- a/krusader/Konfigurator/kgdependencies.cpp
+++ b/krusader/Konfigurator/kgdependencies.cpp
@@ -138,7 +138,7 @@ void KgDependencies::addApplication(const QString& name, QGridLayout *grid, int
addLabel(grid, row, 0, name, parent);
KonfiguratorURLRequester *fullPath =
- createURLRequester("Dependencies", name, defaultValue, parent, false, page);
+ createURLRequester("Dependencies", name, defaultValue, parent, false, QString(), page);
connect(fullPath->extension(), &KonfiguratorExtension::applyManually, this, &KgDependencies::slotApply);
grid->addWidget(fullPath, row, 1);
}
diff --git a/krusader/Konfigurator/kggeneral.cpp b/krusader/Konfigurator/kggeneral.cpp
index f15d2528..774f0d33 100644
--- a/krusader/Konfigurator/kggeneral.cpp
+++ b/krusader/Konfigurator/kggeneral.cpp
@@ -118,10 +118,12 @@ void KgGeneral::createViewerTab()
QWidget * hboxWidget4 = new QWidget(vboxWidget);
auto * hbox4 = new QHBoxLayout(hboxWidget4);
+ const QString listerLimitTip = i18n("If a text file is bigger than this size then lister will be used.");
QLabel *label5 = new QLabel(i18n("Use lister if the text file is bigger than:"), hboxWidget4);
+ label5->setWhatsThis(listerLimitTip);
hbox4->addWidget(label5);
KonfiguratorSpinBox *spinBox = createSpinBox("General", "Lister Limit", _ListerLimit,
- 0, 0x7FFFFFFF, hboxWidget4, false, PAGE_VIEWER);
+ 0, 0x7FFFFFFF, hboxWidget4, false, listerLimitTip, PAGE_VIEWER);
hbox4->addWidget(spinBox);
QLabel *label6 = new QLabel(i18n("MB"), hboxWidget4);
hbox4->addWidget(label6);
@@ -142,7 +144,7 @@ void KgGeneral::createViewerTab()
QLabel *label1 = new QLabel(i18n("Editor:"), editorGrp);
editorGrid->addWidget(label1, 0, 0);
KonfiguratorURLRequester *urlReq = createURLRequester("General", "Editor", "internal editor",
- editorGrp, false, PAGE_VIEWER, false);
+ editorGrp, false, QString(), PAGE_VIEWER, false);
editorGrid->addWidget(urlReq, 0, 1);
QLabel *label2 = new QLabel(i18n("Hint: use 'internal editor' if you want to use Krusader's fast built-in editor"), editorGrp);
@@ -197,7 +199,8 @@ void KgGeneral::createExtensionsTab()
defaultAtomicExtensions += ".moc.cpp";
listBox = createListBox("Look&Feel", "Atomic Extensions",
- defaultAtomicExtensions, vboxWidget2, true, PAGE_EXTENSIONS);
+ defaultAtomicExtensions, vboxWidget2, true,
+ QString(), PAGE_EXTENSIONS);
vbox2->addWidget(listBox);
}
diff --git a/krusader/Konfigurator/kgpanel.cpp b/krusader/Konfigurator/kgpanel.cpp
index 9a865e67..2b3a290f 100644
--- a/krusader/Konfigurator/kgpanel.cpp
+++ b/krusader/Konfigurator/kgpanel.cpp
@@ -144,7 +144,8 @@ void KgPanel::setupGeneralTab()
};
KonfiguratorComboBox *cmb = createComboBox("Look&Feel", "Tab Bar Position",
- "bottom", positions, 2, groupBox, true, false, PAGE_GENERAL);
+ "bottom", positions, 2, groupBox, true, false,
+ QString(), PAGE_GENERAL);
hbox->addWidget(cmb);
gridLayout->addLayout(hbox, 1, 0, Qt::AlignLeft);
@@ -178,7 +179,8 @@ void KgPanel::setupGeneralTab()
hbox = new QHBoxLayout();
hbox->addWidget(new QLabel(i18n("Position:"), groupBox));
cmb = createComboBox("Look&Feel", "Quicksearch Position",
- "bottom", positions, 2, groupBox, true, false, PAGE_GENERAL);
+ "bottom", positions, 2, groupBox, true, false,
+ QString(), PAGE_GENERAL);
hbox->addWidget(cmb);
hbox->addWidget(createSpacer(groupBox));
gridLayout->addLayout(hbox, 1, 0);
@@ -193,7 +195,7 @@ void KgPanel::setupGeneralTab()
{i18n("Filter"), QString::number(KrSearchBar::MODE_FILTER)}};
cmb = createComboBox("Look&Feel", "Default Search Mode",
QString::number(KrSearchBar::MODE_SEARCH), modes, 3, groupBox, true, false,
- PAGE_GENERAL);
+ QString(), PAGE_GENERAL);
cmb->setToolTip(i18n("Set the default mode on first usage"));
hbox->addWidget(cmb);
hbox->addWidget(createSpacer(groupBox));
@@ -263,7 +265,8 @@ void KgPanel::setupLayoutTab()
layouts[ i ].value = layoutNames[i];
}
KonfiguratorComboBox *cmb = createComboBox("PanelLayout", "Layout", "default",
- layouts, numLayouts, tab, true, false, PAGE_LAYOUT);
+ layouts, numLayouts, tab, true, false,
+ QString(), PAGE_LAYOUT);
grid->addWidget(cmb, 0, 1);
delete [] layouts;
@@ -276,7 +279,8 @@ void KgPanel::setupLayoutTab()
{ i18nc("Frame color", "Statusbar"), "Statusbar" }
};
cmb = createComboBox("PanelLayout", "FrameColor",
- "default", frameColor, 3, tab, true, false, PAGE_LAYOUT);
+ "default", frameColor, 3, tab, true, false,
+ QString(), PAGE_LAYOUT);
grid->addWidget(cmb, 1, 1);
@@ -290,7 +294,8 @@ void KgPanel::setupLayoutTab()
{ i18nc("Frame shape", "Panel"), "Panel" },
};
cmb = createComboBox("PanelLayout", "FrameShape",
- "default", frameShape, 4, tab, true, false, PAGE_LAYOUT);
+ "default", frameShape, 4, tab, true, false,
+ QString(), PAGE_LAYOUT);
grid->addWidget(cmb, 2, 1);
@@ -304,7 +309,8 @@ void KgPanel::setupLayoutTab()
{ i18nc("Frame shadow", "Sunken"), "Sunken" },
};
cmb = createComboBox("PanelLayout", "FrameShadow",
- "default", frameShadow, 4, tab, true, false, PAGE_LAYOUT);
+ "default", frameShadow, 4, tab, true, false,
+ QString(), PAGE_LAYOUT);
grid->addWidget(cmb, 3, 1);
}
@@ -320,7 +326,9 @@ void KgPanel::setupView(KrViewInstance *instance, QWidget *parent)
auto *iconSizes = new KONFIGURATOR_NAME_VALUE_PAIR[KrView::iconSizes.count()];
for(int i = 0; i < KrView::iconSizes.count(); i++)
iconSizes[i].text = iconSizes[i].value = QString::number(KrView::iconSizes[i]);
- KonfiguratorComboBox *cmb = createComboBox(instance->name(), "IconSize", _FilelistIconSize, iconSizes, KrView::iconSizes.count(), parent, true, true, PAGE_VIEW);
+ KonfiguratorComboBox *cmb = createComboBox(instance->name(), "IconSize", _FilelistIconSize,
+ iconSizes, KrView::iconSizes.count(), parent, true, true,
+ QString(), PAGE_VIEW);
delete [] iconSizes;
cmb->lineEdit()->setValidator(new QRegExpValidator(QRegExp("[1-9]\\d{0,1}"), cmb));
hbox->addWidget(cmb);
@@ -378,12 +386,13 @@ void KgPanel::setupPanelTab()
// -------------------- Panel Tooltip ----------------------------------
auto *tooltipLayout = new QHBoxLayout();
+ const QString delayTip = i18n("The duration after a tooltip is shown for a file item, in "
+ "milliseconds. Set a negative value to disable tooltips.");
QLabel *tooltipLabel = new QLabel(i18n("Tooltip delay (msec):"));
- tooltipLabel->setWhatsThis(i18n("The duration after a tooltip is shown for a file item, in "
- "milliseconds. Set a negative value to disable tooltips."));
+ tooltipLabel->setWhatsThis(delayTip);
tooltipLayout->addWidget(tooltipLabel);
KonfiguratorSpinBox *tooltipSpinBox = createSpinBox("Look&Feel", "Panel Tooltip Delay", 1000,
- -100, 5000, panelGrp, false, PAGE_VIEW);
+ -100, 5000, panelGrp, false, delayTip, PAGE_VIEW);
tooltipSpinBox->setSingleStep(100);
tooltipLayout->addWidget(tooltipSpinBox);
tooltipLayout->addStretch(1);
@@ -423,7 +432,8 @@ void KgPanel::setupPanelTab()
{ i18nc("Krusader sort", "Krusader"), QString::number(KrViewProperties::Krusader) }
};
KonfiguratorComboBox *cmb = createComboBox("Look&Feel", "Sort method", QString::number(_DefaultSortMethod),
- sortMethods, 5, panelGrp, true, false, PAGE_VIEW);
+ sortMethods, 5, panelGrp, true, false,
+ QString(), PAGE_VIEW);
hbox->addWidget(cmb);
hbox->addWidget(createSpacer(panelGrp));
@@ -477,7 +487,9 @@ void KgPanel::setupPanelTab()
defType = QString("%1").arg(inst->id());
}
- cmb = createComboBox("Look&Feel", "Default Panel Type", defType, panelTypes, viewsSize, panelGrp, false, false, PAGE_VIEW);
+ cmb = createComboBox("Look&Feel", "Default Panel Type", defType,
+ panelTypes, viewsSize, panelGrp, false, false,
+ QString(), PAGE_VIEW);
hbox->addWidget(cmb);
hbox->addWidget(createSpacer(panelGrp));
@@ -702,7 +714,8 @@ void KgPanel::setupMediaMenuTab()
createComboBox("MediaMenu", "ShowSize",
"Always", showSizeValues,
sizeof(showSizeValues) / sizeof(*showSizeValues),
- tab, false, false, PAGE_MEDIA_MENU);
+ tab, false, false,
+ QString(), PAGE_MEDIA_MENU);
showSizeHBox->addWidget(showSizeCmb);
createIgnoredMountpointsList(tab, tabLayout);
showSizeHBox->addStretch();
@@ -744,7 +757,8 @@ void KgPanel::createIgnoredMountpointsList(QWidget *tab, QBoxLayout *tabLayout)
QStringList defaultHiddenMountpoints; // Empty list
listBox = createListBox("MediaMenu", "Hidden Mountpoints",
- defaultHiddenMountpoints, vboxWidget2, true, PAGE_MEDIA_MENU);
+ defaultHiddenMountpoints, vboxWidget2, true,
+ QString(), PAGE_MEDIA_MENU);
vbox2->addWidget(listBox);
}
diff --git a/krusader/Konfigurator/konfiguratorpage.cpp b/krusader/Konfigurator/konfiguratorpage.cpp
index b28ee7af..03f6f7ba 100644
--- a/krusader/Konfigurator/konfiguratorpage.cpp
+++ b/krusader/Konfigurator/konfiguratorpage.cpp
@@ -76,7 +76,7 @@ bool KonfiguratorPage::isChanged()
}
KonfiguratorCheckBox* KonfiguratorPage::createCheckBox(QString configGroup, QString name,
- bool defaultValue, QString text, QWidget *parent, bool restart, const QString& toolTip, int page)
+ bool defaultValue, QString text, QWidget *parent, bool restart, const QString &toolTip, int page)
{
KonfiguratorCheckBox *checkBox = new KonfiguratorCheckBox(std::move(configGroup), std::move(name), defaultValue, std::move(text),
parent, restart, page);
@@ -90,40 +90,56 @@ KonfiguratorCheckBox* KonfiguratorPage::createCheckBox(QString configGroup, QStr
}
KonfiguratorSpinBox* KonfiguratorPage::createSpinBox(QString configGroup, QString configName,
- int defaultValue, int min, int max, QWidget *parent, bool restart, int page)
+ int defaultValue, int min, int max, QWidget *parent, bool restart, const QString &toolTip, int page)
{
KonfiguratorSpinBox *spinBox = new KonfiguratorSpinBox(std::move(configGroup), std::move(configName), defaultValue,
min, max, parent, restart, page);
+ if (!toolTip.isEmpty()) {
+ spinBox->setWhatsThis(toolTip);
+ spinBox->setToolTip(toolTip);
+ }
registerObject(spinBox->extension());
return spinBox;
}
KonfiguratorEditBox* KonfiguratorPage::createEditBox(QString configGroup, QString name,
- QString defaultValue, QWidget *parent, bool restart, int page)
+ QString defaultValue, QWidget *parent, bool restart, const QString &toolTip, int page)
{
KonfiguratorEditBox *editBox = new KonfiguratorEditBox(std::move(configGroup), std::move(name), std::move(defaultValue), parent,
restart, page);
+ if (!toolTip.isEmpty()) {
+ editBox->setWhatsThis(toolTip);
+ editBox->setToolTip(toolTip);
+ }
registerObject(editBox->extension());
return editBox;
}
KonfiguratorListBox* KonfiguratorPage::createListBox(QString configGroup, QString name,
- QStringList defaultValue, QWidget *parent, bool restart, int page)
+ QStringList defaultValue, QWidget *parent, bool restart, const QString &toolTip, int page)
{
KonfiguratorListBox *listBox = new KonfiguratorListBox(std::move(configGroup), std::move(name), std::move(defaultValue), parent,
restart, page);
+ if (!toolTip.isEmpty()) {
+ listBox->setWhatsThis(toolTip);
+ listBox->setToolTip(toolTip);
+ }
registerObject(listBox->extension());
return listBox;
}
KonfiguratorURLRequester* KonfiguratorPage::createURLRequester(QString configGroup, QString name,
- QString defaultValue, QWidget *parent, bool restart, int page, bool expansion)
+ QString defaultValue, QWidget *parent, bool restart, const QString &toolTip, int page, bool expansion)
{
KonfiguratorURLRequester *urlRequester = new KonfiguratorURLRequester(std::move(configGroup), std::move(name), std::move(defaultValue),
parent, restart, page, expansion);
+ if (!toolTip.isEmpty()) {
+ urlRequester->setWhatsThis(toolTip);
+ urlRequester->setToolTip(toolTip);
+ }
registerObject(urlRequester->extension());
return urlRequester;
@@ -244,10 +260,15 @@ KonfiguratorFontChooser *KonfiguratorPage::createFontChooser(QString configGroup
}
KonfiguratorComboBox *KonfiguratorPage::createComboBox(QString configGroup, QString name, QString defaultValue,
- KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, QWidget *parent, bool restart, bool editable, int page)
+ KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, QWidget *parent, bool restart, bool editable,
+ const QString &toolTip, int page)
{
KonfiguratorComboBox *comboBox = new KonfiguratorComboBox(std::move(configGroup), std::move(name), std::move(defaultValue), params,
paramNum, parent, restart, editable, page);
+ if (!toolTip.isEmpty()) {
+ comboBox->setWhatsThis(toolTip);
+ comboBox->setToolTip(toolTip);
+ }
registerObject(comboBox->extension());
return comboBox;
diff --git a/krusader/Konfigurator/konfiguratorpage.h b/krusader/Konfigurator/konfiguratorpage.h
index 9d11c2fb..3d25f047 100644
--- a/krusader/Konfigurator/konfiguratorpage.h
+++ b/krusader/Konfigurator/konfiguratorpage.h
@@ -124,7 +124,7 @@ public:
*/
KonfiguratorCheckBox *createCheckBox(QString configGroup, QString name, bool defaultValue,
QString text, QWidget *parent = nullptr, bool restart = false,
- const QString& toolTip = QString(), int page = FIRST_PAGE);
+ const QString &toolTip = QString(), int page = FIRST_PAGE);
/**
* Adds a new spinbox item to the page.
@@ -141,13 +141,14 @@ public:
* @param max The maximum value of the spinbox
* @param parent Reference to the parent widget
* @param restart The change of this parameter requires Krusader restart
+ * @param toolTip Tooltip used for this spinbox
* @param page The subpage of a Konfigurator page (because of setDefaults)
*
* @return reference to the newly created spinbox
*/
KonfiguratorSpinBox *createSpinBox(QString configGroup, QString configName, int defaultValue,
int min, int max, QWidget *parent = nullptr, bool restart = false,
- int page = FIRST_PAGE);
+ const QString &toolTip = QString(), int page = FIRST_PAGE);
/**
* Adds a new editbox item to the page.
@@ -162,13 +163,14 @@ public:
* @param defaultValue The default value of the editbox
* @param parent Reference to the parent widget
* @param restart The change of this parameter requires Krusader restart
+ * @param toolTip Tooltip used for this editbox
* @param page The subpage of a Konfigurator page (because of setDefaults)
*
* @return reference to the newly created editbox
*/
KonfiguratorEditBox *createEditBox(QString configGroup, QString name, QString defaultValue,
QWidget *parent = nullptr, bool restart = false,
- int page = FIRST_PAGE);
+ const QString &toolTip = QString(), int page = FIRST_PAGE);
/**
* Adds a new listbox item to the page.
@@ -185,13 +187,14 @@ public:
* @param defaultValue The default value of the listbox
* @param parent Reference to the parent widget
* @param restart The change of this parameter requires Krusader restart
+ * @param toolTip Tooltip used for this listbox
* @param page The subpage of a Konfigurator page (because of setDefaults)
*
* @return reference to the newly created editbox
*/
KonfiguratorListBox *createListBox(QString configGroup, QString name, QStringList defaultValue,
QWidget *parent = nullptr, bool restart = false,
- int page = FIRST_PAGE);
+ const QString &toolTip = QString(), int page = FIRST_PAGE);
/**
* Adds a new URL requester item to the page.
@@ -206,6 +209,7 @@ public:
* @param defaultValue The default value of the URL requester
* @param parent Reference to the parent widget
* @param restart The change of this parameter requires Krusader restart
+ * @param toolTip Tooltip used for this URL requester
* @param page The subpage of a Konfigurator page (because of setDefaults)
* @param expansion Whether to perform url expansion
*
@@ -213,8 +217,8 @@ public:
*/
KonfiguratorURLRequester *createURLRequester(QString configGroup, QString name,
QString defaultValue, QWidget *parent,
- bool restart, int page = FIRST_PAGE,
- bool expansion = true);
+ bool restart, const QString &toolTip = QString(),
+ int page = FIRST_PAGE, bool expansion = true);
/**
* Adds a new font chooser item to the page.
@@ -257,6 +261,7 @@ public:
* @param parent Reference to the parent widget
* @param restart The change of this parameter requires Krusader restart
* @param editable Flag indicates that the combo can be edited
+ * @param toolTip Tooltip used for this combobox
* @param page The subpage of a Konfigurator page (because of setDefaults)
*
* @return reference to the newly created combobox
@@ -264,7 +269,8 @@ public:
KonfiguratorComboBox *createComboBox(QString configGroup, QString name, QString defaultValue,
KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum,
QWidget *parent = nullptr, bool restart = false,
- bool editable = false, int page = FIRST_PAGE);
+ bool editable = false, const QString &toolTip = QString(),
+ int page = FIRST_PAGE);
/**
* Creates a frame on the page.
More information about the kde-doc-english
mailing list