#include <Settings.h>
Static Public Member Functions | |
static void | activeTab (QTabWidget *w, QString name) |
static void | columnWidth (QTableView *w, QString name) |
static void | columnWidth (QTreeView *w, QString name) |
static QStringList | getDirHistory (const QString &caption) |
static QString | getFilter (QString name) |
static QStringList | getHistory (const QString &name) |
static QString | getPath (QString name) |
static void | getRect (QWidget *w, QString name) |
static void | getSize (QWidget *w, QString name) |
static QString | getText (QWidget *parent, const QString &caption, const QString &label, QLineEdit::EchoMode mode=QLineEdit::Normal, const QString &text=QString::null, bool *ok=0) |
static void | getWidget (QWidget *d, QString name=QString::null, bool rect=true) |
static bool | printSetup (QPrinter &p) |
static void | setActiveTab (QTabWidget *w, QString name) |
static void | setColumnWidth (QTableView *w, QString name) |
static void | setColumnWidth (QTreeView *w, QString name) |
static void | setDirHistory (const QString &caption, QDir newPath) |
static void | setFilter (QString name, QString filter) |
static void | setHistory (const QString &name, QString newString, int maxCount=20) |
static void | setPath (QString name, QDir dirPath) |
static void | setRect (QWidget *w, QString name) |
static void | setSize (QWidget *w, QString name) |
static void | setSplitter (QSplitter *w, QString name) |
static void | setWidget (QWidget *d, QString name=QString::null, bool rect=true) |
static void | splitter (QSplitter *w, QString name) |
void QGpGuiTools::Settings::activeTab | ( | QTabWidget * | w, |
QString | name | ||
) | [static] |
void QGpGuiTools::Settings::columnWidth | ( | QTableView * | w, |
QString | name | ||
) | [static] |
restore columms widths
References TRACE.
{ TRACE; QSettings reg; reg.beginGroup( "DialogOptions" ); reg.beginGroup(name); if(reg.contains(w->objectName())) { QStringList colWidthList=reg.value(w->objectName()).toStringList(); int n=colWidthList.count(); if(w->model()->columnCount()<n) n=w->model()->columnCount(); for(int i=0; i<n; i++ ) { w->setColumnWidth(i, colWidthList.at(i).toInt()); } } }
void QGpGuiTools::Settings::columnWidth | ( | QTreeView * | w, |
QString | name | ||
) | [static] |
restore columms widths
References TRACE.
{ TRACE; QSettings reg; reg.beginGroup( "DialogOptions" ); reg.beginGroup(name); if(reg.contains(w->objectName())) { QStringList colWidthList=reg.value(w->objectName()).toStringList(); int n=colWidthList.count(); if(w->model()->columnCount()<n) n=w->model()->columnCount(); for(int i=0; i<n; i++ ) { w->setColumnWidth(i, colWidthList.at(i).toInt()); } } }
QStringList QGpGuiTools::Settings::getDirHistory | ( | const QString & | caption | ) | [static] |
Restores the directory history from registry
References getHistory(), and TRACE.
{ TRACE; #ifdef Q_WS_MAC QSettings reg(qApp->organizationDomain()); #else QSettings reg(qApp->organizationName()); #endif reg.beginGroup( "DirectoryHistories" ); QStringList l=getHistory(reg, "common" ); l+=getHistory(reg, caption); // Check that all items exit for(int i=l.count()-1;i>=0;i--) { QDir d(l.at(i)); if(!d.exists()) l.removeAt(i); } // Add current directory QDir d; l.prepend(d.absolutePath()); return l; }
QString QGpGuiTools::Settings::getFilter | ( | QString | name | ) | [static] |
QStringList QGpGuiTools::Settings::getHistory | ( | const QString & | name | ) | [static] |
Restores history from registry
Referenced by getDirHistory(), QGpGuiTools::ColumnTextWidget::restoreParserSettings(), QGpGuiTools::FindReplaceWidget::setHistoryBaseName(), and QGpGuiTools::RegExpRowSelector::setView().
{ QSettings reg; return Settings::getHistory(reg, name); }
QString QGpGuiTools::Settings::getPath | ( | QString | name | ) | [static] |
Load a path from the registry
References TRACE.
{ TRACE; #ifdef Q_WS_MAC QSettings reg(qApp->organizationDomain()); #else QSettings reg(qApp->organizationName()); #endif reg.beginGroup( "CurrentDirectories" ); if(reg.contains(name)) { QDir d(reg.value(name).toString()); if(d.exists()) return d.absolutePath(); } return QDir::currentPath (); }
void QGpGuiTools::Settings::getRect | ( | QWidget * | w, |
QString | name | ||
) | [static] |
Load the widget's rectangle from the registry
References TRACE.
Referenced by QGpGuiTools::Dialog::getRect(), QGpGuiTools::FileDialog::getRect(), getWidget(), QGpGuiTools::PropertyEditor::PropertyEditor(), and QGpGuiTools::ExpandTabWidget::restoreState().
{ TRACE; bool ok, allOk=true; QSettings reg; reg.beginGroup("WidgetRect"); reg.beginGroup(name); if(reg.contains("x")) { int x=reg.value("x", w->x()).toInt(&ok); if( !ok) allOk=false; int y=reg.value("y", w->y()).toInt(&ok); if( !ok) allOk=false; int width=reg.value("width", w->width()).toInt(&ok); if( !ok) allOk=false; int height=reg.value("height", w->height()).toInt(&ok); if( !ok) allOk=false; if(allOk) { QDesktopWidget * desktop=QApplication::desktop(); QRect r; if(w->parentWidget()) { // On the screen of the parent widget, usually dialog boxes r=desktop->screenGeometry(w->parentWidget()); } else { // Complete screen available for top level widgets r=desktop->screen(desktop->primaryScreen())->rect(); } // QDesktopWidget::availableGeometry() does not work perfectly under Linux KDE Gentoo at least // prefer our old manual method. #if defined(Q_WS_WIN) if(y<40) y=40; y-=20; #endif if(x<r.left()) { x=r.left(); } else if(x>r.right()-width) { if(width>r.width()) { width=r.right()-x; } else { x=r.right()-width; } } if(y<r.top()) { y=r.top(); } else if(y>r.bottom()-height) { if(height>r.height()) { height=r.bottom()-y; } else { y=r.bottom()-height; } } w->move(x, y); if(width>0 && height>0) { w->resize(width, height); } } } }
void QGpGuiTools::Settings::getSize | ( | QWidget * | w, |
QString | name | ||
) | [static] |
Load the widget's size from the registry
References TRACE.
QString QGpGuiTools::Settings::getText | ( | QWidget * | parent, |
const QString & | caption, | ||
const QString & | label, | ||
QLineEdit::EchoMode | mode = QLineEdit::Normal , |
||
const QString & | text = QString::null , |
||
bool * | ok = 0 |
||
) | [static] |
QInputDialog::getText with save-retore mechanism
References TRACE.
{ TRACE; QSettings reg; reg.beginGroup( "DialogOptions" ); QString t=reg.value(caption).toString(); if( !text.isEmpty()) t=text; QString res=QInputDialog::getText(parent, caption, label, mode, t, ok); if( *ok) reg.setValue(caption, res); return res; }
void QGpGuiTools::Settings::getWidget | ( | QWidget * | d, |
QString | name = QString::null , |
||
bool | rect = true |
||
) | [static] |
Load the widget's settings from the registry.
Only the Qt common widgets are loaded.
References getRect(), and TRACE.
Referenced by QGpGuiTools::CoordinateFile::CoordinateFile(), and QGpGuiTools::CoordinateFile::write().
bool QGpGuiTools::Settings::printSetup | ( | QPrinter & | p | ) | [static] |
Set printer information from settings and/or user dialog
References TRACE.
{ TRACE; QSettings reg; reg.beginGroup( "PrintOptions" ); if(reg.contains( "printerName" )) { p.setPrinterName(reg.value( "printerName" ).toString()); } if(reg.contains( "outputFileName" )) { p.setOutputFileName(reg.value( "outputFileName" ).toString()); } if(reg.contains( "orientation" )) { p.setOrientation(( QPrinter::Orientation) reg.value( "orientation" ).toInt()); } if(reg.contains( "pageSize" )) { p.setPaperSize(( QPrinter::PaperSize) reg.value( "pageSize" ).toInt()); } if(reg.contains( "pageOrder" )) { p.setPageOrder(( QPrinter::PageOrder) reg.value( "pageOrder" ).toInt()); } if(reg.contains( "paperSource" )) { p.setPaperSource(( QPrinter::PaperSource) reg.value( "paperSource" ).toInt()); } if(reg.contains( "numCopies" )) { p.setNumCopies(reg.value( "numCopies" ).toInt()); } if(reg.contains( "outputFormat" )) { p.setOutputFormat(( QPrinter::OutputFormat) reg.value( "outputFormat" ).toInt()); } if(reg.contains( "colorMode" )) { p.setColorMode(( QPrinter::ColorMode) reg.value( "colorMode" ).toInt()); } if(reg.contains( "printRange" )) { p.setPrintRange(( QPrinter::PrintRange) reg.value( "printRange" ).toInt()); } if(reg.contains( "toPage" ) && reg.contains( "fromPage")) { p.setFromTo(reg.value( "fromPage" ).toInt(), reg.value( "toPage" ).toInt()); } if(reg.contains( "collateCopies" )) { p.setCollateCopies(reg.value( "collateCopies" ).toBool()); } p.setCreator(QApplication::applicationName()); QPrintDialog pd(&p); PrintDialogWrapper pdWrap(&pd); if(pd.exec()==QDialog::Accepted) { reg.setValue( "printerName", p.printerName()); reg.setValue( "outputFileName", p.outputFileName()); reg.setValue( "orientation", p.orientation()); reg.setValue( "pageSize", p.pageSize()); reg.setValue( "pageOrder", p.pageOrder()); reg.setValue( "paperSource", p.paperSource()); reg.setValue( "numCopies", p.numCopies()); reg.setValue( "outputFormat", p.outputFormat()); reg.setValue( "colorMode", p.colorMode()); reg.setValue( "printRange", p.printRange()); reg.setValue( "fromPage", p.fromPage()); reg.setValue( "toPage", p.toPage()); reg.setValue( "collateCopies", p.collateCopies()); return true; } else return false; }
void QGpGuiTools::Settings::setActiveTab | ( | QTabWidget * | w, |
QString | name | ||
) | [static] |
void QGpGuiTools::Settings::setColumnWidth | ( | QTableView * | w, |
QString | name | ||
) | [static] |
save columms widths
References TRACE.
Referenced by QGpGuiTools::ColumnTextWidget::~ColumnTextWidget().
void QGpGuiTools::Settings::setColumnWidth | ( | QTreeView * | w, |
QString | name | ||
) | [static] |
save columms widths
References TRACE.
void QGpGuiTools::Settings::setDirHistory | ( | const QString & | caption, |
QDir | newPath | ||
) | [static] |
Saves the directory history to registry
References setHistory(), and TRACE.
{ TRACE; #ifdef Q_WS_MAC QSettings reg(qApp->organizationDomain()); #else QSettings reg(qApp->organizationName()); #endif reg.beginGroup("DirectoryHistories"); setHistory(reg, caption, newPath.canonicalPath(), 17); setHistory(reg, "common", newPath.canonicalPath(), 3); }
void QGpGuiTools::Settings::setFilter | ( | QString | name, |
QString | filter | ||
) | [static] |
void QGpGuiTools::Settings::setHistory | ( | const QString & | name, |
QString | newString, | ||
int | maxCount = 20 |
||
) | [static] |
Saves the directory history to registry
Referenced by QGpGuiTools::ColumnTextWidget::saveParserSettings(), setDirHistory(), and QGpGuiTools::ColumnTextWidget::setParserFile().
{ QSettings reg; Settings::setHistory(reg, name, newString, maxCount); }
void QGpGuiTools::Settings::setPath | ( | QString | name, |
QDir | dirPath | ||
) | [static] |
Save a path in the registry
References TRACE.
{ TRACE; #ifdef Q_WS_MAC QSettings reg(qApp->organizationDomain()); #else QSettings reg(qApp->organizationName()); #endif reg.beginGroup( "CurrentDirectories" ); QString p=dirPath.canonicalPath(); reg.setValue(name, p); // Set current directory to dirPath, in case of uninitialized path // See getPath() QDir::setCurrent(p); }
void QGpGuiTools::Settings::setRect | ( | QWidget * | w, |
QString | name | ||
) | [static] |
Save the widget's rectangle in the registry if widget is visible
Be careful not to use QDialog if you want to save rectangles to registry, but Dialog.
References QGpGuiTools::Dialog::setRect(), and TRACE.
Referenced by QGpGuiTools::PropertyEditor::moveEvent(), QGpGuiTools::ExpandTabWidget::saveState(), and setWidget().
{ TRACE; Dialog * d=qobject_cast<Dialog *>(w); if(d) { d->setRect(name); } else { if(w->isVisible()) { QSettings reg; reg.beginGroup("WidgetRect"); reg.beginGroup(name); reg.setValue("x", w->x()); reg.setValue("y", w->y()); reg.setValue("width", w->width()); reg.setValue("height", w->height()); } } }
void QGpGuiTools::Settings::setSize | ( | QWidget * | w, |
QString | name | ||
) | [static] |
Save the widget's size in the registry (not the position)
References TRACE.
Referenced by QGpGuiTools::PropertyEditor::resizeEvent().
void QGpGuiTools::Settings::setSplitter | ( | QSplitter * | w, |
QString | name | ||
) | [static] |
void QGpGuiTools::Settings::setWidget | ( | QWidget * | d, |
QString | name = QString::null , |
||
bool | rect = true |
||
) | [static] |
Save widget's settings into the registry
Be careful not to use QDialog if you want to save rectangles to registry, but Dialog.
References setRect(), and TRACE.
Referenced by QGpGuiTools::CoordinateFile::read(), and QGpGuiTools::CoordinateFile::write().
void QGpGuiTools::Settings::splitter | ( | QSplitter * | w, |
QString | name | ||
) | [static] |
restore splitter positions
References TRACE.