Пример #1
0
void DevGUI::setupCompiler()
{
	QAction *a;
	QToolBar *tb = new QToolBar(this);
	tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    tb->setWindowTitle(tr("Compiler Actions"));
    addToolBar(tb);
    
    QMenu *menu = new QMenu(tr("&Compile"), this);
    menuBar()->addMenu(menu);
    
    actionCompile = a = new QAction(QIcon(":/compile.png"), tr("&Compile..."), this);
    a->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_C);
    //connect(a, SIGNAL(triggered()), this, SLOT(projComp()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);
    
    actionCompile = a = new QAction(QIcon(":/rebuild.png"), tr("&Rebuild..."), this);
    a->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_A);
    //connect(a, SIGNAL(triggered()), this, SLOT(projRebuild()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);
    
	Compiler = new DevDock(tr("Compiler"), Qt::BottomDockWidgetArea, this);
	tabCompiler = Compiler->Tab();
	
}
Пример #2
0
void TextEdit::setupEditActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Edit Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(menu);

    QAction *a;
    a = actionUndo = new QAction(QIcon(rsrcPath + "/editundo.png"), tr("&Undo"), this);
    a->setShortcut(QKeySequence::Undo);
    tb->addAction(a);
    menu->addAction(a);
    a = actionRedo = new QAction(QIcon(rsrcPath + "/editredo.png"), tr("&Redo"), this);
    a->setShortcut(QKeySequence::Redo);
    tb->addAction(a);
    menu->addAction(a);
    menu->addSeparator();
    a = actionCut = new QAction(QIcon(rsrcPath + "/editcut.png"), tr("Cu&t"), this);
    a->setShortcut(QKeySequence::Cut);
    tb->addAction(a);
    menu->addAction(a);
    a = actionCopy = new QAction(QIcon(rsrcPath + "/editcopy.png"), tr("&Copy"), this);
    a->setShortcut(QKeySequence::Copy);
    tb->addAction(a);
    menu->addAction(a);
    a = actionPaste = new QAction(QIcon(rsrcPath + "/editpaste.png"), tr("&Paste"), this);
    a->setShortcut(QKeySequence::Paste);
    tb->addAction(a);
    menu->addAction(a);
    actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty());
}
Пример #3
0
QToolBar* MainWindow::createFormatToolBar()
{
    QToolBar *pFormatBar = new QToolBar();
    pFormatBar->setWindowTitle( "Format Bar" );

    m_pCmbFont = new QFontComboBox;
    m_pCmbFont->setEditable( false );
    m_pCmbFont->setFocusPolicy( Qt::NoFocus );
    m_pCmbFontPointSize = new QComboBox;
    updateFontPointSize( m_pCmbFont->currentText() );
    m_pCmbFontPointSize->setFocusPolicy( Qt::NoFocus );
    QToolButton *pBtnMoreOptions = new QToolButton;
    pBtnMoreOptions->setText( "More..." );
    pBtnMoreOptions->setStyleSheet( "border: 1px solid #000000" );
    pBtnMoreOptions->setFixedHeight( 20 );
    pBtnMoreOptions->setFocusPolicy( Qt::NoFocus );

    pFormatBar->addWidget( m_pCmbFont );
    pFormatBar->addWidget( m_pCmbFontPointSize );
    pFormatBar->addWidget( pBtnMoreOptions );

    connect( m_pCmbFont, SIGNAL(currentIndexChanged(int)), this, SLOT(onFontFamilyChanged()) );
    connect( m_pCmbFontPointSize, SIGNAL(currentIndexChanged(int)), this, SLOT(onFontPointSizeChanged()) );
    connect( pBtnMoreOptions, SIGNAL(clicked()), this, SLOT(onFormatMoreBtnClicked()) );

    return pFormatBar;
}
Пример #4
0
void TextEdit::setupEditActions()
{

    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Edit Actions"));
    toolBar1.addWidget(tb);

    QAction *a;
    a = new QAction(QIcon(rsrcPath + "/fileopen.png"), tr("&Open image"), this);
    a->setShortcut(QKeySequence::Open);
    connect(a, SIGNAL(triggered()), this, SLOT(imageOpen()));
    tb->addAction(a);
    a = actionUndo = new QAction(QIcon(rsrcPath + "/editundo.png"), tr("Undo"), this);
    a->setShortcut(QKeySequence::Undo);
    tb->addAction(a);
    a = actionRedo = new QAction(QIcon(rsrcPath + "/editredo.png"), tr("&Redo"), this);
    a->setShortcut(QKeySequence::Redo);
    tb->addAction(a);
    a = actionCut = new QAction(QIcon(rsrcPath + "/editcut.png"), tr("Cu&t"), this);
    a->setShortcut(QKeySequence::Cut);
    tb->addAction(a);
    a = actionCopy = new QAction(QIcon(rsrcPath + "/editcopy.png"), tr("&Copy"), this);
    a->setShortcut(QKeySequence::Copy);
    tb->addAction(a);
    a = actionPaste = new QAction(QIcon(rsrcPath + "/editpaste.png"), tr("&Paste"), this);
    a->setShortcut(QKeySequence::Paste);
    tb->addAction(a);
    actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty());
}
Пример #5
0
void DevGUI::setupTextActions()
{
	QToolBar *tb = new QToolBar(this);
	tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
	tb->setWindowTitle(tr("Format Actions"));
	addToolBarBreak(Qt::TopToolBarArea);
	addToolBar(tb);
	
	Font = new QComboBox(tb);
	tb->addWidget(Font);
	Font->setEditable(true);
	QFontDatabase db;
	Font->addItems(db.families());
	connect(Font, SIGNAL(activated(const QString &)),
			this, SLOT(textFamily(const QString &)));
	Font->setCurrentIndex(Font->findText(DevApp::font().family()));
	
	Size = new QComboBox(tb);
	Size->setObjectName("Size");
	tb->addWidget(Size);
	Size->setEditable(true);

	foreach(int size, db.standardSizes())
		Size->addItem(QString::number(size));

	connect(Size, SIGNAL(activated(const QString &)),
			this, SLOT(textSize(const QString &)));
	Size->setCurrentIndex(Size->findText(QString::number(DevApp::font().pointSize())));
}
Пример #6
0
void IdealController::addView(Qt::DockWidgetArea area, View* view)
{
    IdealDockWidget *dock = new IdealDockWidget(this, m_mainWindow);
    // dock object name is used to store toolview settings
    QString dockObjectName = view->document()->title();
    // support different configuration for same docks opened in different areas
    if (m_mainWindow->area())
        dockObjectName += '_' + m_mainWindow->area()->objectName();

    dock->setObjectName(dockObjectName);

    KAcceleratorManager::setNoAccel(dock);
    QWidget *w = view->widget(dock);
    if (w->parent() == 0)
    {
        /* Could happen when we're moving the widget from
           one IdealDockWidget to another.  See moveView below.
           In this case, we need to reparent the widget. */
        w->setParent(dock);
    }

    QList<QAction *> toolBarActions = view->toolBarActions();
    if (toolBarActions.isEmpty()) {
      dock->setWidget(w);
    } else {
      QMainWindow *toolView = new QMainWindow();
      QToolBar *toolBar = new QToolBar(toolView);
      int iconSize = m_mainWindow->style()->pixelMetric(QStyle::PM_SmallIconSize);
      toolBar->setIconSize(QSize(iconSize, iconSize));
      toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
      toolBar->setWindowTitle(i18n("%1 Tool Bar", w->windowTitle()));
      toolBar->setFloatable(false);
      toolBar->setMovable(false);
      toolBar->addActions(toolBarActions);
      toolView->setCentralWidget(w);
      toolView->addToolBar(toolBar);
      dock->setWidget(toolView);
    }

    dock->setWindowTitle(view->widget()->windowTitle());
    dock->setWindowIcon(view->widget()->windowIcon());
    dock->setFocusProxy(dock->widget());

    if (IdealButtonBarWidget* bar = barForDockArea(area)) {
        QAction* action = bar->addWidget(
            view->document()->title(), dock,
            static_cast<MainWindow*>(parent())->area(), view);
        m_dockwidget_to_action[dock] = m_view_to_action[view] = action;

        m_docks->addAction(action);
        connect(dock, &IdealDockWidget::closeRequested, action, &QAction::toggle);
    }

    connect(dock, &IdealDockWidget::dockLocationChanged, this, &IdealController::dockLocationChanged);

    dock->hide();

    docks.insert(dock);
}
Пример #7
0
static QToolBar *createToolBar(const QString &title, const QString &objectName, const ActionList &actions)
{
    QToolBar *rc =  new QToolBar;
    rc->setObjectName(objectName);
    rc->setWindowTitle(title);
    addActionsToToolBar(actions, rc);
    return rc;
}
Пример #8
0
void
MainWindow::setupEditActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Edit Actions"));
    addToolBar(tb);
    QMenu *menu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(menu);
}
Пример #9
0
void ToolBoxManager::setup( ToolBarItem* toolBar ) const
{
    if ( !toolBar || !_toolBox )
        return; // empty tool bar

    int ct = _toolBox->count();
    for ( int i=0; i<ct; i++ )
    {
        // get always the first item widget
        QWidget* w = _toolBox->widget(0);
        _toolBox->removeItem(0);
        delete w;
    }

    CommandManager& mgr = Application::Instance->commandManager();
    QList<ToolBarItem*> items = toolBar->getItems();

    for ( QList<ToolBarItem*>::ConstIterator item = items.begin(); item != items.end(); ++item )
    {
        QToolBar* bar = new QToolBar();
        bar->setOrientation(Qt::Vertical);
        bar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        std::string toolbarName = (*item)->command();
        bar->setObjectName(QString::fromLatin1((*item)->command().c_str()));
        bar->setWindowTitle(QObject::trUtf8(toolbarName.c_str())); // i18n
        _toolBox->addItem( bar, bar->windowTitle() );

        QList<ToolBarItem*> subitems = (*item)->getItems();
        for ( QList<ToolBarItem*>::ConstIterator subitem = subitems.begin(); subitem != subitems.end(); ++subitem )
        {
            if ( (*subitem)->command() == "Separator" ) {
                //bar->addSeparator();
            } else {
                mgr.addTo((*subitem)->command().c_str(), bar);
            }
        }

        // Now set the right size policy for each tool button
        QList<QToolButton*> tool = bar->findChildren<QToolButton*>();
        for (QList<QToolButton*>::Iterator it = tool.begin(); it != tool.end(); ++it) {
            (*it)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
            // When setting the horizontal size policy but no icon is set we use the following trick
            // to make the button text left aligned.
            QIcon icon = (*it)->icon();
            if (icon.isNull())
            {
                // Create an icon filled with the button color
                int size = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
                QPixmap p(size, size);
                p.fill(Qt::transparent);
                (*it)->setIcon(p);
            }
        }
    }
}
Пример #10
0
void DlgCustomToolbarsImp::renameCustomToolbar(const QString& old_name, const QString& new_name)
{
    QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
    Workbench* w = WorkbenchManager::instance()->active();
    if (w && w->name() == std::string((const char*)data.toByteArray())) {
        QList<QToolBar*> bars = getMainWindow()->findChildren<QToolBar*>(old_name);
        if (bars.size() != 1)
            return;

        QToolBar* tb = bars.front();
        tb->setObjectName(new_name);
        tb->setWindowTitle(new_name);
    }
}
Пример #11
0
void TextEdit::setupEditActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Edit Actions"));
    addToolBar(tb);
    QMenu *menu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(menu);

    QAction *a;
    a = actionUndo = new QAction(QIcon::fromTheme("edit-undo", QIcon(rsrcPath + "/editundo.png")),
                                              tr("&Undo"), this);
    a->setShortcut(QKeySequence::Undo);
    tb->addAction(a);
    menu->addAction(a);
    a = actionRedo = new QAction(QIcon::fromTheme("edit-redo", QIcon(rsrcPath + "/editredo.png")),
                                              tr("&Redo"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Redo);
    tb->addAction(a);
    menu->addAction(a);
    menu->addSeparator();
    a = actionCut = new QAction(QIcon::fromTheme("edit-cut", QIcon(rsrcPath + "/editcut.png")),
                                             tr("Cu&t"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Cut);
    tb->addAction(a);
    menu->addAction(a);
    a = actionCopy = new QAction(QIcon::fromTheme("edit-copy", QIcon(rsrcPath + "/editcopy.png")),
                                 tr("&Copy"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Copy);
    tb->addAction(a);
    menu->addAction(a);
    a = actionPaste = new QAction(QIcon::fromTheme("edit-paste", QIcon(rsrcPath + "/editpaste.png")),
                                  tr("&Paste"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Paste);
    tb->addAction(a);
    menu->addAction(a);
#ifndef QT_NO_CLIPBOARD
    if (const QMimeData *md = QApplication::clipboard()->mimeData())
        actionPaste->setEnabled(md->hasText());
#endif
}
Пример #12
0
void DevGUI::setupEditActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Edit Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(menu);

    QAction *a;
    a = actionUndo = new QAction(QIcon(":/undo.png"), tr("&Undo"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Z);
    tb->addAction(a);
    menu->addAction(a);
    
    a = actionRedo = new QAction(QIcon(":/redo.png"), tr("&Redo"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Y);
    tb->addAction(a);
    menu->addAction(a);
    
    menu->addSeparator();
    
    a = actionCut = new QAction(QIcon(":/cut.png"), tr("Cu&t"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_X);
    tb->addAction(a);
    menu->addAction(a);
    
    a = actionCopy = new QAction(QIcon(":/copy.png"), tr("&Copy"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_C);
    tb->addAction(a);
    menu->addAction(a);
    
    a = actionPaste = new QAction(QIcon(":/paste.png"), tr("&Paste"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_V);
    tb->addAction(a);
    menu->addAction(a);
    actionPaste->setEnabled(!DevApp::clipboard()->text().isEmpty());
}
Пример #13
0
void TextEdit::setupEditActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Edit Actions"));
    addToolBar(tb);
    QMenu *menu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(menu);

    QAction *a;
    a = actionUndo = new QAction(QIcon(":/res/smallUndo.png"),tr("&Undo"), this);
    a->setShortcut(QKeySequence::Undo);
    tb->addAction(a);
    menu->addAction(a);
    a = actionRedo = new QAction(QIcon(":/res/smallRedo.png"), tr("&Redo"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Redo);
    tb->addAction(a);
    menu->addAction(a);
    menu->addSeparator();
    a = actionCut = new QAction(QIcon(":/res/smallcut.png"),tr("Cu&t"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Cut);
    tb->addAction(a);
    menu->addAction(a);
    a = actionCopy = new QAction(QIcon(":/res/smallcopy.png"), tr("&Copy"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Copy);
    tb->addAction(a);
    menu->addAction(a);
    a = actionPaste = new QAction(QIcon(":/res/smallpaste.png"), tr("&Paste"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::Paste);
    tb->addAction(a);
    menu->addAction(a);
#ifndef QT_NO_CLIPBOARD
    actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty());
#endif
}
Пример #14
0
void TextEdit::setupTextActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Format Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("F&ormat"), this);
    menuBar()->addMenu(menu);

    actionTextBold = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")),
                                 tr("&Bold"), this);
    actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
    actionTextBold->setPriority(QAction::LowPriority);
	QFont bold;
    bold.setBold(true);
    actionTextBold->setFont(bold);
    connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold()));
    tb->addAction(actionTextBold);
    menu->addAction(actionTextBold);
    actionTextBold->setCheckable(true);

    actionTextItalic = new QAction(QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png")),
                                   tr("&Italic"), this);
    actionTextItalic->setPriority(QAction::LowPriority);
    actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
    QFont italic;
    italic.setItalic(true);
    actionTextItalic->setFont(italic);
    connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic()));
    tb->addAction(actionTextItalic);
    menu->addAction(actionTextItalic);
    actionTextItalic->setCheckable(true);

    actionTextUnderline = new QAction(QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png")),
                                      tr("&Underline"), this);
    actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
    actionTextUnderline->setPriority(QAction::LowPriority);
    QFont underline;
    underline.setUnderline(true);
    actionTextUnderline->setFont(underline);
    connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline()));
    tb->addAction(actionTextUnderline);
    menu->addAction(actionTextUnderline);
    actionTextUnderline->setCheckable(true);

    menu->addSeparator();

    QActionGroup *grp = new QActionGroup(this);
    connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*)));

    // Make sure the alignLeft  is always left of the alignRight
    if (QApplication::isLeftToRight()) {
        actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")),
                                      tr("&Left"), grp);
        actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp);
        actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp);
    } else {
        actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp);
        actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp);
        actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp);
    }
    actionAlignJustify = new QAction(QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png")), tr("&Justify"), grp);

    actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
    actionAlignLeft->setCheckable(true);
    actionAlignLeft->setPriority(QAction::LowPriority);
    actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
    actionAlignCenter->setCheckable(true);
    actionAlignCenter->setPriority(QAction::LowPriority);
    actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
    actionAlignRight->setCheckable(true);
    actionAlignRight->setPriority(QAction::LowPriority);
    actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
    actionAlignJustify->setCheckable(true);
    actionAlignJustify->setPriority(QAction::LowPriority);

    tb->addActions(grp->actions());
    menu->addActions(grp->actions());

    menu->addSeparator();

    QPixmap pix(24, 24);
    
    pix.fill(Qt::black);
    actionTextColor = new QAction(QIcon::fromTheme("text-color", QIcon(rsrcPath + "/textcolor.png")), 
    									tr("&Text Color..."), this);
    connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor()));
    tb->addAction(actionTextColor);
    menu->addAction(actionTextColor);
    
    pix.fill(Qt::green);
    actionHighlightedTextColor = new QAction(QIcon::fromTheme("text-highlight-color", QIcon(rsrcPath + "/texthighlight.png")), 
    									tr("&Text Highlight Color..."), this);
    connect(actionHighlightedTextColor, SIGNAL(triggered()), this, SLOT(HighlightedText()));
    tb->addAction(actionHighlightedTextColor);
    menu->addAction(actionHighlightedTextColor);
    
    
   //pix.fill(Qt::white);
    actionBackgroundColor = new QAction(QIcon::fromTheme("bg-color", QIcon(rsrcPath + "/bgfill.png")), 
    									tr("&Background Color..."), this);
    connect(actionBackgroundColor, SIGNAL(triggered()), this, SLOT(backgroundColor()));
    tb->addAction(actionBackgroundColor);
    menu->addAction(actionBackgroundColor);




    tb = new QToolBar(this);
    tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    tb->setWindowTitle(tr("Format Actions"));
    addToolBarBreak(Qt::TopToolBarArea);
    addToolBar(tb);

    comboStyle = new QComboBox(tb);
    tb->addWidget(comboStyle);
    comboStyle->addItem("Standard");
    comboStyle->addItem("Bullet List (Disc)");
    comboStyle->addItem("Bullet List (Circle)");
    comboStyle->addItem("Bullet List (Square)");
    comboStyle->addItem("Ordered List (Decimal)");
    comboStyle->addItem("Ordered List (Alpha lower)");
    comboStyle->addItem("Ordered List (Alpha upper)");
    comboStyle->addItem("Ordered List (Roman lower)");
    comboStyle->addItem("Ordered List (Roman upper)");
    connect(comboStyle, SIGNAL(activated(int)),
            this, SLOT(textStyle(int)));

    comboFont = new QFontComboBox(tb);
    tb->addWidget(comboFont);
    connect(comboFont, SIGNAL(activated(QString)),
            this, SLOT(textFamily(QString)));

    comboSize = new QComboBox(tb);
    comboSize->setObjectName("comboSize");
    tb->addWidget(comboSize);
    comboSize->setEditable(true);

    QFontDatabase db;
    foreach(int size, db.standardSizes())
        comboSize->addItem(QString::number(size));

    connect(comboSize, SIGNAL(activated(QString)),
            this, SLOT(textSize(QString)));
    comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font()
                                                                   .pointSize())));
}
Пример #15
0
void TextEdit::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    QIcon newIcon = QIcon::fromTheme("document-new", QIcon(rsrcPath + "/filenew.png"));
    a = new QAction( newIcon, tr("&New"), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(QKeySequence::New);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon::fromTheme("document-open", QIcon(rsrcPath + "/fileopen.png")),
                    tr("&Open..."), this);
    a->setShortcut(QKeySequence::Open);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();


   	actionSave = a = new QAction(QIcon::fromTheme("document-save", QIcon(rsrcPath + "/filesave.png")),
                                 tr("&Save"), this);
    a->setShortcut(QKeySequence::Save);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);
    menu->addSeparator();

    a = new QAction(tr("Save &As ODT..."), this);
    a->setPriority(QAction::LowPriority);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAsOdt()));
    menu->addAction(a);
    
    a = new QAction(tr("Save &As HTML..."), this);
    a->setPriority(QAction::LowPriority);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAsHtml()));
    menu->addAction(a);
    menu->addSeparator();


#ifndef QT_NO_PRINTER
    //a = new QAction(QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png")),
    //                tr("&Print..."), this);
    //a->setPriority(QAction::LowPriority);
    //a->setShortcut(QKeySequence::Print);
    //connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    //tb->addAction(a);
    //menu->addAction(a);

    //a = new QAction(QIcon::fromTheme("fileprint", QIcon(rsrcPath + "/fileprint.png")),
     //               tr("Print Preview..."), this);
    //connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
    //menu->addAction(a);

    a = new QAction(QIcon::fromTheme("exportpdf", QIcon(rsrcPath + "/exportpdf.png")),
    tr("&Export PDF..."), this);
    a->setPriority(QAction::LowPriority);
    a->setShortcut(Qt::CTRL + Qt::Key_D);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();
#endif

    a = new QAction(tr("&Quit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(a, SIGNAL(triggered()), this, SLOT(close()));
    menu->addAction(a);
}
Пример #16
0
QToolBar* specActionLibrary::toolBar(QWidget* target)
{
	QToolBar* bar = new QToolBar(target) ;
	bar->setContentsMargins(0, 0, 0, 0) ;
	bar->setIconSize(QSize(20, 20)) ;

	specView* view = dynamic_cast<specView*>(target) ;
	specDataView*   dataView   = dynamic_cast<specDataView*>(target) ;
	specMetaView*   metaView   = dynamic_cast<specMetaView*>(target) ;
	specLogView*    logView    = dynamic_cast<specLogView*>(target) ;
	specPlot*       plot       = dynamic_cast<specPlot*>(target) ;
	specPlotWidget* plotWidget = dynamic_cast<specPlotWidget*>(target) ;

	if(view && view->model())
	{
		addParent(view) ;
		addParent(view->model()) ;
		addNewAction(bar, new specAddFolderAction(target)) ;
		if(metaView)
			addNewAction(bar, new specNewMetaItemAction(target));
		else
		{
			addNewAction(bar, new specImportSpecAction(target)) ;
			addNewAction(bar, new specTreeAction(target)) ;
			addNewAction(bar, new specFlattenTreeAction(target)) ;
		}
		if(dataView || metaView)
			addNewAction(bar, new specAddSVGItemAction(target)) ;
		addNewAction(bar, new genericExportAction(target)) ;
		bar->addSeparator() ;
		addNewAction(bar, new specCopyAction(target)) ;
		if(dataView || metaView)
			addNewAction(bar, new matrixExportAction(target)) ;
		addNewAction(bar, new specCutAction(target)) ;
		addNewAction(bar, new specPasteAction(target)) ;
		addNewAction(bar, new specDeleteAction(target)) ;
		bar->addSeparator() ;
		if(metaView || logView)
		{
			bar->addAction(undoAction(view)) ;
			bar->addAction(redoAction(view)) ;
			bar->addSeparator() ;
		}
		if(dataView)
		{
			addNewAction(bar, new toggle3DPlotAction(target)) ;
			addNewAction(bar, new specMergeAction(target)) ;
			addNewAction(bar, new specTiltMatrixAction(target)) ;
			addNewAction(bar, new specDescriptorEditAction(target)) ;
			bar->addSeparator() ;
			addNewAction(bar, new specRemoveDataAction(target)) ;
			addNewAction(bar, new specAverageDataAction(target)) ;
			addNewAction(bar, new specSpectrumCalculatorAction(target)) ;
			addNewAction(bar, new specNormalizeAction(target)) ;
		}
		addNewAction(bar, new specItemPropertiesAction(target)) ;
		addNewAction(bar, new specSetMultilineAction(target)) ;
		if(metaView)
		{
			addNewAction(bar, new specAddConnectionsAction(target)) ;
			addNewAction(bar, new specSelectConnectedAction(target)) ;
			addNewAction(bar, new specAddFitAction(target)) ;
			addNewAction(bar, new specRemoveFitAction(target)) ;
			addNewAction(bar, new specToggleFitStyleAction(target));
			addNewAction(bar, new specConductFitAction(target)) ;
		}
		if(logView)
			addNewAction(bar, new specDescriptorEditAction(target)) ;
		bar->addSeparator() ;
		if(dataView || metaView)
			addNewAction(bar, new changePlotStyleAction(target)) ;
		bar->setWindowTitle(tr("Items toolbar"));
	}

	if(plot)
	{
		addParent(plot);
		addNewAction(bar, new specTitleAction(target)) ;
		addNewAction(bar, new specXLabelAction(target)) ;
		addNewAction(bar, new specYLabelAction(target)) ;
		bar->addActions(plot->actions());
		bar->setWindowTitle(tr("Plot toolbar"));
	}

	if(plotWidget)
	{
		delete bar ;
		bar = plotWidget->createToolbar() ;
		bar-> addSeparator() ;
		bar-> addAction(purgeUndoAction) ;
		bar-> addSeparator() ;
		bar-> addAction(undoAction(this)) ;
		bar-> addAction(redoAction(this)) ;
		bar->setWindowTitle(tr("Main toolbar"));
	}

	return bar ;
}
void EditorMainWindow::SetupUI(QMainWindow *MainWindow) {

	setWindowIcon(*QtConfig::GetIcon("colorwheel.png"));

	MainWindow->setWindowTitle("Sound Engine v0.2.3");

	MainWindow->resize(1280, 720);

	MainWindow->setDockOptions(QMainWindow::AnimatedDocks |
								QMainWindow::AllowNestedDocks |
								QMainWindow::AllowTabbedDocks);

	MainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::TabPosition::North);

	// ************************************************************************
	// Load styling

	ReloadStyleSheets();

	// ************************************************************************
	// File Picker

	auto *picker = new FilePicker();
	picker->setNameFilter("*.xml");
	GUI::Set(QT_INSTACE::FILE_PICKER, (void*) picker);

	// ************************************************************************
	// Menu Bar

	QMenuBar *menuBar = new QMenuBar(MainWindow);
	menuBar->setObjectName(QStringLiteral("menuBar"));
	menuBar->setGeometry(QRect(0, 0, 1051, 21));
	MainWindow->setMenuBar(menuBar);

	// Menu Entry
	{
		QMenu *menuEngine = new QMenu(menuBar);
		menuEngine->setObjectName(QStringLiteral("menuEngine"));
		menuEngine->setTitle("File");

		menuBar->addAction(menuEngine->menuAction());

		{
			QAction *action = new QAction(MainWindow);
			action->setText("Exit");
			action->setIcon(*QtConfig::GetIcon("power.png"));
			menuEngine->addAction(action);
			QObject::connect(action, &QAction::triggered, this, &EditorMainWindow::close);
		}

		{
			QAction *action = new QAction(MainWindow);
			action->setText("Save As...");
			action->setIcon(*QtConfig::GetIcon("memorycard.png"));
			menuEngine->addAction(action);

			QObject::connect(action, &QAction::triggered, this, [picker]() {
				picker->OpenForSave();
			});

			QObject::connect(picker, &QFileDialog::fileSelected, this, [picker] (const QString & file) {
				if (picker->IsSaving()) {
					CSoundEditor::GetScene()->SaveSceneAs(file.toStdString().c_str());
				}
			});
		}
	}

	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Scene");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("Clear Scene");
		action->setIcon(*QtConfig::GetIcon("denied.png"));
		menu->addAction(action);

		QObject::connect(action, &QAction::triggered, this, []() {
			CSoundEditor::GetScene()->Clear();
			GUI::Get<SceneWindow>(QT_INSTACE::SCENE_EDITOR)->Clear();
		});
	}

	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Tools");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		{
			QAction *action = new QAction(MainWindow);
			action->setText("Reload StyleSheets");
			action->setIcon(*QtConfig::GetIcon("cmyk.png"));
			menu->addAction(action);
			QObject::connect(action, &QAction::triggered, this, &EditorMainWindow::ReloadStyleSheets);
		}

		// Submenu buttons
		{
			QAction *action = new QAction(MainWindow);
			action->setText("Reload CSound Config");
			action->setIcon(*QtConfig::GetIcon("loading.png"));
			menu->addAction(action);
			QObject::connect(action, &QAction::triggered, this, []() {
				SoundManager::Init();
			});
		}
	}

	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("CSound");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("Options");
		action->setIcon(*QtConfig::GetIcon("gear.png"));
		menu->addAction(action);

		appWindows["CSoundOptions"] = new CSoundOptionsWindow();

		QObject::connect(action, &QAction::triggered, this, [&]() {
			appWindows["CSoundOptions"]->Toggle();
		});
	}
	// Menu Entry
	{
		QMenu *menu = new QMenu(menuBar);
		menu->setTitle("Help");
		menuBar->addAction(menu->menuAction());

		// Submenu buttons
		QAction *action = new QAction(MainWindow);
		action->setText("About");
		action->setIcon(*QtConfig::GetIcon("chat.png"));
		menu->addAction(action);

		appWindows["About"] = new AboutWindow();

		QObject::connect(action, &QAction::triggered, this, [&]() {
			appWindows["About"]->Toggle();
		});
	}

	// ************************************************************************
	// Toolbar

	QToolBar *toolbar = new QToolBar();
	toolbar->setWindowTitle("Toolbar");

	// Play Audio
	{
		QToolButton *button = new QToolButton();
		button->setText("Play");
		button->setMaximumWidth(80);
		button->setIcon(*QtConfig::GetIcon("play.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			CSoundEditor::GetScene()->Play();
		});
		toolbar->addWidget(button);
	}

	// Stop Audio
	{
		QToolButton *button = new QToolButton();
		button->setText("Stop");
		button->setMaximumWidth(80);
		button->setIcon(*QtConfig::GetIcon("volume_disabled.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			CSoundEditor::GetScene()->Stop();
		});
		toolbar->addWidget(button);
	}

	// Save Scene
	{
		QToolButton *button = new QToolButton();
		button->setText("Save Scene");
		button->setIcon(*QtConfig::GetIcon("download.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		QObject::connect(button, &QToolButton::clicked, this, []() {
			auto result = CSoundEditor::GetScene()->SaveScene();
			if (!result) {
				auto picker = GUI::Get<FilePicker>(QT_INSTACE::FILE_PICKER);
				if (picker) {
					picker->OpenForSave();
				}
			}
		});
		toolbar->addWidget(button);
	}

	// Load Scene
	{
		QToolButton *button = new QToolButton();
		button->setText("Load Scene");
		button->setIcon(*QtConfig::GetIcon("upload.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		QObject::connect(picker, &QFileDialog::fileSelected, this, [picker] (const QString & file) {
			if (!picker->IsSaving())
			{
				CSoundEditor::GetScene()->LoadScene(file.toStdString().c_str());
				GUI::Get<SceneWindow>(QT_INSTACE::SCENE_EDITOR)->Init();
			}
		});

		QObject::connect(button, &QToolButton::clicked, this, [picker]() {
			picker->OpenForLoad();
		});
		toolbar->addWidget(button);
	}

	// Headphone Test
	{
		QToolButton *button = new QToolButton();
		button->setText("Headphone Test");
		button->setIcon(*QtConfig::GetIcon("speaker.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		appWindows["HeadphoneTest"] = new HeadphoneTestWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["HeadphoneTest"]->Toggle();
		});

		toolbar->addWidget(button);
	}

	// Moving Plane
	{
		QToolButton *button = new QToolButton();
		button->setText("Moving Plane");
		button->setIcon(*QtConfig::GetIcon("frames.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		toolbar->addWidget(button);

		appWindows["MovingPlane"] = new MovingPlaneWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["MovingPlane"]->Toggle();
		});
	}

	// Sweeping Plane
	{
		QToolButton *button = new QToolButton();
		button->setText("Horizontal Sweep");
		button->setIcon(*QtConfig::GetIcon("half-loading.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
		toolbar->addWidget(button);

		appWindows["SweepingPlane"] = new SweepingPlaneWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["SweepingPlane"]->Toggle();
		});
	}

	// Expanding Sphere
	{
		QToolButton *button = new QToolButton();
		button->setText("Expanding Sphere");
		button->setIcon(*QtConfig::GetIcon("target.png"));
		button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		appWindows["ExpandingPlane"] = new ExpandingSphereWindow();
		QObject::connect(button, &QToolButton::clicked, this, [this]() {
			appWindows["ExpandingPlane"]->Toggle();
		});

		toolbar->addWidget(button);
	}

	// Padding Scene
	{
		QWidget *empty = new QWidget();
		empty->setObjectName("ToolWiteSpace");
		toolbar->addWidget(empty);
	}

	// Sound Output Mode
	{
		dropdown = new QComboBox();
		dropdown->setMinimumWidth(60);

		QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();
		dropdown->setItemDelegate(itemDelegate);

		dropdown->addItem("None", QVariant(-1));
		dropdown->addItem("Mono", QVariant(0));
		dropdown->addItem("HRTF2", QVariant(1));
		dropdown->addItem("Stereo", QVariant(2));
		dropdown->addItem("ind-HRTF", QVariant(4));
		dropdown->addItem("PAN2", QVariant(8));
		dropdown->addItem("Quad-HRTF", QVariant(16));
		dropdown->addItem("Multi-8", QVariant(32));
		dropdown->addItem("Quad-Stereo", QVariant(64));

		// Default is HRTF
		dropdown->setCurrentIndex(2);
		SoundManager::SetGlobalOutputModelIndex(1);

		// Add widget
		auto widget = new CustomWidget(QBoxLayout::LeftToRight);
		widget->setObjectName("GlobalOutputDropdown");
		auto label = new QLabel("Global output");
		widget->AddWidget(label);
		widget->AddWidget(dropdown);
		toolbar->addWidget(widget);

		void (QComboBox::* indexChangedSignal)(int index) = &QComboBox::currentIndexChanged;
		QObject::connect(dropdown, indexChangedSignal, this, [&](int index) {
			if (index == 0) {
				SoundManager::SetGlobalOutputModelIndex(1024);
				CSoundEditor::GetScene()->SetOutputModel("none");
				return;
			} else if (SoundManager::GetGlobalOutputModelIndex() == 1024) {
				CSoundEditor::GetScene()->SetOutputModel("global-output");
			}
			auto data = dropdown->currentData().toUInt();
			SoundManager::SetGlobalOutputModelIndex(data);
		});
	}

	// Attach toobar to the main window
	MainWindow->addToolBar(toolbar);

	// ************************************************************************
	// Status Bar

	QStatusBar *statusBar = new QStatusBar(MainWindow);
	statusBar->setObjectName(QStringLiteral("statusBar"));
	MainWindow->setStatusBar(statusBar);

	//QMetaObject::connectSlotsByName(MainWindow);

	// ************************************************************************
	// Central Area

	QWidget *centeralWidget = new QWidget();
	centeralWidget->setFixedWidth(0);
	MainWindow->setCentralWidget(centeralWidget);

	// ************************************************************************
	// Attach windows
	dockWindows["TextPreview"] = new TextPreviewWindow();
	dockWindows["CodeEditor"] = new CodeEditorWindow();
	dockWindows["ComponentList"] = new ComponentList();
	dockWindows["InstrumentList"] = new InstrumentList();
	dockWindows["ScoreList"] = new ScoreList();

	dockWindows["ScoreEditor"] = new ScoreEditor();
	dockWindows["InstrumentEditor"] = new InstrumentEditor();
	dockWindows["ComponentEditor"] = new ComponentEditor();
	
	dockWindows["SceneWindow"] = new SceneWindow();
	dockWindows["GameWindow"] = new GameWindow();

	dockWindows["ObjectProperty"] = new SceneObjectProperties();
	dockWindows["CameraProperty"] = new CameraPropertyEditor();
	dockWindows["CSoundControl"] = new CSoundControlWindow();

	//// Left Dock
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["SceneWindow"], Qt::Orientation::Vertical);
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["ScoreEditor"], Qt::Orientation::Horizontal);
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["InstrumentEditor"], Qt::Orientation::Horizontal);
	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["ComponentEditor"], Qt::Orientation::Vertical);
	MainWindow->tabifyDockWidget(dockWindows["ComponentEditor"], dockWindows["ObjectProperty"]);
	MainWindow->tabifyDockWidget(dockWindows["ComponentEditor"], dockWindows["CameraProperty"]);
	MainWindow->tabifyDockWidget(dockWindows["ComponentEditor"], dockWindows["CSoundControl"]);

	MainWindow->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dockWindows["TextPreview"], Qt::Orientation::Horizontal);
	MainWindow->tabifyDockWidget(dockWindows["TextPreview"], dockWindows["CodeEditor"]);
	MainWindow->tabifyDockWidget(dockWindows["TextPreview"], dockWindows["GameWindow"]);

	dockWindows["GameWindow"]->setFloating(true);
	dockWindows["GameWindow"]->setFloating(false);
	dockWindows["GameWindow"]->raise();

	// Right Dock
	MainWindow->addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dockWindows["ComponentList"], Qt::Orientation::Vertical);
	MainWindow->addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dockWindows["InstrumentList"], Qt::Orientation::Vertical);
	MainWindow->addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dockWindows["ScoreList"], Qt::Orientation::Vertical);

	// Activate Windows
	dockWindows["ObjectProperty"]->raise();
}
Пример #18
0
void TextEdit::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    a = new QAction(QIcon(rsrcPath + "/filenew.png"), tr("&New"), this);
    a->setShortcut(QKeySequence::New);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/fileopen.png"), tr("&Open..."), this);
    a->setShortcut(QKeySequence::Open);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    actionSave = a = new QAction(QIcon(rsrcPath + "/filesave.png"), tr("&Save"), this);
    a->setShortcut(QKeySequence::Save);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(tr("Save &As..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
    menu->addAction(a);
    menu->addSeparator();

#ifndef QT_NO_PRINTER
    a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("&Print..."), this);
    a->setShortcut(QKeySequence::Print);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("Print Preview..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/exportpdf.png"), tr("&Export PDF..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_D);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();
#endif

    a = new QAction(tr("&Quit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(a, SIGNAL(triggered()), this, SLOT(close()));
    menu->addAction(a);
}
Пример #19
0
/**
\param bcont
**/
int entryPoint ( BfBulmaFact *bcont )
{
    BL_FUNC_DEBUG

    g_selcanales = new BcCanalSeleccionarView ( bcont->company(), 0 );
    g_selccostes = new BcCentroCosteSeleccionarView (bcont->company(), 0);
    
    /// Inicializa el sistema de traducciones 'gettext'.
    setlocale ( LC_ALL, "" );
    blBindTextDomain ( "pluginbf_canalyccoste", g_confpr->value( CONF_DIR_TRADUCCION ).toLatin1().constData() );
    g_pluginbf_canalyccoste = bcont;

    QMenu *pPluginMenu = bcont->menuMaestro;
    pPluginMenu->addSeparator();
    
    BlAction *accionA = new BlAction ( _ ( "&Canal" ), 0 );
    accionA->setStatusTip ( _ ( "Ver Canales" ) );
    accionA->setWhatsThis ( _ ( "Ver Canales" ) );
    accionA->setIcon ( QIcon ( QString::fromUtf8 ( ":/BulmaCont32x32/images/png/i_canales.xpm" ) ) );
    accionA->setObjectName("mui_actionCanal");
    pPluginMenu->addAction ( accionA );
    
    BlAction *accionB = new BlAction ( _ ( "&Centros de Coste" ), 0 );
    accionB->setStatusTip ( _ ( "Ver Centros de Coste" ) );
    accionB->setWhatsThis ( _ ( "Ver Centros de Coste" ) );
    accionB->setIcon ( QIcon ( QString::fromUtf8 ( ":/BulmaCont32x32/images/png/i_centroCoste.xpm" ) ) );
    accionB->setObjectName("mui_actionCCoste");
    pPluginMenu->addAction ( accionB );

    
    /// A&ntilde;adimos la nueva opci&oacute;n al men&uacute; principal del programa.
    /// Usamos un toolBox especial para meter los botones de contabilidad.
    QToolBar *toolCont =  bcont->findChild<QToolBar *> ( "contabilidad" );
    if ( !toolCont) {
	toolCont = new QToolBar(bcont);
	toolCont->setObjectName("contabilidad");
	toolCont->setFocusPolicy(Qt::TabFocus);
	toolCont->setOrientation(Qt::Horizontal);
	toolCont->setIconSize(QSize(32, 32));
        toolCont->setWindowTitle(N_("Contabilidad", 0));
        toolCont->setToolTip(N_("Contabilidad", 0));
        toolCont->setStatusTip(N_("Contabilidad", 0));
        toolCont->setWhatsThis(N_("Contabilidad", 0));
        toolCont->setAccessibleName(N_("Contabilidad", 0));
        toolCont->setAccessibleDescription(N_("Contabilidad", 0));
	bcont->addToolBar(Qt::TopToolBarArea, toolCont);
    } // end if
    toolCont->addAction(accionA);
    toolCont->addAction(accionB);
    
// =================================================
    /// Vamos a probar con un docwindow.
    BlDockWidget *doc1 = new BlDockWidget ( _ ( "Selector de Canales" ), bcont );
    doc1->setObjectName("mui_selcanales");
    doc1->setFeatures ( QDockWidget::AllDockWidgetFeatures );

    doc1->setGeometry ( 100, 100, 100, 500 );
    doc1->resize ( 330, 250 );
    bcont->addDockWidget ( Qt::RightDockWidgetArea, doc1 );

    doc1->show();

    doc1->setWidget ( g_selcanales );

// =================================================	
	
    
/**
 *
 *
 *
 *
 */	
// =================================================
    /// Vamos a probar con un docwindow.
    BlDockWidget *doc2 = new BlDockWidget ( _ ( "Selector de Centros de Coste" ), bcont );
    doc2->setObjectName("mui_selcostes");
    doc2->setFeatures ( QDockWidget::AllDockWidgetFeatures );

    doc2->setGeometry ( 100, 100, 100, 500 );
    doc2->resize ( 330, 250 );
    bcont->addDockWidget ( Qt::RightDockWidgetArea, doc2 );

    doc2->show();

    doc2->setWidget ( g_selccostes );

    return 0;
}
Пример #20
0
void TextEdit::setupTextActions()
{
    formattingToolBar = new QToolBar(this);
    formattingToolBar->setWindowTitle(tr("Format Actions"));
    addToolBar(formattingToolBar);

    QMenu *menu = new QMenu(tr("F&ormat"), this);
    menuBar()->addMenu(menu);

    actionTextBold = new QAction(QIcon(":/res/smalltextbold.png"), tr("&Bold"), this);
    actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
    actionTextBold->setPriority(QAction::LowPriority);
    QFont bold;
    bold.setBold(true);
    actionTextBold->setFont(bold);
    connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold()));
    formattingToolBar->addAction(actionTextBold);
    menu->addAction(actionTextBold);
    actionTextBold->setCheckable(true);

    actionTextItalic = new QAction(QIcon(":/res/smalltextitalic.png"), tr("&Italic"), this);
    actionTextItalic->setPriority(QAction::LowPriority);
    actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
    QFont italic;
    italic.setItalic(true);
    actionTextItalic->setFont(italic);
    connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic()));
    formattingToolBar->addAction(actionTextItalic);
    menu->addAction(actionTextItalic);
    actionTextItalic->setCheckable(true);

    actionTextUnderline = new QAction(QIcon(":/res/smalltextunder.png"), tr("&Underline"), this);
    actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
    actionTextUnderline->setPriority(QAction::LowPriority);
    QFont underline;
    underline.setUnderline(true);
    actionTextUnderline->setFont(underline);
    connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline()));
    formattingToolBar->addAction(actionTextUnderline);
    menu->addAction(actionTextUnderline);
    actionTextUnderline->setCheckable(true);

    menu->addSeparator();

    QActionGroup *grp = new QActionGroup(this);
    connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*)));

    // Make sure the alignLeft  is always left of the alignRight
    if (QApplication::isLeftToRight()) 
    {
        actionAlignLeft = new QAction(QIcon(":/res/smalltextleft.png"), tr("&Left"), grp);
        actionAlignCenter = new QAction(QIcon(":/res/smalltextcenter.png"), tr("C&enter"), grp);
        actionAlignRight = new QAction(QIcon(":/res/smalltextright.png"), tr("&Right"), grp);
    } 
    else 
    {
        actionAlignRight = new QAction(QIcon(":/res/smalltextright.png"), tr("&Right"), grp);
        actionAlignCenter = new QAction(QIcon(":/res/smalltextcenter.png"), tr("C&enter"), grp);
        actionAlignLeft = new QAction(QIcon(":/res/smalltextleft.png"), tr("&Left"), grp);
    }
    actionAlignJustify = new QAction(QIcon(":/res/smalltextjustify.png"), tr("&Justify"), grp);

    actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
    actionAlignLeft->setCheckable(true);
    actionAlignLeft->setPriority(QAction::LowPriority);
    actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
    actionAlignCenter->setCheckable(true);
    actionAlignCenter->setPriority(QAction::LowPriority);
    actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
    actionAlignRight->setCheckable(true);
    actionAlignRight->setPriority(QAction::LowPriority);
    actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
    actionAlignJustify->setCheckable(true);
    actionAlignJustify->setPriority(QAction::LowPriority);

    formattingToolBar->addActions(grp->actions());
    menu->addActions(grp->actions());

    menu->addSeparator();

    actionTextColor = new QAction(QIcon(":/res/smallcolor.png"), tr("&Color..."), this);
    colorButton = new Qtitan::PopupColorButton(formattingToolBar);
    colorButton->setDefaultAction(actionTextColor);
    formattingToolBar->addWidget(colorButton);
    menu->addAction(actionTextColor);
    connect(colorButton, SIGNAL(colorChanged(const QColor&)), this, SLOT(textColor(const QColor&)));
    connect(actionTextColor, SIGNAL(triggered()), this, SLOT(setColorText()));

    QToolBar* tb = new QToolBar(this);
    tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    tb->setWindowTitle(tr("Format Actions"));
    addToolBarBreak(Qt::TopToolBarArea);
    addToolBar(tb);

    comboStyle = new QComboBox(tb);
    tb->addWidget(comboStyle);
    comboStyle->addItem("Standard");
    comboStyle->addItem("Bullet List (Disc)");
    comboStyle->addItem("Bullet List (Circle)");
    comboStyle->addItem("Bullet List (Square)");
    comboStyle->addItem("Ordered List (Decimal)");
    comboStyle->addItem("Ordered List (Alpha lower)");
    comboStyle->addItem("Ordered List (Alpha upper)");
    comboStyle->addItem("Ordered List (Roman lower)");
    comboStyle->addItem("Ordered List (Roman upper)");
    connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int)));

    comboFont = new QFontComboBox(tb);
    tb->addWidget(comboFont);
    connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString)));

    comboSize = new QComboBox(tb);
    comboSize->setObjectName("comboSize");
    tb->addWidget(comboSize);
    comboSize->setEditable(true);

    QFontDatabase db;
    foreach(int size, db.standardSizes())
        comboSize->addItem(QString::number(size));

    connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString)));
    comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font().pointSize())));
}
Пример #21
0
DSPWindow::DSPWindow(QWidget *parent)
  : QMainWindow(parent)
{
  owDate = new QDate;
  *owDate = QDate::currentDate();

  // Меню - Файл ---------------------------------------------------------------
  QToolBar *tb = new QToolBar(this);
  tb->setWindowTitle(tr("File Actions"));
  addToolBar(tb);

  QMenu *menu = new QMenu(tr("&File"), this);
  menuBar()->addMenu(menu);

  QAction *a;
    
  a = new QAction(QIcon(rsrcPath + "/filenew.png"), tr("&New"), this);
  a->setShortcut(Qt::CTRL + Qt::Key_N);
  //connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
  tb->addAction(a);
  menu->addAction(a);

  a = new QAction(QIcon(rsrcPath + "/fileopen.png"), tr("&Open..."), this);
  a->setShortcut(Qt::CTRL + Qt::Key_O);
  //connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
  tb->addAction(a);
  menu->addAction(a);

  menu->addSeparator();

  actionSave = a = new QAction(QIcon(rsrcPath + "/filesave.png"), tr("&Save"), this);
  a->setShortcut(Qt::CTRL + Qt::Key_S);
  //connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
  a->setEnabled(false);
  tb->addAction(a);
  menu->addAction(a);

  a = new QAction(tr("Save &As..."), this);
  //connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
  menu->addAction(a);
  menu->addSeparator();

  a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("&Print..."), this);
  a->setShortcut(Qt::CTRL + Qt::Key_P);
  //connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
  tb->addAction(a);
  menu->addAction(a);

  a = new QAction(QIcon(rsrcPath + "/exportpdf.png"), tr("&Export PDF..."), this);
  a->setShortcut(Qt::CTRL + Qt::Key_D);
  //connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
  tb->addAction(a);
  menu->addAction(a);

  menu->addSeparator();

  a = new QAction(tr("&Quit"), this);
  a->setShortcut(Qt::CTRL + Qt::Key_Q);
  connect(a, SIGNAL(triggered()), this, SLOT(close()));
  menu->addAction(a);
  // Меню - Файл ..............................................................


  // Навигатор ----------------------------------------------------------------
  //QPalette palette( Qt::gray );
  //palette.setColor( QPalette::Button , QColor(Qt::white));

  navigator = new QDockWidget(tr("Навигатор"), this);
  navigator->setFeatures( navigator->features() ^ QDockWidget::DockWidgetClosable );
  navigator->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  navigator->setMaximumSize(QSize( NButtonWidth + 40 , 16777215)); // <- Задаем фиксированный размер
  navigator->setMinimumSize(QSize( NButtonWidth + 40 , 0)); // <----------|

  addDockWidget(Qt::LeftDockWidgetArea, navigator );
    
  navigatorBox = new QToolBox( navigator );
  navigatorBox->setFrameShape( QFrame::Panel );
  navigatorBox->setFrameShadow( QFrame::Plain );
  navigatorBox->setLineWidth(1);
  //navigatorBox->setPalette( palette );
  navigator->setWidget( navigatorBox );

  navigatorButtonGroup = new QButtonGroup;
  navigatorButtonGroup->setExclusive ( true );
  connect( navigatorButtonGroup , SIGNAL(buttonClicked ( int )), 
	   this, SLOT(selectPageInMainLayout( int )));

  NavigatorButton *navigatorButton;
  NavigatorLabel *navigatorLabel;

  // Оперативная работа ---
  QWidget *pageOpWork = new QWidget();

  QVBoxLayout *pageOpWorkVboxLayout = new QVBoxLayout( pageOpWork );
  pageOpWorkVboxLayout->setSpacing(6);
  pageOpWorkVboxLayout->setMargin(9);

  navigatorBox->addItem( pageOpWork , tr( "Оперативная работа" ));
  navigatorBox->setItemIcon ( 0 , QIcon( piconPath + "/32/ow.png") );
  // ее кнопки 

  navigatorLabel = new NavigatorLabel( tr( "Производство:"));
  pageOpWorkVboxLayout->addWidget( navigatorLabel );

  navigatorButton = new NavigatorButton( tr( "Производство фосфора") , 
				     QIcon( piconPath + "/32/Factor.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 21 );

  navigatorButton = new NavigatorButton( tr( "Выработка") ,
				     QIcon( piconPath + "/32/vyr.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 22 );

  // Разделитель >-------<
  QFrame *line = new QFrame;	// --------------------------
  line->setFrameShape(QFrame::HLine);
  pageOpWorkVboxLayout->addWidget( line );

  navigatorLabel = new NavigatorLabel( tr( "Сырье:"));
  pageOpWorkVboxLayout->addWidget( navigatorLabel );

  navigatorButton = new NavigatorButton( tr( "Приход сырья") ,
				     QIcon( piconPath + "/22/add.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 23 );

  navigatorButton = new NavigatorButton( tr( "Остатки сырья") ,
				     QIcon( piconPath + "/32/ost.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 24 );

  // Разделитель >-------<
  line = new QFrame;	// --------------------------
  line->setFrameShape(QFrame::HLine);
  pageOpWorkVboxLayout->addWidget( line );

  navigatorLabel = new NavigatorLabel( tr( "Продукция:"));
  pageOpWorkVboxLayout->addWidget( navigatorLabel );

  navigatorButton = new NavigatorButton( tr( "Приход со стороны") ,
				     QIcon( piconPath + "/22/add.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 25 );

  navigatorButton = new NavigatorButton( tr( "Отгрузка продукции") ,
				     QIcon( piconPath + "/22/remove.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 26 );

  navigatorButton = new NavigatorButton( tr( "Остатки продукции") ,
				     QIcon( piconPath + "/32/ost.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 27 );

  // Разделитель >-------<
  line = new QFrame;	// --------------------------
  line->setFrameShape(QFrame::HLine);
  pageOpWorkVboxLayout->addWidget( line );

  navigatorButton = new NavigatorButton( tr( "Простои") ,
				     QIcon( piconPath + "/32/potP4.png") );
  pageOpWorkVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 26 );


  QSpacerItem *spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, 
					    QSizePolicy::Expanding);

  pageOpWorkVboxLayout->addItem( spacerItem );
  // Оперативная работа ...

  // Отчеты ---
  QWidget *pageRaports = new QWidget();

  QVBoxLayout *pageRaportsVboxLayout = new QVBoxLayout( pageRaports );
  pageRaportsVboxLayout->setSpacing(6);
  pageRaportsVboxLayout->setMargin(9);
   
  navigatorBox->addItem( pageRaports , tr( "Отчеты" ));
  navigatorBox->setItemIcon ( 1 , QIcon( piconPath + "/16/fileopen.png") );
   
   
  navigatorButton = new NavigatorButton( tr( "Информация о работе") ,
 					 QIcon( radiantPath + "/docs_16.png") );
  pageRaportsVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 41 );

  // Разделитель >-------<
  line = new QFrame;	// --------------------------
  line->setFrameShape(QFrame::HLine);
  pageRaportsVboxLayout->addWidget( line );

  navigatorLabel = new NavigatorLabel( tr( "Баланс общий:"));
  pageRaportsVboxLayout->addWidget( navigatorLabel );

  navigatorButton = new NavigatorButton( tr( "Нарастающий") ,
 					 QIcon( radiantPath + "/docs_16.png") );
  pageRaportsVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 42 );

  navigatorButton = new NavigatorButton( tr( "Текущий") ,
 					 QIcon( radiantPath + "/docs_16.png") );
  pageRaportsVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 43 );
   
  spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, 
 			       QSizePolicy::Expanding);
  
  pageRaportsVboxLayout->addItem( spacerItem );


  spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, 
 			       QSizePolicy::Expanding);
  pageRaportsVboxLayout->addItem( spacerItem );
  // Отчеты ..


  // Справочники ---
  QWidget *pageHandbooks = new QWidget();

  QVBoxLayout *pageHandbooksVboxLayout = new QVBoxLayout( pageHandbooks );
  pageHandbooksVboxLayout->setSpacing(6);
  pageHandbooksVboxLayout->setMargin(9);

  navigatorBox->addItem( pageHandbooks , tr( "Справочники" ));
  navigatorBox->setItemIcon ( 2 , QIcon( piconPath + "/48/s.png") );

  navigatorButton = new NavigatorButton( tr( "Баланс фосфора") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 51 );

  navigatorButton = new NavigatorButton( tr( "Выработка") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 52 );

  navigatorButton = new NavigatorButton( tr( "Продукция") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 53 );

  navigatorButton = new NavigatorButton( tr( "Сырье") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 54 );

  navigatorButton = new NavigatorButton( tr( "Причины простоев") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 55 );

  navigatorButton = new NavigatorButton( tr( "Оборудование") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 56 );

  navigatorButton = new NavigatorButton( tr( "Поставщики") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 57 );

  navigatorButton = new NavigatorButton( tr( "Потребители") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 58 );

  // Разделитель >-------<
  line = new QFrame;		// --------------------------
  line->setFrameShape(QFrame::HLine);
  pageHandbooksVboxLayout->addWidget( line );
     
  navigatorButton = new NavigatorButton( tr( "Единицы измерения массы") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 59 );

  navigatorButton = new NavigatorButton( tr( "Цеха") ,
				     QIcon( piconPath + "/22/s_s22.png") );
  pageHandbooksVboxLayout->addWidget( navigatorButton );
  navigatorButtonGroup->addButton ( navigatorButton , 60 );

  spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, 
			       QSizePolicy::Expanding);

  pageHandbooksVboxLayout->addItem( spacerItem );

  // Справочники ..
  // Навигатор ................................................................

  // Док календарь - все остальное для работы с датами ----
  
  QDockWidget * dateTimeBrowser = new QDockWidget(tr("Дата"), this);
  dateTimeBrowser->setFeatures( dateTimeBrowser->features() ^ QDockWidget::DockWidgetClosable);
  dateTimeBrowser->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  dateTimeBrowser->setMaximumSize(QSize( NButtonWidth + 42 , 210 )); // <- Задаем фиксированный размер
  dateTimeBrowser->setMinimumSize(QSize( NButtonWidth + 42 , 0)); // <----------|

  addDockWidget(Qt::LeftDockWidgetArea , dateTimeBrowser );
  
  QWidget *pDatePickerWidget = new QWidget;
  QVBoxLayout *pDatePickerWidgetLayout = new QVBoxLayout; 
  pDatePickerWidgetLayout->setMargin(1);
  pDatePickerWidgetLayout->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
  pDatePickerWidget->setLayout( pDatePickerWidgetLayout );

  PDatePicker *pDatePicker = new PDatePicker( 19 , 28 );
  pDatePicker->setFrameStyle( QFrame::Box | QFrame::Plain );
  //pDatePicker->setFocusPolicy( Qt::NoFocus );
  pDatePickerWidgetLayout->addWidget( pDatePicker );

  dateTimeBrowser->setWidget( pDatePickerWidget );

  
  // ..

  // *************************************************************************
  // Рабочая область ---------------------------------------------------------
  mainWidget = new QWidget;
  mainWidget->setMinimumSize(QSize(400, 0)); // >|----------|<
  setCentralWidget ( mainWidget );
  mainLayout = new QStackedLayout( mainWidget );

  // Оперативная работа ........................
  // Производство фосфора    
  ow_prod_phos = new OW_Prod_Phos;
  mainLayout->addWidget( ow_prod_phos );
  // .. 
  // Выработка
  ow_producing = new OW_Producing;
  mainLayout->addWidget( ow_producing );
  // .. 
  // Приход со стороны
  ow_income = new OW_Income;
  mainLayout->addWidget( ow_income );
  // .. 
  // Отгрузка
  ow_outcome = new OW_Outcome;
  mainLayout->addWidget( ow_outcome );
  // .. 
  // Отгрузка
  ow_depot = new OW_Depot;
  mainLayout->addWidget( ow_depot );
  // .. 
  //Отчеты -------------------------------------
  // Общая информация по работе предприятия
  r_infoforday = new R_InfoForDay;
  mainLayout->addWidget( r_infoforday );
  // ..
  // Баланс общий
  r_allproductionbalance = new R_AllProductionBalance;
  mainLayout->addWidget( r_allproductionbalance );
  // ..
  // Справочники -------------------------------
  // Справочник Баланс фосфора --
  s_bal_dbtable = new S_BAL_DBTable;
  mainLayout->addWidget( s_bal_dbtable );
  // ..
  // Выработка --
  s_vyr_dbtable = new S_VYR_DBTable;
  mainLayout->addWidget( s_vyr_dbtable );
  // ..
  // Продукция --
  s_prod_dbtable = new S_PROD_DBTable;
  mainLayout->addWidget( s_prod_dbtable );
  // ..
  // Сырье --
  s_syr_dbtable = new S_SYR_DBTable;
  mainLayout->addWidget( s_syr_dbtable );
  // ..
  // Причины простоев --
  s_pprost_dbtable = new S_PPROST_DBTable;
  mainLayout->addWidget( s_pprost_dbtable );
  // ..
  // Оборудование --
  s_ob_dbtable = new S_OB_DBTable;
  mainLayout->addWidget( s_ob_dbtable );
  // ..
  // Поставщики --
  s_post_dbtable = new S_POST_DBTable;
  mainLayout->addWidget( s_post_dbtable );
  // ..
  // Поставщики --
  s_potr_dbtable = new S_POTR_DBTable;
  mainLayout->addWidget( s_potr_dbtable );
  // ..
  // Цеха --
  s_dep_dbtable = new S_DEP_DBTable;
  mainLayout->addWidget( s_dep_dbtable );
  // ..
  // Справочник единиц измерения --
  s_ed_mass_dbtable = new S_ED_MASS_DBTable;
  mainLayout->addWidget( s_ed_mass_dbtable );
  // ..
  // Справочники ...............................
 
  // Рабочая область .........................................................
  resize( 800, 576);

  // Сигналы и слоты для функций этого класса *--> >>--|
  connect( pDatePicker , SIGNAL( dateChanged( const QDate & )), 
	   this , SLOT( setOWDate( const QDate & )));
}
Пример #22
0
void TextEdit::setupTextActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Format Actions"));
    toolBar1.addWidget(tb);

    actionTextBold = new QAction(QIcon(rsrcPath + "/textbold.png"), tr("&Bold"), this);
    actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
    QFont bold;
    bold.setBold(true);
    actionTextBold->setFont(bold);
    connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold()));
    tb->addAction(actionTextBold);
    actionTextBold->setCheckable(true);

    actionTextItalic = new QAction(QIcon(rsrcPath + "/textitalic.png"), tr("&Italic"), this);
    actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
    QFont italic;
    italic.setItalic(true);
    actionTextItalic->setFont(italic);
    connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic()));
    tb->addAction(actionTextItalic);
    actionTextItalic->setCheckable(true);

    actionTextUnderline = new QAction(QIcon(rsrcPath + "/textunder.png"), tr("&Underline"), this);
    actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
    QFont underline;
    underline.setUnderline(true);
    actionTextUnderline->setFont(underline);
    connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline()));
    tb->addAction(actionTextUnderline);
    actionTextUnderline->setCheckable(true);

    QActionGroup *grp = new QActionGroup(this);
    connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *)));

    // Make sure the alignLeft  is always left of the alignRight
    if (QApplication::isLeftToRight()) {
	actionAlignLeft = new QAction(QIcon(rsrcPath + "/textleft.png"), tr("&Left"), grp);
	actionAlignCenter = new QAction(QIcon(rsrcPath + "/textcenter.png"), tr("C&enter"), grp);
	actionAlignRight = new QAction(QIcon(rsrcPath + "/textright.png"), tr("&Right"), grp);
    } else {
	actionAlignRight = new QAction(QIcon(rsrcPath + "/textright.png"), tr("&Right"), grp);
	actionAlignCenter = new QAction(QIcon(rsrcPath + "/textcenter.png"), tr("C&enter"), grp);
	actionAlignLeft = new QAction(QIcon(rsrcPath + "/textleft.png"), tr("&Left"), grp);
    }
    actionAlignJustify = new QAction(QIcon(rsrcPath + "/textjustify.png"), tr("&Justify"), grp);

    actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
    actionAlignLeft->setCheckable(true);
    actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
    actionAlignCenter->setCheckable(true);
    actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
    actionAlignRight->setCheckable(true);
    actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
    actionAlignJustify->setCheckable(true);

    tb->addActions(grp->actions());

    QPixmap pix(16, 16);
    pix.fill(Qt::black);
    actionTextColor = new QAction(pix, tr("&Color..."), this);
    connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor()));
    tb->addAction(actionTextColor);

    tb = new QToolBar(this);
    tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    tb->setWindowTitle(tr("Format Actions"));
    toolBar2.addWidget(tb);

    comboStyle = new QComboBox(tb);
    tb->addWidget(comboStyle);
    comboStyle->addItem("Standard");
    comboStyle->addItem("Bullet List (Disc)");
    comboStyle->addItem("Bullet List (Circle)");
    comboStyle->addItem("Bullet List (Square)");
    comboStyle->addItem("Ordered List (Decimal)");
    comboStyle->addItem("Ordered List (Alpha lower)");
    comboStyle->addItem("Ordered List (Alpha upper)");
    connect(comboStyle, SIGNAL(activated(int)),
	    this, SLOT(textStyle(int)));

    comboFont = new QFontComboBox(tb);
    tb->addWidget(comboFont);
    connect(comboFont, SIGNAL(activated(const QString &)),
	    this, SLOT(textFamily(const QString &)));

    comboSize = new QComboBox(tb);
    comboSize->setObjectName("comboSize");
    tb->addWidget(comboSize);
    comboSize->setEditable(true);

    QFontDatabase db;
    foreach(int size, db.standardSizes())
	comboSize->addItem(QString::number(size));

    connect(comboSize, SIGNAL(activated(const QString &)),
	    this, SLOT(textSize(const QString &)));
    comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font()
								   .pointSize())));
}
Пример #23
0
void DevGUI::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    a = new QAction(QIcon(":/new.png"), tr("&New..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_N);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(":/open.png"), tr("&Open..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_O);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    actionSave = a = new QAction(QIcon(":/save.png"), tr("&Save"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_S);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);
    
    a = new QAction(QIcon(":/save.png"), tr("Save &As..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
    a->setEnabled(false);
    menu->addAction(a);

    menu->addSeparator();

    actionSaveAll = a = new QAction(QIcon(":/saveall.png"), tr("&Save All"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_A);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAll()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    a = new QAction(QIcon(":/print.png"), tr("&Print..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_P);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    tb->addAction(a);
    menu->addAction(a);

    actionClose = a = new QAction(QIcon(":/close.png"), tr("&Close"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_W);
	a->setEnabled(false);
    connect(a, SIGNAL(triggered()), this, SLOT(fileClose()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    a = new QAction(QIcon(":/exit.png"), tr("E&xit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect( a, SIGNAL(triggered()), qApp, SLOT( quit() ) );
    menu->addAction(a);
}
Пример #24
0
TazDlg::TazDlg(QWidget* pParent)
	: QMainWindow(pParent), m_settings("tobis_stuff", "takin"),
		m_pSettingsDlg(new SettingsDlg(this, &m_settings)),
		m_pStatusMsg(new QLabel(this)),
		m_pCoordQStatusMsg(new QLabel(this)),
		m_pCoordCursorStatusMsg(new QLabel(this)),
		m_sceneRecip(this),
		m_dlgRecipParam(this, &m_settings),
		m_dlgRealParam(this, &m_settings),
		m_pGotoDlg(new GotoDlg(this, &m_settings))
{
	//log_debug("In ", __func__, ".");

	const bool bSmallqVisible = 0;
	const bool bBZVisible = 1;
	const bool bWSVisible = 1;

	this->setupUi(this);
	this->setWindowTitle(s_strTitle.c_str());
	this->setFont(g_fontGen);
	this->setWindowIcon(load_icon("res/icons/takin.svg"));

	btnAtoms->setEnabled(g_bHasScatlens);

	if(m_settings.contains("main/geo"))
	{
		QByteArray geo = m_settings.value("main/geo").toByteArray();
		restoreGeometry(geo);
	}
	/*if(m_settings.contains("main/width") && m_settings.contains("main/height"))
	{
		int iW = m_settings.value("main/width").toInt();
		int iH = m_settings.value("main/height").toInt();
		resize(iW, iH);
	}*/

	m_pStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	m_pCoordQStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	m_pCoordCursorStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	for(QLabel* pLabel : {m_pStatusMsg/*, m_pCoordQStatusMsg, m_pCoordCursorStatusMsg*/})
		pLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);

	QStatusBar *pStatusBar = new QStatusBar(this);
	pStatusBar->addWidget(m_pStatusMsg, 1);
	pStatusBar->addPermanentWidget(m_pCoordQStatusMsg, 0);
	pStatusBar->addPermanentWidget(m_pCoordCursorStatusMsg, 0);
	m_pCoordQStatusMsg->setMinimumWidth(350);
	m_pCoordQStatusMsg->setAlignment(Qt::AlignCenter);
	m_pCoordCursorStatusMsg->setMinimumWidth(325);
	m_pCoordCursorStatusMsg->setAlignment(Qt::AlignCenter);
	this->setStatusBar(pStatusBar);

	// --------------------------------------------------------------------------------

	m_vecEdits_real =
	{
		editA, editB, editC,
		editAlpha, editBeta, editGamma
	};
	m_vecEdits_recip =
	{
		editARecip, editBRecip, editCRecip,
		editAlphaRecip, editBetaRecip, editGammaRecip
	};

	m_vecEdits_plane =
	{
		editScatX0, editScatX1, editScatX2,
		editScatY0, editScatY1, editScatY2,

		editRealX0, editRealX1, editRealX2,
		editRealY0, editRealY1, editRealY2,
	};
	m_vecEdits_monoana =
	{
		editMonoD, editAnaD
	};

	//m_vecSpinBoxesSample = { spinRotPhi, spinRotTheta, spinRotPsi };
	m_vecCheckBoxesSenses = { checkSenseM, checkSenseS, checkSenseA };


	m_vecEditNames_real =
	{
		"sample/a", "sample/b", "sample/c",
		"sample/alpha", "sample/beta", "sample/gamma"
	};
	m_vecEditNames_recip =
	{
		"sample/a_recip", "sample/b_recip", "sample/c_recip",
		"sample/alpha_recip", "sample/beta_recip", "sample/gamma_recip"
	};
	m_vecEditNames_plane =
	{
		"plane/x0", "plane/x1", "plane/x2",
		"plane/y0", "plane/y1", "plane/y2",

		"plane/real_x0", "plane/real_x1", "plane/real_x2",
		"plane/real_y0", "plane/real_y1", "plane/real_y2",
	};
	m_vecEditNames_monoana =
	{
		"tas/mono_d", "tas/ana_d"
	};

	m_vecSpinBoxNamesSample = {"sample/phi", "sample/theta", "sample/psi"};
	m_vecCheckBoxNamesSenses = {"tas/sense_m", "tas/sense_s", "tas/sense_a"};


	// recip
	m_pviewRecip = new ScatteringTriangleView(groupRecip);
	groupRecip->addTab(m_pviewRecip, "Reciprocal Lattice");

	m_pviewProjRecip = new ProjLatticeView(groupRecip);
	groupRecip->addTab(m_pviewProjRecip, "Projection");

	m_pviewRecip->setScene(&m_sceneRecip);
	m_pviewProjRecip->setScene(&m_sceneProjRecip);

	if(m_settings.contains("main/recip_tab"))
		groupRecip->setCurrentIndex(m_settings.value("main/recip_tab").value<int>());


	// real
	m_pviewRealLattice = new LatticeView(groupReal);
	groupReal->addTab(m_pviewRealLattice, "Real Lattice");

	m_pviewReal = new TasLayoutView(groupReal);
	groupReal->addTab(m_pviewReal, "TAS Instrument");

	m_pviewTof = new TofLayoutView(groupReal);
	groupReal->addTab(m_pviewTof, "TOF Instrument");

	m_pviewRealLattice->setScene(&m_sceneRealLattice);
	m_pviewReal->setScene(&m_sceneReal);
	m_pviewTof->setScene(&m_sceneTof);

	if(m_settings.contains("main/real_tab"))
		groupReal->setCurrentIndex(m_settings.value("main/real_tab").value<int>());



	QObject::connect(m_pSettingsDlg, SIGNAL(SettingsChanged()), this, SLOT(SettingsChanged()));

	QObject::connect(&m_sceneReal, SIGNAL(nodeEvent(bool)), this, SLOT(RealNodeEvent(bool)));
	QObject::connect(&m_sceneRecip, SIGNAL(nodeEvent(bool)), this, SLOT(RecipNodeEvent(bool)));
	QObject::connect(&m_sceneTof, SIGNAL(nodeEvent(bool)), this, SLOT(TofNodeEvent(bool)));

	// TAS
	QObject::connect(&m_sceneRecip, SIGNAL(triangleChanged(const TriangleOptions&)),
		&m_sceneReal, SLOT(triangleChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneReal, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneRecip, SLOT(tasChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		&m_sceneReal, SLOT(recipParamsChanged(const RecipParams&)));

	// TOF
	QObject::connect(&m_sceneRecip, SIGNAL(triangleChanged(const TriangleOptions&)),
		&m_sceneTof, SLOT(triangleChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneTof, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneRecip, SLOT(tasChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		&m_sceneTof, SLOT(recipParamsChanged(const RecipParams&)));

	// connections between instruments
	QObject::connect(&m_sceneTof, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneReal, SLOT(triangleChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneReal, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneTof, SLOT(triangleChanged(const TriangleOptions&)));

	// scale factor
	if(m_pviewRecip)
		QObject::connect(m_pviewRecip, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneRecip, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewProjRecip)
		QObject::connect(m_pviewProjRecip, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneProjRecip, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewRealLattice)
		QObject::connect(m_pviewRealLattice, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneRealLattice, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewReal)
		QObject::connect(m_pviewReal, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneReal, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewTof)
		QObject::connect(m_pviewTof, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneTof, SLOT(scaleChanged(t_real_glob)));

	// parameter dialogs
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		&m_dlgRecipParam, SLOT(paramsChanged(const RecipParams&)));
	QObject::connect(&m_sceneReal, SIGNAL(paramsChanged(const RealParams&)),
		&m_dlgRealParam, SLOT(paramsChanged(const RealParams&)));

	// cursor position
	QObject::connect(&m_sceneRecip, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)),
		this, SLOT(RecipCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)));
	QObject::connect(&m_sceneProjRecip, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)),
		this, SLOT(RecipCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)));
	QObject::connect(&m_sceneRealLattice, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)),
		this, SLOT(RealCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)));

	QObject::connect(&m_sceneRecip, SIGNAL(spurionInfo(const tl::ElasticSpurion&, const std::vector<tl::InelasticSpurion<t_real_glob>>&, const std::vector<tl::InelasticSpurion<t_real_glob>>&)),
		this, SLOT(spurionInfo(const tl::ElasticSpurion&, const std::vector<tl::InelasticSpurion<t_real_glob>>&, const std::vector<tl::InelasticSpurion<t_real_glob>>&)));

	QObject::connect(m_pGotoDlg, SIGNAL(vars_changed(const CrystalOptions&, const TriangleOptions&)),
		this, SLOT(VarsChanged(const CrystalOptions&, const TriangleOptions&)));
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		m_pGotoDlg, SLOT(RecipParamsChanged(const RecipParams&)));

	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		this, SLOT(recipParamsChanged(const RecipParams&)));


	for(QLineEdit* pEdit : m_vecEdits_monoana)
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(UpdateDs()));

	for(QLineEdit* pEdit : m_vecEdits_real)
	{
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CheckCrystalType()));
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaks()));
	}

	for(QLineEdit* pEdit : m_vecEdits_plane)
	{
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaks()));
	}

	//for(QDoubleSpinBox* pSpin : m_vecSpinBoxesSample)
	//	QObject::connect(pSpin, SIGNAL(valueChanged(t_real)), this, SLOT(CalcPeaks()));

	for(QLineEdit* pEdit : m_vecEdits_recip)
	{
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CheckCrystalType()));
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaksRecip()));
	}

	QObject::connect(checkSenseM, SIGNAL(stateChanged(int)), this, SLOT(UpdateMonoSense()));
	QObject::connect(checkSenseS, SIGNAL(stateChanged(int)), this, SLOT(UpdateSampleSense()));
	QObject::connect(checkSenseA, SIGNAL(stateChanged(int)), this, SLOT(UpdateAnaSense()));

	QObject::connect(editSpaceGroupsFilter, SIGNAL(textEdited(const QString&)), this, SLOT(RepopulateSpaceGroups()));
	QObject::connect(comboSpaceGroups, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCrystalType()));
	QObject::connect(comboSpaceGroups, SIGNAL(currentIndexChanged(int)), this, SLOT(CalcPeaks()));
	QObject::connect(checkPowder, SIGNAL(stateChanged(int)), this, SLOT(CalcPeaks()));

	QObject::connect(btnAtoms, SIGNAL(clicked(bool)), this, SLOT(ShowAtomsDlg()));



	// --------------------------------------------------------------------------------
	// file menu
	QMenu *pMenuFile = new QMenu("File", this);

	QAction *pNew = new QAction("New", this);
	pNew->setIcon(load_icon("res/icons/document-new.svg"));
	pMenuFile->addAction(pNew);

	pMenuFile->addSeparator();

	QAction *pLoad = new QAction("Load...", this);
	pLoad->setIcon(load_icon("res/icons/document-open.svg"));
	pMenuFile->addAction(pLoad);

	m_pMenuRecent = new QMenu("Recently Loaded", this);
	tl::RecentFiles recent(&m_settings, "main/recent");
	m_pMapperRecent = new QSignalMapper(m_pMenuRecent);
	QObject::connect(m_pMapperRecent, SIGNAL(mapped(const QString&)),
		this, SLOT(LoadFile(const QString&)));
	recent.FillMenu(m_pMenuRecent, m_pMapperRecent);
	pMenuFile->addMenu(m_pMenuRecent);

	QAction *pSave = new QAction("Save", this);
	pSave->setIcon(load_icon("res/icons/document-save.svg"));
	pMenuFile->addAction(pSave);

	QAction *pSaveAs = new QAction("Save as...", this);
	pSaveAs->setIcon(load_icon("res/icons/document-save-as.svg"));
	pMenuFile->addAction(pSaveAs);

	pMenuFile->addSeparator();

	QAction *pImport = new QAction("Import...", this);
	pImport->setIcon(load_icon("res/icons/drive-harddisk.svg"));
	pMenuFile->addAction(pImport);

	m_pMenuRecentImport = new QMenu("Recently Imported", this);
	tl::RecentFiles recentimport(&m_settings, "main/recent_import");
	m_pMapperRecentImport = new QSignalMapper(m_pMenuRecentImport);
	QObject::connect(m_pMapperRecentImport, SIGNAL(mapped(const QString&)),
		this, SLOT(ImportFile(const QString&)));
	recentimport.FillMenu(m_pMenuRecentImport, m_pMapperRecentImport);
	pMenuFile->addMenu(m_pMenuRecentImport);

	pMenuFile->addSeparator();

	QAction *pSettings = new QAction("Settings...", this);
	pSettings->setIcon(load_icon("res/icons/preferences-system.svg"));
	pMenuFile->addAction(pSettings);

	pMenuFile->addSeparator();

	QAction *pExit = new QAction("Exit", this);
	pExit->setIcon(load_icon("res/icons/system-log-out.svg"));
	pMenuFile->addAction(pExit);


	// --------------------------------------------------------------------------------
	// recip menu
	m_pMenuViewRecip = new QMenu("Reciprocal Space", this);

	m_pGoto = new QAction("Go to Position...", this);
	m_pGoto->setIcon(load_icon("res/icons/goto.svg"));
	m_pMenuViewRecip->addAction(m_pGoto);

	QAction *pRecipParams = new QAction("Information...", this);
	m_pMenuViewRecip->addAction(pRecipParams);
	m_pMenuViewRecip->addSeparator();

	m_pSmallq = new QAction("Show Reduced Scattering Vector q", this);
	m_pSmallq->setIcon(load_icon("res/icons/q.svg"));
	m_pSmallq->setCheckable(1);
	m_pSmallq->setChecked(bSmallqVisible);
	m_pMenuViewRecip->addAction(m_pSmallq);

	m_pSnapSmallq = new QAction("Snap G to Bragg Peak", this);
	m_pSnapSmallq->setCheckable(1);
	m_pSnapSmallq->setChecked(m_sceneRecip.getSnapq());
	m_pMenuViewRecip->addAction(m_pSnapSmallq);

	QAction *pKeepAbsKiKf = new QAction("Keep |ki| and |kf| Fixed", this);
	pKeepAbsKiKf->setCheckable(1);
	pKeepAbsKiKf->setChecked(m_sceneRecip.getKeepAbsKiKf());
	m_pMenuViewRecip->addAction(pKeepAbsKiKf);

	m_pBZ = new QAction("Show First Brillouin Zone", this);
	m_pBZ->setIcon(load_icon("res/icons/brillouin.svg"));
	m_pBZ->setCheckable(1);
	m_pBZ->setChecked(bBZVisible);
	m_pMenuViewRecip->addAction(m_pBZ);


	QMenu *pMenuEwald = new QMenu("Ewald Sphere", this);
	QActionGroup *pGroupEwald = new QActionGroup(this);
	m_pEwaldSphereNone = new QAction("Disabled", this);
	m_pEwaldSphereKi = new QAction("Around ki", this);
	m_pEwaldSphereKf = new QAction("Around kf", this);
	for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf})
	{
		pAct->setCheckable(1);
		pGroupEwald->addAction(pAct);
	}

	m_pEwaldSphereKf->setChecked(1);
	pMenuEwald->addActions(pGroupEwald->actions());
	m_pMenuViewRecip->addMenu(pMenuEwald);


	m_pMenuViewRecip->addSeparator();

	QMenu *pMenuProj = new QMenu("Projection", this);
	pMenuProj->setTearOffEnabled(1);
	QActionGroup *pGroupProj = new QActionGroup(this);

	m_pProjGnom = new QAction("Gnomonic", this);
	m_pProjStereo = new QAction("Stereographic", this);
	m_pProjPara = new QAction("Parallel", this);
	m_pProjPersp = new QAction("Perspectivic", this);

	for(QAction *pAct : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp})
	{
		pAct->setCheckable(1);
		pGroupProj->addAction(pAct);
	}

	m_pProjStereo->setChecked(1);
	pMenuProj->addActions(pGroupProj->actions());

	m_pMenuViewRecip->addMenu(pMenuProj);

#if !defined NO_3D
	QAction *pView3D = new QAction("3D View...", this);
	//pView3D->setIcon(QIcon::fromTheme("applications-graphics"));
	m_pMenuViewRecip->addAction(pView3D);
#endif

	m_pMenuViewRecip->addSeparator();

	QAction *pRecipExport = new QAction("Export Lattice Graphics...", this);
	pRecipExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pRecipExport);

	QAction *pProjExport = new QAction("Export Projection Graphics...", this);
	pProjExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pProjExport);

#ifdef USE_GIL
	QAction *pBZExport = new QAction("Export Brillouin Zone Image...", this);
	pBZExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pBZExport);
#endif


	// --------------------------------------------------------------------------------
	// real menu
	m_pMenuViewReal = new QMenu("Real Space", this);
	m_pMenuViewReal->addAction(m_pGoto);

	QAction *pRealParams = new QAction("Information...", this);
	m_pMenuViewReal->addAction(pRealParams);

	m_pMenuViewReal->addSeparator();

	m_pShowRealQDir = new QAction("Show Q Direction", this);
	m_pShowRealQDir->setCheckable(1);
	m_pShowRealQDir->setChecked(m_sceneReal.GetTasLayout()->GetRealQVisible());
	m_pMenuViewReal->addAction(m_pShowRealQDir);

	m_pWS = new QAction("Show Wigner-Seitz Cell", this);
	m_pWS->setIcon(load_icon("res/icons/brillouin.svg"));
	m_pWS->setCheckable(1);
	m_pWS->setChecked(bWSVisible);
	m_pMenuViewReal->addAction(m_pWS);

	m_pMenuViewReal->addSeparator();

#if !defined NO_3D
	QAction *pView3DReal = new QAction("3D View...", this);
	//pView3DReal->setIcon(QIcon::fromTheme("applications-graphics"));
	m_pMenuViewReal->addAction(pView3DReal);
	m_pMenuViewReal->addSeparator();
#endif

	QAction *pRealLatticeExport = new QAction("Export Lattice Graphics...", this);
	pRealLatticeExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pRealLatticeExport);

	QAction *pRealExport = new QAction("Export TAS Layout...", this);
	pRealExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pRealExport);

	QAction *pTofExport = new QAction("Export TOF Layout...", this);
	pTofExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pTofExport);

#ifdef USE_GIL
	QAction *pWSExport = new QAction("Export Wigner-Seitz Cell Image...", this);
	pWSExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pWSExport);
#endif

	QAction *pExportUC = new QAction("Export Unit Cell Model...", this);
	pExportUC->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pExportUC);


	// --------------------------------------------------------------------------------
	// resolution menu
	QMenu *pMenuReso = new QMenu("Resolution", this);

	QAction *pResoParams = new QAction("Parameters...", this);
	pResoParams->setIcon(load_icon("res/icons/accessories-calculator.svg"));
	pMenuReso->addAction(pResoParams);

	pMenuReso->addSeparator();

	QAction *pResoEllipses = new QAction("Ellipses...", this);
	pResoEllipses->setIcon(load_icon("res/icons/ellipses.svg"));
	pMenuReso->addAction(pResoEllipses);

#if !defined NO_3D
	QAction *pResoEllipses3D = new QAction("3D Ellipsoids...", this);
	pMenuReso->addAction(pResoEllipses3D);
#endif

	pMenuReso->addSeparator();

	QAction *pResoConv = new QAction("Convolution...", this);
	pMenuReso->addAction(pResoConv);


	// --------------------------------------------------------------------------------
	// calc menu
	QMenu *pMenuCalc = new QMenu("Calculation", this);

	QAction *pNeutronProps = new QAction("Neutron Properties...", this);
	pNeutronProps->setIcon(load_icon("res/icons/x-office-spreadsheet-template.svg"));
	pMenuCalc->addAction(pNeutronProps);

	pMenuCalc->addSeparator();

	QAction *pPowder = new QAction("Powder Lines...", this);
	pPowder->setIcon(load_icon("res/icons/weather-snow.svg"));
	pMenuCalc->addAction(pPowder);

	QAction *pDW = new QAction("Scattering Factors...", this);
	pMenuCalc->addAction(pDW);

	QAction *pFormfactor = nullptr;
	if(g_bHasFormfacts && g_bHasScatlens)
	{
		pFormfactor = new QAction("Form Factors...", this);
		pMenuCalc->addAction(pFormfactor);
	}

	QAction *pSgList = new QAction("Space Group Types...", this);
	pMenuCalc->addAction(pSgList);

	QAction *pDisp = new QAction("Dispersions...", this);
	//pDisp->setIcon(load_icon("disp.svg"));
	pMenuCalc->addAction(pDisp);

	pMenuCalc->addSeparator();

	QAction *pDynPlane = new QAction("Kinematic Plane...", this);
	pMenuCalc->addAction(pDynPlane);

	QAction *pSpuri = new QAction("Spurious Scattering...", this);
	pMenuCalc->addAction(pSpuri);


#if !defined NO_NET
	// --------------------------------------------------------------------------------
	// network menu
	QMenu *pMenuNet = new QMenu("Network", this);

	QAction *pConn = new QAction("Connect to Instrument...", this);
	pConn->setIcon(load_icon("res/icons/network-transmit-receive.svg"));
	pMenuNet->addAction(pConn);

	QAction *pDisconn = new QAction("Disconnect", this);
	pDisconn->setIcon(load_icon("res/icons/network-offline.svg"));
	pMenuNet->addAction(pDisconn);

	pMenuNet->addSeparator();

	QAction *pNetScanMon = new QAction("Scan Monitor...", this);
	pMenuNet->addAction(pNetScanMon);

	QAction *pNetCache = new QAction("Network Cache...", this);
	pMenuNet->addAction(pNetCache);

	QAction *pNetRefresh = new QAction("Refresh", this);
	pNetRefresh->setIcon(load_icon("res/icons/view-refresh.svg"));
	pMenuNet->addSeparator();
	pMenuNet->addAction(pNetRefresh);
#endif


	// --------------------------------------------------------------------------------
	// tools menu
	QMenu *pMenuTools = new QMenu("Tools", this);

	QAction *pScanViewer = new QAction("Scan Viewer...", this);
	pMenuTools->addAction(pScanViewer);



	// --------------------------------------------------------------------------------
	// help menu
	QMenu *pMenuHelp = new QMenu("Help", this);

	QAction *pHelp = new QAction("Show Help...", this);
	pHelp->setIcon(load_icon("res/icons/help-browser.svg"));
	pMenuHelp->addAction(pHelp);

	QAction *pDevelDoc = new QAction("Show Developer Help...", this);
	if(find_resource("doc/devel/html/index.html", 0) == "")
		pDevelDoc->setEnabled(0);
	pDevelDoc->setIcon(load_icon("res/icons/help-browser.svg"));
	pMenuHelp->addAction(pDevelDoc);

	pMenuHelp->addSeparator();

	QAction *pAboutQt = new QAction("About Qt...", this);
	//pAboutQt->setIcon(QIcon::fromTheme("help-about"));
	pMenuHelp->addAction(pAboutQt);

	//pMenuHelp->addSeparator();
	QAction *pAbout = new QAction("About Takin...", this);
	pAbout->setIcon(load_icon("res/icons/dialog-information.svg"));
	pMenuHelp->addAction(pAbout);



	// --------------------------------------------------------------------------------
	QMenuBar *pMenuBar = new QMenuBar(this);
	pMenuBar->addMenu(pMenuFile);
	pMenuBar->addMenu(m_pMenuViewRecip);
	pMenuBar->addMenu(m_pMenuViewReal);
	pMenuBar->addMenu(pMenuReso);
	pMenuBar->addMenu(pMenuCalc);
	pMenuBar->addMenu(pMenuTools);
#if !defined NO_NET
	pMenuBar->addMenu(pMenuNet);
#endif
	pMenuBar->addMenu(pMenuHelp);


	QObject::connect(pNew, SIGNAL(triggered()), this, SLOT(New()));
	QObject::connect(pLoad, SIGNAL(triggered()), this, SLOT(Load()));
	QObject::connect(pSave, SIGNAL(triggered()), this, SLOT(Save()));
	QObject::connect(pSaveAs, SIGNAL(triggered()), this, SLOT(SaveAs()));
	QObject::connect(pImport, SIGNAL(triggered()), this, SLOT(Import()));
	QObject::connect(pScanViewer, SIGNAL(triggered()), this, SLOT(ShowScanViewer()));
	QObject::connect(pSettings, SIGNAL(triggered()), this, SLOT(ShowSettingsDlg()));
	QObject::connect(pExit, SIGNAL(triggered()), this, SLOT(close()));

	QObject::connect(m_pSmallq, SIGNAL(toggled(bool)), this, SLOT(EnableSmallq(bool)));
	QObject::connect(m_pBZ, SIGNAL(toggled(bool)), this, SLOT(EnableBZ(bool)));
	QObject::connect(m_pWS, SIGNAL(toggled(bool)), this, SLOT(EnableWS(bool)));

	for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf})
		QObject::connect(pAct, SIGNAL(triggered()), this, SLOT(ShowEwaldSphere()));

	QObject::connect(m_pShowRealQDir, SIGNAL(toggled(bool)), this, SLOT(EnableRealQDir(bool)));

	QObject::connect(m_pSnapSmallq, SIGNAL(toggled(bool)), &m_sceneRecip, SLOT(setSnapq(bool)));
	QObject::connect(pKeepAbsKiKf, SIGNAL(toggled(bool)), &m_sceneRecip, SLOT(setKeepAbsKiKf(bool)));

	QObject::connect(pRecipParams, SIGNAL(triggered()), this, SLOT(ShowRecipParams()));
	QObject::connect(pRealParams, SIGNAL(triggered()), this, SLOT(ShowRealParams()));

	for(QAction *pProj : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp})
		QObject::connect(pProj, SIGNAL(triggered()), this, SLOT(RecipProjChanged()));

#if !defined NO_3D
	QObject::connect(pView3D, SIGNAL(triggered()), this, SLOT(Show3D()));
	QObject::connect(pView3DReal, SIGNAL(triggered()), this, SLOT(Show3DReal()));
	QObject::connect(pResoEllipses3D, SIGNAL(triggered()), this, SLOT(ShowResoEllipses3D()));
#endif

	QObject::connect(pRecipExport, SIGNAL(triggered()), this, SLOT(ExportRecip()));
	QObject::connect(pProjExport, SIGNAL(triggered()), this, SLOT(ExportProj()));
	QObject::connect(pRealExport, SIGNAL(triggered()), this, SLOT(ExportReal()));
	QObject::connect(pTofExport, SIGNAL(triggered()), this, SLOT(ExportTof()));
	QObject::connect(pRealLatticeExport, SIGNAL(triggered()), this, SLOT(ExportRealLattice()));

	QObject::connect(pExportUC, SIGNAL(triggered()), this, SLOT(ExportUCModel()));

#ifdef USE_GIL
	QObject::connect(pBZExport, SIGNAL(triggered()), this, SLOT(ExportBZImage()));
	QObject::connect(pWSExport, SIGNAL(triggered()), this, SLOT(ExportWSImage()));
#endif

	QObject::connect(pResoParams, SIGNAL(triggered()), this, SLOT(ShowResoParams()));
	QObject::connect(pResoEllipses, SIGNAL(triggered()), this, SLOT(ShowResoEllipses()));
	QObject::connect(pResoConv, SIGNAL(triggered()), this, SLOT(ShowResoConv()));

	QObject::connect(pNeutronProps, SIGNAL(triggered()), this, SLOT(ShowNeutronDlg()));
	QObject::connect(m_pGoto, SIGNAL(triggered()), this, SLOT(ShowGotoDlg()));
	QObject::connect(pPowder, SIGNAL(triggered()), this, SLOT(ShowPowderDlg()));
	QObject::connect(pDisp, SIGNAL(triggered()), this, SLOT(ShowDispDlg()));
	QObject::connect(pSpuri, SIGNAL(triggered()), this, SLOT(ShowSpurions()));
	QObject::connect(pDW, SIGNAL(triggered()), this, SLOT(ShowDWDlg()));
	QObject::connect(pDynPlane, SIGNAL(triggered()), this, SLOT(ShowDynPlaneDlg()));

#if !defined NO_NET
	QObject::connect(pConn, SIGNAL(triggered()), this, SLOT(ShowConnectDlg()));
	QObject::connect(pDisconn, SIGNAL(triggered()), this, SLOT(Disconnect()));
	QObject::connect(pNetRefresh, SIGNAL(triggered()), this, SLOT(NetRefresh()));
	QObject::connect(pNetCache, SIGNAL(triggered()), this, SLOT(ShowNetCache()));
	QObject::connect(pNetScanMon, SIGNAL(triggered()), this, SLOT(ShowNetScanMonitor()));
#endif

	QObject::connect(pSgList, SIGNAL(triggered()), this, SLOT(ShowSgListDlg()));

	if(pFormfactor)
		QObject::connect(pFormfactor, SIGNAL(triggered()), this, SLOT(ShowFormfactorDlg()));

	QObject::connect(pHelp, SIGNAL(triggered()), this, SLOT(ShowHelp()));
	QObject::connect(pDevelDoc, SIGNAL(triggered()), this, SLOT(ShowDevelDoc()));
	QObject::connect(pAbout, SIGNAL(triggered()), this, SLOT(ShowAbout()));
	QObject::connect(pAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));


	setMenuBar(pMenuBar);
	// --------------------------------------------------------------------------------


	// --------------------------------------------------------------------------------
	// context menus
	if(m_pviewRecip) m_pviewRecip->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewProjRecip) m_pviewProjRecip->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewRealLattice) m_pviewRealLattice->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewReal) m_pviewReal->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewTof) m_pviewTof->setContextMenuPolicy(Qt::CustomContextMenu);

	if(m_pviewRecip)
		QObject::connect(m_pviewRecip, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RecipContextMenu(const QPoint&)));
	if(m_pviewProjRecip)
		QObject::connect(m_pviewProjRecip, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RecipContextMenu(const QPoint&)));
	if(m_pviewRealLattice)
		QObject::connect(m_pviewRealLattice, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RealContextMenu(const QPoint&)));
	if(m_pviewReal)
		QObject::connect(m_pviewReal, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RealContextMenu(const QPoint&)));
	if(m_pviewTof)
		QObject::connect(m_pviewTof, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RealContextMenu(const QPoint&)));


	// --------------------------------------------------------------------------------
	// tool bars
	QToolBar *pFileTools = new QToolBar(this);
	pFileTools->setWindowTitle("File");
	pFileTools->addAction(pNew);
	pFileTools->addAction(pLoad);
	pFileTools->addAction(pImport);
	pFileTools->addAction(pSave);
	pFileTools->addAction(pSaveAs);
	addToolBar(pFileTools);

	QToolBar *pRecipTools = new QToolBar(this);
	pRecipTools->setWindowTitle("Reciprocal Space");
	pRecipTools->addAction(m_pGoto);
	pRecipTools->addAction(m_pSmallq);
	pRecipTools->addAction(m_pBZ);
	//pRecipTools->addAction(m_pEwaldSphere);
	addToolBar(pRecipTools);

	QToolBar *pResoTools = new QToolBar(this);
	pResoTools->setWindowTitle("Resolution");
	pResoTools->addAction(pResoParams);
	pResoTools->addAction(pResoEllipses);
	addToolBar(pResoTools);

	QToolBar *pCalcTools = new QToolBar(this);
	pCalcTools->setWindowTitle("Calculation");
	pCalcTools->addAction(pNeutronProps);
	pCalcTools->addAction(pPowder);
	addToolBar(pCalcTools);

#if !defined NO_NET
	QToolBar *pNetTools = new QToolBar(this);
	pNetTools->setWindowTitle("Network");
	pNetTools->addAction(pConn);
	pNetTools->addAction(pDisconn);
	pNetTools->addAction(pNetRefresh);
	addToolBar(pNetTools);
#endif

	// --------------------------------------------------------------------------------


	RepopulateSpaceGroups();

	unsigned int iMaxPeaks = m_settings.value("main/max_peaks", 10).toUInt();

	m_sceneRecip.GetTriangle()->SetMaxPeaks(iMaxPeaks);
	m_sceneRecip.GetTriangle()->SetPlaneDistTolerance(s_dPlaneDistTolerance);

	m_sceneProjRecip.GetLattice()->SetMaxPeaks(iMaxPeaks/2);

	m_sceneRealLattice.GetLattice()->SetMaxPeaks(iMaxPeaks);
	m_sceneRealLattice.GetLattice()->SetPlaneDistTolerance(s_dPlaneDistTolerance);

#if !defined NO_3D
	if(m_pRecip3d)
	{
		m_pRecip3d->SetMaxPeaks((t_real)iMaxPeaks);
		m_pRecip3d->SetPlaneDistTolerance(s_dPlaneDistTolerance);
	}
#endif

	m_bReady = 1;
	UpdateDs();
	CalcPeaks();


	m_sceneRecip.GetTriangle()->SetqVisible(bSmallqVisible);
	m_sceneRecip.GetTriangle()->SetBZVisible(bBZVisible);
	m_sceneRecip.GetTriangle()->SetEwaldSphereVisible(EWALD_KF);
	m_sceneRealLattice.GetLattice()->SetWSVisible(bWSVisible);
	m_sceneRecip.emitUpdate();
	//m_sceneRecip.emitAllParams();

	setAcceptDrops(1);
}