|
Message-ID: <20150417210550.GA5384@openwall.com> Date: Sat, 18 Apr 2015 00:05:50 +0300 From: Aleksey Cherepanov <lyosha@...nwall.com> To: john-dev@...ts.openwall.com Subject: Re: Improving Johnny On Fri, Apr 17, 2015 at 10:31:25PM +0300, Shinnok wrote: > > > On Apr 16, 2015, at 4:16 PM, Mathieu Laprise <mathlaprise@...il.com <mailto:mathlaprise@...il.com>> wrote: > > > > Hey guys, > > I continue working on what we said yesterday. Here is just a quick update saying why I didn't finished yet. > > There is probably a problem in the layout logic somewhere in the MainWindow designer file. In 2012, Aleksey found a workaround by specifying a maximum size and a magic numbe for the left menu bar : > > // TODO: Magic number. It seems to be wrong approach. > > m_ui->listWidgetTabs->setMaximumWidth(m_ui->listWidgetTabs->sizeHintForColumn(0) + 4); > > > > This workaround works most of the time but when you change the text dynamically in the MainWindow class by choosing french in the setting's list. I apply a translator, call the QT built-in method retranslateUi and everything layout correctly except the listWidgetTabs. As you can see on the screenshot http://i.imgur.com/8yZ0vkb.jpg <http://i.imgur.com/8yZ0vkb.jpg> , the listWidgetTabs object don't resize correctly when we add a bigger text than it previously contained(french word "Mot de passe" is bigger than "Password"). The rest of the screen looks great with translation because the layouts do their jobs and there are no hardcoded values. > > > > I tried to force relayout by calling update, updateGeometry, repaint and doing similar to what Aleksey did. However, it doesn't work. It only works when you read the settings and translate the application in main.cpp, before MainWindow is created. (http://i.imgur.com/YTvljPh.png <http://i.imgur.com/YTvljPh.png>) > > > > So we have two solutions: > > > > 1- Remove the work around with a magic number and find a real fix. What makes it harder is that all UI code for all screens is in the same file(mainwindow.ui) so I'll have to proceed with care while making changes to layouts. > > > > 2- On first startup, the application will choose system language(ex: french). If the user go in the settings to choose english, he has to restart the application for the changes to take effects. For all further startups, the language will be english. > > > > > This is a limitation of QListWidget that warrants a workaround. The proper fix for this with Qt >= 5.2.0 is to set QListWidget::SizeAdjustPolicy to QAbstractScrollArea::AdjustToContents. This is what you end up with: > > https://www.dropbox.com/s/je1fhj0cqx4y5ax/Screen%20Shot%202015-04-17%20at%2010.14.27%20PM.png?dl=0 <https://www.dropbox.com/s/je1fhj0cqx4y5ax/Screen%20Shot%202015-04-17%20at%2010.14.27%20PM.png?dl=0> > > 1. Automatic adjust to contents on the fly. > 2. Things that are really way to big will get elided. (thankfully there's eliding already in ListWidget) > 3. All else on defaults(Layouts to preferred, no max-mins, no resize, ..). > > In my example I removed the setMaximumWidth call in MainWindow. As a general rule of thumb in UI design, we should never use a max constraint anywhere unless that's really the last resort. I'll look for the best approach to #ifdef for Qt <= 5.2. > > I should have some time tomorrow to deal with the repo issue, so that we can proceed to commiting the various changes we're talking about. > > PS: We might have to #ifdef the Qt 4 support back in like Mathieu did(Kali, KDE4 compat., etc..), shouldn't be that hard since there are just a couple of changes for 5. Though at some point I'd really like to get rid of it. http://stackoverflow.com/questions/6337589/qlistwidget-adjust-size-to-content The solution is to subclass QListWidget overriding sizeHint to return sizeHintForColumn(0) as width. Though for me, it is needed to add 4 pixels, hence the hardcoded value (though it is not need in default desktop environment). So I propose to move m_ui->listWidgetTabs->setMaximumWidth(m_ui->listWidgetTabs->sizeHintForColumn(0)); into sizeHint of a subclass of QListWidget. Old mail about width http://openwall.com/lists/john-dev/2012/08/20/1 > > - Fedora gives "..." in "Passwords" label > > always under gnome3 fallback mode(?) > > I've seen it on other distros as well (openSUSE, Ubuntu), when testing > older versions of Johnny - talking to my X server over SSH port > forwarding. I think it's not dependent on what distro Johnny runs on, > but rather what distro (fonts) the X server runs on. Yet you need to > fix it in Johnny somehow. Old mail about problems with small window height http://openwall.com/lists/john-dev/2012/08/19/10 small height causes scrollbar to appear in list widget, the width of the widget is not adjusted so items are shrunk and labels are reduced. Thanks! -- Regards, Aleksey Cherepanov
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.