Bug 121176

Summary: "Resize Columns Automatically" won't enable after resizing a column
Product: [Applications] juk Reporter: Luke McCarthy <luke>
Component: generalAssignee: Michael Pyne <mpyne>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 2.3   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Luke McCarthy 2006-02-01 20:19:21 UTC
Version:           2.3 (using KDE KDE 3.5.0)
Installed from:    Unlisted Binary Package
Compiler:          gcc 4.03 
OS:                Linux

In automatic column resizing mode, resize one of the columns. A message box pops up:

"Manual column widths have been have been enabled..."

Click "View" > "Resize Column Headers Automatically"

The same message box appears.

It seems that the column is still "selected". If you mouse over the column it will move as if you are still holding the left button down. You need to click on the column to allow the automatic resizing to be enabled!
Comment 1 Michael Pyne 2006-02-02 00:59:25 UTC
Confirmed.  I'll try to fix it tonight.
Comment 2 Michael Pyne 2006-02-02 02:24:37 UTC
SVN commit 504741 by mpyne:

Fix bug 121176 (Manual Column widths notice interferes with dragging columns) in JuK.

Basically, when you drag a column to resize it, when JuK is busy setting the widths
automatically, JuK will automatically switch to manual resize.  But, it also notifies you of
the switch.

This has the effect of Qt missing the mouse release event, so the header still thinks it is
being dragged and just causes all around weirdness.

I've fixed this by delaying the notification dialog until after the resize is done, which
makes more sense anyways I think.

cc'ing Carsten for changelog update please. :)

BUG:121176
CCMAIL:cniehaus@kde.org


 M  +33 -27    playlist.cpp  
 M  +7 -1      playlist.h  


--- branches/KDE/3.5/kdemultimedia/juk/playlist.cpp #504740:504741
@@ -316,7 +316,7 @@
     m_allowDuplicates(false),
     m_polished(false),
     m_applySharedSettings(true),
-    m_mousePressed(false),
+    m_columnWidthModeChanged(false),
     m_disableColumnWidthUpdates(true),
     m_time(0),
     m_widthsDirty(true),
@@ -339,7 +339,7 @@
     m_allowDuplicates(false),
     m_polished(false),
     m_applySharedSettings(true),
-    m_mousePressed(false),
+    m_columnWidthModeChanged(false),
     m_disableColumnWidthUpdates(true),
     m_time(0),
     m_widthsDirty(true),
@@ -363,7 +363,7 @@
     m_allowDuplicates(false),
     m_polished(false),
     m_applySharedSettings(true),
-    m_mousePressed(false),
+    m_columnWidthModeChanged(false),
     m_disableColumnWidthUpdates(true),
     m_time(0),
     m_widthsDirty(true),
@@ -386,7 +386,7 @@
     m_allowDuplicates(false),
     m_polished(false),
     m_applySharedSettings(true),
-    m_mousePressed(false),
+    m_columnWidthModeChanged(false),
     m_disableColumnWidthUpdates(true),
     m_time(0),
     m_widthsDirty(true),
@@ -1099,24 +1099,32 @@
 {
     if(watched == header()) {
 	switch(e->type()) {
+	case QEvent::MouseMove:
+	{
+	    if((static_cast<QMouseEvent *>(e)->state() & LeftButton) == LeftButton &&
+		!action<KToggleAction>("resizeColumnsManually")->isChecked())
+	    {
+		m_columnWidthModeChanged = true;
+
+		action<KToggleAction>("resizeColumnsManually")->setChecked(true);
+		slotColumnResizeModeChanged();
+	    }
+
+	    break;
+	}
 	case QEvent::MouseButtonPress:
 	{
-	    switch(static_cast<QMouseEvent *>(e)->button()) {
-	    case RightButton:
+	    if(static_cast<QMouseEvent *>(e)->button() == RightButton)
 		m_headerMenu->popup(QCursor::pos());
-		break;
-	    case LeftButton:
-		m_mousePressed = true;
-		break;
-	    default:
-		break;
-	    }
+
 	    break;
 	}
 	case QEvent::MouseButtonRelease:
 	{
-	    if(static_cast<QMouseEvent *>(e)->button() == LeftButton)
-		m_mousePressed = false;
+	    if(m_columnWidthModeChanged) {
+		m_columnWidthModeChanged = false;
+		notifyUserColumnWidthModeChanged();
+	    }
 
 	    if(!manualResize() && m_widthsDirty)
 		QTimer::singleShot(0, this, SLOT(slotUpdateColumnWidths()));
@@ -2270,22 +2278,20 @@
 	new Playlist(m_collection, selectedItems(), name);
 }
 
+void Playlist::notifyUserColumnWidthModeChanged()
+{
+    KMessageBox::information(this,
+			     i18n("Manual column widths have been enabled.  You can "
+				  "switch back to automatic column sizes in the view "
+				  "menu."),
+			     i18n("Manual Column Widths Enabled"),
+			     "ShowManualColumnWidthInformation");
+}
+
 void Playlist::slotColumnSizeChanged(int column, int, int newSize)
 {
     m_widthsDirty = true;
     m_columnFixedWidths[column] = newSize;
-
-    if(m_mousePressed && !action<KToggleAction>("resizeColumnsManually")->isChecked()) {
-	KMessageBox::information(this,
-				 i18n("Manual column widths have been enabled.  You can "
-				      "switch back to automatic column sizes in the view "
-				      "menu."),
-				 i18n("Manual Column Widths Enabled"),
-				 "ShowManualColumnWidthInformation");
-	
-	action<KToggleAction>("resizeColumnsManually")->setChecked(true);
-	slotColumnResizeModeChanged();
-    }
 }
 
 void Playlist::slotInlineCompletionModeChanged(KGlobalSettings::Completion mode)
--- branches/KDE/3.5/kdemultimedia/juk/playlist.h #504740:504741
@@ -502,6 +502,12 @@
     void setup();
 
     /**
+     * This function is called to let the user know that JuK has automatically enabled
+     * manual column width adjust mode.
+     */
+    void notifyUserColumnWidthModeChanged();
+
+    /**
      * Load the playlist from a file.  \a fileName should be the absolute path.
      * \a fileInfo should point to the same file as \a fileName.  This is a
      * little awkward API-wise, but keeps us from throwing away useful
@@ -641,7 +647,7 @@
     bool m_allowDuplicates;
     bool m_polished;
     bool m_applySharedSettings;
-    bool m_mousePressed;
+    bool m_columnWidthModeChanged;
 
     QValueList<int> m_weightDirty;
     bool m_disableColumnWidthUpdates;