Initial import of CVS-v2_8_branch

This commit is contained in:
Fred Gleason
2014-08-12 15:13:02 -04:00
commit afd67c7af8
1508 changed files with 405304 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
## automake.am
##
## Automake.am for rivendell/utils/rdsoftkeys
##
## (C) Copyright 2002-2006 Fred Gleason <fredg@paravelsystems.com>
##
## $Id: Makefile.am,v 1.8.8.2 2012/12/03 16:53:46 cvs Exp $
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
## published by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@
INCLUDES = -I$(top_srcdir)/lib
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
moc_%.cpp: %.h
$(MOC) $< -o $@
bin_PROGRAMS = rdsoftkeys
dist_rdsoftkeys_SOURCES = rdsoftkeys.cpp rdsoftkeys.h
nodist_rdsoftkeys_SOURCES = moc_rdsoftkeys.cpp
rdsoftkeys_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
EXTRA_DIST = rdsoftkeys.pro
CLEANFILES = *~\
*.exe\
*.idb\
*ilk\
*.obj\
*.pdb\
*.qm\
moc_*
MAINTAINERCLEANFILES = *~\
Makefile.in\
moc_*

View File

@@ -0,0 +1,326 @@
// rdsoftkeys.cpp
//
// A utility for sending RML Commands
//
// (C) Copyright 2002-2006 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: rdsoftkeys.cpp,v 1.7.8.2 2014/01/08 02:08:41 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdlib.h>
#ifndef WIN32
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#endif
#include <qtranslator.h>
#include <qapplication.h>
#include <qwindowsstyle.h>
#include <qtextcodec.h>
#include <qsignalmapper.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qsettings.h>
#include <rdprofile.h>
#include <rd.h>
#include <rdcmd_switch.h>
#include <rdconfig.h>
#include <rdsoftkeys.h>
//
// Icons
//
#include "../icons/rivendell-22x22.xpm"
MainWidget::MainWidget(QWidget *parent,const char *name)
: QMainWindow(parent,name)
{
key_ysize=70;
//
// Read Command Options
//
RDConfig *config=new RDConfig();
QString map_filename=config->filename();
delete config;
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdsoftkeys",RDSOFTKEYS_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--map-file") {
map_filename=cmd->value(i);
}
}
delete cmd;
//
// Generate Font
//
QFont font("Helvetica",12,QFont::Bold);
font.setPixelSize(12);
QFont label_font("Helvetica",18,QFont::Bold);
label_font.setPixelSize(18);
setCaption(QString("RDSoftKeys")+" v"+VERSION);
//
// Create And Set Icon
//
key_icon_map=new QPixmap(rivendell_xpm);
setIcon(*key_icon_map);
//
// RML Send Socket
//
key_socket=new QSocketDevice(QSocketDevice::Datagram);
//
// Create Buttons
//
QPushButton *button;
QString rmlcmd;
int n=0;
QString color_name;
QColor color;
QString str1;
QString str2;
int h=0;
int s=0;
int v=0;
QSignalMapper *mapper=new QSignalMapper(this);
connect(mapper,SIGNAL(mapped(int)),this,SLOT(buttonData(int)));
RDProfile *profile=new RDProfile();
profile->setSource(map_filename);
key_columns=
profile->intValue("SoftKeys","Columns",RDSOFTKEYS_DEFAULT_COLUMNS);
unsigned col=0;
unsigned row=0;
while(!(rmlcmd=profile->stringValue("SoftKeys",QString().
sprintf("Command%d",n+1),"")).isEmpty()) {
for(unsigned i=0;i<rmlcmd.length();i++) {
if(rmlcmd.at(i)==':') {
key_macros.push_back(rmlcmd.right(rmlcmd.length()-(i+1)));
key_addrs.push_back(rmlcmd.left(i));
button=new QPushButton(this);
button->setGeometry(10+90*col,10+60*row,80,50);
button->
setText(WrapText(button,profile->
stringValue("SoftKeys",QString().
sprintf("Legend%d",n+1),
QString().sprintf("Button %d",n+1))));
if(!(color_name=profile->stringValue("SoftKeys",
QString().sprintf("Color%d",n+1),"")).
isEmpty()) {
color=QColor(color_name);
QPalette pal=QPalette(color,backgroundColor());
color.getHsv(&h,&s,&v);
if((h>180)&&(h<300)) {
v=255;
}
else {
if(v<168) {
v=255;
}
else {
v=0;
}
}
s=0;
color.setHsv(h,s,v);
pal.setColor(QPalette::Active,QColorGroup::ButtonText,color);
pal.setColor(QPalette::Inactive,QColorGroup::ButtonText,color);
button->setPalette(pal);
}
mapper->setMapping(button,n);
connect(button,SIGNAL(clicked()),mapper,SLOT(map()));
if(++col==key_columns) {
col=0;
row++;
key_ysize+=60;
}
}
}
n++;
}
if((key_macros.size()%key_columns)==0) {
key_ysize-=60;
}
//
// Set Window Size
//
setMinimumWidth(sizeHint().width());
setMaximumWidth(sizeHint().width());
setMinimumHeight(sizeHint().height());
setMaximumHeight(sizeHint().height());
}
QSize MainWidget::sizeHint() const
{
unsigned x=0;
unsigned y=0;
if(key_macros.size()>=key_columns) {
x=10+90*key_columns;
y=10+60*key_macros.size()/key_columns;
}
else {
x=10+90*key_macros.size();
y=70;
}
return QSize(x,key_ysize);
}
QSizePolicy MainWidget::sizePolicy() const
{
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
}
void MainWidget::buttonData(int id)
{
QHostAddress addr;
#ifndef WIN32
struct hostent *hostent=gethostbyname(key_addrs[id]);
if(hostent==NULL) {
QMessageBox::warning(this,tr("RDSoftKeys"),hstrerror(h_errno));
return;
}
if(hostent->h_addr_list!=NULL) {
char str[INET_ADDRSTRLEN];
inet_ntop(hostent->h_addrtype,*hostent->h_addr_list,str,sizeof(str));
addr.setAddress(str);
}
else {
addr.setAddress(key_addrs[id]);
}
#else
addr.setAddress(key_addrs[id]);
#endif // WIN32
key_socket->writeBlock(key_macros[id],key_macros[id].length(),
addr,(Q_UINT16)RD_RML_NOECHO_PORT);
}
void MainWidget::closeEvent(QCloseEvent *e)
{
exit(0);
}
QString MainWidget::WrapText(QWidget *w,const QString &text)
{
QFontMetrics fm(w->font());
QString str;
QString residue = text;
bool space_found=false;
int l;
int lines=0;
if(!text.isEmpty()) {
while(!residue.isEmpty()) {
space_found=false;
for(int i=(int)residue.length();i>=0;i--) {
if((i==((int)residue.length()))||(residue.at(i).isSpace())) {
if(fm.boundingRect(residue.left(i)).width()<=w->width()-6) {
space_found=true;
if(!str.isEmpty()) {
str+="\n";
if(++lines==3) {
return str;
}
}
str+=residue.left(i);
if(i==(int)residue.length()) {
return str;
}
residue=residue.right(residue.length()-i-1);
}
}
}
if(!space_found) {
l=residue.length();
for(int i=l;i>=0;i--) {
if(fm.boundingRect(residue.left(i)).width()<=(w->width()-6)) {
if(!str.isEmpty()) {
str+="\n";
if(++lines==3) {
return str;
}
}
str+=residue.left(i);
if(i==(int)residue.length()) {
return str;
}
residue=residue.right(residue.length()-i-1);
}
}
}
}
}
return text;
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv);
QApplication::setStyle(new QWindowsStyle);
//
// Load Translations
//
QString tr_path;
QString qt_path;
#ifdef WIN32
QSettings settings;
settings.insertSearchPath(QSettings::Windows,"/SalemRadioLabs");
tr_path=QString().sprintf("%s\\",
(const char *)settings.
readEntry("/Rivendell/InstallDir"));
qt_path=tr_path;
#else
tr_path=QString(PREFIX)+QString("/share/srlabs/");
qt_path=QString(QTDIR)+QString("/translation/");
#endif // WIN32
QTranslator qt(0);
qt.load(qt_path+QString("qt_")+QTextCodec::locale(),".");
a.installTranslator(&qt);
QTranslator libradio(0);
libradio.load(tr_path+QString("libradio_")+QTextCodec::locale(),".");
a.installTranslator(&libradio);
QTranslator tests(0);
tests.load(tr_path+QString("rdsoftkeys_")+QTextCodec::locale(),".");
a.installTranslator(&tests);
//
// Start Event Loop
//
MainWidget *w=new MainWidget(NULL,"main");
a.setMainWidget(w);
w->setGeometry(w->geometry().x(),w->geometry().y(),w->sizeHint().width(),w->sizeHint().height());
w->show();
return a.exec();
}

View File

@@ -0,0 +1,65 @@
// rdsoftkeys.h
//
// A utility for sending RML Commands
//
// (C) Copyright 2002-2006 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: rdsoftkeys.h,v 1.5 2010/07/29 19:32:40 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDSOFTKEYS_H
#define RDSOFTKEYS_H
#include <vector>
#include <qmainwindow.h>
#include <qsize.h>
#include <qsizepolicy.h>
#include <qpixmap.h>
#include <qsocketdevice.h>
#include <rdmacro.h>
//
// Settings
//
#define RDSOFTKEYS_USAGE "[--map-file=<filename>]\n\nWhere <filename> is the name of the file load soft key definitions from.\nThe default value is master Rivendell configuration file.\n"
#define RDSOFTKEYS_DEFAULT_COLUMNS 1
class MainWidget : public QMainWindow
{
Q_OBJECT
public:
MainWidget(QWidget *parent=0,const char *name=0);
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
private slots:
void buttonData(int id);
void closeEvent(QCloseEvent *e);
private:
QString WrapText(QWidget *w,const QString &text);
QPixmap *key_icon_map;
QSocketDevice *key_socket;
unsigned key_columns;
unsigned key_ysize;
std::vector<QString> key_macros;
std::vector<QString> key_addrs;
};
#endif // RDSOFTKEYS_H

View File

@@ -0,0 +1,44 @@
# rdsoftkeys.pro
#
# The utils/rdsoftkeys QMake project file for Rivendell
#
# (C) Copyright 2003-2006 Fred Gleason <fredg@paravelsystems.com>
#
# $Id: rdsoftkeys.pro,v 1.3.18.1 2013/01/07 15:35:08 cvs Exp $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
TEMPLATE = app
TARGET = rdsoftkeys
win32 {
DEFINES += WIN32
DEFINES += VERSION=\"$$[VERSION]\"
DEFINES += PACKAGE=\"rivendell\"
DEFINES += PACKAGE_VERSION=\"$$[VERSION]\"
DEFINES += PACKAGE_NAME=\"rivendell\"
DEFINES += PACKAGE_BUGREPORT=\"fredg@paravelsystems.com\"
}
SOURCES += rdsoftkeys.cpp
HEADERS += rdsoftkeys.h
RES_FILE += ..\..\icons\rivendell.res
INCLUDEPATH += ..\..\..\libradio\radio ..\..\lib
LIBS = -lqui -L..\..\..\libradio\radio -lradio -L..\..\lib -llib
CONFIG += qt