From: Juergen Spitzmueller Date: Thu, 21 Mar 2019 18:23:33 +0000 (+0100) Subject: Replace Type combo, which was considered irritating, with a Type filter X-Git-Tag: lyx-2.4.0dev-acb2ca7b~2405 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7403fd2f883dfc9b043b6285688f6014213c8ab3;p=features.git Replace Type combo, which was considered irritating, with a Type filter The new one allows to display only user or system files. --- diff --git a/src/frontends/qt4/GuiLyXFiles.cpp b/src/frontends/qt4/GuiLyXFiles.cpp index 7e99515e72..598bfc0d88 100644 --- a/src/frontends/qt4/GuiLyXFiles.cpp +++ b/src/frontends/qt4/GuiLyXFiles.cpp @@ -39,8 +39,9 @@ namespace lyx { namespace frontend { -void GuiLyXFiles::getFiles(QMap & in, QString const type) +QMap GuiLyXFiles::getFiles() { + QMap result; // We look for lyx files in the subdirectory dir of // 1) user_lyxdir // 2) build_lyxdir (if not empty) @@ -52,16 +53,20 @@ void GuiLyXFiles::getFiles(QMap & in, QString const type) QStringList relpaths; // The three locations to look at. - string const user = addPath(package().user_support().absFileName(), fromqstr(type)); - string const build = addPath(package().build_support().absFileName(), fromqstr(type)); - string const system = addPath(package().system_support().absFileName(), fromqstr(type)); + string const user = addPath(package().user_support().absFileName(), fromqstr(type_)); + string const build = addPath(package().build_support().absFileName(), fromqstr(type_)); + string const system = addPath(package().system_support().absFileName(), fromqstr(type_)); available_languages_.insert(toqstr("en"), qt_("English")); - // Search in the base path - dirs << toqstr(user) - << toqstr(build) - << toqstr(system); + QString const type = fileTypeCO->itemData(fileTypeCO->currentIndex()).toString(); + + // Search in the base paths + if (type == "all" || type == "user") + dirs << toqstr(user); + if (type == "all" || type == "system") + dirs << toqstr(build) + << toqstr(system); for (int i = 0; i < dirs.size(); ++i) { QString const dir = dirs.at(i); @@ -103,7 +108,7 @@ void GuiLyXFiles::getFiles(QMap & in, QString const type) if (localization != "en") // strip off lang/ relpath = relpath.mid(relpath.indexOf('/') + 1); - in.insert(relpath, cat); + result.insert(relpath, cat); QMap lm; if (localizations_.contains(relpath)) @@ -139,6 +144,7 @@ void GuiLyXFiles::getFiles(QMap & in, QString const type) } setLanguage(); languageLA->setText(qt_("Preferred &Language:")); + return result; } @@ -210,6 +216,12 @@ GuiLyXFiles::GuiLyXFiles(GuiView & lv) //filesLW->setViewMode(QListView::ListMode); filesLW->setIconSize(QSize(22, 22)); + QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png")); + QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png")); + fileTypeCO->addItem(qt_("User and System Files"), toqstr("all")); + fileTypeCO->addItem(user_icon, qt_("User Files Only"), toqstr("user")); + fileTypeCO->addItem(system_icon, qt_("System Files Only"), toqstr("system")); + setFocusProxy(filter_); } @@ -342,10 +354,8 @@ void GuiLyXFiles::on_browsePB_pressed() void GuiLyXFiles::updateContents() { - QString type = fileTypeCO->itemData(fileTypeCO->currentIndex()).toString(); - QMap files; languageCO->clear(); - getFiles(files, type); + QMap files = getFiles(); languageCO->model()->sort(0); filesLW->clear(); @@ -494,20 +504,6 @@ bool GuiLyXFiles::initialiseParams(string const & type) void GuiLyXFiles::paramsToDialog() { - fileTypeCO->clear(); - if (type_ == "examples" || type_ == "templates") { - fileTypeCO->addItem(qt_("Templates"), toqstr("templates")); - fileTypeCO->addItem(qt_("Examples"), toqstr("examples")); - } else if (type_ == "ui") - fileTypeCO->addItem(qt_("User Interface Files"), toqstr("ui")); - else if (type_ == "bind") - fileTypeCO->addItem(qt_("Key Binding Files"), toqstr("bind")); - - if (!type_.isEmpty()) { - int i = fileTypeCO->findData(type_); - if (i != -1) - fileTypeCO->setCurrentIndex(i); - } if (type_ == "examples") setTitle(qt_("Open Example File")); else if (type_ == "templates") diff --git a/src/frontends/qt4/GuiLyXFiles.h b/src/frontends/qt4/GuiLyXFiles.h index 2ee22c888b..e4213353b8 100644 --- a/src/frontends/qt4/GuiLyXFiles.h +++ b/src/frontends/qt4/GuiLyXFiles.h @@ -69,7 +69,7 @@ private: /// bool translateName() const; /// - void getFiles(QMap &, QString const); + QMap getFiles(); /// Get the full file path in the selected localization QString const getRealPath(QString relpath = QString()); /// diff --git a/src/frontends/qt4/ui/LyXFilesUi.ui b/src/frontends/qt4/ui/LyXFilesUi.ui index e90beb7072..7807b4b28d 100644 --- a/src/frontends/qt4/ui/LyXFilesUi.ui +++ b/src/frontends/qt4/ui/LyXFilesUi.ui @@ -6,8 +6,8 @@ 0 0 - 381 - 474 + 284 + 479 @@ -18,28 +18,71 @@ - - - - - &Type: - - - fileTypeCO - - - - - - - - 0 - 0 - - - - - + + + Filter + + + + + + &Type: + + + fileTypeCO + + + + + + + + 0 + 0 + + + + Determines whether only personal user files, system files or all files are displayed + + + + + + + &Name: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + + + Filter case-sensitively + + + Case Sensiti&ve + + + + + + + + + + + + + @@ -52,47 +95,22 @@ - + + + + 0 + 0 + + The available language(s) of the selected file will be displayed here - - - - &Filter: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - - - - - - Filter case-sensitively - - - Case Sensiti&ve - - - - - - - - + true @@ -110,7 +128,7 @@ - + @@ -134,7 +152,7 @@ - + 6