コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: psi-plus/plugins
void ChessWindow::createMenu() {
    QMenuBar *menuBar = ui_.menubar;
    menuBar->setStyleSheet("QMenuBar::item {background-color: #ffffe7; border-radius: 1px; border: 1px solid #74440e; color: black;"
                   "spacing: 10px; padding: 1px 4px; background: transparent; }"
                   "QMenuBar::item:selected { background-color: #ffeeaf; color: black;  }"
                   "QMenuBar::item:pressed { background: #ffeeaf; color: black;  }");

    QAction *loadAction = new QAction(tr("Load game"), menuBar);
    QAction *saveAction = new QAction(tr("Save game"), menuBar);
    QAction *quitAction = new QAction(tr("Quit"), menuBar);
    loseAction = new QAction(tr("Resign"), menuBar);
    QAction *soundAction = new QAction(tr("Enable sound"),menuBar);
    soundAction->setCheckable(true);
    soundAction->setChecked(enabledSound);

    QMenu *fileMenu = menuBar->addMenu(tr("File"));
    QMenu *gameMenu = menuBar->addMenu(tr("Game"));

    fileMenu->addAction(loadAction);
    fileMenu->addAction(saveAction);
    fileMenu->addSeparator();
    fileMenu->addAction(quitAction);
    gameMenu->addAction(loseAction);
    gameMenu->addSeparator();
    gameMenu->addAction(soundAction);

    connect(loadAction, SIGNAL(triggered()), this, SLOT(load()));
    connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()), Qt::QueuedConnection);
    connect(loseAction, SIGNAL(triggered()), this, SIGNAL(lose()));
    connect(soundAction, SIGNAL(triggered(bool)), this, SIGNAL(toggleEnableSound(bool)));
}
コード例 #2
0
///
/// Public Funcitons
///
//!
//! Fills the given tool bars with actions for the TableViewPanel view.
//!
//! \param mainToolBar The main tool bar to fill with actions.
//! \param panelToolBar The panel tool bar to fill with actions.
//!
void TableViewPanel::fillToolBars ( QToolBar *mainToolBar, QToolBar *panelToolBar )
{
	// Temp
	QAction *ui_descriptionAction;
	ui_descriptionAction = new QAction(this);
    ui_descriptionAction->setObjectName(QString::fromUtf8("ui_descriptionAction"));
    ui_descriptionAction->setCheckable(true);
    QIcon icon1;
    icon1.addFile(QString::fromUtf8(":/infoIcon"), QSize(), QIcon::Normal, QIcon::Off);
    ui_descriptionAction->setIcon(icon1);
	ui_descriptionAction->setToolTip("Show Description");

	connect(ui_descriptionAction, SIGNAL(toggled(bool)), this, SLOT(showDiscription(bool)));

	// Column visibility select control
	// Place holder for drop down to select which columns of table are visible
	// This should be populated with column names
	QAction *visibilityAct = new QAction(tr("&Select Columns..."), this);
	visibilityAct->setStatusTip(tr("Select columns for visibility..."));
    connect(visibilityAct, SIGNAL(triggered()), this, SLOT());

	QMenu *visibilityMenu = new QMenu();
	visibilityMenu->addAction(visibilityAct);
    visibilityMenu->addSeparator();

	QString menuStyleSheet (
        "QMenuBar {"
        "    border: none;"
        "    margin: 0px;"
        "    padding: 0px;"
		"    background: none;"
        "}"
        "QMenuBar::item {"
        "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a5a5a5, stop:0.2 #999999, stop:0.8 #b0b0b0, stop:1 #555555);"
        "    color: #000000;"
		"    border: 1px solid #323232"
        "    border-radius: 5px;"
        "}"
        "QMenuBar::item:selected {"
        "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);"
        "    color: #000000;"
		"    border: 1px solid #222222"
        "    border-radius: 5px;"
        "}"
        "QMenuBar::item:pressed {"
        "    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);"
        "    color: #000000;"
		"    border: 1px solid #222222"
        "    border-radius: 5px;"
        "}"
    );

	QMenuBar *visibilityMenuBar = new QMenuBar();
	visibilityMenuBar->setMinimumWidth(50);
	visibilityMenuBar->setStyleSheet(menuStyleSheet);
	visibilityMenuBar->addMenu(visibilityMenu);
	visibilityMenuBar->addAction(visibilityAct);

	// Search control
	// Keyword search highlights rows

	QLineEdit *searchField = new QLineEdit();
	searchField->setMaximumWidth(200);

	mainToolBar->addAction(ui_descriptionAction);
	mainToolBar->addSeparator();
	mainToolBar->addWidget(visibilityMenuBar);
	mainToolBar->addSeparator();
	mainToolBar->addWidget(searchField);
}