fixed #685
This commit is contained in:
@@ -60,7 +60,6 @@ KeySequenceEditor::KeySequenceEditor(QWidget* parent, QAction* a)
|
||||
|
||||
void KeySequenceEditor::set_action_shortcut() {
|
||||
action->setShortcut(keySequence());
|
||||
action->setShortcutContext(Qt::ApplicationShortcut);
|
||||
}
|
||||
|
||||
void KeySequenceEditor::reset_to_default() {
|
||||
|
||||
@@ -341,7 +341,6 @@ void kbd_shortcut_processor(QByteArray& file, QMenu* menu, bool save, bool first
|
||||
}
|
||||
}
|
||||
}
|
||||
a->setShortcutContext(Qt::ApplicationShortcut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,41 @@ void ViewerWindow::set_texture(GLuint t, double iar, QMutex* imutex) {
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewerWindow::shortcut_copier(QVector<QShortcut*>& shortcuts, QMenu* menu) {
|
||||
QList<QAction*> menu_action = menu->actions();
|
||||
for (int i=0;i<menu_action.size();i++) {
|
||||
if (menu_action.at(i)->menu() != nullptr) {
|
||||
shortcut_copier(shortcuts, menu_action.at(i)->menu());
|
||||
} else if (!menu_action.at(i)->isSeparator() && !menu_action.at(i)->shortcut().isEmpty()) {
|
||||
QShortcut* sc = new QShortcut(this);
|
||||
sc->setKey(menu_action.at(i)->shortcut());
|
||||
connect(sc, SIGNAL(activated()), menu_action.at(i), SLOT(trigger()));
|
||||
shortcuts.append(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWindow::showEvent(QShowEvent *)
|
||||
{
|
||||
// Here, we copy all shortcuts from the MainWindow to this window. I don't like this solution, but messing around
|
||||
// with Qt's event system proved fruitless. Also setting the shortcuts to ApplicationShortcut rather than
|
||||
// WindowShortcut caused issues elsewhere (shortcuts being picked up in comboboxes and dialog boxes - we only
|
||||
// want the shortcuts to be shared to this window). Therefore, this and shortcut_copier() are so far the best
|
||||
// solutions I can find.
|
||||
|
||||
// Clear any existing shortcuts in case they've changed since the last showing
|
||||
for (int i=0;i<shortcuts_.size();i++) {
|
||||
delete shortcuts_.at(i);
|
||||
}
|
||||
shortcuts_.clear();
|
||||
|
||||
// Recursively copy all shortcuts from MainWindow to this window
|
||||
QList<QAction*> menubar_actions = olive::MainWindow->menuBar()->actions();
|
||||
for (int i=0;i<menubar_actions.size();i++) {
|
||||
shortcut_copier(shortcuts_, menubar_actions.at(i)->menu());
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWindow::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
hide();
|
||||
|
||||
+20
-15
@@ -29,27 +29,32 @@ class QMenu;
|
||||
class QShortcut;
|
||||
|
||||
class ViewerWindow : public QOpenGLWidget {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
ViewerWindow(QWidget *parent);
|
||||
void set_texture(GLuint t, double iar, QMutex *imutex);
|
||||
ViewerWindow(QWidget *parent);
|
||||
void set_texture(GLuint t, double iar, QMutex *imutex);
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent*) override;
|
||||
virtual void mousePressEvent(QMouseEvent*) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent*) override;
|
||||
virtual void showEvent(QShowEvent*) override;
|
||||
virtual void keyPressEvent(QKeyEvent*) override;
|
||||
virtual void mousePressEvent(QMouseEvent*) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent*) override;
|
||||
|
||||
virtual void paintGL() override;
|
||||
virtual void paintGL() override;
|
||||
private:
|
||||
GLuint texture;
|
||||
double ar;
|
||||
QMutex* mutex;
|
||||
GLuint texture;
|
||||
double ar;
|
||||
QMutex* mutex;
|
||||
|
||||
// exit full screen message
|
||||
QTimer fullscreen_msg_timer;
|
||||
bool show_fullscreen_msg;
|
||||
QRect fullscreen_msg_rect;
|
||||
// shortcuts
|
||||
void shortcut_copier(QVector<QShortcut*>& shortcuts, QMenu* menu);
|
||||
QVector<QShortcut*> shortcuts_;
|
||||
|
||||
// exit full screen message
|
||||
QTimer fullscreen_msg_timer;
|
||||
bool show_fullscreen_msg;
|
||||
QRect fullscreen_msg_rect;
|
||||
private slots:
|
||||
void fullscreen_msg_timeout();
|
||||
void fullscreen_msg_timeout();
|
||||
};
|
||||
|
||||
#endif // VIEWERWINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user