KControl: Add option to toggle visibility of hidden modules

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
(cherry picked from commit 82ed0caa3f)
r14.1.x
Mavridis Philippe 2 months ago
parent 10675b72c3
commit eac0d87067

@ -43,6 +43,7 @@ TQString KCGlobal::_iversion = "";
TQString KCGlobal::_imachine = ""; TQString KCGlobal::_imachine = "";
IndexViewMode KCGlobal::_viewmode = Icon; IndexViewMode KCGlobal::_viewmode = Icon;
TDEIcon::StdSizes KCGlobal::_iconsize = TDEIcon::SizeMedium; TDEIcon::StdSizes KCGlobal::_iconsize = TDEIcon::SizeMedium;
bool KCGlobal::_showhidden = false;
TQString KCGlobal::_baseGroup = ""; TQString KCGlobal::_baseGroup = "";
void KCGlobal::init() void KCGlobal::init()

@ -46,6 +46,7 @@ public:
static TQString systemMachine() { return _imachine; } static TQString systemMachine() { return _imachine; }
static IndexViewMode viewMode() { return _viewmode; } static IndexViewMode viewMode() { return _viewmode; }
static TDEIcon::StdSizes iconSize() { return _iconsize; } static TDEIcon::StdSizes iconSize() { return _iconsize; }
static bool showHiddenModules() { return _showhidden; }
static TQString baseGroup(); static TQString baseGroup();
static void setIsInfoCenter(bool b) { _infocenter = b; } static void setIsInfoCenter(bool b) { _infocenter = b; }
@ -60,6 +61,7 @@ public:
static void setSystemMachine(const TQString& n){ _imachine = n; } static void setSystemMachine(const TQString& n){ _imachine = n; }
static void setViewMode(IndexViewMode m) { _viewmode = m; } static void setViewMode(IndexViewMode m) { _viewmode = m; }
static void setIconSize(TDEIcon::StdSizes s) { _iconsize = s; } static void setIconSize(TDEIcon::StdSizes s) { _iconsize = s; }
static void setShowHiddenModules(bool o) { _showhidden = o; }
static void repairAccels( TQWidget * tw ); static void repairAccels( TQWidget * tw );
@ -71,6 +73,7 @@ private:
static IndexViewMode _viewmode; static IndexViewMode _viewmode;
static TDEIcon::StdSizes _iconsize; static TDEIcon::StdSizes _iconsize;
static TQString _baseGroup; static TQString _baseGroup;
static bool _showhidden;
}; };
#endif #endif

@ -42,6 +42,8 @@ void IndexWidget::reload()
{ {
if (_icon) if (_icon)
_icon->fill(); _icon->fill();
if (_tree)
_tree->fill();
} }
TQListViewItem *IndexWidget::firstTreeViewItem() TQListViewItem *IndexWidget::firstTreeViewItem()

@ -12,6 +12,8 @@
<Action name="activate_largeicons"/> <Action name="activate_largeicons"/>
<Action name="activate_hugeicons"/> <Action name="activate_hugeicons"/>
</Menu> </Menu>
<Separator/>
<Action name="show_hidden_modules"/>
</Menu> </Menu>
<Menu name="help"> <Menu name="help">
<Action name="help_about_module" append="about_merge"/> <Action name="help_about_module" append="about_merge"/>

@ -103,7 +103,7 @@ extern "C" TDE_EXPORT int kdemain(int argc, char *argv[])
TDELocale::setMainCatalogue("kcontrol"); TDELocale::setMainCatalogue("kcontrol");
TDEAboutData aboutKControl( "kcontrol", I18N_NOOP("Trinity Control Center"), TDEAboutData aboutKControl( "kcontrol", I18N_NOOP("Trinity Control Center"),
KCONTROL_VERSION, I18N_NOOP("The Trinity Control Center"), TDEAboutData::License_GPL, KCONTROL_VERSION, I18N_NOOP("The Trinity Control Center"), TDEAboutData::License_GPL,
I18N_NOOP("(c) 1998-2004, The Trinity Control Center Developers")); I18N_NOOP("(c) 1998-2024, The Trinity Control Center Developers"));
TQCString argv_0 = argv[0]; TQCString argv_0 = argv[0];
TDEAboutData *aboutData; TDEAboutData *aboutData;

@ -25,6 +25,7 @@
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <kservicegroup.h> #include <kservicegroup.h>
#include <kiconloader.h> #include <kiconloader.h>
#include <tdecmoduleloader.h>
#include <kdebug.h> #include <kdebug.h>
@ -168,3 +169,14 @@ TQPixmap ModuleIconView::loadIcon( const TQString &name )
return icon; return icon;
} }
ModuleIconItem::ModuleIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, ConfigModule *m)
: TDEListViewItem(parent, text)
, _tag(TQString::null)
, _module(m)
{
setPixmap(0, pm);
if (!_module) return;
setVisible(KCGlobal::showHiddenModules() || !_module->needsTest() || TDECModuleLoader::testModule(*_module));
}

@ -29,13 +29,7 @@ class ModuleIconItem : public TDEListViewItem
{ {
public: public:
ModuleIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, ConfigModule *m = 0) ModuleIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, ConfigModule *m = 0);
: TDEListViewItem(parent, text)
, _tag(TQString::null)
, _module(m)
{
setPixmap(0, pm);
}
void setConfigModule(ConfigModule* m) { _module = m; } void setConfigModule(ConfigModule* m) { _module = m; }
void setTag(const TQString& t) { _tag = t; } void setTag(const TQString& t) { _tag = t; }

@ -286,7 +286,7 @@ bool ConfigModuleList::readDesktopEntriesRecursive(const TQString &path)
continue; continue;
ConfigModule *module = new ConfigModule(s); ConfigModule *module = new ConfigModule(s);
if (module->library().isEmpty() || (module->needsTest() && !TDECModuleLoader::testModule(*module))) if (module->library().isEmpty())
{ {
delete module; delete module;
continue; continue;

@ -26,6 +26,7 @@
#include <tdelocale.h> #include <tdelocale.h>
#include <kiconloader.h> #include <kiconloader.h>
#include <kservicegroup.h> #include <kservicegroup.h>
#include <tdecmoduleloader.h>
#include <kdebug.h> #include <kdebug.h>
#include <tqwhatsthis.h> #include <tqwhatsthis.h>
#include <tqbitmap.h> #include <tqbitmap.h>
@ -91,6 +92,14 @@ ModuleTreeView::ModuleTreeView(ConfigModuleList *list, TQWidget * parent, const
void ModuleTreeView::fill() void ModuleTreeView::fill()
{ {
// If we have a currently selected module, preserve selection
ConfigModule *currentModule = nullptr;
if (currentItem())
{
currentModule = static_cast<ModuleTreeItem*>(currentItem())->module();
}
// (Re)fill the tree view
clear(); clear();
TQStringList subMenus = _modules->submenus(KCGlobal::baseGroup()); TQStringList subMenus = _modules->submenus(KCGlobal::baseGroup());
@ -107,7 +116,14 @@ void ModuleTreeView::fill()
TQPtrList<ConfigModule> moduleList = _modules->modules(KCGlobal::baseGroup()); TQPtrList<ConfigModule> moduleList = _modules->modules(KCGlobal::baseGroup());
for (module=moduleList.first(); module != 0; module=moduleList.next()) for (module=moduleList.first(); module != 0; module=moduleList.next())
{ {
new ModuleTreeItem(this, module); new ModuleTreeItem(this, module);
}
// Restore selection
if (currentModule)
{
makeSelected(currentModule);
makeVisible(currentModule);
} }
} }
@ -131,8 +147,6 @@ void ModuleTreeView::fill(ModuleTreeItem *parent, const TQString &parentPath)
} }
} }
TQSize ModuleTreeView::sizeHint() const TQSize ModuleTreeView::sizeHint() const
{ {
return TQListView::sizeHint().boundedTo( return TQListView::sizeHint().boundedTo(
@ -272,12 +286,7 @@ ModuleTreeItem::ModuleTreeItem(TQListViewItem *parent, ConfigModule *module)
, _tag(TQString::null) , _tag(TQString::null)
, _maxChildIconWidth(0) , _maxChildIconWidth(0)
{ {
if (_module) init();
{
setText(0, " " + module->moduleName());
_icon = module->icon();
setPixmap(0, appIcon(_icon));
}
} }
ModuleTreeItem::ModuleTreeItem(TQListView *parent, ConfigModule *module) ModuleTreeItem::ModuleTreeItem(TQListView *parent, ConfigModule *module)
@ -286,12 +295,7 @@ ModuleTreeItem::ModuleTreeItem(TQListView *parent, ConfigModule *module)
, _tag(TQString::null) , _tag(TQString::null)
, _maxChildIconWidth(0) , _maxChildIconWidth(0)
{ {
if (_module) init();
{
setText(0, " " + module->moduleName());
_icon = module->icon();
setPixmap(0, appIcon(_icon));
}
} }
ModuleTreeItem::ModuleTreeItem(TQListViewItem *parent, const TQString& text) ModuleTreeItem::ModuleTreeItem(TQListViewItem *parent, const TQString& text)
@ -308,6 +312,18 @@ ModuleTreeItem::ModuleTreeItem(TQListView *parent, const TQString& text)
, _maxChildIconWidth(0) , _maxChildIconWidth(0)
{} {}
void ModuleTreeItem::init()
{
if (!_module) return;
setText(0, " " + _module->moduleName());
_icon = _module->icon();
setPixmap(0, appIcon(_icon));
setVisible(KCGlobal::showHiddenModules() || !_module->needsTest() || TDECModuleLoader::testModule(*_module));
}
void ModuleTreeItem::setPixmap(int column, const TQPixmap& pm) void ModuleTreeItem::setPixmap(int column, const TQPixmap& pm)
{ {
if (!pm.isNull()) if (!pm.isNull())

@ -56,6 +56,9 @@ public:
protected: protected:
void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ); void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align );
private:
void init();
private: private:
ConfigModule *_module; ConfigModule *_module;
TQString _tag; TQString _tag;

@ -267,6 +267,10 @@ actionCollection());
actionCollection(), "activate_hugeicons"); actionCollection(), "activate_hugeicons");
icon_huge->setExclusiveGroup( "iconsize" ); icon_huge->setExclusiveGroup( "iconsize" );
show_hidden_modules = new TDEToggleAction
(i18n("Show hidden modules"), 0, this, TQ_SLOT(toggleHiddenModules()),
actionCollection(), "show_hidden_modules");
about_module = new TDEAction(i18n("About Current Module"), 0, this, TQ_SLOT(aboutModule()), actionCollection(), "help_about_module"); about_module = new TDEAction(i18n("About Current Module"), 0, this, TQ_SLOT(aboutModule()), actionCollection(), "help_about_module");
about_module->setEnabled(false); about_module->setEnabled(false);
@ -340,6 +344,12 @@ void TopLevel::activateHugeIcons()
_index->reload(); _index->reload();
} }
void TopLevel::toggleHiddenModules()
{
KCGlobal::setShowHiddenModules(show_hidden_modules->isChecked());
_index->reload();
}
void TopLevel::newModule(const TQString &name, const TQString& docPath, const TQString &quickhelp) void TopLevel::newModule(const TQString &name, const TQString& docPath, const TQString &quickhelp)
{ {
setCaption(name, false); setCaption(name, false);

@ -64,6 +64,7 @@ protected slots:
void activateMediumIcons(); void activateMediumIcons();
void activateLargeIcons(); void activateLargeIcons();
void activateHugeIcons(); void activateHugeIcons();
void toggleHiddenModules();
void deleteDummyAbout(); void deleteDummyAbout();
@ -86,6 +87,7 @@ private:
TDEToggleAction *tree_view, *icon_view; TDEToggleAction *tree_view, *icon_view;
TDEToggleAction *icon_small, *icon_medium, *icon_large, *icon_huge; TDEToggleAction *icon_small, *icon_medium, *icon_large, *icon_huge;
TDEToggleAction *show_hidden_modules;
TDEAction *report_bug, *about_module; TDEAction *report_bug, *about_module;
IndexWidget *_index; IndexWidget *_index;

Loading…
Cancel
Save