summaryrefslogtreecommitdiffstats
path: root/kdesktop
diff options
context:
space:
mode:
Diffstat (limited to 'kdesktop')
-rw-r--r--kdesktop/kdesktop.kcfg10
-rw-r--r--kdesktop/kdiconview.cpp91
-rw-r--r--kdesktop/kdiconview.h5
-rw-r--r--kdesktop/krootwm.cpp28
4 files changed, 104 insertions, 30 deletions
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 @@
<label>Align direction</label>
<whatsthis>If this is enabled, icons are aligned vertically, otherwise horizontally.</whatsthis>
</entry>
+ <entry key="IconSpacing" type="Int">
+ <default>5</default>
+ <label>Icon spacing</label>
+ <whatsthis><p>This is the minimal distance (in pixels) between the icons on your desktop.</p></whatsthis>
+ </entry>
+ <entry key="SpacingCtrlScroll" type="Bool">
+ <default>false</default>
+ <label>Change spacing by Ctrl+Mouse Scroll</label>
+ <whatsthis><p>If this is enabled, you can change desktop icon spacing by pressing Ctrl and scrolling on the desktop background.</p></whatsthis>
+ </entry>
<entry key="Preview" type="StringList">
<default></default>
<label>Show Icon Previews For</label>
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 &currentI
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"<<endl;
-
+
rect.moveTopLeft(TQPoint(currentIconArea.x()+spacing(),currentIconArea.y()+spacing()));
do {
success=false;
@@ -1939,7 +1986,7 @@ void KDIconView::moveToFreePosition(TQIconViewItem *item, const TQRect &currentI
break;
}
}
-
+
if (!success) {
rect.moveTopLeft(TQPoint(rect.right()+spacing(),spacing()));
}
diff --git a/kdesktop/kdiconview.h b/kdesktop/kdiconview.h
index 7b20e1817..f3ebe6718 100644
--- a/kdesktop/kdiconview.h
+++ b/kdesktop/kdiconview.h
@@ -75,6 +75,7 @@ public:
void lineupIcons(TQIconView::Arrangement);
+ void setIconsLocked( bool b );
void setAutoAlign( bool b );
TQStringList selectedURLs();
@@ -165,6 +166,9 @@ public slots:
void slotClear();
void refreshIcons();
+ void incIconSpacing();
+ void decIconSpacing();
+
protected slots:
void slotFreeSpaceOverlayStart();
void slotFreeSpaceOverlayFinished();
@@ -214,6 +218,7 @@ private:
bool m_bNeedRepaint;
bool m_bNeedSave;
+ bool m_iconsLocked;
bool m_autoAlign;
/** true if even one icon has an icon-position entry in the .directory */
diff --git a/kdesktop/krootwm.cpp b/kdesktop/krootwm.cpp
index e5b4b76e0..4010c1f22 100644
--- a/kdesktop/krootwm.cpp
+++ b/kdesktop/krootwm.cpp
@@ -109,7 +109,7 @@ KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop),
bookmarks = 0;
bookmarkMenu = 0;
}
-
+
// The windowList and desktop menus can be part of a menubar (Mac style)
// so we create them here
desktopMenu = new TQPopupMenu;
@@ -250,7 +250,7 @@ void KRootWm::initConfig()
if ( m_bDesktopEnabled ) {
m_pDesktop->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<TDEToggleAction*>(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() {