Skip to content

Commit

Permalink
- Slightly refactored command line arguments processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rncbc committed Oct 28, 2023
1 parent 64a0de3 commit 4c985dc
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 57 deletions.
4 changes: 2 additions & 2 deletions src/qjackctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,13 @@ int main ( int argc, char **argv )
}

// Check if we'll just start an external program...
if (!setup.sCmdLine.isEmpty()) {
if (!setup.cmdLine.isEmpty()) {
jack_client_t *pJackClient
= jack_client_open("qjackctl-start", JackNoStartServer, nullptr);
if (pJackClient) {
jack_client_close(pJackClient);
const int iExitStatus
= ::system(setup.sCmdLine.toUtf8().constData());
= ::system(setup.cmdLine.join(' ').toUtf8().constData());
app.quit();
return iExitStatus;
}
Expand Down
8 changes: 4 additions & 4 deletions src/qjackctlMainForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ bool qjackctlMainForm::setup ( qjackctlSetup *pSetup )
jackStabilize();

// Look for immediate server startup?...
if (m_pSetup->bStartJack || !m_pSetup->sCmdLine.isEmpty())
if (m_pSetup->bStartJack || !m_pSetup->cmdLine.isEmpty())
m_pSetup->bStartJackCmd = true;
if (m_pSetup->bStartJackCmd)
startJack();
Expand Down Expand Up @@ -3339,13 +3339,13 @@ bool qjackctlMainForm::startJackClient ( bool bDetach )
}

// Have we an initial command-line to start away?
if (!m_pSetup->sCmdLine.isEmpty()) {
if (!m_pSetup->cmdLine.isEmpty()) {
// Run it dettached...
shellExecute(m_pSetup->sCmdLine,
shellExecute(m_pSetup->cmdLine.join(' '),
tr("Command line argument..."),
tr("Command line argument started"));
// And reset it forever more...
m_pSetup->sCmdLine.clear();
m_pSetup->cmdLine.clear();
}

// Remember to schedule an initial connection refreshment.
Expand Down
18 changes: 7 additions & 11 deletions src/qjackctlSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,7 @@ bool qjackctlSetup::parse_args ( const QStringList& args )

for (const QString& sArg : parser.positionalArguments()) {
if (sArg != "-T" && sArg != "-ndefault") {
if (iCmdArgs > 0)
sCmdLine += ' ';
sCmdLine += sArg;
cmdLine.append(sArg);
++iCmdArgs;
}
}
Expand All @@ -724,14 +722,14 @@ bool qjackctlSetup::parse_args ( const QStringList& args )

for (int i = 1; i < argc; ++i) {

QString sArg = args.at(i);

if (iCmdArgs > 0) {
sCmdLine += ' ';
sCmdLine += args.at(i);
sCmdArgs.append(sArg);
++iCmdArgs;
continue;
}

QString sArg = args.at(i);
QString sVal;
const int iEqual = sArg.indexOf('=');
if (iEqual >= 0) {
Expand Down Expand Up @@ -793,18 +791,16 @@ bool qjackctlSetup::parse_args ( const QStringList& args )
} // FIXME: Avoid auto-start jackd stuffed args!
else if (sArg != "-T" && sArg != "-ndefault") {
// Here starts the optional command line...
sCmdLine += sArg;
cmdLine.append(sArg);
++iCmdArgs;
}
}

#endif

// HACK: If there's a command line, it must be spawned on background...
if (iCmdArgs > 0) {
sCmdLine += ' ';
sCmdLine += '&';
}
if (iCmdArgs > 0)
cmdLine.append("&");

// Alright with argument parsing.
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/qjackctlSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class qjackctlSetup
bool bStopJack;

// User supplied command line.
QString sCmdLine;
QStringList cmdLine;

// Current/previous (default) preset name.
QString sDefPreset;
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Volba -p vyžaduje argument (preset, přednastavení).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>Volba -a vyžaduje argument (cesta).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Volba -n vyžaduje argument (název).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Option -p benötigt ein Argument (Preset).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>Option -a benötigt ein Argument (Pfad).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Option -n benötigt ein Argument (Name).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>La opción -p nececita un argumento (nombre de un preset).</translation>
</message>
Expand All @@ -94,13 +94,13 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>La opción -a requiere un argumento (ruta).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>La opción -n necesita un argumento (nombre).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>L&apos;option -p nécessite un argument (préréglage).</translation>
</message>
Expand Down Expand Up @@ -94,13 +94,13 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>L&apos;option -a nécessite un argument (chemin).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>L&apos;option -n nécessite un argument (nom).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>L&apos;opzione -p richiede un argomento (preset).</translation>
</message>
Expand All @@ -94,13 +94,13 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>L&apos;opzione -a richiede un argomento (indirizzo).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>L&apos;opzione -n richiede un argomento (nome).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation></translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation></translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>옵션 -p에는 인수(사전설정)가 필요합니다.</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>옵션 -a에는 인수(경로)가 필요합니다.</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>옵션 -n에는 인수(이름)가 필요합니다.</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Optie -p vereist een argument (preset).</translation>
</message>
Expand Down Expand Up @@ -94,13 +94,13 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>Optie -a vereist een argument (pad).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Optie -n vereist een argument (naam).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Opção -p requer um argumento (preset).</translation>
</message>
Expand All @@ -94,13 +94,13 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>A opção -a requer um argumento (caminho).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Opção -n requer um argumento (nome).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<name>QObject</name>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Ключ -p требует аргумента (пресет).</translation>
</message>
Expand Down Expand Up @@ -94,13 +94,13 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>Ключу -a необходим аргумент (расположение)</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Ключу -n необходим аргумент (название).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Možnosť -p vyžaduje argument (prednastavenie).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>Možnost -a vyžaduje argument (cesta).</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Možnosť -n vyžaduje argument (názov).</translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/qjackctl_tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="685"/>
<location filename="../qjackctlSetup.cpp" line="749"/>
<location filename="../qjackctlSetup.cpp" line="747"/>
<source>Option -p requires an argument (preset).</source>
<translation>Seçenek -p bir bağımsız değişken (ön ayar) gerektirir.</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="694"/>
<location filename="../qjackctlSetup.cpp" line="758"/>
<location filename="../qjackctlSetup.cpp" line="756"/>
<source>Option -a requires an argument (path).</source>
<translation>Seçenek -a bir argüman (yol) gerektirir.</translation>
</message>
<message>
<location filename="../qjackctlSetup.cpp" line="704"/>
<location filename="../qjackctlSetup.cpp" line="768"/>
<location filename="../qjackctlSetup.cpp" line="766"/>
<source>Option -n requires an argument (name).</source>
<translation>Seçenek -n bir argüman (isim) gerektirir.</translation>
</message>
Expand Down
Loading

0 comments on commit 4c985dc

Please sign in to comment.