Skip to content

Commit d451699

Browse files
committed
fix mirror screen bug
1 parent 0bf86b7 commit d451699

File tree

6 files changed

+65
-26
lines changed

6 files changed

+65
-26
lines changed

src/loginform.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ LoginForm::LoginForm(QWidget *parent) :
6868

6969
ui->setupUi(this);
7070
initialize();
71-
ctrlClicked = false;
71+
winClicked = false;
7272

7373
}
7474

@@ -1011,7 +1011,7 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
10111011

10121012
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
10131013

1014-
ctrlClicked = false;
1014+
winClicked = false;
10151015
if(ui->stackedWidget->currentIndex() == ui->stackedWidget->indexOf(ui->resetpage))
10161016
on_resetpasswordButton_clicked();
10171017
else if(ui->stackedWidget->currentIndex() == ui->stackedWidget->indexOf(ui->warningpage)){
@@ -1035,7 +1035,7 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
10351035
}
10361036
else if (event->key() == Qt::Key_Escape) {
10371037

1038-
ctrlClicked = false;
1038+
winClicked = false;
10391039
#ifdef SCREENKEYBOARD
10401040
emit sendKeyboardCloseRequest();
10411041
#endif
@@ -1060,19 +1060,19 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
10601060
}
10611061
else if ((event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) &&
10621062
ui->stackedWidget->currentIndex() == ui->stackedWidget->indexOf(ui->loginpage)) {
1063-
ctrlClicked = false;
1063+
winClicked = false;
10641064
userSelectStateMachine(event->key(), -1);
1065-
}else if (event->key() == Qt::Key_Control){
1066-
ctrlClicked = true;
1067-
}else if (event->key() == Qt::Key_Shift){
1065+
}else if (event->key() == Qt::Key_Meta || event->key() == Qt::Key_Meta ){
1066+
winClicked = true;
1067+
}else if (event->key() == Qt::Key_Space){
10681068

1069-
if(ctrlClicked)
1069+
if(winClicked)
10701070
emit selectKeyboard();
10711071

1072-
ctrlClicked = false;
1072+
winClicked = false;
10731073
}
10741074
else {
1075-
ctrlClicked = false;
1075+
winClicked = false;
10761076
QWidget::keyPressEvent(event);
10771077
}
10781078

src/loginform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private slots:
217217
bool passwordChangeError;
218218
int nwcheckcount;
219219
QString realM;
220-
bool ctrlClicked;
220+
bool winClicked;
221221
QString currentSessionStr;
222222

223223

src/mainwindow.cpp

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ MainWindow::MainWindow(int screen, QWidget *parent) :
5050
setGeometry(screenRect);
5151

5252

53-
if(mainWindowsList != NULL)
53+
if(mainWindowsList != NULL){
5454
mainWindowsList[m_Screen] = this;
5555

56+
}
5657

5758
previousScreen = 1;
5859
setBackground(true);
@@ -67,7 +68,7 @@ MainWindow::MainWindow(int screen, QWidget *parent) :
6768
}
6869

6970
qApp->installEventFilter(this);
70-
71+
mirrored = 0;
7172
currentScreen = m_Screen;
7273

7374
widgetScreen = m_Screen;
@@ -161,6 +162,15 @@ MainWindow::MainWindow(int screen, QWidget *parent) :
161162
QObject::connect(m_LoginForm, &LoginForm::sendCurrentUser, m_SettingsForm, &SettingsForm::receiveCurrentUser);
162163
keyboardInit();
163164

165+
}else{
166+
167+
if(mainWindowsList[1] != NULL && mainWindowsList[0] != NULL){
168+
if(mainWindowsList[1]->pos().x() == mainWindowsList[0]->pos().x()){
169+
mainWindowsList[1]->hide();
170+
mirrored = 1;
171+
}
172+
}
173+
164174
}
165175

166176
}
@@ -221,7 +231,7 @@ void MainWindow::setBackground(bool start)
221231

222232
if(!pathToBackgroundImage.isNull() && !pathToBackgroundImage.isEmpty()){
223233

224-
backgroundImage = QImage(pathToBackgroundImage);
234+
backgroundImage = QImage(pathToBackgroundImage);
225235

226236
}else if(!pathToBackgroundImageDir.isNull() && !pathToBackgroundImageDir.isEmpty()){
227237

@@ -482,26 +492,40 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
482492
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
483493
QPoint globalCursorPos = QCursor::pos();
484494

495+
if(mainWindowsList[1] != NULL && mainWindowsList[0] != NULL){
496+
if(mainWindowsList[1]->pos().x() == mainWindowsList[0]->pos().x()){
497+
mainWindowsList[1]->hide();
498+
mirrored = 1;
499+
}
500+
}
501+
502+
503+
if(mirrored)
504+
mainWindowsList[1]->hide();
505+
485506
int mousescreen = qApp->desktop()->screenNumber(globalCursorPos);
486507

487508
if(mousescreen != currentScreen){
488509

510+
// mainWindowsList[previousScreen]->hide();
489511
previousScreen = currentScreen;
490512
currentScreen = mousescreen;
491513

514+
515+
492516
QRect prvScreenRect = QApplication::desktop()->screenGeometry(previousScreen);
493517
QRect curScreenRect = QApplication::desktop()->screenGeometry(currentScreen);
494518

495519
for (int i = 0; i < QApplication::desktop()->screenCount(); i++){
496520
if(mainWindowsList[i]->pos().x() == prvScreenRect.x() && mainWindowsList[i]->pos().y() == prvScreenRect.y()){
497-
498521
mainWindowsList[i]->hide();
499522
mainWindowsList[i]->setGeometry(curScreenRect);
523+
500524
mainWindowsList[i]->move(QPoint(curScreenRect.x(), curScreenRect.y()));
501525
mainWindowsList[i]->m_Screen = currentScreen;
502526
mainWindowsList[i]->setBackground(false);
503527
mainWindowsList[i]->show();
504-
528+
// mainWindowsList[previousScreen]->hide();
505529

506530
}else if(mainWindowsList[i]->pos().x() == curScreenRect.x() && mainWindowsList[i]->pos().y() == curScreenRect.y()){
507531

@@ -514,13 +538,19 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
514538

515539
mainWindowsList[i]->show();
516540

541+
517542
}
518543

519544
}
520545

546+
}else{
521547
}
522548

523549
}
550+
551+
if(mirrored)
552+
mainWindowsList[1]->hide();
553+
524554
return false;
525555
}
526556

@@ -591,6 +621,13 @@ void MainWindow::checkNetwork(){
591621

592622
void MainWindow::receiveNetworkStatus(bool connected){
593623

624+
if(mainWindowsList[1] != NULL && mainWindowsList[0] != NULL){
625+
if(mainWindowsList[1]->pos().x() == mainWindowsList[0]->pos().x()){
626+
mainWindowsList[1]->hide();
627+
mirrored = 1;
628+
}
629+
}
630+
594631
emit sendNetworkStatustoChilds(connected);
595632

596633
}

src/mainwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public slots:
7979
static MainWindow **mainWindowsList;
8080
QPoint mouseppos;
8181
QLabel *hostNameLabel;
82+
int initialScreenset;
83+
int mirrored;
8284

8385
#ifdef SCREENKEYBOARD
8486
Keyboard *screenKeyboard;

src/settingsform.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SettingsForm::SettingsForm(QWidget *parent) :
4141
ui->setupUi(this);
4242

4343
initialize();
44-
ctrlClicked = false;
44+
winClicked = false;
4545

4646

4747
qDebug() << tr("SettingsForm is initializing");
@@ -510,7 +510,7 @@ void SettingsForm::keyPressEvent(QKeyEvent *event)
510510
{
511511

512512
if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) {
513-
ctrlClicked = false;
513+
winClicked = false;
514514
if(ui->kybrdcomboBox->isActiveWindow()){
515515

516516
}
@@ -524,27 +524,27 @@ void SettingsForm::keyPressEvent(QKeyEvent *event)
524524
}
525525
}else if(event->key() == Qt::Key_Escape){
526526

527-
ctrlClicked = false;
527+
winClicked = false;
528528
clearFocus();
529529

530530
ui->kybrdcomboBox->clearFocus();
531531
ui->NwpushButton->clearFocus();
532532

533533

534-
} else if(event->key() == Qt::Key_Control){
534+
} else if(event->key() == Qt::Key_Meta){
535535

536-
ctrlClicked = true;
536+
winClicked = true;
537537

538538

539-
}else if(event->key() == Qt::Key_Shift){
539+
}else if(event->key() == Qt::Key_Space){
540540

541-
if(ctrlClicked)
541+
if(winClicked)
542542
keyboardSelect();
543-
ctrlClicked = false;
543+
winClicked = false;
544544

545545
}else{
546546

547-
ctrlClicked = false;
547+
winClicked = false;
548548
QWidget::keyPressEvent(event);
549549
}
550550

src/settingsform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public slots:
108108
bool nwButtonPressed;
109109
bool networkOK;
110110
NetworkDialog *nwDialog;
111-
bool ctrlClicked;
111+
bool winClicked;
112112
bool batteryExist;
113113

114114

0 commit comments

Comments
 (0)