mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Add system/local icon to available modules list
Also markup modules with missing requirements (like we do for layouts)
This commit is contained in:
parent
c0f734bcef
commit
b60259fbe1
@ -1472,7 +1472,7 @@ def checkModulesConfig():
|
||||
## It has been automatically generated by configure
|
||||
## Use "Options/Reconfigure" if you need to update it after a
|
||||
## configuration change.
|
||||
## "ModuleName" "filename" "Description" "Packages" "Requires" "Excludes" "Category"
|
||||
## "ModuleName" "filename" "Description" "Packages" "Requires" "Excludes" "Category" "Local"
|
||||
''')
|
||||
|
||||
# build the list of available modules
|
||||
@ -1587,8 +1587,11 @@ def processModuleFile(file, filename, bool_docbook):
|
||||
cm.write(line + '\n')
|
||||
cm.close()
|
||||
|
||||
return (b'"%s" "%s" "%s" "%s" "%s" "%s" "%s"\n'
|
||||
% (modname, filename, desc, pkgs, req, excl, catgy))
|
||||
local = "true"
|
||||
if (file.startswith(srcdir)):
|
||||
local = "false"
|
||||
return (b'"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"\n'
|
||||
% (modname, filename, desc, pkgs, req, excl, catgy, local))
|
||||
|
||||
|
||||
def checkCiteEnginesConfig():
|
||||
|
@ -37,10 +37,10 @@ ModuleList theModuleList;
|
||||
LyXModule::LyXModule(string const & n, string const & i,
|
||||
string const & d, vector<string> const & p,
|
||||
vector<string> const & r, vector<string> const & e,
|
||||
string const & c):
|
||||
string const & c, bool const local):
|
||||
name_(n), id_(i), description_(d), package_list_(p),
|
||||
required_modules_(r), excluded_modules_(e), category_(c),
|
||||
checked_(false), available_(false)
|
||||
checked_(false), available_(false), local_(local)
|
||||
{
|
||||
filename_ = id_ + ".module";
|
||||
}
|
||||
@ -199,9 +199,13 @@ bool ModuleList::read()
|
||||
break;
|
||||
string const catgy = lex.getString();
|
||||
LYXERR(Debug::TCLASS, "Category: " << catgy);
|
||||
if (!lex.next())
|
||||
break;
|
||||
bool const local = lex.getString() == "true";
|
||||
LYXERR(Debug::TCLASS, "Local: " << local);
|
||||
// This code is run when we have
|
||||
// modName, fname, desc, pkgs, req, exc, and catgy
|
||||
addLayoutModule(modname, fname, desc, pkgs, req, exc, catgy);
|
||||
// modName, fname, desc, pkgs, req, exc, catgy, and local
|
||||
addLayoutModule(modname, fname, desc, pkgs, req, exc, catgy, local);
|
||||
} // end switch
|
||||
} //end while
|
||||
|
||||
@ -216,9 +220,9 @@ bool ModuleList::read()
|
||||
void ModuleList::addLayoutModule(string const & modname,
|
||||
string const & filename, string const & description,
|
||||
vector<string> const & pkgs, vector<string> const & req,
|
||||
vector<string> const & exc, string const & catgy)
|
||||
vector<string> const & exc, string const & catgy, bool const local)
|
||||
{
|
||||
LyXModule lm(modname, filename, description, pkgs, req, exc, catgy);
|
||||
LyXModule lm(modname, filename, description, pkgs, req, exc, catgy, local);
|
||||
modlist_.push_back(lm);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
std::vector<std::string> const & packagelist,
|
||||
std::vector<std::string> const & requires,
|
||||
std::vector<std::string> const & excludes,
|
||||
std::string const & catgy);
|
||||
std::string const & catgy, bool const local);
|
||||
/// whether the required packages are available
|
||||
bool isAvailable() const;
|
||||
/// the missing prerequisites, if any
|
||||
@ -78,6 +78,8 @@ public:
|
||||
{ return excluded_modules_; }
|
||||
///
|
||||
std::string category() const { return category_; }
|
||||
/// Is this a local module (from the user directory)?
|
||||
bool isLocal() const { return local_; }
|
||||
/// \return true if the module is compatible with this one, i.e.,
|
||||
/// it does not exclude us and we do not exclude it.
|
||||
/// this will also return true if modname is unknown and we do not
|
||||
@ -110,6 +112,8 @@ private:
|
||||
///
|
||||
mutable bool available_;
|
||||
///
|
||||
mutable bool local_;
|
||||
///
|
||||
mutable std::vector<std::string> prerequisites_;
|
||||
};
|
||||
|
||||
@ -149,7 +153,7 @@ public:
|
||||
void addLayoutModule(std::string const &, std::string const &,
|
||||
std::string const &, std::vector<std::string> const &,
|
||||
std::vector<std::string> const &, std::vector<std::string> const &,
|
||||
std::string const &);
|
||||
std::string const &, bool const);
|
||||
///
|
||||
std::vector<LyXModule> modlist_;
|
||||
};
|
||||
|
@ -78,6 +78,7 @@
|
||||
#include <QDirIterator>
|
||||
#include <QFontDatabase>
|
||||
#include <QHeaderView>
|
||||
#include <QPixmap>
|
||||
#include <QScrollBar>
|
||||
#include <QTextBoundaryFinder>
|
||||
#include <QTextCursor>
|
||||
@ -1767,6 +1768,10 @@ void GuiDocument::filterModules(QString const & str)
|
||||
modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
|
||||
return 0 < b.name.localeAwareCompare(a.name);
|
||||
});
|
||||
|
||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||
|
||||
int i = 0;
|
||||
for (modInfoStruct const & m : modInfoList) {
|
||||
if (m.name.contains(str, Qt::CaseInsensitive) || contains(m.id, fromqstr(str))) {
|
||||
@ -1774,6 +1779,10 @@ void GuiDocument::filterModules(QString const & str)
|
||||
item->setData(m.name, Qt::DisplayRole);
|
||||
item->setData(toqstr(m.id), Qt::UserRole);
|
||||
item->setData(m.description, Qt::ToolTipRole);
|
||||
if (m.local)
|
||||
item->setIcon(user_icon);
|
||||
else
|
||||
item->setIcon(system_icon);
|
||||
modules_av_model_.insertRow(i, item);
|
||||
++i;
|
||||
}
|
||||
@ -4239,9 +4248,13 @@ void GuiDocument::updateAvailableModules()
|
||||
modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
|
||||
return 0 < b.name.localeAwareCompare(a.name);
|
||||
});
|
||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||
int i = 0;
|
||||
QFont catfont;
|
||||
catfont.setBold(true);
|
||||
QBrush unavbrush;
|
||||
unavbrush.setColor(Qt::gray);
|
||||
for (modInfoStruct const & m : modInfoList) {
|
||||
QStandardItem * item = new QStandardItem();
|
||||
QStandardItem * catItem = new QStandardItem();
|
||||
@ -4258,8 +4271,14 @@ void GuiDocument::updateAvailableModules()
|
||||
item->setEditable(false);
|
||||
catItem->setEditable(false);
|
||||
item->setData(m.name, Qt::DisplayRole);
|
||||
if (m.missingreqs)
|
||||
item->setForeground(unavbrush);
|
||||
item->setData(toqstr(m.id), Qt::UserRole);
|
||||
item->setData(m.description, Qt::ToolTipRole);
|
||||
if (m.local)
|
||||
item->setIcon(user_icon);
|
||||
else
|
||||
item->setIcon(system_icon);
|
||||
catItem->appendRow(item);
|
||||
}
|
||||
modules_av_model_.sort(0);
|
||||
@ -4612,6 +4631,8 @@ GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
|
||||
else {
|
||||
m.id = name;
|
||||
m.name = toqstr(name + " (") + qt_("Not Found") + toqstr(")");
|
||||
m.local = false;
|
||||
m.missingreqs = true;
|
||||
}
|
||||
mInfo.push_back(m);
|
||||
}
|
||||
@ -4807,7 +4828,12 @@ GuiDocument::modInfoStruct GuiDocument::modInfo(LyXModule const & mod)
|
||||
// change requires a lot of others
|
||||
modInfoStruct m;
|
||||
m.id = mod.getID();
|
||||
m.name = toqstr(translateIfPossible(from_utf8(mod.getName())));
|
||||
QString const guiname = toqstr(translateIfPossible(from_utf8(mod.getName())));
|
||||
m.missingreqs = !isModuleAvailable(mod.getID());
|
||||
if (m.missingreqs) {
|
||||
m.name = QString(qt_("%1 (missing req.)")).arg(guiname);
|
||||
} else
|
||||
m.name = guiname;
|
||||
m.category = mod.category().empty() ? qt_("Miscellaneous")
|
||||
: toqstr(translateIfPossible(from_utf8(mod.category())));
|
||||
QString desc = toqstr(translateIfPossible(from_utf8(mod.getDescription())));
|
||||
@ -4816,11 +4842,15 @@ GuiDocument::modInfoStruct GuiDocument::modInfo(LyXModule const & mod)
|
||||
int pos = bf.toNextBoundary();
|
||||
if (pos > 0)
|
||||
desc.truncate(pos);
|
||||
QString modulename = QString(qt_("(Module name: %1)")).arg(toqstr(m.id));
|
||||
// Tooltip is the desc followed by the module name
|
||||
m.description = QString("%1<i>%2</i>")
|
||||
m.local = mod.isLocal();
|
||||
QString const mtype = m.local ? qt_("personal module") : qt_("distributed module");
|
||||
QString modulename = QString(qt_("<b>Module name:</b> <i>%1</i> (%2)")).arg(toqstr(m.id)).arg(mtype);
|
||||
// Tooltip is the desc followed by the module name and the type
|
||||
m.description = QString("%1%2")
|
||||
.arg(desc.isEmpty() ? QString() : QString("<p>%1</p>").arg(desc),
|
||||
modulename);
|
||||
if (m.missingreqs)
|
||||
m.description += QString("<p>%1</p>").arg(qt_("<b>Note:</b> Some requirements for this module are missing!"));
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -258,6 +258,8 @@ private:
|
||||
std::string id;
|
||||
QString description;
|
||||
QString category;
|
||||
bool local;
|
||||
bool missingreqs;
|
||||
};
|
||||
///
|
||||
static modInfoStruct modInfo(LyXModule const & mod);
|
||||
|
Loading…
Reference in New Issue
Block a user