Skip to content

Commit d10313a

Browse files
Merge pull request #37 from Reim-developer/dev
Fix beavior in Bash Script
2 parents b3f2857 + 645712a commit d10313a

7 files changed

Lines changed: 210 additions & 27 deletions

File tree

Source/Core/CoreSettingWindow.cc

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#include "Include/CoreSettingWindow.hpp"
2+
#include "../Utils/Include/Utils.hpp"
3+
4+
using ZClipboard::Core::CoreSettingWindow;
5+
using ZClipboard::Core::CoreSettingWindowData;
6+
using ZClipboard::GUI::Toolkit::SettingWindowLayoutData;
7+
using ZClipboard::AppUtils::Utils;
8+
9+
using Self = CoreSettingWindow;
10+
using DataImpl = CoreSettingWindowData;
11+
using LayoutManager = SettingWindowLayoutManager;
12+
using WindowComponents = SettingWindowComponentsManager;
13+
using Window = QMainWindow;
14+
using Button = QPushButton;
15+
using Layout = QGridLayout;
16+
17+
#if defined (Z_DEBUG)
18+
#include "../Utils/Include/AssertNullPtr.hpp"
19+
#include "../Utils/Include/Logging.hpp"
20+
21+
using ZClipboard::AppUtils::LogContext;
22+
#endif
23+
24+
Self *Self::StartBuild() noexcept {
25+
if(!Impl) {
26+
Utils::MakeSmartPtr<DataImpl>(Impl);
27+
}
28+
29+
return this;
30+
}
31+
32+
WindowComponents *Self::GetWindowComponents() noexcept {
33+
if(!windowComponents) {
34+
Utils::MakeSmartPtr<WindowComponents>(windowComponents);
35+
}
36+
37+
return this
38+
-> windowComponents.get();
39+
}
40+
41+
Window *Self::GetMainWindow() noexcept {
42+
return this
43+
-> Impl
44+
-> mainWindow;
45+
}
46+
47+
Button *Self::GetSettingButton() noexcept{
48+
return this
49+
-> Impl
50+
-> settingButton;
51+
}
52+
53+
Layout *Self::GetLayout() noexcept {
54+
return this
55+
-> Impl
56+
-> layout;
57+
}
58+
59+
Self *Self::WhenDone() noexcept {
60+
#if defined (Z_DEBUG)
61+
using Assert = AssertContext;
62+
using Log = LogContext;
63+
64+
Assert{}.RequireNonNullPtr(Impl.get());
65+
Assert{}.RequireNonNullPtr(Impl->mainWindow);
66+
Assert{}.RequireNonNullPtr(Impl->settingButton);
67+
68+
Log{}.LogDebug(Impl.get());
69+
Log{}.LogDebug(Impl->mainWindow);
70+
Log{}.LogDebug(Impl->settingButton);
71+
#endif
72+
73+
return this;
74+
}
75+
76+
void Self::Finally_Add_Listener() noexcept {
77+
// const auto window = this->GetMainWindow();
78+
const auto settingButton = this->GetSettingButton();
79+
const auto windowComponents = this->GetWindowComponents();
80+
const auto layout = this->GetLayout();
81+
82+
using Impl = SettingWindowLayoutData;
83+
if(!layoutManager) {
84+
Utils::MakeSmartPtr<LayoutManager>(layoutManager);
85+
}
86+
layoutManager
87+
-> StartBuild()
88+
-> WithAndThen(&Impl::componentsManager, windowComponents)
89+
-> WithAndThen(&Impl::layout, layout)
90+
-> WhenDone()
91+
-> SetupSettingWindowLayout();
92+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef CORE_SETTING_WINDOW_HPP
2+
#include "../../Utils/Include/Namespace_Macro.hpp"
3+
#include "../../Utils/Include/Meta_Macro.hpp"
4+
#include "../../GUI/Toolkit/Include/SettingWindow_Components.hpp"
5+
#include "../../GUI/Toolkit/Include/SettingWindow_LayoutManager.hpp"
6+
#include "../../Lib_Memory/Include/Memory.hpp"
7+
#include <QPushButton>
8+
#include <QMainWindow>
9+
10+
using ZClipboard::GUI::Toolkit::SettingWindowComponentsManager;
11+
using ZClipboard::GUI::Toolkit::SettingWindowLayoutManager;
12+
using ZClipboard::Lib_Memory::PtrUnique;
13+
14+
CORE_NAMESPACE
15+
16+
struct CoreSettingWindowData {
17+
QPushButton *settingButton;
18+
QMainWindow *mainWindow;
19+
QGridLayout *layout;
20+
};
21+
22+
class CoreSettingWindow {
23+
private:
24+
using Self = CoreSettingWindow;
25+
using WindowComponents = SettingWindowComponentsManager;
26+
using LayoutManager = SettingWindowLayoutManager;
27+
using ImplData = CoreSettingWindowData;
28+
using Window = QMainWindow;
29+
using Button = QPushButton;
30+
using Layout = QGridLayout;
31+
32+
private:
33+
PtrUnique<WindowComponents> windowComponents;
34+
PtrUnique<ImplData> Impl;
35+
PtrUnique<LayoutManager> layoutManager;
36+
37+
private:
38+
WindowComponents *GetWindowComponents() noexcept;
39+
Window *GetMainWindow() noexcept;
40+
Button *GetSettingButton() noexcept;
41+
Layout *GetLayout() noexcept;
42+
43+
public:
44+
Self *StartBuild() noexcept;
45+
46+
CLASS_BUILD(T, V)
47+
inline Self *WithAndThen(T ImplData::*member, V &&value) noexcept {
48+
Impl.get()->*member = FORWARD(V, value);
49+
50+
return this;
51+
}
52+
53+
Self *WhenDone() noexcept;
54+
void Finally_Add_Listener() noexcept;
55+
};
56+
57+
END_NAMESPACE
58+
#endif // CORE_SETTING_WINDOW_HPP

Source/GUI/Include/SettingButton.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
#include "../../Core/Include/CoreSetting.hpp"
1515
#include "../../Lib_Memory/Include/Memory.hpp"
1616
#include "../Toolkit/Include/MainWindow_Components.hpp"
17+
#include "../../Core/Include/CoreSettingWindow.hpp"
1718
#include "../../Utils/Include/Namespace_Macro.hpp"
1819

1920
using ZClipboard::Core::SettingCore;
2021
using ZClipboard::GUI::Toolkit::MainWindowComponentsManager;
22+
using ZClipboard::Core::CoreSettingWindow;
2123
using ZClipboard::Lib_Memory::PtrUnique;
2224

2325
GUI_NAMESPACE
@@ -36,10 +38,10 @@ GUI_NAMESPACE
3638

3739
private:
3840
using Window = QMainWindow;
39-
using Toolkit = MainWindowComponentsManager;
41+
using MainWindowComponents = MainWindowComponentsManager;
4042

4143
public:
42-
void SetupSettingButton(Window *window, Toolkit *toolkit);
44+
void SetupSettingButton(Window *window, MainWindowComponents *toolkit);
4345
QPushButton *getSettingButton();
4446

4547
private:
@@ -52,6 +54,9 @@ GUI_NAMESPACE
5254
private:
5355
SettingCore *settingCore;
5456
PtrUnique<QSettings> settings;
57+
PtrUnique<QDialog> dialog;
58+
PtrUnique<QGridLayout> layout;
59+
PtrUnique<CoreSettingWindow> coreSettingWindow;
5560
QPushButton *setPasswordButton;
5661

5762
QLabel *languageDescription;

Source/GUI/SettingButton.cc

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
11
#include "Include/SettingButton.hpp"
22
#include "../Language/Include/Translate.hpp"
3-
#include "../Utils/Include/Settings.hpp"
4-
#include "../Utils/Include/Config.hpp"
5-
#include "../Utils/Include/Utils.hpp"
6-
#include "../Language/Include/Language.hpp"
73
#include "Include/Window.hpp"
84
#include <QStringLiteral>
95
#include <QSettings>
106
#include <QIcon>
11-
#include "../Core/Include/CoreSetting.hpp"
127

13-
using ZClipboard::Core::SettingCore;
14-
using ZClipboard::Core::SettingCoreParams;
15-
using ZClipboard::Language::Translate;
8+
using ZClipboard::Core::CoreSettingWindowData;
169
using ZClipboard::Language::TransValue;
1710
using ZClipboard::GUI::SettingButton;
1811
using ZClipboard::AppUtils::Utils;
1912

20-
void SettingButton::SetupSettingButton(QMainWindow *window, Toolkit *toolkit) {
21-
auto settingButton = toolkit->GetSettingButton();
22-
settingCore = new SettingCore();
13+
#if defined (Z_DEBUG)
14+
#include "../Utils/Include/AssertNullPtr.hpp"
15+
#endif
2316

24-
const auto function = [this, window]() {
17+
void SettingButton::SetupSettingButton(
18+
QMainWindow *window, MainWindowComponents *mainWindowComponents) {
19+
20+
auto settingButton = mainWindowComponents->GetSettingButton();
21+
22+
Utils::MakeSmartPtr<CoreSettingWindow>(coreSettingWindow);
23+
Utils::MakeSmartPtr<QDialog>(dialog);
24+
Utils::MakeSmartPtr<QGridLayout>(layout, dialog.get());
25+
26+
// settingCore = new SettingCore();
27+
28+
const auto function = [this, settingButton, window]() {
2529
// window->hide();
2630
// showSettingDialog(window);
31+
32+
#if defined (Z_DEBUG)
33+
using Assert = AssertContext;
34+
35+
Assert{}.RequireNonNullPtr(settingButton);
36+
Assert{}.RequireNonNullPtr(layout.get());
37+
Assert{}.RequireNonNullPtr(window);
38+
39+
#endif
40+
41+
using DataImpl = CoreSettingWindowData;
42+
coreSettingWindow
43+
-> StartBuild()
44+
-> WithAndThen(&DataImpl::settingButton, settingButton)
45+
-> WithAndThen(&DataImpl::layout, layout.get())
46+
-> WithAndThen(&DataImpl::mainWindow, window)
47+
-> Finally_Add_Listener();
48+
49+
dialog->exec();
50+
2751
};
2852
connect(settingButton, &QPushButton::clicked, this, function);
2953

Source/GUI/Toolkit/Include/SettingWindow_LayoutManager.hpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@ GUI_TOOLKIT_NAMESPACE
2828
private:
2929
PtrUnique<DataImpl> Impl;
3030

31-
public:
32-
Self *StartBuild() noexcept;
33-
34-
CLASS_BUILD(T, V)
35-
inline Self *WithAndThen(T DataImpl::*member, V &&value) noexcept {
36-
Impl.get()->*member = FORWARD(V, value);
37-
38-
return this;
39-
}
40-
41-
Self *WhenDone() noexcept;
42-
31+
private:
4332
Layout *GetLayout() noexcept;
4433
ComponentsManager *GetComponentsManager() noexcept;
4534

@@ -71,6 +60,18 @@ GUI_TOOLKIT_NAMESPACE
7160
Layout *layout,
7261
ComponentsManager *componentsManager) const noexcept;
7362

63+
public:
64+
Self *StartBuild() noexcept;
65+
66+
CLASS_BUILD(T, V)
67+
inline Self *WithAndThen(T DataImpl::*member, V &&value) noexcept {
68+
Impl.get()->*member = FORWARD(V, value);
69+
70+
return this;
71+
}
72+
73+
Self *WhenDone() noexcept;
74+
7475
void SetupSettingWindowLayout() noexcept;
7576

7677
};

Source/Utils/Include/Namespace_Macro.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#define GUI_WINDOW_NAMESPACE \
1717
namespace ZClipboard::GUI::Windows {
1818

19+
#define GUI_WINDOW_TRANSLATOR_NAMESPACE \
20+
namespace ZClipboard::GUI::Windows::Translator {
21+
1922
#define GUI_HOT_RELOAD_NAMESPACE \
2023
namespace ZClipboard::GUI::Hot_Reload {
2124

scripts/gen_compile_commands.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cmake_detect() {
2222
}
2323

2424
bear_detect() {
25-
if command -v bear >/dev/null 2&1; then
25+
if command -v bear >/dev/null 2>&1; then
2626
echo "[OK] Bear is already install in your os..."
2727

2828
else

0 commit comments

Comments
 (0)