Beispiel #1
0
static void usage(FILE *fp, int markers)
{
    struct Option *opt;
    struct Flag *flag;
    char item[256];
    const char *key_desc;
    int maxlen;
    int len, n;
    int new_prompt = 0;

    new_prompt = G__uses_new_gisprompt();

    if (!st->pgm_name)		/* v.dave && r.michael */
	st->pgm_name = G_program_name();
    if (!st->pgm_name)
	st->pgm_name = "??";

    if (st->module_info.label || st->module_info.description) {
	fprintf(fp, "\n");
	if (markers)
	    fprintf(fp, "{{{DESCRIPTION}}}\n");
	fprintf(fp, "%s\n", _("Description:"));
	if (st->module_info.label)
	    fprintf(fp, " %s\n", st->module_info.label);
	if (st->module_info.description)
	    fprintf(fp, " %s\n", st->module_info.description);
    }
    if (st->module_info.keywords) {
	fprintf(fp, "\n");
	if (markers)
	    fprintf(fp, "{{{KEYWORDS}}}\n");
	fprintf(fp, "%s\n ", _("Keywords:"));
	G__print_keywords(fp, NULL);
	fprintf(fp, "\n");
    }

    fprintf(fp, "\n");
    if (markers)
	fprintf(fp, "{{{USAGE}}}\n");
    fprintf(fp, "%s\n ", _("Usage:"));

    len = show(fp, st->pgm_name, 1);

    /* Print flags */

    if (st->n_flags) {
	item[0] = ' ';
	item[1] = '[';
	item[2] = '-';
	flag = &st->first_flag;
	for (n = 3; flag != NULL; n++, flag = flag->next_flag)
	    item[n] = flag->key;
	item[n++] = ']';
	item[n] = 0;
	len = show(fp, item, len);
    }

    maxlen = 0;
    if (st->n_opts) {
	opt = &st->first_option;
	while (opt != NULL) {
	    if (opt->key_desc != NULL)
		key_desc = opt->key_desc;
	    else if (opt->type == TYPE_STRING)
		key_desc = "string";
	    else
		key_desc = "value";

	    if (!opt->key) {
		fprintf(stderr, "\n%s\n", _("ERROR: Option key not defined"));
		exit(EXIT_FAILURE);
	    }
	    n = strlen(opt->key);
	    if (n > maxlen)
		maxlen = n;

	    strcpy(item, " ");
	    if (!opt->required)
		strcat(item, "[");
	    strcat(item, opt->key);
	    strcat(item, "=");
	    strcat(item, key_desc);
	    if (opt->multiple) {
		strcat(item, "[,");
		strcat(item, key_desc);
		strcat(item, ",...]");
	    }
	    if (!opt->required)
		strcat(item, "]");

	    len = show(fp, item, len);

	    opt = opt->next_opt;
	}
    }
    if (new_prompt) {
	strcpy(item, " [--overwrite]");
	len = show(fp, item, len);
    }

    strcpy(item, " [--help]");
    len = show(fp, item, len);

    strcpy(item, " [--verbose]");
    len = show(fp, item, len);

    strcpy(item, " [--quiet]");
    len = show(fp, item, len);

    fprintf(fp, "\n");

    /* Print help info for flags */

    fprintf(fp, "\n");
    if (markers)
	fprintf(fp, "{{{FLAGS}}}\n");
    fprintf(fp, "%s\n", _("Flags:"));

    if (st->n_flags) {
	flag = &st->first_flag;
	while (flag != NULL) {
	    fprintf(fp, "  -%c   ", flag->key);

	    if (flag->label) {
		fprintf(fp, "%s\n", flag->label);
		if (flag->description)
		    fprintf(fp, "        %s\n", flag->description);

	    }
	    else if (flag->description) {
		fprintf(fp, "%s\n", flag->description);
	    }

	    flag = flag->next_flag;
	}
    }

    if (new_prompt)
	fprintf(fp, " --o   %s\n",
		_("Allow output files to overwrite existing files"));

    fprintf(fp, " --h   %s\n", _("Print usage summary"));
    fprintf(fp, " --v   %s\n", _("Verbose module output"));
    fprintf(fp, " --q   %s\n", _("Quiet module output"));

    /* Print help info for options */

    if (st->n_opts) {
	fprintf(fp, "\n");
	if (markers)
	    fprintf(fp, "{{{PARAMETERS}}}\n");
	fprintf(fp, "%s\n", _("Parameters:"));
	opt = &st->first_option;
	while (opt != NULL) {
	    fprintf(fp, "  %*s   ", maxlen, opt->key);

	    if (opt->label) {
		fprintf(fp, "%s\n", opt->label);
		if (opt->description) {
		    fprintf(fp, "  %*s    %s\n",
			    maxlen, " ", opt->description);
		}
	    }
	    else if (opt->description) {
		fprintf(fp, "%s\n", opt->description);
	    }

	    if (opt->options)
		show_options(fp, maxlen, opt->options);
	    /*
	       fprintf (fp, "  %*s   options: %s\n", maxlen, " ",
	       _(opt->options)) ;
	     */
	    if (opt->def)
		fprintf(fp, _("  %*s   default: %s\n"), maxlen, " ",
			opt->def);

	    if (opt->descs) {
		int i = 0;

		while (opt->opts[i]) {
		    if (opt->descs[i])
			fprintf(fp, "  %*s    %s: %s\n",
				maxlen, " ", opt->opts[i], opt->descs[i]);

		    i++;
		}
	    }

	    opt = opt->next_opt;
	}
    }
}
Beispiel #2
0
void ofxObject::updateMessages()
{
	for(unsigned int i=0; i < messages.size(); i++){
		if(messages[i]->isEnabled){
      
			//grab commonly needed values
			float startTime = messages[i]->startTime + messages[i]->startDelay;
			float endTime = messages[i]->getFinishTime();
			float duration = messages[i]->duration;
			float time = ofxMessage::interpolateTime(messages[i]->interpolation, (curTime - startTime)/duration);
			float t = time;
			float x,y,z,w;
			//printf("t_%02d = %f\n", i, t);
      
			//adjust t for palindrome looping
			if(messages[i]->playMode == OF_LOOP_PALINDROME_PLAY){
				if(messages[i]->loopDirection) t = 1.0 - time;
			}
      
			//translation__________________________________________________________
			if(messages[i]->id == OF_TRANSLATE){
				if(curTime >= startTime){
					if(!messages[i]->isRunning){
						//set start values once
						ofVec3f *vec = (ofVec3f *)messages[i]->baseStartVals;
						if(vec){
							if(vec->x == OF_RELATIVE_VAL) x = xyz.x;
							else x = vec->x;
							if(vec->y == OF_RELATIVE_VAL) y = xyz.y;
							else y = vec->y;
							if(vec->z == OF_RELATIVE_VAL) z = xyz.z;
							else z = vec->z;
              
							messages[i]->setStartVals(x,y,z);
							//printf("message start vals = %f, %f, %f\n", x,y,z);
						}
            
						//set end values once
						ofVec3f *vecEnd = (ofVec3f *)messages[i]->baseEndVals;
						if(vecEnd){
							if(vecEnd->x == OF_RELATIVE_VAL) x = xyz.x;
							else x = vecEnd->x;
							if(vecEnd->y == OF_RELATIVE_VAL) y = xyz.y;
							else y = vecEnd->y;
							if(vecEnd->z == OF_RELATIVE_VAL) z = xyz.z;
							else z = vecEnd->z;
              
							messages[i]->setEndVals(x,y,z);
							//printf("message end vals = %f, %f, %f\n", x,y,z);
						}
            
						/*
             printf("translate start Vals = %f, %f, %f\n", x,y,z);
             printf("translate end Vals = %f, %f, %f\n",
             ((ofVec3f *)messages[i]->vals)->x,
             ((ofVec3f *)messages[i]->vals)->y,
             ((ofVec3f *)messages[i]->vals)->z);
             */
            
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setTrans((1-t)*((ofVec3f *)messages[i]->startVals)->x + t*((ofVec3f *)messages[i]->endVals)->x,
                     (1-t)*((ofVec3f *)messages[i]->startVals)->y + t*((ofVec3f *)messages[i]->endVals)->y,
                     (1-t)*((ofVec3f *)messages[i]->startVals)->z + t*((ofVec3f *)messages[i]->endVals)->z);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f trans = ofxMessage::bezier(t, messages[i]->pathPoints);
						setTrans(trans.x, trans.y, trans.z);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f trans = ofxMessage::spline(t, messages[i]->pathPoints);
						setTrans(trans.x, trans.y, trans.z);
					}
          
				}
			}
			//rotation_____________________________________________________________
			else if(messages[i]->id == OF_ROTATE){
				if(curTime >= startTime){
					if(!messages[i]->isRunning){
						//set start values once
						ofVec3f *vec = (ofVec3f *)messages[i]->baseStartVals;
						if(vec){
							if(vec->x == OF_RELATIVE_VAL) x = xyzRot.x;
							else x = vec->x;
							if(vec->y == OF_RELATIVE_VAL) y = xyzRot.y;
							else y = vec->y;
							if(vec->z == OF_RELATIVE_VAL) z = xyzRot.z;
							else z = vec->z;
              
							messages[i]->setStartVals(x, y, z);
						}
            
						//set end values once
						ofVec3f *vecEnd = (ofVec3f *)messages[i]->baseEndVals;
						if(vecEnd){
							if(vecEnd->x == OF_RELATIVE_VAL) x = xyzRot.x;
							else x = vecEnd->x;
							if(vecEnd->y == OF_RELATIVE_VAL) y = xyzRot.y;
							else y = vecEnd->y;
							if(vecEnd->z == OF_RELATIVE_VAL) z = xyzRot.z;
							else z = vecEnd->z;
              
							messages[i]->setEndVals(x,y,z);
						}
            
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setRot((1-t)*((ofVec3f *)messages[i]->startVals)->x + t*((ofVec3f *)messages[i]->endVals)->x,
                   (1-t)*((ofVec3f *)messages[i]->startVals)->y + t*((ofVec3f *)messages[i]->endVals)->y,
                   (1-t)*((ofVec3f *)messages[i]->startVals)->z + t*((ofVec3f *)messages[i]->endVals)->z);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f rot = ofxMessage::bezier(t, messages[i]->pathPoints);
						setRot(rot.x, rot.y, rot.z);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f rot = ofxMessage::spline(t, messages[i]->pathPoints);
						setRot(rot.x, rot.y, rot.z);
					}
				}
			}
			//scaling_______________________________________________________________
			else if(messages[i]->id == OF_SCALE){
				//printf("startTime = %f\n", startTime);
				if(curTime >= startTime){
					//printf("doing message %f\n", curTime);
					if(!messages[i]->isRunning){
						//set start values once
						float *v = (float *)messages[i]->baseStartVals;
						if(v){
							if(v[0] == OF_RELATIVE_VAL) x = scale.x;
							else x = v[0];
              
							messages[i]->setStartVals(x);
						}
            
						//set end values once
						float *vEnd = (float *)messages[i]->baseEndVals;
						if(vEnd){
							if(vEnd[0] == OF_RELATIVE_VAL) x = scale.x;
							else x = vEnd[0];
              
							messages[i]->setEndVals(x);
						}
            
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setScale((1-t)*((float *)messages[i]->startVals)[0] + t*((float *)messages[i]->endVals)[0]);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f s = ofxMessage::bezier(t, messages[i]->pathPoints);
						setScale(s.x);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f s = ofxMessage::spline(t, messages[i]->pathPoints);
						setScale(s.x);
					}
				}
			}
			//scaling in 3 dimensions differently ___________________________________
			else if(messages[i]->id == OF_SCALE3){
				if(curTime >= startTime){
					if(!messages[i]->isRunning){
						//set start avlues once
						ofVec3f *vec = (ofVec3f *)messages[i]->baseStartVals;
						if(vec){
							if(vec->x == OF_RELATIVE_VAL) x = scale.x;
							else x = vec->x;
							if(vec->y == OF_RELATIVE_VAL) y = scale.y;
							else y = vec->y;
							if(vec->z == OF_RELATIVE_VAL) z = scale.z;
							else z = vec->z;
              
							messages[i]->setStartVals(x, y, z);
						}
            
						//set end values once
						ofVec3f *vecEnd = (ofVec3f *)messages[i]->baseEndVals;
						if(vecEnd){
							if(vecEnd->x == OF_RELATIVE_VAL) x = scale.x;
							else x = vecEnd->x;
							if(vecEnd->y == OF_RELATIVE_VAL) y = scale.y;
							else y = vecEnd->y;
							if(vecEnd->z == OF_RELATIVE_VAL) z = scale.z;
							else z = vecEnd->z;
              
							messages[i]->setEndVals(x,y,z);
						}
            
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setScale((1-t)*((ofVec3f *)messages[i]->startVals)->x + t*((ofVec3f *)messages[i]->endVals)->x,
                     (1-t)*((ofVec3f *)messages[i]->startVals)->y + t*((ofVec3f *)messages[i]->endVals)->y,
                     (1-t)*((ofVec3f *)messages[i]->startVals)->z + t*((ofVec3f *)messages[i]->endVals)->z);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f s = ofxMessage::bezier(t, messages[i]->pathPoints);
						setScale(s.x, s.y, s.z);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f s = ofxMessage::spline(t, messages[i]->pathPoints);
						setScale(s.x, s.y, s.z);
					}
				}
			}
			//color _________________________________________________________________
			else if(messages[i]->id == OF_SETCOLOR){
				if(curTime >= startTime){
					if(!messages[i]->isRunning){
						//set start values once
						ofVec3f *vec = (ofVec3f *)messages[i]->baseStartVals;
						if(vec){
							if(vec->x == OF_RELATIVE_VAL) x = material->getColorVec4f().x;
							else x = vec->x;
							if(vec->y == OF_RELATIVE_VAL) y = material->getColorVec4f().y;
							else y = vec->y;
							if(vec->z == OF_RELATIVE_VAL) z = material->getColorVec4f().z;
							else z = vec->z;
              
							messages[i]->setStartVals(x, y, z);
						}
            
						//set end values once
						ofVec3f *vecEnd = (ofVec3f *)messages[i]->baseEndVals;
						if(vecEnd){
							if(vecEnd->x == OF_RELATIVE_VAL) x = material->getColorVec4f().x;
							else x = vecEnd->x;
							if(vecEnd->y == OF_RELATIVE_VAL) y = material->getColorVec4f().y;
							else y = vecEnd->y;
							if(vecEnd->z == OF_RELATIVE_VAL) z = material->getColorVec4f().z;
							else z = vecEnd->z;
              
							messages[i]->setEndVals(x,y,z);
						}
            
						//printf("color startvals = %f, %f , %f\n", x,y,z);
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setColor((1-t)*((ofVec3f *)messages[i]->startVals)->x + t*((ofVec3f *)messages[i]->endVals)->x,
                     (1-t)*((ofVec3f *)messages[i]->startVals)->y + t*((ofVec3f *)messages[i]->endVals)->y,
                     (1-t)*((ofVec3f *)messages[i]->startVals)->z + t*((ofVec3f *)messages[i]->endVals)->z);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f c = ofxMessage::bezier(t, messages[i]->pathPoints);
						setColor(c.x, c.y, c.z);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f c = ofxMessage::spline(t, messages[i]->pathPoints);
						setColor(c.x, c.y, c.z);
					}
				}
			}      // color with alpha channel
      else if(messages[i]->id == OF_SETCOLOR4){
				if(curTime >= startTime){
					if(!messages[i]->isRunning){
						//set start values once
						ofVec4f *vec = (ofVec4f *)messages[i]->baseStartVals;
						if(vec){
							if(vec->x == OF_RELATIVE_VAL) x = material->getColorVec4f().x;
							else x = vec->x;
							if(vec->y == OF_RELATIVE_VAL) y = material->getColorVec4f().y;
							else y = vec->y;
							if(vec->z == OF_RELATIVE_VAL) z = material->getColorVec4f().z;
							else z = vec->z;
              if(vec->w == OF_RELATIVE_VAL) w = material->getColorVec4f().w;
							else w = vec->w;
              
							messages[i]->setStartVals(x, y, z, w);
						}
            
						//set end values once
						ofVec4f *vecEnd = (ofVec4f *)messages[i]->baseEndVals;
						if(vecEnd){
							if(vecEnd->x == OF_RELATIVE_VAL) x = material->getColorVec4f().x;
							else x = vecEnd->x;
							if(vecEnd->y == OF_RELATIVE_VAL) y = material->getColorVec4f().y;
							else y = vecEnd->y;
							if(vecEnd->z == OF_RELATIVE_VAL) z = material->getColorVec4f().z;
							else z = vecEnd->z;
              if(vecEnd->w == OF_RELATIVE_VAL) w = material->getColorVec4f().w;
							else w = vecEnd->w;
              
							messages[i]->setEndVals(x,y,z,w);
						}
            
						//printf("color startvals = %f, %f , %f\n", x,y,z);
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setColor((1-t)*((ofVec4f *)messages[i]->startVals)->x + t*((ofVec4f *)messages[i]->endVals)->x,
                     (1-t)*((ofVec4f *)messages[i]->startVals)->y + t*((ofVec4f *)messages[i]->endVals)->y,
                     (1-t)*((ofVec4f *)messages[i]->startVals)->z + t*((ofVec4f *)messages[i]->endVals)->z,
                     (1-t)*((ofVec4f *)messages[i]->startVals)->w + t*((ofVec4f *)messages[i]->endVals)->w);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f c = ofxMessage::bezier(t, messages[i]->pathPoints);
						setColor(c.x, c.y, c.z, c.w);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f c = ofxMessage::spline(t, messages[i]->pathPoints);
						setColor(c.x, c.y, c.z, c.w);
					}
				}
			}
			//alpha__________________________________________________________________
			else if(messages[i]->id == OF_SETALPHA){
				if(curTime >= startTime){
					if(!messages[i]->isRunning){
						//set start values once
						float *v = (float *)messages[i]->baseStartVals;
						if(v){
							if(v[0] == OF_RELATIVE_VAL) x = material->getColorVec4f().w;
							else x = v[0];
              
							messages[i]->setStartVals(x);
						}
            
						//set end values once
						float *vEnd = (float *)messages[i]->baseEndVals;
						if(vEnd){
							if(vEnd[0] == OF_RELATIVE_VAL) x = material->getColorVec4f().w;
							else x = vEnd[0];
              
							messages[i]->setEndVals(x);
						}
            
						messages[i]->isRunning = true;
					}
					//update value
					if(messages[i]->path == OF_LINEAR_PATH){
						setAlpha((1-t)*((float *)messages[i]->startVals)[0] + t*((float *)messages[i]->endVals)[0]);
					}else if(messages[i]->path == OF_BEZIER_PATH){
						ofVec4f s = ofxMessage::bezier(t, messages[i]->pathPoints);
						setAlpha(s.x);
					}else if(messages[i]->path == OF_SPLINE_PATH){
						ofVec4f s = ofxMessage::spline(t, messages[i]->pathPoints);
						setAlpha(s.x);
					}
				}
			}
			//show____________________________________________________________________
			else if(messages[i]->id == OF_SHOW){
				if(curTime >= startTime){
					show();
					messages[i]->isEnabled = false;
				}
			}
			//hide____________________________________________________________________
			else if(messages[i]->id == OF_HIDE){
				if(curTime >= startTime){
          hide();
					messages[i]->isEnabled = false;
				}
			}
      
			//function________________________________________________________________
			else if(messages[i]->id == OF_FUNCTION){
				if(curTime >= startTime){
          messages[i]->functionPtr(messages[i]->startVals);
					messages[i]->isEnabled = false;
				}
			}
      
      
			//cleanup messages _____________________________________________________________________________________
			//if the message is done and no longer needed, delete it
			if(time == 1.0){ //only delete it when it's reached completion
				messages[i]->isEnabled = false;
				messages[i]->isRunning = false;
        
				if(messages[i]->autoDelete){
					deleteMessage(messages[i]);
				}
        
				if(i < messages.size()){	//just in case a message just got deleted above
					//handle special looping behaviors
					if(messages[i]->playMode == OF_LOOP_PLAY){
						messages[i]->isEnabled = true;
						messages[i]->isRunning = false;
						messages[i]->setStartTime(curTime);
					}
					else if(messages[i]->playMode == OF_LOOP_PALINDROME_PLAY){
						messages[i]->loopDirection = !messages[i]->loopDirection;
						messages[i]->isEnabled = true;
						messages[i]->isRunning = false;
						messages[i]->setStartTime(curTime);
					}
				}
			}
		}
	}
}
Beispiel #3
0
void MainWidget::triangleReceiver()
{
    show();
}
Beispiel #4
0
 Dialog::Result Dialog::show (
     const Window& parent, const Template& template_
     )
 {
     return (show(parent, template_, &::DialogProcedure));
 }
Beispiel #5
0
BitcoinGUI::BitcoinGUI(QWidget *parent) :
    QMainWindow(parent),
    clientModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0),
    prevBlocks(0)
{
    restoreWindowGeometry();
    setWindowTitle(tr("Czarcoin") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
    QApplication::setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Create wallet frame and make it the central widget
    walletFrame = new WalletFrame(this);
    setCentralWidget(walletFrame);

    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    // Needs walletFrame to be initialized
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create system tray icon and notification
    createTrayIcon();

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setMinimumWidth(56);
    frameBlocks->setMaximumWidth(56);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = QApplication::style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
    // prevents an oben debug window from becoming stuck/unusable on client shutdown
    connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));

    // Install event filter to be able to catch status tip events (QEvent::StatusTip)
    this->installEventFilter(this);

    // Initially wallet actions should be disabled
    setWalletActionsEnabled(false);
}
Beispiel #6
0
        void EtherSceneController::LoadClassicLoginWidget(EtherLoginNotifier *login_notifier, bool default_view, QMap<QString,QString> stored_login_data)
        {
            // Classical login widgets
            classical_login_widget_ = new CoreUi::Classical::ClassicalLoginWidget(login_notifier, stored_login_data);
            classic_login_proxy_ = new QGraphicsProxyWidget(0, Qt::Widget);
            classic_login_proxy_->setZValue(100);
            classic_login_proxy_->setWidget(classical_login_widget_);

            // Default to correct view
            if (default_view)
                classic_login_proxy_->show();
            else
                classic_login_proxy_->hide();
            scene_->addItem(classic_login_proxy_);

            // Classical login widget control button
            QPushButton *classical_login_button = new QPushButton("Classic Mode");
            classical_login_button->setStyleSheet("border: 1px solid rgba(255,255,255,100); color: white; background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(18, 18, 18, 255), stop:1 rgba(54, 54, 54, 255)); padding: 10px;");
            classical_login_button->setFont(QFont("Narkisim", 12));

            QGraphicsProxyWidget *classic_login_button_proxy_ = new QGraphicsProxyWidget(0, Qt::Widget);
            classic_login_button_proxy_->setWidget(classical_login_button);
            
            layout_manager_->AddCornerAnchor(classic_login_button_proxy_, Qt::TopRightCorner, Qt::TopRightCorner);

            // Connect classic login signals/slots
            connect(classical_login_button, SIGNAL( clicked() ), classical_login_widget_, SLOT( show() ));
            connect(classical_login_button, SIGNAL( clicked() ), SLOT( StopActiveItemAnimations() ));
            connect(classical_login_widget_, SIGNAL( AppExitRequested() ), SLOT( TryExitApplication() ));
        }
Beispiel #7
0
BitcoinGUI::BitcoinGUI(QWidget *parent):
    QMainWindow(parent),
    clientModel(0),
    walletModel(0),
    encryptWalletAction(0),
    unlockForMintingAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0)
{
    resize(850, 550);
    setWindowTitle(tr("Minermind Wallet"));
#ifndef Q_WS_MAC
    setWindowIcon(QIcon(":icons/minermind_icon"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create the tray icon (or setup the dock icon)
    createTrayIcon();

    // Create tabs
    overviewPage = new OverviewPage();

    transactionsPage = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout();
    transactionView = new TransactionView(this);
    vbox->addWidget(transactionView);
    transactionsPage->setLayout(vbox);

    mintingPage = new QWidget(this);
    QVBoxLayout *vboxMinting = new QVBoxLayout();
    mintingView = new MintingView(this);
    vboxMinting->addWidget(mintingView);
    mintingPage->setLayout(vboxMinting);

    addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);

    receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);

    sendCoinsPage = new SendCoinsDialog(this);

    messagePage = new SignVerifyMessageDialog(this);

    multisigPage = new MultisigDialog(this);

    centralWidget = new QStackedWidget(this);
    centralWidget->addWidget(overviewPage);
    centralWidget->addWidget(transactionsPage);
    centralWidget->addWidget(mintingPage);
    centralWidget->addWidget(addressBookPage);
    centralWidget->addWidget(receiveCoinsPage);
    centralWidget->addWidget(sendCoinsPage);
#ifdef FIRST_CLASS_MESSAGING
    centralWidget->addWidget(messagePage);
#endif
    setCentralWidget(centralWidget);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setMinimumWidth(56);
    frameBlocks->setMaximumWidth(56);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);

    // Clicking on a transaction on the overview page simply sends you to transaction history page
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));

    // Doubleclicking on a transaction on the transaction history page shows details
    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    gotoOverviewPage();
}
Beispiel #8
0
std::string instrToString(PC it, Either<const Unit*, const UnitEmitter*> u) {
  std::string out;
  PC iStart = it;
  Op op = decode_op(it);

  auto readRATA = [&] {
    if (auto unit = u.left()) {
      auto const rat = decodeRAT(unit, it);
      folly::format(&out, " {}", show(rat));
      return;
    }

    auto const pc = it;
    it += encodedRATSize(pc);
    out += " <RepoAuthType>";
  };

  auto offsetOf = [u](PC pc) {
    return u.match(
      [pc](const Unit* u) { return u->offsetOf(pc); },
      [pc](const UnitEmitter* ue) { return ue->offsetOf(pc); }
    );
  };

  auto lookupLitstrId = [u](Id id) {
    return u.match(
      [id](const Unit* u) { return u->lookupLitstrId(id); },
      [id](const UnitEmitter* ue) { return ue->lookupLitstr(id); }
    );
  };

  auto lookupArrayId = [u](Id id) {
    return u.match(
      [id](const Unit* u) { return u->lookupArrayId(id); },
      [id](const UnitEmitter* ue) { return ue->lookupArray(id); }
    );
  };

  switch (op) {

#define READ(t) folly::format(&out, " {}", *((t*)&*it)); it += sizeof(t)

#define READOFF() do {                                          \
  Offset _value = *(Offset*)it;                                 \
  folly::format(&out, " {}", _value);                           \
  if (u != nullptr) {                                           \
    folly::format(&out, " ({})", offsetOf(iStart + _value));    \
  }                                                             \
  it += sizeof(Offset);                                         \
} while (false)

#define READV() folly::format(&out, " {}", decode_iva(it));

#define READLA() folly::format(&out, " L:{}", decode_iva(it));

#define READIVA() do {                                          \
  auto imm = decode_iva(it);                                    \
  folly::format(&out, " {}", imm);                              \
  immIdx++;                                                     \
} while (false)

#define READOA(type) do {                               \
  auto const immVal = static_cast<type>(                \
    *reinterpret_cast<const uint8_t*>(it)               \
  );                                                    \
  it += sizeof(unsigned char);                          \
  folly::format(&out, " {}", subopToName(immVal));      \
} while (false)

#define READLITSTR(sep) do {                                    \
  Id id = decode_raw<Id>(it);                                   \
  if (id < 0) {                                                 \
    assertx(op == OpSSwitch);                                    \
    folly::format(&out, "{}-", sep);                            \
  } else {                                                      \
    auto const sd = lookupLitstrId(id);                         \
    folly::format(&out, "{}\"{}\"", sep,                        \
                  escapeStringForCPP(sd->data(), sd->size()));  \
  }                                                             \
} while (false)

#define READSVEC() do {                                 \
  int sz = decode_iva(it);                              \
  out += " <";                                          \
  const char* sep = "";                                 \
  for (int i = 0; i < sz; ++i) {                        \
    out += sep;                                         \
    if (op == OpSSwitch) {                              \
      READLITSTR("");                                   \
      out += ":";                                       \
    }                                                   \
    Offset o = decode_raw<Offset>(it);                  \
    folly::format(&out, "{}", offsetOf(iStart + o));    \
    sep = " ";                                          \
  }                                                     \
  out += ">";                                           \
} while (false)

#define READI32VEC() do {                                      \
  int sz = decode_iva(it);                                     \
  out += " <";                                                 \
  const char* sep = "";                                        \
  for (int i = 0; i < sz; ++i) {                               \
    folly::format(&out, "{}{}", sep, decode_raw<uint32_t>(it));\
    sep = ", ";                                                \
  }                                                            \
  out += ">";                                                  \
} while (false)

#define READBOOLVEC() do {                                     \
  int sz = decode_iva(it);                                     \
  uint8_t tmp = 0;                                             \
  out += " \"";                                                \
  for (int i = 0; i < sz; ++i) {                               \
    if (i % 8 == 0) tmp = decode_raw<uint8_t>(it);             \
    out += ((tmp >> (i % 8)) & 1) ? "1" : "0";                 \
  }                                                            \
  out += "\"";                                                 \
} while (false)

#define READITERTAB() do {                              \
  auto const sz = decode_iva(it);                       \
  out += " <";                                          \
  const char* sep = "";                                 \
  for (int i = 0; i < sz; ++i) {                        \
    out += sep;                                         \
    auto const k = (IterKind)decode_iva(it);            \
    switch (k) {                                        \
      case KindOfIter:  out += "(Iter) ";  break;       \
      case KindOfMIter: out += "(MIter) "; break;       \
      case KindOfCIter: out += "(CIter) "; break;       \
      case KindOfLIter: out += "(LIter) "; break;       \
    }                                                   \
    folly::format(&out, "{}", decode_iva(it));           \
    if (k == KindOfLIter) {                             \
      folly::format(&out, " L:{}", decode_iva(it));     \
    }                                                   \
    sep = ", ";                                         \
  }                                                     \
  out += ">";                                           \
} while (false)

#define ONE(a) H_##a
#define TWO(a, b) H_##a; H_##b
#define THREE(a, b, c) H_##a; H_##b; H_##c;
#define FOUR(a, b, c, d) H_##a; H_##b; H_##c; H_##d;
#define FIVE(a, b, c, d, e) H_##a; H_##b; H_##c; H_##d; H_##e;
#define NA
#define H_BLA READSVEC()
#define H_SLA READSVEC()
#define H_ILA READITERTAB()
#define H_I32LA READI32VEC()
#define H_BLLA READBOOLVEC()
#define H_IVA READIVA()
#define H_I64A READ(int64_t)
#define H_LA READLA()
#define H_IA READV()
#define H_CAR READV()
#define H_CAW READV()
#define H_DA READ(double)
#define H_BA READOFF()
#define H_OA(type) READOA(type)
#define H_SA READLITSTR(" ")
#define H_RATA readRATA()
#define H_AA do {                                                \
  out += ' ';                                                    \
  staticArrayStreamer(lookupArrayId(decode_raw<Id>(it)), out);   \
} while (false)
#define H_VSA do {                                      \
  int sz = decode_iva(it);                              \
  out += " <";                                          \
  for (int i = 0; i < sz; ++i) {                        \
    H_SA;                                               \
  }                                                     \
  out += " >";                                          \
} while (false)
#define H_KA (out += ' ', out += show(decode_member_key(it, u)))
#define H_LAR (out += ' ', out += show(decodeLocalRange(it)))
#define H_FCA (out += ' ', out += show(decodeFCallArgs(it)))

#define O(name, imm, push, pop, flags)    \
  case Op##name: {                        \
    out += #name;                         \
    UNUSED unsigned immIdx = 0;           \
    imm;                                  \
    break;                                \
  }
OPCODES
#undef O
#undef READ
#undef READV
#undef READLA
#undef ONE
#undef TWO
#undef THREE
#undef FOUR
#undef FIVE
#undef NA
#undef H_BLA
#undef H_SLA
#undef H_ILA
#undef H_I32LA
#undef H_BLLA
#undef H_IVA
#undef H_I64A
#undef H_LA
#undef H_IA
#undef H_CAR
#undef H_CAW
#undef H_DA
#undef H_BA
#undef H_OA
#undef H_SA
#undef H_AA
#undef H_VSA
#undef H_KA
#undef H_LAR
#undef H_FCA
    default: assertx(false);
  };
  return out;
}
Beispiel #9
0
void CFinder::Open()
{
	show();
	m_pSearch->setFocus(Qt::OtherFocusReason);
	OnUpdate();
}
AReViBalloon::AReViBalloon(ArCW &arCW, string text, double height, double width, double posX, double posY, double posZ, double /*oriZ*/)
	:	Object3D(arCW)
{
	setTransient(false);
	/* Instanciations */
	_mesh = Mesh3D::NEW();
	_shape = Shape3D::NEW();
	cerr << height << " "<<width << endl;
	_ctexture = CairoTexture::NEW(1024*height, 1024* width);
	_textManager=CairoTextManager::NEW(_ctexture);
	_textManager->setFontSize(200);

	/* Configuration */ 
	_ctexture->setLineWidth(12);
	_ctexture->setLineCap(CairoTexture::LINE_CAP_ROUND);

	double sx = height / 2;
	double sy = width / 2;

	/* Création mesh */
	_mesh->accessVertices().push_back(Util3D::Dbl3(-sx,-sy,0));
	_mesh->accessVertices().push_back(Util3D::Dbl3(+sx,-sy,0));
	_mesh->accessVertices().push_back(Util3D::Dbl3(+sx,+sy,0));
	_mesh->accessVertices().push_back(Util3D::Dbl3(-sx,+sy,0));
	_mesh->accessTextures().push_back(Util3D::Dbl2(0.0,0.0));
	_mesh->accessTextures().push_back(Util3D::Dbl2(1.0,0.0));
	_mesh->accessTextures().push_back(Util3D::Dbl2(1.0,1.0));
	_mesh->accessTextures().push_back(Util3D::Dbl2(0.0,1.0));
	_mesh->accessVertexFaces().push_back(Util3D::Face(0,1,3));
	_mesh->accessVertexFaces().push_back(Util3D::Face(1,2,3));
	_mesh->computeDefaultNormals(true);
	if (!_mesh->applyChanges(true)) 
		cerr << "ERREUR MESH ...." << endl;

	/* Orientation correcte mesh */
	ArRef<Transform3D> tr = calculateTransformation (1.57,1.57,0);

	_mesh->writeTransformation(tr);

	/* Lien entre objets */
	_shape->addRootPart(_mesh);
	_mesh->setTexture(_ctexture);
	_mesh->setTextureRepeat(false,false);
	
	/*----Dessin de la bulle et du texte----*/
	_text = text;

	/*-------Lien avec la shape--------*/
	setShape(_shape); 
	_shape->setBillboard(true,false);
	
	/*--------Placement de la bulle au-dessus du personnage----------*/
	translate(posX,posY,posZ);
	
	_light=Light3D::NEW();
	_light->setDirectional(false);
//	_light->setLocation(shared_dynamic_cast<AReViWindow3D>(AReViMascaretApplication::getInstance()->accessWindow())->getAReViViewer());
//	_light->attachTo(shared_dynamic_cast<AReViWindow3D>(AReViMascaretApplication::getInstance()->accessWindow())->getAReViViewer());
    vector< shared_ptr<IEHA::Window3D> > windows = AReViMascaretApplication::getInstance()->getWindows();
    for(int i = 0; i < windows.size(); i++)
    {
        _light->setLocation(shared_dynamic_cast<AReViWindow3D>(windows[i])->getAReViViewer());
        _light->attachTo(shared_dynamic_cast<AReViWindow3D>(windows[i])->getAReViViewer());
    }

	/*--------Affichage de la bulle------*/
	show();

}
Beispiel #11
0
void PropertiesDock::bringToFront()
{
    show();
    raise();
    mPropertyBrowser->setFocus();
}
Beispiel #12
0
	Widget::Widget(const IntCoord& _coord, Align _align, const WidgetSkinInfoPtr _info, CroppedRectanglePtr _parent, WidgetCreator * _creator, const Ogre::String & _name) :
		CroppedRectangleInterface(IntCoord(_coord.point(), _info->getSize()), _align, _parent), // размер по скину
		mOwner(static_cast<Widget*>(_parent)),
		UserData(),
		LayerItem(),
		mStateInfo(_info->getStateInfo()),
		mMaskPeekInfo(_info->getMask()),
		mText(null),
		mEnabled(true),
		mVisible(true),
		mInheritedShow(true),
		mAlpha(ALPHA_MIN),
		mName(_name),
		mTexture(_info->getTextureName()),
		mMainSkin(null),
		mWidgetCreator(_creator),
		mInheritsAlpha(true),
		mNeedKeyFocus(false),
		mNeedMouseFocus(true),
		mNeedDragDrop(false),
		mWidgetClient(null)
	{
		// корректируем абсолютные координаты
		mAbsolutePosition = _coord.point();
		if (null != mParent) mAbsolutePosition += mParent->getAbsolutePosition();

		// имя отсылателя сообщений
		mWidgetEventSender = this;

		// загружаем кирпичики виджета
		SubWidgetManager & manager = SubWidgetManager::getInstance();
		for (VectorSubWidgetInfo::const_iterator iter =_info->getBasisInfo().begin(); iter!=_info->getBasisInfo().end(); ++iter) {
			CroppedRectangleInterface * sub = manager.createSubWidget(*iter, this);
			mSubSkinChild.push_back(sub);
			if (sub->_isText()) mText = static_cast<SubWidgetTextInterfacePtr>(sub);
			else if (null == mMainSkin) mMainSkin = sub;
		}

		if (false == isRootWidget()) {
			// если отец уже приаттачен, то и мы аттачимся ??? проверить что уже аттачиться при сет текстуре
			if ((null != getParent()->getLayerItemKeeper())) _attachToLayerItemKeeper(getParent()->getLayerItemKeeper());

			// проверяем наследуемую скрытость
			if ((!mParent->isShow()) || (!getParent()->_isInheritedShow())) {
				mInheritedShow = false;
				// скрываем только саб скины, детей у нас еще нет
				for (VectorCroppedRectanglePtr::iterator skin = mSubSkinChild.begin(); skin != mSubSkinChild.end(); ++skin) (*skin)->hide();
			}
		}

		// этот стиль есть всегда, даже если создатель не хотел его
		setState("normal");

		// парсим свойства
		const MapString & param = _info->getParams();
		if (false == param.empty()) {
			MapString::const_iterator iter = param.find("FontName");
			if (iter != param.end()) setFontName(iter->second);
			iter = param.find("FontHeight");
			if (iter != param.end()) setFontHeight(utility::parseInt(iter->second));
			iter = param.find("NeedKey");
			if (iter != param.end()) setNeedKeyFocus(iter->second == "true");
			iter = param.find("NeedMouse");
			if (iter != param.end()) setNeedMouseFocus(iter->second == "true");
			iter = param.find("AlignText");
			if (iter != param.end()) setTextAlign(SkinManager::parseAlign(iter->second));
			iter = param.find("Colour");
			if (iter != param.end()) setColour(utility::parseColour(iter->second));
			iter = param.find("Pointer");
			if (iter != param.end()) mPointer = iter->second;
			iter = param.find("Show");
			if (iter != param.end()) {
				if (utility::parseBool(iter->second)) show();
				else hide();
			}
		}

		// выставляем альфу, корректировка по отцу автоматически
		setAlpha(ALPHA_MAX);

		// создаем детей
		const VectorChildSkinInfo& child = _info->getChild();
		for (VectorChildSkinInfo::const_iterator iter=child.begin(); iter!=child.end(); ++iter) {
			WidgetPtr widget = createWidgetT(iter->type, iter->skin, iter->coord, iter->align);
			widget->_setInternalString(iter->name);
			// заполняем UserString пропертями
			for (MapString::const_iterator prop=iter->params.begin(); prop!=iter->params.end(); ++prop) {
				widget->setUserString(prop->first, prop->second);
			}
		}

		// а вот теперь нормальный размер
		setSize(_coord.size());

	}
Beispiel #13
0
int main(int argc, char* argv[]) {
    int opt;
    auto pss_sort = [](const Vma& a, const Vma& b) {
        uint64_t pss_a = show_wss ? a.wss.pss : a.usage.pss;
        uint64_t pss_b = show_wss ? b.wss.pss : b.usage.pss;
        return pss_a > pss_b;
    };

    auto uss_sort = [](const Vma& a, const Vma& b) {
        uint64_t uss_a = show_wss ? a.wss.uss : a.usage.uss;
        uint64_t uss_b = show_wss ? b.wss.uss : b.usage.uss;
        return uss_a > uss_b;
    };

    std::function<bool(const Vma& a, const Vma& b)> sort_func = nullptr;
    while ((opt = getopt(argc, argv, "himpuWw")) != -1) {
        switch (opt) {
            case 'h':
                hide_zeroes = true;
                break;
            case 'i':
                // TODO: libmeminfo doesn't support the flag to chose
                // between idle page tracking vs clear_refs. So for now,
                // this flag is unused and the library defaults to using
                // /proc/<pid>/clear_refs for finding the working set.
                use_pageidle = true;
                break;
            case 'm':
                // this is the default
                break;
            case 'p':
                sort_func = pss_sort;
                break;
            case 'u':
                sort_func = uss_sort;
                break;
            case 'W':
                reset_wss = true;
                break;
            case 'w':
                show_wss = true;
                break;
            case '?':
                usage(argv[0]);
                return 0;
            default:
                abort();
        }
    }

    if (optind != (argc - 1)) {
        fprintf(stderr, "Need exactly one pid at the end\n");
        usage(argv[0]);
        exit(EXIT_FAILURE);
    }

    pid_t pid = atoi(argv[optind]);
    if (pid == 0) {
        std::cerr << "Invalid process id" << std::endl;
        exit(EXIT_FAILURE);
    }

    if (reset_wss) {
        if (!ProcMemInfo::ResetWorkingSet(pid)) {
            std::cerr << "Failed to reset working set of pid : " << pid << std::endl;
            exit(EXIT_FAILURE);
        }
        return 0;
    }

    ProcMemInfo proc(pid, show_wss);
    const MemUsage& proc_stats = show_wss ? proc.Wss() : proc.Usage();
    std::vector<Vma> maps(proc.Maps());
    if (sort_func != nullptr) {
        std::sort(maps.begin(), maps.end(), sort_func);
    }

    return show(proc_stats, maps);
}
Beispiel #14
0
MainWindow::MainWindow(QWidget *parent) :
    ParentWindow(parent),
    m_page(0),
    m_webView(new QWebView),
#ifndef MEEGO_EDITION_HARMATTAN
    m_actionMinimizeToTray(new QAction(i18n("&Minimize to Tray"), this)),
#endif
    m_inspector(0),
    m_fontDB(),
    m_signIn(false),
    m_firstLoad(true)
{
#ifdef Q_OS_UNIX
    chdir(PREFIX);
#endif
    setWindowTitle(i18n("Hotot"));
    setWindowIcon(QIcon::fromTheme("hotot_qt", QIcon("share/hotot/image/ic64_hotot.png")));
    qApp->setWindowIcon(QIcon::fromTheme("hotot_qt", QIcon("share/hotot/image/ic64_hotot.png")));
#ifndef MEEGO_EDITION_HARMATTAN
    this->resize(QSize(640, 480));
    this->setCentralWidget(m_webView);
    this->setMinimumSize(QSize(400, 400));
#else
    MApplicationPage* page = new MApplicationPage;
    page->setCentralWidget(m_webView);
    page->setComponentsDisplayMode(MApplicationPage::AllComponents,
                                           MApplicationPageModel::Hide);
    page->setAutoMarginsForComponentsEnabled(false);
    page->resize(page->exposedContentRect().size());
    page->appear(this, MSceneWindow::DestroyWhenDone);
    page->setPannable(false);
#endif

    m_menu = new QMenu(this);

    m_actionCompose = new QAction(QIcon(), i18n("&Compose"), this);
    connect(m_actionCompose, SIGNAL(triggered()), this, SLOT(compose()));
    m_menu->addAction(m_actionCompose);
    m_actionCompose->setVisible(false);
#ifndef MEEGO_EDITION_HARMATTAN
    QSettings settings("hotot-qt", "hotot");
    m_actionMinimizeToTray->setCheckable(true);
    m_actionMinimizeToTray->setChecked(settings.value("minimizeToTray", false).toBool());
    connect(m_actionMinimizeToTray, SIGNAL(toggled(bool)), this, SLOT(toggleMinimizeToTray(bool)));
    m_menu->addAction(m_actionMinimizeToTray);
#endif
    m_actionShow = new QAction(QIcon(), i18n("Show &MainWindow"), this);
    connect(m_actionShow, SIGNAL(triggered()), this, SLOT(show()));
    m_menu->addAction(m_actionShow);

    m_actionExit = new QAction(QIcon::fromTheme("application-exit"), i18n("&Exit"), this);
    m_actionExit->setShortcut(QKeySequence::Quit);
    connect(m_actionExit, SIGNAL(triggered()), this, SLOT(exit()));
    m_menu->addAction(m_actionExit);

    m_actionDev = new QAction(QIcon::fromTheme("configure"), i18n("&Developer Tool"), this);
    connect(m_actionDev, SIGNAL(triggered()), this, SLOT(showDeveloperTool()));

#ifdef HAVE_KDE
    m_tray = new KDETrayBackend(this);
#else
    m_tray = new QtTrayBackend(this);
#endif

    m_tray->setContextMenu(m_menu);
#ifndef MEEGO_EDITION_HARMATTAN
    addAction(m_actionExit);
#endif

    m_page = new HototWebPage(this);
#ifdef HAVE_KDE
    m_page->setNetworkAccessManager(new KIO::Integration::AccessManager(m_page));
#endif

#ifdef Q_OS_UNIX
    QDir dir(QDir::homePath().append("/.config/hotot-qt"));
#else
    QDir dir(QDesktopServices::storageLocation(QDesktopServices::DataLocation).append("/Hotot"));
#endif

    if (!dir.exists())
        dir.mkpath(".");

    m_confDir = dir.absolutePath();

    QWebSettings::setOfflineStoragePath(dir.absolutePath());
    QWebSettings::setOfflineStorageDefaultQuota(15 * 1024 * 1024);

    m_webView->setPage(m_page);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);


    m_inspector = new QWebInspector;
    m_inspector->setPage(m_page);

#ifdef MEEGO_EDITION_HARMATTAN
    connect(page, SIGNAL(exposedContentRectChanged()), this, SLOT(contentSizeChanged()));
    m_page->setPreferredContentsSize(page->exposedContentRect().size().toSize());
    m_webView->setResizesToContents(true);
#endif

#ifdef Q_OS_UNIX
    m_webView->load(QUrl("file://" PREFIX "/share/hotot/index.html"));
#else
    QFileInfo f("share/hotot/index.html");
    m_webView->load(QUrl::fromLocalFile(f.absoluteFilePath()));
#endif
    connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
    connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(onLinkHovered(QString, QString, QString)));
}
Beispiel #15
0
Widget::Widget()
{
    // This class is the host of the whole application. This is BAD. Needs to be rectified. Should split this up into either: More classes OR More Files

    firstComp = NULL; //Setup the linked list

    //Spawn a QMainWindow, and set its attributes
    mainWindow = new QMainWindow();
    mainWindow->resize(400, 400);
    mainWindow->setWindowTitle("Lan Party Manager " + releaseType + " " + releaseVer);

    setup = new QSettings(QSettings::IniFormat, QSettings::SystemScope, "Alldritt Coding", "LanParty Manager", this);
    QStringList keys = setup->allKeys();

    if(keys.length() != 8)
    {
        setup->clear();
        setup->setValue("udpBroadcast", 1000);
        setup->setValue("tcpBroadcast", 5000);
        setup->setValue("udpPort", 45454);
        setup->setValue("tcpPort", 1337);
        setup->setValue("debug", false);
        setup->setValue("releaseType", releaseType);
        setup->setValue("releaseVer", releaseVer);
        setup->setValue("networkUpdateRate", 1000);
    }
    else
    {
		udpBroadcastRate = setup->value("udpBroadcast", 1000).toInt();
		tcpCheckRate = setup->value("tcpBroadcast", 5000).toInt();
		standardUdpPort = setup->value("udpPort", 45454).toInt();
		standardTcpPort = setup->value("tcpPort", 1337).toInt();
		debugMode = setup->value("debug", false).toBool();
		//releaseType = setup->value("releaseType", "").toString();
		//releaseVer = setup->value("releaseVer", "").toString();
		networkUpdateRate = setup->value("networkUpdateRate", 1000).toInt();
    }

    settings = new QWidget(mainWindow, Qt::Dialog);
    settings->resize(300, 300);
    settings->setWindowTitle("Settings");
    settings->hide();
	
    QLabel * la = new QLabel(settings);
    la->move(15, 15);
    la->setText("UDP Broadcast Delay");
	
    QLabel * lb = new QLabel(settings);
    lb->move(15, 45);
    lb->setText("TCP Broadcast Delay");
	
    QLabel * lc = new QLabel(settings);
    lc->move(15, 75);
    lc->setText("Default UDP Port (Advanced)");
	
    QLabel * ld = new QLabel(settings);
    ld->move(15, 105);
    ld->setText("Default TCP Port (Advanced)");
	
    QLabel * le = new QLabel(settings);
    le->move(15, 165);
    le->setText("Debug Mode");
	
    QLabel * lf = new QLabel(settings);
    lf->move(15, 135);
    lf->setText("Total Bytes Refresh Rate");

    uPort = new QLineEdit(settings);
    uPort->setGeometry(200, 75, 50, 20);
    uPort->setText(QString().number(standardUdpPort));

    tPort = new QLineEdit(settings);
    tPort->setGeometry(200, 105, 50, 20);
    tPort->setText(QString().number(standardTcpPort));

    uDelay = new QLineEdit(settings);
    uDelay->setGeometry(200, 15, 50, 20);
    uDelay->setText(QString().number(udpBroadcastRate));

    tDelay = new QLineEdit(settings);
    tDelay->setGeometry(200, 45, 50, 20);
    tDelay->setText(QString().number(tcpCheckRate));

    nDelay = new QLineEdit(settings);
    nDelay->setGeometry(200, 135, 50, 20);
    nDelay->setText(QString().number(networkUpdateRate));

    debugOn = new QCheckBox(settings);
    debugOn->move(200, 165);
    debugOn->setChecked(debugMode);

    QPushButton * apply = new QPushButton(settings);
    apply->setGeometry(200, 200, 60, 30);
    apply->setText("Apply");
    QObject::connect(apply, SIGNAL(clicked()), this, SLOT(apply()));

    QWidget * passWindow = new QWidget(mainWindow, Qt::Tool);
    passWindow->resize(200, 80);
    passWindow->hide();

    QLabel * passLabel = new QLabel(passWindow);
    passLabel->move(50, 10);
    passLabel->setText("Enter Password");

    passBox = new QLineEdit(passWindow);
    passBox->setGeometry(40, 25, 130, 20);

    QPushButton * enter = new QPushButton(passWindow);
    enter->setGeometry(40, 50, 50, 25);
    enter->setText("Enter");

    QObject::connect(enter, SIGNAL(clicked()), this, SLOT(passEnter()));
    QObject::connect(enter, SIGNAL(clicked()), passWindow, SLOT(hide()));
    QObject::connect(passBox, SIGNAL(returnPressed()), this, SLOT(passEnter()));
    QObject::connect(passBox, SIGNAL(returnPressed()), passWindow, SLOT(hide()));

    icon = new QIcon(":/images/icon.png");
    sysIcon = new QSystemTrayIcon(*icon, this);
    sysIcon->show();
    sysMenu = new QMenu(mainWindow);
    QAction * exitAction = sysMenu->addAction("Exit");
    sysIcon->setContextMenu(sysMenu);
    connect(exitAction, SIGNAL(triggered(bool)), qApp, SLOT(quit()));
    connect(exitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
    bool success = connect(sysIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconClicked(QSystemTrayIcon::ActivationReason)));
    if(success != true)
    {
		sysIcon->showMessage("System Tray Error", "Window Respawn Connection Failed", QSystemTrayIcon::Information, 10000 );
    }

	QMenu* file = mainWindow->menuBar()->addMenu(tr("&File"));
	QMenu* help = mainWindow->menuBar()->addMenu(tr("&Help"));

	QAction* exitAct = new QAction(tr("&Exit"), this);
	exitAct->setStatusTip(tr("Quit"));
	connect(exitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

	QAction* settingAct = new QAction(tr("&Settings"), this);
	settingAct->setStatusTip(tr("Access the Settings page"));
	connect(settingAct, SIGNAL(triggered()), this, SLOT(settingsWindow()));

	QAction* aboutQtAct = new QAction(tr("About &Qt"), this);
	aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
	connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

	QAction* aboutAct = new QAction(tr("&About"), this);
	aboutAct->setStatusTip(tr("Show the About box"));
	connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

	help->addAction(aboutQtAct);
	help->addAction(aboutAct);
	file->addAction(settingAct);
	file->addAction(exitAct);
	mainWindow->show();

    server = new QPushButton(mainWindow);
    client = new QPushButton(mainWindow);

    log = new QFile("log.txt");
    currentTime = new QDateTime(); //create the log timestamp
    *currentTime = QDateTime::currentDateTime(); //get system time

    if(!log->open(QIODevice::ReadWrite|QIODevice::Append))
    {
        QMessageBox::information(0, "Error", "Can't open logfile. Reason: " + log->errorString());
    }

    if(debugMode)
    {
		writeLog("LanMan " + releaseType + " " + releaseVer + " Logfile Start");
		writeLog("Time Format is: DD/MM/YYYY - HOUR:MIN:SEC AM/PM");
    }

    server->setGeometry(10, 30, 100, 30);
    client->setGeometry(290, 30, 100, 30);
    server->setText("SERVER MODE");
    client->setText("CLIENT MODE");
    client->show();
    server->show();
    connect(client, SIGNAL(released()), this, SLOT(startClient()));
    connect(server, SIGNAL(released()), passWindow, SLOT(show()));
    mainLabel = new QLabel("", mainWindow);
    mainLabel->move(165, 40);
    mainLabel->show();
    udpSocket = new QUdpSocket(this);
}
Beispiel #16
0
void psAxesBox(
	float x, float y, float width, float height,
	float x1Beg, float x1End, float p1Beg, float p1End, 
	float d1Num, float f1Num, int n1Tic, int grid1, char *label1,
	float x2Beg, float x2End, float p2Beg, float p2End,
	float d2Num, float f2Num, int n2Tic, int grid2, char *label2,
	char *labelFont, float labelSize,
	char *title, char *titleFont, float titleSize,
	int style)
/*
FUNCTION:  draw an axes box via PostScript

PARAMETERS:
x		i x coordinate of lower left corner of box
y		i y coordinate of lower left corner of box
width		i width of box
height		i height of box
x1Beg  		i axis value at beginning of axis 1
x1End		i axis value at end of axis 1
p1Beg  		i pad value at beginning of axis 1
p1End		i pad value at end of axis 1
d1Num		i numbered tic increment for axis 1 (0.0 for automatic)
f1Num		i first numbered tic for axis 1
n1Tic		i number of horizontal tics per numbered tic for axis 1
grid1		i grid code for axis 1:  NONE, DOT, DASH, or SOLID
label1		i label for axis 1
x2Beg  		i axis value at beginning of axis 2
x2End		i axis value at end of axis 2
p2Beg  		i pad value at beginning of axis 2
p2End		i pad value at end of axis 2
d2Num		i vertical numbered tic increment (0.0 for automatic)
f2Num		i first numbered vertical tic
n2Tic		i number of vertical tics per numbered tic
grid2		i grid code for vertical axis:  NONE, DOT, DASH, or SOLID
label2		i vertical axis label
labelFont	i name of font to use for axes labels
labelSize	i size of font to use for axes labels
title		i axes box title
titleFont	i name of font to use for title
titleSize	i size of font to use for title
style		i NORMAL (axis 1 on bottom, axis 2 on left) 
		  SEISMIC (axis 1 on left, axis 2 on top)

NOTES:
psAxesBox will determine the numbered tic increment and first
numbered tic automatically, if the specified increment is zero.
Axis numbering is in scientific notation, if necessary and is plotted to four significant digits.

Pad values must be specified in the same units as the corresponding 
axes values.  These pads are useful when the contents of the axes box 
requires more space than implied by the axes values.  For example, 
the first and last seismic wiggle traces plotted inside an axes box 
will typically extend beyond the axes values corresponding to the 
first and last traces.  However, all tics will lie with the limits 
specified in the axes values (x1Beg, x1End, x2Beg, x2End).

AUTHOR:   Dave Hale,  Colorado School of Mines, 06/27/89
MODIFIED: Ken Larner, Colorado School of Mines, 08/30/90
*/
{
	int n1num,n2num,ntic,ndash,grided;
	int ndig,ndigits,nexp,nexpmax,nexplot1,nexplot2,
		nplaces,nplacesmax,nformat;
	float xa,xas,ya,yas,yb,xb,ticsize,dnum,fnum,dtic,amin,amax,azero,
		base,scale,anum,anumnorm,atic,fnexp,
		size1,size2,ticb,numb,numb2,labelb,dash[2],
		labelCH,labelCW,labelCA,labelCD,
		titleCH,titleCW,titleCA,titleCD,
		pnorm,fdexp,azeronorm;
	char str[256],str2[256],sformat[256];

	/* determine font dimensions */
	labelCH = fontheight(labelFont,labelSize);
	labelCW = fontwidth(labelFont,labelSize);
	labelCA = fontascender(labelFont,labelSize);
	labelCD = fontdescender(labelFont,labelSize);
	titleCH = fontheight(titleFont,titleSize);
	titleCW = fontwidth(titleFont,titleSize);
	titleCA = fontascender(titleFont,titleSize);
	titleCD = fontdescender(titleFont,titleSize);

	/* determine sizes of axes 1 and 2 */
	if (style==NORMAL) {
		size1 = width;
		size2 = height;
	} else {
		size1 = height;
		size2 = width;
	}

	/* determine numbered tic intervals */
	if (d1Num==0.0) {
		n1num = size1/(4*labelCW);
		scaxis(x1Beg,x1End,&n1num,&d1Num,&f1Num);
	}
	if (d2Num==0.0) {
		n2num = size2/(4*labelCW);
		scaxis(x2Beg,x2End,&n2num,&d2Num,&f2Num);
	}

	/* save graphics state */
	gsave();

	/* set gray (for black axes) */
	setgray(0.0);

	/* translate coordinate system, so that origin is at x,y */
	translate(x,y);

	/* if style is not NORMAL, rotate coordinate system */
	if (style!=NORMAL) {
		rotate(-90.0);
		translate(-height,0.0);
	}

	/* start a new path (just to be safe) */
	newpath();

	/* set font and character size */
	setfont(labelFont,labelSize);

	/* determine tic size */
	ticsize = 0.3*labelCH;

	/* draw axis 1 */
	amin = (x1Beg<x1End)?x1Beg:x1End;
	amax = (x1Beg>x1End)?x1Beg:x1End;
	azero = 0.0001*(amax-amin);
	dnum = d1Num;  fnum = f1Num;  ntic = n1Tic;
	scale = size1/(x1End+p1End-x1Beg-p1Beg);
	base = -scale*(x1Beg+p1Beg);
	ticb = -ticsize;
	numb = 1.2*ticb-labelCA;
	if(style!=NORMAL)   numb = 1.2*ticb;
	labelb = numb-labelCH;

	/* determine axes1 exponent for scientific notation   */
	ndigits = 0;
	ndig    = 0;
	fdexp = log10(1.001*ABS(dnum));
	if(fdexp<0.)   fdexp -=1.0;
	for (anum=fnum; anum<=amax; anum+=dnum) {
		if(anum==fnum && anum==0.)
			nexpmax = 0;
		nexp    = 0;
		if(anum!=0.)   {
			fnexp = log10(1.001*ABS(anum));
			if(fnexp>0.)   nexp    = (int)fnexp;
			else           nexp    = (int)fnexp-1;		
			if(anum==fnum)
				nexpmax = nexp;
			if(nexpmax<nexp || nexpmax==0)    
				nexpmax = nexp;
			ndig = 1+nexp-(int)fdexp;
		}
		if(ndigits<ndig)   ndigits = ndig;
	}
	nexplot1 = 0;
	if(ABS(nexpmax)>3)   
		nexplot1 = nexpmax;
	if((nexpmax<0) && (ndigits+ABS(nexpmax))>4)   
		nexplot1 = nexpmax;
	
	/* loop for axis1 numbering */
	nplacesmax = 0;
	pnorm      = pow(10.0,(double)nexplot1);
	azeronorm  = azero/pnorm;
	fdexp = log10(1.001*ABS(dnum/pnorm));
	if(fdexp<0.)   fdexp -=1.0;
	for (anum=fnum; anum<=amax; anum+=dnum) {

		if (anum<amin) continue;
		xa = base+scale*anum;
		xas = xa+0.25*labelCH;
		moveto(xa,0.0);  lineto(xa,ticb);
		anumnorm = anum/pnorm;

		/* find the number of places in axis1 numbers */
		nplaces = 1;
		nexp    = 1;
		nexp    = 0;
		if (anumnorm<-azeronorm || anumnorm>azeronorm)   {
			fnexp = log10(1.001*ABS(anumnorm));
			if(fnexp>0.)   {
				nexp    = (int)fnexp;
				nplaces = nexp+2;
			}
			else   {
				nexp    = (int)fnexp-1;
				nplaces = -nexp+2;
			}
		}
		/* numbers limited to four significant digits */
		ndigits = 1+nexp-(int)fdexp;
		if(ndigits>4)   ndigits = 4;

		if((nexp>=0) && ((ndigits+1)>nplaces))    
			nplaces = ndigits+1;
		if(anum<0. )   
			nplaces +=1;
		if(nexp<0)   
			nplaces = nplaces+ndigits-1;
		if(nplacesmax<nplaces)   
			nplacesmax = nplaces;

		nformat = ndigits-(nexp+1);
		if(nformat<0)   nformat = 0;

		if (anumnorm>-azeronorm && anumnorm<azeronorm)
			sprintf(str,"%.4g",0.0);
		else	{
			sprintf(sformat,"%%.%df",nformat);
			sprintf(str,sformat,anumnorm);
		}
	
		if (style!=NORMAL) {
			moveto(xas,numb);
			rotate(90.0);
			justshow(-1.0,str);
			rotate(-90.0);
		}
		else   {
			moveto(xa,numb);
			justshow(-0.5,str);
		}
			
	}
	/* draw exponential multiplier for axis1 */
	if(nexplot1!=0)  {
		if(style==NORMAL)   {
			moveto(size1,labelb);
			show("x10");
			moveto(size1+1.5*labelCW,labelb+0.5*labelCA);
			sprintf(str2,"%d",nexplot1);
			show(str2);
		}
		else   {
			moveto(size1+1.4*labelCH,-2.0*labelCW);
			rotate(90.);
			show("x10");
			rotate(-90.);
			moveto(size1+1.05*labelCH,-0.5*labelCW);
			sprintf(str2,"%d",nexplot1);
			rotate(90.);
			show(str2);
			rotate(-90.);
		}
	}
	stroke();

	/* draw axis1 tick marks */
	if(style!=NORMAL)   labelb = numb-0.5*nplacesmax*labelCW;
	dtic = dnum/ntic;
	for (atic=fnum-ntic*dtic-dtic; atic<=amax; atic+=dtic) {
		if (atic<amin) continue;
		xa = base+scale*atic;
		moveto(xa,0.0);  lineto(xa,ticb/2);
	}
	stroke();

	/* draw axis1 grid lines */
	if (grid1==SOLID) {
		grided = 1;
		ndash = 0;
	} else if (grid1==DASH) {
		grided = 1;
		ndash = 1;  dash[0] = 10;
	} else if (grid1==DOT) {
		grided = 1;
		ndash = 2;  dash[0] = 1;  dash[1] = 5;
	} else
		grided = 0;
	if (grided) {
		for (anum=fnum; anum<=amax; anum+=dnum) {
			if (anum<amin) continue;
			xa = base+scale*anum;
			moveto(xa,0.0);  lineto(xa,size2);
		}
		setdash(dash,ndash,0.0);
		stroke();
		setdash(dash,0,0.0);
	}
	
	/* draw axis1 label */
	moveto(size1/2.0,labelb);
	if(style!=NORMAL)   {
		rotate(180.);
		justshow(-0.5,label1);
		rotate(-180.);
	}
	else 	justshow(-0.5,label1);
 
	/* draw axis 2 */
	amin = (x2Beg<x2End)?x2Beg:x2End;
	amax = (x2Beg>x2End)?x2Beg:x2End;
	azero = 0.0001*(amax-amin);
	dnum = d2Num;  fnum = f2Num;  ntic = n2Tic;
	scale = size2/(x2End+p2End-x2Beg-p2Beg);
	base = -scale*(x2Beg+p2Beg);
	ticb = -ticsize;
	numb = ticb+labelCD;
	labelb = numb-labelCH;
	
	/* determine axes2 exponent for scientific notation   */
	ndigits = 0;
	ndig    = 0;
	fdexp   = log10(1.001*ABS(dnum));
	if(fdexp<0.)   fdexp -=1.0;
	for (anum=fnum; anum<=amax; anum+=dnum) {
		if(anum==fnum && anum==0.)
			nexpmax = 0;
		nexp    = 0;
		if(anum!=0.)   {
			fnexp = log10(1.001*ABS(anum));
			if(fnexp>0.)   nexp    = (int)fnexp;
			else           nexp    = (int)fnexp-1;		
			if(anum==fnum)
				nexpmax = nexp;
			if(nexpmax<nexp || nexpmax==0)    
				nexpmax = nexp;
			ndig = 1+nexp-(int)fdexp;
		}
		if(ndigits<ndig)   ndigits = ndig;
	}
	nexplot2 = 0;
	if(ABS(nexpmax)>3)   
		nexplot2 = nexpmax;
	if((nexpmax<0) && (ndigits+ABS(nexpmax))>4)   
		nexplot2 = nexpmax;
	
	/* loop for axis 2 numbering */
	nplacesmax = 0;
	pnorm      = pow(10.0,(double)nexplot2);
	azeronorm  = azero/pnorm;
	fdexp = log10(1.001*ABS(dnum/pnorm));
	if(fdexp<0.)   fdexp -=1.0;
	for (anum=fnum; anum<=amax; anum+=dnum) {
		ya = base+scale*anum;
		moveto(0.0,ya);  lineto(ticb,ya);
		anumnorm = anum/pnorm;
		yas = ya-0.25*labelCH;
	
		/* find the number of places in axis2 numbers */
		nplaces = 1;
		nexp    = 1;
		if (anumnorm<-azeronorm || anumnorm>azeronorm)   {
			fnexp = log10(1.001*ABS(anumnorm));
			if(fnexp>0.)   {
				nexp    = (int)fnexp;
				nplaces = nexp+2;
			}
			else   {
				nexp    = (int)fnexp-1;
				nplaces = -nexp+2;
			}
		}
		/* numbers limited to four significant digits */
		ndigits = 1+nexp-(int)fdexp;
		if(ndigits>4)   ndigits = 4;

		if((nexp>=0) && ((ndigits+1)>nplaces))    
			nplaces = ndigits+1;
		if(anum<0. )   
			nplaces +=1;
		if(nexp<0)   
			nplaces = nplaces+ndigits-1;
		if(nplacesmax<nplaces)   
			nplacesmax = nplaces;

		nformat = ndigits-(nexp+1);
		if(nformat<0)   nformat = 0;
	
		if (anumnorm>-azeronorm && anumnorm<azeronorm)
			sprintf(str,"%.4g",0.0);
		else	{
			sprintf(sformat,"%%.%df",nformat);
			sprintf(str,sformat,anumnorm);
		}

		if (style!=NORMAL) {
			moveto(numb,ya);
			rotate(90.0);
			justshow(-0.5,str);
			rotate(-90.0);
		}
		else   {
			moveto(numb,yas); 
			justshow(-1.,str);
		}
	}
	/* draw exponential mulitplier for axis2 */
	if(nexplot2!=0)  {
		if(style==NORMAL)   {
			numb2 = size2+.5*labelCH;
			moveto(labelb,numb2);
			show("x10");
			xb = labelb+1.5*labelCW;
			numb2 = numb2+0.5*labelCA;
			moveto(xb,numb2);
			sprintf(str2,"%d",nexplot2);
			show(str2);
		}
		else   {
			moveto(labelb,size2-.5*labelCW);
			rotate(90.);
			show("x10");
			rotate(-90.);
			moveto(labelb-.35*labelCH,size2+1.0*labelCW);
			sprintf(str2,"%d",nexplot2);
			rotate(90.);
			show(str2);
			rotate(-90.);
		}
	}
	stroke();

	/* draw axis2 tick marks */
	if(style==NORMAL)   labelb = numb-0.5*nplacesmax*labelCW;	
	dtic = dnum/ntic;
	for (atic=fnum-ntic*dtic-dtic; atic<=amax; atic+=dtic) {
		if (atic<amin) continue;
		ya = base+scale*atic;
		moveto(0.0,ya);  lineto(ticb/2,ya);
	}
	stroke();
	
	/* draw axis2 grid lines */
	if (grid2==SOLID) {
		grided = 1;
		ndash = 0;
	} else if (grid2==DASH) {
		grided = 1;
		ndash = 1;  dash[0] = 10;
	} else if (grid2==DOT) {
		grided = 1;
		ndash = 2;  dash[0] = 1;  dash[1] = 5;
	} else
		grided = 0;
	if (grided) {
		for (anum=fnum; anum<=amax; anum+=dnum) {
			if (anum<amin) continue;
			ya = base+scale*anum;
			moveto(0.0,ya);  lineto(size1,ya);
		}
		setdash(dash,ndash,0.0);
		stroke();
		setdash(dash,0,0.0);
	}
	
	/* draw axis2 label */
	moveto(labelb,size2/2.0);
	rotate(90.0);
	justshow(-0.5,label2);
	rotate(-90.0);

	/* draw title */
	setfont(titleFont,titleSize);
	if (style==NORMAL) {
		numb2 = size2+0.5*titleCH-titleCD;
		if(nexplot2!=0)	numb2 = numb2+.5*(labelCH+labelCA);
		moveto(size1/2.0,numb2);
		justshow(-0.5,title);
	} else {
		numb2 = size1+0.5*titleCH+titleCA;
		if(nexplot1!=0)	numb2 = numb2+labelCH;
		moveto(numb2,size2/2.0);
		rotate(90.0);
		justshow(-0.5,title);
		rotate(-90.0);
	}

	/* draw axes box */
	moveto(0.0,0.0);
	lineto(size1,0.0);
	lineto(size1,size2);
	lineto(0.0,size2);
	lineto(0.0,0.0);
	stroke();

	/* restore graphics state */
	grestore();
}
void IntroPhone::activate() {
	error = "";
	errorAlpha = anim::fvalue(0);
	show();
	enableAll(true);
}
Beispiel #18
0
BitcoinGUI::BitcoinGUI(QWidget *parent):
    QMainWindow(parent),
    clientModel(0),
    walletModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    lockWalletToggleAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0)
{
    resize(850, 550);
    setWindowTitle(tr("Pseudocoin") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
    qApp->setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create the tray icon (or setup the dock icon)
    createTrayIcon();

    // Create tabs
    overviewPage = new OverviewPage();

    transactionsPage = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout();
    transactionView = new TransactionView(this);
    vbox->addWidget(transactionView);
    transactionsPage->setLayout(vbox);

    addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);

    receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);

    sendCoinsPage = new SendCoinsDialog(this);

    signVerifyMessageDialog = new SignVerifyMessageDialog(this);

    centralWidget = new QStackedWidget(this);
    centralWidget->addWidget(overviewPage);
    centralWidget->addWidget(transactionsPage);
    centralWidget->addWidget(addressBookPage);
    centralWidget->addWidget(receiveCoinsPage);
    centralWidget->addWidget(sendCoinsPage);
    setCentralWidget(centralWidget);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelMintingIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelMintingIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    labelEncryptionIcon->setObjectName("labelEncryptionIcon");
    labelConnectionsIcon->setObjectName("labelConnectionsIcon");
    labelBlocksIcon->setObjectName("labelBlocksIcon");
    labelMintingIcon->setObjectName("labelMintingIcon");
    labelEncryptionIcon->setStyleSheet("#labelEncryptionIcon QToolTip {color:#cecece;background-color:#333333;border:0px;}");
    labelConnectionsIcon->setStyleSheet("#labelConnectionsIcon QToolTip {color:#cecece;background-color:#333333;border:0px;}");
    labelBlocksIcon->setStyleSheet("#labelBlocksIcon QToolTip {color:#cecece;background-color:#333333;border:0px;}");
    labelMintingIcon->setStyleSheet("#labelMintingIcon QToolTip {color:#cecece;background-color:#333333;border:0px;}");

    // Set minting pixmap
    labelMintingIcon->setPixmap(QIcon(":/icons/minting").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
    labelMintingIcon->setEnabled(false);
    // Add timer to update minting icon
    QTimer *timerMintingIcon = new QTimer(labelMintingIcon);
    timerMintingIcon->start(MODEL_UPDATE_DELAY);
    connect(timerMintingIcon, SIGNAL(timeout()), this, SLOT(updateMintingIcon()));
    // Add timer to update minting weights
    QTimer *timerMintingWeights = new QTimer(labelMintingIcon);
    timerMintingWeights->start(30 * 1000);
    connect(timerMintingWeights, SIGNAL(timeout()), this, SLOT(updateMintingWeights()));
    // Set initial values for user and network weights
    nWeight, nNetworkWeight = 0;

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = qApp->style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
    // this->setStyleSheet("background-color: #effbef;");

    // Clicking on a transaction on the overview page simply sends you to transaction history page
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));

    // Double-clicking on a transaction on the transaction history page shows details
    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // Clicking on "Verify Message" in the address book sends you to the verify message tab
    connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
    // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
    connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));

    gotoOverviewPage();
}
//----[  syncTrade  ]----------------------------------------------------------
void EvidyonGUIModule_TradeDialog::syncTrade(
    const char* their_name,
    CurrencyType my_offered_currency,
    unsigned char* my_items, unsigned int number_of_my_items,
    CurrencyType their_offered_currency,
    TradeItemDescription* their_items, unsigned int number_of_their_items) {
  GUILayer* layer = hide();

  {
    char trade_text[256];
    sprintf_s(trade_text, 256, "%s offers", their_name);
    label_their_items_.textLabel()->setText(trade_text);
    sprintf_s(trade_text, 256, "Trading with %s", their_name);
    label_my_items_.textLabel()->setText(trade_text);

    label_inventory_.textLabel()->setAlignment(GUIALIGN_CENTER);
    label_inventory_.textLabel()->setFont(button_font_);
    label_inventory_.textLabel()->setTextColor(0xFFFFFFFF);
    label_their_items_.textLabel()->setAlignment(GUIALIGN_CENTER);
    label_their_items_.textLabel()->setFont(button_font_);
    label_their_items_.textLabel()->setTextColor(0xFFFFFFFF);
    label_my_items_.textLabel()->setAlignment(GUIALIGN_CENTER);
    label_my_items_.textLabel()->setFont(button_font_);
    label_my_items_.textLabel()->setTextColor(0xFFFFFFFF);
  }

  inventory_items_list_.clear();
  my_items_list_.clear();
  their_items_list_.clear();

  // create the offered items list
  std::set<int> offered;
  for (int i = 0; i < number_of_my_items; ++i) {
    int index = my_items[i];
    if (index > Evidyon::AVATAR_INVENTORY_SIZE) continue;
    GUIHelper_CreateButtonForInventoryItem(
      i,
      &my_items_list_,
      button_font_,
      &inventory_[index],
      item_descriptions_,
      number_of_item_descriptions_);
    offered.insert(index);
  }

  // add my currency if it's non-zero
  if (my_offered_currency > 0) {
    EvidyonGUIButton* button = my_items_list_.button(AVATAR_INVENTORY_SIZE + 1);
    button->enable();
    char amount[128];
    sprintf_s(amount, 128, "%lu gold", my_offered_currency);
    button->setText(amount);
    button->setFont(button_font_);
    button->getTextLabelElement()->setAlignment(GUIALIGN_LEFT);
  }

  // create the inventory with items not in trade
  int offered_item = 0;
  for (int i = 0; i < Evidyon::AVATAR_INVENTORY_SIZE; ++i) {
    if (offered.find(i) != offered.end()) continue;
    GUIHelper_CreateButtonForInventoryItem(
      i,
      &inventory_items_list_,
      button_font_,
      &inventory_[i],
      item_descriptions_,
      number_of_item_descriptions_);
  }

  // create the other player's offered items
  for (int i = 0; i < number_of_their_items; ++i) {
    unsigned int type = their_items[i].type;
    if (type >= number_of_item_descriptions_) continue;
    const Item::ItemClientDescription* desc = &item_descriptions_[type];
    EvidyonGUIButton* button = their_items_list_.button(i);
    char text[256];
    GUIHelper_GetItemNameString(their_items[i].quantity, desc, text, 256);
    button->setText(text);
    button->getTextLabelElement()->setAlignment(GUIALIGN_LEFT);
    button->setFont(button_font_);
    button->enable();
  }

  // add their currency if it's non-zero
  if (their_offered_currency > 0) {
    EvidyonGUIButton* button = their_items_list_.button(AVATAR_INVENTORY_SIZE + 1);
    button->enable();
    char amount[128];
    sprintf_s(amount, 128, "%lu gold", their_offered_currency);
    button->setText(amount);
    button->setFont(button_font_);
    button->getTextLabelElement()->setAlignment(GUIALIGN_LEFT);
  }

  // copy their items
  if (their_items == NULL || number_of_their_items == 0) {
    memset(their_items_, 0, sizeof(their_items_));
    number_of_their_items_ = 0;
  } else {
    memcpy(their_items_, their_items, sizeof(TradeItemDescription) * number_of_their_items);
    number_of_their_items_ = number_of_their_items;
  }

  syncAcceptOrWithdrawButton();

  show(layer);
}
Beispiel #20
0
int setupui(void)
{
    char *p, *ctype, Rlocale[1000] = ""; /* Windows' locales can be very long */

    initapp(0, 0);

    /* set locale before doing anything with menus */
    setlocale(LC_CTYPE, ""); /* necessary in case next fails to set
				a valid locale */
    if((p = getenv("LC_ALL"))) strcpy(Rlocale, p);
    if((p = getenv("LC_CTYPE"))) strcpy(Rlocale, p);
    if (strcmp(Rlocale, "C") == 0) strcpy(Rlocale, "en");
    setlocale(LC_CTYPE, Rlocale);
    mbcslocale = MB_CUR_MAX > 1;
    ctype = setlocale(LC_CTYPE, NULL);
    p = strrchr(ctype, '.');
    if(p && isdigit(p[1])) localeCP = atoi(p+1); else localeCP = 1252;

    readconsolecfg();
    int flags = StandardWindow | Document | Menubar;
    if(mbcslocale) flags |= UseUnicode;
    if (RguiMDI & RW_MDI) {
	TRACERUI("Rgui");
	RFrame = newwindow(
#ifdef _WIN64
	    "RGui (64-bit)",
#else
	    "RGui (32-bit)",
#endif
	    MDIsize,
	    StandardWindow | Menubar | Workspace);
	setclose(RFrame, closeconsole);
	show(RFrame);
	TRACERUI("Rgui done");
	TRACERUI("Console");
	if (!(RConsole = newconsole("R Console", flags ))) return 0;
	TRACERUI("Console done");
    } else {
	TRACERUI("Console");
#ifdef _WIN64
	if (!(RConsole = newconsole("R Console (64-bit)", flags ))) return 0;
#else
	if (!(RConsole = newconsole("R Console (32-bit)", flags ))) return 0;
#endif
	TRACERUI("Console done");
    }
    
    if (ismdi()) {
	  int btsize = 24;
	  rect r = rect(2, 2, btsize, btsize);
	  control tb, bt;

	  MCHECK(tb = newtoolbar(btsize + 4));
	  addto(tb);

	  MCHECK(bt = newtoolbutton(open_image, r, menueditoropen));
	  MCHECK(addtooltip(bt, G_("Open script")));
	  r.x += (btsize + 1) ;

	  MCHECK(bt = newtoolbutton(open1_image, r, menuloadimage));
	  MCHECK(addtooltip(bt, G_("Load workspace")));
	  r.x += (btsize + 1) ;

	  MCHECK(bt = newtoolbutton(save_image, r, menusaveimage));
	  MCHECK(addtooltip(bt, G_("Save workspace")));
	  r.x += (btsize + 6);

	  MCHECK(bt = newtoolbutton(copy_image, r, buttoncopy));
	  MCHECK(addtooltip(bt, G_("Copy")));
	  r.x += (btsize + 1);

	  MCHECK(bt = newtoolbutton(paste_image, r, buttonpaste));
	  MCHECK(addtooltip(bt, G_("Paste")));
	  r.x += (btsize + 1);

	  MCHECK(bt = newtoolbutton(copypaste_image, r, buttoncopypaste));
	  MCHECK(addtooltip(bt, G_("Copy and paste")));
	  r.x += (btsize + 6);

	  MCHECK(bt = newtoolbutton(stop_image, r, buttonkill));
	  MCHECK(addtooltip(bt, G_("Stop current computation")));
	  r.x += (btsize + 6) ;

	  MCHECK(bt = newtoolbutton(print_image, r, menuprint));
	  MCHECK(addtooltip(bt, G_("Print")));
    }
    if (ismdi() && (RguiMDI & RW_STATUSBAR)) {
	TRACERUI("status bar");
	addstatusbar();
	addto(RConsole);
	TRACERUI("status bar done");
    }
    if (ismdi()) {
	char s[256];
	PrintVersionString(s, 256);
	setstatus(s);
    }
    addto(RConsole);
    setclose(RConsole, closeconsole);
    setdrop(RConsole, dropconsole);
    MCHECK(RConsolePopup = gpopup(popupact, ConsolePopup));
    MCHECK(RMenuBar = newmenubar(menuact));
    MCHECK(newmenu(G_("File")));
    MCHECK(msource = newmenuitem(G_("Source R code..."), 0, menusource));
    MCHECK(newmenuitem(G_("New script"), 0, menueditornew));
    MCHECK(newmenuitem(G_("Open script..."), 0, menueditoropen));
    MCHECK(mdisplay = newmenuitem(G_("Display file(s)..."), 0, menudisplay));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mload = newmenuitem(G_("Load Workspace..."), 0, menuloadimage));
    MCHECK(msave = newmenuitem(G_("Save Workspace..."), 'S', menusaveimage));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mloadhistory = newmenuitem(G_("Load History..."), 0,
				      menuloadhistory));
    MCHECK(msavehistory = newmenuitem(G_("Save History..."), 0,
				      menusavehistory));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("Change dir..."), 0, menuchangedir));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("Print..."), 'P', menuprint));
    MCHECK(newmenuitem(G_("Save to File..."), 0, menusavefile));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("Exit"), 0, menuexit));

    MCHECK(newmenu(G_("Edit")));
    MCHECK(mcopy = newmenuitem(G_("Copy"), 'C', menucopy));
    MCHECK(mpaste = newmenuitem(G_("Paste"), 'V', menupaste));
    MCHECK(mpastecmds = newmenuitem(G_("Paste commands only"), 0,
				    menupastecmds));
    MCHECK(mcopypaste = newmenuitem(G_("Copy and Paste"), 'X', menucopypaste));
    MCHECK(newmenuitem(G_("Select all"), 0, menuselectall));
    MCHECK(newmenuitem(G_("Clear console"), 'L', menuclear));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mde = newmenuitem(G_("Data editor..."), 0, menude));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mconfig = newmenuitem(G_("GUI preferences..."), 0, menuconfig));
    if (ismdi()) {
	MCHECK(newmenu(G_("View")));
	MCHECK(mtools = newmenuitem(G_("Toolbar"), 0, menutools));
	MCHECK(mstatus = newmenuitem(G_("Statusbar"), 0, menustatus));
	if(RguiMDI & RW_TOOLBAR) check(mtools);
	if(RguiMDI & RW_STATUSBAR) check(mstatus);
    }
    MCHECK(newmenu(G_("Misc")));
    MCHECK(newmenuitem(G_("Stop current computation           \tESC"), 0,
		       menukill));
    MCHECK(newmenuitem(G_("Stop all computations"), 0, menukillall));
    if (DebugMenuitem || isdebuggerpresent())
	MCHECK(newmenuitem(G_("Break to debugger"), 0, menudebug));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mlazy = newmenuitem(G_("Buffered output"), 'W', menulazy));
    MCHECK(mcomplete = newmenuitem(G_("Word completion"), 0, menucomplete));
    check(mcomplete);
    MCHECK(mfncomplete = newmenuitem(G_("Filename completion"), 0,
				     menufncomplete));
    if(check_file_completion())
	check(mfncomplete);
    else
	uncheck(mfncomplete);
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mls = newmenuitem(G_("List objects"), 0, menuls));
    MCHECK(mrm = newmenuitem(G_("Remove all objects"), 0, menurm));
    MCHECK(msearch = newmenuitem(G_("List search &path"), 0, menusearch));

    pmenu = (PkgMenuItems) malloc(sizeof(struct structPkgMenuItems));
    RguiPackageMenu(pmenu);
    RguiWindowMenu();
    MCHECK(m = newmenu(G_("Help")));
    MCHECK(newmenuitem(G_("Console"), 0, menuconsolehelp));
    MCHECK(newmenuitem("-", 0, NULL));
    CheckForManuals();
    hmenu = (HelpMenuItems) malloc(sizeof(struct structHelpMenuItems));
    RguiCommonHelp(m, hmenu);
    consolesetbrk(RConsole, menukill, ESC, 0);
    wgl_hist_init(R_HistorySize, 0);
    if (R_RestoreHistory) wgl_loadhistory(R_HistoryFile);
    if (ismdi() && !(RguiMDI & RW_TOOLBAR)) toolbar_hide();
    show(RConsole);
    return 1;
}
Beispiel #21
0
 Dialog::Result Dialog::show ( const Template& template_ )
 {
     return (show(template_, &::DialogProcedure));
 }
Beispiel #22
0
int winaddmenuitem(const char * item, const char * menu,
		   const char * action, char *errmsg)
{
    int i, im;
    menuitem m;
    char mitem[1002], *p;

    /* if (nitems > 499) {
	strcpy(errmsg, G_("too many menu items have been created"));
	return 2;
	} */
    if (strlen(item) + strlen(menu) > 1000) {
	strcpy(errmsg, G_("menu + item is limited to 1000 bytes"));
	return 5;
    }

    for (im = 0; im < nmenus; im++) {
	if (strcmp(menu, usermenunames[im]) == 0) break;
    }
    if (im == nmenus) {
	strcpy(errmsg, G_("menu does not exist"));
	return 3;
    }

    strcpy(mitem, menu); strcat(mitem, "/"); strcat(mitem, item);

    for (i = 0; i < nitems; i++) {
	if (strcmp(mitem, umitems[i]->name) == 0) break;
    }
    if (i < nitems) { /* existing item */
	if (strcmp(action, "enable") == 0) {
	    enable(umitems[i]->m);
	} else if (strcmp(action, "disable") == 0) {
	    disable(umitems[i]->m);
	} else {
	    p = umitems[i]->action;
	    p = realloc(p, strlen(action) + 1);
	    if(!p) {
		strcpy(errmsg, G_("failed to allocate char storage"));
		return 4;
	    }
	    strcpy(p, action);
	}
    } else {
	addto(usermenus[im]);
	m  = newmenuitem(item, 0, menuuser);
	if (m) {
	    if(alloc_items <= nitems) {
		if(alloc_items <= 0) {
		    alloc_items = 100;
		    umitems = (Uitem *) malloc(sizeof(Uitem) * alloc_items);
		} else {
		    alloc_items += 100;
		    umitems = (Uitem *) realloc(umitems,
						sizeof(Uitem) * alloc_items);
		}
	    }
	    umitems[nitems] = (Uitem) malloc(sizeof(uitem));
	    umitems[nitems]->m = m;
	    umitems[nitems]->name = p = (char *) malloc(strlen(mitem) + 1);
	    if(!p) {
		strcpy(errmsg, G_("failed to allocate char storage"));
		return 4;
	    }
	    strcpy(p, mitem);
	    if(!p) {
		strcpy(errmsg, G_("failed to allocate char storage"));
		return 4;
	    }
	    umitems[nitems]->action = p = (char *) malloc(strlen(action) + 1);
	    strcpy(p, action);
	    m->max = nitems;
	    nitems++;
	} else {
	    strcpy(errmsg, G_("failed to allocate menuitem"));
	    return 1;
	}
    }
    show(RConsole);
    return 0;
}
Beispiel #23
0
SecurityDlg::SecurityDlg(CICQDaemon *s, CSignalManager *_sigman,
                         QWidget *parent)
   : LicqDialog(parent, "SecurityDialog", false, WStyle_ContextHelp | WDestructiveClose )
{
  server = s;
  sigman = _sigman;
  eSecurityInfo   = 0;
  ePasswordChange = 0;

  unsigned long nUin = gUserManager.OwnerUin();
  QString strUin;
  if (nUin)
    strUin.setNum(nUin);

  QVBoxLayout *lay = new QVBoxLayout(this, 8);
  QGroupBox *box = new QGroupBox(1, QGroupBox::Horizontal, tr("Options"), this);
  lay->addWidget(box);

  QGroupBox *passwordBox = new QGroupBox(2, QGroupBox::Horizontal,
    tr("Password/UIN settings"), this);
#if QT_VERSION > 300
  box->setInsideSpacing(1);
  passwordBox->setInsideSpacing(1);
#endif
  lay->addWidget(passwordBox);

  // Password boxes
  lblUin = new QLabel(tr("&Uin:"), passwordBox);
  edtUin = new QLineEdit(passwordBox);
  QWhatsThis::add(edtUin, tr("Enter the UIN which you want to use.  "
                             "Only available if \"Local changes only\" is "
                             "checked."));
  lblPassword = new QLabel(tr("&Password:"******"Enter your ICQ password here."));
  lblVerify = new QLabel(tr("&Verify:"), passwordBox);
  edtSecond = new QLineEdit(passwordBox);
  QWhatsThis::add(edtSecond, tr("Verify your ICQ password here."));
  chkOnlyLocal = new QCheckBox(tr("&Local changes only"), passwordBox);
  QWhatsThis::add(chkOnlyLocal, tr("If checked, password/UIN changes will apply"
                                   " only on your local computer.  Useful if "
                                   "your password is incorrectly saved in Licq."));

  edtUin->setEnabled(false);
  edtFirst->setEchoMode(QLineEdit::Password);
  edtSecond->setEchoMode(QLineEdit::Password);
  lblUin->setBuddy(edtUin);
  lblPassword->setBuddy(edtFirst);
  lblVerify->setBuddy(edtSecond);

  // UIN
  edtUin->setValidator(new QIntValidator(10000, 2147483647, edtUin));
  if (nUin) 
    edtUin->setText(strUin);

  // Owner password
  ICQOwner *o = gUserManager.FetchOwner(LOCK_R);
  if (o != NULL)
  {
    edtFirst->setText(o->Password());
    edtSecond->setText(o->Password());
  }
  else
  {
    edtFirst->setEnabled(false);
    edtSecond->setEnabled(false);
  }

  QVBoxLayout *blay = new QVBoxLayout;
  chkAuthorization = new QCheckBox(tr("Authorization Required"), box);
  QWhatsThis::add(chkAuthorization, tr("Determines whether regular ICQ clients "
                                       "require your authorization to add you to "
                                       "their contact list."));
  chkWebAware = new QCheckBox(tr("Web Presence"), box);
  QWhatsThis::add(chkWebAware, tr("Web Presence allows users to see if you are online "
                                  "through your web indicator."));
  chkHideIp = new QCheckBox(tr("Hide IP"), box);
  QWhatsThis::add(chkHideIp, tr("Hide IP stops users from seeing your IP address. It doesn't guarantee it will be hidden though."));
  blay->addWidget(chkAuthorization);
  blay->addWidget(chkWebAware);
  blay->addWidget(chkHideIp);

  btnUpdate = new QPushButton(tr("&Update"), this);
  btnUpdate->setDefault(true);
  btnUpdate->setMinimumWidth(75);
  btnCancel = new QPushButton(tr("&Cancel"), this);
  btnCancel->setMinimumWidth(75);
  QHBoxLayout *hlay = new QHBoxLayout;
  hlay->addWidget(QWhatsThis::whatsThisButton(this), 0, AlignLeft);
  hlay->addSpacing(20);
  hlay->addStretch(1);
  hlay->addWidget(btnUpdate, 0, AlignRight);
  hlay->addSpacing(20);
  hlay->addWidget(btnCancel, 0, AlignLeft);
  lay->addLayout(hlay);

  connect (btnUpdate, SIGNAL(clicked()), SLOT(ok()) );
  connect (btnCancel, SIGNAL(clicked()), SLOT(close()) );
  connect (chkOnlyLocal, SIGNAL(toggled(bool)), SLOT(slot_chkOnlyLocalToggled(bool)));

  // do some magic ;)
  // if we are offline, we enable the checkbox "Only local changes"
  // this saves one click :)
  if (o != NULL)  // Make sure we exist
  {
    slot_chkOnlyLocalToggled( (o->Status() == ICQ_STATUS_OFFLINE) );
    chkAuthorization->setChecked(o->GetAuthorization());
    chkWebAware->setChecked(o->WebAware());
    chkHideIp->setChecked(o->HideIp());
    gUserManager.DropOwner();
  }
  else
  {
    slot_chkOnlyLocalToggled(true);
    chkOnlyLocal->setEnabled(false);
    chkAuthorization->setChecked(false);
    chkWebAware->setChecked(false);
    chkHideIp->setChecked(false);
  }


  setCaption(tr("ICQ Security Options"));

  // remember the initial values
  // later we use these to apply only what has been changed by the user
  initAuthorization = chkAuthorization->isChecked();
  initWebAware      = chkWebAware->isChecked();
  initHideIp        = chkHideIp->isChecked();
  initEdtUin        = edtUin->text();
  initEdtFirst      = edtFirst->text();
  initEdtSecond     = edtSecond->text();

	// Set Tab Order
	setTabOrder(chkAuthorization, chkWebAware);
	setTabOrder(chkWebAware, chkHideIp);
	setTabOrder(chkHideIp, edtUin);
	setTabOrder(edtUin, edtFirst);
	setTabOrder(edtFirst, edtSecond);
	setTabOrder(edtSecond, chkOnlyLocal);
	setTabOrder(chkOnlyLocal, btnUpdate);
	setTabOrder(btnUpdate, btnCancel);

  show();
}
Beispiel #24
0
static void buttoncopypaste(control m)
{
    menucopypaste(m);
    show(RConsole);
}
Beispiel #25
0
void SectionWidget::showFast() {
	show();
	showFinished();
}
Beispiel #26
0
static void buttonkill(control m)
{
    show(RConsole);
    UserBreak = TRUE;
}
Beispiel #27
0
void MainWidget::shootFullScreen()
{
    originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
    updateScreenshotLabel();
    show();
}
void StartGameMenuWidget::showHelpClicked()
{
    emit showHelp();
    show();
}
Beispiel #29
0
void MainWidget::triangleReceiver(QPixmap pixmap)
{
    originalPixmap = pixmap;
    updateScreenshotLabel();
    show();
}
Beispiel #30
0
gboolean add_icon(Window win)
{
	// Avoid duplicates
	for (GSList *l = systray.list_icons; l; l = l->next) {
		TrayWindow *other = (TrayWindow *)l->data;
		if (other->win == win) {
			return FALSE;
		}
	}

	XTextProperty xname;
	char *name;
	if (XGetWMName(server.display, win, &xname)) {
		name = strdup((char *)xname.value);
		XFree(xname.value);
	} else {
		name = strdup("");
	}

	if (systray_profile)
		fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name);
	Panel *panel = systray.area.panel;

	// Get the process ID of the application that created the window
	int pid = 0;
	{
		Atom actual_type;
		int actual_format;
		unsigned long nitems;
		unsigned long bytes_after;
		unsigned char *prop = 0;
		int ret = XGetWindowProperty(server.display,
		                             win,
		                             server.atom._NET_WM_PID,
		                             0,
		                             1024,
		                             False,
		                             AnyPropertyType,
		                             &actual_type,
		                             &actual_format,
		                             &nitems,
		                             &bytes_after,
		                             &prop);
		if (ret == Success && prop) {
			pid = prop[1] * 256;
			pid += prop[0];
		}
	}

	// Create the parent window that will embed the icon
	XWindowAttributes attr;
	if (systray_profile)
		fprintf(stderr, "XGetWindowAttributes(server.display, win = %ld, &attr)\n", win);
	if (XGetWindowAttributes(server.display, win, &attr) == False) {
		free(name);
		return FALSE;
	}
	unsigned long mask = 0;
	XSetWindowAttributes set_attr;
	Visual *visual = server.visual;
	fprintf(stderr,
			GREEN "add_icon: %lu (%s), pid %d, visual %p, colormap %lu, depth %d, width %d, height %d" RESET "\n",
	        win,
	        name,
	        pid,
	        attr.visual,
	        attr.colormap,
	        attr.depth,
	        attr.width,
	        attr.height);
	if (server.disable_transparency) {
		set_attr.background_pixmap = ParentRelative;
		mask = CWBackPixmap;
		if (systray_composited || attr.depth != server.depth) {
			visual = attr.visual;
			set_attr.colormap = attr.colormap;
			mask |= CWColormap;
		}
	} else {
		if (systray_composited || attr.depth != server.depth) {
			visual = attr.visual;
			set_attr.background_pixel = 0;
			set_attr.border_pixel = 0;
			set_attr.colormap = attr.colormap;
			mask = CWColormap | CWBackPixel | CWBorderPixel;
		} else {
			set_attr.background_pixmap = ParentRelative;
			mask = CWBackPixmap;
		}
	}
	if (systray_profile)
		fprintf(stderr, "XCreateWindow(...)\n");
	Window parent = XCreateWindow(server.display,
	                              panel->main_win,
	                              0,
	                              0,
	                              systray.icon_size,
	                              systray.icon_size,
	                              0,
	                              attr.depth,
	                              InputOutput,
	                              visual,
	                              mask,
	                              &set_attr);

	// Add the icon to the list
	TrayWindow *traywin = g_new0(TrayWindow, 1);
	traywin->parent = parent;
	traywin->win = win;
	traywin->depth = attr.depth;
	// Reparenting is done at the first paint event when the window is positioned correctly over its empty background,
	// to prevent graphical corruptions in icons with fake transparency
	traywin->pid = pid;
	traywin->name = name;
	traywin->chrono = chrono;
	chrono++;

	if (!systray.area.on_screen)
		show(&systray.area);

	if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT)
		systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
	else
		systray.list_icons = g_slist_append(systray.list_icons, traywin);
	systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
	// print_icons();

	if (!panel->is_hidden) {
		if (systray_profile)
			fprintf(stderr, "XMapRaised(server.display, traywin->parent)\n");
		XMapRaised(server.display, traywin->parent);
	}

	if (systray_profile)
		fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__);

	// Resize and redraw the systray
	if (systray_profile)
		fprintf(stderr,
				BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
				profiling_get_time(),
				__FUNCTION__,
				__LINE__);
	systray.area.resize_needed = TRUE;
	panel->area.resize_needed = TRUE;
	schedule_redraw(&systray.area);
	refresh_systray = TRUE;
	return TRUE;
}