mtsgui: conveniently switch between tabs using Alt+Left and Alt+Right

metadata
Wenzel Jakob 2014-01-11 22:02:16 +01:00
parent 8bbb097936
commit 155cb3b83a
4 changed files with 18 additions and 1 deletions

View File

@ -492,8 +492,16 @@ void GLWidget::keyPressEvent(QKeyEvent *event) {
case Qt::Key_PageUp: m_context->movementScale *= 2; break;
case Qt::Key_PageDown: m_context->movementScale /= 2; break;
case Qt::Key_Left:
if (event->modifiers() & Qt::AltModifier) {
emit switchTab(-1);
return;
}
m_leftKeyDown = true; break;
case Qt::Key_Right:
if (event->modifiers() & Qt::AltModifier) {
emit switchTab(1);
return;
}
m_rightKeyDown = true; break;
case Qt::Key_Up:
m_upKeyDown = true; break;
@ -520,7 +528,7 @@ void GLWidget::keyPressEvent(QKeyEvent *event) {
if (m_context->selectionMode == EScene) {
m_context->selectionMode = ENothing;
m_aabb.reset();
} else {
} else if (m_context->scene) {
m_context->selectionMode = EScene;
m_aabb = m_context->scene->getKDTree()->getAABB();
}

View File

@ -90,6 +90,7 @@ signals:
void loadFileRequest(const QString &fileName);
void crop(int type, int x, int y, int width, int height);
void selectionChanged();
void switchTab(int rel);
public slots:
void timerImpulse();

View File

@ -169,6 +169,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->glView, SIGNAL(statusMessage(const QString &)), this, SLOT(onStatusMessage(const QString &)),
Qt::QueuedConnection);
connect(ui->glView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(ui->glView, SIGNAL(switchTab(int)), this, SLOT(onSwitchTab(int)));
/* Load defaults from app settings file */
ui->glView->setInvertMouse(settings.value("invertMouse", false).toBool());
@ -500,6 +501,12 @@ void MainWindow::on_actionFocusSelected_triggered() {
ui->glView->keyPressEvent(&event);
}
void MainWindow::onSwitchTab(int rel) {
int index = ui->tabBar->currentIndex() + rel;
if (index >= 0 && index < ui->tabBar->count())
ui->tabBar->setCurrentIndex(index);
}
void MainWindow::on_actionFocusAll_triggered() {
QKeyEvent event(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier);
ui->glView->keyPressEvent(&event);

View File

@ -202,6 +202,7 @@ private slots:
void on_glView_crop(int type, int x=0, int y=0,
int width=0, int height=0);
void onSelectionChanged();
void onSwitchTab(int rel);
private:
void exportImage(const QString &fileName);