Exemplo n.º 1
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);

  a = new QAction(tr("Save &As..."), this);
  a->setPriority(QAction::LowPriority);
  connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
//  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);
}
Exemplo n.º 2
0
Dialog_Mail::Dialog_Mail(QWidget *parent, QString iTitle, int *iIdx, DialogMailType iMode)
    : QDialog(parent)
{
    Mode = iMode;
    Idx = iIdx;
    setWindowTitle(iTitle);

    QAction *ActSend = new QAction(tr("Отправить"),this);
    ActSend->setIcon(QPixmap(":img/SendMail.png"));
    ActSend->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
    ActSend->setText(tr("&Отправить Сообщения"));
    ActSend->setToolTip(tr("Отправить Сообщения"));
    ActSend->setStatusTip(tr("Отправить Сообщения"));
    connect(ActSend, SIGNAL(triggered()), this, SLOT(SlotSend()));

    QAction *ActSave = new QAction(tr("Сохранить"),this);
    ActSave->setIcon(QPixmap(":img/Save.png"));
    ActSave->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
    ActSave->setText(tr("&Сохранить Сообщение"));
    ActSave->setToolTip(tr("Сохранить Сообщение"));
    ActSave->setStatusTip(tr("Сохранить Сообщение"));
    connect(ActSave, SIGNAL(triggered()), this, SLOT(SlotSave()));

    QAction *ActCancel = new QAction(tr("Отменить"),this);
    ActCancel->setIcon(QPixmap(":img/Cancel.png"));
    ActCancel->setShortcut(QKeySequence("ESC"));
    ActCancel->setText(tr("&Отменить Сообщение"));
    ActCancel->setToolTip(tr("Отменить Сообщение"));
    ActCancel->setStatusTip(tr("Отменить Сообщение"));
    connect(ActCancel, SIGNAL(triggered()), this, SLOT(SlotCancel()));

    QHBoxLayout *ToolLayout = new QHBoxLayout();
    ToolLayout->setMargin(0);
    QToolBar *ToolBar = new QToolBar();
    ToolBar->setOrientation(Qt::Horizontal);
    ToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    ToolLayout->addWidget(ToolBar);

    ToolBar->addAction(ActSend);
    ToolBar->addSeparator();
    ToolBar->addAction(ActSave);
    ToolBar->addSeparator();
    ToolBar->addAction(ActCancel);

    QFrame *ToolFrame = new QFrame();
    ToolFrame->setStyleSheet(QString("background-color: %1").arg(Global.Palette.color(QPalette::Window).name()));
    ToolFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
    ToolFrame->setLayout(ToolLayout);

    QVBoxLayout *TBox = new QVBoxLayout();
    TBox->setMargin(0);
    Receiver = new QComboBox();
    Subj = new QLineEdit();
    Message = new QTextEdit();
    QFormLayout *Form = new QFormLayout();
    Form->addRow(tr("Получатель: "), Receiver);
    Form->addRow(tr("Тема: "), Subj);
    Form->setLabelAlignment(Qt::AlignRight);
    TBox->addLayout(Form,0);
    TBox->addWidget(Message,1);

    QFrame *Center = new QFrame();
    Center->setLayout(TBox);

    QVBoxLayout *Out = new QVBoxLayout();
    Out->addWidget(ToolFrame,0);
    Out->addSpacing(4);
    Out->addWidget(Center,1);
    setLayout(Out);
    setMinimumSize(480,320);
    Init();
}
Exemplo n.º 3
0
	void Mainframe::show()
	{
		// prevent multiple inserting of menu entries, by calls of showFullScreen(), ...
		if (preferences_action_ != 0) 
		{
			MainControl::show();
			return;
		}

		QToolBar* tb = NULL;
		if (UIOperationMode::instance().getMode() <= UIOperationMode::MODE_ADVANCED)
		{
			tb = new QToolBar("Main Toolbar", this);
			tb->setObjectName("Main Toolbar");
			tb->setIconSize(QSize(22,22));
			addToolBar(Qt::TopToolBarArea, tb);
		}

		MainControl::show();

		QMenu *menu = initPopupMenu(MainControl::WINDOWS, UIOperationMode::MODE_ADVANCED);

		if (menu)
		{
			menu->addSeparator();
		  menu->addAction(tb->toggleViewAction());
		}

		// NOTE: this *has* to be run... a null pointer is unproblematic
		if (UIOperationMode::instance().getMode() <= UIOperationMode::MODE_ADVANCED)
		{
						MolecularFileDialog::getInstance(0)->addToolBarEntries(tb);
						DownloadPDBFile::getInstance(0)->addToolBarEntries(tb);
						DownloadElectronDensity::getInstance(0)->addToolBarEntries(tb);
						PubChemDialog::getInstance(0)->addToolBarEntries(tb);
						UndoManagerDialog::getInstance(0)->addToolBarEntries(tb);
						tb->addAction(fullscreen_action_);

						Path path;

						IconLoader& loader = IconLoader::instance();
						qload_action_ = new QAction(loader.getIcon("actions/quickopen-file"), tr("quickload"), this);
						qload_action_->setObjectName("quickload");
						connect(qload_action_, SIGNAL(triggered()), this, SLOT(quickLoadConfirm()));
						HelpViewer::getInstance("BALLView Docu")->registerForHelpSystem(qload_action_, "tips.html#quickload");
						tb->addAction(qload_action_);

						qsave_action_ = new QAction(loader.getIcon("actions/quicksave"), tr("quicksave"), this);
						qsave_action_->setObjectName("quicksave");
						connect(qsave_action_, SIGNAL(triggered()), this, SLOT(quickSave()));
						HelpViewer::getInstance("BALLView Docu")->registerForHelpSystem(qsave_action_, "tips.html#quickload");
						tb->addAction(qsave_action_);

						tb->addSeparator();
						DisplayProperties::getInstance(0)->addToolBarEntries(tb);
						MolecularStructure::getInstance(0)->addToolBarEntries(tb);
		}

		scene_->addToolBarEntries(tb);
		if (UIOperationMode::instance().getMode() <= UIOperationMode::MODE_ADVANCED)
		{
		
						tb->addAction(stop_simulation_action_);
						tb->addAction(preferences_action_);
						HelpViewer::getInstance("BALLView Docu")->addToolBarEntries(tb);
		}
		// we have changed the child widgets stored in the maincontrol (e.g. toolbars), so we have
		// to restore the window state again!
		restoreWindows();
	}
toSGATrace::toSGATrace(QWidget *main, toConnection &connection)
        : toToolWidget(SGATraceTool, "trace.html", main, connection, "toSGATrace")
{
    QToolBar *toolbar = toAllocBar(this, tr("SGA trace"));
    layout()->addWidget(toolbar);

    FetchAct = new QAction(QPixmap(const_cast<const char**>(refresh_xpm)),
                           tr("Fetch statements in SGA"), this);
    FetchAct->setShortcut(QKeySequence::Refresh);
    connect(FetchAct, SIGNAL(triggered()), this, SLOT(refresh(void)));
    toolbar->addAction(FetchAct);

    toolbar->addSeparator();

    QLabel * labSchema = new QLabel(tr("Schema") + " ", toolbar);
    toolbar->addWidget(labSchema);

    Schema = new toResultCombo(toolbar);
    Schema->additionalItem(tr("Any"));
    Schema->setSelected(connection.user().toUpper());
    Schema->query(toSQL::sql(toSQL::TOSQL_USERLIST));
    toolbar->addWidget(Schema);

    connect(Schema, SIGNAL(activated(const QString &)), this, SLOT(changeSchema(const QString &)));

    toolbar->addSeparator();

    QLabel * labRef = new QLabel(tr("Refresh") + " ", toolbar);
    toolbar->addWidget(labRef);
    connect(Refresh = toRefreshCreate(toolbar, TO_TOOLBAR_WIDGET_NAME),
            SIGNAL(activated(const QString &)), this, SLOT(changeRefresh(const QString &)));
    toolbar->addWidget(Refresh);

    toolbar->addSeparator();

    QLabel * labType = new QLabel(tr("Type") + " ", toolbar);
    toolbar->addWidget(labType);

    Type = new QComboBox(toolbar);
    Type->addItem(tr("SGA"));
    Type->addItem(tr("Long operations"));
    toolbar->addWidget(Type);

    toolbar->addSeparator();

    QLabel * labSelect = new QLabel(tr("Selection") + " ", toolbar);
    toolbar->addWidget(labSelect);

    Limit = new QComboBox(toolbar);
    Limit->addItem(tr("All"));
    Limit->addItem(tr("Unfinished"));
    Limit->addItem(tr("1 execution, 1 parse"));
    Limit->addItem(tr("Top executions"));
    Limit->addItem(tr("Top sorts"));
    Limit->addItem(tr("Top diskreads"));
    Limit->addItem(tr("Top buffergets"));
    Limit->addItem(tr("Top rows"));
    Limit->addItem(tr("Top sorts/exec"));
    Limit->addItem(tr("Top diskreads/exec"));
    Limit->addItem(tr("Top buffergets/exec"));
    Limit->addItem(tr("Top rows/exec"));
    Limit->addItem(tr("Top buffers/row"));
    toolbar->addWidget(Limit);

    toolbar->addWidget(new toSpacer());

    new toChangeConnection(toolbar, TO_TOOLBAR_WIDGET_NAME);

    QSplitter *splitter = new QSplitter(Qt::Vertical, this);
    layout()->addWidget(splitter);

    Trace = new toResultTableView(false, false, splitter);

    QList<int> list;
    list.append(75);
    splitter->setSizes(list);

    Trace->setReadAll(true);
    Statement = new toSGAStatement(splitter);

    connect(Trace, SIGNAL(selectionChanged()),
            this, SLOT(changeItem()));
    CurrentSchema = connection.user().toUpper();
    updateSchemas();

    try
    {
        connect(timer(), SIGNAL(timeout(void)), this, SLOT(refresh(void)));
        toRefreshParse(timer(), toConfigurationSingle::Instance().refresh());
    }
    TOCATCH;

    setFocusProxy(Trace);
}
Exemplo n.º 5
0
RMainWnd::RMainWnd(reditor::REditor* edit) : QMainWindow(), medit(edit)
{
    setWindowTitle(tr("Room Editor"));
    setWindowIcon(QIcon(":/resources/favicon.ico"));
    
    // central widget
    meditWnd = new REditWnd(medit->objects(), medit->camera(), this);
    setCentralWidget(meditWnd);
    
    // set corners for docks
    setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
    setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
    setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
    setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
    
    // docks
    mloggerDock = new QDockWidget(this);
    mloggerDock->setWindowTitle(tr("Editor Log"));
    mlogger = new RLogger(mloggerDock);
    mloggerDock->setWidget(mlogger);
    addDockWidget(Qt::BottomDockWidgetArea, mloggerDock);
    // TODO attach dock window with objects on the scene
    
    // File menu
    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    QAction* newAction = fileMenu->addAction(tr("&New Project"), this, SIGNAL(newProject()), QKeySequence::New);
    newAction->setIcon(QIcon(":/resources/new.png"));
    QAction* openAction = fileMenu->addAction(tr("&Open Project.."), this, SIGNAL(openProject()), QKeySequence::Open);
    openAction->setIcon(QIcon(":/resources/open.png"));
    fileMenu->addSeparator();
    msaveAction = fileMenu->addAction(tr("&Save Project"), this, SIGNAL(saveProject()), QKeySequence::Save);
    msaveAction->setIcon(QIcon(":/resources/save.png"));
    msaveAsAction = fileMenu->addAction(tr("S&ave Project As..."), this, SIGNAL(saveProjectAs()), Qt::SHIFT + Qt::CTRL + Qt::Key_S);
    msaveAsAction->setIcon(QIcon(":/resources/saveAs.png"));
    enableSave(false); // activate after user makes some changes, no sense to save empty project
    fileMenu->addSeparator();
    fileMenu->addAction(tr("&Exit.."), this, SLOT(close()), QKeySequence::Quit);
    
    // Help menu
    QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(tr("&About RoomEdit"), this, SIGNAL(helpAbout()));
    
    // File toolbar
    QToolBar* fileToolBar = addToolBar(tr("File"));
    fileToolBar->addAction(newAction);
    fileToolBar->addAction(openAction);
    fileToolBar->addSeparator();
    fileToolBar->addAction(msaveAction);
    fileToolBar->addAction(msaveAsAction);
    
    // Camera view toolbar
    QToolBar* cameraToolBar = addToolBar(tr("Camera"));
    mcameraGroup = new QButtonGroup(cameraToolBar);
    QPushButton * cam1 = new QPushButton(QString("1"), this);
    QPushButton * cam2 = new QPushButton(QString("2"), this);
    QPushButton * cam3 = new QPushButton(QString("3"), this);
    cam1->setCheckable(true);
    cam2->setCheckable(true);
    cam3->setCheckable(true);
    cam1->setChecked(true);
    mcameraGroup->addButton(cam1, 1);
    mcameraGroup->addButton(cam2, 2);
    mcameraGroup->addButton(cam3, 3);
    mcameraGroup->setExclusive(true);
    connect(mcameraGroup, SIGNAL(buttonClicked(int)), this, SIGNAL(switchCamera(int)));
    cameraToolBar->addWidget(cam1);
    cameraToolBar->addWidget(cam2);
    cameraToolBar->addWidget(cam3);
}
Exemplo n.º 6
0
Window::Window(QWidget* parent):
    QMainWindow(parent)
{
    setObjectName("PlanetScannerWindow");

    QToolBar* toolbar = new QToolBar(this);
    toolbar->setIconSize(QSize(24, 24));
    toolbar->setFloatable(false);
    toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
    addToolBar(toolbar);

    QAction* refreshAction = toolbar->addAction(QIcon(":/icons/refresh.png"), "Refresh");
    connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshPlanets()));
    QAction* settingsAction = toolbar->addAction(QIcon(":/icons/settings.png"), "Settings");
    connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));

    planetTreeView = new QTreeView(this);
    planetTreeView->setMinimumHeight(10);
    planetTreeModel = new PlanetTreeModel(planetTreeView);
    planetTreeProxyModel = new PlanetTreeSortFilterProxyModel(planetTreeModel);
    planetTreeProxyModel->setSourceModel(planetTreeModel);
    planetTreeView->setModel(planetTreeProxyModel);
    planetTreeModel->setHorizontalHeaderLabels(QStringList() << "Hostname" << "Map" << "Gametype" << "Players" << "Address");
    planetTreeView->setSortingEnabled(true);
    planetTreeView->sortByColumn(0, Qt::AscendingOrder);
    planetTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
    planetTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
    connect(planetTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));

    QAction* connectAction = new QAction("Connect", planetTreeView);
    QAction* connectAsSpectatorAction = new QAction("Connect as spectator", planetTreeView);
    QAction* copyAction = new QAction("Copy", planetTreeView);
    QAction* openProfileAction = new QAction("Open profile in a browser", planetTreeView);
    connect(connectAction, SIGNAL(triggered()), this, SLOT(connectSelected()));
    connect(connectAsSpectatorAction, SIGNAL(triggered()), this, SLOT(connectAsSpectatorSelected()));
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copySelected()));
    connect(openProfileAction, &QAction::triggered, this, &Window::openProfileSelected);
    gameContextMenu = new QMenu(planetTreeView);
    planetContextMenu = new QMenu(planetTreeView);
    registeredPlayerContextMenu = new QMenu(planetTreeView);
    unregisteredPlayerContextMenu = new QMenu(planetTreeView);
    gameContextMenu->addActions(QList<QAction*>() << connectAction << connectAsSpectatorAction << copyAction);
    planetContextMenu->addActions(QList<QAction*>() << copyAction);
    registeredPlayerContextMenu->addActions(QList<QAction*>() << openProfileAction << copyAction);
    unregisteredPlayerContextMenu->addActions(QList<QAction*>() << copyAction);

    setCentralWidget(planetTreeView);

    game = new QProcess(this);

    statistics = new StatisticsWebSite(this);
    connect(statistics, &StatisticsWebSite::playersInfoRecieved, this, &Window::processStatisticsPlayers);

    autoRefreshTimer = new QTimer(this);
    connect(autoRefreshTimer, SIGNAL(timeout()), this, SLOT(refreshPlanets()));

    contextMenuShown = false;

    Settings& settings = Settings::getInstance();
    connect(&settings, &Settings::dataChanged, this, &Window::applyChangedSettings);
    settings.load();
    applyChangedSettings();

    ::Settings::loadWindow(this);

    refreshPlanets();
}
Exemplo n.º 7
0
CShaderEditor::CShaderEditor( CApplication& app, CAssetShader& shader ) :
    QDockWidget( "Shader Editor", &app.GetMainFrame() ),
	m_IconTable( (const char** ) ShaderEditor_xpm )
{
	setAttribute(Qt::WA_DeleteOnClose);

	UInt32 border = 4;
    m_App = &app;
	m_Shader = NULL;

	m_Frame = new QWidget( this );

	QAction* action = NULL;
	QToolBar*	toolBar = new QToolBar( m_Frame );
	action = toolBar->addAction( m_IconTable.GetIcon( 0 ), "Open" );
	connect( action, SIGNAL( triggered() ), this, SLOT( OnUIOpen() ) );
	action = toolBar->addAction( m_IconTable.GetIcon( 1 ), "Save" );
	connect( action, SIGNAL( triggered() ), this, SLOT( OnUISave() ) );
	toolBar->addSeparator();
	action = toolBar->addAction( m_IconTable.GetIcon( 2 ), "Undo" );
	connect( action, SIGNAL( triggered() ), this, SLOT( OnUIUndo() ) );
	action = toolBar->addAction( m_IconTable.GetIcon( 3 ), "Redo" );
	connect( action, SIGNAL( triggered() ), this, SLOT( OnUIRedo() ) );
    toolBar->addSeparator();
    action = toolBar->addAction( m_IconTable.GetIcon( 4 ), "Compile" );
    connect( action, SIGNAL( triggered() ), this, SLOT( OnUICompile() ) );

	m_TextEdit[nShaderProgramType_Vertex] = new QTextEdit( m_Frame);
	m_TextEdit[nShaderProgramType_Vertex]->setUndoRedoEnabled( TRUE );
	m_TextEdit[nShaderProgramType_Vertex]->setTabStopWidth( QFontMetrics( m_TextEdit[nShaderProgramType_Vertex]->currentFont( ) ).width(' ') * 4 );
    CShaderEditorSyntaxHighlighter* highlighterVertex = new CShaderEditorSyntaxHighlighter(m_TextEdit[nShaderProgramType_Vertex]->document());

    m_TextEdit[nShaderProgramType_Pixel] = new QTextEdit( m_Frame);
    m_TextEdit[nShaderProgramType_Pixel]->setUndoRedoEnabled( TRUE );
    m_TextEdit[nShaderProgramType_Pixel]->setTabStopWidth( QFontMetrics( m_TextEdit[nShaderProgramType_Pixel]->currentFont( ) ).width(' ') * 4 );
    CShaderEditorSyntaxHighlighter* highlighterPixel = new CShaderEditorSyntaxHighlighter(m_TextEdit[nShaderProgramType_Pixel]->document());

    m_TextEdit[nShaderProgramType_Geometry] = new QTextEdit( m_Frame);
    m_TextEdit[nShaderProgramType_Geometry]->setUndoRedoEnabled( TRUE );
    m_TextEdit[nShaderProgramType_Geometry]->setTabStopWidth( QFontMetrics( m_TextEdit[nShaderProgramType_Geometry]->currentFont( ) ).width(' ') * 4 );
    CShaderEditorSyntaxHighlighter* highlighterGeometry = new CShaderEditorSyntaxHighlighter(m_TextEdit[nShaderProgramType_Geometry]->document());

    m_TabWidget = new QTabWidget( m_Frame );
    m_TabWidget->addTab( m_TextEdit[nShaderProgramType_Vertex], "Vertex Program" );
    m_TabWidget->addTab( m_TextEdit[nShaderProgramType_Pixel], "Pixel Program" );
    m_TabWidget->addTab( m_TextEdit[nShaderProgramType_Geometry], "Geometry Program" );

    m_CurrentProgramEdited = nShaderProgramType_Vertex;

    connect( m_TabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( OnUITabChanged( int ) ) );

	m_LogWindow = new QListWidget( m_Frame );
    m_LogWindow->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    connect( m_LogWindow, SIGNAL( itemDoubleClicked ( QListWidgetItem*) ), this, SLOT( OnUISelectError( QListWidgetItem* ) ) );

	QSplitter* splitter = new QSplitter( Qt::Vertical, m_Frame );
	splitter->addWidget( m_TabWidget );
	splitter->addWidget( m_LogWindow );
	splitter->setStretchFactor( 0, 4 );
	splitter->setStretchFactor( 1, 1 );
	QVBoxLayout *layout = new QVBoxLayout( m_Frame );

	layout->addWidget( toolBar );
	layout->addWidget( splitter );

	layout->setContentsMargins( 0, 0, 0, 0 );
	m_Frame->setLayout( layout );      // use the sizer for layout

	setWidget( m_Frame );
	resize( QSize( 800, 600 ) );

	SetShader( shader );
}
Exemplo n.º 8
0
void tst_QToolBar::actionGeometry()
{
    QToolBar tb;

    QAction action1(0);
    QAction action2(0);
    QAction action3(0);
    QAction action4(0);

    tb.addAction(&action1);
    tb.addAction(&action2);
    tb.addAction(&action3);
    tb.addAction(&action4);

    tb.show();
    QVERIFY(QTest::qWaitForWindowExposed(&tb));

    QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();

    QRect rect01;
    QRect rect02;
    QRect rect03;
    QRect rect04;
    QMenu *popupMenu = 0;

    if (extensions.size() != 0)
    {
        QToolBarExtension *extension = extensions.at(0);
        if (extension->isVisible()) {
            QRect rect0 = extension->geometry();
            QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 );
            QApplication::processEvents();
            popupMenu = qobject_cast<QMenu *>(extension->menu());
            rect01 = popupMenu->actionGeometry(&action1);
            rect02 = popupMenu->actionGeometry(&action2);
            rect03 = popupMenu->actionGeometry(&action3);
            rect04 = popupMenu->actionGeometry(&action4);
        }
    }

    QRect rect1 = tb.actionGeometry(&action1);
    QRect rect2 = tb.actionGeometry(&action2);
    QRect rect3 = tb.actionGeometry(&action3);
    QRect rect4 = tb.actionGeometry(&action4);

    QVERIFY(rect1.isValid());
    QVERIFY(!rect1.isNull());
    QVERIFY(!rect1.isEmpty());

    QVERIFY(rect2.isValid());
    QVERIFY(!rect2.isNull());
    QVERIFY(!rect2.isEmpty());

    QVERIFY(rect3.isValid());
    QVERIFY(!rect3.isNull());
    QVERIFY(!rect3.isEmpty());

    QVERIFY(rect4.isValid());
    QVERIFY(!rect4.isNull());
    QVERIFY(!rect4.isEmpty());

    if (rect01.isValid())
        QCOMPARE(popupMenu->actionAt(rect01.center()), &action1);
    else
        QCOMPARE(tb.actionAt(rect1.center()), &action1);

    if (rect02.isValid())
        QCOMPARE(popupMenu->actionAt(rect02.center()), &action2);
    else
        QCOMPARE(tb.actionAt(rect2.center()), &action2);

    if (rect03.isValid())
        QCOMPARE(popupMenu->actionAt(rect03.center()), &action3);
    else
        QCOMPARE(tb.actionAt(rect3.center()), &action3);

    if (rect04.isValid())
        QCOMPARE(popupMenu->actionAt(rect04.center()), &action4);
    else
        QCOMPARE(tb.actionAt(rect4.center()), &action4);
}
Exemplo n.º 9
0
void tst_QToolBar::actionTriggered()
{
    QToolBar tb;
    connect(&tb, SIGNAL(actionTriggered(QAction*)), SLOT(slot(QAction*)));

    QAction action1(0);
    QAction action2(0);
    QAction action3(0);
    QAction action4(0);

    tb.addAction(&action1);
    tb.addAction(&action2);
    tb.addAction(&action3);
    tb.addAction(&action4);

    tb.show();
    QVERIFY(QTest::qWaitForWindowExposed(&tb));

    QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();

    QRect rect01;
    QRect rect02;
    QRect rect03;
    QRect rect04;
    QMenu *popupMenu = 0;

    if (extensions.size() != 0)
    {
        QToolBarExtension *extension = extensions.at(0);
        if (extension->isVisible()) {
            QRect rect0 = extension->geometry();
            QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 );
            QApplication::processEvents();
            popupMenu = qobject_cast<QMenu *>(extension->menu());
            rect01 = popupMenu->actionGeometry(&action1);
            rect02 = popupMenu->actionGeometry(&action2);
            rect03 = popupMenu->actionGeometry(&action3);
            rect04 = popupMenu->actionGeometry(&action4);
        }
    }

    QRect rect1 = tb.actionGeometry(&action1);
    QRect rect2 = tb.actionGeometry(&action2);
    QRect rect3 = tb.actionGeometry(&action3);
    QRect rect4 = tb.actionGeometry(&action4);

    QAbstractButton *button1 = 0;
    QAbstractButton *button2 = 0;
    QAbstractButton *button3 = 0;
    QAbstractButton *button4 = 0;

    if (!rect01.isValid()) {
        button1 = qobject_cast<QAbstractButton *>(tb.childAt(rect1.center()));
        QVERIFY(button1 != 0);
    }
    if (!rect02.isValid()) {
        button2 = qobject_cast<QAbstractButton *>(tb.childAt(rect2.center()));
        QVERIFY(button2 != 0);
    }
    if (!rect03.isValid()) {
        button3 = qobject_cast<QAbstractButton *>(tb.childAt(rect3.center()));
        QVERIFY(button3 != 0);
    }
    if (!rect04.isValid()) {
        button4 = qobject_cast<QAbstractButton *>(tb.childAt(rect4.center()));
        QVERIFY(button4 != 0);
    }

    ::triggered = 0;
    if (!rect01.isValid())
        QTest::mouseClick(button1, Qt::LeftButton);
    else
        QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect01.center(), -1 );
    QCOMPARE(::triggered, &action1);

    ::triggered = 0;
    if (!rect02.isValid())
        QTest::mouseClick(button2, Qt::LeftButton);
    else
        QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect02.center(), -1 );
    QCOMPARE(::triggered, &action2);

    ::triggered = 0;
    if (!rect03.isValid())
        QTest::mouseClick(button3, Qt::LeftButton);
    else
        QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect03.center(), -1 );
    QCOMPARE(::triggered, &action3);

    ::triggered = 0;
    if (!rect04.isValid())
        QTest::mouseClick(button4, Qt::LeftButton);
    else
        QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect04.center(), -1 );
    QCOMPARE(::triggered, &action4);
}
Exemplo n.º 10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    // Setup this MainWindow with the parameters mainwindow.ui:
    // Definition of size, creation of widgets inside etc..
    ui->setupUi(this);

    // Retrieve pointers of widgets already created by the up operation
    // Those who will be used again outside the creator are saved at class variables
    QMenuBar * menuBar = ui->menuBar;
    QSlider *slider_color = ui->verticalSlider;
    QSlider *slider_style = ui->verticalSlider_2;
    QToolBar * toolbar = ui->toolBar;
    mydrawzone = ui->widget;

    // Declaration of menus and adition inside menubar
    QMenu * openMenu = menuBar->addMenu( tr("&Open"));
    QMenu * saveMenu = menuBar->addMenu( tr("&Save"));
    QMenu * quitMenu = menuBar->addMenu( tr("&Quit"));
    QMenu * penMenu = menuBar->addMenu( tr("&Pen Settings"));
    QMenu * colorMenu = menuBar->addMenu( tr("&Color Settings"));
    QMenu * styleMenu = menuBar->addMenu( tr("&Style Settings"));
    QMenu * formMenu = menuBar->addMenu( tr("&Form Settings"));

    // Declaration of principal actions
    // Those that will be shown at the toolbar
    QAction * openAction = new QAction( QIcon(":/icons/open.png"), tr("&Open"), this);
    QAction * saveAction = new QAction( QIcon(":/icons/save.png"), tr("&Save"), this);
    QAction * quitAction = new QAction( QIcon(":/icons/quit.png"), tr("&Quit"), this);
    QAction * paintAction = new QAction( QIcon(":/icons/paint.png"), tr("&Paint"), this);
    QAction * editAction = new QAction( QIcon(":/icons/edit.png"), tr("&Edit"), this);
    QAction * moveAction = new QAction( QIcon(":/icons/move.png"), tr("&Edit"), this);

    // Declaration of some other actions
    // Those that will have shortcuts as well but wont be shown in the toolbar
    QAction *set_pen_color =new QAction(tr("Alternate Color Pen"), this);
    QAction *set_pen_width_larger =new QAction(tr("&Pen Width +"), this);
    QAction *set_pen_width_shorter =new QAction(tr("&Pen Width -"), this);
    QAction *set_pen_style =new QAction(tr("&Alternate Style Pen"), this);
    QAction *set_figure_form =new QAction(tr("&Alternate Figure Form"), this);
    QAction *undo =new QAction(tr("&Undo"), this);

    // Declaration of action groups
    // The pointers for the actions are saved inside class variables
    // to be used outside the class creator
    QActionGroup *action_group_color = new QActionGroup(this);
    color0 = action_group_color->addAction(tr("Black Pen"));
    color1 = action_group_color->addAction(tr("White Pen"));
    color2 = action_group_color->addAction(tr("Dark Gray Pen"));
    color3 = action_group_color->addAction(tr("Gray Pen"));
    color4 = action_group_color->addAction(tr("Light Gray Pen"));
    color5 = action_group_color->addAction(tr("Red Pen"));
    color6 = action_group_color->addAction(tr("Green Pen"));
    color7 = action_group_color->addAction(tr("Blue Pen"));
    color8 = action_group_color->addAction(tr("Cyan Pen"));
    color9 = action_group_color->addAction(tr("Magenta Pen"));
    color10 = action_group_color->addAction(tr("Yellow Pen"));
    color11 = action_group_color->addAction(tr("Dark Red Pen"));
    color12 = action_group_color->addAction(tr("Dark Green Pen"));
    color13 = action_group_color->addAction(tr("Dark Blue Pen"));
    color14 = action_group_color->addAction(tr("Dark Cyan Pen"));
    color15 = action_group_color->addAction(tr("Dark Magenta Pen"));
    color16 = action_group_color->addAction(tr("Dark Yellow Pen"));
    color17 = action_group_color->addAction(tr("Transparent"));

    QActionGroup *action_group_style = new QActionGroup(this);
    style0 = action_group_style->addAction(tr("Solid Pen"));
    style1 = action_group_style->addAction(tr("Dash Line Pen"));
    style2 = action_group_style->addAction(tr("Dot Line Pen"));
    style3 = action_group_style->addAction(tr("Dash dot Line Pen"));
    style4 = action_group_style->addAction(tr("Dash Dot Dot Line Pen"));
    style5 = action_group_style->addAction(tr("Custom Dash Line Pen"));

    QActionGroup *action_group_form = new QActionGroup(this);
    form0 = action_group_form->addAction(tr("Line Form"));
    form1 = action_group_form->addAction(tr("Rectangle Form"));
    form2 = action_group_form->addAction(tr("Elipse Form"));

    // Adition of shortcuts for principal actions
    openAction->setShortcut( tr("Ctrl+O"));
    saveAction->setShortcut( tr("Ctrl+S"));
    quitAction->setShortcut( tr("Ctrl+Q"));
    paintAction->setShortcut( tr("Ctrl+P"));
    editAction->setShortcut( tr("Ctrl+E"));
    moveAction->setShortcut( tr("Ctrl+M"));

    // Adition of shortcuts for those other actions
    set_pen_color->setShortcut( tr("Ctrl+C"));
    set_pen_style->setShortcut( tr("Ctrl+Space"));
    set_pen_width_larger->setShortcut( tr("Ctrl++"));
    set_pen_width_shorter->setShortcut( tr("Ctrl+-"));
    set_figure_form->setShortcut( tr("Ctrl+F"));
    undo->setShortcut(tr ("Ctrl+Z"));

    // Adition of tool tips for principal actions
    openAction->setToolTip( tr("Open file"));
    saveAction->setToolTip( tr("Save file"));
    quitAction->setToolTip( tr("Quit file"));

    // Adition of status tips for principal actions
    openAction->setStatusTip( tr("Open file"));
    saveAction->setStatusTip( tr("Save file"));
    quitAction->setStatusTip( tr("Quit file"));

    // Adition of actions to menus
    openMenu->addAction(openAction);
    saveMenu->addAction(saveAction);
    quitMenu->addAction(quitAction);

    penMenu->addAction(set_pen_width_larger);
    penMenu->addAction(set_pen_width_shorter);
    penMenu->addAction(undo);

    colorMenu->addAction(set_pen_color);
    colorMenu->addActions(action_group_color->actions());

    styleMenu->addAction(set_pen_style);
    styleMenu->addActions(action_group_style->actions());

    formMenu->addAction(set_figure_form);
    formMenu->addActions(action_group_form->actions());

    // Adition of principal actions to toolbar
    toolbar->addAction(openAction);
    toolbar->addAction(saveAction);
    toolbar->addAction(quitAction);
    toolbar->addAction(paintAction);
    toolbar->addAction(editAction);
    toolbar->addAction(moveAction);

    // Set some parameters to the sliders
    slider_color->setTickPosition(QSlider::TicksBothSides);
    slider_color->setMinimum(0);
    slider_color->setMaximum(17);
    slider_color->setSingleStep(1);

    slider_style->setTickPosition(QSlider::TicksBothSides);
    slider_style->setMinimum(0);
    slider_style->setMaximum(5);
    slider_style->setSingleStep(1);

    // Link actions and signals to slots
    connect(openAction, SIGNAL(triggered( )), this, SLOT(openFile()));
    connect(saveAction, SIGNAL(triggered( )), this, SLOT(saveFile()));
    connect(quitAction, SIGNAL(triggered( )), this, SLOT(quitApp()));

    connect(paintAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_paint()));
    connect(editAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_edit()));
    connect(moveAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_move()));
    connect(set_pen_width_larger, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_larger()));
    connect(set_pen_width_shorter, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_shorter()));
    connect(undo, SIGNAL(triggered( )), mydrawzone, SLOT(undo()));

    connect(set_pen_color, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_color()));
    connect(action_group_color, SIGNAL(triggered(QAction *)), this, SLOT(doIt(QAction *)));
    connect(this, SIGNAL(color_pen_changed(int)), mydrawzone, SLOT(set_pen_color(int)));

    connect(set_pen_style, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_style()));
    connect(action_group_style, SIGNAL(triggered(QAction *)), this, SLOT(doIt2(QAction *)));
    connect(this, SIGNAL(style_pen_changed(int)), mydrawzone, SLOT(set_pen_style(int)));

    connect(set_figure_form, SIGNAL(triggered( )), mydrawzone, SLOT(set_figure_form()));
    connect(action_group_form, SIGNAL(triggered(QAction *)), this, SLOT(doIt3(QAction *)));
    connect(this, SIGNAL(form_painter_changed(int)), mydrawzone, SLOT(set_figure_form(int)));

    connect(slider_color, SIGNAL(valueChanged(int)), this, SLOT(slide_color_pen_changed(int)));
    connect(slider_style, SIGNAL(valueChanged(int)), this, SLOT(slide_style_pen_changed(int)));
}
Exemplo n.º 11
0
WndSets::WndSets(QWidget *parent)
    : QMainWindow(parent)
{
    // left toolbar
    QToolBar *setsEditToolBar = new QToolBar;
    setsEditToolBar->setOrientation(Qt::Vertical);
    setsEditToolBar->setIconSize(QSize(24, 24));
    setsEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    aTop = new QAction(QString(), this);
    aTop->setIcon(QIcon("theme:icons/arrow_top_green.svg"));
    aTop->setToolTip(tr("Move selected set to the top"));
    aTop->setEnabled(false);
    connect(aTop, SIGNAL(triggered()), this, SLOT(actTop()));
    setsEditToolBar->addAction(aTop);

    aUp = new QAction(QString(), this);
    aUp->setIcon(QIcon("theme:icons/arrow_up_green.svg"));
    aUp->setToolTip(tr("Move selected set up"));
    aUp->setEnabled(false);
    connect(aUp, SIGNAL(triggered()), this, SLOT(actUp()));
    setsEditToolBar->addAction(aUp);

    aDown = new QAction(QString(), this);
    aDown->setIcon(QIcon("theme:icons/arrow_down_green.svg"));
    aDown->setToolTip(tr("Move selected set down"));
    aDown->setEnabled(false);
    connect(aDown, SIGNAL(triggered()), this, SLOT(actDown()));
    setsEditToolBar->addAction(aDown);

    aBottom = new QAction(QString(), this);
    aBottom->setIcon(QIcon("theme:icons/arrow_bottom_green.svg"));
    aBottom->setToolTip(tr("Move selected set to the bottom"));
    aBottom->setEnabled(false);
    connect(aBottom, SIGNAL(triggered()), this, SLOT(actBottom()));
    setsEditToolBar->addAction(aBottom);

    // view 
    model = new SetsModel(db, this);
    view = new QTreeView;
    view->setModel(model);

    view->setAlternatingRowColors(true);
    view->setUniformRowHeights(true);
    view->setAllColumnsShowFocus(true);
    view->setSortingEnabled(true);
    view->setSelectionMode(QAbstractItemView::SingleSelection);
    view->setSelectionBehavior(QAbstractItemView::SelectRows);

    view->setDragEnabled(true);
    view->setAcceptDrops(true);
    view->setDropIndicatorShown(true);
    view->setDragDropMode(QAbstractItemView::InternalMove);

#if QT_VERSION < 0x050000
    view->header()->setResizeMode(QHeaderView::Stretch);
    view->header()->setResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents);
#else
    view->header()->setSectionResizeMode(QHeaderView::Stretch);
    view->header()->setSectionResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents);
#endif

    view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder);
    view->setColumnHidden(SetsModel::SortKeyCol, true);
    view->setColumnHidden(SetsModel::IsKnownCol, true);
    view->setRootIsDecorated(false);

    connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
        this, SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &)));

    // bottom buttons
    enableAllButton = new QPushButton(tr("Enable all sets"));
    connect(enableAllButton, SIGNAL(clicked()), this, SLOT(actEnableAll()));
    disableAllButton = new QPushButton(tr("Disable all sets"));
    connect(disableAllButton, SIGNAL(clicked()), this, SLOT(actDisableAll()));


    QLabel *labNotes = new QLabel;
    labNotes->setText("<b>" + tr("hints:") + "</b>" + "<ul><li>" + tr("Enable the sets that you want to have available in the deck editor") + "</li><li>" + tr("Move sets around to change their order, or click on a column header to sort sets on that field") + "</li><li>" + tr("Sets order decides the source that will be used when loading images for a specific card") + "</li><li>" + tr("Disabled sets will be used for loading images only if all the enabled sets failed") + "</li></ul>");

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(actRestore()));

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(setsEditToolBar, 0, 0, 1, 1);
    mainLayout->addWidget(view, 0, 1, 1, 2);
    mainLayout->addWidget(enableAllButton, 1, 1, 1, 1);
    mainLayout->addWidget(disableAllButton, 1, 2, 1, 1);
    mainLayout->addWidget(labNotes, 2, 1, 1, 2);
    mainLayout->addWidget(buttonBox, 3, 1, 1, 2);
    mainLayout->setColumnStretch(1, 1);
    mainLayout->setColumnStretch(2, 1);

    QWidget *centralWidget = new QWidget;
    centralWidget->setLayout(mainLayout);
    setCentralWidget(centralWidget);

    setWindowTitle(tr("Edit sets"));
    resize(700, 400);
}
Exemplo n.º 12
0
FenPrincipale::FenPrincipale()
{	
	showMaximized();
	//showNormal();

	QMenu *menuFichier = menuBar()->addMenu("&Fichier");

	QAction *actionLoadImage = menuFichier->addAction("&Load Image");	
	actionLoadImage->setIcon(QIcon("Icons/fileopen.png"));
	menuFichier->addAction(actionLoadImage);

	QAction *actionExit = menuFichier->addAction("&Quitter");
	actionExit->setIcon(QIcon("Icons/fileclose.png"));
	menuFichier->addAction(actionExit);

	//QMenu *menuTools = menuBar()->addMenu("&Tools");

	QMenu *menuComm = menuBar()->addMenu("&Communication");

	QAction *actionSend = menuComm->addAction("&Send to server");	
	actionSend->setIcon(QIcon("Icons/ok.png"));

	// Création de la barre d'outils

    QToolBar *toolBarFichier = addToolBar("Fichier");
    toolBarFichier->addAction(actionLoadImage);
	toolBarFichier->addAction(actionExit);
	toolBarFichier->addSeparator();
	toolBarFichier->addAction(actionSend);
	
	QObject::connect(actionLoadImage, SIGNAL(triggered()), this, SLOT(LoadImageW()));
    QObject::connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
    QObject::connect(actionSend, SIGNAL(triggered()), this, SLOT(SendServer()));
	QObject::connect(actionSend, SIGNAL(triggered()), this, SLOT(ShowResults()));
    
	//
	// Création des docks
	//

	// dock IMAGE

	dockImage = new QDockWidget("Image", this);
	setCentralWidget(dockImage);

	ImageWidget = new QWidget;
	dockImage->setWidget(ImageWidget);

	// dock SERVEUR

	dockServeur = new QDockWidget("Serveur", this);
	addDockWidget(Qt::LeftDockWidgetArea, dockServeur);


	QWidget *paramDock = new QWidget;
	dockServeur->setWidget(paramDock);

	QSize s(220,20);

	adressServer1 = new QLineEdit(QString("138.195.102.25"));
	adressServer1->setMaximumSize(s);

	QHBoxLayout *adressLayout = new QHBoxLayout;
	adressLayout->addWidget(adressServer1);

	QWidget *adressWidget = new QWidget;
	adressWidget->setLayout(adressLayout);

	portAdressServer = new QLineEdit(QString("6006"));
	portAdressServer->setMaximumSize(s);

	QHBoxLayout *portLayout = new QHBoxLayout;
	portLayout->addWidget(portAdressServer);

	QWidget *portAdressWidget = new QWidget;
	portAdressWidget->setLayout(portLayout);

	QLabel *adressLabel = new QLabel("Adresse IP",paramDock);
	QLabel *portLabel = new QLabel("Port",paramDock);

	QPushButton *okServer = new QPushButton("Send");
	QObject::connect(okServer, SIGNAL(clicked()),this,SLOT(SendServer()));
	QObject::connect(okServer, SIGNAL(clicked()),this,SLOT(ShowResults()));

	QVBoxLayout *paramLayout = new QVBoxLayout(paramDock);
	paramLayout->addWidget(adressLabel);
	paramLayout->addWidget(adressWidget);
	paramLayout->addWidget(portLabel);
	paramLayout->addWidget(portAdressWidget);
	paramLayout->addWidget(okServer);
	paramLayout->setAlignment(Qt::AlignLeft);
	paramDock->setLayout(paramLayout);
	//dockServeur->setGeometry(QRect(100,200,200,250));
	dockServeur->setMaximumSize(250,200);

	// dock RESULTATS

	dockResults = new QDockWidget("Resultats",this);
	addDockWidget(Qt::RightDockWidgetArea, dockResults);
	dockResults->setMaximumWidth(250);

	WidgetResults = new QWidget;
	scrollArea = new QScrollArea;

	dockResults->setWidget(scrollArea);


	

	QPixmap *mini = new QPixmap(QString("test.jpg"));
	Result R(mini,98,"t");
	QPixmap *mini2 = new QPixmap(QString("9143.gif.jpg"));
	Result R2(mini2,95,"v");
	QPixmap *mini3 = new QPixmap(QString("test.jpg"));
	Result R3(mini3,92,"t");
	QPixmap *mini4 = new QPixmap(QString("test.jpg"));
	Result R4(mini4,90,"t");
	QPixmap *mini5 = new QPixmap(QString("test.jpg"));
	Result R5(mini5,88,"t");
	QPixmap *mini6 = new QPixmap(QString("test.jpg"));
	Result R6(mini6,86,"t");
	QPixmap *mini7 = new QPixmap(QString("test.jpg"));
	Result R7(mini7,84,"t");
	QPixmap *mini8 = new QPixmap(QString("test.jpg"));
	Result R8(mini8,82,"t");
	QPixmap *mini9 = new QPixmap(QString("test.jpg"));
	Result R9(mini9,81,"t");
	QPixmap *mini10 = new QPixmap(QString("test.jpg"));
	Result R10(mini10,79,"t");
	QPixmap *mini11 = new QPixmap(QString("test.jpg"));
	Result R11(mini11,78,"t");
	QPixmap *mini12 = new QPixmap(QString("test.jpg"));
	Result R12(mini12,77,"t");
	QPixmap *mini13 = new QPixmap(QString("test.jpg"));
	Result R13(mini13,76,"t");
	QPixmap *mini14 = new QPixmap(QString("test.jpg"));
	Result R14(mini14,75,"t");

	T.push_back(R);
	T.push_back(R2);
	T.push_back(R3);
	T.push_back(R4);
	T.push_back(R5);
	T.push_back(R6);
	T.push_back(R7);
	T.push_back(R8);
	T.push_back(R9);
	T.push_back(R10);
	T.push_back(R11);
	T.push_back(R12);
	T.push_back(R13);
	T.push_back(R14);

}
Exemplo n.º 13
0
//COSTRUTTORE
videoplayer::videoplayer(QWidget *parent)
{
	stoptick = false;

	signalMapper = new QSignalMapper(this);

	createMenu();	

    //includendo gli oggetti menu, bottoni e frame video in QVBoxLayout che li ordina verticalmente
    QVBoxLayout *mainLayout = new QVBoxLayout;

    mainLayout->setMenuBar(menuBar);

    // creo il display LDC e la barra di scorrimento video

    // LCD
    QPalette palette;
    palette.setBrush(QPalette::Light, Qt::darkGray);

	//timerLCD = new QTimer(this);
    panelLCD = new QLCDNumber;
    panelLCD->setPalette(palette);

    //------------------------------------------------------------------
    //qui devo gestire l'lcd con il video
	//impongo che ogni secondo venga refreshato il pannello
	//connect(timerLCD, &QTimer::timeout, this, &videoplayer::tick);
    //-------------------------------------------------------------------

    //Barra di scorrimento
    positionSlider = new QSlider(Qt::Horizontal);

    //Inglobo la barra e LCD in un contenitore che li mette io orizzontale
    QHBoxLayout *seekerLayout = new QHBoxLayout;
    seekerLayout->addWidget(positionSlider);
    seekerLayout->addWidget(panelLCD);
    //aggiungo il contenitore alla finestra principale
    mainLayout->addLayout(seekerLayout);

    //Ora mi occupo dei pulsati
    playAction = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), tr("Play"), this);
    playAction->setShortcut(tr("Ctrl+P"));
    playAction->setDisabled(true);
    pauseAction = new QAction(style()->standardIcon(QStyle::SP_MediaPause), tr("Pause"), this);
    pauseAction->setShortcut(tr("Ctrl+A"));
    pauseAction->setDisabled(true);
    stopAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop), tr("Stop"), this);
    stopAction->setShortcut(tr("Ctrl+S"));
    stopAction->setDisabled(true);
	skipforwardAction = new QAction(style()->standardIcon(QStyle::SP_MediaSkipForward), tr("SkipForward"), this);
    skipforwardAction->setShortcut(tr("Ctrl+S+F"));
    skipforwardAction->setDisabled(true);
	skipbackwardAction = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), tr("SkipBackward"), this);
    skipbackwardAction->setShortcut(tr("Ctrl+S+B"));
    skipbackwardAction->setDisabled(true);
	seekforwardAction = new QAction(style()->standardIcon(QStyle::SP_MediaSeekForward), tr("SeekForward"), this);
    seekforwardAction->setShortcut(tr("Ctrl+F"));
    seekforwardAction->setDisabled(true);
	seekbackwardAction = new QAction(style()->standardIcon(QStyle::SP_MediaSeekBackward), tr("SeekBackward"), this);
    seekbackwardAction->setShortcut(tr("Ctrl+B"));
    seekbackwardAction->setDisabled(true);

	histoAction = new QAction(QIcon(":/images/histogram2.png"), tr("histo"), this);
	logAction = new QAction(QIcon(":/images/log.png"), tr("log"), this);

	histoAction->setDisabled(true);
	logAction->setDisabled(true);


	//event listener dei pulsanti
	connect(playAction, &QAction::triggered, this, &videoplayer::resume);
	connect(this, &videoplayer::first_play, this, &videoplayer::playing);
	connect(pauseAction, &QAction::triggered, this, &videoplayer::pause);
	connect(histoAction, &QAction::triggered, this, &videoplayer::histoClicked);
	connect(logAction, &QAction::triggered, this, &videoplayer::openDialog);

	/**
	utilizzo di un signalMapper per collegare l'evento di pressione dei pulsanti SEEK,
	con un particolare valore che verra inviato allo SLOT seek
	*/
	signalMapper->setMapping(seekforwardAction, 10);
	signalMapper->setMapping(seekbackwardAction, -10);
	signalMapper->setMapping(skipbackwardAction, -60);
	signalMapper->setMapping(skipforwardAction, 60);

	connect(skipforwardAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
	connect(seekforwardAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
	connect(skipbackwardAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
	connect(seekbackwardAction, SIGNAL(triggered()), signalMapper, SLOT(map()));

	connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(seek(int)));

    QToolBar *bar = new QToolBar;
    bar->addAction(playAction);
    bar->addAction(pauseAction);
    bar->addAction(stopAction);
	bar->addAction(skipbackwardAction);
	bar->addAction(seekbackwardAction);
	bar->addAction(seekforwardAction);
	bar->addAction(skipforwardAction);
	bar->addAction(histoAction);
	bar->addAction(logAction);

    QLabel *volumeLabel = new QLabel;
    volumeLabel->setPixmap(QPixmap(":/images/volume.png"));

    volumeSlider = new QSlider(Qt::Horizontal);
    volumeSlider->setRange(0,100);
    volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    //aggiungo i bottoni alla finestra principale
    QHBoxLayout *controlButton = new QHBoxLayout;
    controlButton->addWidget(bar);
    controlButton->addStretch();
    //controlButton->addWidget(volumeLabel);
    //controlButton->addWidget(volumeSlider);
    //controlButton->addSpacing(0);// questa serve per spostare il volume a destra e di quanto dal bordo
    mainLayout->addLayout(controlButton);


    setLayout(mainLayout);

    // setto il titolo del finestra
    setWindowTitle(tr("VideoPlayer"));

    setFixedSize(400,100);

	_clock = new AVClock();										//inizializzazione del clock

	//connect sullo SLIDER
	connect(_clock, &AVClock::needupdate, this, &videoplayer::tick);
	connect(positionSlider, &QSlider::sliderReleased, this, &videoplayer::slider_seek);
	connect(positionSlider, &QSlider::sliderPressed, this, &videoplayer::stop_tick);
}
Exemplo n.º 14
0
MapTool::MapTool(ToolManager *toolManager)
    : Tool(toolManager)
    ,
    //		keepRatio_(true),
    //		lastX_(0.0),
    //		lastY_(0.0),
    //		lastWidth_(100.0),
    //		lastHeight_(100.0),
    active_(false)
{
    // Connect //
    //
    connect(this, SIGNAL(toolAction(ToolAction *)), toolManager, SLOT(toolActionSlot(ToolAction *)));

    QLabel *opacityLabel = new QLabel(" Opacity: ");

    opacityComboBox_ = new QComboBox();
    QStringList opacities;
    opacities << tr("100%") << tr("90%") << tr("80%") << tr("70%") << tr("60%") << tr("50%") << tr("40%") << tr("30%") << tr("20%") << tr("10%");
    opacityComboBox_->addItems(opacities);
    opacityComboBox_->setCurrentIndex(0);
    opacityComboBox_->setStatusTip(tr("Set Map Opacity."));
    opacityComboBox_->setToolTip(tr("Set Map Opacity"));
    connect(opacityComboBox_, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOpacity(QString)));

    loadMapAction_ = new QAction(tr("Load &Map"), this);
    loadMapAction_->setStatusTip(tr("Load a background image."));
    connect(loadMapAction_, SIGNAL(triggered()), this, SLOT(loadMap()));

    deleteMapAction_ = new QAction(tr("&Delete Map"), this);
    deleteMapAction_->setStatusTip(tr("Delete the selected background images."));
    connect(deleteMapAction_, SIGNAL(triggered()), this, SLOT(deleteMap()));

    lockMapAction_ = new QAction(tr("&Lock Maps"), this);
    lockMapAction_->setStatusTip(tr("Toggle locking of the maps."));
    lockMapAction_->setCheckable(true);
    lockMapAction_->setChecked(true);
    connect(lockMapAction_, SIGNAL(triggered(bool)), this, SLOT(lockMap(bool)));

    //	QLabel * xLabel = new QLabel(" x: ");
    //	xLineEdit_ = new QDoubleSpinBox();
    //	xLineEdit_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    //	xLineEdit_->setRange(-1000000.0, 1000000.0);
    //	xLineEdit_->setValue(lastX_);
    //	xLineEdit_->setMinimumWidth(100);
    //	xLineEdit_->setMaximumWidth(100);
    //	connect(xLineEdit_, SIGNAL(editingFinished()), this, SLOT(setX()));

    //	QLabel * yLabel = new QLabel(" y: ");
    //	yLineEdit_ = new QDoubleSpinBox();
    //	yLineEdit_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    //	yLineEdit_->setRange(-1000000.0, 1000000.0);
    //	yLineEdit_->setValue(lastY_);
    //	yLineEdit_->setMinimumWidth(100);
    //	yLineEdit_->setMaximumWidth(100);
    //	connect(yLineEdit_, SIGNAL(editingFinished()), this, SLOT(setY()));

    //	QLabel * wLabel = new QLabel(" w: ");
    //	widthLineEdit_ = new QDoubleSpinBox();
    //	widthLineEdit_->setRange(1.0, 1000000.0);
    //	widthLineEdit_->setValue(lastWidth_);
    //	widthLineEdit_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    //	widthLineEdit_->setMinimumWidth(100);
    //	widthLineEdit_->setMaximumWidth(100);
    //	connect(widthLineEdit_, SIGNAL(editingFinished()), this, SLOT(setWidth()));

    //	QLabel * hLabel = new QLabel(" h: ");
    //	heightLineEdit_ = new QDoubleSpinBox();
    //	heightLineEdit_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    //	heightLineEdit_->setRange(1.0, 1000000.0);
    //	heightLineEdit_->setValue(lastHeight_);
    //	heightLineEdit_->setMinimumWidth(100);
    //	heightLineEdit_->setMaximumWidth(100);
    //	connect(heightLineEdit_, SIGNAL(editingFinished()), this, SLOT(setHeight()));

    // Deactivate if no project //
    //
    connect(ODD::instance()->mainWindow(), SIGNAL(hasActiveProject(bool)), this, SLOT(activateProject(bool)));

    // ToolBar //
    //
    QToolBar *mapToolBar = new QToolBar(tr("Map"));
    mapToolBar->addWidget(opacityLabel);
    mapToolBar->addWidget(opacityComboBox_);
    mapToolBar->addAction(loadMapAction_);
    mapToolBar->addAction(deleteMapAction_);
    mapToolBar->addAction(lockMapAction_);
    //	mapToolBar->addWidget(xLabel);
    //	mapToolBar->addWidget(xLineEdit_);
    //	mapToolBar->addWidget(yLabel);
    //	mapToolBar->addWidget(yLineEdit_);
    //	mapToolBar->addWidget(wLabel);
    //	mapToolBar->addWidget(widthLineEdit_);
    //	mapToolBar->addWidget(hLabel);
    //	mapToolBar->addWidget(heightLineEdit_);

    // ToolManager //
    //
    ODD::instance()->mainWindow()->addToolBar(mapToolBar);

    // View Menu //
    //
    QMenu *viewMenu = ODD::instance()->mainWindow()->getViewMenu();

    QMenu *mapMenu = new QMenu("Background Images", viewMenu);
    mapMenu->addAction(loadMapAction_);
    mapMenu->addAction(deleteMapAction_);
    mapMenu->addAction(lockMapAction_);

    viewMenu->addSeparator();
    viewMenu->addMenu(mapMenu);
}
Exemplo n.º 15
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);
  //inifontsize
  actionTextDump = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")),
                               tr("&Dump"), this);
  connect(actionTextDump, SIGNAL(triggered()), this, SLOT(dividePages()));
  tb->addAction(actionTextDump);
//  menu->addAction(actionTextDump);

  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(16, 16);
  pix.fill(Qt::black);
  actionTextColor = new QAction(pix, tr("&Color..."), this);
  connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor()));
  tb->addAction(actionTextColor);
//  menu->addAction(actionTextColor);


  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())));
  comboPn = new QComboBox(tb);
  comboPn->setObjectName("comboPn");
  tb->addWidget(comboPn);
  comboPn->setEditable(true);

  QFontDatabase db;
  for(int size=1;size<=docs.size();size++)
    comboPn->addItem(QString::number(size));

  connect(comboPn, SIGNAL(activated(QString)),
          this, SLOT(pageChanged(QString)));
  //comboPn->setCurrentIndex(1);
}
Exemplo n.º 16
0
void QucsHelp::setupActions()
{
  QToolBar *toolbar = new QToolBar("main_toolbar",this);

  this->addToolBar(toolbar);

  const QKeySequence ks = QKeySequence();

  QAction *quitAction = new QAction(QIcon((":/bitmaps/quit.png")),
                                    tr("&Quit"), this);
    quitAction->setShortcut((const QKeySequence&)Qt::CTRL+Qt::Key_Q);
    
  QAction *backAction = new QAction(QIcon((":/bitmaps/back.png")),
                                    tr("&Back"), this);
    backAction->setShortcut( Qt::ALT+Qt::Key_Left);
 
    
  QAction *forwardAction = new QAction(QIcon((":/bitmaps/forward.png")),
                                       tr("&Forward"),  this);
   forwardAction->setShortcut(Qt::ALT+Qt::Key_Right);
    
  QAction *homeAction = new QAction(QIcon((":/bitmaps/home.png")),
                                    tr("&Home"),this);
   homeAction->setShortcut(Qt::CTRL+Qt::Key_H);
    
  previousAction = new QAction(QIcon((":/bitmaps/previous.png")),tr("&Previous"),
                               this);
   previousAction->setShortcut( ks);
    
  nextAction = new QAction(QIcon((":/bitmaps/next.png")),
                           tr("&Next"), this);
   nextAction->setShortcut( ks);
    
  viewBrowseDock = new QAction(tr("&Table of Contents"), this);
    
  viewBrowseDock->setCheckable(true);
  viewBrowseDock->setChecked(true);
  viewBrowseDock->setStatusTip(tr("Enables/disables the table of contents"));
  viewBrowseDock->setWhatsThis(tr("Table of Contents\n\nEnables/disables the table of contents"));

  connect(quitAction,SIGNAL(activated()),qApp,SLOT(quit()));

  connect(backAction,SIGNAL(activated()),textBrowser,SLOT(backward()));
  connect(textBrowser,SIGNAL(backwardAvailable(bool)),backAction,SLOT(setEnabled(bool)));

  connect(forwardAction,SIGNAL(activated()),textBrowser,SLOT(forward()));
  connect(textBrowser,SIGNAL(forwardAvailable(bool)),forwardAction,SLOT(setEnabled(bool)));

  connect(homeAction,SIGNAL(activated()),textBrowser,SLOT(home()));
  connect(homeAction,SIGNAL(activated()),this,SLOT(gohome()));

  connect(textBrowser,SIGNAL(sourceChanged(const QUrl &)),this,SLOT(slotSourceChanged(const QUrl &)));
  connect(previousAction,SIGNAL(activated()),this,SLOT(previousLink()));
  connect(nextAction,SIGNAL(activated()),this,SLOT(nextLink()));
  connect(viewBrowseDock, SIGNAL(toggled(bool)), SLOT(slotToggleSidebar(bool)));

  toolbar->addAction(backAction);
  toolbar->addAction(forwardAction);
  toolbar->addSeparator();
  toolbar->addAction(homeAction);
  toolbar->addAction(previousAction);
  toolbar->addAction(nextAction);
  toolbar->addSeparator();
  toolbar->addAction(quitAction);

  QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
  fileMenu->addAction(quitAction);
  fileMenu->addAction(quitAction);

  QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
  viewMenu->addAction(backAction);
  viewMenu->addAction(forwardAction);
  viewMenu->addAction(homeAction);
  viewMenu->addAction(previousAction);
  viewMenu->addAction(nextAction);
  viewMenu->addSeparator();
  viewMenu->addAction(viewBrowseDock);

  QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
  helpMenu->addAction(tr("&About Qt"),qApp,SLOT(aboutQt()));
}
Exemplo n.º 17
0
MessagesSettingsPage::MessagesSettingsPage()
{
    chatMentionCheckBox.setChecked(settingsCache->getChatMention());
    connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));

    chatMentionCompleterCheckbox.setChecked(settingsCache->getChatMentionCompleter());
    connect(&chatMentionCompleterCheckbox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMentionCompleter(int)));
    
    ignoreUnregUsersMainChat.setChecked(settingsCache->getIgnoreUnregisteredUsers());
    ignoreUnregUserMessages.setChecked(settingsCache->getIgnoreUnregisteredUserMessages());
    connect(&ignoreUnregUsersMainChat, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUsers(int)));
    connect(&ignoreUnregUserMessages, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUserMessages(int)));
    
    invertMentionForeground.setChecked(settingsCache->getChatMentionForeground());
    connect(&invertMentionForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextColor(int)));

    invertHighlightForeground.setChecked(settingsCache->getChatHighlightForeground());
    connect(&invertHighlightForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextHighlightColor(int)));

    mentionColor = new QLineEdit();
    mentionColor->setText(settingsCache->getChatMentionColor());
    updateMentionPreview();
    connect(mentionColor, SIGNAL(textChanged(QString)), this, SLOT(updateColor(QString)));

    messagePopups.setChecked(settingsCache->getShowMessagePopup());
    connect(&messagePopups, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowMessagePopups(int)));

    mentionPopups.setChecked(settingsCache->getShowMentionPopup());
    connect(&mentionPopups, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowMentionPopups(int)));

    roomHistory.setChecked(settingsCache->getRoomHistory());
    connect(&roomHistory, SIGNAL(stateChanged(int)), settingsCache, SLOT(setRoomHistory(int)));

    customAlertString = new QLineEdit();
    customAlertString->setPlaceholderText("Word1 Word2 Word3");
    customAlertString->setText(settingsCache->getHighlightWords());
    connect(customAlertString, SIGNAL(textChanged(QString)), settingsCache, SLOT(setHighlightWords(QString)));

    QGridLayout *chatGrid = new QGridLayout;
    chatGrid->addWidget(&chatMentionCheckBox, 0, 0);
    chatGrid->addWidget(&invertMentionForeground, 0, 1);
    chatGrid->addWidget(mentionColor, 0, 2);
    chatGrid->addWidget(&chatMentionCompleterCheckbox, 1, 0);
    chatGrid->addWidget(&ignoreUnregUsersMainChat, 2, 0);
    chatGrid->addWidget(&hexLabel, 1, 2);
    chatGrid->addWidget(&ignoreUnregUserMessages, 3, 0);
    chatGrid->addWidget(&messagePopups, 4, 0);
    chatGrid->addWidget(&mentionPopups, 5, 0);
    chatGrid->addWidget(&roomHistory, 6, 0);
    chatGroupBox = new QGroupBox;
    chatGroupBox->setLayout(chatGrid);
    
    highlightColor = new QLineEdit();
    highlightColor->setText(settingsCache->getChatHighlightColor());
    updateHighlightPreview();
    connect(highlightColor, SIGNAL(textChanged(QString)), this, SLOT(updateHighlightColor(QString)));

    QGridLayout *highlightNotice = new QGridLayout;
    highlightNotice->addWidget(highlightColor, 0, 2);
    highlightNotice->addWidget(&invertHighlightForeground, 0, 1);
    highlightNotice->addWidget(&hexHighlightLabel, 1, 2);
    highlightNotice->addWidget(customAlertString, 0, 0);
    highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
    highlightGroupBox = new QGroupBox;
    highlightGroupBox->setLayout(highlightNotice);

    messageList = new QListWidget;

    int count = settingsCache->messages().getCount();
    for (int i = 0; i < count; i++)
        messageList->addItem(settingsCache->messages().getMessageAt(i));
    
    aAdd = new QAction(this);
    aAdd->setIcon(QPixmap("theme:icons/increment"));
    connect(aAdd, SIGNAL(triggered()), this, SLOT(actAdd()));
    aRemove = new QAction(this);
    aRemove->setIcon(QPixmap("theme:icons/decrement"));
    connect(aRemove, SIGNAL(triggered()), this, SLOT(actRemove()));

    QToolBar *messageToolBar = new QToolBar;
    messageToolBar->setOrientation(Qt::Vertical);
    messageToolBar->addAction(aAdd);
    messageToolBar->addAction(aRemove);

    QHBoxLayout *messageListLayout = new QHBoxLayout;
    messageListLayout->addWidget(messageToolBar);
    messageListLayout->addWidget(messageList);

    messageShortcuts = new QGroupBox;
    messageShortcuts->setLayout(messageListLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;

    mainLayout->addWidget(messageShortcuts);
    mainLayout->addWidget(chatGroupBox);
    mainLayout->addWidget(highlightGroupBox);

    setLayout(mainLayout);
    
    retranslateUi();
}
Exemplo n.º 18
0
ConfigDialog::ConfigDialog(QDir _home, Zones *_zones, Context *context) :
    home(_home), zones(_zones), context(context)
{
    setAttribute(Qt::WA_DeleteOnClose);

#ifdef Q_OS_MAC
    QToolBar *head = addToolBar(tr("Preferences"));
    setMinimumSize(600,540);
    setUnifiedTitleAndToolBarOnMac(true);
    head->setFloatable(false);
    head->setMovable(false);
#else
    QToolBar *head = addToolBar(tr("Options"));
    head->setMovable(false); // oops!

    QFont defaultFont;
    setMinimumSize(60 * defaultFont.pointSize(),580);   //Change for 53 to 60 - To be decided if also Size for Q_OS_MAC need change
#endif

    // center
    QWidget *spacer = new QWidget(this);
    spacer->setAutoFillBackground(false);
    spacer->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    head->addWidget(spacer);

    // icons
    static QIcon generalIcon(QPixmap(":images/toolbar/GeneralPreferences.png"));
    static QIcon athleteIcon(QPixmap(":/images/toolbar/user.png"));
    static QIcon passwordIcon(QPixmap(":/images/toolbar/passwords.png"));
    static QIcon appearanceIcon(QPixmap(":/images/toolbar/color.png"));
    static QIcon dataIcon(QPixmap(":/images/toolbar/data.png"));
    static QIcon metricsIcon(QPixmap(":/images/toolbar/abacus.png"));
    static QIcon devicesIcon(QPixmap(":/images/devices/kickr.png"));

    // Setup the signal mapping so the right config
    // widget is displayed when the icon is clicked
    QSignalMapper *iconMapper = new QSignalMapper(this); // maps each option
    connect(iconMapper, SIGNAL(mapped(int)), this, SLOT(changePage(int)));
    head->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

    QAction *added;

    // General settings
    added = head->addAction(generalIcon, tr("General"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 0);

    added =head->addAction(athleteIcon, tr("Athlete"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 1);

    added =head->addAction(passwordIcon, tr("Passwords"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 2);

    added =head->addAction(appearanceIcon, tr("Appearance"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 3);

    added =head->addAction(dataIcon, tr("Data Fields"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 4);

    added =head->addAction(metricsIcon, tr("Metrics"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 5);

    added =head->addAction(devicesIcon, tr("Train Devices"));
    connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
    iconMapper->setMapping(added, 6);

    // more space
    spacer = new QWidget(this);
    spacer->setAutoFillBackground(false);
    spacer->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    head->addWidget(spacer);


    pagesWidget = new QStackedWidget(this);

    // create those config pages
    general = new GeneralConfig(_home, _zones, context);
    pagesWidget->addWidget(general);

    athlete = new AthleteConfig(_home, _zones, context);
    pagesWidget->addWidget(athlete);

    password = new PasswordConfig(_home, _zones, context);
    pagesWidget->addWidget(password);

    appearance = new AppearanceConfig(_home, _zones, context);
    pagesWidget->addWidget(appearance);

    data = new DataConfig(_home, _zones, context);
    pagesWidget->addWidget(data);

    metric = new MetricConfig(_home, _zones, context);
    pagesWidget->addWidget(metric);

    device = new DeviceConfig(_home, _zones, context);
    pagesWidget->addWidget(device);


    closeButton = new QPushButton(tr("Close"));
    saveButton = new QPushButton(tr("Save"));

    QHBoxLayout *horizontalLayout = new QHBoxLayout;
    horizontalLayout->addWidget(pagesWidget, 1);

    QHBoxLayout *buttonsLayout = new QHBoxLayout;
    buttonsLayout->addStretch();
    buttonsLayout->setSpacing(5);
    buttonsLayout->addWidget(closeButton);
    buttonsLayout->addWidget(saveButton);

    QWidget *contents = new QWidget(this);
    setCentralWidget(contents);
    contents->setContentsMargins(0,0,0,0);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(horizontalLayout);
    mainLayout->addStretch();
    mainLayout->addLayout(buttonsLayout);
    mainLayout->setSpacing(0);
    contents->setLayout(mainLayout);

    // We go fixed width to ensure a consistent layout for
    // tabs, sub-tabs and internal widgets and lists
#ifdef Q_OS_MACX
    setWindowTitle(tr("Preferences"));
#else
    setWindowTitle(tr("Options"));
#endif

    connect(closeButton, SIGNAL(clicked()), this, SLOT(closeClicked()));
    connect(saveButton, SIGNAL(clicked()), this, SLOT(saveClicked()));
}
Exemplo n.º 19
0
PQTextEditor::PQTextEditor(QWidget* parent):
    QMainWindow(parent)
{
    QWidget *centralWidget = new QWidget(this);
    mLayout = new QGridLayout(centralWidget);
    centralWidget->setLayout(mLayout);

    setCentralWidget(centralWidget);

    mEditor = new QTextEdit(this);
    mLayout->addWidget(mEditor, 0, 0);
    connect(mEditor, SIGNAL(textChanged()), SIGNAL(textChanged()));

    QAction *action;
    QToolBar *toolbar = addToolBar(tr("Edit Toolbar"));
    addAction(toolbar, QLatin1String("undo"), QLatin1String("edit-undo"), tr("Undo"), false, QKeySequence::Undo, mEditor, SLOT(undo()));
    addAction(toolbar, QLatin1String("redo"), QLatin1String("edit-redo"), tr("Redo"), false, QKeySequence::Redo, mEditor, SLOT(redo()));
    addAction(toolbar, QLatin1String("cut"), QLatin1String("edit-cut"), tr("Cut"),  false,QKeySequence::Cut, mEditor, SLOT(cut()));
    addAction(toolbar, QLatin1String("copy"), QLatin1String("edit-copy"), tr("Copy"),  false,QKeySequence::Copy, mEditor, SLOT(copy()));
    addAction(toolbar, QLatin1String("paste"), QLatin1String("edit-paste"), tr("Paste"),  false,QKeySequence::Paste, mEditor, SLOT(paste()));

    toolbar = addToolBar(tr("Format Toolbar"));
    addAction(toolbar, QLatin1String("bold"), QLatin1String("format-text-bold"), tr("Bold"), true, QKeySequence::Bold, this, SLOT(slotToggleBold()));
    addAction(toolbar, QLatin1String("italic"), QLatin1String("format-text-italic"), tr("Italic"), true, QKeySequence::Italic, this, SLOT(slotToggleItalic()));
    addAction(toolbar, QLatin1String("strikethrough"), QLatin1String("format-text-strikethrough"), tr("Strikethrough"), true, QKeySequence(), this, SLOT(slotToggleStrikethrough()));
    addAction(toolbar, QLatin1String("underline"), QLatin1String("format-text-underline"), tr("Underline"), true, QKeySequence::Underline, this, SLOT(slotToggleUnderline()));
    toolbar->addSeparator();
    QActionGroup *group = new QActionGroup(this);
    group->addAction(addAction(toolbar, QLatin1String("justify-left"), QLatin1String("format-justify-left"), tr("Justify Left"), true, QKeySequence(), this, SLOT(slotJustifyLeft())));
    group->addAction(addAction(toolbar, QLatin1String("justify-center"), QLatin1String("format-justify-center"), tr("Justify Center"), true, QKeySequence(), this, SLOT(slotJustifyCenter())));
    group->addAction(addAction(toolbar, QLatin1String("justify-fill"), QLatin1String("format-justify-fill"), tr("Justify Fill"), true, QKeySequence(), this, SLOT(slotJustifyFill())));
    group->addAction(addAction(toolbar, QLatin1String("justify-right"), QLatin1String("format-justify-right"), tr("Justify Right"), true, QKeySequence(), this, SLOT(slotJustifyRight())));
    toolbar->addSeparator();
    addAction(toolbar, QLatin1String("unindent"), QLatin1String("format-indent-less"), tr("Unindent"), false, QKeySequence(), this, SLOT(slotUnindent()));
    addAction(toolbar, QLatin1String("indent"), QLatin1String("format-indent-more"), tr("Indent"), false, QKeySequence(), this, SLOT(slotIndent()));


    mStyleComboBox = new QComboBox(this);
    mStyleComboBox->addItem(tr("Standard"));
    mStyleComboBox->addItem(tr("Bullet List (Disc)"));
    mStyleComboBox->addItem(tr("Bullet List (Circle)"));
    mStyleComboBox->addItem(tr("Bullet List (Square)"));
    mStyleComboBox->addItem(tr("Ordered List (Decimal)"));
    mStyleComboBox->addItem(tr("Ordered List (Alpha lower)"));
    mStyleComboBox->addItem(tr("Ordered List (Alpha upper)"));
    mStyleComboBox->addItem(tr("Ordered List (Roman lower)"));
    mStyleComboBox->addItem(tr("Ordered List (Roman upper)"));
    connect(mStyleComboBox, SIGNAL(currentIndexChanged(int)), SLOT(slotChangeStyle(int)));

    mFontComboBox = new QFontComboBox(this);
    connect(mFontComboBox, SIGNAL(currentFontChanged(QFont)), SLOT(slotChangeFont(QFont)));

    mFontSizeComboBox = new QComboBox(this);
    QFontDatabase db;
    Q_FOREACH (int size, db.standardSizes()) {
        mFontSizeComboBox->addItem(QString::number(size));
    }
    /* Initialize */
    mFontSizeComboBox->setCurrentIndex(mFontSizeComboBox->findText(QString::number(QApplication::font().pointSize())));
    connect(mFontSizeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(slotChangeFontSize(int)));

    QPixmap pixmap(16, 16);
    pixmap.fill(mEditor->textColor());
    QAction *colorAction = new QAction(pixmap, tr("Color"), this);
    connect(colorAction, SIGNAL(triggered(bool)), SLOT(slotChangeColor()));

    addToolBarBreak();
    toolbar = addToolBar(tr("Font Toolbar"));
    toolbar->addWidget(mStyleComboBox);
    toolbar->addWidget(mFontComboBox);
    toolbar->addWidget(mFontSizeComboBox);
    toolbar->addAction(colorAction);
}
Exemplo n.º 20
0
TextTools::TextTools(QWidget* parent)
   : QDockWidget(parent)
      {
      _textElement = 0;
      setObjectName("text-tools");
      setWindowTitle(tr("Text Tools"));
      setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea));

      QToolBar* tb = new QToolBar(tr("Text Edit"));
      tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight));

      textStyles = new QComboBox;
      tb->addWidget(textStyles);

      showKeyboard = getAction("show-keys");
      showKeyboard->setCheckable(true);
      tb->addAction(showKeyboard);

      typefaceBold = tb->addAction(*icons[textBold_ICON], "");
      typefaceBold->setToolTip(tr("bold"));
      typefaceBold->setCheckable(true);

      typefaceItalic = tb->addAction(*icons[textItalic_ICON], "");
      typefaceItalic->setToolTip(tr("italic"));
      typefaceItalic->setCheckable(true);

      typefaceUnderline = tb->addAction(*icons[textUnderline_ICON], "");
      typefaceUnderline->setToolTip(tr("underline"));
      typefaceUnderline->setCheckable(true);

      tb->addSeparator();

      QActionGroup* ha = new QActionGroup(tb);
      leftAlign   = new QAction(*icons[textLeft_ICON],   "", ha);
      leftAlign->setToolTip(tr("align left"));
      leftAlign->setCheckable(true);
      leftAlign->setData(ALIGN_LEFT);
      hcenterAlign = new QAction(*icons[textCenter_ICON], "", ha);
      hcenterAlign->setToolTip(tr("align horizontal center"));
      hcenterAlign->setCheckable(true);
      hcenterAlign->setData(ALIGN_HCENTER);
      rightAlign  = new QAction(*icons[textRight_ICON],  "", ha);
      rightAlign->setToolTip(tr("align right"));
      rightAlign->setCheckable(true);
      rightAlign->setData(ALIGN_RIGHT);
      tb->addActions(ha->actions());

      QActionGroup* va = new QActionGroup(tb);
      topAlign  = new QAction(*icons[textTop_ICON],  "", va);
      topAlign->setToolTip(tr("align top"));
      topAlign->setCheckable(true);
      topAlign->setData(ALIGN_TOP);

      bottomAlign  = new QAction(*icons[textBottom_ICON],  "", va);
      bottomAlign->setToolTip(tr("align bottom"));
      bottomAlign->setCheckable(true);
      bottomAlign->setData(ALIGN_BOTTOM);

      baselineAlign  = new QAction(*icons[textBaseline_ICON],  "", va);
      baselineAlign->setToolTip(tr("align vertical baseline"));
      baselineAlign->setCheckable(true);
      baselineAlign->setData(ALIGN_BASELINE);

      vcenterAlign  = new QAction(*icons[textVCenter_ICON],  "", va);
      vcenterAlign->setToolTip(tr("align vertical center"));
      vcenterAlign->setCheckable(true);
      vcenterAlign->setData(ALIGN_VCENTER);
      tb->addActions(va->actions());

      typefaceSubscript   = tb->addAction(*icons[textSub_ICON], "");
      typefaceSubscript->setToolTip(tr("subscript"));
      typefaceSubscript->setCheckable(true);

      typefaceSuperscript = tb->addAction(*icons[textSuper_ICON], "");
      typefaceSuperscript->setToolTip(tr("superscript"));
      typefaceSuperscript->setCheckable(true);

      unorderedList = tb->addAction(*icons[formatListUnordered_ICON], "");
      unorderedList->setToolTip(tr("unordered list"));

      orderedList = tb->addAction(*icons[formatListOrdered_ICON], "");
      orderedList->setToolTip(tr("ordered list"));

      indentMore = tb->addAction(*icons[formatIndentMore_ICON], "");
      indentMore->setToolTip(tr("indent more"));

      indentLess = tb->addAction(*icons[formatIndentLess_ICON], "");
      indentLess->setToolTip(tr("indent less"));

      tb->addSeparator();

      typefaceFamily = new QFontComboBox(this);
      tb->addWidget(typefaceFamily);
      typefaceSize = new QDoubleSpinBox(this);
      tb->addWidget(typefaceSize);

      setWidget(tb);
      QWidget* w = new QWidget(this);
      setTitleBarWidget(w);
      titleBarWidget()->hide();

      connect(typefaceSize,        SIGNAL(valueChanged(double)), SLOT(sizeChanged(double)));
      connect(typefaceFamily,      SIGNAL(currentFontChanged(const QFont&)), SLOT(fontChanged(const QFont&)));
      connect(typefaceBold,        SIGNAL(triggered(bool)), SLOT(boldClicked(bool)));
      connect(typefaceItalic,      SIGNAL(triggered(bool)), SLOT(italicClicked(bool)));
      connect(typefaceUnderline,   SIGNAL(triggered(bool)), SLOT(underlineClicked(bool)));
      connect(typefaceSubscript,   SIGNAL(triggered(bool)), SLOT(subscriptClicked(bool)));
      connect(typefaceSuperscript, SIGNAL(triggered(bool)), SLOT(superscriptClicked(bool)));
      connect(typefaceFamily,      SIGNAL(currentFontChanged(const QFont&)), SLOT(fontChanged(const QFont&)));
      connect(ha,                  SIGNAL(triggered(QAction*)), SLOT(setHalign(QAction*)));
      connect(va,                  SIGNAL(triggered(QAction*)), SLOT(setValign(QAction*)));
      connect(showKeyboard,        SIGNAL(triggered(bool)), SLOT(showKeyboardClicked(bool)));
      connect(textStyles,          SIGNAL(currentIndexChanged(int)), SLOT(styleChanged(int)));
      connect(unorderedList,       SIGNAL(triggered()),     SLOT(unorderedListClicked()));
      connect(orderedList,         SIGNAL(triggered()),     SLOT(orderedListClicked()));
      connect(indentLess,          SIGNAL(triggered()),     SLOT(indentLessClicked()));
      connect(indentMore,          SIGNAL(triggered()),     SLOT(indentMoreClicked()));
      }
Exemplo n.º 21
0
DlgEditTokens::DlgEditTokens(CardDatabaseModel *_cardDatabaseModel, QWidget *parent)
    : QDialog(parent), currentCard(0), cardDatabaseModel(_cardDatabaseModel)
{
    nameLabel = new QLabel(tr("&Name:"));
    nameEdit = new QLineEdit;
    nameEdit->setEnabled(false);
    nameLabel->setBuddy(nameEdit);
    
    colorLabel = new QLabel(tr("C&olor:"));
    colorEdit = new QComboBox;
    colorEdit->addItem(tr("white"), "w");
    colorEdit->addItem(tr("blue"), "u");
    colorEdit->addItem(tr("black"), "b");
    colorEdit->addItem(tr("red"), "r");
    colorEdit->addItem(tr("green"), "g");
    colorEdit->addItem(tr("multicolor"), "m");
    colorEdit->addItem(tr("colorless"), QString());
    colorLabel->setBuddy(colorEdit);
    connect(colorEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(colorChanged(int)));
    
    ptLabel = new QLabel(tr("&P/T:"));
    ptEdit = new QLineEdit;
    ptLabel->setBuddy(ptEdit);
    connect(ptEdit, SIGNAL(textChanged(QString)), this, SLOT(ptChanged(QString)));
    
    annotationLabel = new QLabel(tr("&Annotation:"));
    annotationEdit = new QLineEdit;
    annotationLabel->setBuddy(annotationEdit);
    connect(annotationEdit, SIGNAL(textChanged(QString)), this, SLOT(annotationChanged(QString)));
    
    QGridLayout *grid = new QGridLayout;
    grid->addWidget(nameLabel, 0, 0);
    grid->addWidget(nameEdit, 0, 1);
    grid->addWidget(colorLabel, 1, 0);
    grid->addWidget(colorEdit, 1, 1);
    grid->addWidget(ptLabel, 2, 0);
    grid->addWidget(ptEdit, 2, 1);
    grid->addWidget(annotationLabel, 3, 0);
    grid->addWidget(annotationEdit, 3, 1);
    
    QGroupBox *tokenDataGroupBox = new QGroupBox(tr("Token data"));
    tokenDataGroupBox->setLayout(grid);
    
    cardDatabaseDisplayModel = new CardDatabaseDisplayModel(this);
    cardDatabaseDisplayModel->setSourceModel(cardDatabaseModel);
    cardDatabaseDisplayModel->setIsToken(CardDatabaseDisplayModel::ShowTrue);
    
    chooseTokenView = new QTreeView;
    chooseTokenView->setModel(cardDatabaseDisplayModel);
    chooseTokenView->setUniformRowHeights(true);
    chooseTokenView->setRootIsDecorated(false);
    chooseTokenView->setAlternatingRowColors(true);
    chooseTokenView->setSortingEnabled(true);
    chooseTokenView->sortByColumn(0, Qt::AscendingOrder);
    chooseTokenView->resizeColumnToContents(0);
    chooseTokenView->header()->setStretchLastSection(false);
    chooseTokenView->header()->hideSection(1);
    chooseTokenView->header()->hideSection(2);
    chooseTokenView->header()->setResizeMode(3, QHeaderView::ResizeToContents);
    chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents);
    connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex)));
    
    QAction *aAddToken = new QAction(tr("Add token"), this);
    aAddToken->setIcon(QIcon(":/resources/increment.svg"));
    connect(aAddToken, SIGNAL(triggered()), this, SLOT(actAddToken()));
    QAction *aRemoveToken = new QAction(tr("Remove token"), this);
    aRemoveToken->setIcon(QIcon(":/resources/decrement.svg"));
    connect(aRemoveToken, SIGNAL(triggered()), this, SLOT(actRemoveToken()));
    
    QToolBar *databaseToolBar = new QToolBar;
    databaseToolBar->addAction(aAddToken);
    databaseToolBar->addAction(aRemoveToken);
    
    QVBoxLayout *leftVBox = new QVBoxLayout;
    leftVBox->addWidget(chooseTokenView);
    leftVBox->addWidget(databaseToolBar);
    
    QHBoxLayout *hbox = new QHBoxLayout;
    hbox->addLayout(leftVBox);
    hbox->addWidget(tokenDataGroupBox);
    
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(hbox);
    mainLayout->addWidget(buttonBox);

    setLayout(mainLayout);
    setWindowTitle(tr("Edit tokens"));
}
Exemplo n.º 22
0
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
    : Tab(_tabSupervisor, parent), modified(false)
{
    aClearSearch = new QAction(QString(), this);
    aClearSearch->setIcon(QIcon(":/resources/icon_clearsearch.svg"));
    connect(aClearSearch, SIGNAL(triggered()), this, SLOT(actClearSearch()));

    searchLabel = new QLabel();
    searchEdit = new SearchLineEdit;
    searchLabel->setBuddy(searchEdit);
    setFocusProxy(searchEdit);
    setFocusPolicy(Qt::ClickFocus);

    searchEdit->installEventFilter(&searchKeySignals);
    connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
    connect(&searchKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard()));
    connect(&searchKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actAddCard()));
    connect(&searchKeySignals, SIGNAL(onCtrlAltRBracket()), this, SLOT(actAddCardToSideboard()));
    connect(&searchKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrementCard()));
    connect(&searchKeySignals, SIGNAL(onCtrlAltLBracket()), this, SLOT(actDecrementCardFromSideboard()));
    connect(&searchKeySignals, SIGNAL(onCtrlAltEnter()), this, SLOT(actAddCardToSideboard()));
    connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard()));

    QToolBar *deckEditToolBar = new QToolBar;
    deckEditToolBar->setOrientation(Qt::Horizontal);
    deckEditToolBar->setIconSize(QSize(24, 24));

    QHBoxLayout *searchLayout = new QHBoxLayout;
    searchLayout->addWidget(deckEditToolBar);
    searchLayout->addWidget(searchLabel);
    searchLayout->addWidget(searchEdit);

    databaseModel = new CardDatabaseModel(db, this);
    databaseDisplayModel = new CardDatabaseDisplayModel(this);
    databaseDisplayModel->setSourceModel(databaseModel);
    databaseDisplayModel->setFilterKeyColumn(0);
    databaseDisplayModel->sort(0, Qt::AscendingOrder);

    databaseView = new QTreeView();
    databaseView->setFocusProxy(searchEdit);
    databaseView->setModel(databaseDisplayModel);
    databaseView->setUniformRowHeights(true);
    databaseView->setRootIsDecorated(false);
    databaseView->setAlternatingRowColors(true);
    databaseView->setSortingEnabled(true);
    databaseView->sortByColumn(0, Qt::AscendingOrder);
    databaseView->resizeColumnToContents(0);
    connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &)));
    connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard()));
    searchEdit->setTreeView(databaseView);

    QVBoxLayout *leftFrame = new QVBoxLayout;
    leftFrame->addLayout(searchLayout);
    leftFrame->addWidget(databaseView);

    cardInfo = new CardFrame(250, 356);
    aCardTextOnly = new QAction(QString(), this);
    aCardTextOnly->setCheckable(true);
    connect(aCardTextOnly, SIGNAL(triggered()), cardInfo, SLOT(toggleCardTextOnly()));

    filterModel = new FilterTreeModel();
    databaseDisplayModel->setFilterTree(filterModel->filterTree());
    filterView = new QTreeView;
    filterView->setModel(filterModel);
    filterView->setMaximumWidth(250);
    filterView->setUniformRowHeights(true);
    filterView->setHeaderHidden(true);
    filterView->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(filterModel, SIGNAL(layoutChanged()), filterView, SLOT(expandAll()));
    connect(filterView, SIGNAL(customContextMenuRequested(const QPoint &)),
            this, SLOT(filterViewCustomContextMenu(const QPoint &)));
    FilterBuilder *filterBuilder = new FilterBuilder;
    filterBuilder->setMaximumWidth(250);
    connect(filterBuilder, SIGNAL(add(const CardFilter *)), filterModel, SLOT(addFilter(const CardFilter *)));

    QVBoxLayout *filter = new QVBoxLayout;
    filter->addWidget(filterBuilder, 0, Qt::AlignTop);
    filter->addWidget(filterView, 10);

    QVBoxLayout *middleFrame = new QVBoxLayout;
    middleFrame->addWidget(cardInfo, 0, Qt::AlignTop);
    middleFrame->addLayout(filter, 10);

    deckModel = new DeckListModel(this);
    connect(deckModel, SIGNAL(deckHashChanged()), this, SLOT(updateHash()));
    deckView = new QTreeView();
    deckView->setModel(deckModel);
    deckView->setUniformRowHeights(true);
    deckView->setSortingEnabled(true);
    deckView->sortByColumn(1, Qt::AscendingOrder);
#if QT_VERSION < 0x050000
    deckView->header()->setResizeMode(QHeaderView::ResizeToContents);
#else
    deckView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
    deckView->installEventFilter(&deckViewKeySignals);
    connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &)));
    connect(&deckViewKeySignals, SIGNAL(onEnter()), this, SLOT(actIncrement()));
    connect(&deckViewKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actIncrement()));
    connect(&deckViewKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrement()));
    connect(&deckViewKeySignals, SIGNAL(onRight()), this, SLOT(actIncrement()));
    connect(&deckViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrement()));
    connect(&deckViewKeySignals, SIGNAL(onDelete()), this, SLOT(actRemoveCard()));

    nameLabel = new QLabel();
    nameEdit = new QLineEdit;
    nameLabel->setBuddy(nameEdit);
    connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateName(const QString &)));
    commentsLabel = new QLabel();
    commentsEdit = new QTextEdit;
    commentsEdit->setMaximumHeight(70);
    commentsLabel->setBuddy(commentsEdit);
    connect(commentsEdit, SIGNAL(textChanged()), this, SLOT(updateComments()));
    hashLabel1 = new QLabel();
    hashLabel = new QLabel;

    QGridLayout *grid = new QGridLayout;
    grid->addWidget(nameLabel, 0, 0);
    grid->addWidget(nameEdit, 0, 1);

    grid->addWidget(commentsLabel, 1, 0);
    grid->addWidget(commentsEdit, 1, 1);

    grid->addWidget(hashLabel1, 2, 0);
    grid->addWidget(hashLabel, 2, 1);

    // Update price
    aUpdatePrices = new QAction(QString(), this);
    aUpdatePrices->setIcon(QIcon(":/resources/icon_update.png"));
    connect(aUpdatePrices, SIGNAL(triggered()), this, SLOT(actUpdatePrices()));
    if (!settingsCache->getPriceTagFeature())
        aUpdatePrices->setVisible(false);
    connect(settingsCache, SIGNAL(priceTagFeatureChanged(int)), this, SLOT(setPriceTagFeatureEnabled(int)));

    QToolBar *deckToolBar = new QToolBar;
    deckToolBar->setOrientation(Qt::Vertical);
    deckToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    deckToolBar->setIconSize(QSize(24, 24));
    deckToolBar->addAction(aUpdatePrices);
    QHBoxLayout *deckToolbarLayout = new QHBoxLayout;
    deckToolbarLayout->addStretch();
    deckToolbarLayout->addWidget(deckToolBar);
    deckToolbarLayout->addStretch();

    QVBoxLayout *rightFrame = new QVBoxLayout;
    rightFrame->addLayout(grid);
    rightFrame->addWidget(deckView, 10);
    rightFrame->addLayout(deckToolbarLayout);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(leftFrame, 10);
    mainLayout->addLayout(middleFrame);
    mainLayout->addLayout(rightFrame);
    setLayout(mainLayout);

    aNewDeck = new QAction(QString(), this);
    aNewDeck->setShortcuts(QKeySequence::New);
    connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck()));
    aLoadDeck = new QAction(QString(), this);
    aLoadDeck->setShortcuts(QKeySequence::Open);
    connect(aLoadDeck, SIGNAL(triggered()), this, SLOT(actLoadDeck()));
    aSaveDeck = new QAction(QString(), this);
    aSaveDeck->setShortcuts(QKeySequence::Save);
    connect(aSaveDeck, SIGNAL(triggered()), this, SLOT(actSaveDeck()));
    aSaveDeckAs = new QAction(QString(), this);
//    aSaveDeckAs->setShortcuts(QKeySequence::SaveAs);
    connect(aSaveDeckAs, SIGNAL(triggered()), this, SLOT(actSaveDeckAs()));
    aLoadDeckFromClipboard = new QAction(QString(), this);
    connect(aLoadDeckFromClipboard, SIGNAL(triggered()), this, SLOT(actLoadDeckFromClipboard()));
    aLoadDeckFromClipboard->setShortcuts(QKeySequence::Paste);
    aSaveDeckToClipboard = new QAction(QString(), this);
    connect(aSaveDeckToClipboard, SIGNAL(triggered()), this, SLOT(actSaveDeckToClipboard()));
    aSaveDeckToClipboard->setShortcuts(QKeySequence::Copy);
    aPrintDeck = new QAction(QString(), this);
    aPrintDeck->setShortcuts(QKeySequence::Print);
    connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck()));
    aAnalyzeDeck = new QAction(QString(), this);
    connect(aAnalyzeDeck, SIGNAL(triggered()), this, SLOT(actAnalyzeDeck()));
    aClose = new QAction(QString(), this);
    connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest()));

    aEditSets = new QAction(QString(), this);
    connect(aEditSets, SIGNAL(triggered()), this, SLOT(actEditSets()));
    aEditTokens = new QAction(QString(), this);
    connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens()));

    deckMenu = new QMenu(this);
    deckMenu->addAction(aNewDeck);
    deckMenu->addAction(aLoadDeck);
    deckMenu->addAction(aSaveDeck);
    deckMenu->addAction(aSaveDeckAs);
    deckMenu->addSeparator();
    deckMenu->addAction(aLoadDeckFromClipboard);
    deckMenu->addAction(aSaveDeckToClipboard);
    deckMenu->addSeparator();
    deckMenu->addAction(aPrintDeck);
    deckMenu->addSeparator();
    deckMenu->addAction(aAnalyzeDeck);
    deckMenu->addSeparator();
    deckMenu->addAction(aClose);
    addTabMenu(deckMenu);

    dbMenu = new QMenu(this);
    dbMenu->addAction(aEditSets);
    dbMenu->addAction(aEditTokens);
    dbMenu->addSeparator();
    dbMenu->addAction(aClearSearch);
    dbMenu->addAction(aCardTextOnly);
    addTabMenu(dbMenu);

    aAddCard = new QAction(QString(), this);
    aAddCard->setIcon(QIcon(":/resources/arrow_right_green.svg"));
    connect(aAddCard, SIGNAL(triggered()), this, SLOT(actAddCard()));
    aAddCardToSideboard = new QAction(QString(), this);
    aAddCardToSideboard->setIcon(QIcon(":/resources/add_to_sideboard.svg"));
    connect(aAddCardToSideboard, SIGNAL(triggered()), this, SLOT(actAddCardToSideboard()));
    aRemoveCard = new QAction(QString(), this);
    aRemoveCard->setIcon(QIcon(":/resources/remove_row.svg"));
    connect(aRemoveCard, SIGNAL(triggered()), this, SLOT(actRemoveCard()));
    aIncrement = new QAction(QString(), this);
    aIncrement->setIcon(QIcon(":/resources/increment.svg"));
    connect(aIncrement, SIGNAL(triggered()), this, SLOT(actIncrement()));
    aDecrement = new QAction(QString(), this);
    aDecrement->setIcon(QIcon(":/resources/decrement.svg"));
    connect(aDecrement, SIGNAL(triggered()), this, SLOT(actDecrement()));

    deckEditToolBar->addAction(aAddCard);
    deckEditToolBar->addAction(aAddCardToSideboard);
    deckEditToolBar->addAction(aRemoveCard);
    deckEditToolBar->addAction(aIncrement);
    deckEditToolBar->addAction(aDecrement);
    deckEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    
    retranslateUi();
    
    resize(950, 700);
}
Exemplo n.º 23
0
MQLEdit::MQLEdit(QWidget* parent, Qt::WindowFlags fl)
    : QWidget(parent, fl)
{
  setupUi(this);

  if (OpenRPT::name.isEmpty())
    OpenRPT::name = tr("MetaSQL Editor");

  _mqlSelector = 0;
  _document = _text->document();
  _document->setDefaultFont(QFont("Courier"));

  connect(_document,     SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
  connect(editFindAction,              SIGNAL(triggered()), this, SLOT(editFind()));
  connect(fileDatabaseConnectAction,   SIGNAL(triggered()), this, SLOT(fileDatabaseConnect()));
  connect(fileDatabaseDisconnectAction,SIGNAL(triggered()), this, SLOT(fileDatabaseDisconnect()));
  connect(fileDatabaseOpenAction,      SIGNAL(triggered()), this, SLOT(fileDatabaseOpen()));
  connect(fileDatabaseSaveAsAction,    SIGNAL(triggered()), this, SLOT(fileDatabaseSaveAs()));
  connect(fileExitAction,              SIGNAL(triggered()), this, SLOT(fileExit()));
  connect(fileNewAction,               SIGNAL(triggered()), this, SLOT(fileNew()));
  connect(fileOpenAction,              SIGNAL(triggered()), this, SLOT(fileOpen()));
  connect(filePrintAction,             SIGNAL(triggered()), this, SLOT(filePrint()));
  connect(fileSaveAction,              SIGNAL(triggered()), this, SLOT(fileSave()));
  connect(fileSaveAsAction,            SIGNAL(triggered()), this, SLOT(fileSaveAs()));
  connect(helpAboutAction,             SIGNAL(triggered()), this, SLOT(helpAbout()));
  connect(helpContentsAction,          SIGNAL(triggered()), this, SLOT(helpContents()));
  connect(helpIndexAction,             SIGNAL(triggered()), this, SLOT(helpIndex()));
  connect(searchForParametersAction,   SIGNAL(triggered()), this, SLOT(populateParameterEdit()));
  connect(toolsExecute_QueryAction,    SIGNAL(triggered()), this, SLOT(execQuery()));
  connect(toolsParse_QueryAction,      SIGNAL(triggered()), this, SLOT(parseQuery()));
  connect(viewExecuted_SQLAction,      SIGNAL(triggered()), this, SLOT(showExecutedSQL()));
  connect(viewLog_OutputAction,        SIGNAL(triggered()), this, SLOT(showLog()));
  connect(viewParameter_ListAction,    SIGNAL(triggered()), this, SLOT(showParamList()));
  connect(viewResultsAction,           SIGNAL(triggered()), this, SLOT(showResults()));

  QSqlDatabase db = QSqlDatabase().database();
  if(db.isValid() && db.isOpen())
    OpenRPT::loggedIn = true;
  else
  {
    OpenRPT::loggedIn = false;
    db = QSqlDatabase();
  }

  if (parent) // then must be embedded
  {
    if (DEBUG)
      qDebug("MQLEdit::MQLEdit(%p) OpenRPT::loggedIn = %d",
             parent, OpenRPT::loggedIn);
    fileDatabaseConnectAction->setVisible(! OpenRPT::loggedIn);
    fileDatabaseDisconnectAction->setVisible(! OpenRPT::loggedIn);

    fileExitAction->setText(tr("Close"));

    QToolBar *menuproxy = new QToolBar(this);
    menuproxy->setObjectName("menuproxy");
    menuproxy->setOrientation(Qt::Horizontal);
    verticalLayout->insertWidget(0, menuproxy);

    menuproxy->addAction(fileMenu->menuAction());
    menuproxy->addAction(editMenu->menuAction());
    menuproxy->addAction(ViewMenu->menuAction());
    menuproxy->addAction(ToolsMenu->menuAction());
    menuproxy->addAction(helpMenu->menuAction());
  }
  
  fileDatabaseConnectAction->setEnabled(!OpenRPT::loggedIn);
  fileDatabaseDisconnectAction->setEnabled(OpenRPT::loggedIn);
  fileDatabaseOpenAction->setEnabled(OpenRPT::loggedIn);
  fileDatabaseSaveAsAction->setEnabled(OpenRPT::loggedIn);
  
  _pEdit   = new ParameterEdit(this, Qt::Window);
  _log     = new LogOutput(this);
  _sql     = new LogOutput(this);
  _results = new ResultsOutput(this);

  _highlighter = new MetaSQLHighlighter(_document);

  clear();

  setDestType(MQLUnknown);
}
Exemplo n.º 24
0
int main(int argc, char * argv[])
{
    QList<QWidget*> widgets;
    QApplication app(argc, argv);

    QMainWindow mainWindow;
    mainWindow.setWindowTitle("Test");
    QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
    QMenu *editMenu = mainWindow.menuBar()->addMenu("Edit");
    QMenu *viewMenu = mainWindow.menuBar()->addMenu("View");
    QMenu *toolsMenu = mainWindow.menuBar()->addMenu("Tools");
    QMenu *optionsMenu = mainWindow.menuBar()->addMenu("Options");
    QMenu *helpMenu = mainWindow.menuBar()->addMenu("Help");

    qApp->processEvents();

    fileMenu->addAction("Open");
    QAction *close = fileMenu->addAction("Close");
    fileMenu->addSeparator();
    fileMenu->addAction("Exit");

    close->setEnabled(false);

    editMenu->addAction("Cut");
    editMenu->addAction("Pase");
    editMenu->addAction("Copy");
    editMenu->addSeparator();
    editMenu->addAction("Find");

    viewMenu->addAction("Hide");
    viewMenu->addAction("Show");
    viewMenu->addAction("Explore");
    QAction *visible = viewMenu->addAction("Visible");
    visible->setCheckable(true);
    visible->setChecked(true);

    toolsMenu->addMenu("Hammer");
    toolsMenu->addMenu("Caliper");
    toolsMenu->addMenu("Helm");

    optionsMenu->addMenu("Settings");
    optionsMenu->addMenu("Standard");
    optionsMenu->addMenu("Extended");
    
    QMenu *subMenu = helpMenu->addMenu("Help");
    subMenu->addAction("Index");
    subMenu->addSeparator();
    subMenu->addAction("Vodoo Help");
    helpMenu->addAction("Contens");
    helpMenu->addSeparator();
    helpMenu->addAction("About");

    QToolBar toolbar;
    mainWindow.addToolBar(&toolbar);
    toolbar.addAction(QIcon(qApp->style()->standardPixmap(QStyle::SP_FileIcon)), QString("textAction"));

    QTextEdit textEdit;
    mainWindow.setCentralWidget(&textEdit);

    mainWindow.showMaximized();

    app.exec();
}
Exemplo n.º 25
0
DrumrollEditor::DrumrollEditor(QWidget* parent)
   : QMainWindow(parent)
      {
      setObjectName("Drumroll");
      setWindowTitle(QString("MuseScore"));
//      setIconSize(QSize(preferences.iconWidth, preferences.iconHeight));

      QWidget* mainWidget = new QWidget;
      QGridLayout* layout = new QGridLayout;
      mainWidget->setLayout(layout);
      layout->setSpacing(0);

      QToolBar* tb = addToolBar(tr("Toolbar 1"));
      tb->addAction(getAction("undo"));
      tb->addAction(getAction("redo"));
      tb->addSeparator();
#ifdef HAS_MIDI
      tb->addAction(getAction("midi-on"));
#endif
      QAction* a = getAction("follow");
      a->setCheckable(true);
      a->setChecked(preferences.followSong);

      tb->addAction(a);

      tb->addSeparator();
      tb->addAction(getAction("rewind"));
      tb->addAction(getAction("play"));
      tb->addSeparator();

      //-------------
      tb = addToolBar(tr("Toolbar 3"));
      layout->addWidget(tb, 1, 0, 1, 2);

      for (int i = 0; i < VOICES; ++i) {
            QToolButton* b = new QToolButton(this);
            b->setToolButtonStyle(Qt::ToolButtonTextOnly);
            QPalette p(b->palette());
            p.setColor(QPalette::Base, MScore::selectColor[i]);
            b->setPalette(p);
            QAction* a = getAction(voiceActions[i]);
            b->setDefaultAction(a);
            tb->addWidget(b);
            }

      tb->addSeparator();
      tb->addWidget(new QLabel(tr("Cursor:")));
      pos = new Awl::PosLabel;
      tb->addWidget(pos);
      Awl::PitchLabel* pl = new Awl::PitchLabel();
      tb->addWidget(pl);

      tb->addSeparator();
      tb->addWidget(new QLabel(tr("Velocity:")));
      veloType = new QComboBox;
      veloType->addItem(tr("offset"), int(Note::ValueType::OFFSET_VAL));
      veloType->addItem(tr("user"),   int(Note::ValueType::USER_VAL));
      tb->addWidget(veloType);

      velocity = new QSpinBox;
      velocity->setRange(-1, 127);
      velocity->setSpecialValueText("--");
      velocity->setReadOnly(true);
      tb->addWidget(velocity);

      tb->addWidget(new QLabel(tr("Pitch:")));
      pitch = new Awl::PitchEdit;
      pitch->setReadOnly(true);
      tb->addWidget(pitch);

      double xmag = .1;
      gv  = new DrumView;
      gv->scale(xmag, 1.0);
      layout->addWidget(gv, 3, 1);

      ruler = new Ruler;
      ruler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
      ruler->setFixedHeight(rulerHeight);
      ruler->setMag(xmag, 1.0);

      layout->addWidget(ruler, 2, 1);

      Piano* piano = new Piano;
      piano->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
      piano->setFixedWidth(pianoWidth);
      layout->addWidget(piano, 3, 0);

      setCentralWidget(mainWidget);

      connect(gv->verticalScrollBar(), SIGNAL(valueChanged(int)), piano, SLOT(setYpos(int)));
      connect(gv->horizontalScrollBar(), SIGNAL(valueChanged(int)), ruler, SLOT(setXpos(int)));
      connect(gv,          SIGNAL(xposChanged(int)),           ruler, SLOT(setXpos(int)));
      connect(gv,          SIGNAL(magChanged(double,double)),  ruler, SLOT(setMag(double,double)));
      connect(gv,          SIGNAL(magChanged(double,double)),  piano, SLOT(setMag(double,double)));
      connect(gv,          SIGNAL(pitchChanged(int)),          pl,    SLOT(setPitch(int)));
      connect(gv,          SIGNAL(pitchChanged(int)),          piano, SLOT(setPitch(int)));
      connect(piano,       SIGNAL(pitchChanged(int)),          pl,    SLOT(setPitch(int)));
      connect(gv,          SIGNAL(posChanged(const Pos&)),     pos,   SLOT(setValue(const Pos&)));
      connect(gv,          SIGNAL(posChanged(const Pos&)),     ruler, SLOT(setPos(const Pos&)));
      connect(ruler,       SIGNAL(posChanged(const Pos&)),     pos,   SLOT(setValue(const Pos&)));
      connect(ruler,       SIGNAL(locatorMoved(int)),                 SLOT(moveLocator(int)));
      connect(veloType,    SIGNAL(activated(int)),                    SLOT(veloTypeChanged(int)));
      connect(velocity,    SIGNAL(valueChanged(int)),                 SLOT(velocityChanged(int)));
      connect(gv->scene(), SIGNAL(selectionChanged()),                SLOT(selectionChanged()));
      connect(piano,       SIGNAL(keyPressed(int)),                   SLOT(keyPressed(int)));
      connect(piano,       SIGNAL(keyReleased(int)),                  SLOT(keyReleased(int)));
      resize(800, 400);

      QActionGroup* ag = new QActionGroup(this);
      a = new QAction(this);
      a->setData("delete");
      a->setShortcut(Qt::Key_Delete);
      ag->addAction(a);
      addActions(ag->actions());
      connect(ag, SIGNAL(triggered(QAction*)), SLOT(cmd(QAction*)));

      readSettings();
      }
Exemplo n.º 26
0
// --- StyleSheetEditorDialog
StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent, Mode mode):
    QDialog(parent),
    m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Help)),
    m_editor(new StyleSheetEditor),
    m_validityLabel(new QLabel(tr("Valid Style Sheet"))),
    m_core(core),
    m_addResourceAction(new QAction(tr("Add Resource..."), this)),
    m_addGradientAction(new QAction(tr("Add Gradient..."), this)),
    m_addColorAction(new QAction(tr("Add Color..."), this)),
    m_addFontAction(new QAction(tr("Add Font..."), this))
{
    setWindowTitle(tr("Edit Style Sheet"));
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    connect(m_buttonBox, SIGNAL(helpRequested()), this, SLOT(slotRequestHelp()));
    m_buttonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);

    connect(m_editor, SIGNAL(textChanged()), this, SLOT(validateStyleSheet()));

    QToolBar *toolBar = new QToolBar;

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(toolBar, 0, 0, 1, 2);
    layout->addWidget(m_editor, 1, 0, 1, 2);
    layout->addWidget(m_validityLabel, 2, 0, 1, 1);
    layout->addWidget(m_buttonBox, 2, 1, 1, 1);
    setLayout(layout);

    m_editor->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_editor, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(slotContextMenuRequested(QPoint)));

    QSignalMapper *resourceActionMapper = new QSignalMapper(this);
    QSignalMapper *gradientActionMapper = new QSignalMapper(this);
    QSignalMapper *colorActionMapper = new QSignalMapper(this);

    resourceActionMapper->setMapping(m_addResourceAction, QString());
    gradientActionMapper->setMapping(m_addGradientAction, QString());
    colorActionMapper->setMapping(m_addColorAction, QString());

    connect(m_addResourceAction, SIGNAL(triggered()), resourceActionMapper, SLOT(map()));
    connect(m_addGradientAction, SIGNAL(triggered()), gradientActionMapper, SLOT(map()));
    connect(m_addColorAction, SIGNAL(triggered()), colorActionMapper, SLOT(map()));
    connect(m_addFontAction, SIGNAL(triggered()), this, SLOT(slotAddFont()));

    m_addResourceAction->setEnabled(mode == ModePerForm);

    const char * const resourceProperties[] = {
        "background-image",
        "border-image",
        "image",
        0
    };

    const char * const colorProperties[] = {
        "color",
        "background-color",
        "alternate-background-color",
        "border-color",
        "border-top-color",
        "border-right-color",
        "border-bottom-color",
        "border-left-color",
        "gridline-color",
        "selection-color",
        "selection-background-color",
        0
    };

    QMenu *resourceActionMenu = new QMenu(this);
    QMenu *gradientActionMenu = new QMenu(this);
    QMenu *colorActionMenu = new QMenu(this);

    for (int resourceProperty = 0; resourceProperties[resourceProperty]; ++resourceProperty) {
        QAction *action = resourceActionMenu->addAction(QLatin1String(resourceProperties[resourceProperty]));
        connect(action, SIGNAL(triggered()), resourceActionMapper, SLOT(map()));
        resourceActionMapper->setMapping(action, QLatin1String(resourceProperties[resourceProperty]));
    }

    for (int colorProperty = 0; colorProperties[colorProperty]; ++colorProperty) {
        QAction *gradientAction = gradientActionMenu->addAction(QLatin1String(colorProperties[colorProperty]));
        QAction *colorAction = colorActionMenu->addAction(QLatin1String(colorProperties[colorProperty]));
        connect(gradientAction, SIGNAL(triggered()), gradientActionMapper, SLOT(map()));
        connect(colorAction, SIGNAL(triggered()), colorActionMapper, SLOT(map()));
        gradientActionMapper->setMapping(gradientAction, QLatin1String(colorProperties[colorProperty]));
        colorActionMapper->setMapping(colorAction, QLatin1String(colorProperties[colorProperty]));
    }

    connect(resourceActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddResource(QString)));
    connect(gradientActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddGradient(QString)));
    connect(colorActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddColor(QString)));

    m_addResourceAction->setMenu(resourceActionMenu);
    m_addGradientAction->setMenu(gradientActionMenu);
    m_addColorAction->setMenu(colorActionMenu);

    toolBar->addAction(m_addResourceAction);
    toolBar->addAction(m_addGradientAction);
    toolBar->addAction(m_addColorAction);
    toolBar->addAction(m_addFontAction);

    m_editor->setFocus();

    QDesignerSettingsInterface *settings = core->settingsManager();
    settings->beginGroup(QLatin1String(StyleSheetDialogC));

    if (settings->contains(QLatin1String(Geometry)))
        restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray());

    settings->endGroup();
}