13 #include <qapplication.h> 15 #include <qstringlist.h> 17 #include <QDesktopWidget> 22 #define SUBALBUM_TEXT_LENGTH 35 23 #define PHOTO_TEXT_LENGTH 35 30 QRect appRec = qApp->mainWidget()->frameGeometry();
31 QRect windowRec = window->frameGeometry();
38 if(windowRec.width() < appRec.width())
39 { x = appRec.x() + ((appRec.width() - windowRec.width())/2); }
44 if(windowRec.height() < appRec.height())
45 { y = appRec.y() + ((appRec.height() - windowRec.height())/2); }
50 QRect screen = QApplication::desktop()->availableGeometry();
53 if(x + windowRec.width() > screen.width() )
54 x = screen.width() - windowRec.width();
61 if(y + windowRec.height() > screen.height() )
62 y = screen.height() - windowRec.height();
69 window->move( QPoint( x, y) );
72 QString
clipText(QString
string,
int lines,
int lineWidth)
81 QString building =
"";
82 QFontMetrics fm( qApp->font() );
85 while(
string.length() > 0 && lines > 0)
87 bool spaceFound =
false;
91 while(
string.length() > 0)
95 if(fm.width( QString(line + building +
string.at(0) ) ) < lineWidth )
97 building = building +
string.at(0);
101 if(
string.at(0) ==
' ')
103 line = line + building;
106 string =
string.remove(0, 1);
110 string =
string.remove(0, 1);
111 if(
string.length() == 0)
113 line = line + building;
122 if(!spaceFound || lines == 1)
125 building = building + string;
128 line = line + building;
129 if(fm.width( line ) > lineWidth )
131 while( fm.width(line +
"...") > lineWidth )
133 line.truncate( line.length() - 1);
144 result = result + line;