Show track buttons even on smaller track sizes

CCBUG: 365445
parent 8e957fdd
......@@ -73,6 +73,7 @@ CustomRuler::CustomRuler(const Timecode &tc, const QList<QAction *> &rulerAction
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QFontMetricsF fontMetrics(font());
// Define size variables
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
LABEL_SIZE = fontMetrics.ascent();
FONT_WIDTH = fontMetrics.averageCharWidth();
PREVIEW_SIZE = LABEL_SIZE / 3;
......
......@@ -133,6 +133,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, Timeline *timeline, CustomTra
//setCacheMode(QGraphicsView::CacheBackground);
setAutoFillBackground(false);
setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
setContentsMargins(0, 0, 0, 0);
KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
m_selectedTrackColor = scheme.background(KColorScheme::ActiveBackground ).color();
......
......@@ -49,15 +49,13 @@ HeaderTrack::HeaderTrack(TrackInfo info, const QList <QAction *> &actions, Track
setupUi(this);
setFocusPolicy(Qt::ClickFocus);
m_name = info.trackName.isEmpty() ? QString::number(m_parentTrack->index()) : info.trackName;
QFontMetrics metrics(font());
m_tb = new QToolBar(this);
m_tb->setToolButtonStyle(Qt::ToolButtonIconOnly);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
m_tb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_tb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_tb->setContentsMargins(0, 0, 0, 0);
int iconSize = m_tb->iconSize().width();
QSize s(iconSize, iconSize);
//setMinimumWidth(qMax(metrics.boundingRect(m_name).width() + iconSize + contentsMargins().right() * 6, 5 * iconSize));
track_number->setText(m_name);
track_number->setContextMenuPolicy(Qt::NoContextMenu);
track_number->installEventFilter(this);
......@@ -249,7 +247,23 @@ void HeaderTrack::adjustSize(int height)
QStyle *style = qApp->style();
trackHeight += style->pixelMetric(QStyle::PM_ToolBarIconSize);
bool smallTracks = height < trackHeight;
m_tb->setHidden(smallTracks);
if (smallTracks) {
int ix = button_layout->indexOf(m_tb);
if (ix != -1) {
// Move toolbar to the right of track label
QLayoutItem *item = button_layout->takeAt(ix);
delete item;
horizontalLayout->addWidget(m_tb);
}
} else {
int ix = horizontalLayout->indexOf(m_tb);
if (ix != -1) {
QLayoutItem *item = horizontalLayout->takeAt(ix);
delete item;
button_layout->addWidget(m_tb);
}
}
//m_tb->setHidden(smallTracks);
setFixedHeight(height);
}
......
......@@ -81,6 +81,7 @@ Timeline::Timeline(KdenliveDoc *doc, const QList<QAction *> &actions, const QLis
{
m_trackActions << actions;
setupUi(this);
splitter->setStretchFactor(1, 2);
m_scene = new CustomTrackScene(this);
m_trackview = new CustomTrackView(doc, this, m_scene, parent);
if (m_doc->setSceneList() == -1) *ok = false;
......@@ -142,7 +143,6 @@ Timeline::Timeline(KdenliveDoc *doc, const QList<QAction *> &actions, const QLis
tracksLayout->setContentsMargins(0, 0, 0, 0);
tracksLayout->setSpacing(0);
tracks_frame->setLayout(tracksLayout);
headers_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
headers_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ScrollEventEater *leventEater = new ScrollEventEater(this);
......@@ -364,7 +364,7 @@ int Timeline::getTracks() {
connect(tk, SIGNAL(storeSlowMotion(QString,Mlt::Producer *)), m_doc->renderer(), SLOT(storeSlowmotionProducer(QString,Mlt::Producer *)));
}
}
headers_container->setFixedWidth(headerWidth);
headers_area->setMinimumWidth(headerWidth);
if (audioTarget > -1) {
m_tracks.at(audioTarget)->trackHeader->switchTarget(true);
}
......
......@@ -27,131 +27,161 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="size_frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QFrame" name="ruler_frame">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QScrollArea" name="headers_area">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>70</width>
<height>129</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,10">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="size_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="headers_area">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>89</width>
<height>127</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>145</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QFrame" name="headers_container">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,10">
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item>
<widget class="QFrame" name="ruler_frame">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>145</height>
</size>
<property name="lineWidth">
<number>0</number>
</property>
</spacer>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="headers_container">
<item>
<widget class="QFrame" name="tracks_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="1">
<widget class="QFrame" name="tracks_frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -2,16 +2,8 @@
<ui version="4.0">
<class>TrackHeader_UI</class>
<widget class="QWidget" name="TrackHeader_UI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>254</width>
<height>38</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -72,7 +64,7 @@
<item>
<widget class="QLineEdit" name="track_number">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -92,6 +84,19 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment