Resize bug fixed

This commit is contained in:
Rafael 2016-12-02 13:55:27 +01:00
parent 701a91a4a7
commit 49ecc712a0
7 changed files with 32 additions and 2 deletions

View file

@ -45,6 +45,7 @@
#include <QKeyEvent>
#include <QMimeData>
#include <QToolBar>
#include <QPicture>
#include <QBuffer>
#include <QDebug>
#include <QList>
@ -85,6 +86,9 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
// Global map
globalMap = GlobalString::getGlobalMap();
// Event connects
connect(ui->labJSON, SIGNAL(resized(QSize)), this, SLOT(adaptNewDialogSize(QSize)));
installEventFilter(this);
installEventFilter(ui->labPicture);
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
@ -114,6 +118,18 @@ void PictureDialog::addPreviousNextButtons()
#endif
}
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
int newDialogHeight = ui->labPicture->pixmap()->height();
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
setMinimumSize(width(), newDialogHeight);
setMaximumSize(width(), newDialogHeight);
resize(width(), newDialogHeight);
ui->labPicture->updateGeometry();
ui->jsonFrame->updateGeometry();
}
void PictureDialog::stylizeDialog()
{
#ifdef GTA5SYNC_WIN

View file

@ -53,6 +53,7 @@ public slots:
void playerNameUpdated();
void dialogNextPictureRequested();
void dialogPreviousPictureRequested();
void adaptNewDialogSize(QSize newLabelSize);
void exportCustomContextMenuRequested(const QPoint &pos);
private slots:

View file

@ -93,7 +93,7 @@
<number>4</number>
</property>
<item>
<widget class="QLabel" name="labJSON">
<widget class="UiModLabel" name="labJSON">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -189,7 +189,8 @@
<string>&amp;Close</string>
</property>
<property name="icon">
<iconset theme="dialog-close"/>
<iconset theme="dialog-close">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>

View file

@ -228,6 +228,7 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
QString newWidgetKey = pictureKeyList.at(picIndex);
SnapmaticWidget *picWidget = (SnapmaticWidget*)widgets.key(newWidgetKey);
picDialog->setSnapmaticPicture(picWidget->getPicture(), picIndex);
//picDialog->adaptNewDialogSize();
}
}
}
@ -261,6 +262,7 @@ void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
QString newWidgetKey = pictureKeyList.at(picIndex );
SnapmaticWidget *picWidget = (SnapmaticWidget*)widgets.key(newWidgetKey);
picDialog->setSnapmaticPicture(picWidget->getPicture(), picIndex);
//picDialog->adaptNewDialogSize();
}
}
}

View file

@ -122,6 +122,7 @@ void SnapmaticWidget::on_cmdView_clicked()
// show picture dialog
picDialog->show();
if (navigationBar) picDialog->stylizeDialog();
//picDialog->adaptNewDialogSize();
picDialog->setMinimumSize(picDialog->size());
picDialog->setMaximumSize(picDialog->size());
picDialog->exec();

View file

@ -60,3 +60,9 @@ void UiModLabel::mouseDoubleClickEvent(QMouseEvent *ev)
QLabel::mouseDoubleClickEvent(ev);
emit mouseDoubleClicked(ev->button());
}
void UiModLabel::resizeEvent(QResizeEvent *ev)
{
QLabel::resizeEvent(ev);
emit resized(ev->size());
}

View file

@ -22,6 +22,7 @@
#include <QWidget>
#include <QString>
#include <QLabel>
#include <QSize>
class UiModLabel : public QLabel
{
@ -37,12 +38,14 @@ protected:
void mousePressEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev);
void resizeEvent(QResizeEvent *ev);
signals:
void mouseMoved();
void mousePressed(Qt::MouseButton button);
void mouseReleased(Qt::MouseButton button);
void mouseDoubleClicked(Qt::MouseButton button);
void resized(QSize newSize);
};
#endif // UIMODLABEL_H