@@ -39,39 +39,25 @@ QTMImagePopup::QTMImagePopup (QWidget* parent, qt_simple_widget_rep* owner)
3939 effect->setOffset (0 , 4 );
4040 effect->setColor (QColor (0 , 0 , 0 , 120 ));
4141 this ->setGraphicsEffect (effect);
42-
43- QScreen* Screen= QGuiApplication::primaryScreen ();
44- const double Dpi = Screen ? Screen->logicalDotsPerInch () : 96.0 ;
45- const double Scale = Dpi / 96.0 ;
46- #if defined(Q_OS_MAC)
47- const int IconSize= int (50 * Scale);
48- #else
49- const int IconSize= int (40 * Scale);
50- #endif
51-
5242 leftBtn= new QToolButton ();
5343 leftBtn->setObjectName (" image-align-button" );
5444 leftBtn->setProperty (" icon-name" , " left" );
5545 leftBtn->setIcon (QIcon (" :/window-bar/left-align.svg" ));
56- leftBtn->setIconSize (QSize (IconSize, IconSize));
5746 leftBtn->setCheckable (true );
5847 middleBtn= new QToolButton ();
5948 middleBtn->setObjectName (" image-align-button" );
6049 middleBtn->setProperty (" icon-name" , " center" );
6150 middleBtn->setIcon (QIcon (" :/window-bar/middle-align.svg" ));
62- middleBtn->setIconSize (QSize (IconSize, IconSize));
6351 middleBtn->setCheckable (true );
6452 rightBtn= new QToolButton ();
6553 rightBtn->setObjectName (" image-align-button" );
6654 rightBtn->setProperty (" icon-name" , " right" );
6755 rightBtn->setIcon (QIcon (" :/window-bar/right-align.svg" ));
68- rightBtn->setIconSize (QSize (IconSize, IconSize));
6956 rightBtn->setCheckable (true );
7057 ocrBtn= new QToolButton ();
7158 ocrBtn->setObjectName (" image-align-button" );
7259 ocrBtn->setProperty (" icon-name" , " ocr" );
7360 ocrBtn->setIcon (QIcon (" :/window-bar/ocr.svg" ));
74- ocrBtn->setIconSize (QSize (IconSize, IconSize));
7561 QButtonGroup* alignGroup= new QButtonGroup (this );
7662 alignGroup->addButton (leftBtn);
7763 alignGroup->addButton (middleBtn);
10187QTMImagePopup::showImagePopup (rectangle selr, double magf, int scroll_x,
10288 int scroll_y, int canvas_x) {
10389 cachePosition (selr, magf, scroll_x, scroll_y, canvas_x);
104- this ->adjustSize ();
90+ if (cached_magf <= 0.16 ) {
91+ setFixedSize (0 , 0 );
92+ return ;
93+ }
94+ autoSize ();
10595 int x, y;
10696 getCachedPosition (x, y);
10797 QPoint topLeft (x, y);
@@ -138,6 +128,26 @@ QTMImagePopup::updatePosition () {
138128 move (pos_x, pos_y);
139129}
140130
131+ void
132+ QTMImagePopup::autoSize () {
133+ QScreen* Screen = QGuiApplication::primaryScreen ();
134+ const double Dpi = Screen ? Screen->logicalDotsPerInch () : 96.0 ;
135+ const double Scale = Dpi / 96.0 ;
136+ const int baseWidth = 200 ;
137+ const int baseHeight= 50 ;
138+ double totalScale= Scale * cached_magf * 3.3 ;
139+ #if defined(Q_OS_MAC)
140+ const int IconSize= int (50 * Scale);
141+ #else
142+ const int IconSize= int (40 * totalScale);
143+ #endif
144+ leftBtn->setIconSize (QSize (IconSize, IconSize));
145+ middleBtn->setIconSize (QSize (IconSize, IconSize));
146+ rightBtn->setIconSize (QSize (IconSize, IconSize));
147+ ocrBtn->setIconSize (QSize (IconSize, IconSize));
148+ setFixedSize (int (baseWidth * totalScale), int (baseHeight * totalScale));
149+ }
150+
141151void
142152QTMImagePopup::cachePosition (rectangle selr, double magf, int scroll_x,
143153 int scroll_y, int canvas_x) {
0 commit comments