| 700 | |
| 701 | |
| 702 | void MapEditorController::attach(MainWindow* window) |
| 703 | { |
| 704 | print_dock_widget = nullptr; |
| 705 | measure_dock_widget = nullptr; |
| 706 | color_dock_widget = nullptr; |
| 707 | symbol_dock_widget = nullptr; |
| 708 | std::function<void(const QString&)> zoom_display_function; |
| 709 | |
| 710 | this->window = window; |
| 711 | if (mode == MapEditor) |
| 712 | { |
| 713 | window->setHasUnsavedChanges(map->hasUnsavedChanges()); |
| 714 | } |
| 715 | connect(map, &Map::hasUnsavedChanged, window, &MainWindow::setHasUnsavedChanges); |
| 716 | |
| 717 | #ifdef Q_OS_ANDROID |
| 718 | QAndroidJniObject::callStaticMethod<void>("org/openorienteering/mapper/MapperActivity", |
| 719 | "lockOrientation", |
| 720 | "()V"); |
| 721 | #endif |
| 722 | if (mobile_mode) |
| 723 | { |
| 724 | window->setWindowState(window->windowState() | Qt::WindowFullScreen); |
| 725 | zoom_display_function = [window](const QString& text) { |
| 726 | window->showStatusBarMessage(text, 1000); |
| 727 | }; |
| 728 | } |
| 729 | else |
| 730 | { |
| 731 | // Add zoom / cursor position field to status bar |
| 732 | auto* statusbar_zoom_icon = new QLabel(); |
| 733 | auto fontmetrics = statusbar_zoom_icon->fontMetrics(); |
| 734 | auto pixmap = QPixmap(QLatin1String(":/images/magnifying-glass.png")); |
| 735 | auto scale = qreal(fontmetrics.height()) / pixmap.height(); |
| 736 | if (scale < 0.9 || scale > 1.1) |
| 737 | pixmap = pixmap.scaledToHeight(qRound(scale * pixmap.height()), Qt::SmoothTransformation); |
| 738 | statusbar_zoom_icon->setPixmap(pixmap); |
| 739 | |
| 740 | auto* statusbar_zoom_label = new QLabel(); |
| 741 | statusbar_zoom_label->setMinimumWidth(fontmetrics.boundingRect(QLatin1String("0.333x")).width()); |
| 742 | statusbar_zoom_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 743 | statusbar_zoom_label->setFrameShape(QFrame::NoFrame); |
| 744 | |
| 745 | zoom_display_function = [statusbar_zoom_label](const QString& text) { |
| 746 | statusbar_zoom_label->setText(text); |
| 747 | }; |
| 748 | |
| 749 | statusbar_zoom_frame = new QFrame(); |
| 750 | #ifdef Q_OS_WIN |
| 751 | statusbar_zoom_frame->setFrameShape(QFrame::NoFrame); |
| 752 | #else |
| 753 | statusbar_zoom_frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
| 754 | #endif |
| 755 | auto* statusbar_zoom_frame_layout = new QHBoxLayout(); |
| 756 | statusbar_zoom_frame_layout->setMargin(0); |
| 757 | statusbar_zoom_frame_layout->setSpacing(0); |
| 758 | statusbar_zoom_frame_layout->addSpacing(1); |
| 759 | statusbar_zoom_frame_layout->addWidget(statusbar_zoom_icon); |
no test coverage detected