mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 21:50:18 +02:00
Patch from zeljko to qt. Lot's of bug fixes. Implemented MDI support too. I added small modifications and also updated the qt bindings to 1.35 plus patch
git-svn-id: trunk@11311 -
This commit is contained in:
parent
ca76f52525
commit
a6d281e3df
File diff suppressed because it is too large
Load Diff
@ -207,6 +207,8 @@ end;
|
||||
|
||||
destructor TQtListStrings.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FStringList.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -226,24 +228,24 @@ begin
|
||||
end;
|
||||
|
||||
procedure TQtListStrings.Delete(Index: integer);
|
||||
{var
|
||||
Astr: WideString;}
|
||||
begin
|
||||
if FListChanged then InternalUpdate;
|
||||
|
||||
if Index < FStringList.Count then
|
||||
begin
|
||||
FStringList.Delete(Index);
|
||||
// Astr := FStringList.Text;
|
||||
ExternalUpdate(FStringList,True);
|
||||
FUpdating := True;
|
||||
QListWidget_takeItem(FQtListWidget, Index);
|
||||
FUpdating := False;
|
||||
IsChanged;
|
||||
FUpdating := False;
|
||||
FListChanged := False;
|
||||
end;
|
||||
|
||||
(* FStringList.Delete(Index);
|
||||
QListWidget_takeitem(FQtListWidget, Index); *)
|
||||
end;
|
||||
|
||||
procedure TQtListStrings.Insert(Index: integer; const S: string);
|
||||
var
|
||||
AStr: WideString;
|
||||
begin
|
||||
if FListChanged then InternalUpdate;
|
||||
|
||||
@ -251,8 +253,13 @@ begin
|
||||
|
||||
if Index <= FStringList.Count then
|
||||
begin
|
||||
FUpdating := True;
|
||||
FStringList.Insert(Index,S);
|
||||
ExternalUpdate(FStringList,True);
|
||||
AStr := UTF8Decode(S);
|
||||
QListWidget_insertItem(FQtListWidget, Index, QListWidgetItem_create(@AStr, FQtListWidget, Integer(QListWidgetItemType)));
|
||||
FUpdating := False;
|
||||
IsChanged;
|
||||
FUpdating := False;
|
||||
FListChanged := False;
|
||||
end;
|
||||
end;
|
||||
|
@ -124,14 +124,17 @@ type
|
||||
{ TQtMainWindow }
|
||||
|
||||
TQtMenuBar = class;
|
||||
TQtToolBar = class;
|
||||
|
||||
TQtMainWindow = class(TQtWidget)
|
||||
private
|
||||
protected
|
||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||
public
|
||||
MDIAreaHandle: QMDIAreaH;
|
||||
Splitter: QSplitterH;
|
||||
MenuBar: TQtMenuBar;
|
||||
ToolBar: TQtToolBar;
|
||||
Canvas: TQtDeviceContext;
|
||||
destructor Destroy; override;
|
||||
procedure setTabOrders;
|
||||
@ -393,8 +396,11 @@ type
|
||||
protected
|
||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||
public
|
||||
FList: TStrings;
|
||||
destructor Destroy; override;
|
||||
procedure SlotSelectionChange(current: QListWidgetItemH; previous: QListWidgetItemH); cdecl;
|
||||
procedure SignalItemDoubleClicked(item: QListWidgetItemH); cdecl;
|
||||
procedure SignalItemClicked(item: QListWidgetItemH); cdecl;
|
||||
function currentRow: Integer;
|
||||
procedure setCurrentRow(row: Integer);
|
||||
end;
|
||||
@ -511,6 +517,7 @@ const
|
||||
constructor TQtWidget.Create(const AWinControl: TWinControl; const AParams: TCreateParams);
|
||||
begin
|
||||
// Initializes the properties
|
||||
FProps := NiL;
|
||||
LCLObject := AWinControl;
|
||||
|
||||
// Creates the widget
|
||||
@ -1634,9 +1641,9 @@ begin
|
||||
//FProps.CaseSensitive:=false;
|
||||
FProps.Sorted:=true;
|
||||
end;
|
||||
i:=Fprops.IndexOf(AnIndex);
|
||||
if i<0 then
|
||||
i:=FProps.Add(AnIndex);
|
||||
i := Fprops.IndexOf(AnIndex);
|
||||
if i < 0 then
|
||||
i := FProps.Add(AnIndex);
|
||||
Fprops.Objects[i] := TObject(AValue);
|
||||
end;
|
||||
|
||||
@ -1787,16 +1794,57 @@ end;
|
||||
{ TQtMainWindow }
|
||||
|
||||
function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||
var
|
||||
w: QWidgetH;
|
||||
r: TRect;
|
||||
mdihandle: QMdiAreaH;
|
||||
toolbar: QToolBarH;
|
||||
begin
|
||||
// Creates the widget
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtMainWindow.CreateWidget Name: ', LCLObject.Name);
|
||||
{$endif}
|
||||
|
||||
Result := QWidget_create(nil, QtWindow);
|
||||
|
||||
// Main menu bar
|
||||
MenuBar := TQtMenuBar.Create(Result);
|
||||
w := QApplication_activeWindow;
|
||||
|
||||
// mainform should be TQtMainWindow ...
|
||||
{. $define mdidevel}
|
||||
if not Assigned(w) and not (Application.MainForm.Visible) then
|
||||
begin
|
||||
Result := QMainWindow_create(nil, QtWindow);
|
||||
|
||||
MenuBar := TQtMenuBar.Create(Result);
|
||||
|
||||
|
||||
if Assigned(Application.MainForm.Menu) then
|
||||
QMainWindow_setMenuBar(QMainWindowH(Result), QMenuBarH(MenuBar.Widget));
|
||||
|
||||
{$ifdef mdidevel}
|
||||
MDIAreaHandle := QMdiArea_create(Result);
|
||||
|
||||
QMainWindow_setCentralWidget(QMainWindowH(Result), MDIAreaHandle);
|
||||
{$endif}
|
||||
|
||||
QMainWindow_setDockOptions(QMainWindowH(Result) ,QMainWindowAnimatedDocks);
|
||||
|
||||
end else
|
||||
begin
|
||||
{$ifdef mdidevel}
|
||||
if LCLObject.Tag = 9999 then
|
||||
begin
|
||||
Result := QMdiSubWindow_create(NiL, QtWindow);
|
||||
|
||||
mdiHandle := TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle;
|
||||
if Assigned(mdiHandle) then
|
||||
QMdiArea_addSubWindow(mdiHandle, QMdiSubWindowH(Result), QtWindow);
|
||||
|
||||
end else
|
||||
{$endif}
|
||||
Result := QWidget_create(nil, QtWindow);
|
||||
// Main menu bar
|
||||
MenuBar := TQtMenuBar.Create(Result);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -3210,6 +3258,42 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtListWidget.SignalItemDoubleClicked
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtListWidget.SignalItemDoubleClicked(item: QListWidgetItemH); cdecl;
|
||||
var
|
||||
Msg: TLMessage;
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
Msg.Msg := LM_LBUTTONDBLCLK;
|
||||
try
|
||||
LCLObject.WindowProc(TLMessage(Msg));
|
||||
except
|
||||
Application.HandleException(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtListWidget.SignalItemClicked
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtListWidget.SignalItemClicked(item: QListWidgetItemH); cdecl;
|
||||
var
|
||||
Msg: TLMessage;
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
Msg.Msg := LM_CLICKED;
|
||||
try
|
||||
LCLObject.WindowProc(TLMessage(Msg));
|
||||
except
|
||||
Application.HandleException(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtListWidget.currentRow
|
||||
Params: None
|
||||
|
@ -132,7 +132,7 @@ uses QtWSControls;
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
|
||||
Creates a Qt Form and initializes it according to it´s properties
|
||||
Creates a Qt Form and initializes it according to it's properties
|
||||
------------------------------------------------------------------------------}
|
||||
class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND;
|
||||
@ -150,9 +150,10 @@ begin
|
||||
// Creates the window
|
||||
|
||||
QtMainWindow := TQtMainWindow.Create(AWinControl, AParams);
|
||||
|
||||
|
||||
// Set´s initial properties
|
||||
|
||||
|
||||
Str := UTF8Decode(AWinControl.Caption);
|
||||
|
||||
QtMainWindow.SetWindowTitle(@Str);
|
||||
@ -161,6 +162,7 @@ begin
|
||||
|
||||
SetQtBorderIcons(QtMainWindow, TCustomForm(AWinControl).BorderIcons);
|
||||
|
||||
|
||||
// Sets Various Events
|
||||
|
||||
Hook := QObject_hook_create(QtMainWindow.Widget);
|
||||
@ -168,7 +170,7 @@ begin
|
||||
TEventFilterMethod(Method) := QtMainWindow.EventFilter;
|
||||
|
||||
QObject_hook_hook_events(Hook, Method);
|
||||
|
||||
|
||||
// Return the handle
|
||||
|
||||
Result := THandle(QtMainWindow);
|
||||
@ -231,7 +233,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TQtWSCustomForm.CloseModal(const ACustomForm: TCustomForm);
|
||||
begin
|
||||
|
||||
inherited CloseModal(ACustomForm);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -276,19 +278,14 @@ begin
|
||||
WriteLn('Trace:> [TQtWSCustomForm.ShowModal]');
|
||||
{$endif}
|
||||
|
||||
{if we use QDialog as modal class then everything looks fine}
|
||||
TQtWidget(ACustomForm.Handle).Hide;
|
||||
|
||||
TQtWidget(ACustomForm.Handle).setWindowModality(QtApplicationModal);
|
||||
|
||||
TQtWidget(ACustomForm.Handle).Show;
|
||||
|
||||
{give it a real modal loop, CPU consumption is OK now ... }
|
||||
// while Assigned(ACustomForm) and (ACustomForm.Visible)
|
||||
while (ACustomForm.ModalResult = mrNone) do
|
||||
begin
|
||||
sleep(10);
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
Application.ProcessMessages;
|
||||
sleep(10);
|
||||
Application.ProcessMessages;
|
||||
|
||||
{BUG: if we assign OnCloseQuery(), Lazarus TCustomForm.Close() Fires ModalResult = mrCancel,
|
||||
without counting on OnCloseQuery() result (CanClose), so if we set it up we'll jump over our
|
||||
@ -316,10 +313,10 @@ end;
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
|
||||
We need this method because LCL doesn´t automatically calls SetWindowBorder
|
||||
We need this method because LCL doesn't automatically calls SetWindowBorder
|
||||
after the window is created, so we need to do it on CreateHandle procedure,
|
||||
but CreateHandle cannot call other methods from TQtWSCustomForm because the
|
||||
Handle isn´t created yet before it is finished.
|
||||
Handle isn't created yet before it is finished.
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TQtWSCustomForm.SetQtWindowBorderStyle(const AHandle: TQtMainWindow;
|
||||
const AFormBorderStyle: TFormBorderStyle);
|
||||
|
@ -267,12 +267,12 @@ begin
|
||||
library on the Virtual Magnifying Glass }
|
||||
if AMenuItem.Count > 0 then
|
||||
begin
|
||||
// TQtMenu(AMenuItem.Handle).Free;
|
||||
TQtMenu(AMenuItem.Handle).Free;
|
||||
end
|
||||
{ Here the menu item has a QActionH handle }
|
||||
else
|
||||
begin
|
||||
// TQtAction(AMenuItem.Handle).Free;
|
||||
TQtAction(AMenuItem.Handle).Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -445,10 +445,20 @@ begin
|
||||
QObject_hook_hook_events(Hook, Method);
|
||||
|
||||
// OnSelectionChange event
|
||||
|
||||
QListWidget_currentItemChanged_Event(Method) := QtListWidget.SlotSelectionChange;
|
||||
|
||||
QListWidget_hook_hook_currentItemChanged(QListWidget_hook_create(QtListWidget.Widget), Method);
|
||||
|
||||
QListWidget_itemDoubleClicked_Event(Method) := QtListWidget.SignalItemDoubleClicked;
|
||||
QListWidget_hook_hook_ItemDoubleClicked(QListWidget_hook_create(QtListWidget.Widget), Method);
|
||||
|
||||
QListWidget_itemClicked_Event(Method) := QtListWidget.SignalItemClicked;
|
||||
QListWidget_hook_hook_ItemClicked(QListWidget_hook_create(QtListWidget.Widget), Method);
|
||||
|
||||
// QListWidget_itemClicked_Event(Method;
|
||||
|
||||
// create our FList helper
|
||||
QtListWidget.FList := TQtListStrings.Create(QListWidgetH(QtListWidget.Widget), TCustomListBox(AWinControl));
|
||||
|
||||
|
||||
Result := THandle(QtListWidget);
|
||||
end;
|
||||
@ -493,8 +503,9 @@ class function TQtWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBo
|
||||
var
|
||||
ListWidgetH: QListWidgetH;
|
||||
begin
|
||||
ListWidgetH := QListWidgetH((TQtWidget(ACustomListBox.Handle).Widget));
|
||||
Result := TQtListStrings.Create(ListWidgetH, ACustomListBox);
|
||||
if not Assigned(TQtListWidget(ACustomListBox.Handle).FList) then
|
||||
TQtListWidget(ACustomListBox.Handle).FList := TQtListStrings.Create(ListWidgetH, ACustomListBox);
|
||||
Result := TQtListWidget(ACustomListBox.Handle).FList;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user