1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-01-31 21:22:58 +08:00

update frameless; update wizard

This commit is contained in:
jared 2020-10-28 12:59:25 +08:00
parent c80f79a909
commit a79d044e03
6 changed files with 33 additions and 13 deletions

View File

@ -58,8 +58,7 @@ static bool isFullWin(QQuickView *win)
TaoFrameLessView::TaoFrameLessView(QWindow *parent) : QQuickView(parent)
{
setFlags(/*Qt::CustomizeWindowHint | */ Qt::Window | Qt::FramelessWindowHint
| Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
setFlags(Qt::CustomizeWindowHint | Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
setResizeMode(SizeRootObjectToView);
// WS_THICKFRAME 带回Areo效果
@ -79,13 +78,33 @@ void TaoFrameLessView::setTitleItem(QQuickItem *item)
{
m_titleItem = item;
}
QRect TaoFrameLessView::calcCenterGeo(const QRect &screenGeo, const QSize &normalSize)
{
int w = normalSize.width();
int h = normalSize.height();
int x = screenGeo.x() + (screenGeo.width() - w) / 2;
int y = screenGeo.y() + (screenGeo.height() - h) / 2;
if (screenGeo.width() < w)
{
x = screenGeo.x();
w = screenGeo.width();
}
if (screenGeo.height() < h)
{
y = screenGeo.y();
h = screenGeo.height();
}
return { x, y, w, h };
}
void TaoFrameLessView::moveToScreenCenter()
{
auto geo = screen()->availableGeometry();
int w = width();
int h = height();
auto pos = QPoint { geo.x() + (geo.width() - w) / 2, geo.y() + (geo.height() - h) / 2 };
setPosition(pos.x(), pos.y());
auto geo = calcCenterGeo(screen()->availableGeometry(), size());
if (minimumWidth() > geo.width() || minimumHeight() > geo.height())
{
setMinimumSize(geo.size());
}
setGeometry(geo);
update();
}

View File

@ -13,6 +13,8 @@ public:
void moveToScreenCenter();
bool isMax() const { return m_isMax; }
QQuickItem *titleItem() const { return m_titleItem; }
static QRect calcCenterGeo(const QRect &screenGeo, const QSize &normalSize);
public slots:
void setIsMax(bool isMax);
void setTitleItem(QQuickItem *item);

View File

@ -6,8 +6,8 @@
#include <QLocale>
#include <QQuickView>
#include <QQmlEngine>
const static auto cEnglisthStr = QStringLiteral("English");
const static auto cChineseStr = QStringLiteral("简体中文");
const static auto cEnglisthStr = u8"English";
const static auto cChineseStr = u8"简体中文";
Trans::Trans(QObject *parent) : QTranslator(parent) {}
void Trans::beforeUiReady(QQmlContext *ctx)

View File

@ -18,7 +18,6 @@ Item {
pRoot = pRoot.parent
}
wizardComp.createObject(pRoot)
// wizardComp.createObject(pRoot, {x: pRoot.x, y: pRoot.y, width: pRoot.width, height: pRoot.height})
}
Component {
id: wizardComp
@ -31,13 +30,11 @@ Item {
destroy(wizard)
}
CusWizardPage {
z: 1
visible: wizard.currentIndex === 0
wizardText: qsTr("titleRect can control window")
focusRect: Qt.rect(0,0, wizard.parent.width, 80)
}
CusWizardPage {
z: 1
visible: wizard.currentIndex === 1
wizardText: qsTr("middle rect for control")
focusRect: Qt.rect(200,200, 200, 200)

View File

@ -32,6 +32,7 @@ int main(int argc, char **argv)
TaoFrameLessView view;
view.setMinimumSize({ 800, 600 });
view.resize(1440, 960);
view.moveToScreenCenter();
Trans trans;
AppInfo appInfo;
trans.beforeUiReady(view.rootContext());

View File

@ -6,6 +6,7 @@ import "../.."
Item {
id: pageItem
z: 1
anchors.fill: parent
property rect focusRect
property string wizardText
@ -24,7 +25,7 @@ Item {
GradientStop { position: 0.0; color: "transparent" }
GradientStop { position: 0.8; color: maskColor }
}
opacity: maskOpacity
opacity: maskOpacity / 2
}
}
Row {