From a665e3408bcc1fabd1bdb9b16e06c4d16b05c4df Mon Sep 17 00:00:00 2001 From: jjl Date: Wed, 22 Sep 2010 21:40:44 +0200 Subject: [PVSGUI] Turn on/off toolbar via menu and cmd-switch (pvsgui -h) --- src/pvsgui.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++- src/pvsgui.h | 2 ++ 2 files changed, 48 insertions(+), 1 deletion(-) (limited to 'src') 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(); } diff --git a/src/pvsgui.h b/src/pvsgui.h index ec7c6d7..171f6bd 100644 --- a/src/pvsgui.h +++ b/src/pvsgui.h @@ -44,6 +44,7 @@ public: public Q_SLOTS: void updateConfig(); + void setVisible(bool visible); protected: void enterEvent(QEvent *e); @@ -80,6 +81,7 @@ private: ClientVNCViewer *_vncViewer; AboutDialog *_aboutDialog; + QAction *_showAction; QAction *_disconnectAction; QAction *_startChatAction; QAction *_sendFileAction; -- cgit v1.2.3-55-g7522