Skip to content
/ zlog Public
forked from jr8ppg/zLog

Commit 4b97ee9

Browse files
committed
package stability
1 parent e38b984 commit 4b97ee9

File tree

4 files changed

+95
-91
lines changed

4 files changed

+95
-91
lines changed

zlog/UPackageLoader.dfm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ object PackageLoader: TPackageLoader
1111
Font.Height = -11
1212
Font.Name = 'Tahoma'
1313
Font.Style = []
14+
FormStyle = fsStayOnTop
1415
OldCreateOrder = False
1516
Position = poMainFormCenter
1617
PixelsPerInch = 96

zlog/UPluginManager.dfm

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ object MarketForm: TMarketForm
2424
Align = alTop
2525
AutoSnap = False
2626
Beveled = True
27-
ExplicitTop = 242
28-
ExplicitWidth = 624
2927
end
3028
object ShowPanel: TPanel
3129
Left = 0
@@ -42,8 +40,6 @@ object MarketForm: TMarketForm
4240
BorderWidth = 10
4341
ParentBackground = False
4442
ParentColor = True
45-
TabOrder = 0
46-
ExplicitHeight = 165
4743
object TagLabel: TLabel
4844
AlignWithMargins = True
4945
Left = 10
@@ -61,7 +57,6 @@ object MarketForm: TMarketForm
6157
Font.Name = 'Tahoma'
6258
Font.Style = []
6359
ParentFont = False
64-
ExplicitWidth = 333
6560
end
6661
object MsgLabel: TLinkLabel
6762
Left = 10
@@ -70,18 +65,14 @@ object MarketForm: TMarketForm
7065
Height = 76
7166
Align = alClient
7267
Caption = 'Empower zLog with great features developed by third parties.'
73-
Color = clGrayText
7468
Font.Charset = DEFAULT_CHARSET
7569
Font.Color = clWindowText
7670
Font.Height = -16
7771
Font.Name = 'Tahoma'
7872
Font.Style = []
7973
ParentColor = False
8074
ParentFont = False
81-
TabOrder = 1
8275
OnLinkClick = WebLabelLinkClick
83-
ExplicitWidth = 440
84-
ExplicitHeight = 23
8576
end
8677
object WebLabel: TLinkLabel
8778
Left = 10
@@ -96,10 +87,7 @@ object MarketForm: TMarketForm
9687
Font.Name = 'Tahoma'
9788
Font.Style = []
9889
ParentFont = False
99-
TabOrder = 0
10090
OnLinkClick = WebLabelLinkClick
101-
ExplicitTop = 137
102-
ExplicitWidth = 116
10391
end
10492
end
10593
object ListPanel: TPanel
@@ -112,13 +100,12 @@ object MarketForm: TMarketForm
112100
BevelOuter = bvNone
113101
ParentColor = True
114102
ShowCaption = False
115-
TabOrder = 1
116103
object ListBox: TListBox
117104
AlignWithMargins = True
118105
Left = 10
119106
Top = 47
120107
Width = 614
121-
Height = 343
108+
Height = 310
122109
Margins.Left = 10
123110
Margins.Top = 10
124111
Margins.Right = 10
@@ -131,7 +118,6 @@ object MarketForm: TMarketForm
131118
Font.Style = []
132119
ItemHeight = 19
133120
ParentFont = False
134-
TabOrder = 0
135121
OnClick = ListBoxClick
136122
end
137123
object SearchBox: TSearchBox
@@ -153,10 +139,24 @@ object MarketForm: TMarketForm
153139
ParentFont = False
154140
ParentShowHint = False
155141
ShowHint = True
156-
TabOrder = 1
157142
TextHint = 'Search'
158143
OnChange = SearchBoxChange
159144
end
145+
object CheckBox: TCheckBox
146+
AlignWithMargins = True
147+
Margins.Left = 10
148+
Margins.Right = 10
149+
Margins.Bottom = 10
150+
Align = alBottom
151+
Caption = 'Show unstable (experimental) plugins'
152+
Font.Charset = DEFAULT_CHARSET
153+
Font.Color = clWindowText
154+
Font.Height = -13
155+
Font.Name = 'Tahoma'
156+
Font.Style = []
157+
ParentFont = False
158+
OnClick = SearchBoxChange
159+
end
160160
end
161161
object GridPanel: TGridPanel
162162
Left = 0
@@ -199,14 +199,10 @@ object MarketForm: TMarketForm
199199
item
200200
Value = 100.000000000000000000
201201
end>
202-
TabOrder = 2
203-
ExplicitTop = 551
204202
object InstallButton: TButton
205203
AlignWithMargins = True
206-
Left = 15
207-
Top = 5
208-
Width = 188
209-
Height = 40
204+
Width = 202
205+
Height = 34
210206
Align = alClient
211207
Caption = 'Install'
212208
Enabled = False
@@ -216,16 +212,12 @@ object MarketForm: TMarketForm
216212
Font.Name = 'Tahoma'
217213
Font.Style = []
218214
ParentFont = False
219-
TabOrder = 0
220215
OnClick = InstallButtonClick
221-
ExplicitHeight = 31
222216
end
223217
object DisableButton: TButton
224218
AlignWithMargins = True
225-
Left = 223
226-
Top = 5
227-
Width = 188
228-
Height = 40
219+
Width = 202
220+
Height = 34
229221
Align = alClient
230222
Caption = 'Disable'
231223
Enabled = False
@@ -235,16 +227,12 @@ object MarketForm: TMarketForm
235227
Font.Name = 'Tahoma'
236228
Font.Style = []
237229
ParentFont = False
238-
TabOrder = 1
239230
OnClick = DisableButtonClick
240-
ExplicitHeight = 31
241231
end
242232
object UpgradeButton: TButton
243233
AlignWithMargins = True
244-
Left = 431
245-
Top = 5
246-
Width = 188
247-
Height = 40
234+
Width = 202
235+
Height = 34
248236
Align = alClient
249237
Caption = 'Upgrade'
250238
Enabled = False
@@ -254,9 +242,7 @@ object MarketForm: TMarketForm
254242
Font.Name = 'Tahoma'
255243
Font.Style = []
256244
ParentFont = False
257-
TabOrder = 2
258245
OnClick = UpgradeButtonClick
259-
ExplicitHeight = 31
260246
end
261247
end
262248
object NetHTTPClient: TNetHTTPClient

zlog/UPluginManager.pas

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ TMarketItem = class(TObject)
4545
url: string;
4646
web: string;
4747
sum: string;
48+
exp: string;
4849
use: TList<string>;
4950
function ref: string;
5051
function name: string;
@@ -56,12 +57,14 @@ TMarketItem = class(TObject)
5657
procedure Install;
5758
procedure Disable;
5859
procedure Upgrade;
60+
function IsStable: boolean;
5961
function IsUpToDate: boolean;
6062
function CanInstall: boolean;
6163
function CanDisable: boolean;
6264
function CanUpgrade: boolean;
6365
function Dependency: TArray<TMarketItem>;
6466
end;
67+
TMarketList = TList<TMarketItem>;
6568
TMarketDict = TDictionary<string, TMarketItem>;
6669
TMarketTest = reference to function(Item: TMarketItem): boolean;
6770
TMarketForm = class(TForm)
@@ -72,6 +75,7 @@ TMarketForm = class(TForm)
7275
MsgLabel: TLinkLabel;
7376
WebLabel: TLinkLabel;
7477
Splitter: TSplitter;
78+
CheckBox: TCheckBox;
7579
ListPanel: TPanel;
7680
ShowPanel: TPanel;
7781
GridPanel: TGridPanel;
@@ -97,6 +101,7 @@ TMarketForm = class(TForm)
97101
MarketForm: TMarketForm;
98102
MarketItem: TMarketItem;
99103
MarketDict: TMarketDict;
104+
MarketList: TMarketList;
100105

101106
const
102107
URL_MARKET = 'https://zylo.pafelog.net/market.json';
@@ -274,6 +279,11 @@ procedure Verify(Item: TMarketItem);
274279
end;
275280
end;
276281

282+
function TMarketItem.IsStable: boolean;
283+
begin
284+
Result := exp = 'stable';
285+
end;
286+
277287
function TMarketItem.IsUpToDate: boolean;
278288
var
279289
sum: string;
@@ -334,9 +344,8 @@ procedure TMarketForm.FormCreate(Sender: TObject);
334344

335345
procedure TMarketForm.FormShow(Sender: TObject);
336346
begin
337-
ListBox.Clear;
338347
LoadJSON(URL_MARKET);
339-
ListBoxClick(Self);
348+
SearchBoxChange(Self);
340349
end;
341350

342351
procedure TMarketForm.LoadJSON(url: string);
@@ -349,6 +358,7 @@ procedure TMarketForm.LoadJSON(url: string);
349358
cls, obj: TJsonPair;
350359
begin
351360
try
361+
MarketList.Clear;
352362
buf := TMemoryStream.Create;
353363
res := NetHttpRequest.Get(url, buf);
354364
txt := res.ContentAsString(TEncoding.UTF8);
@@ -386,11 +396,12 @@ function Value(obj: TJsonValue; key: string): string;
386396
Item.url := Value(obj.JsonValue, 'url');
387397
Item.web := Value(obj.JsonValue, 'web');
388398
Item.sum := Value(obj.JsonValue, 'sum');
399+
Item.exp := Value(obj.JsonValue, 'exp');
389400
def := TJsonArray.Create;
390401
arr := obj.JsonValue.GetValue('use', def);
391402
for use in arr do Item.use.Add(use.Value);
392403
MarketDict.AddOrSetvalue(Item.name, Item);
393-
if Item.IsPKG then ListBox.AddItem(Item.tag, Item);
404+
MarketList.Add(Item);
394405
def.Free;
395406
end;
396407

@@ -425,12 +436,17 @@ function Match(Item: TMarketItem): boolean;
425436
end else
426437
Result := False;
427438
end;
439+
function Check(Item: TMarketItem): boolean;
440+
begin
441+
Result := Match(Item) and (Item.IsStable or CheckBox.Checked);
442+
end;
428443
var
429444
Item: TMarketItem;
430445
begin
431446
ListBox.Clear;
432-
for Item in MarketDict.Values do
433-
if Match(Item) then ListBox.AddItem(Item.tag, Item);
447+
for Item in MarketList do
448+
if Check(Item) then ListBox.AddItem(Item.tag, Item);
449+
ListBoxClick(Self);
434450
end;
435451

436452
procedure TMarketForm.InstallButtonClick(Sender: TObject);
@@ -477,8 +493,10 @@ procedure BrowseURL(url: string);
477493

478494
initialization
479495
MarketDict := TMarketDict.Create;
496+
MarketList := TMarketList.Create;
480497

481498
finalization
482499
MarketDict.Free;
500+
MarketList.Free;
483501

484502
end.

0 commit comments

Comments
 (0)