diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-04-21 11:45:51 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-04-23 10:54:04 (GMT) |
commit | 91686a86876553774452d97f3f74d5f147b19164 (patch) | |
tree | fd0d601497f0cc757f12ec7c336b5b64213bbfd3 /Swift/QtUI | |
parent | 6bd72c67896a20041556519548650590553f47c9 (diff) | |
download | swift-contrib-91686a86876553774452d97f3f74d5f147b19164.zip swift-contrib-91686a86876553774452d97f3f74d5f147b19164.tar.bz2 |
Make latency stats optional.
Includes boost program_options so we can use commandline parameters.
Netbook mode is now activated with --netbook-mode.
Latency debug is activated with --latency-debug.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 16 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.h | 8 | ||||
-rw-r--r-- | Swift/QtUI/main.cpp | 12 |
3 files changed, 30 insertions, 6 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 258a7b6..fc5f4cb 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -40,9 +40,19 @@ namespace Swift{ #define SWIFT_APPCAST_URL "" #endif +po::options_description QtSwift::getOptionsDescription() { + po::options_description result("Options"); + result.add_options() + ("help", "produce help message") + ("netbook-mode", "use netbook mode display") + ("latency-debug", "use latency debugging") + ; + return result; +} + -QtSwift::QtSwift(bool netbookMode) : autoUpdater_(NULL) { - if (netbookMode) { +QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) { + if (options.count("netbook-mode")) { splitter_ = new QSplitter(); } else { splitter_ = NULL; @@ -67,7 +77,7 @@ QtSwift::QtSwift(bool netbookMode) : autoUpdater_(NULL) { if (splitter_) { splitter_->show(); } - mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, treeWidgetFactory_, eventWindowFactory_, settings_, application_, systemTray_, soundPlayer_, xmlConsoleWidgetFactory_, chatListWindowFactory_); + mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, treeWidgetFactory_, eventWindowFactory_, settings_, application_, systemTray_, soundPlayer_, xmlConsoleWidgetFactory_, chatListWindowFactory_, options.count("latency-debug") > 0); PlatformAutoUpdaterFactory autoUpdaterFactory; if (autoUpdaterFactory.isSupported()) { diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index 2ebc3d5..72343d8 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -7,6 +7,9 @@ #ifndef SWIFT_QtSwift_H #define SWIFT_QtSwift_H +#include <boost/program_options/variables_map.hpp> +#include <boost/program_options/options_description.hpp> + #include "Swiften/Base/String.h" #include "Swiften/EventLoop/Qt/QtEventLoop.h" #include "QtLoginWindowFactory.h" @@ -14,6 +17,8 @@ #include "QtChatWindowFactory.h" #include "QtSettingsProvider.h" +namespace po = boost::program_options; + class QSplitter; namespace Swift { @@ -33,7 +38,8 @@ namespace Swift { class QtSwift : public QObject { Q_OBJECT public: - QtSwift(bool netbookMode); + QtSwift(po::variables_map options); + static po::options_description getOptionsDescription(); ~QtSwift(); private: MainController *mainController_; diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp index 971d536..f8b805c 100644 --- a/Swift/QtUI/main.cpp +++ b/Swift/QtUI/main.cpp @@ -4,13 +4,21 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ +#include <boost/program_options/options_description.hpp> +#include <boost/program_options/variables_map.hpp> +#include <boost/program_options.hpp> + + #include <QApplication> #include "QtSwift.h" int main(int argc, char* argv[]) { QApplication app(argc, argv); - bool netbookMode = argc > 1; - Swift::QtSwift swift(netbookMode); + boost::program_options::options_description desc = Swift::QtSwift::getOptionsDescription(); + boost::program_options::variables_map vm; + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); + boost::program_options::notify(vm); + Swift::QtSwift swift(vm); return app.exec(); } |