代码拉取完成,页面将自动刷新
同步操作将从 开源应用/DtkDemo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "mainwindow.h"
#include <DWidgetUtil> //加入此头文件方可使用moveToCenter
#include <DSearchEdit>
#include <DTitlebar>
#include <QDebug>
#include <QMenu>
#include <QAction>
MainWindow::MainWindow(DMainWindow *parent)
: DMainWindow(parent)
{
//初始化主窗口 Initialize the main window
setCentralWidget(w);//将w作为窗口的用户部分(整个窗口除了标题栏的部分)
moveToCenter(this); //把窗口移动到屏幕中间
MainWindow::resize(630,500); //改变窗口大小应当改变MainWindow的大小
//下面是创建控件的实例 The following is an example of creating a control
DLabel *label=new DLabel;
label->setParent(w);
label->setText("Hello World");
label->show();
//在标题栏添加控件(其实可以把标题栏看成一个Widget,详细的说明请看文档) Add a control to the title bar (In fact, the title bar can be regarded as a Widget. Please refer to the document for detailed instructions.)
DSearchEdit *searchEdit = new DSearchEdit;
titlebar()->setCustomWidget(searchEdit);
searchEdit->setFixedWidth(200);
searchEdit->show();
//在标题栏上添加一个菜单/菜单项 Add a menu/menu item to the title bar
QMenu *menu=new QMenu;
QAction *action=new QAction("action");
menu->addAction(action);
titlebar()->setMenu(menu);
//设置标题栏上的图标 Set the icon on the title bar
titlebar()->setIcon(QIcon::fromTheme("deepin-launcher"));
//让程序适配浅色模式和深色模式 Adapt the program to light and dark model
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged,this,&MainWindow::setTheme);
}
MainWindow::~MainWindow()
{
delete w;
}
void MainWindow::setTheme(DGuiApplicationHelper::ColorType theme)
{
//这个函数在程序运行之初就会被调用一次,而后每次更换主题颜色时被调用。 This function is called at the beginning of the program and then every time the theme color is changed.
if(theme==DGuiApplicationHelper::LightType){ //在这个位置设置两种不同的样式 Set two different styles at this location
//浅色模式 Light Mode
qDebug()<<"Lighe";
}else {
//深色模式 Dark Mode
qDebug()<<"Dark";
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。