misc: lower minimum window size limit

This commit is contained in:
Gary Wang 2020-07-27 20:47:54 +08:00
parent 20be5e6f4f
commit 31fae2cc8c
4 changed files with 19 additions and 8 deletions

View File

@ -142,12 +142,16 @@ void GraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadio
applyTransformationModeByScaleFactor(); applyTransformationModeByScaleFactor();
} }
void GraphicsView::checkAndDoFitInView() void GraphicsView::checkAndDoFitInView(bool markItOnAnyway)
{ {
if (!isThingSmallerThanWindowWith(transform())) { if (!isThingSmallerThanWindowWith(transform())) {
m_enableFitInView = true; m_enableFitInView = true;
fitInView(sceneRect(), Qt::KeepAspectRatio); fitInView(sceneRect(), Qt::KeepAspectRatio);
} }
if (markItOnAnyway) {
m_enableFitInView = true;
}
} }
void GraphicsView::toggleCheckerboard() void GraphicsView::toggleCheckerboard()

View File

@ -30,7 +30,7 @@ public:
void rotateView(qreal rotateAngel); void rotateView(qreal rotateAngel);
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio); void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
void checkAndDoFitInView(); void checkAndDoFitInView(bool markItOnAnyway = true);
signals: signals:
void navigatorViewRequired(bool required, qreal angle); void navigatorViewRequired(bool required, qreal angle);

View File

@ -29,7 +29,7 @@ MainWindow::MainWindow(QWidget *parent) :
{ {
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setMinimumSize(710, 530); this->setMinimumSize(350, 350);
this->setWindowIcon(QIcon(":/icons/app-icon.svg")); this->setWindowIcon(QIcon(":/icons/app-icon.svg"));
this->setMouseTracking(true); this->setMouseTracking(true);
@ -187,11 +187,11 @@ void MainWindow::adjustWindowSizeBySceneRect()
QSize screenSize = qApp->screenAt(QCursor::pos())->availableSize(); QSize screenSize = qApp->screenAt(QCursor::pos())->availableSize();
if (screenSize.expandedTo(sceneSize) == screenSize) { if (screenSize.expandedTo(sceneSize) == screenSize) {
// we can show the picture by increase the window size. // we can show the picture by increase the window size.
if (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) { QSize finalSize = (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) ?
this->resize(sceneSizeWithMargins); sceneSizeWithMargins : screenSize;
} else { // We have a very reasonable sizeHint() value ;P
this->resize(screenSize); this->resize(finalSize.expandedTo(this->sizeHint()));
}
// We're sure the window can display the whole thing with 1:1 scale. // We're sure the window can display the whole thing with 1:1 scale.
// The old window size may cause fitInView call from resize() and the // The old window size may cause fitInView call from resize() and the
// above resize() call won't reset the scale back to 1:1, so we // above resize() call won't reset the scale back to 1:1, so we
@ -559,6 +559,11 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
#endif // _WIN32 #endif // _WIN32
} }
QSize MainWindow::sizeHint() const
{
return QSize(710, 530);
}
void MainWindow::centerWindow() void MainWindow::centerWindow()
{ {
this->setGeometry( this->setGeometry(

View File

@ -50,6 +50,8 @@ protected slots:
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
QSize sizeHint() const override;
void centerWindow(); void centerWindow();
void closeWindow(); void closeWindow();
void updateWidgetsPosition(); void updateWidgetsPosition();