[KPhotoAlbum] [PATCH 2/3] SettingsData: Default window geometry calculated

Michael Witten mfwitten at MIT.EDU
Wed Sep 24 04:56:38 BST 2008


On 22 Sep 2008, at 10:18 PM, Michael Witten wrote:

> Qt 4.2 actually provides a mechanism for saving and restoring
> window state:
>
>    (1) QWidget::saveGeometry()
>    (2) QWidget::restoreGeometry()
>
> Maybe that's better to use, as it handles screens already and
> other state bits, such as whether the window is maximized.
> However, it doesn't provide centering and the implementation
> looks kind of messy.

On 23 Sep 2008, at 5:44 PM, Michael Witten wrote:

> On 23 Sep 2008, at 3:33 PM, Henner Zeller wrote:
>
>> Another thing: if you have really small screens and end up smaller
>> than say 600x400 you might want to boost the size again up to the
>> screensize - some pixels.
>
> The "- some pixels" is the hard part that will probably fail in a
> not insignificant number of cases.
>
> However, what about view->setWindowState( Qt::WindowFullScreen ); ?

I've got some fledgling support for handling multiple screens
by storing screen numbers as well as geometries:

     // If the setting for the screen is not valid, determine
     // a screen the makes sense. By default, the MainWindow
     // will be put on the primary screen, and all other
     // windows will be placed on the same screen as the
     // main window (or the primary screen):

         QDesktopWidget* d = QApplication::desktop();

         if ( screen == -1 || screen >= d->numScreens() )
         {
             if ( !strcmp(win, Settings::MainWindow) )
                 screen = d->primaryScreen();
             else
             {
                 screen = value( Settings::MainWindow, "screen", -1 );

                 if ( screen == -1 )
                     screen = d->primaryScreen();
             }
         }

     // If the setting does not exist or if the stored rectangle
     // is not within the available screen, assume there is a
     // problem and recalculate a new default geometry for the
     // window:

         QRect available = d->availableGeometry( screen );

         if ( geometry.width() && available.contains( geometry,true ) )
             return geometry;

The one problem I've come across is that the MainWindow and
AnnotationDialog have minimum sizes (imposed by their constituent
widgets), so that small screens (such as with extended desktops)
are too small for these windows, because the default is calculated
to be even smaller than these windows allow.

Perhaps this would be a good case for full screen mode, though
at some point it doesn't matter. It just gets too small, and
this tends to happen around width=800 height=600.

Maybe we can set sizeHint() to return an invalid rect, so that
people can proceed at their own risk.

Also, what about other dialogs and windows? I've found the
following, for instance:

     QSize MainWindow::StatisticsDialog::sizeHint() const
     {
         return QSize( 800, 800 );
     }

Michael Witten




More information about the Kphotoalbum mailing list