KDesktop: customizable icon spacing.

This commit introduces changes to KDesktop which allow for a custom
icon spacing option, some new controls into the Desktop Behaviour
module of KControl, as well as the KDesktop Ctrl+Mouse Scroll binding
to manipulate the icon spacing.

This commit depends on a previous (minor) change in LibKonq.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/185/head
Mavridis Philippe 3 years ago
parent f06c728734
commit 94b9872913
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -33,79 +33,243 @@
<attribute name="title"> <attribute name="title">
<string>General</string> <string>General</string>
</attribute> </attribute>
<grid> <vbox>
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="TQCheckBox" row="0" column="0"> <widget class="TQGroupBox">
<property name="name"> <property name="name">
<cstring>iconsEnabledBox</cstring> <cstring>iconsGroupBox</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Show icons on desktop</string>
</property>
<property name="whatsThis" stdset="0">
<string>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.</string>
</property> </property>
</widget> <property name="title">
<widget class="TQLayoutWidget" row="1" column="0"> <string>Desktop Icons</string>
<property name="name">
<cstring>layout1</cstring>
</property> </property>
<hbox> <vbox>
<property name="name"> <widget class="TQCheckBox">
<cstring>unnamed</cstring>
</property>
<spacer>
<property name="name"> <property name="name">
<cstring>spacer3</cstring> <cstring>iconsEnabledBox</cstring>
</property> </property>
<property name="orientation"> <property name="sizePolicy">
<enum>Horizontal</enum> <sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="sizeType"> <property name="text">
<enum>Fixed</enum> <string>&amp;Show icons on desktop</string>
</property> </property>
<property name="sizeHint"> <property name="whatsThis" stdset="0">
<size> <string>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.</string>
<width>20</width>
<height>0</height>
</size>
</property> </property>
</spacer> </widget>
<widget class="TQLayoutWidget">
<property name="name">
<cstring>layout1</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer>
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
<widget class="TQCheckBox">
<property name="name">
<cstring>vrootBox</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Allow pro&amp;grams in desktop window</string>
</property>
<property name="whatsThis" stdset="0">
<string>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.</string>
</property>
</widget>
</hbox>
</widget>
<widget class="TQCheckBox"> <widget class="TQCheckBox">
<property name="name"> <property name="name">
<cstring>vrootBox</cstring> <cstring>toolTipBox</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Allow pro&amp;grams in desktop window</string> <string>Show &amp;tooltips</string>
</property> </property>
<property name="whatsThis" stdset="0"> </widget>
<string>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.</string> <widget class="KSeparator">
<property name="name">
<cstring>iconOptsSeparator</cstring>
</property> </property>
</widget> </widget>
</hbox> <widget class="TQLayoutWidget">
</widget> <property name="name">
<widget class="TQCheckBox" row="2" column="0"> <cstring>iconOptsOuterLayout</cstring>
<property name="name"> </property>
<cstring>toolTipBox</cstring> <hbox>
</property> <widget class="TQLayoutWidget">
<property name="text"> <property name="name">
<string>Show &amp;tooltips</string> <cstring>iconOptsVLayout</cstring>
</property> </property>
<vbox>
<widget class="TQCheckBox">
<property name="name">
<cstring>lockInPlaceBox</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Lock in Place</string>
</property>
<property name="whatsThis" stdset="0">
<string>Check this option if you want to prevent your icons from being dragged around.</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
<cstring>autoLineupIconsBox</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Align to grid</string>
</property>
<property name="whatsThis" stdset="0">
<string>Check this option if you want to see your icons automatically aligned to the grid when you move them.</string>
</property>
</widget>
</vbox>
</widget>
<spacer>
<property name="name">
<cstring>spacer2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="TQLayoutWidget">
<property name="name">
<cstring>spacingVLayout</cstring>
</property>
<vbox>
<widget class="TQLayoutWidget">
<property name="name">
<cstring>spacingValueLayout</cstring>
</property>
<hbox>
<property name="name">
<cstring>spacingLayout</cstring>
</property>
<widget class="TQLabel">
<property name="name">
<cstring>spacingLabel</cstring>
</property>
<property name="text">
<string>Icon Spacing:</string>
</property>
<property name="whatsThis" stdset="0">
<string>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.</string>
</property>
</widget>
<widget class="TQSpinBox">
<property name="name">
<cstring>spacingValue</cstring>
</property>
<property name="specialValueText">
<string>Default</string>
</property>
<property name="suffix">
<string> px</string>
</property>
<property name="minValue">
<number>5</number>
</property>
<property name="whatsThis" stdset="0">
<string>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.</string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget class="TQCheckBox">
<property name="name">
<cstring>spacingCtrlScroll</cstring>
</property>
<property name="text">
<string>Ctrl+Mouse Scroll changes spacing</string>
</property>
<property name="whatsThis" stdset="0">
<string>Check this if you want to change desktop icon spacing by pressing Ctrl and scrolling on the desktop background.</string>
</property>
</widget>
</vbox>
</widget>
<spacer>
<property name="name">
<cstring>spacer2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
</vbox>
</widget> </widget>
<widget class="TQButtonGroup" row="3" column="0"> <widget class="TQButtonGroup">
<property name="name"> <property name="name">
<cstring>desktopMenuGroup</cstring> <cstring>desktopMenuGroup</cstring>
</property> </property>
@ -151,7 +315,7 @@
</widget> </widget>
</vbox> </vbox>
</widget> </widget>
<widget class="TQGroupBox" row="4" column="0"> <widget class="TQGroupBox">
<property name="name"> <property name="name">
<cstring>groupBox3</cstring> <cstring>groupBox3</cstring>
</property> </property>
@ -260,7 +424,7 @@
</widget> </widget>
<spacer row="0" column="3" rowspan="3" colspan="1"> <spacer row="0" column="3" rowspan="3" colspan="1">
<property name="name"> <property name="name">
<cstring>spacer5</cstring> <cstring>spacer4</cstring>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Horizontal</enum> <enum>Horizontal</enum>
@ -277,9 +441,9 @@
</spacer> </spacer>
</grid> </grid>
</widget> </widget>
<spacer row="5" column="0"> <spacer>
<property name="name"> <property name="name">
<cstring>spacer8</cstring> <cstring>spacer5</cstring>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Vertical</enum> <enum>Vertical</enum>
@ -294,7 +458,7 @@
</size> </size>
</property> </property>
</spacer> </spacer>
</grid> </vbox>
</widget> </widget>
<widget class="TQWidget"> <widget class="TQWidget">
<property name="name"> <property name="name">
@ -307,17 +471,6 @@
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="TQCheckBox" row="0" column="0">
<property name="name">
<cstring>autoLineupIconsBox</cstring>
</property>
<property name="text">
<string>Automatically &amp;line up icons</string>
</property>
<property name="whatsThis" stdset="0">
<string>Check this option if you want to see your icons automatically aligned to the grid when you move them.</string>
</property>
</widget>
<widget class="TQCheckBox" row="1" column="0"> <widget class="TQCheckBox" row="1" column="0">
<property name="name"> <property name="name">
<cstring>showHiddenBox</cstring> <cstring>showHiddenBox</cstring>

@ -28,6 +28,7 @@
#include <tqcombobox.h> #include <tqcombobox.h>
#include <tqpushbutton.h> #include <tqpushbutton.h>
#include <tqbuttongroup.h> #include <tqbuttongroup.h>
#include <tqspinbox.h>
#include <tqtabwidget.h> #include <tqtabwidget.h>
#include <tqwhatsthis.h> #include <tqwhatsthis.h>
#include <tdelistview.h> #include <tdelistview.h>
@ -130,9 +131,12 @@ DesktopBehavior::DesktopBehavior(TDEConfig *config, TQWidget *parent, const char
connect(iconsEnabledBox, TQT_SIGNAL(clicked()), this, TQT_SLOT(enableChanged())); connect(iconsEnabledBox, TQT_SIGNAL(clicked()), this, TQT_SLOT(enableChanged()));
connect(showHiddenBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed())); connect(showHiddenBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed()));
connect(vrootBox, 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(toolTipBox, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(changed()));
connect(mediaListView, TQT_SIGNAL(clicked(TQListViewItem *)), this, TQT_SLOT(mediaListViewChanged(TQListViewItem *))); 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:"); strMouseButton1 = i18n("&Left button:");
strButtonTxt1 = i18n( "You can choose what happens when" strButtonTxt1 = i18n( "You can choose what happens when"
@ -236,6 +240,11 @@ void DesktopBehavior::mediaListViewChanged(TQListViewItem * item)
emit changed(); emit changed();
} }
void DesktopBehavior::spacingChanged(int value)
{
emit changed();
}
void DesktopBehavior::setMediaListViewEnabled(bool enabled) void DesktopBehavior::setMediaListViewEnabled(bool enabled)
{ {
for (DesktopBehaviorMediaItem *it=static_cast<DesktopBehaviorMediaItem *>(mediaListView->firstChild()); for (DesktopBehaviorMediaItem *it=static_cast<DesktopBehaviorMediaItem *>(mediaListView->firstChild());
@ -307,6 +316,9 @@ void DesktopBehavior::load( bool useDefaults )
g_pConfig->setGroup( "Desktop Icons" ); g_pConfig->setGroup( "Desktop Icons" );
bool bShowHidden = g_pConfig->readBoolEntry("ShowHidden", DEFAULT_SHOW_HIDDEN_ROOT_ICONS); bool bShowHidden = g_pConfig->readBoolEntry("ShowHidden", DEFAULT_SHOW_HIDDEN_ROOT_ICONS);
showHiddenBox->setChecked(bShowHidden); 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); //bool bVertAlign = g_pConfig->readBoolEntry("VertAlign", DEFAULT_VERT_ALIGN);
TDETrader::OfferList plugins = TDETrader::self()->query("ThumbCreator"); TDETrader::OfferList plugins = TDETrader::self()->query("ThumbCreator");
previewListView->clear(); previewListView->clear();
@ -333,6 +345,8 @@ void DesktopBehavior::load( bool useDefaults )
iconsEnabledBox->setChecked( g_pConfig->readBoolEntry( "Enabled", true ) ); iconsEnabledBox->setChecked( g_pConfig->readBoolEntry( "Enabled", true ) );
autoLineupIconsBox->setChecked( g_pConfig->readBoolEntry( "AutoLineUpIcons", false ) ); autoLineupIconsBox->setChecked( g_pConfig->readBoolEntry( "AutoLineUpIcons", false ) );
toggleSpacingOpts();
// //
g_pConfig->setGroup( "Mouse Buttons" ); g_pConfig->setGroup( "Mouse Buttons" );
TQString s; TQString s;
@ -365,6 +379,9 @@ void DesktopBehavior::save()
{ {
g_pConfig->setGroup( "Desktop Icons" ); g_pConfig->setGroup( "Desktop Icons" );
g_pConfig->writeEntry("ShowHidden", showHiddenBox->isChecked()); 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; TQStringList previews;
for ( DesktopBehaviorPreviewItem *item = static_cast<DesktopBehaviorPreviewItem *>( previewListView->firstChild() ); for ( DesktopBehaviorPreviewItem *item = static_cast<DesktopBehaviorPreviewItem *>( previewListView->firstChild() );
item; item;
@ -395,6 +412,8 @@ void DesktopBehavior::save()
g_pConfig->writeEntry( "Enabled", iconsEnabledBox->isChecked() ); g_pConfig->writeEntry( "Enabled", iconsEnabledBox->isChecked() );
g_pConfig->writeEntry( "AutoLineUpIcons", autoLineupIconsBox->isChecked() ); g_pConfig->writeEntry( "AutoLineUpIcons", autoLineupIconsBox->isChecked() );
toggleSpacingOpts();
saveMediaListView(); saveMediaListView();
g_pConfig->sync(); g_pConfig->sync();
@ -421,6 +440,9 @@ void DesktopBehavior::enableChanged()
bool enabled = iconsEnabledBox->isChecked(); bool enabled = iconsEnabledBox->isChecked();
behaviorTab->setTabEnabled(behaviorTab->page(1), enabled); behaviorTab->setTabEnabled(behaviorTab->page(1), enabled);
vrootBox->setEnabled(enabled); vrootBox->setEnabled(enabled);
lockInPlaceBox->setEnabled(enabled);
autoLineupIconsBox->setEnabled(enabled);
enableGridChanged();
if (m_bHasMedia) if (m_bHasMedia)
{ {
@ -433,6 +455,24 @@ void DesktopBehavior::enableChanged()
changed(); 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() void DesktopBehavior::comboBoxChanged()
{ {
int i; int i;

@ -44,10 +44,12 @@ signals:
void changed(); void changed();
private slots: private slots:
void enableChanged(); void enableChanged();
void enableGridChanged();
void comboBoxChanged(); void comboBoxChanged();
void editButtonPressed(); void editButtonPressed();
void mediaListViewChanged(TQListViewItem * item); void mediaListViewChanged(TQListViewItem * item);
void spacingChanged(int value);
private: private:
TDEConfig *g_pConfig; TDEConfig *g_pConfig;
@ -56,6 +58,8 @@ private:
void saveMediaListView(); void saveMediaListView();
void setMediaListViewEnabled(bool enabled); void setMediaListViewEnabled(bool enabled);
void toggleSpacingOpts();
// Combo for the menus // Combo for the menus
void fillMenuCombo( TQComboBox * combo ); void fillMenuCombo( TQComboBox * combo );

@ -155,6 +155,16 @@
<label>Align direction</label> <label>Align direction</label>
<whatsthis>If this is enabled, icons are aligned vertically, otherwise horizontally.</whatsthis> <whatsthis>If this is enabled, icons are aligned vertically, otherwise horizontally.</whatsthis>
</entry> </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"> <entry key="Preview" type="StringList">
<default></default> <default></default>
<label>Show Icon Previews For</label> <label>Show Icon Previews For</label>

@ -191,15 +191,13 @@ KDIconView::KDIconView( TQWidget *parent, const char* name )
if (!m_bEditableDesktopIcons) if (!m_bEditableDesktopIcons)
{ {
setItemsMovable(false); setIconsLocked(true);
setAcceptDrops(false);
viewport()->setAcceptDrops(false);
} }
} }
KDIconView::~KDIconView() KDIconView::~KDIconView()
{ {
if (m_dotDirectory && !m_bEditableDesktopIcons) { if (m_dotDirectory && !m_bEditableDesktopIcons || m_iconsLocked) {
m_dotDirectory->rollback(false); // Don't save positions m_dotDirectory->rollback(false); // Don't save positions
} }
@ -296,6 +294,7 @@ void KDIconView::initConfig( bool init )
m_bVertAlign = KDesktopSettings::vertAlign(); m_bVertAlign = KDesktopSettings::vertAlign();
TQStringList oldPreview = previewSettings(); TQStringList oldPreview = previewSettings();
setPreviewSettings( KDesktopSettings::preview() ); setPreviewSettings( KDesktopSettings::preview() );
setSpacing( KDesktopSettings::iconSpacing() );
// read arrange configuration // read arrange configuration
m_eSortCriterion = (SortCriterion)KDesktopSettings::sortCriterion(); m_eSortCriterion = (SortCriterion)KDesktopSettings::sortCriterion();
@ -486,6 +485,30 @@ void KDIconView::lineupIcons()
saveIconPositions(); 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 ) void KDIconView::setAutoAlign( bool b )
{ {
m_autoAlign = 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() void KDIconView::startDirLister()
{ {
// if desktop is resized before start() is called (XRandr) // if desktop is resized before start() is called (XRandr)
@ -644,7 +676,22 @@ void KDIconView::wheelEvent( TQWheelEvent* e )
TQIconViewItem *item = findItem( e->pos() ); TQIconViewItem *item = findItem( e->pos() );
if ( !item ) 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; return;
} }
@ -1726,25 +1773,25 @@ void KDIconView::viewportWheelEvent( TQWheelEvent * e )
void KDIconView::updateWorkArea( const TQRect &wr ) void KDIconView::updateWorkArea( const TQRect &wr )
{ {
m_gotIconsArea = true; // now we have it! m_gotIconsArea = true; // now we have it!
if (( iconArea() == wr ) && (m_needDesktopAlign == false)) { if (( iconArea() == wr ) && (m_needDesktopAlign == false)) {
// nothing changed; avoid repaint/saveIconPosition ... // nothing changed; avoid repaint/saveIconPosition ...
return; return;
} }
TQRect oldArea = iconArea(); TQRect oldArea = iconArea();
setIconArea( wr ); setIconArea( wr );
kdDebug(1204) << "KDIconView::updateWorkArea wr: " << wr.x() << "," << wr.y() << " " << wr.width() << "x" << wr.height() << endl; 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; kdDebug(1204) << " oldArea: " << oldArea.x() << "," << oldArea.y() << " " << oldArea.width() << "x" << oldArea.height() << endl;
bool needRepaint = false; bool needRepaint = false;
TQIconViewItem* item; TQIconViewItem* item;
int dx, dy; int dx, dy;
dx = wr.left() - oldArea.left(); dx = wr.left() - oldArea.left();
dy = wr.top() - oldArea.top(); dy = wr.top() - oldArea.top();
if ( dx != 0 || dy != 0 ) { if ( dx != 0 || dy != 0 ) {
if ( (dx > 0) || (dy > 0) ) { if ( (dx > 0) || (dy > 0) ) {
// the iconArea was shifted right/down; less space now // 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 // the iconArea was shifted left/up; more space now - use it
needRepaint = true; needRepaint = true;
} }
if ( needRepaint ) { if ( needRepaint ) {
for ( item = firstItem(); item; item = item->nextItem() ) { for ( item = firstItem(); item; item = item->nextItem() ) {
item->moveBy( dx, dy ); item->moveBy( dx, dy );
} }
} }
} }
for ( item = firstItem(); item; item = item->nextItem() ) { for ( item = firstItem(); item; item = item->nextItem() ) {
TQRect r( item->rect() ); TQRect r( item->rect() );
int dx = 0, dy = 0; int dx = 0, dy = 0;
@ -1789,7 +1836,7 @@ void KDIconView::updateWorkArea( const TQRect &wr )
repaint( FALSE ); repaint( FALSE );
saveIconPositions(); saveIconPositions();
} }
m_needDesktopAlign = false; m_needDesktopAlign = false;
lineupIcons(); lineupIcons();
} }
@ -1861,18 +1908,18 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item, const TQRect &curre
if (!area.contains(r, FALSE)) { if (!area.contains(r, FALSE)) {
return false; return false;
} }
TQIconViewItem *it = firstItem(); TQIconViewItem *it = firstItem();
for (; it; it = it->nextItem() ) { for (; it; it = it->nextItem() ) {
if ( !it->rect().isValid() || it == item ) { if ( !it->rect().isValid() || it == item ) {
continue; continue;
} }
if ( it->intersects( r ) ) { if ( it->intersects( r ) ) {
return false; return false;
} }
} }
return true; return true;
} }
@ -1891,12 +1938,12 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item, const TQRect& rect,
if ( !rect.isValid() || it == item ) { if ( !rect.isValid() || it == item ) {
continue; continue;
} }
if ( it->intersects( rect ) ) { if ( it->intersects( rect ) ) {
return false; return false;
} }
} }
return true; return true;
} }
@ -1921,12 +1968,12 @@ void KDIconView::moveToFreePosition(TQIconViewItem *item, const TQRect &currentI
m_lastDeletedIconPos = TQPoint(); m_lastDeletedIconPos = TQPoint();
return; return;
} }
//try to find a free place to put the item, honouring the m_bVertAlign property //try to find a free place to put the item, honouring the m_bVertAlign property
TQRect rect=item->rect(); TQRect rect=item->rect();
if (m_bVertAlign) { if (m_bVertAlign) {
kdDebug(1214)<<"moveToFreePosition for vertical alignment"<<endl; kdDebug(1214)<<"moveToFreePosition for vertical alignment"<<endl;
rect.moveTopLeft(TQPoint(currentIconArea.x()+spacing(),currentIconArea.y()+spacing())); rect.moveTopLeft(TQPoint(currentIconArea.x()+spacing(),currentIconArea.y()+spacing()));
do { do {
success=false; success=false;
@ -1939,7 +1986,7 @@ void KDIconView::moveToFreePosition(TQIconViewItem *item, const TQRect &currentI
break; break;
} }
} }
if (!success) { if (!success) {
rect.moveTopLeft(TQPoint(rect.right()+spacing(),spacing())); rect.moveTopLeft(TQPoint(rect.right()+spacing(),spacing()));
} }

@ -75,6 +75,7 @@ public:
void lineupIcons(TQIconView::Arrangement); void lineupIcons(TQIconView::Arrangement);
void setIconsLocked( bool b );
void setAutoAlign( bool b ); void setAutoAlign( bool b );
TQStringList selectedURLs(); TQStringList selectedURLs();
@ -165,6 +166,9 @@ public slots:
void slotClear(); void slotClear();
void refreshIcons(); void refreshIcons();
void incIconSpacing();
void decIconSpacing();
protected slots: protected slots:
void slotFreeSpaceOverlayStart(); void slotFreeSpaceOverlayStart();
void slotFreeSpaceOverlayFinished(); void slotFreeSpaceOverlayFinished();
@ -214,6 +218,7 @@ private:
bool m_bNeedRepaint; bool m_bNeedRepaint;
bool m_bNeedSave; bool m_bNeedSave;
bool m_iconsLocked;
bool m_autoAlign; bool m_autoAlign;
/** true if even one icon has an icon-position entry in the .directory */ /** true if even one icon has an icon-position entry in the .directory */

@ -109,7 +109,7 @@ KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop),
bookmarks = 0; bookmarks = 0;
bookmarkMenu = 0; bookmarkMenu = 0;
} }
// The windowList and desktop menus can be part of a menubar (Mac style) // The windowList and desktop menus can be part of a menubar (Mac style)
// so we create them here // so we create them here
desktopMenu = new TQPopupMenu; desktopMenu = new TQPopupMenu;
@ -250,7 +250,7 @@ void KRootWm::initConfig()
if ( m_bDesktopEnabled ) { if ( m_bDesktopEnabled ) {
m_pDesktop->iconView()->setAutoAlign( KDesktopSettings::autoLineUpIcons() ); m_pDesktop->iconView()->setAutoAlign( KDesktopSettings::autoLineUpIcons() );
if ( kapp->authorize( "editable_desktop_icons" ) ) { 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")); TDEToggleAction *aLockIcons = static_cast<TDEToggleAction*>(m_actionCollection->action("lock_icons"));
if (aLockIcons) if (aLockIcons)
aLockIcons->setChecked( KDesktopSettings::lockIcons() ); aLockIcons->setChecked( KDesktopSettings::lockIcons() );
@ -732,12 +732,24 @@ void KRootWm::slotLineupIcons() {
void KRootWm::slotToggleLockIcons( bool lock ) void KRootWm::slotToggleLockIcons( bool lock )
{ {
if (m_bDesktopEnabled) KDesktopSettings::setLockIcons( lock );
{ KDesktopSettings::writeConfig();
m_pDesktop->iconView()->setItemsMovable( !lock );
KDesktopSettings::setLockIcons( lock ); // Also save it globally...
KDesktopSettings::writeConfig(); 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() { void KRootWm::slotRefreshDesktop() {

Loading…
Cancel
Save