Version: 3.0 (using KDE 3.1.9) Compiler: gcc version 2.95.4 20011002 (Debian prerelease) OS: Linux (i686) release 2.4.20 If I go to the title of the note, press the right mouse button and choose "To Desktop" and then choose a number, e.g. "desktop 2" then the note does not appear on "desktop 2", but on "desktop 3". It is always wrong by one, that means n -> n+1.
Subject: kdepim/knotes CVS commit by lunakl: Fix #56625 - compensate for the menu separator when using the index. CCMAIL: 56625-done@bugs.kde.org M +15 -7 knote.cpp 1.80 M +2 -1 knote.h 1.24 M +1 -1 knotesapp.cpp 1.51 --- kdepim/knotes/knote.cpp #1.79:1.80 @@ -92,5 +92,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q m_alwaysOnTop = new KToggleAction( i18n("Always on Top"), "attach", 0, this, SLOT(slotToggleAlwaysOnTop()), actionCollection(), "always_on_top" ); connect( m_alwaysOnTop, SIGNAL(toggled(bool)), m_alwaysOnTop, SLOT(setChecked(bool)) ); - m_toDesktop = new KListAction( i18n("To Desktop"), 0, this, SLOT(slotToDesktop(int)), actionCollection(), "to_desktop" ); + m_toDesktop = new KListAction( i18n("To Desktop"), 0, this, SLOT(slotPopupActionToDesktop(int)), actionCollection(), "to_desktop" ); connect( m_toDesktop->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(slotUpdateDesktopActions()) ); @@ -181,5 +181,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q { // to avoid flicker, call this before show() - slotToDesktop( note_desktop ); + toDesktop( note_desktop ); show(); } else { @@ -187,5 +187,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q // if this is called before show(), // it won't work for sticky notes!!! - slotToDesktop( note_desktop ); + toDesktop( note_desktop ); } } @@ -367,10 +367,17 @@ void KNote::slotToggleAlwaysOnTop() } -void KNote::slotToDesktop( int id ) +void KNote::slotPopupActionToDesktop( int id ) { - if ( id == 0 || id == NETWinInfo::OnAllDesktops ) + if( id > 1 ) + --id; // compensate for the menu separator + toDesktop( id ); +} + +void KNote::toDesktop( int desktop ) +{ + if ( desktop == 0 || desktop == NETWinInfo::OnAllDesktops ) KWin::setOnAllDesktops( winId(), true ); else - KWin::setOnDesktop( winId(), id ); + KWin::setOnDesktop( winId(), desktop ); } @@ -390,8 +397,9 @@ void KNote::slotUpdateDesktopActions() m_toDesktop->setItems( desktops ); + kdDebug() << "updateDesktopActions:" << wm_client.desktop() << endl; if ( wm_client.desktop() == NETWinInfo::OnAllDesktops ) m_toDesktop->setCurrentItem( 0 ); else - m_toDesktop->setCurrentItem( wm_client.desktop() ); + m_toDesktop->setCurrentItem( wm_client.desktop() + 1 ); // compensate for separator (+1) } --- kdepim/knotes/knote.h #1.23:1.24 @@ -66,4 +66,5 @@ public: bool isNew( const QString& app ) const; bool isModified( const QString& app ) const; + void toDesktop( int desktop ); public slots: @@ -78,5 +79,5 @@ public slots: void slotToggleAlwaysOnTop(); - void slotToDesktop( int id ); + void slotPopupActionToDesktop( int id ); void slotUpdateDesktopActions(); --- kdepim/knotes/knotesapp.cpp #1.50:1.51 @@ -447,5 +447,5 @@ void KNotesApp::showNote( KNote* note ) // if not, show note on the current desktop note->show(); - note->slotToDesktop( KWin::currentDesktop() ); + note->toDesktop( KWin::currentDesktop() ); KWin::setActiveWindow( note->winId() ); note->setFocus();