QDesignerSettings Class Reference

#include <qdesigner_settings.h>

Inheritance diagram for QDesignerSettings:

Inheritance graph
[legend]
Collaboration diagram for QDesignerSettings:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 30 of file qdesigner_settings.h.

Public Member Functions

 QDesignerSettings ()
virtual ~QDesignerSettings ()
QStringList formTemplatePaths () const
void setFormTemplatePaths (const QStringList &paths)
QString defaultUserWidgetBoxXml () const
void setGeometryFor (QWidget *w, const QRect &fallBack=QRect()) const
void saveGeometryFor (const QWidget *w)
QStringList recentFilesList () const
void setRecentFilesList (const QStringList &list)
void setShowNewFormOnStartup (bool showIt)
bool showNewFormOnStartup () const
void setUIMode (int mode)
int uiMode () const
QByteArray mainWindowState () const
void setMainWindowState (const QByteArray &mainWindowState)

Private Member Functions

QStringList defaultFormTemplatePaths () const
void setGeometryHelper (QWidget *w, const QString &key, const QRect &fallBack) const
void saveGeometryHelper (const QWidget *w, const QString &key)

Private Attributes

QString m_designerPath


Constructor & Destructor Documentation

QDesignerSettings::QDesignerSettings (  ) 

Definition at line 39 of file qdesigner_settings.cpp.

References QDir::current(), defaultFormTemplatePaths(), m_designerPath, QDir::mkpath(), and path.

00040     : QSettings()
00041 {
00042     m_designerPath = QLatin1String("/.designer");
00043 
00044     QStringList paths = defaultFormTemplatePaths();
00045     foreach (QString path, paths) {
00046         if (!QDir::current().exists(path))
00047             QDir::current().mkpath(path);
00048     }
00049 }

Here is the call graph for this function:

QDesignerSettings::~QDesignerSettings (  )  [virtual]

Definition at line 51 of file qdesigner_settings.cpp.

00052 {
00053 }


Member Function Documentation

QStringList QDesignerSettings::formTemplatePaths (  )  const

Definition at line 55 of file qdesigner_settings.cpp.

References defaultFormTemplatePaths(), QVariant::toStringList(), and QSettings::value().

Referenced by NewForm::NewForm(), and SaveFormAsTemplate::SaveFormAsTemplate().

00056 {
00057     return value(QLatin1String("FormTemplatePaths"),
00058                  defaultFormTemplatePaths()).toStringList();
00059 }

Here is the call graph for this function:

void QDesignerSettings::setFormTemplatePaths ( const QStringList paths  ) 

Definition at line 61 of file qdesigner_settings.cpp.

References QSettings::setValue().

00062 {
00063     setValue(QLatin1String("FormTemplatePaths"), paths);
00064 }

Here is the call graph for this function:

QString QDesignerSettings::defaultUserWidgetBoxXml (  )  const

Definition at line 66 of file qdesigner_settings.cpp.

References QDir::homePath(), and m_designerPath.

00067 {
00068     return QDir::homePath() + m_designerPath + QLatin1String("/widgetbox.xml");
00069 }

Here is the call graph for this function:

void QDesignerSettings::setGeometryFor ( QWidget w,
const QRect fallBack = QRect() 
) const

Definition at line 89 of file qdesigner_settings.cpp.

References QRect::isNull(), setGeometryHelper(), and w.

Referenced by QDesignerWorkbench::switchToDockedMode(), and QDesignerWorkbench::switchToTopLevelMode().

00090 {
00091     Q_ASSERT(w && !w->objectName().isEmpty());
00092     setGeometryHelper(w, w->objectName(),
00093                       fallBack.isNull() ? QRect(QPoint(0, 0), w->sizeHint()) : fallBack);
00094 }

Here is the call graph for this function:

void QDesignerSettings::saveGeometryFor ( const QWidget w  ) 

Definition at line 83 of file qdesigner_settings.cpp.

References saveGeometryHelper(), and w.

Referenced by QDesignerWorkbench::saveSettings(), and QDesignerWorkbench::switchToDockedMode().

00084 {
00085     Q_ASSERT(w && !w->objectName().isEmpty());
00086     saveGeometryHelper(w, w->objectName());
00087 }

Here is the call graph for this function:

QStringList QDesignerSettings::recentFilesList (  )  const

Definition at line 164 of file qdesigner_settings.cpp.

References QVariant::toStringList(), and QSettings::value().

Referenced by QDesignerActions::addRecentFile(), and QDesignerActions::updateRecentFileActions().

00165 {
00166     return value(QLatin1String("recentFilesList")).toStringList();
00167 }

Here is the call graph for this function:

void QDesignerSettings::setRecentFilesList ( const QStringList list  ) 

Definition at line 169 of file qdesigner_settings.cpp.

References QSettings::setValue().

Referenced by QDesignerActions::addRecentFile(), QDesignerActions::clearRecentFiles(), and QDesignerActions::updateRecentFileActions().

00170 {
00171     setValue(QLatin1String("recentFilesList"), sl);
00172 }

Here is the call graph for this function:

void QDesignerSettings::setShowNewFormOnStartup ( bool  showIt  ) 

Definition at line 174 of file qdesigner_settings.cpp.

References QSettings::setValue().

00175 {
00176     setValue(QLatin1String("newFormDialog/ShowOnStartup"), showIt);
00177 }

Here is the call graph for this function:

bool QDesignerSettings::showNewFormOnStartup (  )  const

Definition at line 179 of file qdesigner_settings.cpp.

References QVariant::toBool(), and QSettings::value().

00180 {
00181     return value(QLatin1String("newFormDialog/ShowOnStartup"), true).toBool();
00182 }

Here is the call graph for this function:

void QDesignerSettings::setUIMode ( int  mode  ) 

Definition at line 184 of file qdesigner_settings.cpp.

References QSettings::setValue().

Referenced by QDesignerActions::updateUIMode().

00185 {
00186     setValue(QLatin1String("UI/currentMode"), mode);
00187 }

Here is the call graph for this function:

int QDesignerSettings::uiMode (  )  const

Definition at line 189 of file qdesigner_settings.cpp.

References QDesignerWorkbench::DockedMode, QVariant::toInt(), QDesignerWorkbench::TopLevelMode, and QSettings::value().

Referenced by QDesignerActions::QDesignerActions(), and QDesignerActions::updateUIMode().

00190 {
00191 #if defined(Q_WS_WIN)
00192     return value(QLatin1String("UI/currentMode"), QDesignerWorkbench::DockedMode).toInt();
00193 #else
00194     return value(QLatin1String("UI/currentMode"), QDesignerWorkbench::TopLevelMode).toInt();
00195 #endif
00196 }

Here is the call graph for this function:

QByteArray QDesignerSettings::mainWindowState (  )  const

Definition at line 198 of file qdesigner_settings.cpp.

References QVariant::toByteArray(), and QSettings::value().

Referenced by setMainWindowState(), and QDesignerWorkbench::switchToDockedMode().

00199 {
00200     return value(QLatin1String("MainWindowState")).toByteArray();
00201 }

Here is the call graph for this function:

void QDesignerSettings::setMainWindowState ( const QByteArray mainWindowState  ) 

Definition at line 203 of file qdesigner_settings.cpp.

References mainWindowState(), and QSettings::setValue().

Referenced by QDesignerWorkbench::~QDesignerWorkbench().

00204 {
00205     setValue(QLatin1String("MainWindowState"), mainWindowState);
00206 }

Here is the call graph for this function:

QStringList QDesignerSettings::defaultFormTemplatePaths (  )  const [private]

Definition at line 71 of file qdesigner_settings.cpp.

References QList< T >::append(), QDir::homePath(), m_designerPath, and qDesigner.

Referenced by formTemplatePaths(), and QDesignerSettings().

00072 {
00073     QStringList paths;
00074 
00075     QString templatePath = QLatin1String("/templates");
00076 
00077     paths.append(QDir::homePath() + m_designerPath + templatePath);
00078     paths.append(qDesigner->applicationDirPath() + templatePath);
00079 
00080     return paths;
00081 }

Here is the call graph for this function:

void QDesignerSettings::setGeometryHelper ( QWidget w,
const QString key,
const QRect fallBack 
) const [private]

Definition at line 110 of file qdesigner_settings.cpp.

References QDesktopWidget::availableGeometry(), QRect::bottom(), QRect::contains(), QApplication::desktop(), g, key, QRect::left(), qMax(), qMin(), QRect::right(), toBool(), QVariant::toInt(), QRect::top(), QVariant::toRect(), QSettings::value(), w, and Qt::WindowMaximized.

Referenced by setGeometryFor().

00112 {
00113 //    beginGroup();
00114     int screen = value(key + QLatin1String("/screen"), 0).toInt();
00115     QRect g = value(key + QLatin1String("/geometry"), fallBack).toRect();
00116     QRect screenRect = QApplication::desktop()->availableGeometry(screen);
00117 
00118     // Do geometry in a couple of steps
00119     // 1) Make sure the rect is within the specified geometry
00120     // 2) Make sure the bottom right and top left fit on the screen, move them in.
00121     // 3) Check again and resize.
00122 
00123     if (w->isWindow() && g.intersect(screenRect).isEmpty())
00124         g = fallBack;
00125 
00126     // Maybe use center?
00127     if (!screenRect.contains(g.bottomRight())) {
00128         g.moveRight(qMax(0 + g.width(), qMin(screenRect.right(), g.right())));
00129         g.moveBottom(qMax(0 + g.height(), qMin(screenRect.bottom(), g.bottom())));
00130     }
00131 
00132     if (!screenRect.contains(g.topLeft())) {
00133         g.moveLeft(qMin(screenRect.right() - g.width(), qMax(screenRect.left(), g.left())));
00134         g.moveTop(qMin(screenRect.bottom() - g.height(), qMax(screenRect.top(), g.top())));
00135     }
00136 
00137     if (!screenRect.contains(g.bottomRight())) {
00138         g.setRight(qMin(screenRect.right(), g.right()));
00139         g.moveBottom(qMin(screenRect.bottom(), g.bottom()));
00140     }
00141 
00142     if (!screenRect.contains(g.topLeft())) {
00143         g.setLeft(qMax(0, qMin(screenRect.left(), g.left())));
00144         g.moveTop(qMax(0, qMin(screenRect.top(), g.top())));
00145     }
00146 
00147 
00148     if (!w->isWindow()) // in workspace
00149         w->parentWidget()->move(g.topLeft());
00150     else
00151         w->move(g.topLeft());
00152 
00153     if (value(key + QLatin1String("/maximized"), false).toBool()) {
00154         w->setWindowState(w->windowState() | Qt::WindowMaximized);
00155     } else {
00156         w->resize(g.size());
00157     }
00158 
00159     if (value(key + QLatin1String("/visible"), true).toBool())
00160         w->show();
00161 //    endGroup();
00162 }

Here is the call graph for this function:

void QDesignerSettings::saveGeometryHelper ( const QWidget w,
const QString key 
) [private]

Definition at line 96 of file qdesigner_settings.cpp.

References QSettings::beginGroup(), QApplication::desktop(), QSettings::endGroup(), key, QSettings::setValue(), and w.

Referenced by saveGeometryFor().

00097 {
00098     beginGroup(key);
00099     QPoint pos = w->pos();
00100     if (!w->isWindow()) // in workspace
00101         pos = w->parentWidget()->pos();
00102 
00103     setValue(QLatin1String("screen"), QApplication::desktop()->screenNumber(w));
00104     setValue(QLatin1String("geometry"), QRect(pos, w->size()));
00105     setValue(QLatin1String("visible"), w->isVisible());
00106     setValue(QLatin1String("maximized"), w->isMaximized());
00107     endGroup();
00108 }

Here is the call graph for this function:


Member Data Documentation

QString QDesignerSettings::m_designerPath [private]

Definition at line 63 of file qdesigner_settings.h.

Referenced by defaultFormTemplatePaths(), defaultUserWidgetBoxXml(), and QDesignerSettings().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 17:19:26 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1