[klipper] Port from KMenu to QMenu

Note: depending on the widget style this renders a regression as the
section might not be supported by the style. This is the case for
Oxygen, see bug 335400.

REVIEW: 118343
wilder-5.14
Martin Gräßlin 12 years ago
parent 461225e400
commit 4718ff36cc
  1. 8
      klipper/klipperpopup.cpp
  2. 4
      klipper/klipperpopup.h
  3. 11
      klipper/popupproxy.cpp
  4. 4
      klipper/popupproxy.h
  5. 8
      klipper/urlgrabber.cpp
  6. 3
      klipper/urlgrabber.h

@ -113,7 +113,7 @@ void KlipperPopup::ensureClean() {
}
void KlipperPopup::buildFromScratch() {
addTitle(QIcon::fromTheme("klipper"), i18n("Klipper - Clipboard Tool"));
addSection(QIcon::fromTheme("klipper"), i18n("Klipper - Clipboard Tool"));
m_filterWidget = new KLineEdit(this);
m_filterWidget->setFocusPolicy( Qt::NoFocus );
@ -190,7 +190,7 @@ void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
e->text(),
e->isAutoRepeat(),
e->count() );
KMenu::keyPressEvent( &ke );
QMenu::keyPressEvent( &ke );
#ifdef DEBUG_EVENTS__
kDebug() << "Passing this event to ancestor (KMenu): " << e << "->" << ke;
#endif
@ -217,14 +217,14 @@ void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
#ifdef DEBUG_EVENTS__
kDebug() << "Passing this event to ancestor (KMenu): " << e;
#endif
KMenu::keyPressEvent(e);
QMenu::keyPressEvent(e);
break;
}
case Qt::Key_Return:
case Qt::Key_Enter:
{
KMenu::keyPressEvent(e);
QMenu::keyPressEvent(e);
this->hide();
if (activeAction() == m_filterWidgetAction)

@ -21,7 +21,7 @@
#include <QList>
#include <KMenu>
#include <QMenu>
class QAction;
class QWidgetAction;
@ -37,7 +37,7 @@ class History;
* Default view of clipboard history.
*
*/
class KlipperPopup : public KMenu
class KlipperPopup : public QMenu
{
Q_OBJECT

@ -24,7 +24,6 @@
#include <QImage>
#include <QStyleOption>
#include <KMenu>
#include <KLocalizedString>
#include <KDebug>
@ -53,13 +52,13 @@ void PopupProxy::slotHistoryChanged() {
}
void PopupProxy::deleteMoreMenus() {
const KMenu* myParent = parent();
const QMenu* myParent = parent();
if ( myParent != m_proxy_for_menu ) {
KMenu* delme = m_proxy_for_menu;
m_proxy_for_menu = static_cast<KMenu*>( m_proxy_for_menu->parent() );
QMenu* delme = m_proxy_for_menu;
m_proxy_for_menu = static_cast<QMenu*>( m_proxy_for_menu->parent() );
while ( m_proxy_for_menu != myParent ) {
delme = m_proxy_for_menu;
m_proxy_for_menu = static_cast<KMenu*>( m_proxy_for_menu->parent() );
m_proxy_for_menu = static_cast<QMenu*>( m_proxy_for_menu->parent() );
}
// We are called probably from within the menus event-handler (triggered=>slotMoveToTop=>changed=>slotHistoryChanged=>deleteMoreMenus)
// what can result in a crash if we just delete the menu here (#155196 and #165154) So, delay the delete.
@ -168,7 +167,7 @@ int PopupProxy::insertFromSpill( int index ) {
// If there is more items in the history, insert a new "More..." menu and
// make *this a proxy for that menu ('s content).
if (history->first() && m_spill_uuid != history->first()->uuid()) {
KMenu* moreMenu = new KMenu(i18n("&More"), m_proxy_for_menu);
QMenu* moreMenu = new QMenu(i18n("&More"), m_proxy_for_menu);
connect(moreMenu, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
QAction *before = index < m_proxy_for_menu->actions().count() ? m_proxy_for_menu->actions().at(index) : 0;
m_proxy_for_menu->insertMenu(before, moreMenu);

@ -24,7 +24,7 @@
#include "history.h"
class KMenu;
class QMenu;
class HistoryItem;
class KlipperPopup;
@ -79,7 +79,7 @@ private:
void deleteMoreMenus();
private:
KMenu* m_proxy_for_menu;
QMenu* m_proxy_for_menu;
QByteArray m_spill_uuid;
QRegExp m_filter;
int m_menu_height;

@ -25,10 +25,10 @@
#include <QUuid>
#include <QFile>
#include <QX11Info>
#include <QMenu>
#include <KDialog>
#include <KLocalizedString>
#include <KMenu>
#include <KService>
#include <KDebug>
#include <KIconLoader>
@ -220,13 +220,13 @@ void URLGrabber::actionMenu( const HistoryItem* item, bool automatically_invoked
m_myPopupKillTimer->stop();
m_myMenu = new KMenu;
m_myMenu = new QMenu;
connect(m_myMenu, SIGNAL(triggered(QAction*)), SLOT(slotItemSelected(QAction*)));
foreach (ClipAction* clipAct, matchingActionsList) {
m_myMenu->addTitle(QIcon::fromTheme( "klipper" ),
i18n("%1 - Actions For: %2", clipAct->description(), KStringHandler::csqueeze(text, 45)));
m_myMenu->addSection(QIcon::fromTheme( "klipper" ),
i18n("%1 - Actions For: %2", clipAct->description(), KStringHandler::csqueeze(text, 45)));
QList<ClipCommand> cmdList = clipAct->commands();
int listSize = cmdList.count();
for (int i=0; i<listSize;++i) {

@ -30,7 +30,6 @@ class HistoryItem;
class QTimer;
class KConfig;
class KMenu;
class QMenu;
class QAction;
@ -85,7 +84,7 @@ private:
// holds mappings of menu action IDs to action commands (action+cmd index in it)
QHash<QString, QPair<ClipAction*, int> > m_myCommandMapper;
KMenu* m_myMenu;
QMenu* m_myMenu;
QTimer* m_myPopupKillTimer;
int m_myPopupKillTimeout;
bool m_stripWhiteSpace;

Loading…
Cancel
Save