Browse Source

TDEMenu search shortcut: various fixes

* Better Escape key usage prevention
* Better handling of different shortcut counts (0 vs 1 vs 2)
* Fixed a deprecated function call to setShortcut()

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/232/head
Mavridis Philippe 2 months ago
parent
commit
10cddab2e3
No known key found for this signature in database GPG Key ID: F8D2D7E2F989A494
  1. 16
      kcontrol/kicker/menutab_impl.cpp
  2. 23
      kicker/kicker/ui/k_mnu.cpp

16
kcontrol/kicker/menutab_impl.cpp

@ -38,6 +38,7 @@
#include <kstandarddirs.h>
#include <tdefontrequester.h>
#include <kkeybutton.h>
#include <tdemessagebox.h>
#include <kicondialog.h>
#include <kiconloader.h>
@ -171,7 +172,7 @@ void MenuTab::load( bool useDefaults )
m_showFrequent->setChecked(true);
c->setGroup("KMenu");
m_searchShortcut->setShortcut(TDEShortcut(c->readEntry("SearchShortcut", "/")));
m_searchShortcut->setShortcut(TDEShortcut(c->readEntry("SearchShortcut", "/")), false);
connect(m_searchShortcut, TQT_SIGNAL(capturedShortcut(const TDEShortcut&)), TQT_SIGNAL(changed()));
connect(m_searchShortcut, TQT_SIGNAL(capturedShortcut(const TDEShortcut&)), TQT_SLOT(setSearchShortcut(const TDEShortcut&)));
@ -359,8 +360,19 @@ void MenuTab::kmenuChanged()
void MenuTab::setSearchShortcut(const TDEShortcut &cut)
{
if( cut == TDEShortcut(TQt::Key_Escape) )
if( cut.contains( KKeySequence(KKey(TQt::Key_Escape)) ) )
{
int anotherTry = KMessageBox::warningYesNo(
this,
i18n("Cannot set Escape as menu search shortcut.\nWould you like to set another shortcut?"),
i18n("Invalid shortcut")
);
if( anotherTry == KMessageBox::Yes )
m_searchShortcut->captureShortcut();
return;
}
m_searchShortcut->setShortcut(cut, false);
}

23
kicker/kicker/ui/k_mnu.cpp

@ -270,13 +270,22 @@ void PanelKMenu::initialize()
TDEToolBarButton *clearButton = new TDEToolBarButton( "locationbar_erase", 0, hbox );
TQStringList cuts = TQStringList::split(";", KickerSettings::searchShortcut());
searchEdit = new KPIM::ClickLineEdit(
hbox,
( cuts.count() == 2
? i18n(" Press '%1' or '%2' to search...").arg(cuts[0], cuts[1])
: i18n(" Press '%1' to search...").arg(cuts[0])
)
);
TQString placeholder;
switch( cuts.count() )
{
case 0:
placeholder = i18n(" Click here to search...");
break;
case 1:
placeholder = i18n(" Press '%1' to search...").arg(cuts[0]);
break;
case 2:
placeholder = i18n(" Press '%1' or '%2' to search...").arg(cuts[0], cuts[1]);
break;
}
searchEdit = new KPIM::ClickLineEdit( hbox, placeholder );
hbox->setFocusPolicy(TQ_StrongFocus);
hbox->setFocusProxy(searchEdit);

Loading…
Cancel
Save