OSDN Git Service

スレタイの[転載禁止]と「©2ch.net」を非表示にする機能を追加
[gikonavigoeson/gikonavi.git] / Giko.pas
index aa24b80..401b11d 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -84,6 +84,7 @@ type
                ToolMenu: TMenuItem;
                Find1: TMenuItem;
                RoundMenu: TMenuItem;
+               Search1: TMenuItem;
                MMSep04: TMenuItem;
                OptionMenu: TMenuItem;
                HelpMenu: TMenuItem;
@@ -426,6 +427,9 @@ type
     URLPATHINFO1: TMenuItem;
     URLQUERYSTRING1: TMenuItem;
     N86: TMenuItem;
+    K4: TMenuItem;
+    WikiFAQ1: TMenuItem;
+    ThrNGEdit: TMenuItem;
                                procedure FormCreate(Sender: TObject);
                procedure FormDestroy(Sender: TObject);
         procedure SaveSettingAll();
@@ -616,6 +620,7 @@ type
         FUpdateExePath: string;    ///\83M\83R\83i\83r\8dX\90V\83C\83\93\83X\83g\81[\83\89\83p\83X
         FUpdateExeArgs: string;    ///\83M\83R\83i\83r\8dX\90V\83C\83\93\83X\83g\81[\83\89\88ø\90\94
         FKokoPopupThreadItem: TThreadItem;
+        FCwSave: Word;  // 8087CW\92l\95Û\91
                procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
                procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
                procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
@@ -708,6 +713,8 @@ type
         procedure LoadIcon();
         //! \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\93Ç\82Ý\8d\9e\82Ý
         procedure LoadPopupMenu();
+        //! \83X\83\8c\83^\83C\8eæ\93¾
+        function GetThreadTitle(OrgTitle: String): String;
        protected
                procedure CreateParams(var Params: TCreateParams); override;
                procedure WndProc(var Message: TMessage); override;
@@ -747,7 +754,7 @@ type
                property WorkCount: Integer read FWorkCount write FWorkCount;
         property UpdateExePath: string read FUpdateExePath write FUpdateExePath;
         property UpdateExeArgs: string read FUpdateExeArgs write FUpdateExeArgs;
-        
+
                procedure SetContent(inThread: TBrowserRecord);
                function GetActiveContent(popup :Boolean = false): TThreadItem;
                function GetActiveList: TObject;
@@ -842,6 +849,8 @@ type
         procedure StoredTaskTray;
         //! \93¯ID\83\8c\83X\83A\83\93\83J\81[\95\\8e¦
         procedure ShowSameIDAncher(const AID: String);
+        //! \83X\83\8c\83^\83C\95\\8e¦\8dX\90V
+        procedure UpdateThreadTitle;
        published
                property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
        end;
@@ -869,6 +878,7 @@ type
 
 var
        GikoForm: TGikoForm;
+    g_AppTerminated: Boolean = False;
 
 implementation
 
@@ -929,6 +939,12 @@ begin
        Writeln('============================================================');
 {$ENDIF}
 //try
+    // \83[\83\8d\8a\84\97á\8aO\82Ì\8c»\8dÝ\82Ì\90Ý\92è\82ð\95Û\91\82·\82é
+    FCwSave := Get8087CW;
+    if ( AnsiPos('9.0', GikoSys.GetIEVersion()) = 1 ) then begin
+        // IE 9\82Ì\8fê\8d\87\82¾\82¯\81A\96³\8cø\83r\83b\83g\82ð\97§\82Ä\82é
+        Set8087CW(FCwSave or $0004);
+    end;
        Sort.SetSortDate(Now());
 
        FTreeType := gttNone;
@@ -1111,6 +1127,9 @@ begin
        ProgressBar.Height := StatusBar.Height - 2;
        ProgressBar.Position := 0;
 
+    // \83X\83\8c\83b\83h\96¼NG\83\8a\83X\83g
+    ThreadNgList := TThreadNgList.Create;
+
        // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
        InitializeBoardPlugIns;
 
@@ -1335,7 +1354,8 @@ begin
        if GikoSys.Setting.AutoLogin then
                GikoDM.LoginAction.Execute;
 
-       GikoSys.Setting.BeLogin := GikoSys.Setting.BeAutoLogin;
+    if GikoSys.Setting.BeAutoLogin then
+        GikoDM.BeLogInOutAction.Execute;
 
        //\83L\83\83\83v\83V\83\87\83\93\82ª\8fã\8f\91\82«\82³\82ê\82Ä\82µ\82Ü\82¤\82Ì\82Å\81A\82±\82±\82Å\8dÄ\90Ý\92è
        FavoriteAddToolButton.Caption := '\92Ç\89Á...';
@@ -1487,6 +1507,12 @@ end;
 procedure TGikoForm.FormShow(Sender: TObject);
 var
        item        : TThreadItem;
+    MonCnt: Integer;
+    MonOk: Boolean;
+    MonR: Integer;
+    MonB: Integer;
+    Right: Integer;
+    Bottom: Integer;
 begin
        if FStartUp then begin
        FStartUp := false;
@@ -1539,6 +1565,42 @@ begin
                 //ShowWindow(Self.Handle, SW_SHOW);
             end;
                end;
+
+//===== \83}\83\8b\83`\83\82\83j\83^\8aÂ\8b«\82ÅFormCreate\82Å\82Í\83t\83H\81[\83\80\88Ê\92u\82ª\90³\82µ\82­\94½\89f\82³\82ê\82È\82¢\8fê\8d\87
+//===== \82ª\82 \82é\82½\82ßFormShow\8f\89\89ñ\82Å\8dÀ\95W\90Ý\92è\82ð\8ds\82¤
+        Top := GikoSys.Setting.WindowTop;
+        Left := GikoSys.Setting.WindowLeft;
+        Height := GikoSys.Setting.WindowHeight;
+        Width := GikoSys.Setting.WindowWidth;
+
+        //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
+        Right := Left + Width;
+        Bottom := Top + Height;
+        MonOk := False;
+        MonCnt := 0;
+        while (MonCnt < Screen.MonitorCount) do begin
+            MonR := Screen.Monitors[MonCnt].Left + Screen.Monitors[MonCnt].Width;
+            MonB := Screen.Monitors[MonCnt].Top  + Screen.Monitors[MonCnt].Height;
+
+            if ((Left  >= Screen.Monitors[MonCnt].Left) and (Left   <  MonR) and
+                (Top   >= Screen.Monitors[MonCnt].Top)  and (Top    <  MonB) and
+                (Right  > Screen.Monitors[MonCnt].Left) and (Right  <= MonR) and
+                (Bottom > Screen.Monitors[MonCnt].Top)  and (Bottom <= MonB)) then begin
+                MonOk := True;
+                Break;
+            end;
+
+            MonCnt := MonCnt + 1;
+        end;
+
+        if (MonOk = False) then begin
+            Left := 0;
+            Top := 0;
+        end;
+
+        if GikoSys.Setting.WindowMax then
+            WindowState := wsMaximized;
+//==========================================================================
        end;
 end;
 
@@ -1553,6 +1615,8 @@ begin
                        Exit;
        end;
 
+    g_AppTerminated := True;
+
     GikoSys.Setting.LastCloseTabURL := '';
        if GikoSys.Setting.TabAutoLoadSave then begin
                GikoDM.TabsSaveAction.Execute;
@@ -1583,7 +1647,7 @@ begin
 
     //OnDestory\82¾\82Æ\8dÄ\8bN\93®\82ð\82©\82¯\82½\82Æ\82«\82È\82Ç\82É\95Û\91\82³\82ê\82È\82¢\82Ì\82ÅOnCloseQuery\82Å\90Ý\92è\95Û\91
     SaveSettingAll();
-    
+
        Application.Terminate;
 end;
 
@@ -1593,6 +1657,11 @@ var
     WindowPlacement: TWindowPlacement;
 begin
        try
+               GikoDM.SaveThreadSearchSetting;
+       except
+       end;
+
+       try
                ActiveListColumnSave;
        except
        end;
@@ -1807,6 +1876,8 @@ begin
        except
        end;
 
+    ThreadNgList.Free;
+
        try
                if FEvent <> nil then
                        FEvent.Free;
@@ -1832,6 +1903,8 @@ begin
         // \83A\83b\83v\83f\81[\83g\8eÀ\8ds
         GikoSys.CreateProcess(FUpdateExePath, FUpdateExeArgs);
     end;
+    // \83[\83\8d\8a\84\97á\8aO\82ð\8c³\82É\96ß\82·
+    Set8087CW(FCwSave);
 end;
 
 // \8ae\8f\8a\82É\82 \82é\83L\83\83\83r\83l\83b\83g\81E BBS \83\81\83j\83\85\81[\82ð\83Z\83b\83g\81^\8dX\90V
@@ -2063,7 +2136,7 @@ begin
 
     if FResPopupBrowser <> nil then begin
         if not(Sender is TResPopupBrowser) then begin
-            if (FResPopupBrowser.Visible) then begin
+            if ((doc <> nil) and (FResPopupBrowser.Visible)) then begin
                 if ResPopupClearTimer.Interval > 0 then begin
                     ResPopupClearTimer.Enabled := True;
                     ResPopupClearTimer.Tag := 0;
@@ -2097,7 +2170,8 @@ begin
     end;
        s := '';
        Ext := AnsiLowerCase(ExtractFileExt(Text2));
-       if (Pos('http://', Text2) = 1) and (GikoSys.Setting.PreviewVisible) and
+//     if (Pos('http://', Text2) = 1) and (GikoSys.Setting.PreviewVisible) and
+       if ((Pos('http://', Text2) = 1) or (Pos('https://', Text2) = 1)) and (GikoSys.Setting.PreviewVisible) and
                        ((Ext = '.jpg') or (Ext = '.jpeg') or (Ext = '.gif') or (Ext = '.png')) or
         (Pos('http://www.nicovideo.jp/watch/', Text2) = 1)  then begin
                if FPreviewBrowser = nil then begin
@@ -2998,7 +3072,7 @@ begin
                if (Thread <> nil) and (ThreadItem <>nil) then begin
                        BrowserBoardNameLabel.Caption := ThreadPTitle;
                        ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
-                       BrowserNameLabel.Caption := ThreadTitle;
+            BrowserNameLabel.Caption := GetThreadTitle(ThreadTitle);
                        ItemImage.Picture := nil;
                        if ThreadIsLog then
                                if ThreadNewArraical then
@@ -3031,7 +3105,7 @@ begin
                                
                        end;
                end else begin
-                       Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + ThreadTitle + ']';
+                       Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + GetThreadTitle(ThreadTitle) + ']';
                        //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
                        StatusBar.Panels[THREADSIZE_PANEL].Text := Format('%6.2f kB', [ThreadItem.Size / 1024]);
                        StatusBar.Panels[THREADSIZE_PANEL].Width :=
@@ -3094,7 +3168,7 @@ begin
                if (FActiveContent <> nil) and (FActiveContent.Thread <> nil)
                        and (FActiveContent.Thread.IsLogFile) then begin
                        try
-                               Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + FActiveContent.Thread.Title + ']'
+                               Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + GetThreadTitle(FActiveContent.Thread.Title) + ']'
                        except
                                on E: Exception do begin
                                        //\83X\83\8c\88ê\97\97DL\8cã\82È\82Ç\82ÉFActiveContent\82Ì\8e\9d\82ÂThread\82ª
@@ -5283,8 +5357,7 @@ begin
        SenderNode.Selected := False;
        FavoriteDragDrop( SenderNode, Source );
 
-       SetLinkBar;
-
+       PostMessage( Handle, USER_SETLINKBAR, 0, 0 );
 end;
 
 procedure TGikoForm.LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
@@ -8095,6 +8168,53 @@ begin
             GikoSys.Setting.GetAppDir + ICONTOOL, clPurple);
     end;
 end;
+
+//! \83X\83\8c\83^\83C\95\\8e¦\8dX\90V
+procedure TGikoForm.UpdateThreadTitle;
+var
+       i: Integer;
+    DspTitle: String;
+begin
+    BrowserTab.Tabs.BeginUpdate;
+    for i := 0 to BrowserTab.Tabs.Count - 1 do begin
+        BrowserTab.Tabs.Strings[i] :=
+            GikoSys.GetShortName(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.Title, 20);
+    end;
+    BrowserTab.Tabs.EndUpdate;
+
+    if (FActiveContent <> nil) and (FActiveContent.Thread <> nil) then begin
+        DspTitle := GetThreadTitle(FActiveContent.Thread.Title);
+        BrowserNameLabel.Caption := DspTitle;
+        Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + DspTitle + ']';
+    end;
+end;
+
+//! \83X\83\8c\83^\83C\8eæ\93¾
+function TGikoForm.GetThreadTitle(OrgTitle: String): String;
+var
+    Idx: Integer;
+    ResTitle: String;
+begin
+    if (GikoSys.Setting.ThreadTitleTrim = False) then begin
+        Result := OrgTitle;
+    end else begin
+        ResTitle := OrgTitle;
+        while (True) do begin
+            Idx := Pos('[\93]\8dÚ\8bÖ\8e~]', ResTitle);
+            if (Idx < 1) then
+                Break;
+            Delete(ResTitle, Idx, 10);
+        end;
+        while (True) do begin
+            Idx := Pos('&copy;2ch.net', ResTitle);
+            if (Idx < 1) then
+                Break;
+            Delete(ResTitle, Idx, 13);
+        end;
+        Result := Trim(ResTitle);
+    end;
+end;
+
 //! \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\93Ç\82Ý\8d\9e\82Ý
 procedure TGikoForm.LoadPopupMenu();
 begin