[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() { 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 = new KLineEdit(this);
m_filterWidget->setFocusPolicy( Qt::NoFocus ); m_filterWidget->setFocusPolicy( Qt::NoFocus );
@ -190,7 +190,7 @@ void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
e->text(), e->text(),
e->isAutoRepeat(), e->isAutoRepeat(),
e->count() ); e->count() );
KMenu::keyPressEvent( &ke ); QMenu::keyPressEvent( &ke );
#ifdef DEBUG_EVENTS__ #ifdef DEBUG_EVENTS__
kDebug() << "Passing this event to ancestor (KMenu): " << e << "->" << ke; kDebug() << "Passing this event to ancestor (KMenu): " << e << "->" << ke;
#endif #endif
@ -217,14 +217,14 @@ void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
#ifdef DEBUG_EVENTS__ #ifdef DEBUG_EVENTS__
kDebug() << "Passing this event to ancestor (KMenu): " << e; kDebug() << "Passing this event to ancestor (KMenu): " << e;
#endif #endif
KMenu::keyPressEvent(e); QMenu::keyPressEvent(e);
break; break;
} }
case Qt::Key_Return: case Qt::Key_Return:
case Qt::Key_Enter: case Qt::Key_Enter:
{ {
KMenu::keyPressEvent(e); QMenu::keyPressEvent(e);
this->hide(); this->hide();
if (activeAction() == m_filterWidgetAction) if (activeAction() == m_filterWidgetAction)

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

@ -24,7 +24,6 @@
#include <QImage> #include <QImage>
#include <QStyleOption> #include <QStyleOption>
#include <KMenu>
#include <KLocalizedString> #include <KLocalizedString>
#include <KDebug> #include <KDebug>
@ -53,13 +52,13 @@ void PopupProxy::slotHistoryChanged() {
} }
void PopupProxy::deleteMoreMenus() { void PopupProxy::deleteMoreMenus() {
const KMenu* myParent = parent(); const QMenu* myParent = parent();
if ( myParent != m_proxy_for_menu ) { if ( myParent != m_proxy_for_menu ) {
KMenu* delme = m_proxy_for_menu; QMenu* 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() );
while ( m_proxy_for_menu != myParent ) { while ( m_proxy_for_menu != myParent ) {
delme = m_proxy_for_menu; 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) // 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. // 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 // If there is more items in the history, insert a new "More..." menu and
// make *this a proxy for that menu ('s content). // make *this a proxy for that menu ('s content).
if (history->first() && m_spill_uuid != history->first()->uuid()) { 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())); connect(moreMenu, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
QAction *before = index < m_proxy_for_menu->actions().count() ? m_proxy_for_menu->actions().at(index) : 0; QAction *before = index < m_proxy_for_menu->actions().count() ? m_proxy_for_menu->actions().at(index) : 0;
m_proxy_for_menu->insertMenu(before, moreMenu); m_proxy_for_menu->insertMenu(before, moreMenu);

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

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

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

Loading…
Cancel
Save