//******************************************************************* // diff PRIVATE //******************************************************************* void QBtWorkspace::diff( const QString& in_fname_1, const QString& in_fname_2 ) const { const QString fname1 = QBtShared::quoted_fpath( in_fname_1 ); const QString fname2 = QBtShared::quoted_fpath( in_fname_2 ); const QString beediff = QBtShared::slashed_dir( QDir::homePath() ) + "/beediff/beediff %1 %2"; bool ok = true; QBtSettings stt; QVariant data; if( stt.read( QBtConfig::DIFF_GROUP + QBtConfig::USE_DEFAULT_KEY, data ) ) { ok = data.toBool(); } QString muster = beediff; if( !ok ) { if( stt.read( QBtConfig::DIFF_GROUP + QBtConfig::COMMAND_KEY, data ) ) { muster = data.toString().trimmed(); if( muster.isEmpty() ) { return; } } } QProcess process; const QString cmd = muster.arg( fname1 ).arg( fname2 ); process.startDetached( cmd ); }
//******************************************************************* // console_start PRIVATE //******************************************************************* void QBtView::console_start() const { const QString path = model_->current_path(); if( !path.isEmpty() ) { QBtSettings stt; QVariant data; bool use_default = true; if( stt.read( QBtConfig::TERMINAL_GROUP + QBtConfig::USE_DEFAULT_KEY, data ) ) { use_default = data.toBool(); } if( use_default ) { static const QString GNOME = "gnome-terminal --working-directory=%1 &"; static const QString KDE = "konsole --workdir %1 &"; const QString cmd = QBtShared::is_gnome() ? GNOME : KDE; system( cmd.arg( path ).toLatin1() ); } else { QString command = QString(); if( stt.read( QBtConfig::TERMINAL_GROUP + QBtConfig::COMMAND_KEY, data ) ) { command = data.toString().trimmed(); } if( !command.isEmpty() ) { if( command.contains( "$dir" ) ) { command.replace( "$dir", path ); } command += " &"; system( command.toLatin1() ); } } } }
//******************************************************************* // save_state PRIVATE //******************************************************************* void QBtConfigApps::save_state() { QBtSettings stt; stt.save( QBtConfig::TERMINAL_GROUP + QBtConfig::USE_DEFAULT_KEY, console_default_->isChecked() ); stt.save( QBtConfig::TERMINAL_GROUP + QBtConfig::COMMAND_KEY , console_command_->text().trimmed() ); stt.save( QBtConfig::DIFF_GROUP + QBtConfig::USE_DEFAULT_KEY, diff_default_->isChecked() ); stt.save( QBtConfig::DIFF_GROUP + QBtConfig::COMMAND_KEY , diff_command_->text().trimmed() ); }
//******************************************************************* // restore PRIVATE //******************************************************************* void QBtWorkspace::restore() { QBtSettings stt; QVariant data; if( stt.read( QBtConfig::WORKSPACE_GROUP + QBtConfig::SPLITTER_KEY, data ) ) { splitter_->restoreState( data.toByteArray() ); } else { splitter_->setStretchFactor( 0, 1 ); splitter_->setStretchFactor( 1, 1 ); } }
//******************************************************************* // restore_state PRIVATE //******************************************************************* void QBtConfigApps::restore_state() { QBtSettings stt; QVariant data; if( stt.read( QBtConfig::TERMINAL_GROUP + QBtConfig::USE_DEFAULT_KEY, data ) ) { data.toBool() ? console_default_->setChecked( true ) : console_other_->setChecked( true ); } if( stt.read( QBtConfig::TERMINAL_GROUP + QBtConfig::COMMAND_KEY, data ) ) { console_command_->setText( data.toString().trimmed() ); } if( stt.read( QBtConfig::DIFF_GROUP + QBtConfig::USE_DEFAULT_KEY, data ) ) { data.toBool() ? diff_default_->setChecked( true ) : diff_other_->setChecked( true ); } if( stt.read( QBtConfig::DIFF_GROUP + QBtConfig::COMMAND_KEY, data ) ) { diff_command_->setText( data.toString().trimmed() ); } }
//******************************************************************* // is_ext_declared PRIVATE //******************************************************************* bool QBtView::is_ext_declared( const QString& in_ext, QString& out_prg, QString& out_par ) const { QStringList data = QStringList(); QBtSettings stt; QVariant value; if( stt.read( QBtConfig::EXT_GROUP + QBtConfig::EXT_KEY, value ) ) { data = value.toStringList(); } const qint32 n = data.size(); for( qint32 i = 0; i < n; ++i ) { const QStringList record = data.at( i ).split( ',' ); if( in_ext == record.at( 0 ).toLower() ) { out_prg = record.at( 1 ); out_par = record.at( 2 ); return true; } } return false; }
//******************************************************************* // save_data PUBLIC //******************************************************************* void QBtConfig::save_data() const { QBtSettings stt; // filter state stt.save( MAIN_WINDOW_GROUP + FILTER_KEY, filter_ ); // button mode stt.save( MAIN_WINDOW_GROUP + BTN_MODE_KEY, btn_mode_ ); // button font stt.save( MAIN_WINDOW_GROUP + BTN_FONT_KEY, btn_font_.toString() ); // font stt.save( VIEW_GROUP + FONT_KEY, font_.toString() ); // background color stt.save( VIEW_GROUP + BKG_F_NC_NS_COLOR_KEY, bkg_f_nc_ns_color_.name() ); // text color stt.save( VIEW_GROUP + TXT_F_NC_NS_COLOR_KEY, txt_f_nc_ns_color_.name() ); // bkg nf nc ns stt.save( VIEW_GROUP + BKG_NF_NC_NS_COLOR_KEY, bkg_nf_nc_ns_color_.name() ); // txt nf nc ns stt.save( VIEW_GROUP + TXT_NF_NC_NS_COLOR_KEY, txt_nf_nc_ns_color_.name() ); // bkg f nc s stt.save( VIEW_GROUP + BKG_F_NC_S_COLOR_KEY, bkg_f_nc_s_color_.name() ); // txt f nc s stt.save( VIEW_GROUP + TXT_F_NC_S_COLOR_KEY, txt_f_nc_s_color_.name() ); // bkg nf nc s stt.save( VIEW_GROUP + BKG_NF_NC_S_COLOR_KEY, bkg_nf_nc_s_color_.name() ); // txt nf nc s stt.save( VIEW_GROUP + TXT_NF_NC_S_COLOR_KEY, txt_nf_nc_s_color_.name() ); // bkg f c s stt.save( VIEW_GROUP + BKG_F_C_S_COLOR_KEY, bkg_f_c_s_color_.name() ); // txt f c s stt.save( VIEW_GROUP + TXT_F_C_S_COLOR_KEY, txt_f_c_s_color_.name() ); // bkg nf c s stt.save( VIEW_GROUP + BKG_NF_C_S_COLOR_KEY, bkg_nf_c_s_color_.name() ); // txt nf c s stt.save( VIEW_GROUP + TXT_NF_C_S_COLOR_KEY, txt_nf_c_s_color_.name() ); // bkg f c ns stt.save( VIEW_GROUP + BKG_F_C_NS_COLOR_KEY, bkg_f_c_ns_color_.name() ); // txt f c ns stt.save( VIEW_GROUP + TXT_F_C_NS_COLOR_KEY, txt_f_c_ns_color_.name() ); // bkg nf c ns stt.save( VIEW_GROUP + BKG_NF_C_NS_COLOR_KEY, bkg_nf_c_ns_color_.name() ); // txt nf c ns stt.save( VIEW_GROUP + TXT_NF_C_NS_COLOR_KEY, txt_nf_c_ns_color_ ); }
//******************************************************************* // read_data PRIVATE //******************************************************************* void QBtConfig::read_data() { QBtSettings stt; QVariant data; // filter state filter_ = DEFAULT_FILTER_STATE; if( stt.read( MAIN_WINDOW_GROUP + FILTER_KEY, data ) ) { filter_ = data.toBool(); } // button mode btn_mode_ = QBtButtonSpace::FULL_DESC; if( stt.read( MAIN_WINDOW_GROUP + BTN_MODE_KEY, data ) ) { btn_mode_ = data.toInt(); } // button font btn_font_ = QFont(); if( stt.read( MAIN_WINDOW_GROUP + BTN_FONT_KEY, data ) ) { btn_font_.fromString( data.toString() ); } // font font_ = QFont(); if( stt.read( VIEW_GROUP + FONT_KEY, data ) ) { font_.fromString( data.toString() ); } // bkg f nc ns bkg_f_nc_ns_color_ = DEFAULT_BKG_F_NC_NS_COLOR; if( stt.read( VIEW_GROUP + BKG_F_NC_NS_COLOR_KEY, data ) ) { bkg_f_nc_ns_color_.setNamedColor( data.toString() ); } // txt f nc ns txt_f_nc_ns_color_ = DEFAULT_TXT_F_NC_NS_COLOR; if( stt.read( VIEW_GROUP + TXT_F_NC_NS_COLOR_KEY, data ) ) { txt_f_nc_ns_color_.setNamedColor( data.toString() ); } // bkg nf nc ns bkg_nf_nc_ns_color_ = DEFAULT_BKG_NF_NC_NS_COLOR; if( stt.read( VIEW_GROUP + BKG_NF_NC_NS_COLOR_KEY, data ) ) { bkg_nf_nc_ns_color_.setNamedColor( data.toString() ); } // txt nf nc ns txt_nf_nc_ns_color_ = DEFAULT_TXT_NF_NC_NS_COLOR; if( stt.read( VIEW_GROUP + TXT_NF_NC_NS_COLOR_KEY, data ) ) { txt_nf_nc_ns_color_.setNamedColor( data.toString() ); } // bkg f nc s bkg_f_nc_s_color_ = DEFAULT_BKG_F_NC_S_COLOR; if( stt.read( VIEW_GROUP + BKG_F_NC_S_COLOR_KEY, data ) ) { bkg_f_nc_s_color_.setNamedColor( data.toString() ); } // txt f nc s txt_f_nc_s_color_ = DEFAULT_TXT_F_NC_S_COLOR; if( stt.read( VIEW_GROUP + TXT_F_NC_S_COLOR_KEY, data ) ) { txt_f_nc_s_color_.setNamedColor( data.toString() ); } // bkg nf nc s bkg_nf_nc_s_color_ = DEFAULT_BKG_NF_NC_S_COLOR; if( stt.read( VIEW_GROUP + BKG_NF_NC_S_COLOR_KEY, data ) ) { bkg_nf_nc_s_color_.setNamedColor( data.toString() ); } // txt nf nc s txt_nf_nc_s_color_ = DEFAULT_TXT_NF_NC_S_COLOR; if( stt.read( VIEW_GROUP + TXT_NF_NC_S_COLOR_KEY, data ) ) { txt_nf_nc_s_color_.setNamedColor( data.toString() ); } // bkg f c s bkg_f_c_s_color_ = DEFAULT_BKG_F_C_S_COLOR; if( stt.read( VIEW_GROUP + BKG_F_C_S_COLOR_KEY, data ) ) { bkg_f_c_s_color_.setNamedColor( data.toString() ); } // txt f c s txt_f_c_s_color_ = DEFAULT_TXT_F_C_S_COLOR; if( stt.read( VIEW_GROUP + TXT_F_C_S_COLOR_KEY, data ) ) { txt_f_c_s_color_.setNamedColor( data.toString() ); } // bkg nf c s bkg_nf_c_s_color_ = DEFAULT_BKG_NF_C_S_COLOR; if( stt.read( VIEW_GROUP + BKG_NF_C_S_COLOR_KEY, data ) ) { bkg_nf_c_s_color_.setNamedColor( data.toString() ); } // txt nf c s txt_nf_c_s_color_ = DEFAULT_TXT_NF_C_S_COLOR; if( stt.read( VIEW_GROUP + TXT_NF_C_S_COLOR_KEY, data ) ) { txt_nf_c_s_color_.setNamedColor( data.toString() ); } // bkg f c ns bkg_f_c_ns_color_ = DEFAULT_BKG_F_C_NS_COLOR; if( stt.read( VIEW_GROUP + BKG_F_C_NS_COLOR_KEY, data ) ) { bkg_f_c_ns_color_.setNamedColor( data.toString() ); } // txt f c ns txt_f_c_ns_color_ = DEFAULT_TXT_F_C_NS_COLOR; if( stt.read( VIEW_GROUP + TXT_F_C_NS_COLOR_KEY, data ) ) { txt_f_c_ns_color_.setNamedColor( data.toString() ); } // bkg nf c ns bkg_nf_c_ns_color_ = DEFAULT_BKG_NF_C_NS_COLOR; if( stt.read( VIEW_GROUP + BKG_NF_C_NS_COLOR_KEY, data ) ) { bkg_nf_c_ns_color_.setNamedColor( data.toString() ); } // txt nf c ns txt_nf_c_ns_color_ = DEFAULT_TXT_NF_C_NS_COLOR; if( stt.read( VIEW_GROUP + TXT_NF_C_NS_COLOR_KEY, data ) ) { txt_nf_c_ns_color_.setNamedColor( data.toString() ); } }
//******************************************************************* // save PRIVATE //******************************************************************* void QBtWorkspace::save() { QBtSettings stt; stt.save( QBtConfig::WORKSPACE_GROUP + QBtConfig::SPLITTER_KEY, splitter_->saveState() ); }