OSDN Git Service

したらばJBBSの板検索のHTMLが変わっていたので対応した。
[gikonavigoeson/gikonavi.git] / Option.pas
index f5ff29c..83c6bda 100644 (file)
@@ -13,7 +13,7 @@ uses
        SHDocVw_TLB,
        MSHTML_TLB,
 {$IFEND}
-       BoardGroup;
+       BoardGroup, BrowserRecord;
 
 type
        TOptionDialog = class(TForm)
@@ -44,13 +44,13 @@ type
                 WriteProxyCheck: TCheckBox;
                 WriteProxyAddressEdit: TEdit;
                 WritePortEdit: TEdit;
-                WriteProxyUserIDEdit: TEdit;
-                WriteProxyPasswordEdit: TEdit;
+                               WriteProxyUserIDEdit: TEdit;
+                               WriteProxyPasswordEdit: TEdit;
                 Font1Sheet: TTabSheet;
                 Bevel1: TBevel;
                 Bevel2: TBevel;
                 Label19: TLabel;
-                Bevel5: TBevel;
+                               Bevel5: TBevel;
                 Label20: TLabel;
                 Label21: TLabel;
                 Label22: TLabel;
@@ -116,10 +116,7 @@ type
                 OpenMailerCheckBox: TCheckBox;
                 GroupBox6: TGroupBox;
                 LogDeleteMessageCheckBox: TCheckBox;
-                ResAnchorGroupBox: TGroupBox;
-                ResAnchorCheckBox: TCheckBox;
                 TabSheet1: TTabSheet;
-                PopupPositionRadioGroup: TRadioGroup;
                TabAddRadioGroup: TRadioGroup;
                 GroupBox8: TGroupBox;
                 Label14: TLabel;
@@ -201,6 +198,27 @@ type
     Label18: TLabel;
     UnFocusedBoldCheckBox: TCheckBox;
     IgnoreKanaCheckBox: TCheckBox;
+    UseKatjuTypeSkinCheckBox: TCheckBox;
+    GroupBox20: TGroupBox;
+    AutoSortCheckBox: TCheckBox;
+    Label24: TLabel;
+    GroupBox21: TGroupBox;
+    StoredTaskTrayCB: TCheckBox;
+    GroupBox22: TGroupBox;
+    LoopBrowserTabsCB: TCheckBox;
+    GroupBox23: TGroupBox;
+    IgnoreContextCheckBox: TCheckBox;
+    GroupBox24: TGroupBox;
+    gppRightTopRB: TRadioButton;
+    gppTopRB: TRadioButton;
+    gppLeftTopRB: TRadioButton;
+    gppLeftRB: TRadioButton;
+    gppRightRB: TRadioButton;
+    gppLeftBottomRB: TRadioButton;
+    gppBottomRB: TRadioButton;
+    gppRighBottomRB: TRadioButton;
+    ResAnchorCheckBox: TCheckBox;
+    IgnoreLimitResCountCheckBox: TCheckBox;
                procedure FormCreate(Sender: TObject);
                procedure FormDestroy(Sender: TObject);
                procedure ApplyButtonClick(Sender: TObject);
@@ -267,6 +285,10 @@ type
                procedure SetAbonpropertys;
                procedure CSSSetContent(Content: string);
                procedure CSSPreview;
+               //! CSS\83v\83\8c\83r\83\85\81[\97pHTMLBody\90\90¬
+               function CreatePreviewBody(Res: array of TResRec): string;
+               //! CSS/SKIN\83v\83\8c\83r\83\85\81[\97pStyle\95\8e\9a\97ñ\8eæ\93¾
+               function GetPreviewUserStyle(): string;
        public
                { Public \90é\8c¾ }
        end;
@@ -291,6 +313,7 @@ const
        DEFAULT_TABFONT_NAME: string = '\82l\82\82o\83S\83V\83b\83N';
        DEFAULT_TABFONT_SIZE: Integer = 9;
        URL_TORA3: WideString = 'http://2ch.tora3.net/';
+       DEFAULT_CSS_FILENAME = 'default.css';
 
 {$R *.DFM}
 
@@ -352,7 +375,7 @@ begin
                FClose := False;
                Exit;
        end;
-        SetAbonpropertys;
+               SetAbonpropertys;
        SaveSetting;
        SettingApply;
 
@@ -615,6 +638,8 @@ begin
        EditorMemo.Color := GikoSys.Setting.EditorBackColor;
        //CSS\95\\8e¦
        CSSCheckBox.Checked := GikoSys.Setting.UseCSS;
+       //\82©\82¿\82ã\83X\83L\83\93\8eg\97p
+       UseKatjuTypeSkinCheckBox.Checked := GikoSys.Setting.UseKatjushaType;
        if FCSSFont <> nil then
                FCSSFont.Free;
        FCSSFont := TFont.Create;
@@ -655,7 +680,7 @@ begin
                FileList.Sort;
                for i := 0 to FileList.Count - 1 do begin
                        //s := ExtractFileName(FileList[i]);
-                       if LowerCase(FileList[i]) = 'default.css' then
+                       if LowerCase(FileList[i]) = DEFAULT_CSS_FILENAME then
                                Item := CSSListView.Items.Insert(0)
                        else
                                Item := CSSListView.Items.Add;
@@ -741,6 +766,8 @@ begin
 
        //\83\8d\83O\8dí\8f\9c\8e\9e\83\81\83b\83Z\81[\83W
        LogDeleteMessageCheckBox.Checked := GikoSys.Setting.DeleteMsg;
+    //\93¯ID\83\8c\83X\83A\83\93\83J\81[\95\\8e¦\82Ì\90§\8cÀ\90\94\89z\82¦\83\81\83b\83Z\81[\83W
+    IgnoreLimitResCountCheckBox.Checked := GikoSys.Setting.LimitResCountMessage;
 
        //\8fI\97¹\8e\9e\8am\94F\83_\83C\83A\83\8d\83O
        ShowDialogForEndCheckBox.Checked := GikoSys.Setting.ShowDialogForEnd;
@@ -753,15 +780,15 @@ begin
        BrowserMaxCombo.ItemIndex := Ord( GikoSys.Setting.BrowserAutoMaximize );
        //\83|\83b\83v\83A\83b\83v\88Ê\92u
        case GikoSys.Setting.PopupPosition of
-               gppRightTop:            PopupPositionRadioGroup.ItemIndex := 0;
-               gppRight:                       PopupPositionRadioGroup.ItemIndex := 1;
-               gppRightBottom: PopupPositionRadioGroup.ItemIndex := 2;
-               gppTop:                                 PopupPositionRadioGroup.ItemIndex := 3;
-               gppCenter:                      PopupPositionRadioGroup.ItemIndex := 4;
-               gppBottom:                      PopupPositionRadioGroup.ItemIndex := 5;
-               gppLeftTop:             PopupPositionRadioGroup.ItemIndex := 6;
-               gppLeft:                                PopupPositionRadioGroup.ItemIndex := 7;
-               gppLeftBottom:  PopupPositionRadioGroup.ItemIndex := 8;
+               gppRightTop:            gppRightTopRB.Checked := True;
+               gppRight:                       gppRightRB.Checked := True;
+               gppRightBottom:     gppRighBottomRB.Checked := True;
+               gppTop:                         gppTopRB.Checked := True;
+               gppCenter:                      gppTopRB.Checked := True; // \93Ç\82Ý\8d\9e\82Ý\82Å\95Ï\8a·\82µ\82Ä\82é\82Í\82¸
+               gppBottom:                      gppBottomRB.Checked := True;
+               gppLeftTop:             gppLeftTopRB.Checked := True;
+               gppLeft:                        gppLeftRB.Checked := True;
+               gppLeftBottom:      gppLeftBottomRB.Checked := True;
        end;
 
        //\94ñ\83A\83N\83e\83B\83u\8e\9e\83|\83b\83v\83A\83b\83v\95\\8e¦
@@ -818,7 +845,8 @@ begin
        else
                DatOchiSortCombo.ItemIndex := 0;
        end;
-
+       AutoSortCheckBox.Checked := GikoSys.Setting.AutoSortThreadList;
+       
        //\82 \82Ú\81`\82ñ
        RloCheckBox.Checked := GikoSys.Setting.AbonDeleterlo;
        ReplaceulCheckBox.Checked := GikoSys.Setting.AbonReplaceul;
@@ -852,6 +880,12 @@ begin
        BeAutoLoginCheckBox.Checked := GikoSys.Setting.BeAutoLogin;
        //\97\9a\97ð\82Ì\8dÅ\91å\95Û\91\90\94
        MaxRecordCountEdit.Text := IntToStr(GikoSys.Setting.MaxRecordCount);
+    // \8dÅ\8f¬\89»\8e\9e\82É\83^\83X\83N\83g\83\8c\83C\82É\8ai\94[\82·\82é\82©
+    StoredTaskTrayCB.Checked := GikoSys.Setting.StoredTaskTray;
+    // \83u\83\89\83E\83U\83^\83u\82Ì\88Ú\93®\82Å\83\8b\81[\83v\82ð\8b\96\89Â\82·\82é\82©
+    LoopBrowserTabsCB.Checked := GikoSys.Setting.LoopBrowserTabs;
+    //
+    IgnoreContextCheckBox.Checked := GikoSys.Setting.GestureIgnoreContext;
 end;
 
 procedure TOptionDialog.SaveSetting;
@@ -912,9 +946,10 @@ begin
        //CSS\95\\8e¦
        if GikoSys.Setting.UseCSS <> CSSCheckBox.Checked then FRepaintThread := true;
        GikoSys.Setting.UseCSS := CSSCheckBox.Checked;
+       GikoSys.Setting.UseKatjushaType := UseKatjuTypeSkinCheckBox.Checked;
        //CSS\83t\83@\83C\83\8b\96¼
        tmp := GikoSys.Setting.CSSFileName;
-       GikoSys.Setting.CSSFileName := 'default.css';
+       GikoSys.Setting.CSSFileName := DEFAULT_CSS_FILENAME;
        if CSSListView.Items.Count > 0 then begin
                try
                        if CSSListView.Items[CSSListView.ItemIndex].Data <> nil then
@@ -998,6 +1033,8 @@ begin
 
        GikoSys.Setting.OpenMailer := OpenMailerCheckBox.Checked;
        GikoSys.Setting.DeleteMsg := LogDeleteMessageCheckBox.Checked;
+    GikoSys.Setting.LimitResCountMessage := IgnoreLimitResCountCheckBox.Checked;
+
        //\8fI\97¹\8e\9e\8am\94F\83_\83C\83A\83\8d\83O
        GikoSys.Setting.ShowDialogForEnd := ShowDialogForEndCheckBox.Checked;
        //AllTabClose
@@ -1008,18 +1045,14 @@ begin
        // \83u\83\89\83E\83U\8dÅ\91å\89»
        GikoSys.Setting.BrowserAutoMaximize := TGikoBrowserAutoMaximize( BrowserMaxCombo.ItemIndex );
        //\83|\83b\83v\83A\83b\83v\88Ê\92u
-       case PopupPositionRadioGroup.ItemIndex of
-               0: GikoSys.Setting.PopupPosition := gppRightTop;
-               1: GikoSys.Setting.PopupPosition := gppRight;
-               2: GikoSys.Setting.PopupPosition := gppRightBottom;
-               3: GikoSys.Setting.PopupPosition := gppTop;
-               4: GikoSys.Setting.PopupPosition := gppCenter;
-               5: GikoSys.Setting.PopupPosition := gppBottom;
-               6: GikoSys.Setting.PopupPosition := gppLeftTop;
-               7: GikoSys.Setting.PopupPosition := gppLeft;
-               8: GikoSys.Setting.PopupPosition := gppLeftBottom;
-       end;
-
+    if (gppRightTopRB.Checked) then GikoSys.Setting.PopupPosition := gppRightTop;
+    if (gppRightRB.Checked) then GikoSys.Setting.PopupPosition := gppRight;
+    if (gppRighBottomRB.Checked) then GikoSys.Setting.PopupPosition := gppRightBottom;
+    if (gppTopRB.Checked) then GikoSys.Setting.PopupPosition := gppTop;
+    if (gppBottomRB.Checked) then GikoSys.Setting.PopupPosition := gppBottom;
+    if (gppLeftTopRB.Checked) then GikoSys.Setting.PopupPosition := gppLeftTop;
+    if (gppLeftRB.Checked) then GikoSys.Setting.PopupPosition := gppLeft;
+    if (gppLeftBottomRB.Checked) then GikoSys.Setting.PopupPosition := gppLeftBottom;
        //\94ñ\83A\83N\83e\83B\83u\8e\9e\83|\83b\83v\83A\83b\83v\95\\8e¦
        GikoSys.Setting.UnActivePopup := UnActivePopupCheckBox.Checked;
        //\83\8c\83X\83|\83b\83v\83A\83b\83v\83{\81[\83\8b\83h\95\\8e¦
@@ -1094,6 +1127,7 @@ begin
                        GikoSys.Setting.DatOchiSortIndex := Ord( gbcLastModified );{gbcLastModified}
                        end;
        end;
+       GikoSys.Setting.AutoSortThreadList := AutoSortCheckBox.Checked;
 
        GikoSys.Setting.WriteSystemSettingFile;
        GikoSys.Setting.WriteBoardURLSettingFile;
@@ -1137,6 +1171,10 @@ begin
                GikoSys.Setting.BeAutoLogin := BeAutoLoginCheckBox.Checked;
        //\97\9a\97ð\82Ì\8dÅ\91å\95Û\91\90\94
        GikoSys.Setting.MaxRecordCount := Max(StrToInt64Def(MaxRecordCountEdit.Text,100),1);
+    GikoSys.Setting.StoredTaskTray := StoredTaskTrayCB.Checked;
+    GikoSys.Setting.LoopBrowserTabs := LoopBrowserTabsCB.Checked;
+
+    GikoSys.Setting.GestureIgnoreContext := IgnoreContextCheckBox.Checked;
 end;
 
 procedure TOptionDialog.SettingApply;
@@ -1249,7 +1287,7 @@ end;
 function TOptionDialog.CheckFolder: Boolean;
 begin
        if Trim(LogFolderEdit.Text) = '' then
-               LogFolderEdit.Text := ExtractFilePath(Application.ExeName) + 'Log';
+               LogFolderEdit.Text := GikoSys.GetAppDir + 'Log';
 
        if DirectoryExists(LogFolderEdit.Text) then begin
                Result := True;
@@ -1287,13 +1325,19 @@ begin
 end;
 
 procedure TOptionDialog.SoundPlayButtonClick(Sender: TObject);
+var
+    s : String;
 begin
-       if not FileExists(SoundFileEdit.Text) then begin
+    s := SoundFileEdit.Text;
+    if (AnsiPos('.\', s) = 1) then begin
+        s := GikoSys.Setting.GetAppDir + Copy(s, 2, Length(s));
+    end;
+       if not FileExists(s) then begin
                MsgBox(Handle, '\91\8dÝ\82µ\82È\82¢\83t\83@\83C\83\8b\82Å\82·', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
                SoundFileEdit.Text := '';
                Exit;
        end;
-       if not sndPlaySound(PChar(SoundFileEdit.Text), SND_ASYNC or SND_NOSTOP) then begin
+       if not sndPlaySound(PChar(s), SND_ASYNC or SND_NOSTOP) then begin
                sndPlaySound(nil, SND_ASYNC);
        end;
 end;
@@ -1454,12 +1498,12 @@ end;
 
 procedure TOptionDialog.CSSSetContent(Content: string);
 var
-       doc : Variant;
+       doc : OleVariant;
 begin
        if CSSBrowser.Document <> nil then begin
-               doc := CSSBrowser.Document;
+               doc := CSSBrowser.OleObject.Document;
                doc.open;
-                               doc.Clear;
+        doc.Clear;
                doc.charset := 'Shift_JIS';
                doc.Write(Content);
                doc.Close;
@@ -1472,14 +1516,12 @@ var
        ThreadItem: TThreadItem;
        html: string;
        Res: array [0..1] of TResRec;
-       UserOptionalStyle: string;
-       i: Integer;
        fileName: string;
 begin
 
        fileName := GikoSys.Setting.CSSFileName;
 
-       GikoSys.Setting.CSSFileName := 'default.css';
+       GikoSys.Setting.CSSFileName := DEFAULT_CSS_FILENAME;
        if CSSListView.Items.Count > 0 then begin
                try
                        if CSSListView.ItemIndex >= 0 then begin
@@ -1487,7 +1529,7 @@ begin
                                        GikoSys.Setting.CSSFileName := string( CSSListView.Items[CSSListView.ItemIndex].data )
                                else
                                        GikoSys.Setting.CSSFileName := CSSListView.Items[CSSListView.ItemIndex].Caption + '.css';
-                        end;
+                                               end;
                except
                end;
        end;
@@ -1512,66 +1554,27 @@ begin
                Res[1].FDateTime := 'ID:Sample';
                Res[1].FBody := '\83I\83}\83G\83\82\83i\81[';
 
-               // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
-               if CSSFontCheckBox.Checked then begin
-                       i := ColorToRGB( FCSSFont.Color );
-                       i := (i shr 16) or (i and $ff00) or ((i and $ff) shl 16);
-
-                       UserOptionalStyle := UserOptionalStyle +
-                               'font-family:"' + FCSSFont.Name + '";' +
-                               'font-size:' + IntToStr( FCSSFont.Size ) + 'pt;' +
-                               'color:#' + IntToHex( i, 6 ) + ';';
-                       if fsBold in FCSSFont.Style then
-                               UserOptionalStyle := UserOptionalStyle + 'font-weight:bold;'
-                       else
-                               UserOptionalStyle := UserOptionalStyle + 'font-weight:normal;';
-                       if fsItalic in FCSSFont.Style then
-                               UserOptionalStyle := UserOptionalStyle + 'font-style:italic;'
-                       else
-                               UserOptionalStyle := UserOptionalStyle + 'font-style:normal;';
-               end;
-               if CSSBackColorCheckBox.Checked then begin
-                       i := ColorToRGB( FCSSBackColor );
-                       i := (i shr 16) or (i and $ff00) or ((i and $ff) shl 16);
-
-                       UserOptionalStyle := UserOptionalStyle +
-                               'background-color:#' + IntToHex( i, 6 ) + ';';
-               end;
 
                if FileExists( GikoSys.GetSkinHeaderFileName ) then begin
                        html :=
                                HTMLCreater.LoadFromSkin( GikoSys.GetSkinHeaderFileName, ThreadItem, 0 ) +
                                '<a name="top"></a>' +
-                               HTMLCreater.SkinedRes( HTMLCreater.LoadFromSkin( GikoSys.GetSkinResFileName, ThreadItem, 0 ), Res[0], '1' ) +
-                               HTMLCreater.SkinedRes( HTMLCreater.LoadFromSkin( GikoSys.GetSkinNewResFileName, ThreadItem, 0 ), Res[1], '2' ) +
+                               HTMLCreater.SkinedRes( HTMLCreater.LoadFromSkin( GikoSys.GetSkinResFileName, ThreadItem, 0 ), @Res[0], '1' ) +
+                               HTMLCreater.SkinedRes( HTMLCreater.LoadFromSkin( GikoSys.GetSkinNewResFileName, ThreadItem, 0 ), @Res[1], '2' ) +
                                '<a name="bottom"></a>' +
                                HTMLCreater.LoadFromSkin( GikoSys.GetSkinFooterFileName, ThreadItem, 0 );
 
                        html := StringReplace( html, '</head>',
-                               '<style type="text/css">body {' + UserOptionalStyle + '}</style></head>', [rfReplaceAll] );
+                               '<style type="text/css">body {' + GetPreviewUserStyle + '}</style></head>', [rfReplaceAll] );
                end else begin
                        html :=
-                               '<html><head>' +
-                               '<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">' +
+                               '<html><head><meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">' +
                                '<title>' + ThreadItem.Title + '</title>' +
                                '<link rel="stylesheet" href="' + GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName + '" type="text/css">' +
-                               '<style type="text/css">body {' + UserOptionalStyle + '}</style>' +
-                               '</head><body>' +
-                               '<div class="title">' + ThreadItem.Title + '</div>';
-
-                               for i := 0 to High( Res ) do
-                               begin
-                                       html := html +
-                                               '<div class="header"><span class="no">' + IntToStr( i + 1 ) + '</span>' +
-                                               '<span class="name_label"> \96¼\91O\81F </span>' +
-                                               '<a class="name_mail" href="mailto:' + Res[i].FMailTo + '">' +
-                                               '<b>' + Res[i].FName + '</b></a><span class="mail"> [' + Res[i].FMailTo + ']</span>' +
-                                               '<span class="date_label"> \93\8a\8de\93ú\81F</span>' +
-                                               '<span class="date"> ' + Res[i].FDateTime+ '</span></div>' +
-                                               '<div class="mes">' + Res[i].FBody + ' </div>';
-                               end;
-
-                               html := html + '</body></html>';
+                               '<style type="text/css">body {' + GetPreviewUserStyle + '}</style>' +
+                               '</head><body><div class="title">' + ThreadItem.Title + '</div>';
+
+                       html := html + CreatePreviewBody(Res) + '</body></html>';
                end;
 
                try
@@ -1586,7 +1589,57 @@ begin
        end;
 
 end;
+function TOptionDialog.CreatePreviewBody(Res: array of TResRec): string;
+var
+       i : Integer;
+begin
+       Result := '';
+       for i := 0 to High( Res ) do
+       begin
+               Result := Result +
+                       '<div class="header"><span class="no">' + IntToStr( i + 1 ) + '</span>' +
+                       '<span class="name_label"> \96¼\91O\81F </span>' +
+                       '<a class="name_mail" href="mailto:' + Res[i].FMailTo + '">' +
+                       '<b>' + Res[i].FName + '</b></a><span class="mail"> [' + Res[i].FMailTo + ']</span>' +
+                       '<span class="date_label"> \93\8a\8de\93ú\81F</span>' +
+                       '<span class="date"> ' + Res[i].FDateTime+ '</span></div>' +
+                       '<div class="mes">' + Res[i].FBody + ' </div>';
+       end;
+end;
+
+function TOptionDialog.GetPreviewUserStyle(): string;
+var
+       i : Integer;
+
+begin
+       Result := '';
+       // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
+       if CSSFontCheckBox.Checked then begin
+               i := ColorToRGB( FCSSFont.Color );
+               i := (i shr 16) or (i and $ff00) or ((i and $ff) shl 16);
+
+               Result := Result +
+                       'font-family:"' + FCSSFont.Name + '";' +
+                       'font-size:' + IntToStr( FCSSFont.Size ) + 'pt;' +
+                       'color:#' + IntToHex( i, 6 ) + ';';
+               if fsBold in FCSSFont.Style then
+                       Result := Result + 'font-weight:bold;'
+               else
+                       Result := Result + 'font-weight:normal;';
+               if fsItalic in FCSSFont.Style then
+                       Result := Result + 'font-style:italic;'
+               else
+                       Result := Result + 'font-style:normal;';
+       end;
+       if CSSBackColorCheckBox.Checked then begin
+               i := ColorToRGB( FCSSBackColor );
+               i := (i shr 16) or (i and $ff00) or ((i and $ff) shl 16);
+
+               Result := Result +
+                       'background-color:#' + IntToHex( i, 6 ) + ';';
+       end;
 
+end;
 procedure TOptionDialog.CSSListViewChange(Sender: TObject; Item: TListItem;
        Change: TItemChange);
 begin