Exemplo n.º 1
0
SerialMonitor::SerialMonitor(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	setWindowIconText("serial");
	ui.plainTextEdit->setReadOnly(true);

	ui.btnAutoScroll->setVisible(false); // disable autoscroll not yet implemented

	connect (ui.btnReOpen, SIGNAL(clicked()), this, SLOT(ReOpenPort()));
	connect (ui.btnSend, SIGNAL(clicked()), this, SLOT(SendData()));
	connect (ui.lineEdit, SIGNAL(returnPressed()), this, SLOT(SendData()));

    //connect (&serialPort, SIGNAL(readyRead()), this, SLOT(ReadSerialPort()));
	
	LoadStyleSheet(this, "style_serial_monitor.css");

	portId = "";
    int index = ui.cbSpeed->findText("9600");
    ui.cbSpeed->setCurrentIndex(index);
    //ui.cbSpeed->setCurrentText("9600");
    portSpeed = "9600";


}
Exemplo n.º 2
0
EditorTab::EditorTab(QWidget *parent)
	: QTabWidget(parent)
{
	this->setTabsClosable(true);
    this->setTabShape(Triangular);

	LoadStyleSheet(this, "style_code_tab.css");

	connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));

	//create context menu
	context= new QMenu(this);		
	LoadStyleSheet(context, "style_menu.css");
	QAction * action = context->addAction("Close tab");
	connect(action, SIGNAL(triggered()), this, SLOT(closeThis()));
	action = context->addAction("Close all but this");
	connect(action, SIGNAL(triggered()), this, SLOT(closeAllButThis()));
	//projectContext->addAction(action);
	//projectContext->addSeparator();
}
Exemplo n.º 3
0
EditorTab::EditorTab(QWidget *parent)
	: QTabWidget(parent)
{
	this->setTabsClosable(true);
	this->setTabShape(Triangular);

	LoadStyleSheet(this, "style_code_tab.css");

	connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));

	//create context menu
	context= new QMenu(this);		
	LoadStyleSheet(context, "style_menu.css");
	QAction * action = context->addAction("Close tab");
	connect(action, SIGNAL(triggered()), this, SLOT(closeThis()));
	action = context->addAction("Close all but this");
	connect(action, SIGNAL(triggered()), this, SLOT(closeAllButThis()));

	tabBar()->installEventFilter( this );

    setAttribute(Qt::WA_DeleteOnClose);
}
Exemplo n.º 4
0
Editor::Editor(QWidget *parent)
	: QsciScintilla(parent)
{
	// identify this widget as a code editor
	// WindoweIconText is used only for windows widgets. 
	// So, it's free for us to use it here
	setWindowIconText("editor");
	//setEolMode(QsciScintilla::EolUnix);

	lexer = new QsciLexerCPP;
	this->setLexer(lexer);
	this->setUtf8(true);
	//setAutoCompletionThreshold(0);
	
	api = new QsciAPIs(lexer);
	api->prepare();

	LoadStyleSheet(this, "style_code_editor.css");
	
    setAutoCompletionThreshold(3);
    setAutoCompletionSource(QsciScintilla::AcsAll);

	context= new QMenu(this);		
	LoadStyleSheet(context, "style_menu.css");
	actionHelpWithThis = context->addAction("Help with this code");
	connect(actionHelpWithThis, SIGNAL(triggered()), this, SLOT(HelpWithThis()));
	context->addSeparator();
	
	QAction * action = context->addAction("Undo");
	action->setShortcut(tr("Ctrl+Z"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuUndo()));
	
	action = context->addAction("Redo");
	action->setShortcut(tr("Ctrl+Y"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuRedo()));
	
	context->addSeparator();
	
	action = context->addAction("Cut");
	action->setShortcut(tr("Ctrl+X"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuCut()));

	action = context->addAction("Copy");
	action->setShortcut(tr("Ctrl+C"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuCopy()));

	action = context->addAction("Paste");
	action->setShortcut(tr("Ctrl+V"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuPaste()));

	/*action = context->addAction("Delete");
	connect(action, SIGNAL(triggered()), this, SLOT(MenuDelete()));
	*/

	context->addSeparator();
	
	action = context->addAction("Select all");
	action->setShortcut(tr("Ctrl+A"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuSelectAll()));
		
	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this,SLOT(ShowEditorMenu(const QPoint )));		
	connect(this, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(onCursorPositionChanged(int, int)));
	
	lblCursorPosition = new QLabel(this);
	LoadStyleSheet(lblCursorPosition, "style_cursorpos.css");
	lblCursorPosition->setVisible(true);

	QVBoxLayout * vl = new QVBoxLayout(this);	
	//QVBoxLayout * vl2 = new QVBoxLayout(this);	
	
	
	int scrollbarw = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);


	QHBoxLayout * hl = new QHBoxLayout(this);		
	hl->addSpacerItem(new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Fixed));
	hl->addWidget(lblCursorPosition);
	hl->addSpacerItem(new QSpacerItem (scrollbarw,0, QSizePolicy::Fixed, QSizePolicy::Fixed));
	vl->addLayout(hl);
	vl->addSpacerItem(new QSpacerItem(0,0, QSizePolicy::Fixed,QSizePolicy::Expanding ));
	
	lastModifiedTime = QDateTime::currentDateTime();

	setAutoIndent(true);

	setEditorStyle();
}
DianVoteControl::DianVoteControl(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DianVoteControl),
    drawer(NULL),
    hidControl(NULL),
    stopWatch(NULL),
    splash(NULL),
    voteMode(SINGLE_VOTE),
    curState(STOP)
{
    QDir dir;
    dir.setCurrent(QCoreApplication::applicationDirPath());

    windowIcon = new QIcon(dir.absoluteFilePath("res/images/app-icon.png"));
    this->setWindowIcon(*windowIcon);

    // show splash.
    QPixmap pixmap(dir.absoluteFilePath("res/images/logo.png"));
    QSplashScreen *splash = new QSplashScreen(pixmap);
    splash->setWindowIcon(*windowIcon);
    splash->setWindowFlags(Qt::WindowStaysOnTopHint);
    splash->setMask(pixmap.mask());
    splash->show();

    ui->setupUi(this);

    pbStart = new QPushButton(this);
    pbStart->setObjectName(tr("pbStart"));
    ui->buttonLayout->addWidget(pbStart, 0, 0);

    pbAuto = new QPushButton(this);
    pbAuto->setObjectName(tr("pbAuto"));
    ui->buttonLayout->addWidget(pbAuto, 0, 1);

    pbPause = new QPushButton(this);
    pbPause->setObjectName(tr("pbPause"));
    ui->buttonLayout->addWidget(pbPause, 0, 0);
    pbPause->hide();

    pbStop = new QPushButton(this);
    pbStop->setObjectName(tr("pbStop"));
    ui->buttonLayout->addWidget(pbStop, 0, 1);
    pbStop->hide();

    pbResult = new QPushButton(this);
    pbResult->setObjectName(tr("pbResult"));
    ui->buttonLayout->addWidget(pbResult, 0, 2);

    pbOption = new QToolButton(this);
    pbOption->setObjectName(tr("pbOption"));
    ui->buttonLayout->addWidget(pbOption, 0, 3);

    qaSingleMode = new QAction(tr("SingleVoteMode"), this);  // 单选模式
    qaSingleMode->setCheckable(true);
    qaSingleMode->setChecked(true);         // 默认模式
    qaMutipleMode = new QAction(tr("MutipleVoteMode"), this); // 多选
    qaMutipleMode->setCheckable(true);
    qaRaceMode = new QAction(tr("RaceVoteMode"), this);    // 抢答
    qaRaceMode->setCheckable(true);
    pbOption->addAction(qaSingleMode);
    pbOption->addAction(qaMutipleMode);
    pbOption->addAction(qaRaceMode);
    connect(qaSingleMode, SIGNAL(triggered()), this, SLOT(DoSingleMode()));
    connect(qaMutipleMode, SIGNAL(triggered()), this, SLOT(DoMutipleMode()));
    connect(qaRaceMode, SIGNAL(triggered()), this, SLOT(DoRaceVoteMode()));

    pbClose = new QPushButton(this);
    pbClose->setObjectName(tr("pbClose"));
    ui->buttonLayout->addWidget(pbClose, 0, 4);

    connect(pbClose, SIGNAL(clicked()), this, SLOT(close()));
    connect(pbStart, SIGNAL(clicked()), this, SLOT(VoteStart()));
    connect(pbAuto, SIGNAL(clicked()), this, SLOT(VoteAuto()));
    connect(pbPause, SIGNAL(clicked()), this, SLOT(VotePause()));
    connect(pbStop, SIGNAL(clicked()), this, SLOT(VoteStop()));
    connect(pbResult, SIGNAL(clicked()), this, SLOT(DoShowResults()));

    drawer = new DianVoteDrawer();
    drawer->setWindowIcon(*windowIcon);
    drawer->setWindowTitle(tr("Result"));
    connect(pbClose, SIGNAL(clicked()), this->drawer, SLOT(close()));
    connect(this, SIGNAL(setOptionNum(int)), drawer->histgram, SLOT(SetOptionNums(int)));
    connect(this, SIGNAL(setOptionNum(int)), drawer->pie, SLOT(SetOptionNums(int)));
    connect(this, SIGNAL(clearDrawData()), drawer->histgram, SLOT(ClearData()));
    connect(this, SIGNAL(clearDrawData()), drawer->pie, SLOT(ClearData()));
    connect(this, SIGNAL(updateGraph(int)), drawer->histgram, SLOT(HandleData(int)));
    connect(this, SIGNAL(updateGraph(int)), drawer->pie, SLOT(HandleData(int)));

    LoadStyleSheet("Default");

    // 记录初始化窗口大小
    initSize = this->size();
    this->setMaximumWidth(this->width());
    this->setMaximumHeight(this->height() + 100);
    this->move(0, 0);

    // 创建Log文件,并打开,程序退出是关闭
    VoteLog->open(QIODevice::WriteOnly | QIODevice::Append);

    // 初始化log记录链表
    log = new QList< RevData* >();
}
Exemplo n.º 6
0
/*----------------------------------------------------------------------
  AttrMediaChanged: the user has created removed or modified a Media
  attribute
  ----------------------------------------------------------------------*/
void AttrMediaChanged (NotifyAttribute *event)
{
  ElementType         elType;
  Element             el;
  Document            doc;
  Attribute           attr;
  AttributeType       attrType;
  CSSInfoPtr          css;
  CSSmedia            media;
  PInfoPtr            pInfo;
  DisplayMode         dispMode;
  char                completeURL[MAX_LENGTH];
  char                tempname[MAX_LENGTH];
  char               *name2;
  int                 length;

  el = event->element;
  doc = event->document;
  attr = event->attribute;
  elType = TtaGetElementType (el);
  /* get the new media value */
  length = TtaGetTextAttributeLength (attr);
  name2 = (char *)TtaGetMemory (length + 1);
  TtaGiveTextAttributeValue (attr, name2, &length);
  media = CheckMediaCSS (name2);
  TtaFreeMemory (name2);
  /* get the CSS URI */
  attrType.AttrSSchema = elType.ElSSchema;
  attrType.AttrTypeNum = HTML_ATTR_HREF_;
  attr = TtaGetAttribute (el, attrType);
  if (attr &&
      /* don't manage a document used by make book */
      (DocumentMeta[doc] == NULL ||
       DocumentMeta[doc]->method != CE_MAKEBOOK))
    {
      length = TtaGetTextAttributeLength (attr);
      name2 = (char *)TtaGetMemory (length + 1);
      TtaGiveTextAttributeValue (attr, name2, &length);
      /* load the stylesheet file found here ! */
      NormalizeURL (name2, doc, completeURL, tempname, NULL);
      TtaFreeMemory (name2);
      /* get the right CSS context */ 
      css = SearchCSS (doc, completeURL, el, &pInfo);
    }
  else
    /* get the right CSS context */ 
    css = SearchCSS (doc, NULL, el, &pInfo);
  if (css && pInfo)
    {
      /* avoid too many redisplay */
      dispMode = TtaGetDisplayMode (doc);
      /* something changed and we are not printing */
      if (media == CSS_ALL || media == CSS_SCREEN)
        {
          if (dispMode != NoComputedDisplay)
            TtaSetDisplayMode (doc, NoComputedDisplay);
          LoadStyleSheet (completeURL, doc, el, NULL, NULL, media,
                          pInfo->PiCategory == CSS_USER_STYLE);
          /* restore the display mode */
          if (dispMode != NoComputedDisplay)
            TtaSetDisplayMode (doc, dispMode);
        }
      else
        {
          if (media == CSS_PRINT || media == CSS_OTHER)
            {
              if (dispMode != NoComputedDisplay)
                TtaSetDisplayMode (doc, NoComputedDisplay);
              UnlinkCSS (css, doc, el, TRUE, FALSE, TRUE);
              /* restore the display mode */
              if (dispMode != NoComputedDisplay)
                TtaSetDisplayMode (doc, dispMode);
            }
          /* only update the CSS media info */
          pInfo->PiMedia = media;
        }
    }
}
Exemplo n.º 7
0
void SeekBar::resizeEvent(QResizeEvent *event) {
    LoadStyleSheet();
    QWidget::resizeEvent(event);
}
Exemplo n.º 8
0
SeekBar::SeekBar(QWidget *parent) : QSlider(parent) {
    setPageStep(0);
    setOrientation(Qt::Horizontal);
    LoadStyleSheet();
}