1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
#include "gallerywidget.h"
#include "ui_gallerywidget.h"
#include "configparams.h"
#include "logging.h"
#include "appglobal.h"
#include <QSplashScreen>
#include "dispatch/dispatcher.h"
#include <QFileInfo>
#include <QStatusBar>
#include "txwidget.h"
galleryWidget::galleryWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::galleryWidget)
{
ui->setupUi(this);
ui->tabWidget->setCurrentIndex(0);
ui->templateMatrix->setSortFlag(QDir::Name);
}
galleryWidget::~galleryWidget()
{
writeSettings();
delete ui;
}
void galleryWidget::init()
{
readSettings();
}
void galleryWidget::changedMatrix()
{
changedMatrix(imageViewer::RXSSTVTHUMB);
changedMatrix(imageViewer::RXDRMTHUMB);
changedMatrix(imageViewer::TXSSTVTHUMB);
changedMatrix(imageViewer::TXDRMTHUMB);
changedMatrix(imageViewer::TXSTOCKTHUMB);
changedMatrix(imageViewer::TEMPLATETHUMB);
}
void galleryWidget::slotDirChanged(QString dn)
{
if(dn==txStockImagesPath)
{
ui->txStockMatrix->changed();
}
if(dn==templatesPath)
{
ui->templateMatrix->changed();
txWidgetPtr->setupTemplatesComboBox();
}
}
void galleryWidget::changedMatrix(imageViewer::thumbType itype)
{
switch(itype)
{
case imageViewer::RXSSTVTHUMB:
ui->rxSSTVMatrix->init(galleryRows,galleryColumns,rxSSTVImagesPath,imageViewer::RXSSTVTHUMB);
break;
case imageViewer::RXDRMTHUMB:
ui->rxDRMMatrix->init(galleryRows,galleryColumns,rxDRMImagesPath,imageViewer::RXDRMTHUMB);
break;
case imageViewer::TXSSTVTHUMB:
ui->txSSTVMatrix->init(galleryRows,galleryColumns,txSSTVImagesPath,imageViewer::TXSSTVTHUMB);
break;
case imageViewer::TXDRMTHUMB:
ui->txDRMMatrix->init(galleryRows,galleryColumns,txDRMImagesPath,imageViewer::TXDRMTHUMB);
break;
case imageViewer::TXSTOCKTHUMB:
ui->txStockMatrix->init(galleryRows,galleryColumns,txStockImagesPath,imageViewer::TXSTOCKTHUMB);
break;
case imageViewer::TEMPLATETHUMB:
ui->templateMatrix->init(galleryRows,galleryColumns,templatesPath,imageViewer::TEMPLATETHUMB);
break;
default:
break;
}
}
/*!
reads the settings (saved images for tx,rx,templates)
*/
void galleryWidget::readSettings()
{
QSettings qSettings;
qSettings.beginGroup ("Gallery");
splashStr+=QString( "Loading RX images" ).rightJustified(25,' ')+"\n";
splashPtr->showMessage ( splashStr ,Qt::AlignLeft,Qt::white);
qApp->processEvents();
ui->rxSSTVMatrix->init(galleryRows,galleryColumns,rxSSTVImagesPath,imageViewer::RXSSTVTHUMB);
ui->rxDRMMatrix->init(galleryRows,galleryColumns,rxDRMImagesPath,imageViewer::RXDRMTHUMB);
splashStr+=QString( "Loading TX images" ).rightJustified(25,' ')+"\n";
splashPtr->showMessage ( splashStr ,Qt::AlignLeft,Qt::white);
qApp->processEvents();
ui->txSSTVMatrix->init(galleryRows,galleryColumns,txSSTVImagesPath,imageViewer::TXSSTVTHUMB);
ui->txDRMMatrix->init(galleryRows,galleryColumns,txDRMImagesPath,imageViewer::TXDRMTHUMB);
ui->txStockMatrix->init(galleryRows,galleryColumns,txStockImagesPath,imageViewer::TXSTOCKTHUMB);
splashStr+=QString( "Loading Templates" ).rightJustified(25,' ')+"\n";
splashPtr->showMessage ( splashStr ,Qt::AlignLeft,Qt::white);
ui->templateMatrix->init(galleryRows,galleryColumns,templatesPath,imageViewer::TEMPLATETHUMB);
}
/*!
writes the settings (saved images for tx,rx,templates)
*/
void galleryWidget::writeSettings()
{
QSettings qSettings;
qSettings.beginGroup ( "Gallery" );
qSettings.endGroup();
}
/*!
setup of the user interface
*/
/*!
closeEvent signals the dispatcher to initiate program exit.
*/
/*!
get the filename of a template
\param[in] tm index of template
\return QString containing filename, check with QString.isNull for validity
*/
QString galleryWidget::getTemplateFileName ( int tm )
{
int i;
QString str;
QStringList slTemp;
if(tm>=0)
{
for(i=0;i<ui->templateMatrix->getFileList().count();i++)
{
str=ui->templateMatrix->getFileList().at(i).absoluteFilePath();
slTemp.append(str);
}
slTemp.sort();
return slTemp.at(tm);
}
else return QString();
}
const QStringList &galleryWidget::getFilenames()
{
QString str;
sl.clear();
int i;
for(i=0;i<ui->templateMatrix->getFileList().count();i++)
{
str=getTemplateFileName (i);
QFileInfo fi(str);
sl.append(fi.baseName());
}
return sl;
}
/*!
loads an image in the rximages gallery in a new position
\param[in] fn the filename
*/
void galleryWidget::putRxImage ( QString fn )
{
if(transmissionModeIndex==TRXSSTV)
{
statusBarPtr->showMessage ( "Saved: "+fn );
ui->rxSSTVMatrix->changed();
}
else
{
statusBarPtr->showMessage ( "Saved: "+fn+QString(" (%1dB)").arg(lastAvgSNR,0,'f',0) );
ui->rxDRMMatrix->changed();
}
}
void galleryWidget::txImageChanged()
{
if(transmissionModeIndex==TRXSSTV)
{
ui->txSSTVMatrix->changed();
}
else
{
ui->txDRMMatrix->changed();
}
}
void galleryWidget::txStockImageChanged()
{
ui->txStockMatrix->changed();
}
/*!
loads an image in the rximages gallery in a new position
\return QString containing filename, check with QString.isEmpty for validity
*/
QString galleryWidget::getLastRxImage()
{
return ui->rxDRMMatrix->getLastFile();
}
|