TDE System Settings – easy to use control center
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

174 satır
5.3 KiB

  1. /**
  2. * This file is part of the System Settings package
  3. * Copyright (C) 2005 Benjamin C Meyer (ben+systempreferences at meyerhome dot net)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #include "modulesview.h"
  21. #include <tqlabel.h>
  22. #include <klocale.h>
  23. #include <kservicegroup.h>
  24. #include <tqlayout.h>
  25. #include <kiconloader.h>
  26. #include <kcmultidialog.h>
  27. #include <kdialogbase.h>
  28. #include <kiconviewsearchline.h>
  29. #include <kapplication.h>
  30. #include <kaboutapplication.h>
  31. #include <kdebug.h>
  32. #include <tqiconview.h>
  33. #include "kcmsearch.h"
  34. #include "moduleiconitem.h"
  35. #include "kcmodulemenu.h"
  36. ModulesView::ModulesView( KCModuleMenu *rootMenu, const TQString &menuPath, TQWidget *parent,
  37. const char *name ) : TQWidget( parent, name ), rootMenu( NULL )
  38. {
  39. this->rootMenu = rootMenu;
  40. this->menuPath = menuPath;
  41. TQVBoxLayout *tqlayout = new TQVBoxLayout( this, 11, 6, "tqlayout" );
  42. displayName = this->rootMenu->caption;
  43. TQValueList<MenuItem> subMenus = rootMenu->menuList(menuPath);
  44. TQValueList<MenuItem>::iterator it;
  45. for ( it = subMenus.begin(); it != subMenus.end(); ++it ){
  46. if( !(*it).menu )
  47. continue;
  48. // After the first time around add a line
  49. if( it != subMenus.begin() ){
  50. TQFrame *line = new TQFrame( this, "line");
  51. line->setFrameShadow( TQFrame::Sunken );
  52. line->setFrameShape( TQFrame::HLine );
  53. tqlayout->addWidget( line );
  54. }
  55. // Build the row of modules/icons
  56. createRow( (*it).subMenu, tqlayout );
  57. }
  58. tqlayout->addStretch(1);
  59. // Make empty iconView for the search widget
  60. if( groups.count()==0 ) {
  61. RowIconView *iconView = new RowIconView( this, "groupiconview" );
  62. iconView->setLineWidth( 0 );
  63. groups.append( iconView );
  64. }
  65. setPaletteBackgroundColor( groups[0]->paletteBackgroundColor() );
  66. // Align them up!
  67. {
  68. uint most = 0;
  69. TQValueList<RowIconView*>::iterator it;
  70. for ( it = groups.begin(); it != groups.end(); ++it ){
  71. TQIconViewItem *item = (*it)->firstItem();
  72. while( item ) {
  73. if(item->width() > most)
  74. most = item->width();
  75. item = item->nextItem();
  76. }
  77. }
  78. for ( it = groups.begin(); it != groups.end(); ++it )
  79. (*it)->setGridX(most);
  80. }
  81. }
  82. ModulesView::~ModulesView()
  83. {
  84. }
  85. void ModulesView::createRow( const TQString &parentPath, TQBoxLayout *boxLayout )
  86. {
  87. KServiceGroup::Ptr group = KServiceGroup::group( parentPath );
  88. if ( !group ){
  89. kdDebug() << "Invalid Group \"" << parentPath << "\". Check your installation."<< endl;
  90. return;
  91. }
  92. // Make header
  93. TQHBoxLayout *rowLayout = new TQHBoxLayout( 0, 0, 6, "rowLayout" );
  94. // Heaer Icon
  95. TQLabel *icon = new TQLabel( this, "groupicon" );
  96. icon->setPixmap( SmallIcon( group->icon() ) );
  97. icon->tqsetSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1,
  98. (TQSizePolicy::SizeType)5, 0, 0, icon->sizePolicy().hasHeightForWidth() ) );
  99. rowLayout->addWidget( icon );
  100. // Header Name
  101. TQLabel *textLabel = new TQLabel( this, "groupcaption" );
  102. textLabel->setText( group->caption() );
  103. textLabel->tqsetSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)7,
  104. (TQSizePolicy::SizeType)5, 0, 0, textLabel->sizePolicy().hasHeightForWidth()));
  105. TQFont textLabel_font( textLabel->font() );
  106. textLabel_font.setBold( true );
  107. textLabel->setFont( textLabel_font );
  108. rowLayout->addWidget( textLabel );
  109. boxLayout->addLayout( rowLayout );
  110. // Make IconView
  111. RowIconView *iconView = new RowIconView( this, "groupiconview" );
  112. iconView->setFrameShape( RowIconView::StyledPanel );
  113. iconView->setLineWidth( 0 );
  114. iconView->setSpacing( 0 );
  115. iconView->setMargin( 0 );
  116. iconView->setItemsMovable( false );
  117. iconView->setSelectionMode(TQIconView::NoSelection);
  118. groups.append( iconView );
  119. connect(iconView, TQT_SIGNAL( clicked( TQIconViewItem* ) ),
  120. this, TQT_SIGNAL( itemSelected( TQIconViewItem* ) ) );
  121. boxLayout->addWidget( iconView );
  122. // Add all the items in their proper order
  123. TQValueList<MenuItem> list = rootMenu->menuList( parentPath );
  124. TQValueList<MenuItem>::iterator it;
  125. for ( it = list.begin(); it != list.end(); ++it ){
  126. if( !(*it).menu )
  127. (void)new ModuleIconItem( iconView, (*it).item );
  128. else
  129. {
  130. TQString path = (*it).subMenu;
  131. KServiceGroup::Ptr group = KServiceGroup::group( path );
  132. if ( group ) {
  133. ModuleIconItem *item = new ModuleIconItem( ((KIconView*)iconView),
  134. group->caption(), group->icon() );
  135. item->modules = rootMenu->modules( path );
  136. }
  137. }
  138. }
  139. // Force the height for those items that have two words.
  140. iconView->setMinimumHeight( iconView->tqminimumSizeHint().height() );
  141. }
  142. void ModulesView::clearSelection() {
  143. TQValueList<RowIconView*>::iterator it;
  144. for ( it = groups.begin(); it != groups.end(); ++it ) {
  145. (*it)->clearSelection();
  146. }
  147. }
  148. #include "modulesview.moc"