rewrite cleanup

This commit is contained in:
itsmattkc
2018-12-30 21:24:26 +11:00
parent f347c8eabe
commit 6e7bd5daaf
5 changed files with 74 additions and 88 deletions
-11
View File
@@ -96,15 +96,11 @@ void PreferencesDialog::save() {
void PreferencesDialog::setup_ui() {
QVBoxLayout* verticalLayout = new QVBoxLayout(this);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
QTabWidget* tabWidget = new QTabWidget(this);
tabWidget->setObjectName(QStringLiteral("tabWidget"));
QTabWidget* tab = new QTabWidget();
QGridLayout* gridLayout_2 = new QGridLayout(tab);
gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
gridLayout_2->addWidget(new QLabel("Image sequence formats:"), 0, 0, 1, 1);
imgSeqFormatEdit = new QLineEdit(tab);
@@ -116,7 +112,6 @@ void PreferencesDialog::setup_ui() {
recordingComboBox = new QComboBox(tab);
recordingComboBox->addItem("Mono");
recordingComboBox->addItem("Stereo");
recordingComboBox->setObjectName(QStringLiteral("recordingComboBox"));
gridLayout_2->addWidget(recordingComboBox, 1, 1, 1, 1);
@@ -125,21 +120,16 @@ void PreferencesDialog::setup_ui() {
tabWidget->addTab(tab_2, "Behavior");
QWidget* tab_4 = new QWidget();
QVBoxLayout* verticalLayout_2 = new QVBoxLayout(tab_4);
verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2"));
QGroupBox* groupBox = new QGroupBox(tab_4);
groupBox->setTitle("Seeking");
groupBox->setObjectName(QStringLiteral("groupBox"));
QVBoxLayout* verticalLayout_3 = new QVBoxLayout(groupBox);
verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3"));
accurateSeekButton = new QRadioButton(groupBox);
accurateSeekButton->setText("Accurate Seeking\nAlways show the correct frame (visual may pause briefly as correct frame is retrieved)");
accurateSeekButton->setObjectName(QStringLiteral("accurateSeekButton"));
verticalLayout_3->addWidget(accurateSeekButton);
fastSeekButton = new QRadioButton(groupBox);
fastSeekButton->setText("Fast Seeking\nSeek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export)");
fastSeekButton->setObjectName(QStringLiteral("fastSeekButton"));
verticalLayout_3->addWidget(fastSeekButton);
@@ -161,7 +151,6 @@ void PreferencesDialog::setup_ui() {
verticalLayout->addWidget(tabWidget);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setObjectName(QStringLiteral("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
+8 -5
View File
@@ -275,13 +275,18 @@ void MainWindow::make_new_menu(QMenu *parent) {
parent->addAction("&Folder", this, SLOT(new_folder()));
}
void MainWindow::make_inout_menu(QMenu *parent) {
parent->addAction("Set In Point", this, SLOT(set_in_point()), QKeySequence("I"));
parent->addAction("Set Out Point", this, SLOT(set_out_point()), QKeySequence("O"));
parent->addAction("Clear In/Out Point", this, SLOT(clear_inout()), QKeySequence("G"));
}
void MainWindow::show_about() {
AboutDialog a(this);
a.exec();
}
void MainWindow::delete_slot()
{
void MainWindow::delete_slot() {
if (panel_timeline->headers->hasFocus()) {
panel_timeline->headers->delete_markers();
} else if (panel_timeline->focused()) {
@@ -538,9 +543,7 @@ void MainWindow::setup_menus() {
edit_menu->addSeparator();
edit_menu->addAction("Set In Point", this, SLOT(set_in_point()), QKeySequence("I"));
edit_menu->addAction("Set Out Point", this, SLOT(set_out_point()), QKeySequence("O"));
edit_menu->addAction("Clear In/Out Point", this, SLOT(clear_inout()), QKeySequence("G"));
make_inout_menu(edit_menu);
edit_menu->addAction("Delete In/Out Point", this, SLOT(delete_inout()), QKeySequence(";"));
edit_menu->addAction("Ripple Delete In/Out Point", this, SLOT(ripple_delete_inout()), QKeySequence("'"));
+1
View File
@@ -16,6 +16,7 @@ public:
~MainWindow();
void make_new_menu(QMenu* parent);
void make_inout_menu(QMenu* parent);
public slots:
void undo();
-5
View File
@@ -1717,16 +1717,13 @@ void Timeline::setup_ui() {
QWidget* videoContainer = new QWidget(splitter);
QHBoxLayout* videoContainerLayout = new QHBoxLayout(videoContainer);
videoContainerLayout->setSpacing(0);
videoContainerLayout->setObjectName(QStringLiteral("horizontalLayout_2"));
videoContainerLayout->setContentsMargins(0, 0, 0, 0);
video_area = new TimelineWidget(videoContainer);
video_area->setObjectName(QStringLiteral("video_area"));
video_area->setFocusPolicy(Qt::ClickFocus);
videoContainerLayout->addWidget(video_area);
videoScrollbar = new QScrollBar(videoContainer);
videoScrollbar->setObjectName(QStringLiteral("videoScrollbar"));
videoScrollbar->setMaximum(0);
videoScrollbar->setSingleStep(20);
videoScrollbar->setPageStep(1826);
@@ -1741,7 +1738,6 @@ void Timeline::setup_ui() {
audioContainerLayout->setSpacing(0);
audioContainerLayout->setContentsMargins(0, 0, 0, 0);
audio_area = new TimelineWidget(audioContainer);
audio_area->setObjectName(QStringLiteral("audio_area"));
audio_area->setFocusPolicy(Qt::ClickFocus);
audioContainerLayout->addWidget(audio_area);
@@ -1759,7 +1755,6 @@ void Timeline::setup_ui() {
timeline_area_layout->addWidget(editAreas);
horizontalScrollBar = new ResizableScrollBar(timeline_area);
horizontalScrollBar->setObjectName(QStringLiteral("horizontalScrollBar"));
horizontalScrollBar->setMaximum(0);
horizontalScrollBar->setSingleStep(20);
horizontalScrollBar->setPageStep(1826);
+65 -67
View File
@@ -23,34 +23,34 @@
#define MARKER_SIZE 4
bool center_scroll_to_playhead(QScrollBar* bar, double zoom, long playhead) {
// returns true is the scroll was changed, false if not
int target_scroll = qMin(bar->maximum(), qMax(0, getScreenPointFromFrame(zoom, playhead)-(bar->width()>>1)));
if (target_scroll == bar->value()) {
return false;
}
bar->setValue(target_scroll);
return true;
// returns true is the scroll was changed, false if not
int target_scroll = qMin(bar->maximum(), qMax(0, getScreenPointFromFrame(zoom, playhead)-(bar->width()>>1)));
if (target_scroll == bar->value()) {
return false;
}
bar->setValue(target_scroll);
return true;
}
TimelineHeader::TimelineHeader(QWidget *parent) :
QWidget(parent),
snapping(true),
snapping(true),
dragging(false),
resizing_workarea(false),
zoom(1),
in_visible(0),
in_visible(0),
fm(font()),
dragging_markers(false),
scroll(0)
{
height_actual = fm.height();
setCursor(Qt::ArrowCursor);
setMouseTracking(true);
setCursor(Qt::ArrowCursor);
setMouseTracking(true);
setFocusPolicy(Qt::ClickFocus);
show_text(true);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(show_context_menu(const QPoint &)));
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(show_context_menu(const QPoint &)));
}
void TimelineHeader::set_scroll(int s) {
@@ -81,11 +81,11 @@ void TimelineHeader::set_visible_in(long i) {
void TimelineHeader::set_in_point(long new_in) {
long new_out = viewer->seq->workarea_out;
if (new_out == new_in) {
new_in--;
} else if (new_out < new_in) {
if (new_out == new_in) {
new_in--;
} else if (new_out < new_in) {
new_out = viewer->seq->getEndFrame();
}
}
undo_stack.push(new SetTimelineInOutCommand(viewer->seq, true, new_in, new_out));
update_parents();
@@ -93,18 +93,18 @@ void TimelineHeader::set_in_point(long new_in) {
void TimelineHeader::set_out_point(long new_out) {
long new_in = viewer->seq->workarea_in;
if (new_out == new_in) {
new_out++;
} else if (new_in > new_out || new_in < 0) {
new_in = 0;
}
if (new_out == new_in) {
new_out++;
} else if (new_in > new_out || new_in < 0) {
new_in = 0;
}
undo_stack.push(new SetTimelineInOutCommand(viewer->seq, true, new_in, new_out));
update_parents();
}
void TimelineHeader::set_scrollbar_max(QScrollBar* bar, long sequence_end_frame, int offset) {
bar->setMaximum(qMax(0, getScreenPointFromFrame(zoom, sequence_end_frame) - offset));
bar->setMaximum(qMax(0, getScreenPointFromFrame(zoom, sequence_end_frame) - offset));
}
void TimelineHeader::show_text(bool enable) {
@@ -118,7 +118,7 @@ void TimelineHeader::show_text(bool enable) {
}
void TimelineHeader::mousePressEvent(QMouseEvent* event) {
if (viewer->seq != NULL) {
if (viewer->seq != NULL && event->buttons() & Qt::LeftButton) {
if (resizing_workarea) {
sequence_end = viewer->seq->getEndFrame();
} else {
@@ -275,11 +275,11 @@ void TimelineHeader::update_parents() {
void TimelineHeader::update_zoom(double z) {
zoom = z;
update();
update();
}
double TimelineHeader::get_zoom() {
return zoom;
return zoom;
}
void TimelineHeader::delete_markers() {
@@ -295,33 +295,33 @@ void TimelineHeader::delete_markers() {
void TimelineHeader::paintEvent(QPaintEvent*) {
if (viewer->seq != NULL && zoom > 0) {
QPainter p(this);
QPainter p(this);
int yoff = (text_enabled) ? height()/2 : 0;
double interval = viewer->seq->frame_rate;
int textWidth = 0;
int textWidth = 0;
int lastTextBoundary = INT_MIN;
int i = 0;
int i = 0;
int lastLineX = INT_MIN;
int sublineCount = 1;
int sublineTest = qRound(interval*zoom);
int sublineInterval = 1;
int sublineCount = 1;
int sublineTest = qRound(interval*zoom);
int sublineInterval = 1;
while (sublineTest > SUBLINE_MIN_PADDING
&& sublineInterval >= 1) {
sublineCount *= 2;
sublineInterval = (interval/sublineCount);
sublineTest = qRound(sublineInterval*zoom);
}
sublineCount = qMin(sublineCount, qRound(interval));
&& sublineInterval >= 1) {
sublineCount *= 2;
sublineInterval = (interval/sublineCount);
sublineTest = qRound(sublineInterval*zoom);
}
sublineCount = qMin(sublineCount, qRound(interval));
while (true) {
long frame = qRound(interval*i);
while (true) {
long frame = qRound(interval*i);
int lineX = qRound(frame*zoom) - scroll;
int next_lineX = qRound(qRound(interval*(i+1))*zoom) - scroll;
if (lineX > width()) break;
if (lineX > width()) break;
if (next_lineX > 0 && lineX > lastLineX+LINE_MIN_PADDING) {
// draw text
if (text_enabled && lineX-textWidth > lastTextBoundary) {
@@ -348,19 +348,19 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
p.drawLine(sublineX, yoff, sublineX, yoff+(height()/4));
}
}
i++;
}
i++;
}
// draw in/out selection
int in_x;
// draw in/out selection
int in_x;
if (viewer->seq->using_workarea) {
in_x = getHeaderScreenPointFromFrame((resizing_workarea ? temp_workarea_in : viewer->seq->workarea_in));
int out_x = getHeaderScreenPointFromFrame((resizing_workarea ? temp_workarea_out : viewer->seq->workarea_out));
p.fillRect(QRect(in_x, 0, out_x-in_x, height()), QColor(0, 192, 255, 128));
p.setPen(Qt::white);
p.drawLine(in_x, 0, in_x, height());
p.drawLine(out_x, 0, out_x, height());
}
p.fillRect(QRect(in_x, 0, out_x-in_x, height()), QColor(0, 192, 255, 128));
p.setPen(Qt::white);
p.drawLine(in_x, 0, in_x, height());
p.drawLine(out_x, 0, out_x, height());
}
// draw markers
for (int i=0;i<viewer->seq->markers.size();i++) {
@@ -389,30 +389,28 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
p.drawPolygon(points, 5);
}
// draw playhead triangle
p.setRenderHint(QPainter::Antialiasing);
// draw playhead triangle
p.setRenderHint(QPainter::Antialiasing);
in_x = getHeaderScreenPointFromFrame(viewer->seq->playhead);
QPoint start(in_x, height()+2);
QPainterPath path;
path.moveTo(start + QPoint(1,0));
path.lineTo(in_x-PLAYHEAD_SIZE, yoff);
path.lineTo(in_x+PLAYHEAD_SIZE+1, yoff);
path.lineTo(start);
p.fillPath(path, Qt::red);
in_x = getHeaderScreenPointFromFrame(viewer->seq->playhead);
QPoint start(in_x, height()+2);
QPainterPath path;
path.moveTo(start + QPoint(1,0));
path.lineTo(in_x-PLAYHEAD_SIZE, yoff);
path.lineTo(in_x+PLAYHEAD_SIZE+1, yoff);
path.lineTo(start);
p.fillPath(path, Qt::red);
}
}
void TimelineHeader::show_context_menu(const QPoint &pos) {
QMenu contextMenu(tr("Context menu"), this);
QMenu menu(this);
QAction clear_in_out("Clear In/Out Points", this);
if (!viewer->seq->using_workarea) clear_in_out.setEnabled(false);
connect(&clear_in_out, SIGNAL(triggered()), mainWindow, SLOT(on_actionClear_In_Out_triggered()));
contextMenu.addAction(&clear_in_out);
contextMenu.exec(mapToGlobal(pos));
mainWindow->make_inout_menu(&menu);
menu.exec(mapToGlobal(pos));
}
void TimelineHeader::resized_scroll_listener(double d) {
update_zoom(zoom * d);
update_zoom(zoom * d);
}