MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / initWindow

Method initWindow

ElaWidgetToolsExample/mainwindow.cpp:83–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void MainWindow::initWindow()
84{
85 setFocusPolicy(Qt::StrongFocus);
86 // setIsCentralStackedWidgetTransparent(true);
87 setWindowIcon(QIcon(":/include/Image/Cirno.jpg"));
88 resize(1200, 740);
89 // eTheme->setThemeMode(ElaThemeType::Dark);
90 // setIsNavigationBarEnable(false);
91 // setNavigationBarDisplayMode(ElaNavigationType::Compact);
92 // setWindowButtonFlag(ElaAppBarType::MinimizeButtonHint, false);
93 setUserInfoCardPixmap(QPixmap(":/Resource/Image/Cirno.jpg"));
94 setUserInfoCardTitle("Ela Tool");
95 setUserInfoCardSubTitle("Liniyous@gmail.com");
96 setWindowTitle("ElaWidgetTool");
97 // setIsStayTop(true);
98 // setUserInfoCardVisible(false);
99 // setNavigationBarWidth(260);
100 ElaText* centralStack = new ElaText("这是一个主窗口堆栈页面", this);
101 centralStack->setFocusPolicy(Qt::StrongFocus);
102 centralStack->setTextPixelSize(32);
103 centralStack->setAlignment(Qt::AlignCenter);
104 addCentralWidget(centralStack);
105
106 // 窗口绘制模式
107 setWindowPixmap(ElaThemeType::Light, QPixmap(":/Resource/Image/WindowBase/Miku.png"));
108 setWindowPixmap(ElaThemeType::Dark, QPixmap(":/Resource/Image/WindowBase/WorldTree.jpg"));
109 setWindowMoviePath(ElaThemeType::Light, ":/Resource/Image/WindowBase/Miku.gif");
110 setWindowMoviePath(ElaThemeType::Dark, ":/Resource/Image/WindowBase/WorldTree.gif");
111 //setWindowPaintMode(ElaWindowType::PaintMode::Pixmap);
112
113 // 自定义AppBar菜单
114 ElaMenu* appBarMenu = new ElaMenu(this);
115 appBarMenu->setMenuItemHeight(27);
116 connect(appBarMenu->addAction("跳转到一级主要堆栈"), &QAction::triggered, this, [=]() {
117 setCurrentStackIndex(0);
118 });
119 connect(appBarMenu->addAction("跳转到二级主要堆栈"), &QAction::triggered, this, [=]() {
120 setCurrentStackIndex(1);
121 });
122 connect(appBarMenu->addAction("更改页面切换特效(Scale)"), &QAction::triggered, this, [=]() {
123 setStackSwitchMode(ElaWindowType::StackSwitchMode::Scale);
124 });
125 connect(appBarMenu->addElaIconAction(ElaIconType::GearComplex, "自定义主窗口设置"), &QAction::triggered, this, [=]() {
126 navigation(_settingKey);
127 });
128 appBarMenu->addSeparator();
129 connect(appBarMenu->addElaIconAction(ElaIconType::MoonStars, "更改项目主题"), &QAction::triggered, this, [=]() {
130 eTheme->setThemeMode(eTheme->getThemeMode() == ElaThemeType::Light ? ElaThemeType::Dark : ElaThemeType::Light);
131 });
132 connect(appBarMenu->addAction("使用原生菜单"), &QAction::triggered, this, [=]() {
133 setCustomMenu(nullptr);
134 });
135 setCustomMenu(appBarMenu);
136
137 // 堆栈独立自定义窗口
138 QWidget* centralCustomWidget = new QWidget(this);
139 QHBoxLayout* centralCustomWidgetLayout = new QHBoxLayout(centralCustomWidget);
140 centralCustomWidgetLayout->setContentsMargins(13, 15, 9, 6);

Callers

nothing calls this directly

Calls 15

setMenuItemHeightMethod · 0.80
setThemeModeMethod · 0.80
getThemeModeMethod · 0.80
undoCommandMethod · 0.80
redoCommandMethod · 0.80
setFixedHeightMethod · 0.80
setPlaceholderTextMethod · 0.80
setIsWrapAnywhereMethod · 0.80
setBusyingWidthMethod · 0.80
setFixedSizeMethod · 0.80
setIsBusyingMethod · 0.80
addWidgetMethod · 0.80

Tested by

no test coverage detected