30 #include <QApplication> 32 #include <QMessageBox> 33 #include <QStyleFactory> 34 #include <QTextStream> 37 #include "../common/GuiParams.hxx" 45 static QString
ss2QS(
const std::string & st)
47 return QString::fromStdString(st);
57 QMessageBox mbox(QMessageBox::Critical,
60 QMessageBox::Ok, NULL);
71 static void startupServer(
const QString & lock_file_name, SoDa::GuiParams & p)
76 if(p.getServerName() !=
"") {
77 server_name =
ss2QS(p.getServerName());
80 QString app_dir = QCoreApplication::applicationDirPath();
81 server_name = app_dir +
"/SoDaServer";
84 if(!QFile::exists(server_name)) {
85 alertAndExit(QString(
"%1 did not find the SoDa Radio server program.\n" 86 "It looked in\n[%2]\n" 87 "Please press OK button to quit.\n\n" 88 "(Though this is -not- OK. " 89 "Send a note when you get a chance to kb1vc@kb1vc.org)").arg(qApp->applicationDisplayName()).arg(server_name));
93 QString server_command;
95 char ub_fix[] =
"UBUNTU_MENUPROXY=";
98 server_command = QString(
"%1 --uds_name %2 ").arg(server_name).arg(
ss2QS(p.getServerSocketBasename()));
101 QString uhd_args =
ss2QS(p.getUHDArgs());
102 if(uhd_args !=
"") server_command += QString(
"--uhdargs %1 ").arg(uhd_args);
103 if(p.getDebugLevel() > 0) server_command += QString(
"--debug %1 ").arg(p.getDebugLevel());
104 QString server_args =
ss2QS(p.getServerArgs());
105 if(server_args !=
"") server_command += QString(
"%1 ").arg(server_args);
108 server_command += QString(
" --lockfile %1 ").arg(lock_file_name);
110 QProcess::startDetached(server_command);
124 qApp->setStyle(QStyleFactory::create(
"fusion"));
127 palette.setColor(QPalette::Window, QColor(53,53,53));
128 palette.setColor(QPalette::WindowText, Qt::white);
129 palette.setColor(QPalette::Base, QColor(15,15,15));
130 palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
131 palette.setColor(QPalette::ToolTipBase, Qt::lightGray);
132 palette.setColor(QPalette::ToolTipText, Qt::blue);
133 palette.setColor(QPalette::Text, Qt::white);
134 palette.setColor(QPalette::Button, QColor(53,53,53));
135 palette.setColor(QPalette::ButtonText, Qt::white);
136 palette.setColor(QPalette::BrightText, Qt::red);
138 palette.setColor(QPalette::Highlight, QColor(61,79,201).lighter());
139 palette.setColor(QPalette::HighlightedText, Qt::black);
141 palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray);
142 palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray);
144 qApp->setPalette(palette);
147 bool checkForZombies(
const QString & server_lock_filename,
const QString & server_socket_base)
150 if(QFileInfo::exists(server_lock_filename)) {
151 QString error_message = QString(
"%1 exists. \ 152 This is an indication that a zombiefied \ 153 SoDaServer instance is still running.\ 155 <li>Kill the zombie SoDaServer process.</li>\ 156 <li>Delete files that look like this: <p>%2_cmd</p> and <p>%2_wfall</p></li> \ 157 <li>Delete this file: <p>%1</p></li> \ 159 </ol>").arg(server_lock_filename).arg(server_socket_base);
160 QMessageBox mbox(QMessageBox::Critical,
163 QMessageBox::Ok, NULL);
167 QTextStream qw(stdout);
169 qw << QString(
"%1 exists.\nThis is an indication that a zombiefied\n\ 170 SoDaServer instance is still running.\n\n\ 171 1. Kill the zombie SoDaServer process.\n\ 172 2. Delete files that look like this: %2_cmd and %2_wfall\n\ 173 3. Delete this file: %1\n\ 174 4. Try again.\n").arg(server_lock_filename).arg(server_socket_base);
190 int main(
int argc,
char *argv[])
192 QApplication a(argc, argv);
193 SoDa::GuiParams p(argc, argv);
195 if(p.hadNoCommand()) {
200 QString apdir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
202 if(!QDir(apdir).exists()) {
206 QString uhdargs = QString::fromStdString(p.getUHDArgs());
207 QString server_lock_filename = QString(
"%1/sodaserver_args%2.lock")
212 if(p.getServerSocketBasename() == std::string(
"")) {
213 ssbn = QString(
"%1/SoDa_%2_").arg(apdir).arg(uhdargs);
214 std::string nbn = ssbn.toStdString();
215 p.setServerSocketBasename(nbn);
218 ssbn = QString::fromStdString(p.getServerSocketBasename());
static void alertAndExit(const QString &err_msg)
pop up a notification box and then bail out.
void setupLookNFeel()
initialize colors and shades for GUI elements to present a look and feel based on the fusion style...
bool checkForZombies(const QString &server_lock_filename, const QString &server_socket_base)
int main(int argc, char *argv[])
Start the SoDaRadio GUI app and launch the server process.
static QString ss2QS(const std::string &st)
simple conversion from std::string to QString...
static void startupServer(const QString &lock_file_name, SoDa::GuiParams &p)
start the radio server process