Split code from MainWindow into another dialog