diff options
author | jjl | 2010-09-22 21:40:44 +0200 |
---|---|---|
committer | jjl | 2010-09-22 21:40:44 +0200 |
commit | a665e3408bcc1fabd1bdb9b16e06c4d16b05c4df (patch) | |
tree | 58517d6d6ffc1cf672cbb61ae2ae8f11df9242ff /src/pvsgui.cpp | |
parent | [PVSGUI] always construct QSystemTrayIcon, even if systray is not available (diff) | |
download | pvs-a665e3408bcc1fabd1bdb9b16e06c4d16b05c4df.tar.gz pvs-a665e3408bcc1fabd1bdb9b16e06c4d16b05c4df.tar.xz pvs-a665e3408bcc1fabd1bdb9b16e06c4d16b05c4df.zip |
[PVSGUI] Turn on/off toolbar via menu and cmd-switch (pvsgui -h)
Diffstat (limited to 'src/pvsgui.cpp')
-rw-r--r-- | src/pvsgui.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp index 5f2ac60..c2ac3cb 100644 --- a/src/pvsgui.cpp +++ b/src/pvsgui.cpp @@ -18,6 +18,7 @@ */ #include "pvsgui.h" +#include "version.h" PVSGUI::PVSGUI(QWidget *parent) : QWidget(parent) @@ -88,6 +89,7 @@ PVSGUI::PVSGUI(QWidget *parent) : connect(_serverSocket, SIGNAL(newConnection()), this, SLOT(receiveFile())); // signals & slots - menu + connect(_showAction, SIGNAL(toggled(bool)), this, SLOT(setVisible(bool))); connect(_disconnectAction, SIGNAL(triggered()), this, SLOT(pvsDisconnect())); connect(_startChatAction, SIGNAL(triggered()), _chatDialog, SLOT(open())); connect(_sendFileAction, SIGNAL(triggered()), this, SLOT(sendFile())); @@ -116,7 +118,6 @@ PVSGUI::PVSGUI(QWidget *parent) : setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint); setAttribute(Qt::WA_AlwaysShowToolTips); updateConfig(); - setVisible(true); hide(); } @@ -136,6 +137,13 @@ void PVSGUI::updateConfig() setLocation(_settings.value("Display/location").toInt()); } + +void PVSGUI::setVisible(bool visible) +{ + QWidget::setVisible(visible); + _showAction->setChecked(isVisible()); +} + //////////////////////////////////////////////////////////////////////////////// // Protected @@ -178,6 +186,8 @@ void PVSGUI::mouseMoveEvent(QMouseEvent *event) void PVSGUI::setupMenu() { // setup actions + _showAction = new QAction(tr("Show &toolbar"), this); + _showAction->setCheckable(true); _disconnectAction = new QAction(tr("&Disconnect"), this); _startChatAction = new QAction(tr("C&hat"), this); _sendFileAction = new QAction(tr("&Send File"), this); @@ -187,6 +197,7 @@ void PVSGUI::setupMenu() _quitAction = new QAction(tr("&Quit"), this); // setup menu + _menu->addAction(_showAction); _menu->addMenu(_hostMenu); _menu->addAction(_disconnectAction); _menu->addAction(_showInfoAction); @@ -402,9 +413,34 @@ void PVSGUI::receiveFile() //////////////////////////////////////////////////////////////////////////////// // Main +void printHelp() +{ + QTextStream qout(stdout); + qout << QObject::tr("Usage: pvsgui [OPTIONS]...") << endl; + qout << QObject::tr("Start the Pool Video Switch GUI.") << endl; + qout << QObject::tr("Options:") << endl << endl; + qout << "-n or --nobar" << "\t" << QObject::tr("Start only with systray icon.") << endl; + qout << "-h or --help" << "\t" << QObject::tr("Show this help text and quit.") << endl; + qout << "-v or --version" << "\t" << QObject::tr("Show version and quit.") << endl; + qout << endl; + qout.flush(); + exit(0); +} + +void printVersion() +{ + QTextStream qout(stdout); + qout << QObject::tr("Version: ") << VERSION_STRING << endl; + qout << endl; + qout.flush(); + exit(0); +} + int main(int argc, char *argv[]) { QApplication app(argc, argv); + QStringList args = app.arguments(); + app.setQuitOnLastWindowClosed(false); app.setOrganizationName("openslx"); app.setOrganizationDomain("openslx.org"); app.setApplicationName("pvsgui"); @@ -414,7 +450,16 @@ int main(int argc, char *argv[]) translator.load(":pvsgui"); app.installTranslator(&translator); + if (args.contains("-h") || args.contains("--help")) + printHelp(); + + if (args.contains("-v") || args.contains("--version")) + printVersion(); + PVSGUI pvsgui; + if (!args.contains("-n") && !args.contains("--nobar")) + pvsgui.setVisible(true); + return app.exec(); } |