Merge pull request #752 from qSLX/master

Preventing losing keyboard focus by editor.
master
Marius Kintel 2014-04-22 01:03:21 -04:00
commit 91074eba48
5 changed files with 93 additions and 70 deletions

View File

@ -202,10 +202,10 @@ private:
char const * afterCompileSlot;
bool procevents;
class QTemporaryFile *tempFile;
class ProgressWidget *progresswidget;
class CGALWorker *cgalworker;
QMutex consolemutex;
signals:
void highlightError(int);
void unhighlightLastError();

View File

@ -126,6 +126,9 @@
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::WheelFocus</enum>
</property>
</widget>
</item>
</layout>
@ -139,6 +142,9 @@
</property>
<widget class="QGLView" name="qglview" native="true"/>
<widget class="QTextEdit" name="console">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
@ -328,6 +334,9 @@
<addaction name="viewActionDiagonal"/>
<addaction name="viewActionCenter"/>
<addaction name="separator"/>
<addaction name="viewActionZoomIn"/>
<addaction name="viewActionZoomOut"/>
<addaction name="separator"/>
<addaction name="viewActionResetView"/>
<addaction name="separator"/>
<addaction name="viewActionPerspective"/>
@ -864,6 +873,22 @@
<string>Reset View</string>
</property>
</action>
<action name="viewActionZoomIn">
<property name="text">
<string>Zoom In</string>
</property>
<property name="shortcut">
<string>Ctrl+]</string>
</property>
</action>
<action name="viewActionZoomOut">
<property name="text">
<string>Zoom Out</string>
</property>
<property name="shortcut">
<string>Ctrl+[</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -170,25 +170,6 @@ void QGLView::paintGL()
if (running_under_wine) swapBuffers();
}
void QGLView::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Plus: // On many keyboards, this requires to press Shift-equals
case Qt::Key_Equal: // ...so simplify this a bit.
cam.viewer_distance *= 0.9;
updateGL();
break;
case Qt::Key_Minus:
cam.viewer_distance /= 0.9;
updateGL();
break;
case Qt::Key_C: // 'center'
cam.object_trans << 0, 0, 0;
updateGL();
break;
}
}
void QGLView::wheelEvent(QWheelEvent *event)
{
cam.viewer_distance *= pow(0.9, event->delta() / 120.0);
@ -197,7 +178,6 @@ void QGLView::wheelEvent(QWheelEvent *event)
void QGLView::mousePressEvent(QMouseEvent *event)
{
setFocus();
mouse_drag_active = true;
last_mouse = event->globalPos();
}
@ -298,3 +278,14 @@ bool QGLView::save(const char *filename)
return img.save(filename, "PNG");
}
void QGLView::ZoomIn(void)
{
cam.viewer_distance *= 0.9;
updateGL();
}
void QGLView::ZoomOut(void)
{
cam.viewer_distance /= 0.9;
updateGL();
}

View File

@ -46,6 +46,10 @@ public:
bool save(const char *filename);
void resetView();
public slots:
void ZoomIn(void);
void ZoomOut(void);
public:
QLabel *statusLabel;
@ -55,7 +59,6 @@ private:
bool mouse_drag_active;
QPoint last_mouse;
void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);

View File

@ -198,6 +198,8 @@ MainWindow::MainWindow(const QString &filename)
fps = 0;
fsteps = 1;
editActionZoomIn->setShortcuts(QList<QKeySequence>() << editActionZoomIn->shortcuts() << QKeySequence("CTRL+="));
connect(this, SIGNAL(highlightError(int)), editor, SLOT(highlightError(int)));
connect(this, SIGNAL(unhighlightLastError()), editor, SLOT(unhighlightLastError()));
editor->setTabStopWidth(30);
@ -357,6 +359,8 @@ MainWindow::MainWindow(const QString &filename)
connect(this->viewActionPerspective, SIGNAL(triggered()), this, SLOT(viewPerspective()));
connect(this->viewActionOrthogonal, SIGNAL(triggered()), this, SLOT(viewOrthogonal()));
connect(this->viewActionHide, SIGNAL(triggered()), this, SLOT(hideConsole()));
connect(this->viewActionZoomIn, SIGNAL(triggered()), qglview, SLOT(ZoomIn()));
connect(this->viewActionZoomOut, SIGNAL(triggered()), qglview, SLOT(ZoomOut()));
// Help menu
connect(this->helpActionAbout, SIGNAL(triggered()), this, SLOT(helpAbout()));