mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Restore the ability to associate menus with actions
This commit is contained in:
parent
2eb32da7d6
commit
6928a3a0f5
@ -431,3 +431,13 @@ void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor &
|
|||||||
painter.drawArc(drawing_rect, angle * 16, (360 - gap) * 16);
|
painter.drawArc(drawing_rect, angle * 16, (360 - gap) * 16);
|
||||||
painter.restore();
|
painter.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_menu_on_action(QAction* ac, QMenu* menu) {
|
||||||
|
ac->setMenu<QMenu*>(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu*
|
||||||
|
menu_for_action(QAction *ac) {
|
||||||
|
return ac->menu<QMenu*>();
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QParallelAnimationGroup>
|
#include <QParallelAnimationGroup>
|
||||||
|
|
||||||
@ -140,3 +141,5 @@ private:
|
|||||||
int load_style(const QHash<unsigned long,QString> &icon_map, int transient_scroller=0);
|
int load_style(const QHash<unsigned long,QString> &icon_map, int transient_scroller=0);
|
||||||
void set_no_activate_on_click(QWidget *widget);
|
void set_no_activate_on_click(QWidget *widget);
|
||||||
void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor & light, const QColor & dark);
|
void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor & light, const QColor & dark);
|
||||||
|
void set_menu_on_action(QAction* ac, QMenu* menu);
|
||||||
|
QMenu* menu_for_action(QAction *ac);
|
||||||
|
@ -86,3 +86,5 @@ int load_style(SIP_PYDICT icon_map_, int transient_scroller);
|
|||||||
%End
|
%End
|
||||||
void set_no_activate_on_click(QWidget *widget);
|
void set_no_activate_on_click(QWidget *widget);
|
||||||
void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor & light, const QColor & dark) /ReleaseGIL/;
|
void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor & light, const QColor & dark) /ReleaseGIL/;
|
||||||
|
void set_menu_on_action(QAction* ac, QMenu* menu);
|
||||||
|
QMenu* menu_for_action(QAction *ac);
|
||||||
|
@ -6,8 +6,12 @@
|
|||||||
# for no good reason. Since we have a huge body of poorly maintained third
|
# for no good reason. Since we have a huge body of poorly maintained third
|
||||||
# party plugin code, we NEED backward compat.
|
# party plugin code, we NEED backward compat.
|
||||||
|
|
||||||
from qt.core import QSinglePointEvent, QDialog, QMenu, QDrag, QEventLoop, QThread, QMessageBox
|
from qt.core import (
|
||||||
|
QAction, QDialog, QDrag, QEventLoop, QMenu, QMessageBox, QSinglePointEvent,
|
||||||
|
QThread
|
||||||
|
)
|
||||||
|
|
||||||
|
from calibre_extensions import progress_indicator
|
||||||
|
|
||||||
# Restore removed functions from QMouseEvent
|
# Restore removed functions from QMouseEvent
|
||||||
QSinglePointEvent.x = lambda self: int(self.position().x())
|
QSinglePointEvent.x = lambda self: int(self.position().x())
|
||||||
@ -27,3 +31,8 @@ QDrag.exec_ = QDrag.exec
|
|||||||
QEventLoop.exec_ = QEventLoop.exec
|
QEventLoop.exec_ = QEventLoop.exec
|
||||||
QThread.exec_ = QThread.exec
|
QThread.exec_ = QThread.exec
|
||||||
QMessageBox.exec_ = QMessageBox.exec
|
QMessageBox.exec_ = QMessageBox.exec
|
||||||
|
|
||||||
|
|
||||||
|
# Restore ability to associate a menu with an action
|
||||||
|
QAction.setMenu = lambda self, menu: progress_indicator.set_menu_on_action(self, menu)
|
||||||
|
QAction.menu = lambda self, menu: progress_indicator.menu_for_action(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user