added new command line argument for connecting on startup, fix for window title buttons on Ubuntu

This commit is contained in:
Volker Fischer 2009-05-26 20:01:23 +00:00
parent 280f0091f3
commit c49434e3b6
3 changed files with 52 additions and 7 deletions

View file

@ -26,11 +26,22 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
Qt::WindowFlags f ) : const bool bNewConnectOnStartup,
QWidget* parent, Qt::WindowFlags f ) :
pClient ( pNCliP ), QDialog ( parent, f ), pClient ( pNCliP ), QDialog ( parent, f ),
ClientSettingsDlg ( pNCliP, parent, Qt::WindowMinMaxButtonsHint ), ClientSettingsDlg ( pNCliP, parent
ChatDlg ( parent, Qt::WindowMinMaxButtonsHint ) #ifdef _WIN32
// this somehow only works reliable on Windows
, Qt::WindowMinMaxButtonsHint
#endif
),
ChatDlg ( parent
#ifdef _WIN32
// this somehow only works reliable on Windows
, Qt::WindowMinMaxButtonsHint
#endif
)
{ {
setupUi ( this ); setupUi ( this );
@ -143,6 +154,16 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
} }
// connect on startup ---
if ( bNewConnectOnStartup )
{
// since the software starts up right now, the previous state was
// "not connected" so that a call to "OnConnectDisconBut()" will
// start the connection
OnConnectDisconBut();
}
// Settings menu ---------------------------------------------------------- // Settings menu ----------------------------------------------------------
pSettingsMenu = new QMenu ( "&View", this ); pSettingsMenu = new QMenu ( "&View", this );
pSettingsMenu->addAction ( tr ( "&Chat..." ), this, pSettingsMenu->addAction ( tr ( "&Chat..." ), this,

View file

@ -66,8 +66,8 @@ class CLlconClientDlg : public QDialog, private Ui_CLlconClientDlgBase
Q_OBJECT Q_OBJECT
public: public:
CLlconClientDlg ( CClient* pNCliP, QWidget* parent = 0, CLlconClientDlg ( CClient* pNCliP, const bool bNewConnectOnStartup,
Qt::WindowFlags f = 0 ); QWidget* parent = 0, Qt::WindowFlags f = 0 );
virtual ~CLlconClientDlg(); virtual ~CLlconClientDlg();
protected: protected:

View file

@ -52,6 +52,7 @@ int main ( int argc, char** argv )
// check if server or client application shall be started // check if server or client application shall be started
bool bIsClient = true; bool bIsClient = true;
bool bUseGUI = true; bool bUseGUI = true;
bool bConnectOnStartup = false;
int iUploadRateLimitKbps = DEF_MAX_UPLOAD_RATE_KBPS; int iUploadRateLimitKbps = DEF_MAX_UPLOAD_RATE_KBPS;
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER; quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
std::string strIniFileName = ""; std::string strIniFileName = "";
@ -72,6 +73,7 @@ int main ( int argc, char** argv )
continue; continue;
} }
// use GUI flag -------------------------------------------------------- // use GUI flag --------------------------------------------------------
if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) ) if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) )
{ {
@ -80,6 +82,7 @@ int main ( int argc, char** argv )
continue; continue;
} }
// use logging --------------------------------------------------------- // use logging ---------------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) )
{ {
@ -88,6 +91,7 @@ int main ( int argc, char** argv )
continue; continue;
} }
// force low upload data rate flag ------------------------------------- // force low upload data rate flag -------------------------------------
if ( GetNumericArgument ( argc, argv, i, "-u", "--maxuploadrate", if ( GetNumericArgument ( argc, argv, i, "-u", "--maxuploadrate",
100, 1000000, rDbleArgument ) ) 100, 1000000, rDbleArgument ) )
@ -98,6 +102,7 @@ int main ( int argc, char** argv )
continue; continue;
} }
// port number --------------------------------------------------------- // port number ---------------------------------------------------------
if ( GetNumericArgument ( argc, argv, i, "-p", "--port", if ( GetNumericArgument ( argc, argv, i, "-p", "--port",
0, 65535, rDbleArgument ) ) 0, 65535, rDbleArgument ) )
@ -107,6 +112,7 @@ int main ( int argc, char** argv )
continue; continue;
} }
// HTML status file ---------------------------------------------------- // HTML status file ----------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) )
{ {
@ -122,6 +128,7 @@ int main ( int argc, char** argv )
continue; continue;
} }
// initialization file ------------------------------------------------- // initialization file -------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) ) if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
{ {
@ -130,6 +137,16 @@ int main ( int argc, char** argv )
continue; continue;
} }
// connect on startup --------------------------------------------------
if ( GetFlagArgument ( argc, argv, i, "-c", "--connect" ) )
{
bConnectOnStartup = true;
cout << "connect on startup enabled" << std::endl;
continue;
}
// help (usage) flag --------------------------------------------------- // help (usage) flag ---------------------------------------------------
if ( ( !strcmp ( argv[i], "--help" ) ) || if ( ( !strcmp ( argv[i], "--help" ) ) ||
( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) ) ( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) )
@ -182,7 +199,13 @@ int main ( int argc, char** argv )
// GUI object // GUI object
CLlconClientDlg ClientDlg ( CLlconClientDlg ClientDlg (
&Client, 0, Qt::WindowMinMaxButtonsHint ); &Client, bConnectOnStartup,
0
#ifdef _WIN32
// this somehow only works reliable on Windows
, Qt::WindowMinMaxButtonsHint
#endif
);
// set main window // set main window
pMainWindow = &ClientDlg; pMainWindow = &ClientDlg;
@ -269,6 +292,7 @@ std::string UsageArguments ( char **argv )
" -p, --port local port number (only avaiable for server)\n" " -p, --port local port number (only avaiable for server)\n"
" -m, --htmlstatus enable HTML status file, set file name (only avaiable for server)\n" " -m, --htmlstatus enable HTML status file, set file name (only avaiable for server)\n"
" -u, --maxuploadrate maximum upload rate (only avaiable for server)\n" " -u, --maxuploadrate maximum upload rate (only avaiable for server)\n"
" -c, --connect connect to last server on startup (only available for client)\n"
" -h, -?, --help this help text\n" " -h, -?, --help this help text\n"
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n"; "Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
} }