MCPcopy Create free account
hub / github.com/LibrePCB/LibrePCB / MainWindow

Method MainWindow

libs/librepcb/editor/mainwindow.cpp:147–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 ******************************************************************************/
146
147MainWindow::MainWindow(GuiApplication& app,
148 slint::ComponentHandle<ui::AppWindow> win, int id,
149 QObject* parent) noexcept
150 : QObject(parent),
151 onUiDataChanged(*this),
152 mId(id),
153 mSettingsPrefix(QString("window_%1").arg(mId)),
154 mApp(app),
155 mWindow(win),
156 mWidget(static_cast<QWidget*>(slint::cbindgen_private::slint_qt_get_widget(
157 &mWindow->window().window_handle()))),
158 mSections(new UiObjectList<WindowSection, ui::WindowSectionData>()),
159 mProjectPreviewRenderer(new ProjectReadmeRenderer(this)),
160 mTestAdapter() {
161 Q_ASSERT(mWidget);
162 mWidget->setObjectName("mainWindow");
163
164 // Register Slint callbacks.
165 mWindow->window().on_close_requested(
166 std::bind(&MainWindow::closeRequested, this));
167
168 // Prepare file system model.
169 auto fileSystemModel = std::make_shared<FileSystemModel>(
170 mApp.getWorkspace(), mApp.getWorkspace().getProjectsPath(),
171 mSettingsPrefix % "/workspace_tree", &mApp.getQuickAccess());
172 connect(fileSystemModel.get(), &FileSystemModel::openFileTriggered, &mApp,
173 [this](const FilePath& fp) { mApp.openFile(fp, mWidget); });
174 connect(fileSystemModel.get(), &FileSystemModel::newProjectTriggered, &mApp,
175 [this](const FilePath& parentDir) {
176 mApp.createProject(parentDir, false, mWidget);
177 });
178
179 // Set global data.
180 const ui::Data& d = mWindow->global<ui::Data>();
181 d.set_panel_page(ui::PanelPage::Home);
182 d.set_sections(mSections);
183 d.set_current_section_index(0);
184 d.set_cursor_coordinates(slint::SharedString());
185 d.set_workspace_folder_tree(fileSystemModel);
186 d.set_notifications_unread(
187 mApp.getNotifications().getUnreadNotificationsCount());
188 d.set_notifications_progress_index(
189 mApp.getNotifications().getCurrentProgressIndex());
190 d.set_notifications_shown(false);
191 d.set_project_preview_rendering(false);
192
193 // Bind global data to signals.
194 connect(&mApp.getNotifications(),
195 &NotificationsModel::unreadNotificationsCountChanged, this,
196 [this](int count) {
197 mWindow->global<ui::Data>().set_notifications_unread(count);
198 });
199 connect(&mApp.getNotifications(),
200 &NotificationsModel::currentProgressIndexChanged, this,
201 [this](int index) {
202 mWindow->global<ui::Data>().set_notifications_progress_index(index);
203 });
204 connect(mProjectPreviewRenderer.get(), &ProjectReadmeRenderer::runningChanged,

Callers

nothing calls this directly

Calls 15

QStringClass · 0.85
bindFunction · 0.85
q2sFunction · 0.85
s2qFunction · 0.85
updateFunction · 0.85
getOverrideWindowSizeFunction · 0.85
windowMethod · 0.80
openFileMethod · 0.80
requestMethod · 0.80
getSettingsMethod · 0.80

Tested by

no test coverage detected