ui: center windows on top of main window
* justify windows in middle of main window * fixed window resizing * add window displacement automatic with logo
This commit is contained in:
@@ -148,7 +148,7 @@ void QtAbout::setupAbout()
|
||||
QPushButton* closeButton = new QPushButton(this);
|
||||
closeButton->setIcon(QIcon(closePixmap.pixmap()));
|
||||
closeButton->setObjectName("closeButton");
|
||||
closeButton->move(450, 20);
|
||||
closeButton->move(455, 25);
|
||||
closeButton->show();
|
||||
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(handleCloseButtonPress()));
|
||||
|
||||
@@ -21,7 +21,7 @@ QtAboutLicense::QtAboutLicense(QWidget *parent)
|
||||
|
||||
QSize QtAboutLicense::sizeHint() const
|
||||
{
|
||||
return QSize(600,600);
|
||||
return QSize(600, 600);
|
||||
}
|
||||
|
||||
void QtAboutLicense::populateWindow(QWidget* widget)
|
||||
|
||||
@@ -16,4 +16,4 @@ protected:
|
||||
virtual void windowReady() override;
|
||||
};
|
||||
|
||||
#endif //QT_ABOUT_LICENSE_H
|
||||
#endif // QT_ABOUT_LICENSE_H
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtLicense::QtLicense(QWidget *parent)
|
||||
: QtWindow(parent, 68)
|
||||
: QtWindow(parent)
|
||||
{
|
||||
raise();
|
||||
}
|
||||
|
||||
QSize QtLicense::sizeHint() const
|
||||
{
|
||||
return QSize(725, 550);
|
||||
return QSize(750, 550);
|
||||
}
|
||||
|
||||
void QtLicense::clear()
|
||||
@@ -112,8 +112,6 @@ void QtLicense::populateWindow(QWidget* widget)
|
||||
layout->addSpacing(20);
|
||||
|
||||
widget->setLayout(layout);
|
||||
|
||||
resize(750, 550);
|
||||
}
|
||||
|
||||
void QtLicense::windowReady()
|
||||
|
||||
@@ -26,12 +26,18 @@ void QtRecentProjectButton::handleButtonClick()
|
||||
MessageLoadProject(m_projectFilePath.str(), false).dispatch();
|
||||
};
|
||||
|
||||
|
||||
QtStartScreen::QtStartScreen(QWidget *parent)
|
||||
: QtWindow(parent, 68)
|
||||
: QtWindow(parent)
|
||||
{
|
||||
this->raise();
|
||||
}
|
||||
|
||||
QSize QtStartScreen::sizeHint() const
|
||||
{
|
||||
return QSize(570, 600);
|
||||
}
|
||||
|
||||
void QtStartScreen::setupStartScreen()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str());
|
||||
@@ -77,13 +83,6 @@ void QtStartScreen::setupStartScreen()
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(handleRecentButton()));
|
||||
position += 40;
|
||||
}
|
||||
|
||||
resize(570, 600);
|
||||
}
|
||||
|
||||
QSize QtStartScreen::sizeHint() const
|
||||
{
|
||||
return QSize(500, 500);
|
||||
}
|
||||
|
||||
void QtStartScreen::handleNewProjectButton()
|
||||
|
||||
@@ -10,31 +10,23 @@
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtWindow::QtWindow(QWidget* parent, int displacement)
|
||||
QtWindow::QtWindow(QWidget* parent)
|
||||
: QtWindowStackElement(parent)
|
||||
, m_window(nullptr)
|
||||
, m_title(nullptr)
|
||||
, m_nextButton(nullptr)
|
||||
, m_previousButton(nullptr)
|
||||
, m_closeButton(nullptr)
|
||||
, m_displacement(displacement)
|
||||
, m_cancelAble(true)
|
||||
, m_scrollAble(false)
|
||||
, m_showAsPopup(false)
|
||||
, m_hasLogo(false)
|
||||
, m_mousePressedInWindow(false)
|
||||
{
|
||||
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
|
||||
move(parent->pos().x() + parent->width() / 2 - 250, parent->pos().y() + parent->height() / 2 - 250);
|
||||
|
||||
QSize windowSize = sizeHint();
|
||||
|
||||
m_window = new QWidget(this);
|
||||
windowSize.setHeight(windowSize.height() - displacement - 10);
|
||||
windowSize.setWidth(windowSize.width() - 10);
|
||||
m_window->move(0, displacement);
|
||||
m_window->resize(windowSize);
|
||||
|
||||
std::string frameStyle =
|
||||
"#window {"
|
||||
@@ -57,6 +49,8 @@ QtWindow::QtWindow(QWidget* parent, int displacement)
|
||||
m_window->setGraphicsEffect(effect);
|
||||
}
|
||||
|
||||
resize(sizeHint());
|
||||
|
||||
this->raise();
|
||||
}
|
||||
|
||||
@@ -245,9 +239,20 @@ void QtWindow::hideWindow()
|
||||
|
||||
void QtWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSize windowSize = event->size() - QSize(10, 10 + m_displacement);
|
||||
int displacement = 0;
|
||||
if (m_hasLogo)
|
||||
{
|
||||
displacement = 58;
|
||||
}
|
||||
|
||||
QSize windowSize = event->size() - QSize(10, 10 + displacement);
|
||||
m_window->resize(windowSize);
|
||||
m_window->move(0, m_displacement);
|
||||
m_window->move(5, displacement + 10);
|
||||
|
||||
move(
|
||||
parentWidget()->pos().x() + parentWidget()->width() / 2 - event->size().width() / 2,
|
||||
parentWidget()->pos().y() + parentWidget()->height() / 2 - event->size().height() / 2
|
||||
);
|
||||
}
|
||||
|
||||
void QtWindow::keyPressEvent(QKeyEvent *event)
|
||||
@@ -322,6 +327,9 @@ void QtWindow::addLogo()
|
||||
coatiLogoLabel->resize(coatiLogo.width(), coatiLogo.height());
|
||||
coatiLogoLabel->move(30, 25);
|
||||
coatiLogoLabel->show();
|
||||
|
||||
m_hasLogo = true;
|
||||
resize(sizeHint());
|
||||
}
|
||||
|
||||
void QtWindow::handleNextPress()
|
||||
|
||||
@@ -17,7 +17,7 @@ class QtWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtWindow(QWidget* parent = nullptr, int displacement = 0);
|
||||
QtWindow(QWidget* parent = nullptr);
|
||||
|
||||
QSize sizeHint() const override;
|
||||
|
||||
@@ -83,14 +83,14 @@ private slots:
|
||||
void handleClosePress();
|
||||
|
||||
private:
|
||||
int m_displacement;
|
||||
|
||||
bool m_cancelAble;
|
||||
bool m_scrollAble;
|
||||
bool m_showAsPopup;
|
||||
|
||||
bool m_hasLogo;
|
||||
|
||||
QPoint m_dragPosition;
|
||||
bool m_mousePressedInWindow;
|
||||
};
|
||||
|
||||
#endif //QT_WINDOW_H
|
||||
#endif // QT_WINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user