src: split indexing dialog to multiple classes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "QtWindow.h"
|
||||
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
@@ -11,9 +10,7 @@
|
||||
#include "ResourcePaths.h"
|
||||
|
||||
QtWindow::QtWindow(bool isSubWindow, QWidget* parent)
|
||||
: QtWindowStackElement(parent)
|
||||
, m_isSubWindow(isSubWindow)
|
||||
, m_window(nullptr)
|
||||
: QtWindowBase(isSubWindow, parent)
|
||||
, m_title(nullptr)
|
||||
, m_subTitle(nullptr)
|
||||
, m_nextButton(nullptr)
|
||||
@@ -22,68 +19,7 @@ QtWindow::QtWindow(bool isSubWindow, QWidget* parent)
|
||||
, m_cancelAble(true)
|
||||
, m_scrollAble(false)
|
||||
, m_hasLogo(false)
|
||||
, m_mousePressedInWindow(false)
|
||||
, m_sizeGrip(nullptr)
|
||||
{
|
||||
if (isSubWindow)
|
||||
{
|
||||
setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowFlags(Qt::Window);
|
||||
}
|
||||
|
||||
m_window = new QWidget(this);
|
||||
m_window->setObjectName("window");
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(m_window);
|
||||
layout->setSpacing(0);
|
||||
|
||||
m_content = new QWidget();
|
||||
layout->addWidget(m_content);
|
||||
|
||||
if (isSubWindow)
|
||||
{
|
||||
std::string frameStyle =
|
||||
"#window {"
|
||||
" border: 1px solid lightgray;"
|
||||
" border-radius: 15px;"
|
||||
" background: white;"
|
||||
"}";
|
||||
m_window->setStyleSheet(frameStyle.c_str());
|
||||
|
||||
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
||||
effect->setBlurRadius(15);
|
||||
effect->setXOffset(0);
|
||||
effect->setYOffset(5);
|
||||
effect->setColor(Qt::darkGray);
|
||||
m_window->setGraphicsEffect(effect);
|
||||
|
||||
QHBoxLayout* gripLayout = new QHBoxLayout();
|
||||
m_sizeGrip = new QSizeGrip(m_window);
|
||||
setSizeGripStyle(true);
|
||||
gripLayout->addWidget(new QWidget());
|
||||
gripLayout->addWidget(m_sizeGrip);
|
||||
layout->addLayout(gripLayout);
|
||||
}
|
||||
|
||||
resize(sizeHint());
|
||||
|
||||
moveToCenter();
|
||||
|
||||
this->raise();
|
||||
}
|
||||
|
||||
QSize QtWindow::sizeHint() const
|
||||
{
|
||||
return QSize(
|
||||
ApplicationSettings::getInstance()->getWindowBaseWidth(),
|
||||
ApplicationSettings::getInstance()->getWindowBaseHeight()
|
||||
);
|
||||
}
|
||||
|
||||
void QtWindow::setup()
|
||||
@@ -143,24 +79,6 @@ void QtWindow::setup()
|
||||
setupDone();
|
||||
}
|
||||
|
||||
void QtWindow::setSizeGripStyle(bool isBlack)
|
||||
{
|
||||
if (!m_sizeGrip)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const std::wstring path = isBlack ? L"size_grip_black.png" : L"size_grip_white.png";
|
||||
|
||||
m_sizeGrip->setStyleSheet(QString::fromStdWString(
|
||||
L"QSizeGrip {"
|
||||
" max-height: 16px;"
|
||||
" max-width: 16px;"
|
||||
" border-image: url(" + ResourcePaths::getGuiPath().wstr() + L"window/" + path + L");"
|
||||
"}"
|
||||
));
|
||||
}
|
||||
|
||||
void QtWindow::setCancelAble(bool cancelable)
|
||||
{
|
||||
setCloseEnabled(cancelable);
|
||||
@@ -178,32 +96,6 @@ bool QtWindow::isScrollAble() const
|
||||
return m_scrollAble;
|
||||
}
|
||||
|
||||
bool QtWindow::isSubWindow() const
|
||||
{
|
||||
return m_isSubWindow;
|
||||
}
|
||||
|
||||
void QtWindow::moveToCenter()
|
||||
{
|
||||
if (parentWidget())
|
||||
{
|
||||
if (m_isSubWindow)
|
||||
{
|
||||
move(
|
||||
parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||
parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
move(
|
||||
parentWidget()->pos().x() + parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||
parentWidget()->pos().y() + parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::updateTitle(const QString& title)
|
||||
{
|
||||
if (m_title)
|
||||
@@ -325,16 +217,6 @@ void QtWindow::setCloseDefault(bool isDefault)
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::showWindow()
|
||||
{
|
||||
show();
|
||||
}
|
||||
|
||||
void QtWindow::hideWindow()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void QtWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
handleClose();
|
||||
@@ -423,53 +305,6 @@ void QtWindow::keyPressEvent(QKeyEvent* event)
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void QtWindow::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow)
|
||||
{
|
||||
if (m_isSubWindow)
|
||||
{
|
||||
QPoint pos = event->globalPos() - m_dragPosition;
|
||||
QRect parentRect = parentWidget()->rect();
|
||||
|
||||
if (pos.x() < parentRect.left())
|
||||
{
|
||||
pos.setX(parentRect.left());
|
||||
}
|
||||
pos.setX(qBound(parentRect.left(), parentRect.right() - width(), pos.x()));
|
||||
pos.setY(qBound(parentRect.top(), parentRect.bottom() - height(), pos.y()));
|
||||
|
||||
move(pos);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
move(event->globalPos() - m_dragPosition);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||
event->accept();
|
||||
m_mousePressedInWindow = true;
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||
event->accept();
|
||||
m_mousePressedInWindow = false;
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::populateWindow(QWidget* widget)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user