diff --git a/kcontrol/konq/desktopbehavior.ui b/kcontrol/konq/desktopbehavior.ui index c247ab354..2f346f47e 100644 --- a/kcontrol/konq/desktopbehavior.ui +++ b/kcontrol/konq/desktopbehavior.ui @@ -33,79 +33,243 @@ General - + unnamed - + - iconsEnabledBox - - - - 7 - 0 - 0 - 0 - - - - &Show icons on desktop - - - Uncheck this option if you do not want to have icons on the desktop. Without icons the desktop will be somewhat faster but you will no longer be able to drag files to the desktop. + iconsGroupBox - - - - layout1 + + Desktop Icons - - - unnamed - - + + - spacer3 + iconsEnabledBox - - Horizontal + + + 7 + 0 + 0 + 0 + - - Fixed + + &Show icons on desktop - - - 20 - 0 - + + Uncheck this option if you do not want to have icons on the desktop. Without icons the desktop will be somewhat faster but you will no longer be able to drag files to the desktop. - + + + + layout1 + + + + unnamed + + + + spacer1 + + + Horizontal + + + Fixed + + + + 20 + 0 + + + + + + vrootBox + + + false + + + Allow pro&grams in desktop window + + + Check this option if you want to run X11 programs that draw into the desktop such as xsnow, xpenguin or xmountain. If you have problems with applications like netscape that check the root window for running instances, disable this option. + + + + - vrootBox - - - false + toolTipBox - Allow pro&grams in desktop window + Show &tooltips - - Check this option if you want to run X11 programs that draw into the desktop such as xsnow, xpenguin or xmountain. If you have problems with applications like netscape that check the root window for running instances, disable this option. + + + + iconOptsSeparator - - - - - toolTipBox - - - Show &tooltips - + + + iconOptsOuterLayout + + + + + iconOptsVLayout + + + + + lockInPlaceBox + + + false + + + Lock in Place + + + Check this option if you want to prevent your icons from being dragged around. + + + + + autoLineupIconsBox + + + false + + + Align to grid + + + Check this option if you want to see your icons automatically aligned to the grid when you move them. + + + + + + + spacer2 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + spacingVLayout + + + + + spacingValueLayout + + + + spacingLayout + + + + spacingLabel + + + Icon Spacing: + + + Changing this value controls how close or far to each other the icons are placed on the desktop. This option has effect only if the "Align to Grid" option is enabled. + + + + + spacingValue + + + Default + + + px + + + 5 + + + Changing this value controls how close or far to each other the icons are placed on the desktop. This option has effect only if the "Align to Grid" option is enabled. + + + + + spacer3 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + + + spacingCtrlScroll + + + Ctrl+Mouse Scroll changes spacing + + + Check this if you want to change desktop icon spacing by pressing Ctrl and scrolling on the desktop background. + + + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + - + desktopMenuGroup @@ -151,7 +315,7 @@ - + groupBox3 @@ -260,7 +424,7 @@ - spacer5 + spacer4 Horizontal @@ -277,9 +441,9 @@ - + - spacer8 + spacer5 Vertical @@ -294,7 +458,7 @@ - + @@ -307,17 +471,6 @@ unnamed - - - autoLineupIconsBox - - - Automatically &line up icons - - - Check this option if you want to see your icons automatically aligned to the grid when you move them. - - showHiddenBox diff --git a/kcontrol/konq/desktopbehavior_impl.cpp b/kcontrol/konq/desktopbehavior_impl.cpp index 17fc2f364..5c5fe2b95 100644 --- a/kcontrol/konq/desktopbehavior_impl.cpp +++ b/kcontrol/konq/desktopbehavior_impl.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -130,9 +131,12 @@ DesktopBehavior::DesktopBehavior(TDEConfig *config, TQWidget *parent, const char connect(iconsEnabledBox, TQT_SIGNAL(clicked()), this, TQT_SLOT(enableChanged())); connect(showHiddenBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed())); connect(vrootBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed())); - connect(autoLineupIconsBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed())); + connect(lockInPlaceBox, TQT_SIGNAL(clicked()), this, TQT_SLOT(enableGridChanged())); + connect(autoLineupIconsBox, TQT_SIGNAL(clicked()), this, TQT_SLOT(enableGridChanged())); connect(toolTipBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed())); connect(mediaListView, TQT_SIGNAL(clicked(TQListViewItem *)), this, TQT_SLOT(mediaListViewChanged(TQListViewItem *))); + connect(spacingValue, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(spacingChanged(int))); + connect(spacingCtrlScroll, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed())); strMouseButton1 = i18n("&Left button:"); strButtonTxt1 = i18n( "You can choose what happens when" @@ -236,6 +240,11 @@ void DesktopBehavior::mediaListViewChanged(TQListViewItem * item) emit changed(); } +void DesktopBehavior::spacingChanged(int value) +{ + emit changed(); +} + void DesktopBehavior::setMediaListViewEnabled(bool enabled) { for (DesktopBehaviorMediaItem *it=static_cast(mediaListView->firstChild()); @@ -307,6 +316,9 @@ void DesktopBehavior::load( bool useDefaults ) g_pConfig->setGroup( "Desktop Icons" ); bool bShowHidden = g_pConfig->readBoolEntry("ShowHidden", DEFAULT_SHOW_HIDDEN_ROOT_ICONS); showHiddenBox->setChecked(bShowHidden); + spacingValue->setValue( g_pConfig->readNumEntry("IconSpacing", 5) ); + spacingCtrlScroll->setChecked( g_pConfig->readBoolEntry("SpacingCtrlScroll", false) ); + lockInPlaceBox->setChecked( g_pConfig->readBoolEntry( "LockIcons", false ) ); //bool bVertAlign = g_pConfig->readBoolEntry("VertAlign", DEFAULT_VERT_ALIGN); TDETrader::OfferList plugins = TDETrader::self()->query("ThumbCreator"); previewListView->clear(); @@ -333,6 +345,8 @@ void DesktopBehavior::load( bool useDefaults ) iconsEnabledBox->setChecked( g_pConfig->readBoolEntry( "Enabled", true ) ); autoLineupIconsBox->setChecked( g_pConfig->readBoolEntry( "AutoLineUpIcons", false ) ); + toggleSpacingOpts(); + // g_pConfig->setGroup( "Mouse Buttons" ); TQString s; @@ -365,6 +379,9 @@ void DesktopBehavior::save() { g_pConfig->setGroup( "Desktop Icons" ); g_pConfig->writeEntry("ShowHidden", showHiddenBox->isChecked()); + g_pConfig->writeEntry("IconSpacing", spacingValue->value()); + g_pConfig->writeEntry("SpacingCtrlScroll", spacingCtrlScroll->isChecked()); + g_pConfig->writeEntry("LockIcons", lockInPlaceBox->isChecked()); TQStringList previews; for ( DesktopBehaviorPreviewItem *item = static_cast( previewListView->firstChild() ); item; @@ -395,6 +412,8 @@ void DesktopBehavior::save() g_pConfig->writeEntry( "Enabled", iconsEnabledBox->isChecked() ); g_pConfig->writeEntry( "AutoLineUpIcons", autoLineupIconsBox->isChecked() ); + toggleSpacingOpts(); + saveMediaListView(); g_pConfig->sync(); @@ -421,6 +440,9 @@ void DesktopBehavior::enableChanged() bool enabled = iconsEnabledBox->isChecked(); behaviorTab->setTabEnabled(behaviorTab->page(1), enabled); vrootBox->setEnabled(enabled); + lockInPlaceBox->setEnabled(enabled); + autoLineupIconsBox->setEnabled(enabled); + enableGridChanged(); if (m_bHasMedia) { @@ -433,6 +455,24 @@ void DesktopBehavior::enableChanged() changed(); } +void DesktopBehavior::toggleSpacingOpts() +{ + bool enabled = ( + autoLineupIconsBox->isEnabled() && // Desktop grid available + autoLineupIconsBox->isChecked() && // Desktop grid enabled + !lockInPlaceBox->isChecked() // Lock in Place is off + ); + + spacingCtrlScroll->setEnabled(enabled); + spacingValue->setEnabled(enabled); +} + +void DesktopBehavior::enableGridChanged() +{ + toggleSpacingOpts(); + changed(); +} + void DesktopBehavior::comboBoxChanged() { int i; diff --git a/kcontrol/konq/desktopbehavior_impl.h b/kcontrol/konq/desktopbehavior_impl.h index bc5965750..8a1a5c247 100644 --- a/kcontrol/konq/desktopbehavior_impl.h +++ b/kcontrol/konq/desktopbehavior_impl.h @@ -44,10 +44,12 @@ signals: void changed(); private slots: - void enableChanged(); + void enableChanged(); + void enableGridChanged(); void comboBoxChanged(); void editButtonPressed(); void mediaListViewChanged(TQListViewItem * item); + void spacingChanged(int value); private: TDEConfig *g_pConfig; @@ -56,6 +58,8 @@ private: void saveMediaListView(); void setMediaListViewEnabled(bool enabled); + void toggleSpacingOpts(); + // Combo for the menus void fillMenuCombo( TQComboBox * combo ); diff --git a/kdesktop/kdesktop.kcfg b/kdesktop/kdesktop.kcfg index 5df427c71..71e008562 100644 --- a/kdesktop/kdesktop.kcfg +++ b/kdesktop/kdesktop.kcfg @@ -155,6 +155,16 @@ If this is enabled, icons are aligned vertically, otherwise horizontally. + + 5 + +

This is the minimal distance (in pixels) between the icons on your desktop.

+
+ + false + +

If this is enabled, you can change desktop icon spacing by pressing Ctrl and scrolling on the desktop background.

+
diff --git a/kdesktop/kdiconview.cpp b/kdesktop/kdiconview.cpp index c8c5a1fe6..409887784 100644 --- a/kdesktop/kdiconview.cpp +++ b/kdesktop/kdiconview.cpp @@ -191,15 +191,13 @@ KDIconView::KDIconView( TQWidget *parent, const char* name ) if (!m_bEditableDesktopIcons) { - setItemsMovable(false); - setAcceptDrops(false); - viewport()->setAcceptDrops(false); + setIconsLocked(true); } } KDIconView::~KDIconView() { - if (m_dotDirectory && !m_bEditableDesktopIcons) { + if (m_dotDirectory && !m_bEditableDesktopIcons || m_iconsLocked) { m_dotDirectory->rollback(false); // Don't save positions } @@ -296,6 +294,7 @@ void KDIconView::initConfig( bool init ) m_bVertAlign = KDesktopSettings::vertAlign(); TQStringList oldPreview = previewSettings(); setPreviewSettings( KDesktopSettings::preview() ); + setSpacing( KDesktopSettings::iconSpacing() ); // read arrange configuration m_eSortCriterion = (SortCriterion)KDesktopSettings::sortCriterion(); @@ -486,6 +485,30 @@ void KDIconView::lineupIcons() saveIconPositions(); } +void KDIconView::incIconSpacing() +{ + if ( m_autoAlign && !KDesktopSettings::lockIcons() && KDesktopSettings::spacingCtrlScroll() ) + { + setSpacing( ( spacing() + 1 ) ); + lineupIcons(); + + KDesktopSettings::setIconSpacing( spacing() ); + KDesktopSettings::writeConfig(); + } +} + +void KDIconView::decIconSpacing() +{ + if ( m_autoAlign && !KDesktopSettings::lockIcons() && KDesktopSettings::spacingCtrlScroll() && spacing() > 5 ) + { + setSpacing( ( spacing() - 1 ) ); + lineupIcons(); + + KDesktopSettings::setIconSpacing( spacing() ); + KDesktopSettings::writeConfig(); + } +} + void KDIconView::setAutoAlign( bool b ) { m_autoAlign = b; @@ -517,6 +540,15 @@ void KDIconView::setAutoAlign( bool b ) } } +void KDIconView::setIconsLocked( bool lock ) +{ + m_iconsLocked = lock; + + setItemsMovable(!lock); + setAcceptDrops(!lock); + viewport()->setAcceptDrops(!lock); +} + void KDIconView::startDirLister() { // if desktop is resized before start() is called (XRandr) @@ -644,7 +676,22 @@ void KDIconView::wheelEvent( TQWheelEvent* e ) TQIconViewItem *item = findItem( e->pos() ); if ( !item ) { - emit wheelRolled( e->delta() ); + TQWheelEvent *we = TQT_TQWHEELEVENT(e); + + if ( we->state() == ControlButton ) + { + if ( we->delta() >= 0 ) + incIconSpacing(); + else + decIconSpacing(); + + we->accept(); + } + else + { + emit wheelRolled( e->delta() ); + } + return; } @@ -1726,25 +1773,25 @@ void KDIconView::viewportWheelEvent( TQWheelEvent * e ) void KDIconView::updateWorkArea( const TQRect &wr ) { m_gotIconsArea = true; // now we have it! - + if (( iconArea() == wr ) && (m_needDesktopAlign == false)) { // nothing changed; avoid repaint/saveIconPosition ... return; } - + TQRect oldArea = iconArea(); setIconArea( wr ); - + kdDebug(1204) << "KDIconView::updateWorkArea wr: " << wr.x() << "," << wr.y() << " " << wr.width() << "x" << wr.height() << endl; kdDebug(1204) << " oldArea: " << oldArea.x() << "," << oldArea.y() << " " << oldArea.width() << "x" << oldArea.height() << endl; - + bool needRepaint = false; TQIconViewItem* item; int dx, dy; - + dx = wr.left() - oldArea.left(); dy = wr.top() - oldArea.top(); - + if ( dx != 0 || dy != 0 ) { if ( (dx > 0) || (dy > 0) ) { // the iconArea was shifted right/down; less space now @@ -1762,14 +1809,14 @@ void KDIconView::updateWorkArea( const TQRect &wr ) // the iconArea was shifted left/up; more space now - use it needRepaint = true; } - + if ( needRepaint ) { for ( item = firstItem(); item; item = item->nextItem() ) { item->moveBy( dx, dy ); } } } - + for ( item = firstItem(); item; item = item->nextItem() ) { TQRect r( item->rect() ); int dx = 0, dy = 0; @@ -1789,7 +1836,7 @@ void KDIconView::updateWorkArea( const TQRect &wr ) repaint( FALSE ); saveIconPositions(); } - + m_needDesktopAlign = false; lineupIcons(); } @@ -1861,18 +1908,18 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item, const TQRect &curre if (!area.contains(r, FALSE)) { return false; } - + TQIconViewItem *it = firstItem(); for (; it; it = it->nextItem() ) { if ( !it->rect().isValid() || it == item ) { continue; } - + if ( it->intersects( r ) ) { return false; } } - + return true; } @@ -1891,12 +1938,12 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item, const TQRect& rect, if ( !rect.isValid() || it == item ) { continue; } - + if ( it->intersects( rect ) ) { return false; } } - + return true; } @@ -1921,12 +1968,12 @@ void KDIconView::moveToFreePosition(TQIconViewItem *item, const TQRect ¤tI m_lastDeletedIconPos = TQPoint(); return; } - + //try to find a free place to put the item, honouring the m_bVertAlign property TQRect rect=item->rect(); if (m_bVertAlign) { kdDebug(1214)<<"moveToFreePosition for vertical alignment"<iconView()->setAutoAlign( KDesktopSettings::autoLineUpIcons() ); if ( kapp->authorize( "editable_desktop_icons" ) ) { - m_pDesktop->iconView()->setItemsMovable( !KDesktopSettings::lockIcons() ); + m_pDesktop->iconView()->setIconsLocked( KDesktopSettings::lockIcons() ); TDEToggleAction *aLockIcons = static_cast(m_actionCollection->action("lock_icons")); if (aLockIcons) aLockIcons->setChecked( KDesktopSettings::lockIcons() ); @@ -732,12 +732,24 @@ void KRootWm::slotLineupIcons() { void KRootWm::slotToggleLockIcons( bool lock ) { - if (m_bDesktopEnabled) - { - m_pDesktop->iconView()->setItemsMovable( !lock ); - KDesktopSettings::setLockIcons( lock ); - KDesktopSettings::writeConfig(); - } + KDesktopSettings::setLockIcons( lock ); + KDesktopSettings::writeConfig(); + + // Also save it globally... + int desktop = TDEApplication::desktop()->primaryScreen(); + TQCString cfilename; + if (desktop == 0) + cfilename = "kdesktoprc"; + else + cfilename.sprintf("kdesktop-screen-%drc", desktop); + + TDEConfig *kdg_config = new TDEConfig(cfilename, false, false); + kdg_config->setGroup( "General" ); + kdg_config->writeEntry( "LockIcons", lock ); + kdg_config->sync(); + delete kdg_config; + + m_pDesktop->iconView()->setIconsLocked( lock ); } void KRootWm::slotRefreshDesktop() {