merged with slight code cleanup

This commit is contained in:
itsmattkc
2019-01-12 13:55:53 +11:00
53 changed files with 659 additions and 484 deletions
+20 -17
View File
@@ -48,10 +48,10 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
QOpenGLWidget(parent),
default_fbo(nullptr),
waveform(false),
dragging(false),
selected_gizmo(nullptr),
waveform_zoom(1.0),
waveform_scroll(0)
waveform_scroll(0),
dragging(false),
selected_gizmo(nullptr)
{
setMouseTracking(true);
setFocusPolicy(Qt::ClickFocus);
@@ -87,14 +87,14 @@ void ViewerWidget::set_waveform_scroll(int s) {
void ViewerWidget::show_context_menu() {
QMenu menu(this);
QAction* save_frame_as_image = menu.addAction("Save Frame as Image...");
QAction* save_frame_as_image = menu.addAction(tr("Save Frame as Image..."));
connect(save_frame_as_image, SIGNAL(triggered(bool)), this, SLOT(save_frame()));
QAction* show_fullscreen_action = menu.addAction("Show Fullscreen");
QAction* show_fullscreen_action = menu.addAction(tr("Show Fullscreen"));
connect(show_fullscreen_action, SIGNAL(triggered()), this, SLOT(show_fullscreen()));
QMenu zoom_menu("Zoom");
QAction* fit_zoom = zoom_menu.addAction("Fit");
QMenu zoom_menu(tr("Zoom"));
QAction* fit_zoom = zoom_menu.addAction(tr("Fit"));
connect(fit_zoom, SIGNAL(triggered(bool)), this, SLOT(set_fit_zoom()));
zoom_menu.addAction("10%")->setData(0.1);
zoom_menu.addAction("25%")->setData(0.25);
@@ -104,13 +104,13 @@ void ViewerWidget::show_context_menu() {
zoom_menu.addAction("150%")->setData(1.5);
zoom_menu.addAction("200%")->setData(2.0);
zoom_menu.addAction("400%")->setData(4.0);
QAction* custom_zoom = zoom_menu.addAction("Custom");
QAction* custom_zoom = zoom_menu.addAction(tr("Custom"));
connect(custom_zoom, SIGNAL(triggered(bool)), this, SLOT(set_custom_zoom()));
connect(&zoom_menu, SIGNAL(triggered(QAction*)), this, SLOT(set_menu_zoom(QAction*)));
menu.addMenu(&zoom_menu);
if (!viewer->is_main_sequence()) {
menu.addAction("Close Media", viewer, SLOT(close_media()));
menu.addAction(tr("Close Media"), viewer, SLOT(close_media()));
}
menu.exec(QCursor::pos());
@@ -120,7 +120,7 @@ void ViewerWidget::save_frame() {
QFileDialog fd(this);
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setFileMode(QFileDialog::AnyFile);
fd.setWindowTitle("Save Frame");
fd.setWindowTitle(tr("Save Frame"));
fd.setNameFilter("Portable Network Graphic (*.png);;JPEG (*.jpg);;Windows Bitmap (*.bmp);;Portable Pixmap (*.ppm);;X11 Bitmap (*.xbm);;X11 Pixmap (*.xpm)");
if (fd.exec()) {
@@ -159,7 +159,10 @@ void ViewerWidget::set_fit_zoom() {
void ViewerWidget::set_custom_zoom() {
bool ok;
double d = QInputDialog::getDouble(this, "Viewer Zoom", "Set Custom Zoom Value:", container->zoom*100, 0, 2147483647, 2, &ok);
double d = QInputDialog::getDouble(this,
tr("Viewer Zoom"),
tr("Set Custom Zoom Value:"),
container->zoom*100, 0, 2147483647, 2, &ok);
if (ok) {
container->fit = false;
container->zoom = d*0.01;
@@ -205,7 +208,7 @@ void ViewerWidget::seek_from_click(int x) {
EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) {
if (gizmos != nullptr) {
double multiplier = (double) viewer->seq->width / (double) width();
double multiplier = double(viewer->seq->width) / double(width());
QPoint mouse_pos(qRound(x*multiplier), qRound(y*multiplier));
int dot_size = 2 * qRound(GIZMO_DOT_SIZE * multiplier);
int target_size = 2 * qRound(GIZMO_TARGET_SIZE * multiplier);
@@ -243,7 +246,7 @@ EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) {
void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) {
if (selected_gizmo != nullptr) {
double multiplier = (double) viewer->seq->width / (double) width();
double multiplier = double(viewer->seq->width) / double(width());
int x_movement = (event->pos().x() - drag_start_x)*multiplier;
int y_movement = (event->pos().y() - drag_start_y)*multiplier;
@@ -431,9 +434,9 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture
if (e->enable_coords) {
e->process_coords(timecode, coords, data);
}
if ((e->enable_shader && shaders_are_enabled) || e->enable_superimpose) {
if ((e->enable_shader && shaders_are_enabled) || e->enable_superimpose) {
e->startEffect();
if ((e->enable_shader && shaders_are_enabled) && e->is_glsl_linked()) {
if ((e->enable_shader && shaders_are_enabled) && e->is_glsl_linked()) {
e->process_shader(timecode, coords);
composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture, true);
fbo_switcher = !fbo_switcher;
@@ -635,8 +638,8 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
// set up autoscale
if (c->autoscale && (video_width != s->width && video_height != s->height)) {
float width_multiplier = (float) s->width / (float) video_width;
float height_multiplier = (float) s->height / (float) video_height;
float width_multiplier = float(s->width) / float(video_width);
float height_multiplier = float(s->height) / float(video_height);
float scale_multiplier = qMin(width_multiplier, height_multiplier);
glScalef(scale_multiplier, scale_multiplier, 1);
}