| 1021 | } |
| 1022 | |
| 1023 | void MainWindow::setup() { |
| 1024 | if (!m_initPassed) { |
| 1025 | QFile(m_pathConfig).remove(); |
| 1026 | close(); |
| 1027 | return; |
| 1028 | } |
| 1029 | |
| 1030 | m_uiEditMode = m_config->value(SETTING_UI_EDIT_MODE, true).toBool(); |
| 1031 | |
| 1032 | |
| 1033 | setUIDocks(); |
| 1034 | show(); |
| 1035 | |
| 1036 | const QByteArray geometry = m_config->value(SETTING_WINDOW_GEOMETRY, QByteArray()).toByteArray(); |
| 1037 | if (restoreState(m_config->value(SETTING_WINDOW_STATE).toByteArray()) && restoreGeometry(geometry) && restoreGeometry(geometry)) { |
| 1038 | const QPoint position = m_config->value(SETTING_WINDOW_POSITION).toPoint(); |
| 1039 | QTimer::singleShot(0, [this, position]() { move(position); }); |
| 1040 | } else { |
| 1041 | foreach (DockWidget *dw, m_dockPtrs) { |
| 1042 | dw->setVisible(true); |
| 1043 | } |
| 1044 | resize(minimumWidth(), minimumHeight()); |
| 1045 | setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), qApp->screens().first()->availableGeometry())); |
| 1046 | } |
| 1047 | |
| 1048 | // restore the fullscreen modes as needed |
| 1049 | if (opts.fullscreen == -1) { |
| 1050 | setFullscreen(m_config->value(SETTING_WINDOW_FULLSCREEN, 0).toInt()); |
| 1051 | } else { |
| 1052 | setFullscreen(opts.fullscreen); |
| 1053 | } |
| 1054 | |
| 1055 | setUIEditMode(m_uiEditMode); |
| 1056 | |
| 1057 | stateLoadInfo(); |
| 1058 | recentLoadInfo(); |
| 1059 | |
| 1060 | if (m_config->value(SETTING_DEBUGGER_RESTORE_ON_OPEN).toBool()) { |
| 1061 | if (!opts.debugFile.isEmpty()) { |
| 1062 | debugImportFile(opts.debugFile); |
| 1063 | } else { |
| 1064 | debugImportFile(m_config->value(SETTING_DEBUGGER_IMAGE_PATH).toString()); |
| 1065 | } |
| 1066 | } |
| 1067 | |
| 1068 | if (opts.useSettings && isFirstRun() && m_initPassed && !m_needFullReset) { |
| 1069 | QMessageBox *info = new QMessageBox(); |
| 1070 | m_config->setValue(SETTING_FIRST_RUN, true); |
| 1071 | info->setWindowTitle(MSG_INFORMATION); |
| 1072 | info->setText(tr("Welcome!\n\nCEmu uses a customizable dock-style interface. " |
| 1073 | "Drag and drop to move tabs and windows around on the screen, " |
| 1074 | "and choose which docks are available in the 'Docks' menu in the topmost bar. " |
| 1075 | "Be sure that 'Enable UI edit mode' is selected when laying out your interface. " |
| 1076 | "Enjoy!" |
| 1077 | "\n\n(Notice: depending on your version, you can drag grouped tabs or an individual tab from their title or tab bar, respectively)" |
| 1078 | )); |
| 1079 | info->setWindowModality(Qt::NonModal); |
| 1080 | info->setWindowFlags(info->windowFlags() | Qt::WindowStaysOnTopHint); |