コード例 #1
0
ファイル: gb_spiel.cpp プロジェクト: schdorm/openhanse-old
void gesamtbild::zeitanzeige(/*int dora, int hin, int may*/)
{
			qWarning() << "Zeit";


			QDialog *zeitw = new QDialog(this);
			QVBoxLayout layout(zeitw);
			QLabel *anzeige = new QLabel(tr("Time: Day %1,").arg(GAMEDATA->gametime().day()).append(QString("%1 hours").arg(GAMEDATA->gametime().hour())), zeitw);

// 			anzeige->setText(anzeige->text().append(QString(", %2 Uhr %3").arg( gameview->stunde, gameview->minute)));gameview->stunde
// 			qWarning() << anzeige->text().append(QString(", %2 Uhr %3").arg( gameview->stunde, gameview->minute));

			QPushButton *ok = new QPushButton("Ok",zeitw);
			ok->move(50, 50);
			layout.addWidget(anzeige);
			layout.addWidget(ok);
// 			zeitw->setGeometry(width()/2,height()/2,200,100);
			zeitw->setLayout(&layout);
			zeitw->setAutoFillBackground(true);
			zeitw->move(gameview->width()/2,gameview->height()/2);
  			zeitw->raise();
			zeitw->show();

			connect(ok, SIGNAL(clicked()), gameview, SLOT(endePause()));
			connect(ok, SIGNAL(clicked()), zeitw, SLOT(close()));
			connect(ok, SIGNAL(clicked()), zeitw, SLOT(deleteLater()));
}
コード例 #2
0
void MenuButton::mousePressEvent ( QGraphicsSceneMouseEvent * event ) {
    QGraphicsItem::mousePressEvent(event);
    if(event->button() != Qt::LeftButton) return;
    if(currentMenu) {
        currentMenu->setFocus(); //BUG: doesnt seem to work
        return;
    }

    QDialog *menu = new QDialog(panelWindow);
    menu->move(event->screenPos().x(), event->screenPos().y());
    QVBoxLayout *layout = new QVBoxLayout();

    QCheckBox *editModeCheck = new QCheckBox("Edit Panel", menu);
    editModeCheck->setChecked(editMode);
    connect(editModeCheck, SIGNAL(clicked(bool)), panelWindow, SLOT(setEditMode(bool)));
    connect(editModeCheck, SIGNAL(clicked(bool)), this, SLOT(setEditMode(bool)));

    layout->addWidget(editModeCheck);
    QPushButton *addButton = new QPushButton("Add Item", menu);
    connect(addButton, SIGNAL(clicked()), panelWindow, SLOT(addItem()));
    layout->addWidget(addButton);

    QPushButton *saveButton = new QPushButton("Save panel", menu);
    connect(saveButton, SIGNAL(clicked()), panelWindow, SLOT(savePanel()));
    layout->addWidget(saveButton);

    QPushButton *loadButton = new QPushButton("Load panel", menu);
    connect(loadButton, SIGNAL(clicked()), panelWindow, SLOT(loadPanel()));
    layout->addWidget(loadButton);

    QPushButton *settingsButton = new QPushButton("App Settings", menu);
    connect(settingsButton, SIGNAL(clicked()), panelWindow, SLOT(showSettings()));
    connect(settingsButton, SIGNAL(clicked()), this, SLOT(closeCurrentMenu()));
    layout->addWidget(settingsButton);

    QPushButton *closeButton = new QPushButton("Close", menu);
    connect(closeButton, SIGNAL(clicked()), this, SLOT(closeCurrentMenu()));
    layout->addWidget(closeButton);

    QPushButton *quitButton = new QPushButton("Quit", menu);
    connect(quitButton, SIGNAL(clicked()), panelWindow, SLOT(quit()));
    layout->addWidget(quitButton);

    currentMenu = menu;
    connect(currentMenu, SIGNAL(finished(int)), this, SLOT(closeCurrentMenu()));

    menu->setLayout(layout);
    menu->setModal(false);
    menu->show();
}
コード例 #3
0
ファイル: ctkSettings.cpp プロジェクト: benoitbleuze/CTK
//-----------------------------------------------------------------------------
void ctkSettings::restoreState(const QString& key, QDialog& dialog)
{
  this->beginGroup(key);
  
  if(this->contains("Size"))
    {
    dialog.resize(this->value("Size").toSize());
    }
    
  if(this->contains("Position"))
    {
    dialog.move(this->value("Position").toPoint());
    }

  this->endGroup();
}
コード例 #4
0
void MainWindow::on_actionYearlyStatistics_triggered()
{
	QDialog d;
	QVBoxLayout *l = new QVBoxLayout(&d);
	YearlyStatisticsModel *m = new YearlyStatisticsModel();
	QTreeView *view = new QTreeView();
	view->setModel(m);
	l->addWidget(view);
	d.resize(width() * .8, height() / 2);
	d.move(width() * .1, height() / 4);
	QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), &d);
	connect(close, SIGNAL(activated()), &d, SLOT(close()));
	QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), &d);
	connect(quit, SIGNAL(activated()), this, SLOT(close()));
	d.setWindowFlags(Qt::Window | Qt::CustomizeWindowHint
		| Qt::WindowCloseButtonHint | Qt::WindowTitleHint);
	d.setWindowTitle(tr("Yearly Statistics"));
	d.exec();
}
コード例 #5
0
bool ButtonDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
    if (event->type() == QEvent::MouseButtonPress) {

        QMouseEvent* e =(QMouseEvent*)event;

        if (option.rect.adjusted(4, 4, -4, -4).contains(e->x(), e->y()) && m_btns.contains(index)) {
            m_btns.value(index)->state |= QStyle::State_Sunken;
        }
    }
    if (event->type() == QEvent::MouseButtonRelease) {
        QMouseEvent* e =(QMouseEvent*)event;

        if (option.rect.adjusted(4, 4, -4, -4).contains(e->x(), e->y()) && m_btns.contains(index)) {
            m_btns.value(index)->state &= (~QStyle::State_Sunken);

            QDialog *d = new QDialog();

            d->setGeometry(0, 0, 200, 200);
            d->move(QApplication::desktop()->screenGeometry().center() - d->rect().center());
            d->show();
        }
    }
}