Guitar
Classes | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
SettingAiForm Class Reference

#include <SettingAiForm.h>

Inheritance diagram for SettingAiForm:
Inheritance graph
[legend]
Collaboration diagram for SettingAiForm:
Collaboration graph
[legend]

Classes

struct  Private
 
struct  ProviderFormData
 

Public Member Functions

 SettingAiForm (QWidget *parent=nullptr)
 コンストラクタ。UIを初期化し、プロバイダ一覧とAIモデルプリセット一覧をコンボボックスに追加する。 More...
 
 ~SettingAiForm ()
 デストラクタ。 More...
 
void exchange (bool save) override
 設定ファイルとフォームバッファの間でデータを同期する。 More...
 
- Public Member Functions inherited from AbstractSettingForm
 AbstractSettingForm (QWidget *parent=nullptr)
 
void reset (MainWindow *mw, ApplicationSettings *s)
 

Private Slots

void on_groupBox_generate_commit_message_by_ai_clicked (bool checked)
 AIによるコミットメッセージ生成のグループボックスがクリックされたとき。 有効化しようとした場合、クラウドへのデータ送信を警告するダイアログを表示する。 ユーザーがキャンセルすると有効化を取り消す。 More...
 
void on_lineEdit_api_key_textChanged (const QString &arg1)
 APIキー入力欄のテキスト変更時に呼ばれる。 環境変数モードのときは何もしない。ユーザー入力モードのときのみフォームバッファに書き込む。 More...
 
void on_radioButton_use_environment_value_clicked ()
 「環境変数を使用する」ラジオボタンが押されたとき、APIキー取得元を Environment に切り替える。 More...
 
void on_radioButton_use_custom_api_key_clicked ()
 「カスタムAPIキーを使用する」ラジオボタンが押されたとき、APIキー取得元を LocalSecret に切り替える。 More...
 
void on_comboBox_provider_currentIndexChanged (int index)
 AIプロバイダのコンボボックスの選択が変更されたとき、選択されたプロバイダに切り替える。 切り替え後、APIキーの取得元を示すラジオボタンの状態を更新する。 More...
 
void on_comboBox_ai_model_currentTextChanged (const QString &arg1)
 AIモデルのコンボボックスのテキストが変更されたとき、プロバイダを自動推定する。 More...
 

Private Member Functions

void reflectSettingsToUI ()
 現在選択中のプロバイダの状態をウィジェットに反映する。 More...
 
void changeProvider (GenerativeAI::ProviderID id)
 選択中プロバイダを切り替え、UIを更新する。 More...
 
void setRadioButtons (bool enabled, AiApiKeys::KeyFrom from)
 APIキーの取得元を選択するラジオボタンの状態を設定する。 More...
 
void configureModelByString (const std::string &model_uri)
 モデル名文字列でUIを設定し、プロバイダを自動推定する。 シグナルをブロックしないため、guessProviderFromModelName が連鎖的に呼ばれる。 More...
 
void configureModel (const GenerativeAI::Model &model)
 AIモデル情報をUIに反映する。 プロバイダが既知の場合はシグナルをブロックして直接設定し、 不明な場合はシグナル経由でプロバイダを自動推定させる。 More...
 
void guessProviderFromModelName (const std::string &s)
 モデル名文字列からプロバイダを推定し、プロバイダのコンボボックスを更新する。 推定できない場合(index < 1)はインデックス0(Unknown)にフォールバックする。 More...
 
SettingAiForm::ProviderFormDataformdata (GenerativeAI::ProviderID id)
 AIプロバイダIDに対応するフォームデータを返す。 More...
 
SettingAiForm::ProviderFormData const * formdata (GenerativeAI::ProviderID id) const
 
SettingAiForm::ProviderFormDataunknown_provider ()
 Unknown プロバイダのフォームデータを返す。 More...
 
SettingAiForm::ProviderFormDataformdata_by_env_name (const std::string &env_name)
 環境変数名に対応するフォームデータを返す。 More...
 
AiApiKeys::ItemcurrentKeyItem ()
 
AiApiKeys::KeyFrom keyFrom (GenerativeAI::ProviderID id) const
 指定されたAIプロバイダのAPIキーの取得元を返す。 More...
 
GenerativeAI::ModelURI currentModelURI () const
 

Private Attributes

Ui::SettingAiForm * ui
 
Privatem
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractSettingForm
MainWindowmainwindow ()
 
ApplicationSettingssettings ()
 

Constructor & Destructor Documentation

◆ SettingAiForm()

SettingAiForm::SettingAiForm ( QWidget *  parent = nullptr)
explicit

コンストラクタ。UIを初期化し、プロバイダ一覧とAIモデルプリセット一覧をコンボボックスに追加する。

Parameters
parent親ウィジェット
Here is the call graph for this function:

◆ ~SettingAiForm()

SettingAiForm::~SettingAiForm ( )

デストラクタ。

Member Function Documentation

◆ changeProvider()

void SettingAiForm::changeProvider ( GenerativeAI::ProviderID  id)
private

選択中プロバイダを切り替え、UIを更新する。

Parameters
id切り替え先のプロバイダのフォームデータ
Here is the call graph for this function:

◆ configureModel()

void SettingAiForm::configureModel ( const GenerativeAI::Model model)
private

AIモデル情報をUIに反映する。 プロバイダが既知の場合はシグナルをブロックして直接設定し、 不明な場合はシグナル経由でプロバイダを自動推定させる。

Parameters
model設定するAIモデル
Here is the call graph for this function:

◆ configureModelByString()

void SettingAiForm::configureModelByString ( const std::string &  model_uri)
private

モデル名文字列でUIを設定し、プロバイダを自動推定する。 シグナルをブロックしないため、guessProviderFromModelName が連鎖的に呼ばれる。

Parameters
model_uriモデル名文字列
Here is the call graph for this function:

◆ currentKeyItem()

AiApiKeys::Item * SettingAiForm::currentKeyItem ( )
private
Here is the call graph for this function:

◆ currentModelURI()

GenerativeAI::ModelURI SettingAiForm::currentModelURI ( ) const
private
Here is the call graph for this function:

◆ exchange()

void SettingAiForm::exchange ( bool  save)
overridevirtual

設定ファイルとフォームバッファの間でデータを同期する。

Parameters
savetrue のとき: フォームバッファ → 設定ファイル (OK ボタン押下時) false のとき: 設定ファイル → フォームバッファ (設定画面を開いたとき)

Implements AbstractSettingForm.

Here is the call graph for this function:

◆ formdata() [1/2]

SettingAiForm::ProviderFormData * SettingAiForm::formdata ( GenerativeAI::ProviderID  id)
private

AIプロバイダIDに対応するフォームデータを返す。

Parameters
id検索するプロバイダID
Returns
対応する ProviderFormData のポインタ。見つからない場合は nullptr。
Here is the call graph for this function:

◆ formdata() [2/2]

SettingAiForm::ProviderFormData const * SettingAiForm::formdata ( GenerativeAI::ProviderID  id) const
private
Here is the call graph for this function:

◆ formdata_by_env_name()

SettingAiForm::ProviderFormData * SettingAiForm::formdata_by_env_name ( const std::string &  env_name)
private

環境変数名に対応するフォームデータを返す。

Parameters
env_name検索する環境変数名(例: "OPENAI_API_KEY")
Returns
対応する ProviderFormData のポインタ。見つからない場合は nullptr。

◆ guessProviderFromModelName()

void SettingAiForm::guessProviderFromModelName ( const std::string &  s)
private

モデル名文字列からプロバイダを推定し、プロバイダのコンボボックスを更新する。 推定できない場合(index < 1)はインデックス0(Unknown)にフォールバックする。

Parameters
sモデル名文字列
Here is the call graph for this function:

◆ keyFrom()

AiApiKeys::KeyFrom SettingAiForm::keyFrom ( GenerativeAI::ProviderID  id) const
private

指定されたAIプロバイダのAPIキーの取得元を返す。

Parameters
idAIプロバイダID
Returns
APIキーの取得元を示す AiApiKeys::KeyFrom の値。プロバイダが見つからない場合は Default を返す。
Here is the call graph for this function:

◆ on_comboBox_ai_model_currentTextChanged

void SettingAiForm::on_comboBox_ai_model_currentTextChanged ( const QString &  arg1)
privateslot

AIモデルのコンボボックスのテキストが変更されたとき、プロバイダを自動推定する。

Here is the call graph for this function:

◆ on_comboBox_provider_currentIndexChanged

void SettingAiForm::on_comboBox_provider_currentIndexChanged ( int  index)
privateslot

AIプロバイダのコンボボックスの選択が変更されたとき、選択されたプロバイダに切り替える。 切り替え後、APIキーの取得元を示すラジオボタンの状態を更新する。

Here is the call graph for this function:

◆ on_groupBox_generate_commit_message_by_ai_clicked

void SettingAiForm::on_groupBox_generate_commit_message_by_ai_clicked ( bool  checked)
privateslot

AIによるコミットメッセージ生成のグループボックスがクリックされたとき。 有効化しようとした場合、クラウドへのデータ送信を警告するダイアログを表示する。 ユーザーがキャンセルすると有効化を取り消す。

◆ on_lineEdit_api_key_textChanged

void SettingAiForm::on_lineEdit_api_key_textChanged ( const QString &  arg1)
privateslot

APIキー入力欄のテキスト変更時に呼ばれる。 環境変数モードのときは何もしない。ユーザー入力モードのときのみフォームバッファに書き込む。

Here is the call graph for this function:

◆ on_radioButton_use_custom_api_key_clicked

void SettingAiForm::on_radioButton_use_custom_api_key_clicked ( )
privateslot

「カスタムAPIキーを使用する」ラジオボタンが押されたとき、APIキー取得元を LocalSecret に切り替える。

Here is the call graph for this function:

◆ on_radioButton_use_environment_value_clicked

void SettingAiForm::on_radioButton_use_environment_value_clicked ( )
privateslot

「環境変数を使用する」ラジオボタンが押されたとき、APIキー取得元を Environment に切り替える。

Here is the call graph for this function:

◆ reflectSettingsToUI()

void SettingAiForm::reflectSettingsToUI ( )
private

現在選択中のプロバイダの状態をウィジェットに反映する。

ApiKeyFrom::Environment の場合は実際に環境変数を読んでテキストフィールドに表示するが、 編集不可(setEnabled(false))にして読み取り専用として扱う。 ApiKeyFrom::LocalSecret の場合はフォームバッファの値を表示し、編集可能にする。

Here is the call graph for this function:

◆ setRadioButtons()

void SettingAiForm::setRadioButtons ( bool  enabled,
AiApiKeys::KeyFrom  from 
)
private

APIキーの取得元を選択するラジオボタンの状態を設定する。

Parameters
enabledtrue のとき両方のラジオボタンを有効化し、from に応じて選択状態を設定する。 false のとき両方を無効化する(Unknown プロバイダ選択時など)。
fromどちらのラジオボタンを選択するかを示す値。enabled が false のときは無視される。
Here is the call graph for this function:

◆ unknown_provider()

SettingAiForm::ProviderFormData * SettingAiForm::unknown_provider ( )
private

Unknown プロバイダのフォームデータを返す。

Returns
provider_formdata の先頭要素(Unknown プロバイダ)へのポインタ。
Note
provider_formdata の先頭要素が必ず Unknown プロバイダであることを前提とする。 コンストラクタの初期化リストの順序に依存しているため、変更時は注意。

Member Data Documentation

◆ m

Private* SettingAiForm::m
private

◆ ui

Ui::SettingAiForm* SettingAiForm::ui
private

The documentation for this class was generated from the following files: