Update mainwindow.cpp

adding andrey's code manually after failed merge