summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-18 14:36:02 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-18 14:36:02 -0600
commitcf9a9af6a8c3606e8d1e1372ea78332f4b69309e (patch)
tree2dc86582a9272a7db97b1d2978b31aef4b7d8c5e
parentf6095d86a621538298e764b710344c3e50ecc9e8 (diff)
downloadtdebase-cf9a9af6a8c3606e8d1e1372ea78332f4b69309e.tar.gz
tdebase-cf9a9af6a8c3606e8d1e1372ea78332f4b69309e.zip
Properly restore icon positions on login
-rw-r--r--kdesktop/kdiconview.cc85
-rw-r--r--ksmserver/shutdowndlg.cpp6
2 files changed, 80 insertions, 11 deletions
diff --git a/kdesktop/kdiconview.cc b/kdesktop/kdiconview.cc
index 8a9a896df..1590443d8 100644
--- a/kdesktop/kdiconview.cc
+++ b/kdesktop/kdiconview.cc
@@ -489,7 +489,17 @@ void KDIconView::setAutoAlign( bool b )
// Auto line-up icons
if ( b ) {
- if (!KRootWm::self()->startup) lineupIcons(); else KRootWm::self()->startup = false;
+ // set maxItemWidth to ensure sane initial icon layout before the auto align code is fully activated
+ int sz = iconSize() ? iconSize() : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
+ setMaxItemWidth( QMAX( QMAX( sz, previewIconSize( iconSize() ) ), KonqFMSettings::settings()->iconTextWidth() ) );
+ setFont( font() ); // Force calcRect()
+
+ if (!KRootWm::self()->startup) {
+ lineupIcons();
+ }
+ else {
+ KRootWm::self()->startup = false;
+ }
connect( this, TQT_SIGNAL( iconMoved() ),
this, TQT_SLOT( lineupIcons() ) );
}
@@ -1061,6 +1071,9 @@ void KDIconView::slotNewItems( const KFileItemList & entries )
KFileItemListIterator it(entries);
KFileIVI* fileIVI = 0L;
+ typedef TQValueList<KFileIVI*> KFileIVIList;
+ KFileIVIList newItemsList;
+
// Ensure that the saved positions had a chance to be loaded
if (!m_dotDirectory) {
initDotDirectories();
@@ -1131,14 +1144,56 @@ void KDIconView::slotNewItems( const KFileItemList & entries )
fileIVI->move( x, y );
if ( (!firstRun) && (!isFreePosition( fileIVI )) && (!m_needDesktopAlign) ) // if we can't put it there, then let TQIconView decide
{
- kdDebug(1214)<<"slotNewItems() pos was not free :-("<<endl;
- fileIVI->move( oldPos.x(), oldPos.y() );
- m_dotDirectory->deleteGroup( group );
- m_bNeedSave = true;
+ if (!isFreePosition( fileIVI ))
+ {
+ // Find the offending icon and move it out of the way; saved positions have precedence!
+ TQRect r = fileIVI->rect();
+ TQIconViewItem *it = firstItem();
+ for (; it; it = it->nextItem() )
+ {
+ if ( !it->rect().isValid() || it == fileIVI )
+ {
+ continue;
+ }
+
+ if ( it->intersects( r ) )
+ {
+ moveToFreePosition(it);
+ }
+ }
+ }
+ else {
+ kdDebug(1214)<<"slotNewItems() pos was not free :-("<<endl;
+ fileIVI->move( oldPos.x(), oldPos.y() );
+ m_dotDirectory->deleteGroup( group );
+ m_bNeedSave = true;
+ }
}
else
{
- kdDebug(1214)<<"Using saved position"<<endl;
+ if (!isFreePosition( fileIVI ))
+ {
+ kdDebug(1214)<<"slotNewItems() pos was not free :-("<<endl;
+ // Find the offending icon and move it out of the way; saved positions have precedence!
+ TQRect r = fileIVI->rect();
+ TQIconViewItem *it = firstItem();
+ for (; it; it = it->nextItem() )
+ {
+ if ( !it->rect().isValid() || it == fileIVI )
+ {
+ continue;
+ }
+
+ if ( it->intersects( r ) )
+ {
+ moveToFreePosition(it);
+ }
+ }
+ }
+ else
+ {
+ kdDebug(1214)<<"Using saved position"<<endl;
+ }
}
}
else
@@ -1146,18 +1201,26 @@ void KDIconView::slotNewItems( const KFileItemList & entries )
// Not found, we'll need to save the new pos
kdDebug(1214)<<"slotNewItems(): New item without position information, try to find a sane location"<<endl;
- moveToFreePosition(fileIVI);
-
- m_bNeedSave = true;
+ newItemsList.append(fileIVI);
}
}
}
+ KFileIVIList::iterator newitemit;
+ for ( newitemit = newItemsList.begin(); newitemit != newItemsList.end(); ++newitemit )
+ {
+ fileIVI = (*newitemit);
+ moveToFreePosition(fileIVI);
+ m_bNeedSave = true;
+ }
+
setIconArea( area );
// align on grid
if ( m_autoAlign )
+ {
lineupIcons();
+ }
setUpdatesEnabled( true );
}
@@ -1677,10 +1740,14 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item ) const
for (; it; it = it->nextItem() )
{
if ( !it->rect().isValid() || it == item )
+ {
continue;
+ }
if ( it->intersects( r ) )
+ {
return false;
+ }
}
return true;
diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp
index 3b1e27f68..5be3f70a2 100644
--- a/ksmserver/shutdowndlg.cpp
+++ b/ksmserver/shutdowndlg.cpp
@@ -792,15 +792,17 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
TQValueList<TQT_DBusData> params;
params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend");
TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
- if(reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1)
+ if(reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
canSuspend = reply[0].toVariant().value.toBool();
+ }
// can hibernate?
params.clear();
params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate");
reply = upowerProperties.sendWithReply("Get", params);
- if(reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1)
+ if(reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
canHibernate = reply[0].toVariant().value.toBool();
+ }
#else
#ifdef COMPILE_HALBACKEND
// Query HAL for suspend/resume support