CustomRuler::CustomRuler(const Timecode &tc, const QList<QAction *> &rulerActions, CustomTrackView *parent) : QWidget(parent), m_timecode(tc), m_view(parent), m_duration(0), m_offset(0), m_hidePreview(true), m_headPosition(SEEK_INACTIVE), m_clickedGuide(-1), m_rate(-1), m_mouseMove(NO_MOVE) { setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); QFontMetricsF fontMetrics(font()); // Define size variables LABEL_SIZE = fontMetrics.ascent(); FONT_WIDTH = fontMetrics.averageCharWidth(); PREVIEW_SIZE = LABEL_SIZE / 3; setFixedHeight(LABEL_SIZE * 2); MAX_HEIGHT = height() - 1; FULL_HEIGHT = MAX_HEIGHT; int mark_length = MAX_HEIGHT - LABEL_SIZE - 1; MIDDLE_MARK_X = LABEL_SIZE + mark_length / 3; LITTLE_MARK_X = LABEL_SIZE + mark_length / 2; updateFrameSize(); m_scale = 3; m_zoneStart = 0; m_zoneEnd = 100; m_contextMenu = new QMenu(this); m_contextMenu->addActions(rulerActions); QAction *addGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add Guide")); connect(addGuide, SIGNAL(triggered()), m_view, SLOT(slotAddGuide())); m_editGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n("Edit Guide")); connect(m_editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide())); m_deleteGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete Guide")); connect(m_deleteGuide , SIGNAL(triggered()), this, SLOT(slotDeleteGuide())); QAction *delAllGuides = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete All Guides")); connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides())); m_goMenu = m_contextMenu->addMenu(i18n("Go To")); connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*))); setMouseTracking(true); m_zoneBG = palette().color(QPalette::Highlight); m_zoneBG.setAlpha(KdenliveSettings::useTimelineZoneToEdit() ? 180 : 60); }
CustomRuler::CustomRuler(const Timecode &tc, CustomTrackView *parent) : QWidget(parent), m_timecode(tc), m_view(parent), m_duration(0), m_offset(0), m_headPosition(SEEK_INACTIVE), m_clickedGuide(-1), m_rate(-1), m_mouseMove(NO_MOVE) { setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); QFontMetricsF fontMetrics(font()); // Define size variables LABEL_SIZE = fontMetrics.ascent(); FONT_WIDTH = fontMetrics.averageCharWidth(); setMinimumHeight(LABEL_SIZE * 2); setMaximumHeight(LABEL_SIZE * 2); MAX_HEIGHT = height(); BIG_MARK_X = LABEL_SIZE + 1; int mark_length = MAX_HEIGHT - BIG_MARK_X; MIDDLE_MARK_X = BIG_MARK_X + mark_length / 2; LITTLE_MARK_X = BIG_MARK_X + mark_length / 3; updateFrameSize(); m_scale = 3; m_zoneStart = 0; m_zoneEnd = 100; m_contextMenu = new QMenu(this); QAction *addGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Add Guide")); connect(addGuide, SIGNAL(triggered()), m_view, SLOT(slotAddGuide())); m_editGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n("Edit Guide")); connect(m_editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide())); m_deleteGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete Guide")); connect(m_deleteGuide , SIGNAL(triggered()), this, SLOT(slotDeleteGuide())); QAction *delAllGuides = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete All Guides")); connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides())); m_goMenu = m_contextMenu->addMenu(i18n("Go To")); connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*))); setMouseTracking(true); }