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 18:52:20 +00: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[] =
|
2010-04-17 13:04:41 +00:00
|
|
|
{ "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
|
2008-06-06 04:10:42 +00:00
|
|
|
|
|
|
|
char const * info_types_gui[] =
|
|
|
|
{ N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"),
|
2010-04-17 13:04:41 +00:00
|
|
|
N_("menu"), N_("icon"), N_("buffer"), N_("lyxinfo"), ""};
|
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)
|
|
|
|
typeCO->addItem(qt_(info_types_gui[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);
|
2010-01-30 11:15:05 +00:00
|
|
|
int type_index = findToken(info_types, fromqstr(type));
|
|
|
|
typeCO->setCurrentIndex(type_index >= 0 ? type_index : 0);
|
|
|
|
// 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
|
|
|
{
|
2010-01-30 11:15:05 +00:00
|
|
|
int type_index = typeCO->currentIndex();
|
|
|
|
QString type;
|
|
|
|
if (type_index != -1)
|
|
|
|
type = info_types[type_index];
|
|
|
|
QString const name = nameLE->text();
|
|
|
|
return qstring_to_ucs4(type + ' ' + name);
|
2008-06-05 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-01 08:07:20 +00:00
|
|
|
bool GuiInfo::checkWidgets(bool readonly) const
|
|
|
|
{
|
|
|
|
nameLE->setReadOnly(readonly);
|
|
|
|
typeCO->setEnabled(!readonly);
|
|
|
|
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"
|