Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Improve UI
Browse files Browse the repository at this point in the history
Improve focus policy in screenpen.
  • Loading branch information
zty199 committed Apr 17, 2021
1 parent 2ad741b commit eeb4862
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/TeacherServer/screenpen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ScreenPen::ScreenPen(QWidget *parent) :
connect(new QShortcut(QKeySequence(Qt::Key_Minus), this), SIGNAL(activated()), this, SLOT(reducePenWidth()));
connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this), SIGNAL(activated()), this, SLOT(on_btn_exit_clicked()));

clear();
this->clear();
this->setFocus();
}

Expand All @@ -46,7 +46,7 @@ void ScreenPen::mousePressEvent(QMouseEvent *e)
endPnt = e->pos();
if(e->buttons() & Qt::RightButton)
{
clear();
this->clear();
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ void ScreenPen::drawCursor()
unsetCursor();
return;
}
setCursor(QCursor(pixmap, 0, pixmap.height()));
this->setCursor(QCursor(pixmap, 0, pixmap.height()));
}

void ScreenPen::draw(QImage &image)
Expand Down Expand Up @@ -152,7 +152,7 @@ void ScreenPen::draw(QImage &image)
default:
break;
}
update();
this->update();
}

void ScreenPen::clear()
Expand All @@ -165,24 +165,32 @@ void ScreenPen::clear()

void ScreenPen::on_btn_brush_clicked()
{
ui->btn_brush->setFocus();

draw_type = BRUSH_DRAW;
drawCursor();
}

void ScreenPen::on_btn_line_clicked()
{
ui->btn_line->setFocus();

draw_type = LINE_DRAW;
drawCursor();
}

void ScreenPen::on_btn_rect_clicked()
{
ui->btn_rect->setFocus();

draw_type = RECT_DRAW;
drawCursor();
}

void ScreenPen::on_btn_ellipse_clicked()
{
ui->btn_ellipse->setFocus();

draw_type = ELLIPSE_DRAW;
drawCursor();
}
Expand All @@ -199,7 +207,7 @@ void ScreenPen::on_btn_color_clicked()

void ScreenPen::on_btn_whiteboard_clicked()
{
clear();
this->clear();
if(flag_whiteboard)
{
bg_color = QColor(0, 0, 0, 1);
Expand All @@ -219,6 +227,8 @@ void ScreenPen::on_btn_exit_clicked()

void ScreenPen::clearDrawType()
{
this->setFocus();

draw_type = NONE_DRAW;
drawCursor();
}
Expand Down

0 comments on commit eeb4862

Please sign in to comment.