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 <QKeyEvent>
#include <QMimeData> #include <QMimeData>
#include <QToolBar> #include <QToolBar>
#include <QPicture>
#include <QBuffer> #include <QBuffer>
#include <QDebug> #include <QDebug>
#include <QList> #include <QList>
@ -85,6 +86,9 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
// Global map // Global map
globalMap = GlobalString::getGlobalMap(); globalMap = GlobalString::getGlobalMap();
// Event connects
connect(ui->labJSON, SIGNAL(resized(QSize)), this, SLOT(adaptNewDialogSize(QSize)));
installEventFilter(this); installEventFilter(this);
installEventFilter(ui->labPicture); installEventFilter(ui->labPicture);
ui->labPicture->setFocusPolicy(Qt::StrongFocus); ui->labPicture->setFocusPolicy(Qt::StrongFocus);
@ -114,6 +118,18 @@ void PictureDialog::addPreviousNextButtons()
#endif #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() void PictureDialog::stylizeDialog()
{ {
#ifdef GTA5SYNC_WIN #ifdef GTA5SYNC_WIN

View file

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

View file

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

View file

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

View file

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

View file

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