int QPrintPreviewWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: paintRequested((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break;
        case 1: previewChanged(); break;
        case 2: print(); break;
        case 3: zoomIn((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 4: zoomIn(); break;
        case 5: zoomOut((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 6: zoomOut(); break;
        case 7: setZoomFactor((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 8: setOrientation((*reinterpret_cast< QPrinter::Orientation(*)>(_a[1]))); break;
        case 9: setViewMode((*reinterpret_cast< ViewMode(*)>(_a[1]))); break;
        case 10: setZoomMode((*reinterpret_cast< ZoomMode(*)>(_a[1]))); break;
        case 11: setCurrentPage((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 12: fitToWidth(); break;
        case 13: fitInView(); break;
        case 14: setLandscapeOrientation(); break;
        case 15: setPortraitOrientation(); break;
        case 16: setSinglePageViewMode(); break;
        case 17: setFacingPagesViewMode(); break;
        case 18: setAllPagesViewMode(); break;
        case 19: updatePreview(); break;
        case 20: d_func()->_q_fit(); break;
        case 21: d_func()->_q_updateCurrentPage(); break;
        }
        _id -= 22;
    }
    return _id;
}
Exemple #2
0
PhraseWidget::PhraseWidget(Phrase* phrase,QWidget *parent)
    : QWidget(parent) {

    m_phrase        = phrase;
    m_phraseEditor  = new PhraseEditor(m_phrase);

    m_refreshButton = new QToolButton(this);
    m_name          = new QLabel(m_phrase->name(),this);
    m_scrollArea    = new QScrollArea(this);
    m_pixmap        = new QLabel();

    m_refreshButton->setIcon(QIcon::fromTheme("accessories-text-editor"));

    m_name->setFixedWidth(100);

    m_scrollArea->setWidget(m_pixmap);
    m_scrollArea->setWidgetResizable(true);
    m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    if(m_phrase->image())
        m_pixmap->setPixmap(QPixmap::fromImage(*m_phrase->image()));

    QHBoxLayout* layout = new QHBoxLayout(this);

    layout->addWidget(m_name);
    layout->addWidget(m_refreshButton);
    layout->addWidget(m_scrollArea);

    connect(m_phrase,SIGNAL(previewChanged()),this,SLOT(updatePixmap()));
    connect(m_refreshButton,SIGNAL(clicked()),this,SLOT(openEditor()));
}
Exemple #3
0
void MainWindow::nextPage()
{
    const int currentPage = preview->currentPage();
    if (currentPage < preview->pageCount())
    {
	preview->setCurrentPage(currentPage + 1);
	previewChanged();
    }
}
Exemple #4
0
void MainWindow::previousPage()
{
    const int currentPage = preview->currentPage();
    if (currentPage > 1)
    {
	preview->setCurrentPage(currentPage - 1);
	previewChanged();
    }
}
Exemple #5
0
void Camera::c_previewStopped() {
    // Make sure that the signal is emitted before the old Image is deleted
    QSharedPointer<Image> tmp(m_latest_preview);
    m_latest_preview = QSharedPointer<Image>(new Image(":/testchart.png"));
    emit previewChanged(m_latest_preview.data());
    if (m_state != CAMERA_SHUTDOWN) {
        m_state = CAMERA_TRANSITIONING;
        emit stateChanged(m_state);
        // reset(); // release UI lock
        setViewfinder(true);
    }
}
Exemple #6
0
void MainWindow::onTreeItemClicked(QTreeWidgetItem* item, int col) {

    Displayable* d = 0;

    // magic numbers need to turn into constants...
    // don't know where to put them right now...
    switch(item->type()) {
        case 1000: d = (Score*)item; break;
        case 1001: d = (Staff*)item; break;
        case 1002: d = (Voice*)item; break;
    }

    if(d) {
        disconnect(m_selection);

        // set m_selection
        m_selection = d;

        connect(ui->refreshButton,SIGNAL(clicked()),m_selection,SLOT(refresh()));
        connect(m_selection,SIGNAL(previewChanged()),this,SLOT(onRefreshButtonClicked()));

        // set pixmap label
        if(d->image())
            ui->pixmap->setPixmap(QPixmap::fromImage(*d->image()));
        else
            d->refresh();

        ui->listWidget->clear();
        QList<Phrase*>& list = d->getPhraseList();
        for(int i = 0; i < list.size(); i++)
            new PhraseWidgetListItem(list.at(i),ui->listWidget);
        delete &list;

        // set contentEdit
        ui->contentEdit->setPlainText(d->content());

        // set nameEdit
        ui->nameEdit->setText(d->name());
    }
}
PrintPreviewDialog::PrintPreviewDialog(QPrinter *printer, QWidget *parent)
	: QDialog(parent)
{
	m_initialized = false;

	QVBoxLayout *mainLayout = new QVBoxLayout;

	m_printPreviewWidget = new QPrintPreviewWidget(printer, this);
	connect(m_printPreviewWidget, SIGNAL(paintRequested(QPrinter*)), this, SIGNAL(paintRequested(QPrinter*)));
	connect(m_printPreviewWidget, SIGNAL(previewChanged()), this, SLOT(updateZoomFactor()));

	ToolBar *toolBar = new ToolBar("printpreview_toolbar", this);
	Action *action = new Action(Icon("zoom-fit-width"), tr("Fit &width"), this, "printpreview_fit_width");
	connect(action, SIGNAL(triggered()), m_printPreviewWidget, SLOT(fitToWidth()));
	toolBar->addAction(action);
	action = new Action(Icon("zoom-fit-best"), tr("Fit p&age"), this, "printpreview_fit_page");
	connect(action, SIGNAL(triggered()), m_printPreviewWidget, SLOT(fitInView()));
	toolBar->addAction(action);
	m_zoomToAction = new ZoomAction(Icon("zoom-original"), tr("&Zoom"), this, "printpreview_zoom_to");
	connect(m_zoomToAction, SIGNAL(zoomFactorAdded(qreal)), this, SLOT(setZoomFactor(qreal)));
	toolBar->addAction(m_zoomToAction);
	toolBar->addAction(StandardAction::zoomIn(this, SLOT(zoomIn()), this));
	toolBar->addAction(StandardAction::zoomOut(this, SLOT(zoomOut()), this));
	action = new Action(Icon("document-print"), tr("&Print"), this, "printpreview_print");
	connect(action, SIGNAL(triggered()), this, SLOT(print()));
	toolBar->addAction(action);
	action = new Action(Icon("window-close"), tr("&Close"), this, "printpreview_close");
	connect(action, SIGNAL(triggered()), this, SLOT(reject()));
	toolBar->addAction(action);

	mainLayout->addWidget(toolBar);
	mainLayout->addWidget(m_printPreviewWidget);
	setLayout(mainLayout);

	m_zoomToAction->setZoomFactor(1.0);
}
Exemple #8
0
void MainWindow::actualSize()
{
    preview->setZoomFactor(1.0);
    previewChanged();
}
Exemple #9
0
void MainWindow::lastPage()
{
    preview->setCurrentPage(preview->pageCount());
    previewChanged();
}
Exemple #10
0
void MainWindow::firstPage()
{
    preview->setCurrentPage(1);
    previewChanged();
}
Exemple #11
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    createStatusBar();

    // Recent files
    for (int i = 0; i < MaxRecentFiles; ++i)
    {
	recentFileActions[i] = new QAction(this);
	recentFileActions[i]->setVisible(false);
	connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile()));
	ui->menuFile->insertAction(ui->actionExit, recentFileActions[i]);
    }
    recentFilesSeparator = ui->menuFile->insertSeparator(ui->actionExit);

    printer = new QPrinter;
    printer->setFullPage(true);
    printer->setPaperSize(QPrinter::Letter);
    printer->setPageMargins(.5, .5, .5, .5, QPrinter::Inch);

    report = new Report(printer, this);
    view = new ReportView(report, this);

    preview = new QPrintPreviewWidget(printer, this);
    setCentralWidget(preview);
    preview->fitToWidth();

    QFontComboBox* fontComboBox = new QFontComboBox;
    fontComboBox->setFontFilters(QFontComboBox::MonospacedFonts | QFontComboBox::ScalableFonts);
    fontComboBox->setCurrentFont(report->font().family());
    ui->fontToolBar->insertWidget(ui->actionBold, fontComboBox);
    connect(fontComboBox, SIGNAL(currentFontChanged(QFont)), report, SLOT(setFont(QFont)));

    pageNumberComboBox = new QComboBox;
    ui->viewToolBar->insertWidget(ui->actionNextPage, pageNumberComboBox);
    connect(pageNumberComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentPageChanged(int)));

    const qreal zoomFactors[] = { 12.5, 25, 50, 100, 125, 150, 200, 400, 800 };
    zoomComboBox = new QComboBox;
    for (unsigned int i = 0; i < sizeof(zoomFactors) / sizeof(*zoomFactors); ++i)
    {
	zoomComboBox->addItem(QString("%1%").arg(zoomFactors[i]));
    }
    zoomComboBox->setCurrentIndex(-1);
    ui->viewToolBar->insertWidget(ui->actionZoomOut, zoomComboBox);
    connect(zoomComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(zoomChanged(QString)));

    QActionGroup* orientationGroup = new QActionGroup(this);
    orientationGroup->addAction(ui->actionPortrait);
    orientationGroup->addAction(ui->actionLandscape);
    orientationChanged(report->orientation());

    QActionGroup* heightGroup = new QActionGroup(this);
    heightGroup->addAction(ui->action6LPI);
    heightGroup->addAction(ui->action8LPI);
    heightGroup->addAction(ui->action9LPI);
    heightGroup->setDisabled(ui->actionStretchFont->isEnabled());
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), heightGroup, SLOT(setDisabled(bool)));

    QActionGroup* widthGroup = new QActionGroup(this);
    widthGroup->addAction(ui->actionDefaultWidth);
    widthGroup->addAction(ui->action10CPI);
    widthGroup->addAction(ui->action12CPI);
    widthGroup->addAction(ui->action17CPI);
    widthGroup->setDisabled(ui->actionStretchFont->isEnabled());
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), widthGroup, SLOT(setDisabled(bool)));

    QActionGroup* pageGroup = new QActionGroup(this);
    pageGroup->addAction(ui->actionSinglePage);
    pageGroup->addAction(ui->actionFacingPages);
    pageGroup->addAction(ui->actionAllPages);
    ui->actionSinglePage->setChecked(preview->viewMode() == QPrintPreviewWidget::SinglePageView);
    ui->actionFacingPages->setChecked(preview->viewMode() == QPrintPreviewWidget::FacingPagesView);
    ui->actionAllPages->setChecked(preview->viewMode() == QPrintPreviewWidget::AllPagesView);

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->actionOpenURL, SIGNAL(triggered()), this, SLOT(openUrl()));
    connect(ui->actionReload, SIGNAL(triggered()), this, SLOT(reload()));
    connect(ui->actionSaveAsPDF, SIGNAL(triggered()), this, SLOT(saveAsPdf()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(ui->actionPageSetup, SIGNAL(triggered()), this, SLOT(pageSetup()));
    connect(ui->actionEmail, SIGNAL(triggered()), this, SLOT(email()));
    connect(ui->actionCopy, SIGNAL(triggered()), this, SLOT(copy()));
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), report, SLOT(setStretchFont(bool)));
    connect(report, SIGNAL(stretchFontChanged(bool)), ui->actionStretchFont, SLOT(setChecked(bool)));
    connect(ui->actionBold, SIGNAL(toggled(bool)), report, SLOT(setBold(bool)));
    connect(ui->actionStripes, SIGNAL(toggled(bool)), report, SLOT(setStripes(bool)));
    connect(ui->actionStripeColor, SIGNAL(triggered()), this, SLOT(stripeColor()));
    connect(ui->actionColor, SIGNAL(triggered()), this, SLOT(fontColor()));
    connect(ui->action6LPI, SIGNAL(triggered()), this, SLOT(height6Lpi()));
    connect(ui->action8LPI, SIGNAL(triggered()), this, SLOT(height8Lpi()));
    connect(ui->action9LPI, SIGNAL(triggered()), this, SLOT(height9Lpi()));
    connect(ui->actionDefaultWidth, SIGNAL(toggled(bool)), this, SLOT(widthDefault()));
    connect(ui->action10CPI, SIGNAL(triggered()), this, SLOT(width10Cpi()));
    connect(ui->action12CPI, SIGNAL(triggered()), this, SLOT(width12Cpi()));
    connect(ui->action17CPI, SIGNAL(triggered()), this, SLOT(width17Cpi()));
    connect(ui->actionFirstPage, SIGNAL(triggered()), this, SLOT(firstPage()));
    connect(ui->actionPreviousPage, SIGNAL(triggered()), this, SLOT(previousPage()));
    connect(ui->actionNextPage, SIGNAL(triggered()), this, SLOT(nextPage()));
    connect(ui->actionLastPage, SIGNAL(triggered()), this, SLOT(lastPage()));
    connect(ui->actionFitWidth, SIGNAL(triggered()), preview, SLOT(fitToWidth()));
    connect(ui->actionFitHeight, SIGNAL(triggered()), preview, SLOT(fitInView()));
    connect(ui->actionPortrait, SIGNAL(triggered()), preview, SLOT(setPortraitOrientation()));
    connect(ui->actionLandscape, SIGNAL(triggered()), preview, SLOT(setLandscapeOrientation()));
    connect(ui->actionActualSize, SIGNAL(triggered()), this, SLOT(actualSize()));
    connect(ui->actionZoomIn, SIGNAL(triggered()), preview, SLOT(zoomIn()));
    connect(ui->actionZoomOut, SIGNAL(triggered()), preview, SLOT(zoomOut()));
    connect(ui->actionSinglePage, SIGNAL(triggered()), preview, SLOT(setSinglePageViewMode()));
    connect(ui->actionFacingPages, SIGNAL(triggered()), preview, SLOT(setFacingPagesViewMode()));
    connect(ui->actionAllPages, SIGNAL(triggered()), preview, SLOT(setAllPagesViewMode()));
    connect(ui->actionMainToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleMainToolbar(bool)));
    connect(ui->actionViewToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleViewToolbar(bool)));
    connect(ui->actionFontToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleFontToolbar(bool)));
    connect(ui->actionStatusBar, SIGNAL(triggered(bool)), this, SLOT(toggleStatusBar(bool)));
    connect(ui->menuToolbars, SIGNAL(aboutToShow()), this, SLOT(updateToolbarMenu()));
    connect(ui->menuView, SIGNAL(aboutToShow()), this, SLOT(updateToolbarMenu()));
    connect(preview, SIGNAL(previewChanged()), this, SLOT(previewChanged()));

    connect(preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(paint(QPrinter*)));
    connect(report, SIGNAL(loaded()), preview, SLOT(updatePreview()));
    connect(report, SIGNAL(changed()), preview, SLOT(updatePreview()));
    connect(report, SIGNAL(loaded()), this, SLOT(documentLoaded()));
    connect(report, SIGNAL(orientationChanged(QPrinter::Orientation)), this, SLOT(orientationChanged(QPrinter::Orientation)));
    connect(report, SIGNAL(lpiChanged(int)), this, SLOT(lpiChanged(int)));
    connect(report, SIGNAL(cpiChanged(int)), this, SLOT(cpiChanged(int)));
    connect(report, SIGNAL(boldChanged(bool)), ui->actionBold, SLOT(setChecked(bool)));
    connect(report, SIGNAL(fontChanged(QFont)), fontComboBox, SLOT(setCurrentFont(QFont)));

    QSettings settings;
    restoreGeometry(settings.value("geometry").toByteArray());
    restoreState(settings.value("state").toByteArray());
    recentFiles = settings.value("recentFiles").toStringList();
    currentFolder = settings.value("currentFolder").toString();
    ui->statusBar->setVisible(settings.value("statusBar", true).toBool());

    updateRecentFileActions();

    zoomTimer = new QTimer(this);
    connect(zoomTimer, SIGNAL(timeout()), this, SLOT(updateZoom()));
    connect(preview, SIGNAL(previewChanged()), this, SLOT(updateZoom()));
    zoomTimer->start(1000);
}
/**
	Met en place le dialogue
*/
void QETPrintPreviewDialog::build() {
	preview_ = new QPrintPreviewWidget(printer_);
	diagrams_label_       = new QLabel(tr("Sch\351mas \340 imprimer\240:"));
	diagrams_list_        = new DiagramsChooser(project_);
	diagrams_select_all_  = new QPushButton(tr("Tout cocher"));
	diagrams_select_none_ = new QPushButton(tr("Tout d\351cocher"));
	toggle_diagrams_list_ = new QAction(QET::Icons::Diagram,              tr("Cacher la liste des sch\351mas"),            this);
	toggle_print_options_ = new QAction(QET::Icons::Configure,            tr("Cacher les options d'impression"),           this);
	adjust_width_         = new QAction(QET::Icons::ViewFitWidth,         tr("Ajuster la largeur"),                        this);
	adjust_page_          = new QAction(QET::Icons::ViewFitWindow,        tr("Ajuster la page"),                           this);
	zoom_out_             = new QAction(QET::Icons::ZoomOut,              tr("Zoom arri\350re"),                           this);
	zoom_box_             = new QComboBox(this);
	zoom_in_              = new QAction(QET::Icons::ZoomIn,               tr("Zoom avant"),                                this);
	landscape_            = new QAction(QET::Icons::PrintLandscape,       tr("Paysage"),                                   this);
	portrait_             = new QAction(QET::Icons::PrintPortrait,        tr("Portrait"),                                  this);
	first_page_           = new QAction(QET::Icons::ArrowLeftDouble,      tr("Premi\350re page"),                          this);
	previous_page_        = new QAction(QET::Icons::ArrowLeft,            tr("Page pr\351c\351dente"),                     this);
	next_page_            = new QAction(QET::Icons::ArrowRight,           tr("Page suivante"),                             this);
	last_page_            = new QAction(QET::Icons::ArrowRightDouble,     tr("Derni\350re page"),                          this);
	single_page_view_     = new QAction(QET::Icons::SinglePage,           tr("Afficher une seule page"),                   this);
	facing_pages_view_    = new QAction(QET::Icons::PrintTwoPages,        tr("Afficher deux pages"),                       this);
	all_pages_view_       = new QAction(QET::Icons::PrintAllPages,        tr("Afficher un aper\347u de toutes les pages"), this);
	page_setup_           = new QAction(QET::Icons::DocumentPrintFrame,   tr("Mise en page"),                              this);
	
	toggle_diagrams_list_ -> setCheckable(true);
	toggle_diagrams_list_ -> setChecked(true);
	toggle_print_options_ -> setCheckable(true);
	toggle_print_options_ -> setChecked(true);
	
#ifdef Q_OS_WIN32
	/*
		Sous Windows, le QPageSetupDialog utilise le dialogue natif ; ce
		dernier ne peut gerer que les imprimantes physiques ("native
		printers" ).
		cf avertissement : QAbstractPageSetupDialog::QAbstractPageSetupDialog:
		Page setup dialog cannot be used on non-native printers
	*/
	if (!(printer_ -> outputFileName().isEmpty())) {
		page_setup_ -> setEnabled(false);
		page_setup_ -> setText(tr("Mise en page (non disponible sous Windows pour l'impression PDF/PS)"));
	}
#endif
	
	toolbar_ = new QToolBar();
	toolbar_ -> addAction(toggle_diagrams_list_);
	toolbar_ -> addAction(toggle_print_options_);
	toolbar_ -> addSeparator();
	toolbar_ -> addAction(adjust_width_);
	toolbar_ -> addAction(adjust_page_);
	toolbar_ -> addAction(zoom_out_);
	toolbar_ -> addWidget(zoom_box_);
	toolbar_ -> addAction(zoom_in_);
	toolbar_ -> addSeparator();
	toolbar_ -> addAction(landscape_);
	toolbar_ -> addAction(portrait_);
	toolbar_ -> addSeparator();
	toolbar_ -> addAction(first_page_);
	toolbar_ -> addAction(previous_page_);
	toolbar_ -> addAction(next_page_);
	toolbar_ -> addAction(last_page_);
	toolbar_ -> addSeparator();
	toolbar_ -> addAction(single_page_view_);
	toolbar_ -> addAction(facing_pages_view_);
	toolbar_ -> addAction(all_pages_view_);
	toolbar_ -> addSeparator();
	toolbar_ -> addAction(page_setup_);
	
	print_options_box_= new QGroupBox(tr("Options d'impression"));
	use_full_page_ = new QCheckBox(tr("Utiliser toute la feuille"));
	use_full_page_ -> setChecked(printer_ -> fullPage());
	use_full_page_label_ = new QLabel(tr(
		"Si cette option est coch\351e, les marges de la feuille seront "
		"ignor\351es et toute sa surface sera utilis\351e pour l'impression. "
		"Cela peut ne pas \352tre support\351 par votre imprimante."
	));
	use_full_page_label_ -> setWordWrap(true);
	use_full_page_label_ -> setContentsMargins(20, 0, 0, 0);
	fit_diagram_to_page_ = new QCheckBox(tr("Adapter le sch\351ma \340 la page"));
	fit_diagram_to_page_label_ = new QLabel(tr(
		"Si cette option est coch\351e, le sch\351ma sera agrandi ou "
		"r\351tr\351ci de fa\347on \340 remplir toute la surface imprimable "
		"d'une et une seule page."
	));
	fit_diagram_to_page_label_ -> setWordWrap(true);
	fit_diagram_to_page_label_ -> setContentsMargins(20, 0, 0, 0);
	fit_diagram_to_page_ -> setChecked(true);
	
	// recupere les parametres d'export definis dans la configuration de l'application
	ExportProperties default_print_properties = QETDiagramEditor::defaultPrintProperties();
	
	render_properties_ = new ExportPropertiesWidget(default_print_properties);
	render_properties_ -> setPrintingMode(true);
	
	buttons_ = new QDialogButtonBox();
	buttons_ -> addButton(new QPushButton(QET::Icons::DocumentPrint, tr("Imprimer")), QDialogButtonBox::AcceptRole);
	buttons_ -> addButton(QDialogButtonBox::Cancel);
	
	connect(diagrams_select_all_,  SIGNAL(released()),    this,     SLOT(selectAllDiagrams()));
	connect(diagrams_select_none_, SIGNAL(released()),    this,     SLOT(selectNoDiagram()));
	connect(toggle_diagrams_list_, SIGNAL(toggled(bool)), this,     SLOT(setDiagramsListVisible(bool)));
	connect(toggle_print_options_, SIGNAL(toggled(bool)), this,     SLOT(setPrintOptionsVisible(bool)));
	connect(adjust_width_,         SIGNAL(triggered()),   preview_, SLOT(fitToWidth()));
	connect(adjust_page_,          SIGNAL(triggered()),   preview_, SLOT(fitInView()));
	connect(zoom_out_,             SIGNAL(triggered()),   this,     SLOT(zoomOut()));
	connect(zoom_in_,              SIGNAL(triggered()),   this,     SLOT(zoomIn()));
	connect(landscape_,            SIGNAL(triggered()),   preview_, SLOT(setLandscapeOrientation()));
	connect(portrait_,             SIGNAL(triggered()),   preview_, SLOT(setPortraitOrientation()));
	connect(first_page_,           SIGNAL(triggered()),   this,     SLOT(firstPage()));
	connect(previous_page_,        SIGNAL(triggered()),   this,     SLOT(previousPage()));
	connect(next_page_,            SIGNAL(triggered()),   this,     SLOT(nextPage()));
	connect(last_page_,            SIGNAL(triggered()),   this,     SLOT(lastPage()));
	connect(single_page_view_,     SIGNAL(triggered()),   preview_, SLOT(setSinglePageViewMode()));
	connect(facing_pages_view_,    SIGNAL(triggered()),   preview_, SLOT(setFacingPagesViewMode()));
	connect(all_pages_view_,       SIGNAL(triggered()),   preview_, SLOT(setAllPagesViewMode()));
	connect(page_setup_,           SIGNAL(triggered()),   this,     SLOT(pageSetup()));
	
	connect(use_full_page_,        SIGNAL(toggled(bool)), this, SLOT(useFullPage(bool)));
	connect(fit_diagram_to_page_,  SIGNAL(toggled(bool)), this, SLOT(fitDiagramToPage(bool)));
	
	connect(render_properties_,    SIGNAL(optionChanged()), preview_, SLOT(updatePreview()));
	
	connect(preview_,  SIGNAL(previewChanged()),         this, SLOT(updateZoomList()));
	connect(zoom_box_, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreviewZoom()));
	
	connect(buttons_, SIGNAL(accepted()), this, SLOT(accept()));
	connect(buttons_, SIGNAL(rejected()), this, SLOT(reject()));
	
	hlayout0_ = new QHBoxLayout();
	vlayout0_ = new QVBoxLayout();
	vlayout1_ = new QVBoxLayout();
	vlayout2_ = new QVBoxLayout();
	
	vlayout1_ -> addWidget(use_full_page_);
	vlayout1_ -> addWidget(use_full_page_label_);
	vlayout1_ -> addWidget(fit_diagram_to_page_);
	vlayout1_ -> addWidget(fit_diagram_to_page_label_);
	print_options_box_ -> setLayout(vlayout1_);
	
	vlayout2_ -> addWidget(diagrams_label_);
	vlayout2_ -> addWidget(diagrams_list_);
	vlayout2_ -> addWidget(diagrams_select_all_);
	vlayout2_ -> addWidget(diagrams_select_none_);
	
	hlayout0_ -> addLayout(vlayout2_);
	hlayout0_ -> addWidget(preview_);
	
	vlayout0_ -> addWidget(toolbar_);
	vlayout0_ -> addLayout(hlayout0_);
	vlayout0_ -> addWidget(render_properties_);
	vlayout0_ -> addWidget(print_options_box_);
	vlayout0_ -> addWidget(buttons_);
	
	setLayout(vlayout0_);
	updateZoomList();
}
MainWidget::MainWidget(QWidget *parent) :
    QWidget(parent)
{
    //init color palette for variables
    VariableColorPalette palette(QColor(50,100,200));


    preview = new CubeMapPreview(500);
    loader = new CubeMapLoader();
    curveEditor = new CurveEditor(this);
    curveEditor->setViewScale(0.1,-1);
    setEditorRange(100);
    curveEditor->setSnap(1,0);
    curveEditor->setCurrentFrame(0);




    //create and init variables
    CurveVariable * pitch = new CurveVariable("Pitch");
    CurveVariable * yaw = new CurveVariable("Yaw");
    CurveVariable * roll = new CurveVariable("Roll");
    CurveVariable * zoom = new CurveVariable("Zoom");
    CurveVariable * fov = new CurveVariable("Fov",180);
    CurveVariable * frame = new CurveVariable("Cubemap",0);

    //add variables to key frames watcher
    KeyFrames * keyFrames = KeyFrames::getInstance();
    keyFrames->addVariable(pitch);
    keyFrames->addVariable(zoom);
    keyFrames->addVariable(roll);
    keyFrames->addVariable(fov);
    keyFrames->addVariable(yaw);
    keyFrames->addVariable(frame);

    curveEditor->addVariable(pitch);
    curveEditor->addVariable(yaw);
    curveEditor->addVariable(roll);
    curveEditor->addVariable(zoom);
    curveEditor->addVariable(fov);
    curveEditor->addVariable(frame);

    preview->setPitchVar(pitch);
    preview->setFovVar(fov);
    preview->setYawVar(yaw);
    preview->setRollVar(roll);
    preview->setZoomVar(zoom);

    loader->setFrameVar(frame);

    //setup time line
    timeLine = new TimeLine(this);

    //init IO module
    importExport = new IOWidget(loader, timeLine, this);

    //let the timeline know that a frame has been keyed/un keyed
    connect(pitch,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
    connect(yaw,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
    connect(roll,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
    connect(zoom,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
    connect(fov,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
    connect(frame,SIGNAL(changed(float,float)), timeLine, SLOT(update()));

    //update preview when cube map changes
    connect(loader,SIGNAL(faceChanged(QImage *,CubeFace)),preview,SLOT(setFace(QImage *, CubeFace)));

    //tells the cube map loader to load the cube map corresponding to the new frame
    connect(timeLine,SIGNAL(frameChanged(float)),loader,SLOT(variablesValues(float)));

    //tells the preview to display a new frame
    connect(timeLine,SIGNAL(frameChanged(float)),preview,SLOT(variablesValues(float)));

    //update the frame cursor of the curve editor
    connect(timeLine,SIGNAL(frameChanged(float)),curveEditor,SLOT(setCurrentFrame(float)));

    //Change the range of frames displayed by the curvor editor when the number of frames changes
    connect(timeLine,SIGNAL(frameNumberChanged(int)), this, SLOT(setEditorRange(int)));

    //Refresh preview when curves have been edited
    connect(curveEditor,SIGNAL(curvesChanged(float, float)),preview,SLOT(refreshVariablesValues(float, float)));

    //connect(timeLine,SIGNAL(frameChanged(float)),preview,SLOT(refresh()));
    //stop playback if the user interacts with the preview
    connect(preview,SIGNAL(previewChanged()),timeLine,SLOT(stop()));


    QTabWidget * tabWidget = new QTabWidget(this);
    tabWidget->addTab(loader,"Cube&map");
    tabWidget->addTab(curveEditor,"Curve &Editor");
    tabWidget->addTab(importExport,"E&xport");


    QScrollArea * previewScroll = new QScrollArea(this);
    previewScroll->setWidget(preview);
    previewScroll->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

    QPalette pal = previewScroll->palette();
    pal.setColor(QPalette::Background,Qt::black);
    previewScroll->setPalette(pal);


    QScrollArea * tabScroll = new QScrollArea(this);
    tabScroll->setWidget(tabWidget);
    //so the content will expand if possible
    tabScroll->setWidgetResizable(true);


    QSplitter * splitterH = new QSplitter(Qt::Horizontal);
    splitterH->addWidget(previewScroll);

    splitterH->addWidget(tabScroll);
    //splitterH->addWidget(tabWidget);
    //splitterH->setStretchFactor(0,1);
    splitterH->setStretchFactor(1,1);

    QSplitter * splitterV = new QSplitter(Qt::Vertical);
    splitterV->addWidget(splitterH);
    splitterV->addWidget(timeLine);
    splitterV->setStretchFactor(0,1);

    QGridLayout * gridLayout = new QGridLayout();

    gridLayout->addWidget(splitterV,0,0);

    setLayout(gridLayout);

    //load settings
    readSettings();
}