MCPcopy Create free account
hub / github.com/YACReader/yacreader / setupUI

Method setupUI

YACReader/main_window_viewer.cpp:240–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240void MainWindowViewer::setupUI()
241{
242 // setUnifiedTitleAndToolBarOnMac(true);
243
244 viewer = new Viewer(this);
245 connect(viewer, &Viewer::comicLoaded, this, [this] {
246 if (viewer->magnifyingGlassIsVisible())
247 setMglassActionsEnabled(true);
248 setLoadedComicActionsEnabled(true);
249 });
250 connect(viewer, &Viewer::magnifyingGlassVisibilityChanged, this, &MainWindowViewer::setMglassActionsEnabled);
251 connect(viewer, &Viewer::reset, this, &MainWindowViewer::processReset);
252 // detected end of comic
253 connect(viewer, &Viewer::openNextComic, this, &MainWindowViewer::openNextComic);
254 // detected start of comic
255 connect(viewer, &Viewer::openPreviousComic, this, &MainWindowViewer::openPreviousComic);
256
257 setCentralWidget(viewer);
258 QScreen *screen = window()->screen();
259 if (screen == nullptr) {
260 screen = QApplication::screens().constFirst();
261 }
262
263 int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
264 int widthDesktopResolution = screen != nullptr ? screen->size().width() : 1024;
265 int height, width;
266 height = static_cast<int>(heightDesktopResolution * 0.84);
267 width = static_cast<int>(height * 0.70);
268 Configuration &conf = Configuration::getConfiguration();
269 if (!restoreGeometry(conf.getGeometry())) {
270 move(QPoint((widthDesktopResolution - width) / 2, ((heightDesktopResolution - height) - 40) / 2));
271 resize(QSize(width, height));
272 } else {
273 // Guard against the window landing off-screen when a monitor is unplugged
274 // between sessions. Qt 6 tries to remap the geometry to the primary screen
275 // when the saved screen is gone, but the result can still be off-screen.
276 const QRect restored = geometry();
277 const auto availableScreens = QApplication::screens();
278 const bool onScreen = std::any_of(
279 availableScreens.cbegin(), availableScreens.cend(),
280 [&restored](QScreen *s) { return s->availableGeometry().intersects(restored); });
281 if (!onScreen) {
282 const QRect avail = QApplication::primaryScreen()->availableGeometry();
283 move(avail.center() - QPoint(width / 2, height / 2));
284 }
285 }
286
287 had = new HelpAboutDialog(this); // TODO load data
288
289 had->loadAboutInformation(":/files/about.html");
290 had->loadHelp(":/files/helpYACReader.html");
291
292 optionsDialog = new OptionsDialog(this);
293 connect(optionsDialog, &QDialog::accepted, viewer, &Viewer::updateOptions);
294 connect(optionsDialog, &YACReaderOptionsDialog::optionsChanged, this, &MainWindowViewer::reloadOptions);
295 connect(optionsDialog, &OptionsDialog::changedFilters, viewer, &Viewer::updateFilters);
296 connect(optionsDialog, &OptionsDialog::changedImageOptions, viewer, &Viewer::onImageOptionsChanged);
297

Callers

nothing calls this directly

Calls 8

QPointClass · 0.85
getGeometryMethod · 0.80
loadAboutInformationMethod · 0.80
loadHelpMethod · 0.80
getShowToolbarsMethod · 0.80
getFullScreenMethod · 0.80
restoreOptionsMethod · 0.45

Tested by

no test coverage detected