Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic TX panel resize/align #12

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/mainwidgets/txwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ txWidget::txWidget(QWidget *parent) : QWidget(parent), ui(new Ui::txWidget)

connect(ui->sstvModeComboBox,SIGNAL(activated(int)),SLOT(slotModeChanged(int )));
connect(ui->sstvResizeComboBox,SIGNAL(activated(int)),SLOT(slotResizeChanged(int)));
connect(ui->alignImageButtonGroup,SIGNAL(buttonClicked(QAbstractButton*)),SLOT(slotAlignmentChange(QAbstractButton*)));

connect(ui->drmTxBandwidthComboBox,SIGNAL(activated(int)),SLOT(slotGetTXParams()));
connect(ui->drmTxInterleaveComboBox,SIGNAL(activated(int)),SLOT(slotGetTXParams()));
Expand Down Expand Up @@ -636,20 +637,47 @@ void txWidget::slotModeChanged(int m)

void txWidget::slotResizeChanged(int i)
{
QList<QAbstractButton*> buttons = ui->alignImageButtonGroup->buttons();
switch (i) {
case 0: // Stretch
for( int s=0; s<buttons.count(); ++s )
{
buttons[s]->setEnabled(false);
}
imageViewerPtr->setAspectMode(Qt::IgnoreAspectRatio);
break;
case 1: // Crop
for( int s=0; s<buttons.count(); ++s )
{
buttons[s]->setEnabled(true);
}
imageViewerPtr->setAspectMode(Qt::KeepAspectRatioByExpanding);
break;
case 2: // Fit
for( int s=0; s<buttons.count(); ++s )
{
buttons[s]->setEnabled(true);
}
imageViewerPtr->setAspectMode(Qt::KeepAspectRatio);
break;
}
applyTemplate();
}

void txWidget::slotAlignmentChange(QAbstractButton* button) {
int i = 4;
if (button->objectName() == "alignButtonTopCenter") {
i = 1;
}else if (button->objectName() == "alignButtonCenterLeft") {
i = 3;
}else if (button->objectName() == "alignButtonCenterRight") {
i = 5;
}else if (button->objectName() == "alignButtonBottomCenter") {
i = 7;
}
imageViewerPtr->setImageAlignment(i);
applyTemplate();
}



Expand Down
1 change: 1 addition & 0 deletions src/mainwidgets/txwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public slots:

void slotModeChanged(int);
void slotResizeChanged(int);
void slotAlignmentChange(QAbstractButton*);
void slotBinary();
void slotHybridToggled();
void slotNotifyTimeout();
Expand Down
121 changes: 120 additions & 1 deletion src/mainwidgets/txwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>19</height>
<height>10</height>
</size>
</property>
</spacer>
Expand All @@ -889,6 +889,122 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Image Alignment</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="alignmentGridLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<item row="3" column="0">
<widget class="QRadioButton" name="alignButtonCenterLeft">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<attribute name="buttonGroup">
<string notr="true">alignImageButtonGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="alignButtonTopCenter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<attribute name="buttonGroup">
<string notr="true">alignImageButtonGroup</string>
</attribute>
</widget>
</item>
<item row="3" column="2" alignment="Qt::AlignRight">
<widget class="QRadioButton" name="alignButtonCenterRight">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<attribute name="buttonGroup">
<string notr="true">alignImageButtonGroup</string>
</attribute>
</widget>
</item>
<item row="3" column="1" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="alignButtonCenter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">alignImageButtonGroup</string>
</attribute>
</widget>
</item>
<item row="4" column="1" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="alignButtonBottomCenter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<attribute name="buttonGroup">
<string notr="true">alignImageButtonGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="drmTXTab">
Expand Down Expand Up @@ -1640,4 +1756,7 @@
<include location="../qsstv.qrc"/>
</resources>
<connections/>
<buttongroups>
<buttongroup name="alignImageButtonGroup"/>
</buttongroups>
</ui>
76 changes: 72 additions & 4 deletions src/widgets/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,11 @@ void imageViewer::setAspectMode(Qt::AspectRatioMode mode)
aspectRatioMode = mode;
}

void imageViewer::setImageAlignment(int align)
{
imageAlignment = align;
}

int imageViewer::applyTemplate()
{
// qDebug() << "applyTemplate";
Expand Down Expand Up @@ -969,10 +974,41 @@ int imageViewer::applyTemplate()
Qt::SmoothTransformation
)
);
int locX = (scaledImage.width()-tWidth)/2;
int locY = (scaledImage.height()-tHeight)/2;
switch (imageAlignment) {
case 0:
locX = 0;
locY = 0;
break;
case 2:
locX = (scaledImage.width()-tWidth);
case 1:
locY = 0;
break;
case 3:
locX = 0;
break;
case 5:
locX = (scaledImage.width()-tWidth);
break;
case 6:
locX = 0;
locY = (scaledImage.height()-tHeight);
break;
case 8:
locX = (scaledImage.width()-tWidth);
case 7:
locY = (scaledImage.height()-tHeight);
break;
default:
break;
}

// Crop to intended dimensions at the centre of the image
displayedImage = QImage(scaledImage
.copy((scaledImage.width()-tWidth)/2,
(scaledImage.height()-tHeight)/2,
.copy(locX,
locY,
tWidth,
tHeight
)
Expand Down Expand Up @@ -1024,10 +1060,42 @@ int imageViewer::applyTemplate()
Qt::SmoothTransformation
)
);

int locX = (scaledImage.width()-tWidth)/2;
int locY = (scaledImage.height()-tHeight)/2;
switch (imageAlignment) {
case 0:
locX = 0;
locY = 0;
break;
case 2:
locX = (scaledImage.width()-tWidth);
case 1:
locY = 0;
break;
case 3:
locX = 0;
break;
case 5:
locX = (scaledImage.width()-tWidth);
break;
case 6:
locX = 0;
locY = (scaledImage.height()-tHeight);
break;
case 8:
locX = (scaledImage.width()-tWidth);
case 7:
locY = (scaledImage.height()-tHeight);
break;
default:
break;
}

scaledImage=scaledImage.convertToFormat(QImage::Format_ARGB32);
overlayedImage= QImage(scaledImage
.copy((scaledImage.width()-tWidth)/2,
(scaledImage.height()-tHeight)/2,
.copy(locX,
locY,
tWidth,
tHeight
)
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/imageviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class imageViewer : public QLabel
// int calcSize(int &sizeRatio);
uint setSize(int tcommpressSize,bool usesCompression);
void setAspectMode(Qt::AspectRatioMode mode);
void setImageAlignment(int align);
int getFileSize(){return fileSize;}
QString toCall;
QString toOperator;
Expand Down Expand Up @@ -169,6 +170,7 @@ private slots:
bool useCompression;
QString templateFileName;
Qt::AspectRatioMode aspectRatioMode;
int imageAlignment;
bool useTemplate;
int targetWidth;
int targetHeight;
Expand Down