void CreateAccount::setupCards()
{
    createImageLabel(ui->lblVisa, ":/visa.png");
    createImageLabel(ui->lblMaestro, ":/maestro.png");
    createImageLabel(ui->lblAmex, ":/amex.png");

    // setup card year
    ui->cmbCardYear->clear();
    ui->cmbCardYear->addItem("Year");
    int cyear = QDateTime::currentDateTime().date().year();
    for(int i = cyear; i <= cyear+10; ++i) {
        ui->cmbCardYear->addItem(QString::number(i));
    }

    // setup card month
    ui->cmbCardMonth->clear();
    QStringList months;
    months << tr("Month")
           << tr("January")
           << tr("February")
           << tr("March")
           << tr("April")
           << tr("May")
           << tr("June")
           << tr("July")
           << tr("August")
           << tr("September")
           << tr("October")
           << tr("November")
           << tr("December")
              ;
    ui->cmbCardMonth->addItems(months);
}
/**
 * creates the icon for the specified task as a karamba image
 * @param ctask         the window id of the task to create the icon for
 */
PyObject* py_createTaskIcon(PyObject *, PyObject *args)
{
  long widget, x, y;
  long ctask;
  if (!PyArg_ParseTuple(args, (char*)"llll:createTaskIcon", &widget, &x, &y, &ctask))
    return NULL;
  if (!checkKaramba(widget))
    return NULL;

  //get the specified task and insure it exists
  TaskList taskList = ((karamba*)widget)->taskManager.tasks();
  Task* task = 0;
  Task* currTask = 0;
  for (task = taskList.first(); task; task = taskList.next())
  {
    if ((long)task == (long)ctask)
    {
      //task found
      currTask = task;
      break;
    }
  }
  if (currTask == 0)
  {
    //no task was found
    qWarning("Task not found.");
    return (long)NULL ;
  }
  //retrieve the QPixmap that represents this image
  QPixmap iconPixmap = KWin::icon(currTask->window());

  ImageLabel *tmp = createImageLabel((karamba*)widget, x, y, 0, 0);
  tmp->setValue(iconPixmap);
  return (Py_BuildValue((char*)"l", (long)tmp));
}
/**
 * Constructor
 */
Photo_Viewer::Photo_Viewer(QWidget *parent)
    : QMainWindow(parent)
{
	//define path for image files
	setImgPath("./images/");
	//define filetype
	setFiletypeFilter("jpg");
	//populate string vector list with jpg file names
	getSpecificFilesFromDir(getFiletypeFilter(), files);
	//at the start the img location is 0
	setImgLoc(0);
	//set default speed for slideshow
	setSlideshowSpeed(2000);
	//set slideshow toggle off
	setSlideshowToggle(0);

	//setup user interface
	ui.setupUi(this);
	//set screen size
	setSize(888, 600);
//	setSize(888, 500);
	this->resize(maxWidth, maxHeight);
	//center screen
	centerScreen();
	//creates a QLabel which parent is QMainWindow.
	createImageLabel();
}
PyObject* py_createBackgroundImage(PyObject *, PyObject *args)
{
  long widget, x, y;
  char *text;
  if (!PyArg_ParseTuple(args, (char*)"llls:createBackgroundImage", &widget, &x, &y,
                        &text))
    return NULL;
  if (!checkKaramba(widget))
    return NULL;
  ImageLabel *tmp = createImageLabel((karamba*)widget, x, y, text, 1);
  return (Py_BuildValue((char*)"l", (long)tmp));
}
void CreateAccount::checkEmail()
{
    QSqlQuery query;
    if(!query.exec(QString("SELECT * FROM customer where email = '%1'").arg(ui->editEmail->text()))){
        qDebug() << query.lastError().text();
        return;
    }

    qDebug() << "Row count: " << query.size();
    QString icons[] = {":/cross.png", ":/tick.png"};

    if(query.size() >= 1) {
        createImageLabel(ui->lblTick, icons[0]);
        ui->lblTick->setVisible(true);
        ui->lblTick->setToolTip(tr("Email already registered"));
    }
    else {
        createImageLabel(ui->lblTick, icons[1]);
        ui->lblTick->setVisible(true);
    }
}
CreateAccount::CreateAccount(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CreateAccount)
{
    ui->setupUi(this);

    setMaxLengths();
    setupValidators();
    setupCards();

    ui->btnSubmit->setEnabled(false);
    ui->cardBox->setVisible(false);
    ui->dummyBox->setMinimumSize(ui->cardBox->sizeHint());

    ui->editEmail->setMinimumSize(ui->editEmail->sizeHint());
    createImageLabel(ui->lblTick, ":/tick.png");
    ui->lblTick->setVisible(false);
    ui->lblTick->setMinimumSize(ui->lblTick->sizeHint());

    // signals and slots

    connect(ui->editFirstname, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editMiddlename, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editLastname, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editProfession, SIGNAL(editingFinished()), this, SLOT(normalizeName()));

    // connect required fields to submit
    connect(ui->editFirstname, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editLastname, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editEmail, SIGNAL(editingFinished()), this, SLOT(checkEmail()));
    connect(ui->editContact, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editAttachment, SIGNAL(textChanged(QString)), this, SLOT(enableSubmit()));
    connect(ui->editAmount, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));

    connect(ui->btnAttachment, SIGNAL(clicked(bool)), this, SLOT(addAttachment()));
    connect(ui->btnReset, SIGNAL(clicked(bool)), this, SLOT(resetForm()));
}
Exemple #7
0
static void loadMenuLayout()
{
	Medal *medal;
	int i, width, medalCount;
	Texture *texture;

	medal = getMedals();

	medalCount = getMedalCount();

	i = 0;

	width = 0;

	menu.w = 0;

	menu.h = 0;

	menu.startY = 0;

	menu.endY = 0;

	menu.widgetCount = medalCount;

	menu.widgets = malloc(sizeof(Widget *) * menu.widgetCount);

	if (menu.widgets == NULL)
	{
		showErrorAndExit("Ran out of memory when creating Medals Menu");
	}

	for (i=0;i<menu.widgetCount;i++)
	{
		if (medal[i].hidden == TRUE && medal[i].obtained == FALSE)
		{
			menu.widgets[i] = createWidget(_("Hidden Medal"), NULL, NULL, NULL, NULL, 10, 20 + i * 40, FALSE, 255, 255, 255);
		}

		else
		{
			if (medal[i].obtained == TRUE)
			{
				menu.widgets[i] = createWidget(_(medal[i].description), NULL, NULL, NULL, NULL, 10, 20 + i * 40, FALSE, 0, 200, 0);
			}

			else
			{
				menu.widgets[i] = createWidget(_(medal[i].description), NULL, NULL, NULL, NULL, 10, 20 + i * 40, FALSE, 255, 255, 255);
			}
		}

		if (width < menu.widgets[i]->x + menu.widgets[i]->normalState->w)
		{
			width = menu.widgets[i]->x + menu.widgets[i]->normalState->w;
		}

		texture = getMedalImage(medal[i].medalType, medal[i].obtained);

		menu.widgets[i]->label = createImageLabel(texture, menu.widgets[i]->x, menu.widgets[i]->y);

		menu.widgets[i]->label->y = menu.widgets[i]->y + menu.widgets[i]->normalState->h / 2 - menu.widgets[i]->label->text->h / 2;

		menu.endY = menu.widgets[i]->y + menu.widgets[i]->normalState->h - menu.h;
	}

	width += 15;

	menu.h = SCREEN_HEIGHT - BUTTON_PADDING;

	for (i=0;i<menu.widgetCount;i++)
	{
		if (menu.widgets[i]->label != NULL)
		{
			menu.widgets[i]->label->x = width;

			if (menu.w < menu.widgets[i]->label->x + menu.widgets[i]->label->text->w)
			{
				menu.w = menu.widgets[i]->label->x + menu.widgets[i]->label->text->w;
			}
		}
	}

	menu.background = addBorder(createSurface(menu.w, menu.h, FALSE), 255, 255, 255, 0, 0, 0);

	menu.x = (SCREEN_WIDTH - menu.background->w) / 2;
	menu.y = (SCREEN_HEIGHT - menu.background->h) / 2;
}