Moved some functions from main lib to MainWindow
This commit is contained in:
parent
82de6c4ca4
commit
d78936610e
3 changed files with 57 additions and 30 deletions
|
@ -55,19 +55,6 @@ inline std::string toString(const WebServer ws) noexcept
|
|||
}
|
||||
}
|
||||
|
||||
inline WebServer fromString(const std::string& ws)
|
||||
{
|
||||
if ( ws == "Apache" ) {
|
||||
return WebServer::Apache;
|
||||
} else if ( ws == "Nginx" ) {
|
||||
return WebServer::Nginx;
|
||||
} else if ( ws == "IIS" ) {
|
||||
return WebServer::IIS;
|
||||
} else {
|
||||
throw( "Unexpected WebServer: " + ws );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline std::string toString(const DialogsLevel lvl)
|
||||
{
|
||||
|
@ -83,15 +70,6 @@ inline std::string toString(const DialogsLevel lvl)
|
|||
}
|
||||
}
|
||||
|
||||
inline DialogsLevel fromInt(const int lvl)
|
||||
{
|
||||
if ( lvl >= 0 && lvl <= 2) {
|
||||
return static_cast<DialogsLevel>( lvl );
|
||||
} else {
|
||||
throw( "Unexpected DialogsLevel: " + std::to_string(lvl) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define WS_APACHE WebServer::Apache
|
||||
#define WS_NGINX WebServer::Nginx
|
||||
|
|
|
@ -439,10 +439,10 @@ void MainWindow::readConfigs()
|
|||
GlobalConfigs::charts_theme = static_cast<ChartsTheme>( std::stoi( val ) );
|
||||
|
||||
} else if ( var == "MainDialogsLevel" ) {
|
||||
this->dialogs_level = fromInt( std::stoi( val ) );
|
||||
this->setDialogsLevelFromString( val );
|
||||
|
||||
} else if ( var == "DefaultWebServer" ) {
|
||||
this->default_web_server = fromString( val );
|
||||
this->setWebServerFromString( val );
|
||||
|
||||
} else if ( var == "DatabaseDataPath" ) {
|
||||
this->db_data_path = this->resolvePath( val );
|
||||
|
@ -466,7 +466,7 @@ void MainWindow::readConfigs()
|
|||
this->on_box_ConfTextBrowser_ColorScheme_currentIndexChanged( std::stoi( val ) );
|
||||
|
||||
} else if ( var == "CraplogDialogsLevel" ) {
|
||||
this->craplog.setDialogsLevel( fromInt( std::stoi( val ) ) );
|
||||
this->craplog.setDialogsLevel( this->dialogsLevelFromInt( std::stoi( val ) ) );
|
||||
|
||||
} else if ( var == "HideUsedFiles" ) {
|
||||
hide_used_files = this->s2b.at( val );
|
||||
|
@ -632,7 +632,7 @@ void MainWindow::readConfigs()
|
|||
this->craplog.setBlacklistUsed( WS_IIS, 20, this->s2b.at( val ) );
|
||||
|
||||
} else if ( var == "CrapviewDialogsLevel" ) {
|
||||
this->crapview.setDialogsLevel( fromInt( std::stoi( val ) ) );
|
||||
this->crapview.setDialogsLevel( this->dialogsLevelFromInt( std::stoi( val ) ) );
|
||||
|
||||
}/* else {
|
||||
// not valid
|
||||
|
@ -1003,6 +1003,33 @@ void MainWindow::setGeometryFromString( const std::string& geometry )
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::setDialogsLevelFromString( const std::string& dialogs_level )
|
||||
{
|
||||
this->dialogs_level = this->dialogsLevelFromInt( std::stoi( dialogs_level ) );
|
||||
}
|
||||
DialogsLevel MainWindow::dialogsLevelFromInt( const int dialogs_level )
|
||||
{
|
||||
if ( dialogs_level >= 0 && dialogs_level <= 2) {
|
||||
return static_cast<DialogsLevel>( dialogs_level );
|
||||
} else {
|
||||
throw( "Unexpected DialogsLevel: " + std::to_string(dialogs_level) );
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setWebServerFromString(const std::string& web_server )
|
||||
{
|
||||
// 11,12,13 are kept for retro-compatibility, to be removed in a later stage
|
||||
if ( web_server == "Apache" || web_server == "11" ) {
|
||||
this->default_web_server = WebServer::Apache;
|
||||
} else if ( web_server == "Nginx" || web_server == "12" ) {
|
||||
this->default_web_server = WebServer::Nginx;
|
||||
} else if ( web_server == "IIS" || web_server == "13" ) {
|
||||
this->default_web_server = WebServer::IIS;
|
||||
} else {
|
||||
throw( "Unexpected WebServer: " + web_server );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string MainWindow::list2string( const std::vector<std::string>& list, const bool user_agent ) const
|
||||
{
|
||||
|
@ -4257,15 +4284,18 @@ void MainWindow::on_box_ConfWindow_Icons_currentIndexChanged(int index)
|
|||
//// DIALOGS ////
|
||||
void MainWindow::on_slider_ConfDialogs_General_sliderReleased()
|
||||
{
|
||||
this->dialogs_level = fromInt( this->ui->slider_ConfDialogs_General->value() );
|
||||
this->dialogs_level = this->dialogsLevelFromInt(
|
||||
this->ui->slider_ConfDialogs_General->value() );
|
||||
}
|
||||
void MainWindow::on_slider_ConfDialogs_Logs_sliderReleased()
|
||||
{
|
||||
this->craplog.setDialogsLevel( fromInt( this->ui->slider_ConfDialogs_Logs->value() ) );
|
||||
this->craplog.setDialogsLevel( this->dialogsLevelFromInt(
|
||||
this->ui->slider_ConfDialogs_Logs->value() ) );
|
||||
}
|
||||
void MainWindow::on_slider_ConfDialogs_Stats_sliderReleased()
|
||||
{
|
||||
this->crapview.setDialogsLevel( fromInt( this->ui->slider_ConfDialogs_Stats->value() ) );
|
||||
this->crapview.setDialogsLevel( this->dialogsLevelFromInt(
|
||||
this->ui->slider_ConfDialogs_Stats->value() ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -630,14 +630,33 @@ private:
|
|||
|
||||
|
||||
/////////////////
|
||||
//// GENERAL ////
|
||||
//// DIALOGS ////
|
||||
|
||||
// quantoty of informational dialogs to display
|
||||
DialogsLevel dialogs_level{ DL_NORMAL };
|
||||
|
||||
//! Retrieves the dialogs level from the given string
|
||||
/*!
|
||||
\see readConfigs()
|
||||
*/
|
||||
void setDialogsLevelFromString( const std::string& dialogs_level );
|
||||
|
||||
//! Returns the dialogs level corresponding to the given number
|
||||
DialogsLevel dialogsLevelFromInt( const int dialogs_level );
|
||||
|
||||
|
||||
////////////////////
|
||||
//// WEB SERVER ////
|
||||
|
||||
// default web server
|
||||
WebServer default_web_server{ WS_APACHE };
|
||||
|
||||
//! Retrieves the Web Server from the given string
|
||||
/*!
|
||||
\see readConfigs()
|
||||
*/
|
||||
void setWebServerFromString( const std::string& web_server );
|
||||
|
||||
|
||||
//////////////////
|
||||
//// GRAPHICS ////
|
||||
|
|
Loading…
Reference in a new issue