summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-09-11 12:56:48 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-09-22 13:55:02 +0300
commit82ed0caa3f87db41359230813b23b539d88a32eb (patch)
tree74e8887e7419d4d3fd7e46ce9fafb083cf19ad61
parent8da4fdbdbc7635014f83bfa1364dfdadcb00677b (diff)
downloadtdebase-82ed0caa3f87db41359230813b23b539d88a32eb.tar.gz
tdebase-82ed0caa3f87db41359230813b23b539d88a32eb.zip
KControl: Add option to toggle visibility of hidden modules
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r--kcontrol/kcontrol/global.cpp1
-rw-r--r--kcontrol/kcontrol/global.h3
-rw-r--r--kcontrol/kcontrol/indexwidget.cpp2
-rw-r--r--kcontrol/kcontrol/kcontrolui.rc2
-rw-r--r--kcontrol/kcontrol/main.cpp2
-rw-r--r--kcontrol/kcontrol/moduleiconview.cpp12
-rw-r--r--kcontrol/kcontrol/moduleiconview.h8
-rw-r--r--kcontrol/kcontrol/modules.cpp2
-rw-r--r--kcontrol/kcontrol/moduletreeview.cpp46
-rw-r--r--kcontrol/kcontrol/moduletreeview.h3
-rw-r--r--kcontrol/kcontrol/toplevel.cpp10
-rw-r--r--kcontrol/kcontrol/toplevel.h2
12 files changed, 69 insertions, 24 deletions
diff --git a/kcontrol/kcontrol/global.cpp b/kcontrol/kcontrol/global.cpp
index b17581846..c78de0071 100644
--- a/kcontrol/kcontrol/global.cpp
+++ b/kcontrol/kcontrol/global.cpp
@@ -43,6 +43,7 @@ TQString KCGlobal::_iversion = "";
TQString KCGlobal::_imachine = "";
IndexViewMode KCGlobal::_viewmode = Icon;
TDEIcon::StdSizes KCGlobal::_iconsize = TDEIcon::SizeMedium;
+bool KCGlobal::_showhidden = false;
TQString KCGlobal::_baseGroup = "";
void KCGlobal::init()
diff --git a/kcontrol/kcontrol/global.h b/kcontrol/kcontrol/global.h
index 0fbc1d9b7..a0b44c0b7 100644
--- a/kcontrol/kcontrol/global.h
+++ b/kcontrol/kcontrol/global.h
@@ -46,6 +46,7 @@ public:
static TQString systemMachine() { return _imachine; }
static IndexViewMode viewMode() { return _viewmode; }
static TDEIcon::StdSizes iconSize() { return _iconsize; }
+ static bool showHiddenModules() { return _showhidden; }
static TQString baseGroup();
static void setIsInfoCenter(bool b) { _infocenter = b; }
@@ -60,6 +61,7 @@ public:
static void setSystemMachine(const TQString& n){ _imachine = n; }
static void setViewMode(IndexViewMode m) { _viewmode = m; }
static void setIconSize(TDEIcon::StdSizes s) { _iconsize = s; }
+ static void setShowHiddenModules(bool o) { _showhidden = o; }
static void repairAccels( TQWidget * tw );
@@ -71,6 +73,7 @@ private:
static IndexViewMode _viewmode;
static TDEIcon::StdSizes _iconsize;
static TQString _baseGroup;
+ static bool _showhidden;
};
#endif
diff --git a/kcontrol/kcontrol/indexwidget.cpp b/kcontrol/kcontrol/indexwidget.cpp
index 293c5e1d8..ed8e8ca03 100644
--- a/kcontrol/kcontrol/indexwidget.cpp
+++ b/kcontrol/kcontrol/indexwidget.cpp
@@ -42,6 +42,8 @@ void IndexWidget::reload()
{
if (_icon)
_icon->fill();
+ if (_tree)
+ _tree->fill();
}
TQListViewItem *IndexWidget::firstTreeViewItem()
diff --git a/kcontrol/kcontrol/kcontrolui.rc b/kcontrol/kcontrol/kcontrolui.rc
index 92867beb3..c9e4c48aa 100644
--- a/kcontrol/kcontrol/kcontrolui.rc
+++ b/kcontrol/kcontrol/kcontrolui.rc
@@ -12,6 +12,8 @@
<Action name="activate_largeicons"/>
<Action name="activate_hugeicons"/>
</Menu>
+ <Separator/>
+ <Action name="show_hidden_modules"/>
</Menu>
<Menu name="help">
<Action name="help_about_module" append="about_merge"/>
diff --git a/kcontrol/kcontrol/main.cpp b/kcontrol/kcontrol/main.cpp
index 7d709bce5..2e7fac8be 100644
--- a/kcontrol/kcontrol/main.cpp
+++ b/kcontrol/kcontrol/main.cpp
@@ -103,7 +103,7 @@ extern "C" TDE_EXPORT int kdemain(int argc, char *argv[])
TDELocale::setMainCatalogue("kcontrol");
TDEAboutData aboutKControl( "kcontrol", I18N_NOOP("Trinity Control Center"),
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];
TDEAboutData *aboutData;
diff --git a/kcontrol/kcontrol/moduleiconview.cpp b/kcontrol/kcontrol/moduleiconview.cpp
index 7c171f676..6c0f39115 100644
--- a/kcontrol/kcontrol/moduleiconview.cpp
+++ b/kcontrol/kcontrol/moduleiconview.cpp
@@ -25,6 +25,7 @@
#include <kstandarddirs.h>
#include <kservicegroup.h>
#include <kiconloader.h>
+#include <tdecmoduleloader.h>
#include <kdebug.h>
@@ -168,3 +169,14 @@ TQPixmap ModuleIconView::loadIcon( const TQString &name )
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));
+} \ No newline at end of file
diff --git a/kcontrol/kcontrol/moduleiconview.h b/kcontrol/kcontrol/moduleiconview.h
index daaeaa7ea..ff76ebce2 100644
--- a/kcontrol/kcontrol/moduleiconview.h
+++ b/kcontrol/kcontrol/moduleiconview.h
@@ -29,13 +29,7 @@ class ModuleIconItem : public TDEListViewItem
{
public:
- ModuleIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, ConfigModule *m = 0)
- : TDEListViewItem(parent, text)
- , _tag(TQString::null)
- , _module(m)
- {
- setPixmap(0, pm);
- }
+ ModuleIconItem(TQListView *parent, const TQString& text, const TQPixmap& pm, ConfigModule *m = 0);
void setConfigModule(ConfigModule* m) { _module = m; }
void setTag(const TQString& t) { _tag = t; }
diff --git a/kcontrol/kcontrol/modules.cpp b/kcontrol/kcontrol/modules.cpp
index 0d6c9f7fc..ed19874ca 100644
--- a/kcontrol/kcontrol/modules.cpp
+++ b/kcontrol/kcontrol/modules.cpp
@@ -286,7 +286,7 @@ bool ConfigModuleList::readDesktopEntriesRecursive(const TQString &path)
continue;
ConfigModule *module = new ConfigModule(s);
- if (module->library().isEmpty() || (module->needsTest() && !TDECModuleLoader::testModule(*module)))
+ if (module->library().isEmpty())
{
delete module;
continue;
diff --git a/kcontrol/kcontrol/moduletreeview.cpp b/kcontrol/kcontrol/moduletreeview.cpp
index a226cbc89..15f5cb9eb 100644
--- a/kcontrol/kcontrol/moduletreeview.cpp
+++ b/kcontrol/kcontrol/moduletreeview.cpp
@@ -26,6 +26,7 @@
#include <tdelocale.h>
#include <kiconloader.h>
#include <kservicegroup.h>
+#include <tdecmoduleloader.h>
#include <kdebug.h>
#include <tqwhatsthis.h>
#include <tqbitmap.h>
@@ -91,6 +92,14 @@ ModuleTreeView::ModuleTreeView(ConfigModuleList *list, TQWidget * parent, const
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();
TQStringList subMenus = _modules->submenus(KCGlobal::baseGroup());
@@ -107,7 +116,14 @@ void ModuleTreeView::fill()
TQPtrList<ConfigModule> moduleList = _modules->modules(KCGlobal::baseGroup());
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
{
return TQListView::sizeHint().boundedTo(
@@ -272,12 +286,7 @@ ModuleTreeItem::ModuleTreeItem(TQListViewItem *parent, ConfigModule *module)
, _tag(TQString::null)
, _maxChildIconWidth(0)
{
- if (_module)
- {
- setText(0, " " + module->moduleName());
- _icon = module->icon();
- setPixmap(0, appIcon(_icon));
- }
+ init();
}
ModuleTreeItem::ModuleTreeItem(TQListView *parent, ConfigModule *module)
@@ -286,12 +295,7 @@ ModuleTreeItem::ModuleTreeItem(TQListView *parent, ConfigModule *module)
, _tag(TQString::null)
, _maxChildIconWidth(0)
{
- if (_module)
- {
- setText(0, " " + module->moduleName());
- _icon = module->icon();
- setPixmap(0, appIcon(_icon));
- }
+ init();
}
ModuleTreeItem::ModuleTreeItem(TQListViewItem *parent, const TQString& text)
@@ -308,6 +312,18 @@ ModuleTreeItem::ModuleTreeItem(TQListView *parent, const TQString& text)
, _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)
{
if (!pm.isNull())
diff --git a/kcontrol/kcontrol/moduletreeview.h b/kcontrol/kcontrol/moduletreeview.h
index ad21d8715..bf0a12f72 100644
--- a/kcontrol/kcontrol/moduletreeview.h
+++ b/kcontrol/kcontrol/moduletreeview.h
@@ -57,6 +57,9 @@ protected:
void paintCell( TQPainter * p, const TQColorGroup & cg, int column, int width, int align );
private:
+ void init();
+
+private:
ConfigModule *_module;
TQString _tag;
TQString _caption;
diff --git a/kcontrol/kcontrol/toplevel.cpp b/kcontrol/kcontrol/toplevel.cpp
index d3b2a3c2f..667290c3b 100644
--- a/kcontrol/kcontrol/toplevel.cpp
+++ b/kcontrol/kcontrol/toplevel.cpp
@@ -267,6 +267,10 @@ actionCollection());
actionCollection(), "activate_hugeicons");
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->setEnabled(false);
@@ -340,6 +344,12 @@ void TopLevel::activateHugeIcons()
_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)
{
setCaption(name, false);
diff --git a/kcontrol/kcontrol/toplevel.h b/kcontrol/kcontrol/toplevel.h
index 8d2a84145..0abf4e0e5 100644
--- a/kcontrol/kcontrol/toplevel.h
+++ b/kcontrol/kcontrol/toplevel.h
@@ -64,6 +64,7 @@ protected slots:
void activateMediumIcons();
void activateLargeIcons();
void activateHugeIcons();
+ void toggleHiddenModules();
void deleteDummyAbout();
@@ -86,6 +87,7 @@ private:
TDEToggleAction *tree_view, *icon_view;
TDEToggleAction *icon_small, *icon_medium, *icon_large, *icon_huge;
+ TDEToggleAction *show_hidden_modules;
TDEAction *report_bug, *about_module;
IndexWidget *_index;