Don't show desktop menu when there is only one desktop configured. Thanks

to aseigo for the original patch.

svn path=/trunk/kdebase/kwin/; revision=160391
icc-effect-5.14.5
Nadeem Hasan 2002-06-11 19:49:38 +00:00
parent 8fc62651e4
commit b36c644b72
2 changed files with 29 additions and 9 deletions

View File

@ -1614,14 +1614,6 @@ QPopupMenu* Workspace::clientPopup( Client* c )
// PluginMenu *deco = new PluginMenu(mgr, popup);
// deco->setFont(KGlobalSettings::menuFont());
desk_popup = new QPopupMenu( popup );
desk_popup->setCheckable( TRUE );
desk_popup->setFont(KGlobalSettings::menuFont());
connect( desk_popup, SIGNAL( activated(int) ),
this, SLOT( sendToDesktop(int) ) );
connect( desk_popup, SIGNAL( aboutToShow() ),
this, SLOT( desktopPopupAboutToShow() ) );
popup->insertItem( SmallIconSet( "move" ), i18n("&Move")+'\t'+keys->shortcut("Window Move").toString(), Options::MoveOp );
popup->insertItem( i18n("&Size")+'\t'+keys->shortcut("Window Resize").toString(), Options::ResizeOp );
popup->insertItem( i18n("Mi&nimize")+'\t'+keys->shortcut("Window Minimize").toString(), Options::IconifyOp );
@ -1633,7 +1625,6 @@ QPopupMenu* Workspace::clientPopup( Client* c )
popup->insertSeparator();
popup->insertItem(SmallIconSet( "configure" ), i18n("Configur&e..."), this, SLOT( configureWM() ));
popup->insertItem(i18n("&To Desktop"), desk_popup );
popup->insertSeparator();
@ -1642,6 +1633,22 @@ QPopupMenu* Workspace::clientPopup( Client* c )
return popup;
}
void Workspace::initDesktopPopup()
{
if (desk_popup)
return;
desk_popup = new QPopupMenu( popup );
desk_popup->setCheckable( TRUE );
desk_popup->setFont(KGlobalSettings::menuFont());
connect( desk_popup, SIGNAL( activated(int) ),
this, SLOT( sendToDesktop(int) ) );
connect( desk_popup, SIGNAL( aboutToShow() ),
this, SLOT( desktopPopupAboutToShow() ) );
popup->insertItem(i18n("To &Desktop"), desk_popup, -1, 8 );
}
void Workspace::showWindowMenuAt( unsigned long id, int x, int y )
{
Client *target = findClient( id );
@ -3121,6 +3128,7 @@ void Workspace::desktopPopupAboutToShow()
{
if ( !desk_popup )
return;
desk_popup->clear();
desk_popup->insertItem( i18n("&All Desktops"), 0 );
if ( popup_client && popup_client->isSticky() )
@ -3155,6 +3163,17 @@ void Workspace::clientPopupAboutToShow()
{
if ( !popup_client || !popup )
return;
if ( numberOfDesktops() == 1 )
{
delete desk_popup;
desk_popup = 0;
}
else
{
initDesktopPopup();
}
popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() );
popup->setItemEnabled( Options::MoveOp, popup_client->isMovable() );
popup->setItemEnabled( Options::MaximizeOp, popup_client->isMaximizable() );

View File

@ -300,6 +300,7 @@ private:
void init();
void initShortcuts();
void readShortcuts();
void initDesktopPopup();
bool startKDEWalkThroughWindows();
bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode