2008-06-05 15:08:46 +00:00
|
|
|
/**
|
|
|
|
* \file GuiInfo.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiInfo.h"
|
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "Buffer.h"
|
|
|
|
#include "buffer_funcs.h"
|
|
|
|
#include "BufferParams.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "Cursor.h"
|
|
|
|
|
|
|
|
#include "insets/InsetInfo.h"
|
|
|
|
|
2012-06-28 20:52:20 +02:00
|
|
|
#include "support/debug.h"
|
2010-10-31 01:04:03 +00:00
|
|
|
#include "support/gettext.h"
|
2008-06-06 04:10:42 +00:00
|
|
|
#include "support/lstrings.h"
|
2008-06-05 15:08:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
2008-06-06 04:10:42 +00:00
|
|
|
using namespace lyx::support;
|
2008-06-05 15:08:46 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// GuiInfo
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-06-06 04:10:42 +00:00
|
|
|
char const * info_types[] =
|
2018-07-29 19:41:34 +02:00
|
|
|
{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "vcs", "lyxinfo", "" };
|
2008-06-06 04:10:42 +00:00
|
|
|
|
|
|
|
char const * info_types_gui[] =
|
2018-07-26 16:02:03 +02:00
|
|
|
{ N_("Unknown"), N_("Last Assigned Keyboard Shortcut"), N_("All Keyboard Shortcuts"),
|
|
|
|
N_("LyX Preferences Entry"), N_("LaTeX Package Availability"), N_("LaTeX Class Availability"),
|
2018-07-29 19:41:34 +02:00
|
|
|
N_("LyX Menu Location"), N_("LyX Toolbar Icon"), N_("Document Information"),
|
|
|
|
N_("Version Control Information"), N_("LyX Application Information"), ""};
|
2018-07-26 16:02:03 +02:00
|
|
|
|
|
|
|
char const * info_name_gui[] =
|
|
|
|
{ N_("Not Applicable"), N_("LyX Function"), N_("LyX Function"), N_("Preferences Key"), N_("Package Name"),
|
2018-07-29 19:41:34 +02:00
|
|
|
N_("Class Name"), N_("LyX Function"), N_("LyX Function"), N_("Information"),
|
|
|
|
N_("Information"), N_("Information"), ""};
|
2018-07-26 16:02:03 +02:00
|
|
|
|
|
|
|
char const * info_tooltip[] =
|
|
|
|
{ N_("Please select a valid type above"),
|
|
|
|
N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
|
|
|
|
"The output is the most recently assigned keyboard shortcut for this function"),
|
|
|
|
N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
|
|
|
|
"The output lists all possible keyboard shortcuts for this function"),
|
|
|
|
N_("Enter a LyX preferences key such as 'bind_file'. Please refer to src/LyXRC.h for available entries. "
|
|
|
|
"The output is the current setting of this preference."),
|
|
|
|
N_("Enter a LaTeX package name such as 'hyperref' (extension is optional). "
|
|
|
|
"The output will be 'Yes' (package available) or 'No' (package unavailable)."),
|
|
|
|
N_("Enter a LaTeX class name such as 'article' (extension is optional). "
|
|
|
|
"The output will be 'Yes' (class available) or 'No' (class unavailable)."),
|
|
|
|
N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
|
|
|
|
"The output is the path to the function in the menu (using the current localization)."),
|
|
|
|
N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
|
|
|
|
"The output is the toolbar icon for this function (using the active icon theme)."),
|
|
|
|
N_("Enter either 'name' (outputs the filename of the current document), 'path' (outputs the file path), or 'class' (outputs the text class)."),
|
2018-07-29 19:41:34 +02:00
|
|
|
N_("Enter either 'revision', 'tree-revision', 'author', 'time' or 'date'. If available, the respective version control information is output."),
|
2018-07-26 16:02:03 +02:00
|
|
|
N_("Currently supported information type: 'version' (outputs the current LyX version)."),
|
|
|
|
""};
|
2008-06-06 04:10:42 +00:00
|
|
|
|
|
|
|
|
2010-02-15 23:17:45 +00:00
|
|
|
GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
|
2008-06-05 15:08:46 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2008-06-06 04:10:42 +00:00
|
|
|
|
2008-06-06 08:45:58 +00:00
|
|
|
typeCO->blockSignals(true);
|
2008-06-06 04:10:42 +00:00
|
|
|
for (int n = 0; info_types[n][0]; ++n)
|
2018-07-26 16:02:03 +02:00
|
|
|
typeCO->addItem(qt_(info_types_gui[n]), info_types[n]);
|
2008-06-06 08:45:58 +00:00
|
|
|
typeCO->blockSignals(false);
|
|
|
|
|
2010-02-15 23:17:45 +00:00
|
|
|
connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
|
|
|
|
connect(nameLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
2008-06-06 08:45:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-30 11:15:05 +00:00
|
|
|
void GuiInfo::paramsToDialog(Inset const * inset)
|
2008-06-06 08:45:58 +00:00
|
|
|
{
|
2010-01-30 11:15:05 +00:00
|
|
|
InsetInfo const * ii = static_cast<InsetInfo const *>(inset);
|
|
|
|
QString const type = toqstr(ii->infoType());
|
|
|
|
QString const name = toqstr(ii->infoName());
|
2008-06-06 08:45:58 +00:00
|
|
|
typeCO->blockSignals(true);
|
|
|
|
nameLE->blockSignals(true);
|
2018-07-26 16:02:03 +02:00
|
|
|
int const i = typeCO->findData(type);
|
|
|
|
typeCO->setCurrentIndex(i);
|
2010-01-30 11:15:05 +00:00
|
|
|
// Without this test, 'math-insert' (name) will replace 'math-insert '
|
2008-08-03 22:26:01 +00:00
|
|
|
// in nameLE and effectively disallow the input of spaces after a LFUN.
|
2010-01-30 11:15:05 +00:00
|
|
|
if (nameLE->text().trimmed() != name)
|
|
|
|
nameLE->setText(name);
|
2008-06-06 08:45:58 +00:00
|
|
|
typeCO->blockSignals(false);
|
|
|
|
nameLE->blockSignals(false);
|
2008-06-05 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-30 11:15:05 +00:00
|
|
|
docstring GuiInfo::dialogToParams() const
|
2008-06-05 15:08:46 +00:00
|
|
|
{
|
2018-07-26 16:02:03 +02:00
|
|
|
QString type =
|
|
|
|
typeCO->itemData(typeCO->currentIndex()).toString();
|
2010-01-30 11:15:05 +00:00
|
|
|
QString const name = nameLE->text();
|
|
|
|
return qstring_to_ucs4(type + ' ' + name);
|
2008-06-05 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-01 10:07:20 +02:00
|
|
|
bool GuiInfo::checkWidgets(bool readonly) const
|
|
|
|
{
|
|
|
|
nameLE->setReadOnly(readonly);
|
|
|
|
typeCO->setEnabled(!readonly);
|
2018-07-26 16:02:03 +02:00
|
|
|
nameLA->setText(qt_(info_name_gui[typeCO->currentIndex()]) + toqstr(":"));
|
|
|
|
bool const type_enabled =
|
|
|
|
typeCO->itemData(typeCO->currentIndex()).toString() != "unknown";
|
|
|
|
nameLA->setEnabled(type_enabled);
|
|
|
|
nameLE->setEnabled(type_enabled);
|
|
|
|
nameLE->setToolTip(qt_(info_tooltip[typeCO->currentIndex()]));
|
|
|
|
|
2015-04-01 10:07:20 +02:00
|
|
|
if (!InsetParamsWidget::checkWidgets())
|
|
|
|
return false;
|
|
|
|
return !nameLE->text().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-05 15:08:46 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiInfo.cpp"
|