void TableView::contextMenuEvent(QContextMenuEvent *e)
{
    QMenu menu;
    menu.addAction("Nouveau...",this,SLOT(addNewElement()));
    QAction * actionSuppr = new QAction("Supprimer",this);
    connect(actionSuppr,SIGNAL(triggered()),this,SLOT(deleteElement()));
    menu.addAction(actionSuppr);

    QAction * actionEditColor = new QAction("Editer couleur...",this);
    connect(actionEditColor,SIGNAL(triggered()),this,SLOT(editColor()));
    menu.addAction(actionEditColor);

    if (selectedIndexes().empty())
    {
        actionEditColor->setEnabled(false);
        actionSuppr->setEnabled(false);
    }

    menu.exec(e->globalPos());
}
Пример #2
0
FieldView::FieldView(QWidget* parent)
    : QTreeView(parent), m_mapper(new QSignalMapper(this))
{
    //Item action
    m_delItem = new QAction(tr("Delete Item"),this);
    m_applyValueOnSelection = new QAction(tr("Apply on Selection"),this);
    m_applyValueOnAllLines = new QAction(tr("Apply on all lines"),this);
    m_defineCode = new QAction(tr("Define Field Code"),this);
    m_resetCode = new QAction(tr("Reset Field Code"),this);

    m_showGeometryGroup = new QAction(tr("Position columns"),this);
    connect(m_showGeometryGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
        showColumn(CharacterSheetItem::X);
        showColumn(CharacterSheetItem::Y);
        showColumn(CharacterSheetItem::WIDTH);
        showColumn(CharacterSheetItem::HEIGHT);
        showColumn(CharacterSheetItem::PAGE);
    });
    m_showEsteticGroup= new QAction(tr("Esthetic columns"),this);
    connect(m_showEsteticGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
        showColumn(CharacterSheetItem::BGCOLOR);
        showColumn(CharacterSheetItem::BORDER);
        showColumn(CharacterSheetItem::CLIPPED);
        showColumn(CharacterSheetItem::FONT);
        showColumn(CharacterSheetItem::TEXT_ALIGN);
        showColumn(CharacterSheetItem::TEXTCOLOR);
    });
    m_showValueGroup= new QAction(tr("Value columns"),this);
    connect(m_showValueGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
        showColumn(CharacterSheetItem::VALUE);
        showColumn(CharacterSheetItem::VALUES);
        showColumn(CharacterSheetItem::TYPE);
    });
    m_showIdGroup= new QAction(tr("Id columns"),this);
    connect(m_showIdGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
    });

    m_showAllGroup= new QAction(tr("All columns"),this);
    connect(m_showAllGroup,&QAction::triggered,this,[=](){
        hideAllColumns(false);
    });

    setAlternatingRowColors(true);
#ifdef Q_OS_MACX
    setAlternatingRowColors(false);
#endif

    connect(this,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(editColor(QModelIndex)));

    AlignmentDelegate* delegate = new AlignmentDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::TEXT_ALIGN),delegate);

    TypeDelegate* typeDelegate = new TypeDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::TYPE),typeDelegate);

    FontDelegate* fontDelegate = new FontDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::FONT),fontDelegate);

    PageDelegate* pageDelegate = new PageDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::PAGE),pageDelegate);

    setItemDelegateForColumn(CharacterSheetItem::BORDER,new BorderListEditor);

    connect(m_mapper,static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped),this,[this](int i)
    {
        this->setColumnHidden(i,!this->isColumnHidden(i));
    });
}
Пример #3
0
PreferencesDialog::PreferencesDialog(QWidget * parent, Qt::WindowFlags f)
    : QDialog(parent, f), ui(new Ui::PreferencesDialogBox())
{
    ui->setupUi(this);

    NewEmptyMapDialog dialog;
    ui->m_defaultMapModeCombo->addItems(dialog.getPermissionData());

    m_preferences = PreferencesManager::getInstance();

    m_aliasModel = new DiceAliasModel();
    ui->m_tableViewAlias->setModel(m_aliasModel);
    m_diceParser = new DiceParser();
    m_aliasModel->setAliases(m_diceParser->getAliases());

    QHeaderView* horizontalHeader = ui->m_tableViewAlias->horizontalHeader();
    horizontalHeader->setSectionResizeMode(DiceAliasModel::PATTERN,QHeaderView::ResizeToContents);
    horizontalHeader->setSectionResizeMode(DiceAliasModel::VALUE,QHeaderView::Stretch);
    horizontalHeader->setSectionResizeMode(DiceAliasModel::METHOD,QHeaderView::ResizeToContents);
    ui->m_tableViewAlias->setItemDelegateForColumn(DiceAliasModel::METHOD,new CheckBoxDelegate());

    m_paletteModel = new PaletteModel();
    m_paletteModel->setPalette(palette());
    ui->m_paletteTableView->setModel(m_paletteModel);
    horizontalHeader = ui->m_paletteTableView->horizontalHeader();
    horizontalHeader->setSectionResizeMode(0,QHeaderView::Stretch);

    connect(this, SIGNAL(accepted()), this, SLOT(save()));

    connect(ui->m_startDiag,SIGNAL(clicked()),this,SLOT(performDiag()));
    //ui->m_fogColor->setTransparency(true);

    //set general panel as default.
    ui->tabWidget->setCurrentIndex(0);

    //aliases
    connect(ui->m_addDiceAliasAct,SIGNAL(clicked()),this,SLOT(managedAction()));
    connect(ui->m_delDiceAliasAct,SIGNAL(clicked()),this,SLOT(managedAction()));
    connect(ui->m_upDiceAliasAct,SIGNAL(clicked()),this,SLOT(managedAction()));
    connect(ui->m_downDiceAliasAct,SIGNAL(clicked()),this,SLOT(managedAction()));
    connect(ui->m_topDiceAliasAct,SIGNAL(clicked()),this,SLOT(managedAction()));
    connect(ui->m_bottomDiceAliasAct,SIGNAL(clicked()),this,SLOT(managedAction()));
    connect(ui->m_testPushButton,SIGNAL(clicked()),this,SLOT(testAliasCommand()));

    // Misc
    setSizeGripEnabled(true);
    setWindowTitle(QString("%1 - %2").arg(m_preferences->value("Application_Name","rolisteam").toString(),tr("Preferences")));
    setWindowModality(Qt::ApplicationModal);


    m_preferences->registerListener("isPlayer",m_aliasModel);
    m_aliasModel->setGM(!m_preferences->value("isPlayer",false).toBool());


    // background
    connect(ui->m_positioningComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(applyBackground()));
    connect(ui->m_bgColorPush, SIGNAL(colorChanged(QColor)), this, SLOT(applyBackground()));
    connect(ui->m_backgroundImage,SIGNAL(pathChanged()),this,SLOT(applyBackground()));

    //themes
    connect(ui->m_copyThemeButton,SIGNAL(clicked()),this,SLOT(dupplicateTheme()));
    connect(ui->m_themeNameLineEdit,SIGNAL(textEdited(QString)),this,SLOT(setTitleAtCurrentTheme()));


    connect(ui->m_paletteTableView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(editColor(QModelIndex)));
    connect(ui->m_cssEdit,SIGNAL(clicked()),this,SLOT(editCss()));
    connect(ui->m_exportBtn,SIGNAL(clicked()),this,SLOT(exportTheme()));
    connect(ui->m_importBtn,SIGNAL(clicked()),this,SLOT(importTheme()));
    connect(ui->m_deleteTheme,SIGNAL(clicked()),this,SLOT(deleteTheme()));

}