From 0748751c9f097d9d866605306bbdd4b96e2a5c4e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 27 Apr 2011 19:16:41 +0200 Subject: Squashed commit of the changes from the mobile-examples repository (4.7-generated-declarative branch). --- examples/painting/fontsampler/fontsampler.pro | 1 + examples/painting/fontsampler/main.cpp | 4 + examples/painting/fontsampler/mainwindow.cpp | 56 ++++++----- examples/painting/fontsampler/mainwindow.h | 4 + examples/painting/fontsampler/mainwindowbase.ui | 126 ++++++++++++------------ 5 files changed, 106 insertions(+), 85 deletions(-) (limited to 'examples/painting/fontsampler') diff --git a/examples/painting/fontsampler/fontsampler.pro b/examples/painting/fontsampler/fontsampler.pro index b9328a6439..6d93d913e8 100644 --- a/examples/painting/fontsampler/fontsampler.pro +++ b/examples/painting/fontsampler/fontsampler.pro @@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/fontsampler INSTALLS += target sources symbian: CONFIG += qt_example +maemo5: CONFIG += qt_example diff --git a/examples/painting/fontsampler/main.cpp b/examples/painting/fontsampler/main.cpp index 01c8adae53..dffe80348a 100644 --- a/examples/painting/fontsampler/main.cpp +++ b/examples/painting/fontsampler/main.cpp @@ -46,6 +46,10 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow window; +#if defined(Q_OS_SYMBIAN) + window.showMaximized(); +#else window.show(); +#endif return app.exec(); } diff --git a/examples/painting/fontsampler/mainwindow.cpp b/examples/painting/fontsampler/mainwindow.cpp index 0976d1f971..96698437b1 100644 --- a/examples/painting/fontsampler/mainwindow.cpp +++ b/examples/painting/fontsampler/mainwindow.cpp @@ -47,6 +47,10 @@ MainWindow::MainWindow(QWidget *parent) { setupUi(this); +#if defined(Q_OS_SYMBIAN) + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); +#endif + sampleSizes << 32 << 24 << 16 << 14 << 12 << 8 << 4 << 2 << 1; markedCount = 0; setupFontTree(); @@ -140,7 +144,11 @@ void MainWindow::showFont(QTreeWidgetItem *item) QString oldText = textEdit->toPlainText().trimmed(); bool modified = textEdit->document()->isModified(); textEdit->clear(); +#if defined(Q_OS_SYMBIAN) + textEdit->document()->setDefaultFont(QFont(family, 10, weight, italic)); +#else textEdit->document()->setDefaultFont(QFont(family, 32, weight, italic)); +#endif QTextCursor cursor = textEdit->textCursor(); QTextBlockFormat blockFormat; @@ -217,6 +225,30 @@ void MainWindow::updateStyles(QTreeWidgetItem *item, int column) printPreviewAction->setEnabled(markedCount > 0); } +QMap MainWindow::currentPageMap() +{ + QMap pageMap; + + for (int row = 0; row < fontTree->topLevelItemCount(); ++row) { + QTreeWidgetItem *familyItem = fontTree->topLevelItem(row); + QString family; + + if (familyItem->checkState(0) == Qt::Checked) { + family = familyItem->text(0); + pageMap[family] = StyleItems(); + } + + for (int childRow = 0; childRow < familyItem->childCount(); ++childRow) { + QTreeWidgetItem *styleItem = familyItem->child(childRow); + if (styleItem->checkState(0) == Qt::Checked) + pageMap[family].append(styleItem); + } + } + + return pageMap; +} + +#ifndef QT_NO_PRINTER void MainWindow::on_printAction_triggered() { pageMap = currentPageMap(); @@ -283,29 +315,6 @@ void MainWindow::on_printPreviewAction_triggered() preview.exec(); } -QMap MainWindow::currentPageMap() -{ - QMap pageMap; - - for (int row = 0; row < fontTree->topLevelItemCount(); ++row) { - QTreeWidgetItem *familyItem = fontTree->topLevelItem(row); - QString family; - - if (familyItem->checkState(0) == Qt::Checked) { - family = familyItem->text(0); - pageMap[family] = StyleItems(); - } - - for (int childRow = 0; childRow < familyItem->childCount(); ++childRow) { - QTreeWidgetItem *styleItem = familyItem->child(childRow); - if (styleItem->checkState(0) == Qt::Checked) - pageMap[family].append(styleItem); - } - } - - return pageMap; -} - void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer) { QString family = pageMap.keys()[index]; @@ -370,3 +379,4 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer) painter->restore(); } +#endif diff --git a/examples/painting/fontsampler/mainwindow.h b/examples/painting/fontsampler/mainwindow.h index 7ea4cd5ed0..4021ee7c6c 100644 --- a/examples/painting/fontsampler/mainwindow.h +++ b/examples/painting/fontsampler/mainwindow.h @@ -61,11 +61,15 @@ public: public slots: void on_clearAction_triggered(); void on_markAction_triggered(); +#ifndef QT_NO_PRINTER void on_printAction_triggered(); void on_printPreviewAction_triggered(); +#endif void on_unmarkAction_triggered(); +#ifndef QT_NO_PRINTER void printDocument(QPrinter *printer); void printPage(int index, QPainter *painter, QPrinter *printer); +#endif void showFont(QTreeWidgetItem *item); void updateStyles(QTreeWidgetItem *item, int column); diff --git a/examples/painting/fontsampler/mainwindowbase.ui b/examples/painting/fontsampler/mainwindowbase.ui index 6545b34083..1a95ebd6d1 100644 --- a/examples/painting/fontsampler/mainwindowbase.ui +++ b/examples/painting/fontsampler/mainwindowbase.ui @@ -1,10 +1,8 @@ - - - - + + MainWindowBase - - + + 0 0 @@ -12,129 +10,133 @@ 345 - + Font Sampler - - - - 9 - - + + + 6 + + 9 + - + - - + + 0 0 800 - 24 + 18 - - + + &Selection - - - + + + - - + + &File - - - + + + - - + + - - - - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::NoDockWidgetFeatures + + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable - + Available Fonts - + 1 - - - - 9 - - + + + 6 + + 9 + - - + + QAbstractItemView::ExtendedSelection + + + 1 + + - - + + false - + &Print... - + Ctrl+P - - + + E&xit - + Ctrl+Q - - + + &Mark - + Ctrl+M - - + + &Unmark - + Ctrl+U - - + + &Clear - - + + false - + Print Preview... - -- cgit v1.2.3