mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 00:53:53 +02:00
Initial import of CVS-v2_8_branch
This commit is contained in:
75
rdmonitor/Makefile.am
Normal file
75
rdmonitor/Makefile.am
Normal file
@@ -0,0 +1,75 @@
|
||||
## automake.am
|
||||
##
|
||||
## Automake.am for rivendell/rdmonitor
|
||||
##
|
||||
## (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
|
||||
##
|
||||
## $Id: Makefile.am,v 1.1.2.4 2013/11/08 03:57:14 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 $@
|
||||
|
||||
# I18N Stuff
|
||||
install-exec-local:
|
||||
mkdir -p $(DESTDIR)$(prefix)/share/rivendell
|
||||
cp rdmonitor_*.qm $(DESTDIR)$(prefix)/share/rivendell
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(prefix)/share/rivendell/rdmonitor_*.qm
|
||||
|
||||
all:
|
||||
@QT_BIN@/lupdate rdmonitor.pro
|
||||
@QT_BIN@/lrelease rdmonitor.pro
|
||||
|
||||
bin_PROGRAMS = rdmonitor
|
||||
|
||||
dist_rdmonitor_SOURCES = positiondialog.cpp positiondialog.h\
|
||||
rdmonitor.cpp rdmonitor.h\
|
||||
status_tip.cpp status_tip.h
|
||||
|
||||
nodist_rdmonitor_SOURCES = moc_positiondialog.cpp\
|
||||
moc_rdmonitor.cpp
|
||||
|
||||
rdmonitor_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
|
||||
|
||||
EXTRA_DIST = rdmonitor.pro\
|
||||
rdmonitor_cs.ts\
|
||||
rdmonitor_de.ts\
|
||||
rdmonitor_es.ts\
|
||||
rdmonitor_fr.ts\
|
||||
rdmonitor_nb.ts\
|
||||
rdmonitor_nn.ts\
|
||||
rdmonitor_pt_BR.ts
|
||||
|
||||
CLEANFILES = *~\
|
||||
*.qm\
|
||||
moc_*
|
||||
|
||||
MAINTAINERCLEANFILES = *~\
|
||||
*.tar.gz\
|
||||
aclocal.m4\
|
||||
configure\
|
||||
Makefile.in\
|
||||
moc_*
|
176
rdmonitor/positiondialog.cpp
Normal file
176
rdmonitor/positiondialog.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
// positiondialog.cpp
|
||||
//
|
||||
// Dialog to set RDMonitor screen position.
|
||||
//
|
||||
// (C) Copyright 2013 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: positiondialog.cpp,v 1.1.2.2 2013/11/11 20:34:27 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 "positiondialog.h"
|
||||
|
||||
PositionDialog::PositionDialog(QDesktopWidget *dw,RDMonitorConfig *config,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
pos_desktop_widget=dw;
|
||||
pos_config=config;
|
||||
|
||||
setCaption("RDMonitor");
|
||||
|
||||
//
|
||||
// Fonts
|
||||
//
|
||||
QFont button_font("helvetica",12,QFont::Bold);
|
||||
button_font.setPixelSize(12);
|
||||
|
||||
QFont list_font("helvetica",12,QFont::Normal);
|
||||
list_font.setPixelSize(12);
|
||||
|
||||
//
|
||||
// Screen Number
|
||||
//
|
||||
pos_screen_number_box=new QComboBox(this);
|
||||
pos_screen_number_box->setFont(list_font);
|
||||
pos_screen_number_label=
|
||||
new QLabel(pos_screen_number_box,tr("Screen")+":",this);
|
||||
pos_screen_number_label->setFont(button_font);
|
||||
pos_screen_number_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
|
||||
//
|
||||
// Position
|
||||
//
|
||||
pos_position_box=new QComboBox(this);
|
||||
pos_position_box->setFont(list_font);
|
||||
pos_position_box->setFont(list_font);
|
||||
pos_position_label=
|
||||
new QLabel(pos_position_box,tr("Position")+":",this);
|
||||
pos_position_label->setFont(button_font);
|
||||
pos_position_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
for(int i=0;i<RDMonitorConfig::LastPosition;i++) {
|
||||
pos_position_box->
|
||||
insertItem(RDMonitorConfig::positionText((RDMonitorConfig::Position)i));
|
||||
}
|
||||
|
||||
//
|
||||
// X Offset
|
||||
//
|
||||
pos_x_offset_spin=new QSpinBox(this);
|
||||
pos_x_offset_spin->setFont(list_font);
|
||||
pos_x_offset_spin->setRange(0,99);
|
||||
pos_x_offset_label=new QLabel(pos_x_offset_spin,tr("X Offset")+":",this);
|
||||
pos_x_offset_label->setFont(button_font);
|
||||
pos_x_offset_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
|
||||
//
|
||||
// Y Offset
|
||||
//
|
||||
pos_y_offset_spin=new QSpinBox(this);
|
||||
pos_y_offset_spin->setFont(list_font);
|
||||
pos_y_offset_spin->setRange(0,99);
|
||||
pos_y_offset_label=new QLabel(pos_y_offset_spin,tr("Y Offset")+":",this);
|
||||
pos_y_offset_label->setFont(button_font);
|
||||
pos_y_offset_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
|
||||
//
|
||||
// OK Button
|
||||
//
|
||||
pos_ok_button=new QPushButton(tr("OK"),this);
|
||||
pos_ok_button->setFont(button_font);
|
||||
connect(pos_ok_button,SIGNAL(clicked()),this,SLOT(okData()));
|
||||
|
||||
//
|
||||
// Cancel Button
|
||||
//
|
||||
pos_cancel_button=new QPushButton(tr("Cancel"),this);
|
||||
pos_cancel_button->setFont(button_font);
|
||||
connect(pos_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
|
||||
|
||||
setMaximumSize(sizeHint());
|
||||
setMinimumSize(sizeHint());
|
||||
}
|
||||
|
||||
|
||||
QSize PositionDialog::sizeHint() const
|
||||
{
|
||||
return QSize(240,170);
|
||||
}
|
||||
|
||||
|
||||
QSizePolicy PositionDialog::sizePolicy() const
|
||||
{
|
||||
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
|
||||
int PositionDialog::exec()
|
||||
{
|
||||
pos_screen_number_box->clear();
|
||||
for(int i=0;i<pos_desktop_widget->numScreens();i++) {
|
||||
pos_screen_number_box->insertItem(QString().sprintf("%d",i));
|
||||
if(i==pos_config->screenNumber()) {
|
||||
pos_screen_number_box->setCurrentItem(i);
|
||||
}
|
||||
}
|
||||
pos_position_box->setCurrentItem((int)pos_config->position());
|
||||
pos_x_offset_spin->setValue(pos_config->xOffset());
|
||||
pos_y_offset_spin->setValue(pos_config->yOffset());
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
|
||||
void PositionDialog::okData()
|
||||
{
|
||||
pos_config->setScreenNumber(pos_screen_number_box->currentItem());
|
||||
pos_config->
|
||||
setPosition((RDMonitorConfig::Position)pos_position_box->currentItem());
|
||||
pos_config->setXOffset(pos_x_offset_spin->value());
|
||||
pos_config->setYOffset(pos_y_offset_spin->value());
|
||||
|
||||
done(0);
|
||||
}
|
||||
|
||||
|
||||
void PositionDialog::cancelData()
|
||||
{
|
||||
done(-1);
|
||||
}
|
||||
|
||||
|
||||
void PositionDialog::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
pos_screen_number_label->setGeometry(10,10,65,20);
|
||||
pos_screen_number_box->setGeometry(80,10,70,20);
|
||||
|
||||
pos_position_label->setGeometry(10,32,65,20);
|
||||
pos_position_box->setGeometry(80,32,150,20);
|
||||
|
||||
pos_x_offset_label->setGeometry(10,54,65,20);
|
||||
pos_x_offset_spin->setGeometry(80,54,40,20);
|
||||
|
||||
pos_y_offset_label->setGeometry(10,76,65,20);
|
||||
pos_y_offset_spin->setGeometry(80,76,40,20);
|
||||
|
||||
pos_ok_button->setGeometry(size().width()-180,size().height()-60,80,50);
|
||||
pos_cancel_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
||||
}
|
||||
|
||||
|
||||
void PositionDialog::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
cancelData();
|
||||
}
|
68
rdmonitor/positiondialog.h
Normal file
68
rdmonitor/positiondialog.h
Normal file
@@ -0,0 +1,68 @@
|
||||
// positiondialog.h
|
||||
//
|
||||
// Dialog to set RDMonitor screen position.
|
||||
//
|
||||
// (C) Copyright 2013 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: positiondialog.h,v 1.1.2.1 2013/11/08 03:57:15 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 POSITIONDIALOG_H
|
||||
#define POSITIONDIALOG_H
|
||||
|
||||
#include <qcombobox.h>
|
||||
#include <qdesktopwidget.h>
|
||||
#include <qdialog.h>
|
||||
#include <qlabel.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qspinbox.h>
|
||||
|
||||
#include <rdmonitor_config.h>
|
||||
|
||||
class PositionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PositionDialog(QDesktopWidget *dw,RDMonitorConfig *config,QWidget *parent=0);
|
||||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
|
||||
public slots:
|
||||
int exec();
|
||||
|
||||
private slots:
|
||||
void okData();
|
||||
void cancelData();
|
||||
|
||||
private:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void closeEvent(QCloseEvent *e);
|
||||
QLabel *pos_screen_number_label;
|
||||
QComboBox *pos_screen_number_box;
|
||||
QLabel *pos_position_label;
|
||||
QComboBox *pos_position_box;
|
||||
QLabel *pos_x_offset_label;
|
||||
QSpinBox *pos_x_offset_spin;
|
||||
QLabel *pos_y_offset_label;
|
||||
QSpinBox *pos_y_offset_spin;
|
||||
QPushButton *pos_ok_button;
|
||||
QPushButton *pos_cancel_button;
|
||||
QDesktopWidget *pos_desktop_widget;
|
||||
RDMonitorConfig *pos_config;
|
||||
};
|
||||
|
||||
|
||||
#endif // POSITIONDIALOG_H
|
410
rdmonitor/rdmonitor.cpp
Normal file
410
rdmonitor/rdmonitor.cpp
Normal file
@@ -0,0 +1,410 @@
|
||||
// rdmonitor.cpp
|
||||
//
|
||||
// System Monitor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: rdmonitor.cpp,v 1.1.2.13 2014/02/10 20:54:14 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 <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qpainter.h>
|
||||
#include <qsqldatabase.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlabel.h>
|
||||
#include <qtextcodec.h>
|
||||
#include <qtranslator.h>
|
||||
#include <qpainter.h>
|
||||
#include <qprocess.h>
|
||||
#include <qdir.h>
|
||||
#include <qsignalmapper.h>
|
||||
#include <qsqldatabase.h>
|
||||
|
||||
#include <dbversion.h>
|
||||
#include <rd.h>
|
||||
#include <rdcheck_daemons.h>
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdaudioinfo.h>
|
||||
#include <rdstation.h>
|
||||
#include <rdcut.h>
|
||||
#include <rdstatus.h>
|
||||
#include <rdmonitor_config.h>
|
||||
|
||||
#include <rdmonitor.h>
|
||||
|
||||
//
|
||||
// Icons
|
||||
//
|
||||
#include "../icons/rivendell-22x22.xpm"
|
||||
#include "../icons/greenball.xpm"
|
||||
#include "../icons/redball.xpm"
|
||||
|
||||
void SigHandler(int signo)
|
||||
{
|
||||
switch(signo) {
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MainWidget::MainWidget(QWidget *parent,const char *name)
|
||||
:QWidget(parent,name,Qt::WStyle_Customize|Qt::WStyle_NoBorder|Qt::WStyle_StaysOnTop|WX11BypassWM)
|
||||
{
|
||||
QString str;
|
||||
mon_dialog_x=0;
|
||||
mon_dialog_y=0;
|
||||
mon_rdselect_x=0;
|
||||
mon_rdselect_y=0;
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdmonitor","\n");
|
||||
delete cmd;
|
||||
|
||||
//
|
||||
// Hide at startup
|
||||
//
|
||||
setGeometry(0,0,0,0);
|
||||
|
||||
//
|
||||
// Generate Fonts
|
||||
//
|
||||
QFont font=QFont("Helvetica",12,QFont::Bold);
|
||||
font.setPixelSize(12);
|
||||
mon_metrics=new QFontMetrics(font);
|
||||
|
||||
//
|
||||
// Create And Set Icon
|
||||
//
|
||||
setIcon(QPixmap(rivendell_xpm));
|
||||
|
||||
//
|
||||
// Dialogs
|
||||
//
|
||||
mon_rdconfig=new RDConfig();
|
||||
mon_rdconfig->load();
|
||||
mon_desktop_widget=new QDesktopWidget();
|
||||
mon_config=new RDMonitorConfig();
|
||||
mon_config->load();
|
||||
mon_position_dialog=new PositionDialog(mon_desktop_widget,mon_config,this);
|
||||
mon_position_dialog->setGeometry(0,0,mon_position_dialog->sizeHint().width(),
|
||||
mon_position_dialog->sizeHint().height());
|
||||
|
||||
//
|
||||
// Name Label
|
||||
//
|
||||
mon_name_label=new QLabel(this);
|
||||
mon_name_label->setFont(font);
|
||||
|
||||
//
|
||||
// Status Icons
|
||||
//
|
||||
mon_green_label=new QLabel(this);
|
||||
mon_green_label->setPixmap(QPixmap(greenball_xpm));
|
||||
mon_green_label->hide();
|
||||
|
||||
mon_red_label=new QLabel(this);
|
||||
mon_red_label->setPixmap(QPixmap(redball_xpm));
|
||||
mon_red_label->hide();
|
||||
|
||||
//
|
||||
// Validation Timer
|
||||
//
|
||||
mon_validate_timer=new QTimer(this);
|
||||
connect(mon_validate_timer,SIGNAL(timeout()),this,SLOT(validate()));
|
||||
mon_validate_timer->start(5000);
|
||||
|
||||
mon_tooltip=new StatusTip(this);
|
||||
|
||||
mon_name_label->setText(mon_rdconfig->label());
|
||||
SetPosition();
|
||||
|
||||
::signal(SIGTERM,SigHandler);
|
||||
::signal(SIGINT,SigHandler);
|
||||
}
|
||||
|
||||
|
||||
QSizePolicy MainWidget::sizePolicy() const
|
||||
{
|
||||
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::validate()
|
||||
{
|
||||
bool db_ok=false;
|
||||
bool snd_ok=false;
|
||||
int schema=0;
|
||||
std::vector<QString> bad_cuts;
|
||||
|
||||
//
|
||||
// Get Configurations
|
||||
//
|
||||
mon_rdconfig->load();
|
||||
mon_name_label->setText(mon_rdconfig->label());
|
||||
|
||||
//
|
||||
// Check Audio Store
|
||||
//
|
||||
snd_ok=RDAudioStoreValid(mon_rdconfig);
|
||||
|
||||
//
|
||||
// Check Database
|
||||
//
|
||||
db_ok=RDDbValid(mon_rdconfig,&schema);
|
||||
|
||||
//
|
||||
// Record Results
|
||||
//
|
||||
mon_tooltip->
|
||||
setStatus(QRect(0,0,size().width(),size().height()),db_ok,schema,snd_ok);
|
||||
SetSummaryState(db_ok&&(schema==RD_VERSION_DATABASE)&&snd_ok);
|
||||
SetPosition();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::quitMainWidget()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if(e->button()!=QMouseEvent::RightButton) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
e->accept();
|
||||
mon_position_dialog->setGeometry(mon_dialog_x,mon_dialog_y,
|
||||
mon_position_dialog->sizeHint().width(),
|
||||
mon_position_dialog->sizeHint().height());
|
||||
if(mon_position_dialog->exec()==0) {
|
||||
mon_config->save();
|
||||
SetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
if(e->button()!=QMouseEvent::LeftButton) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
e->accept();
|
||||
QDir dir(RD_DEFAULT_RDSELECT_DIR);
|
||||
dir.setFilter(QDir::Files|QDir::Readable);
|
||||
dir.setNameFilter("*.conf");
|
||||
if(dir.entryList().size()>1) {
|
||||
system(QString().sprintf("rdselect -geometry +%d+%d",
|
||||
mon_rdselect_x,mon_rdselect_y));
|
||||
validate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QPainter *p=new QPainter(this);
|
||||
p->setPen(QPen(Qt::black,2));
|
||||
p->drawRect(1,1,size().width(),size().height());
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
mon_name_label->setGeometry(10,5,size().width()-30,size().height()-10);
|
||||
mon_green_label->setGeometry(size().width()-20,5,15,20);
|
||||
mon_red_label->setGeometry(size().width()-20,5,15,20);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::SetSummaryState(bool state)
|
||||
{
|
||||
if(state) {
|
||||
mon_red_label->hide();
|
||||
mon_green_label->show();
|
||||
}
|
||||
else {
|
||||
mon_green_label->hide();
|
||||
mon_red_label->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::SetPosition()
|
||||
{
|
||||
int width=mon_metrics->width(mon_name_label->text())+40;
|
||||
QRect geo=mon_desktop_widget->screenGeometry(mon_config->screenNumber());
|
||||
QRect main_geo=mon_desktop_widget->geometry();
|
||||
int x=0;
|
||||
int dx=mon_config->xOffset();
|
||||
int y=0;
|
||||
int dy=mon_config->yOffset();
|
||||
int dw=mon_position_dialog->size().width()+30;
|
||||
int dh=mon_position_dialog->size().height()+30;
|
||||
|
||||
switch(mon_config->position()) {
|
||||
case RDMonitorConfig::UpperLeft:
|
||||
x=geo.x()+dx;
|
||||
y=geo.y()+dy;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::UpperCenter:
|
||||
x=geo.x()+(geo.width()-width)/2;
|
||||
y=geo.y()+dy;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::UpperRight:
|
||||
x=geo.x()-dx+geo.width()-width;
|
||||
y=geo.y()+dy;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LowerLeft:
|
||||
x=geo.x()+dx;
|
||||
y=geo.y()-dy+geo.height()-RDMONITOR_HEIGHT;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LowerCenter:
|
||||
x=geo.x()+(geo.width()-width)/2;
|
||||
y=geo.y()-dy+geo.height()-RDMONITOR_HEIGHT;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LowerRight:
|
||||
x=geo.x()-dx+geo.width()-width;
|
||||
y=geo.y()-dy+geo.height()-RDMONITOR_HEIGHT;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LastPosition:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Ensure sane values
|
||||
//
|
||||
if(x<0) {
|
||||
x=0;
|
||||
}
|
||||
if(x>(main_geo.width()-width)) {
|
||||
x=main_geo.width()-width;
|
||||
}
|
||||
if(y<0) {
|
||||
y=0;
|
||||
}
|
||||
if(y>(main_geo.height()-RDMONITOR_HEIGHT)) {
|
||||
y=main_geo.height()-RDMONITOR_HEIGHT;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the dialog position
|
||||
//
|
||||
switch(mon_config->position()) {
|
||||
case RDMonitorConfig::UpperLeft:
|
||||
mon_dialog_x=x;
|
||||
mon_rdselect_x=x;
|
||||
mon_dialog_y=y+RDMONITOR_HEIGHT;
|
||||
mon_rdselect_y=y+RDMONITOR_HEIGHT;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::UpperCenter:
|
||||
mon_dialog_x=x+(width-dw)/2;
|
||||
mon_dialog_y=y+RDMONITOR_HEIGHT;
|
||||
mon_rdselect_x=x+(width-RDSELECT_WIDTH)/2;
|
||||
mon_rdselect_y=y+RDMONITOR_HEIGHT;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::UpperRight:
|
||||
mon_dialog_x=x+width-dw;
|
||||
mon_dialog_y=y+RDMONITOR_HEIGHT;
|
||||
mon_rdselect_x=x+width-RDSELECT_WIDTH;
|
||||
mon_rdselect_y=y+RDMONITOR_HEIGHT;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LowerLeft:
|
||||
mon_dialog_x=x;
|
||||
mon_rdselect_x=x;
|
||||
mon_dialog_y=y-dh;
|
||||
mon_rdselect_y=y-RDSELECT_HEIGHT-30;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LowerCenter:
|
||||
mon_dialog_x=x+(width-dw)/2;
|
||||
mon_dialog_y=y-dh;
|
||||
mon_rdselect_x=x+(width-RDSELECT_WIDTH)/2;
|
||||
mon_rdselect_y=y-RDSELECT_HEIGHT-30;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LowerRight:
|
||||
mon_dialog_x=x+width-dw;
|
||||
mon_rdselect_x=x+width-RDSELECT_WIDTH;
|
||||
mon_dialog_y=y-dh;
|
||||
mon_rdselect_y=y-RDSELECT_HEIGHT-30;
|
||||
break;
|
||||
|
||||
case RDMonitorConfig::LastPosition:
|
||||
break;
|
||||
}
|
||||
setGeometry(x,y,width,RDMONITOR_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv);
|
||||
|
||||
//
|
||||
// Load Translations
|
||||
//
|
||||
QTranslator qt(0);
|
||||
qt.load(QString(QTDIR)+QString("/translations/qt_")+QTextCodec::locale(),
|
||||
".");
|
||||
a.installTranslator(&qt);
|
||||
|
||||
QTranslator rd(0);
|
||||
rd.load(QString(PREFIX)+QString("/share/rivendell/librd_")+
|
||||
QTextCodec::locale(),".");
|
||||
a.installTranslator(&rd);
|
||||
|
||||
QTranslator rdhpi(0);
|
||||
rdhpi.load(QString(PREFIX)+QString("/share/rivendell/librdhpi_")+
|
||||
QTextCodec::locale(),".");
|
||||
a.installTranslator(&rdhpi);
|
||||
|
||||
QTranslator tr(0);
|
||||
tr.load(QString(PREFIX)+QString("/share/rivendell/rdmonitor_")+
|
||||
QTextCodec::locale(),".");
|
||||
a.installTranslator(&tr);
|
||||
|
||||
//
|
||||
// Start Event Loop
|
||||
//
|
||||
MainWidget *w=new MainWidget(NULL,"main");
|
||||
a.setMainWidget(w);
|
||||
w->show();
|
||||
return a.exec();
|
||||
}
|
83
rdmonitor/rdmonitor.h
Normal file
83
rdmonitor/rdmonitor.h
Normal file
@@ -0,0 +1,83 @@
|
||||
// rdmonitor.h
|
||||
//
|
||||
// System Monitor Applet for Rivendell
|
||||
//
|
||||
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: rdmonitor.h,v 1.1.2.6 2013/11/08 03:57:15 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 RDMONITOR_H
|
||||
#define RDMONITOR_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qsize.h>
|
||||
#include <qsizepolicy.h>
|
||||
#include <qlabel.h>
|
||||
#include <qtimer.h>
|
||||
#include <qdesktopwidget.h>
|
||||
#include <qfontmetrics.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rdmonitor_config.h>
|
||||
|
||||
#include "positiondialog.h"
|
||||
#include "status_tip.h"
|
||||
|
||||
#define RDSELECT_WIDTH 400
|
||||
#define RDSELECT_HEIGHT 300
|
||||
|
||||
class MainWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWidget(QWidget *parent=0,const char *name=0);
|
||||
QSizePolicy sizePolicy() const;
|
||||
|
||||
private slots:
|
||||
void validate();
|
||||
void quitMainWidget();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
private:
|
||||
void SetSummaryState(bool state);
|
||||
void SetPosition();
|
||||
QLabel *mon_name_label;
|
||||
QLabel *mon_green_label;
|
||||
QLabel *mon_red_label;
|
||||
QTimer *mon_validate_timer;
|
||||
QFontMetrics *mon_metrics;
|
||||
PositionDialog *mon_position_dialog;
|
||||
int mon_dialog_x;
|
||||
int mon_dialog_y;
|
||||
int mon_rdselect_x;
|
||||
int mon_rdselect_y;
|
||||
StatusTip *mon_tooltip;
|
||||
QDesktopWidget *mon_desktop_widget;
|
||||
RDMonitorConfig *mon_config;
|
||||
RDConfig *mon_rdconfig;
|
||||
};
|
||||
|
||||
|
||||
#endif // RDMONITOR_H
|
40
rdmonitor/rdmonitor.pro
Normal file
40
rdmonitor/rdmonitor.pro
Normal file
@@ -0,0 +1,40 @@
|
||||
# rdmonitor.pro
|
||||
#
|
||||
# The QMake project file for RDMonitor.
|
||||
#
|
||||
# (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
|
||||
#
|
||||
# $Id: rdmonitor.pro,v 1.1.2.2 2013/01/01 21:36:32 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
|
||||
|
||||
x11 {
|
||||
SOURCES += rdmonitor.cpp
|
||||
SOURCES += status_tip.cpp
|
||||
}
|
||||
|
||||
x11 {
|
||||
HEADERS += rdmonitor.h
|
||||
HEADERS += status_tip.h
|
||||
}
|
||||
|
||||
TRANSLATIONS += rdmonitor_cs.ts
|
||||
TRANSLATIONS += rdmonitor_de.ts
|
||||
TRANSLATIONS += rdmonitor_es.ts
|
||||
TRANSLATIONS += rdmonitor_fr.ts
|
||||
TRANSLATIONS += rdmonitor_nb.ts
|
||||
TRANSLATIONS += rdmonitor_nn.ts
|
||||
TRANSLATIONS += rdmonitor_pt_BR.ts
|
21
rdmonitor/rdmonitor_cs.ts
Normal file
21
rdmonitor/rdmonitor_cs.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation>Stav: OK</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation>Uložení zvuku: NEPODAŘILO SE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation>Databáze: SPOJENÍ SE NEZDAŘILO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation>Databáze: SCHÉMA ZKRESLENO</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
21
rdmonitor/rdmonitor_de.ts
Normal file
21
rdmonitor/rdmonitor_de.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
21
rdmonitor/rdmonitor_es.ts
Normal file
21
rdmonitor/rdmonitor_es.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
21
rdmonitor/rdmonitor_fr.ts
Normal file
21
rdmonitor/rdmonitor_fr.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
21
rdmonitor/rdmonitor_nb.ts
Normal file
21
rdmonitor/rdmonitor_nb.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
21
rdmonitor/rdmonitor_nn.ts
Normal file
21
rdmonitor/rdmonitor_nn.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
21
rdmonitor/rdmonitor_pt_BR.ts
Normal file
21
rdmonitor/rdmonitor_pt_BR.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<source>Status: OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Audio Store: FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: CONNECTION FAILED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Database: SCHEMA SKEWED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
66
rdmonitor/status_tip.cpp
Normal file
66
rdmonitor/status_tip.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// status_tip.cpp
|
||||
//
|
||||
// Custom ToolTip for RDMonitor's Status Bubble
|
||||
//
|
||||
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: status_tip.cpp,v 1.1.2.2 2012/10/22 23:09:39 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 <qobject.h>
|
||||
|
||||
#include <dbversion.h>
|
||||
|
||||
#include <status_tip.h>
|
||||
|
||||
StatusTip::StatusTip(QWidget *widget,QToolTipGroup *group)
|
||||
: QToolTip(widget,group)
|
||||
{
|
||||
setStatus(QRect(),true,0,true);
|
||||
}
|
||||
|
||||
|
||||
void StatusTip::setStatus(const QRect &rect,bool db_status,int schema,
|
||||
bool snd_status)
|
||||
{
|
||||
tip_rect=rect;
|
||||
if(db_status&&(schema==RD_VERSION_DATABASE)&&snd_status) {
|
||||
tip_text=QObject::tr("Status: OK");
|
||||
}
|
||||
else {
|
||||
tip_text="";
|
||||
if(!db_status) {
|
||||
tip_text=QObject::tr("Database: CONNECTION FAILED");
|
||||
}
|
||||
else {
|
||||
if(schema!=RD_VERSION_DATABASE) {
|
||||
tip_text=QObject::tr("Database: SCHEMA SKEWED");
|
||||
}
|
||||
}
|
||||
if(!snd_status) {
|
||||
if(!tip_text.isEmpty()) {
|
||||
tip_text+="\n";
|
||||
}
|
||||
tip_text+=QObject::tr("Audio Store: FAILED");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StatusTip::maybeTip(const QPoint &pt)
|
||||
{
|
||||
tip(tip_rect,tip_text);
|
||||
}
|
42
rdmonitor/status_tip.h
Normal file
42
rdmonitor/status_tip.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// status_tip.h
|
||||
//
|
||||
// Custom ToolTip for RDMonitor's Status Bubble
|
||||
//
|
||||
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// $Id: status_tip.h,v 1.1.2.2 2012/10/22 23:09:39 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 STATUS_TIP_H
|
||||
#define STATUS_TIP_H
|
||||
|
||||
#include <qtooltip.h>
|
||||
|
||||
class StatusTip : public QToolTip
|
||||
{
|
||||
public:
|
||||
StatusTip(QWidget *widget,QToolTipGroup *group=0);
|
||||
void setStatus(const QRect &rect,bool db_status,int schema,bool snd_status);
|
||||
|
||||
protected:
|
||||
void maybeTip(const QPoint &pt);
|
||||
|
||||
private:
|
||||
QString tip_text;
|
||||
QRect tip_rect;
|
||||
};
|
||||
|
||||
#endif // STATUS_TIP_H
|
Reference in New Issue
Block a user