Exemple #1
0
/***************************************************************************
  * reads the TDEConfig
**/
void KDFWidget::loadSettings( void )
{
  mStd.updateConfiguration();

  if(GUI)
  {
    TDEConfig &config = *kapp->config();
    config.setGroup("KDiskFree");
    for( uint i=0; i<mTabProp.size(); i++ )
    {
      CTabEntry &e = *mTabProp[i];
      e.mWidth = config.readNumEntry( e.mRes, e.mWidth );
    }
    if (mTabProp[usageCol]->mWidth > 16)
      mTabProp[usageCol]->mWidth -= 16;

    config.setGroup("KDFConfig");
    for( uint i=0; i<mTabProp.size(); i++ )
    {
      CTabEntry &e = *mTabProp[i];
      e.mVisible = config.readBoolEntry( e.mRes, e.mVisible );
    }

    makeColumns();
    setUpdateFrequency( mStd.updateFrequency() );
    updateDF();
  }
}
DiskInfoWidget::DiskInfoWidget(QWidget *parent, const char *name, ConfigDialogImpl *config, bool init)
	: QWidget(parent, name)
{
		_config = config;

		connect(&mDiskList , SIGNAL(readDFDone() ), this, SLOT (updateDFDone()) );
		connect(&mDiskList , SIGNAL(criticallyFull(DiskEntry*)), this, SLOT (criticallyFull(DiskEntry*)) );

		mTabProp.resize(8);
		mTabProp[0] = new CTabEntry( "Icon", i18n("Icon"), false, 0);
		mTabProp[1] = new CTabEntry( "Device", i18n("Device"), false, 0);
		mTabProp[2] = new CTabEntry( "Type", i18n("Type"), false, 0);
		mTabProp[3] = new CTabEntry( "Size", i18n("Size"), false, 0);
		mTabProp[4] = new CTabEntry( "MountPoint", i18n("Mount Point"), true, 90 );
		mTabProp[5] = new CTabEntry( "Free", i18n("Free"), false, 0);
		// xgettext:no-c-format
		mTabProp[6] = new CTabEntry( "Full%", i18n("Full %"), false, 0);
		mTabProp[7] = new CTabEntry( "UsageBar", i18n("Usage"), true, 100);

		GUI = !init;
		if( GUI )
		{
			QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 0 );
			mList = new CListView( this, "list" );
			topLayout->addWidget( mList );

			mList->setAllColumnsShowFocus( true );
			mList->setFrameStyle( QFrame::WinPanel + QFrame::Sunken );
			mList->setShowSortIndicator(true);
			QPalette pal;
			QColorGroup cg;
			cg.setColor( QColorGroup::Button, BACKGROUND );
			cg.setColor( QColorGroup::ButtonText, TEXTCOLOR );
			cg.setColor( QColorGroup::Base, BACKGROUND );
			pal.setActive( cg );
			cg.setColor( QColorGroup::Button, BACKGROUND );
			cg.setColor( QColorGroup::ButtonText, TEXTCOLOR );
			cg.setColor( QColorGroup::Base, BACKGROUND );
			pal.setInactive( cg );
			cg.setColor( QColorGroup::Button, BACKGROUND );
			cg.setColor( QColorGroup::ButtonText, TEXTCOLOR );
			cg.setColor( QColorGroup::Base, BACKGROUND );
			pal.setDisabled( cg );
			mList->setPalette( pal );
//			connect( mList,
//				SIGNAL( pressed( QListViewItem *, const QPoint &, int )),
//				this, SLOT( rightButtonPressed( QListViewItem *, const QPoint &, int )));
//			connect( mList,
//				SIGNAL( clicked( QListViewItem *, const QPoint &, int )),
//				this, SLOT( rightButtonClicked( QListViewItem *, const QPoint &, int )));
			connect( mList->header(), SIGNAL(sizeChange(int, int, int)),
				this, SLOT(columnSizeChanged(int, int, int)) );
			makeColumns();
		}

		updateDF();
		setUpdateFrequency(60);
}
Exemple #3
0
void KwikDisk::mousePressEvent(TQMouseEvent *me)
{
   kdDebug() << k_funcinfo << endl;

   if( m_dirty )
      updateDF();

   if( m_menuVisible )
   {
      contextMenu()->hide();
      m_menuVisible = FALSE;
      me->ignore();
      return;
   }

   contextMenuAboutToShow(contextMenu());
   contextMenu()->popup( me->globalPos() );
   m_menuVisible = TRUE;
}
Exemple #4
0
/***************************************************************************
  * writes the TDEConfig
**/
void KDFWidget::applySettings( void )
{
  TDEConfig &config = *kapp->config();

  config.setGroup("KDiskFree");
  if( GUI )
  {
    for( uint i=0; i<mTabProp.size(); i++ )
    {
      CTabEntry &e = *mTabProp[i];
      if( e.mVisible == true )
      {
	e.mWidth = mList->columnWidth(i);
      }
      config.writeEntry( e.mRes, e.mWidth );
    }
  }
  config.sync();
  updateDF();
}
Exemple #5
0
KwikDisk::KwikDisk()
   : KSystemTray()
   , m_readingDF(FALSE)
   , m_dirty(TRUE)
   , m_menuVisible(FALSE)
   , m_inside(FALSE)
   , m_optionDialog(0)
{
   kdDebug() << k_funcinfo << endl;

   setPixmap(KSystemTray::loadIcon("kdf"));
   show();

   connect( &m_diskList, TQT_SIGNAL(readDFDone()), this, TQT_SLOT(updateDFDone()) );
   connect( &m_diskList, TQT_SIGNAL(criticallyFull(DiskEntry*)),
            this, TQT_SLOT(criticallyFull(DiskEntry*)) );

   connect( contextMenu(), TQT_SIGNAL(aboutToHide()), this, TQT_SLOT(aboutToHide()) );

   loadSettings();
   updateDF();
}
void DiskInfoWidget::timerEvent(QTimerEvent *)
{
  updateDF();
}
Exemple #7
0
/**************************************************************************
  * pops up and asks for mount/umount right-clicked device
**/
void KDFWidget::popupMenu( TQListViewItem *item, const TQPoint &p )
{
  if (mPopup) //The user may even be able to popup another menu while this open is active...
       return;

  //
  // The list update will be disabled as long as this menu is
  // visible. Reason: The 'disk' may no longer be valid.
  //

  mDiskList.setUpdatesDisabled(true);  
  DiskEntry *disk = selectedDisk( item );
  if( disk == 0 )
  {
    return;
  }

  mPopup = new TDEPopupMenu( 0 );
  mPopup->insertTitle( disk->mountPoint() );
  mPopup->insertItem( i18n("Mount Device"), 0 );
  mPopup->insertItem( i18n("Unmount Device"), 1 );
  mPopup->insertSeparator();
  mPopup->insertItem( i18n("Open in File Manager"), 2 );
  mPopup->setItemEnabled( 0, disk->mounted() ? false : true );
  mPopup->setItemEnabled( 1, disk->mounted() );
  mPopup->setItemEnabled( 2, disk->mounted() );  
  int position = mPopup->exec( p );  
  


  bool openFileManager = false;
  if( position == -1 )
  {
    mDiskList.setUpdatesDisabled(false);
    delete mPopup; mPopup = 0;
    return;
  }
  else if( position == 0 || position == 1 )
  {
      item->setText( sizeCol, i18n("MOUNTING") );
      item->setText( freeCol, i18n("MOUNTING") );
      item->setPixmap( 0, mList->icon( "mini-clock", false ) );

      int val = disk->toggleMount();
      if( val != 0 /*== false*/ )
	{
	  KMessageBox::error( this, disk->lastSysError() );
	}
      else if ( ( mStd.openFileManager() == true)
		&& (position == 0) ) //only on mount
	{
	  openFileManager = true;
	}

      delete item;
      mDiskList.deleteAllMountedAt(disk->mountPoint());
  }
  else if( position == 2 )
  {
    openFileManager = true;
  }

  if( openFileManager == true )
  {
    kdDebug() << "opening filemanager" << endl;
    if(  mStd.fileManager().isEmpty() == false )
    {
      TQString cmd = mStd.fileManager();
      int pos = cmd.find("%m");
      if( pos > 0 )
      {
	cmd = cmd.replace( pos, 2, TDEProcess::quote(disk->mountPoint()) ) + " &";
      }
      else
      {
	cmd += " " + TDEProcess::quote(disk->mountPoint()) +" &";
      }
      system( TQFile::encodeName(cmd) );
    }
  }
  
  //Update only here as showing of error message triggers event loop.
  mDiskList.setUpdatesDisabled(false);
  delete mPopup; mPopup = 0;

  if( position != 2 ) // No need to update when just opening the fm.
  {
    updateDF();
  }
  
}
Exemple #8
0
/***************************************************************************
  * Update (reread) all disk-dependencies
**/
void KDFWidget::timerEvent(TQTimerEvent *)
{
  updateDF();
}