Skip to content

Commit

Permalink
Renamed class to follow convention. Clean up dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlamhauge committed Mar 13, 2024
1 parent d49ba36 commit 09dd83f
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 86 deletions.
1 change: 1 addition & 0 deletions app/src/actioncommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ GNU General Public License for more details.
#include "vectorimage.h"
#include "soundclip.h"
#include "camera.h"
#include "previewframesdialog.h"

#include "importimageseqdialog.h"
#include "importpositiondialog.h"
Expand Down
14 changes: 14 additions & 0 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GNU General Public License for more details.
*/

#include "mainwindow2.h"
#include "previewframesdialog.h"
#include "ui_mainwindow2.h"

// Qt headers
Expand Down Expand Up @@ -323,6 +324,7 @@ void MainWindow2::createMenus()
connect(ui->actionHorizontal_Flip, &QAction::triggered, mEditor->view(), &ViewManager::flipHorizontal);
connect(ui->actionVertical_Flip, &QAction::triggered, mEditor->view(), &ViewManager::flipVertical);
connect(mEditor->view(), &ViewManager::viewFlipped, this, &MainWindow2::viewFlipped);
connect(ui->actionPreview_frames, &QAction::triggered, this , &MainWindow2::previewFrames);

PreferenceManager* prefs = mEditor->preference();
connect(ui->actionStatusBar, &QAction::triggered, ui->statusBar, &QStatusBar::setVisible);
Expand Down Expand Up @@ -959,6 +961,18 @@ void MainWindow2::importAnimatedImage()
mSuppressAutoSaveDialog = false;
}

void MainWindow2::previewFrames()
{
int currFrame = mEditor->currentFrame();
auto layer = mEditor->layers()->currentLayer();
if (layer->type() == Layer::SOUND || layer->type() == Layer::CAMERA)
return;

int maxFrame = layer->getMaxKeyFramePosition();
PreviewFramesDialog* preview = new PreviewFramesDialog(maxFrame, currFrame);
preview->open();
}

void MainWindow2::lockWidgets(bool shouldLock)
{
QDockWidget::DockWidgetFeatures feat = shouldLock
Expand Down
4 changes: 4 additions & 0 deletions app/src/mainwindow2.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class BackupElement;
class LayerOpacityDialog;
class PegBarAlignmentDialog;
class RepositionFramesDialog;
class PreviewFramesDialog;
class StatusBar;
enum class SETTING;

Expand Down Expand Up @@ -92,6 +93,8 @@ public slots:
void importMovieVideo();
void importAnimatedImage();

void previewFrames();

void lockWidgets(bool shouldLock);

void setOpacity(int opacity);
Expand Down Expand Up @@ -173,6 +176,7 @@ private slots:
PegBarAlignmentDialog* mPegAlign = nullptr;
RepositionFramesDialog* mReposDialog = nullptr;
LayerOpacityDialog* mLayerOpacityDialog = nullptr;
PreviewFramesDialog* mPreviewFramesDialog = nullptr;

void createToolbars();
private:
Expand Down
17 changes: 10 additions & 7 deletions app/src/previewframesdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#include "previewframesdialog.h"
#include "ui_previewframesdialog.h"

previewFramesDialog::previewFramesDialog(int maxFrame, int currentFrame) :
PreviewFramesDialog::PreviewFramesDialog(int maxFrame, int currentFrame) :
QDialog(),
ui(new Ui::previewFramesDialog)
ui(new Ui::PreviewFramesDialog)
{
ui->setupUi(this);
ui->frameSpinBox->setMinimum(1);
ui->frameSpinBox->setMaximum(maxFrame);
ui->frameSpinBox->setValue(currentFrame);
connect(ui->frameSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &previewFramesDialog::frameChanged);

setCurrentFrame(currentFrame);
setMaxFrame(maxFrame);
ui->labMaxNum->setText(QString::number(maxFrame));
connect(ui->frameSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &PreviewFramesDialog::frameChanged);
}

previewFramesDialog::~previewFramesDialog()
PreviewFramesDialog::~PreviewFramesDialog()
{
delete ui;
}


void previewFramesDialog::frameChanged(int frame)
void PreviewFramesDialog::frameChanged(int frame)
{

setCurrentFrame(frame);
ui->labFrame->setText(QString::number(frame));
}
16 changes: 11 additions & 5 deletions app/src/previewframesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,33 @@
#include <QDialog>

namespace Ui {
class previewFramesDialog;
class PreviewFramesDialog;
}

class previewFramesDialog : public QDialog
class PreviewFramesDialog : public QDialog
{
Q_OBJECT

public:
explicit previewFramesDialog(int maxFrame, int currentFrame);
~previewFramesDialog();
explicit PreviewFramesDialog(int maxFrame, int currentFrame);
~PreviewFramesDialog();

void gotoFrame();
void frameChanged(int frame);

void setMaxFrame(int max) { mMaxFrame = max; }
int getMaxFrame() { return mMaxFrame; }
void setCurrentFrame(int curr) { mCurrentFrame = curr; }
int getCurrentFrame() { return mCurrentFrame; }

signals:
void currentFrameChanged(int);

private:
int mMinFrame = 1;
int mMaxFrame = 100;
Ui::previewFramesDialog *ui;
int mCurrentFrame = 1;
Ui::PreviewFramesDialog *ui;
};

#endif // PREVIEWFRAMESDIALOG_H
130 changes: 56 additions & 74 deletions app/ui/previewframesdialog.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>previewFramesDialog</class>
<widget class="QDialog" name="previewFramesDialog">
<class>PreviewFramesDialog</class>
<widget class="QDialog" name="PreviewFramesDialog">
<property name="geometry">
<rect>
<x>0</x>
Expand All @@ -13,13 +13,13 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>10</y>
<width>1081</width>
<height>701</height>
<height>691</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
Expand All @@ -28,76 +28,58 @@
<property name="title">
<string>Preview frames</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>14</x>
<y>30</y>
<width>101</width>
<height>661</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labFrame">
<property name="text">
<string>Frame:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="frameSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labMax">
<property name="text">
<string>Max: 100</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPrevious">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnNext">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labFrame">
<property name="text">
<string>Frame:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="frameSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labMax">
<property name="text">
<string>Maximum:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labMaxNum">
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>529</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
Expand Down

0 comments on commit 09dd83f

Please sign in to comment.