Пример #1
0
LapUSMainWindow::LapUSMainWindow(mtsIntuitiveDaVinci *daVinci,svlFilterImageOpenGLQtWidget *USVideoWidget,svlFilterImageFileWriter &USimagewriter1,svlFilterImageFileWriter &Liveimagewriter1,string saveFolderPath)
{
	clicked = false ;
	released = false;
//	int argc = 0;
//	char **argv;
//	QApplication app(argc, argv);
	this->daVinci = daVinci;
	this->saveFolderPath = saveFolderPath;
	this->setWindowState(Qt::WindowFullScreen);
	setMouseTracking(true);
	count = 1;
	USimagewriter = &USimagewriter1;
	Liveimagewriter = &Liveimagewriter1;
	std::cout<<"Creating the main window......\n";
	/* -------------Create the browser tabs -----------------*/
	browserWidget = new BrowserWidget(this);

	/*--------------Create the US + Real Image Viewer-------*/
	USviewerWidget = new USViewer(this);

	/*-------------Create the preop image viewer -------*/
	preopViewerWidget = new PreopViewer(this);

	/* Create the LapUS mouse */
//	mouse = new LapUSMouse(daVinci); 

    //this->setStyleSheet("background-color:black;");


	/*-------------- Create the video widget ------------------*/

	QHBoxLayout* videoLayout = new QHBoxLayout();//(QBoxLayout::LeftToRight);
	videoLayout->setMargin(0);
	videoLayout->setSpacing(0);
	//videoLayout->addWidget(USVideoWidget,4,Qt::AlignCenter);
	videoLayout->addWidget(USVideoWidget,4);
	//USVideoWidget->setFixedSzie(400,400);

	// contains the video and the save button
	videoWidget = new QWidget();
	videoWidget->setParent(this);
//	videoWidget->setFixedSize(380,380);
	//videoWidget->setFixedSize(400,380);

	//QPushButton * Save = new QPushButton();
	Save = new QPushButton();
	Save->setFixedSize(120,50);
	Save->setText("Save");
	connect(Save,SIGNAL(clicked()),this,SLOT(saveImages()));
	Save->setStyleSheet("QPushButton { background-color:gray; font-size: 14pt}");//" qlineargradientx1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde}");
 
	videoWidget->setLayout(videoLayout);

	justWidget = new QWidget();
	//QVBoxLayout* ll = new QVBoxLayout();
	QHBoxLayout* ll = new QHBoxLayout();
	ll->addWidget(videoWidget);
	ll->addWidget(Save,0,Qt::AlignRight | Qt::AlignVCenter);
	justWidget->setLayout(ll);
	ll->setMargin(0);
	ll->setSpacing(0);


	// QWidget* justWidget = new QWidget();
	// QVBoxLayout* ll = new QVBoxLayout();
	// ll->addWidget(videoWidget);
	// ll->addWidget(Save,0,Qt::AlignBottom | Qt::AlignHCenter);
	// justWidget->setLayout(ll);

	//	videoWidget->show();
	//videoWidget->setMinimumSize(400,400);
	//videoWidget->setGeometry(0,0,350,350);
	//videoWidget->setFixedSize(350,350);  // TODO set it up according to the screen size 
	/*-------------- Create a the left widget containing the video , USViewer and preop ------------------*/


	QDesktopWidget *desk = QApplication::desktop();
//	QRect screenSize;
	if(desk)
     	screenSize = desk->screenGeometry(0);

    std::cout<<"Printing the screen geometry x :";
    std::cout<<screenSize.x() <<"y : "<<screenSize.y();
    std::cout<<"\n";

//	USviewerWidget->hide();
	preopViewerWidget->hide();
	//videoWidget->show();
	//videoWidget->setFixedSize(400,400);


	// QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
	// sizePolicy.setHeightForWidth(true);
	// videoWidget->setSizePolicy(sizePolicy);

	/* add the video widget , USviewer and the preopview in a layout*/
    // QGridLayout *leftLayout = new QGridLayout();
    // leftLayout->addWidget(videoWidget,0,0);
    // leftLayout->addWidget(USviewerWidget,1,0);
    // leftLayout->addWidget(preopViewerWidget,1,0);
    
    //QVBoxLayout *leftLayout = new QVBoxLayout();
    //leftLayout->addWidget(videoWidget,1,Qt::AlignTop);
	//leftLayout->addWidget(USviewerWidget,1);
   // leftLayout->addWidget(preopViewerWidget,1);



    
    QWidget* viewerWidget = new QWidget(this);
    QVBoxLayout *viewerLayout = new QVBoxLayout();
    viewerLayout->addWidget(USviewerWidget);
    viewerLayout->addWidget(preopViewerWidget);
    viewerLayout->setSpacing(0);
	viewerLayout->setMargin(0);


    viewerWidget->setLayout(viewerLayout);
    
	QWidget* leftWidget = new QWidget();
    //QHBoxLayout* leftLayout = new QHBoxLayout();
    QVBoxLayout* leftLayout = new QVBoxLayout();
//    leftLayout->addWidget(videoWidget,1);
    leftLayout->addWidget(justWidget,2);
    leftLayout->addWidget(viewerWidget,1);
    leftLayout->setSpacing(0);
    leftLayout->setMargin(0);

    leftWidget->setLayout(leftLayout);

    leftWidget->setFixedSize(((screenSize.width()*3/4)-10),screenSize.height());
	videoWidget->setFixedSize(screenSize.height()*5/8*4/3,screenSize.height()*5/8);


	//USviewerWidget->hide();
	/*-------------------- Add the top widget and the browser widget to the mainlayout-----------------------*/
    //QGridLayout *mainLayout = new QGridLayout();
    QHBoxLayout* mainLayout = new QHBoxLayout();
//    mainLayout->addWidget(topWidget,0,Qt::AlignTop);
//    mainLayout->addWidget(leftWidget,0,Qt::AlignLeft);

    mainLayout->addWidget(leftWidget,7,Qt::AlignLeft);
    //mainLayout->setSpacing(0);
    //mainLayout->addWidget(browserWidget,0,Qt::AlignBottom);
    mainLayout->addWidget(browserWidget,0,Qt::AlignRight);
    //mainLayout->addWidget(rightWidget,2,Qt::AlignRight);
    //this->setLayout(layout);
    // viewerWidget->setLayout(layout);
    this->setLayout(mainLayout);
	this->show();

	USviewerWidget->setStyleSheet("background-color:black;");
    leftWidget->setStyleSheet("background-color:black;");
   // this->setStyleSheet("background-color:black;");


	/* Create new lap US mouse */
	mouse = new LapUSMouse(daVinci,this);
//	mouse->show();	

	connect(mouse,SIGNAL(pinched(int ,int) ),this,SLOT(mouseClicked(int,int)));
	connect(mouse,SIGNAL(moved(int ,int) ),this,SLOT(mouseMoved(int,int)));
	connect(mouse,SIGNAL(released()),this,SLOT(mouseReleased()));

	connect(browserWidget,SIGNAL(updateUSImage(QListWidgetItem*)),this,SLOT(showItem(QListWidgetItem*)));
	connect(browserWidget,SIGNAL(updatePreopImage(QListWidgetItem*)),this,SLOT(showItemPreop(QListWidgetItem*)));
//	app.exec();

	//connect(callbacks, pinched())
	//this->resize(600,500);
}
Пример #2
0
QPoint StatusDialog::desktopCenter()
{
  QDesktopWidget desktop;
  return QPoint(desktop.width() / 2 - size().width() / 2, desktop.height() / 2 - size().height() / 2);
}
Пример #3
0
QString validHtml(const QString &html, bool allowReplacement, QTextCursor *tc)
	{
	QDesktopWidget dw;
	ValidDocument oValidDocument(allowReplacement);

	QRectF qr = dw.availableGeometry();
	oValidDocument.setTextWidth(qr.width() / 2);
	oValidDocument.setDefaultStyleSheet(qApp->styleSheet());

	oValidDocument.setHtml(html);
	bool fIsValid = oValidDocument.isValid();

	QStringList qslAllowed = allowedSchemes();
	for (QTextBlock qtb = oValidDocument.begin(); qtb != oValidDocument.end(); qtb = qtb.next())
		{
		for (QTextBlock::iterator qtbi = qtb.begin(); qtbi != qtb.end(); ++qtbi)
			{
			const QTextFragment &qtf = qtbi.fragment();
			QTextCharFormat qcf = qtf.charFormat();
			if (! qcf.anchorHref().isEmpty())
				{
				QUrl url(qcf.anchorHref());
				if (! url.isValid() || ! qslAllowed.contains(url.scheme()))
					{
					QTextCharFormat qcfn = QTextCharFormat();
					QTextCursor qtc(&oValidDocument);
					qtc.setPosition(qtf.position(), QTextCursor::MoveAnchor);
					qtc.setPosition(qtf.position()+qtf.length(), QTextCursor::KeepAnchor);
					qtc.setCharFormat(qcfn);
					qtbi = qtb.begin();
					}
				}
			if (qcf.isImageFormat())
				{
				QTextImageFormat qtif = qcf.toImageFormat();
				QUrl url(qtif.name());
				if (! qtif.name().isEmpty() && ! url.isValid())
					fIsValid = false;
				}
			}
		}

	oValidDocument.adjustSize();
	QSizeF s = oValidDocument.size();

	if (!fIsValid || (s.width() > qr.width()) || (s.height() > qr.height())) {
		oValidDocument.setPlainText(html);
		oValidDocument.adjustSize();
		s = oValidDocument.size();

		if ((s.width() > qr.width()) || (s.height() > qr.height())) {
			QString errorMessage = "[[ Text object too large to display ]]";
			if (tc) {
				tc->insertText(errorMessage);
				return QString();
			} else {
				return errorMessage;
			}
		}
	}

	if (tc) {
		QTextCursor tcNew(&oValidDocument);
		tcNew.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
		tc->insertFragment(tcNew.selection());
		return QString();
	} else {
		return oValidDocument.toHtml();
	}
}
Пример #4
0
MainPage::MainPage(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{   
     ui.setupUi(this);

     this->LoadQSS();

     m_mousePressed = false;

     QObject::connect(ui.toolButtonHardware, SIGNAL(clicked()), this, SLOT(HardwareInforClicked()));
     QObject::connect(ui.toolButtonTempManagement, SIGNAL(clicked()), this, SLOT(TemperatureClicked()));
     QObject::connect(ui.toolButtonTestItem, SIGNAL(clicked()), this, SLOT(TestItemClicked()));

     QObject::connect(ui.pushButtonMin, SIGNAL(clicked()), this, SLOT(MinButtonClicked()));
     QObject::connect(ui.pushButtonClose, SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
     QObject::connect(ui.pushButtonUpdate, SIGNAL(clicked()), this, SLOT(UpdateButtonClicked()));

     QObject::connect(&m_checkNewTimer, SIGNAL(timeout()), this, SLOT(CheckNewTimerTimeout()));
     QObject::connect(&m_downloadNewTimer, SIGNAL(timeout()), this, SLOT(DownloadNewTimerTimeout()));

     // 隐藏默认窗口边框和标题栏
     this->setWindowFlags(Qt::Window|Qt::FramelessWindowHint|Qt::WindowSystemMenuHint
         |Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint);

     this->setWindowIcon(QIcon(":/ControlImage/Main.png"));

     QString title = MAIN_TITLE;
     title += LAppParam::GetAppVersion();
     this->ui.labelTitle->setText(title);

     this->ui.pushButtonUpdate->setVisible(false);

    // 获取当前系统DPI, 当前系统DPI除以设计时DPI值, 则得到UI放大系数
    const float DESIGN_DPI = 96.0f; // 设计时DPI
    QPainter painter(this);
    QPaintDevice* pDevice = painter.device();
    PrintLogW(L"System DPI X: %d, Y: %d", pDevice->logicalDpiX(), pDevice->logicalDpiY());
    float ratioX = pDevice->logicalDpiX()/DESIGN_DPI;
    float ratioY = pDevice->logicalDpiY()/DESIGN_DPI;
    m_uiRatio = ratioX > ratioY ? ratioX : ratioY;
    if (m_uiRatio < 1.0f)
        m_uiRatio = 1.0f;
    PrintLogW(L"UI Ratio: %f", m_uiRatio);

    // 根据比例重新调整主UI大小, 并居中显示
    int width = this->geometry().width() * m_uiRatio;
    int height = this->geometry().height() * m_uiRatio;
    this->setFixedSize(width, height);
    QDesktopWidget* pDesk = QApplication::desktop();
    this->move((pDesk->width() - width) / 2, (pDesk->height() - height) / 2);

    // 显示启动画面
    QPixmap originalImage(".\\Image\\Background\\splash.png");
    QSize imageSize(originalImage.width() * m_uiRatio, originalImage.height() * m_uiRatio);
    QPixmap scaledImage = originalImage.scaled(imageSize, Qt::KeepAspectRatio);
    QFont splashFont("Microsoft YaHei UI", 10);
    m_splashScreen.setFont(splashFont);
    m_splashScreen.setPixmap(scaledImage);
    m_splashScreen.show();
    
    width = ui.stackedWidget->width() * m_uiRatio;
    height = ui.stackedWidget->height() * m_uiRatio;

    m_splashScreen.showMessage(QObject::tr("Creating Hardware Page..."), Qt::AlignLeft | Qt::AlignTop, Qt::red);
    m_pHardwareInforPage = new HardwareInforPage(m_uiRatio);
    m_pHardwareInforPage->SetSplashScreen(&m_splashScreen);
    m_pHardwareInforPage->setFixedSize(width, height);
    m_pHardwareInforPage->InitHardwareInfor();
    ui.stackedWidget->addWidget(m_pHardwareInforPage);
    
    m_splashScreen.showMessage(QObject::tr("Creating Temperature Page..."), Qt::AlignLeft | Qt::AlignTop, Qt::red);
    m_pTempManagementPage = new TempManagementPage();
    m_pTempManagementPage->setFixedSize(width, height);
    ui.stackedWidget->addWidget(m_pTempManagementPage);

    m_splashScreen.showMessage(QObject::tr("Creating Test Item Page..."), Qt::AlignLeft | Qt::AlignTop, Qt::red);
    m_pTestItemPage = new TestItemPage(m_uiRatio);
    m_pTestItemPage->setFixedSize(width, height);
    ui.stackedWidget->addWidget(m_pTestItemPage);


    if (APP_NORMAL == LAppParam::GetStartMode())
        ui.stackedWidget->setCurrentWidget(m_pHardwareInforPage);
    else if (APP_RESTARTAGING == LAppParam::GetStartMode())
        ui.stackedWidget->setCurrentWidget(m_pTestItemPage);
    else
        ui.stackedWidget->setCurrentWidget(m_pTestItemPage);
    
}
double get_screen_dpi()
{
	QDesktopWidget *mydesk = qApp->desktop();
	return mydesk->physicalDpiX();
}
Пример #6
0
/*! \internal */
QSize QImageDocumentSelector::sizeHint() const
{
    QDesktopWidget *desktop = QApplication::desktop();
    return QSize(width(),
                 desktop->availableGeometry(desktop->screenNumber(this)).height());
}
Пример #7
0
double get_screen_dpi()
{
	QDesktopWidget *mydesk = application->desktop();
	return mydesk->physicalDpiX();
}
Пример #8
0
void PicturePopup::popUp(  const QString & strCaption
						 , long			lTimeToShow
						 , long			lTimeToLive
						 , long			lTimeToHide
						 )
{
	const QPixmap*	pict  = pixmap();
	int				width = pict->width();
	int				height= pict->height();
	resize(width,height);

	m_nSkinHeight	= height;
	m_nSkinWidth	= width;

	unsigned int nDesktopHeight = 0;
	unsigned int nDesktopWidth  = 0;
	unsigned int nScreenWidth   = 0;
	unsigned int nScreenHeight  = 0;
	
	QRect rcDesktop;
	QRect rcScreen;
	m_strCaption	= strCaption;
	m_lTimeToShow	= lTimeToShow;
	m_lTimeToLive	= lTimeToLive;
	m_lTimeToHide	= lTimeToHide;

    QDesktopWidget* desktopWidget = QApplication::desktop();			// get the desktop
	int primaryScreen = desktopWidget->primaryScreen();					// get the primary screen

    rcDesktop		= desktopWidget->availableGeometry(primaryScreen);	// get the desktop rectangle
	rcScreen		= desktopWidget->screenGeometry(primaryScreen);		// get the screen geometry

	nDesktopWidth	= rcDesktop.width();
	nDesktopHeight	= rcDesktop.height();
	nScreenWidth	= rcScreen.width();
	nScreenHeight	= rcScreen.height();

    if(nScreenWidth < 1024)
    {
	    m_nSkinHeight = 100;
	    m_nSkinWidth = 70;
    }
 	bool bTaskbarOnRight	= nDesktopWidth  < nScreenWidth && rcDesktop.left() == 0;
 	bool bTaskbarOnLeft		= nDesktopWidth  < nScreenWidth && rcDesktop.left() != 0;
 	bool bTaskBarOnTop		= nDesktopHeight < nScreenHeight && rcDesktop.top() !=0;

	switch (m_nAnimStatus)
	{
		case IDT_HIDDEN:
			if (bTaskbarOnRight)
			{
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinWidth/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinWidth/m_nIncrement);
				m_nStartPosX			  = rcDesktop.right();
				m_nStartPosY			  = rcDesktop.bottom() - m_nSkinHeight;
				m_nTaskbarPlacement		  = TASKBAR_ON_RIGHT;
			}
			else if (bTaskbarOnLeft)
			{
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinWidth/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinWidth/m_nIncrement);
				m_nStartPosX			  = rcDesktop.left() - m_nSkinWidth;
				m_nStartPosY			  = rcDesktop.bottom() - m_nSkinHeight;
				m_nTaskbarPlacement		  = TASKBAR_ON_LEFT;
			}
			else if (bTaskBarOnTop)
			{
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinHeight/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinHeight/m_nIncrement);
				m_nStartPosX			  = rcDesktop.right() - m_nSkinWidth;
				m_nStartPosY			  = rcDesktop.top() - m_nSkinHeight;
				m_nTaskbarPlacement		  = TASKBAR_ON_TOP;
			}
			else //if (bTaskbarOnBottom)
			{
				// Taskbar is on the bottom or Invisible
                m_nTaskbarHeight		  = nScreenHeight - nDesktopHeight;
				m_lDelayBetweenShowEvents = m_lTimeToShow/(m_nSkinHeight/m_nIncrement);
				m_lDelayBetweenHideEvents = m_lTimeToHide/(m_nSkinHeight/m_nIncrement);
				m_nStartPosX		      = rcDesktop.right() - m_nSkinWidth;
				m_nStartPosY			  = rcDesktop.bottom();
				m_nTaskbarPlacement		  = TASKBAR_ON_BOTTOM;
			}
			m_nCurrentPosX = m_nStartPosX;
			m_nCurrentPosY = m_nStartPosY;
            m_pTimerAppear->start(m_lDelayBetweenShowEvents);
			break;
		case IDT_WAITING:
			repaint();
            m_pTimerWait->stop();
			m_pTimerWait->setSingleShot(true);
            m_pTimerWait->start(m_lTimeToLive);
			break;
		case IDT_APPEARING:
			repaint();
			break;
		case IDT_DISAPPEARING:
            m_pTimerDisappear->stop();
			m_pTimerWait->setSingleShot(true);
            m_pTimerWait->start(m_lTimeToLive);
			if (bTaskbarOnRight)
			{
				m_nCurrentPosX=rcDesktop.right() - m_nSkinWidth;
			}
			else if (bTaskbarOnLeft)
			{
				m_nCurrentPosX=rcDesktop.left();
			}
			else if (bTaskBarOnTop)
			{
				m_nCurrentPosY=rcDesktop.top();
			}
			else //if (bTaskbarOnBottom)
			{
				m_nCurrentPosY=rcDesktop.bottom() - m_nSkinHeight;
			}
			setGeometry(m_nCurrentPosX, m_nCurrentPosY, m_nSkinWidth, m_nSkinHeight);
			repaint();
			break;
	}
}
Пример #9
0
EtaKeyboard::EtaKeyboard(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowFlags(Qt::WindowStaysOnTopHint |
                   Qt::FramelessWindowHint |
                   Qt::WindowSystemMenuHint |
                   Qt::WindowDoesNotAcceptFocus |
                   Qt::X11BypassWindowManagerHint);

    QDesktopWidget dw;
    screenWidth = dw.screenGeometry(dw.primaryScreen()).width();
    screenHeight = dw.screenGeometry(dw.primaryScreen()).height();

    key_height = screenHeight / 16;
    key_width = screenWidth / 26;
    dock_height = screenHeight / 30;
    m_width = 13*key_width;
    m_height = key_height*4+dock_height;

    configpath = QDir::homePath() + "/.config/etak/config.ini";
    color = "gray";
    Settings::setLanguage("trq");
    Settings::setAutoShowBool(true);

    QFileInfo checkConfig(configpath);

    if (checkConfig.exists() && checkConfig.isFile()) {
        preferences = new QSettings(configpath,QSettings::IniFormat);
        preferences->beginGroup("etak");
        Settings::setLanguage(preferences->value("Language").toString());
        color= preferences->value("Color").toString();
        Settings::setAutoShowBool(preferences->value("AutoShow").toBool());
        preferences->endGroup();
    }

    Settings::setColors(color); // 'blue' or 'gray'
    Helpers::langChange(Settings::getLanguage()); // intialization of X keyboard layout as trq



    setStyleSheet("background-color: "+Settings::getBackgroundColor()+";");

    setGeometry(screenWidth/2+m_width,0,m_width,0);



    out = LabelInstance::Instance();  // Output text right up to keyboard
    out->setParent(this);
    out->setGeometry(0,0,m_width,dock_height);
    out->setStyleSheet("QLabel{color: white; qproperty-alignment: AlignCenter;}");
    QFont f;
    f.setPointSize(key_height / 5);
    out->setFont(f);


    settingsRectangle = new QDialog(this,Qt::X11BypassWindowManagerHint);
    settingsRectangle->setStyleSheet("background-color: "+Settings::getBackgroundColor()+";");
    settingsRectangle->hide();

    toggleAuto = new QPushButton(settingsRectangle);
    toggleAuto->setGeometry(0,0,key_width*2,dock_height);
    toggleAuto->setCheckable(true);
    toggleAuto->setChecked(Settings::getAutoShowBool());
    if(Settings::getAutoShowBool()) {
        toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Kapat"));
    } else {
        toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Aç"));
    }
    toggleAuto->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra());
    QFont g;
    g.setPointSize(key_height / 9);
    toggleAuto->setFont(g);

    connect(toggleAuto,SIGNAL(clicked()),this,SLOT(toggleAutoShow()));

    passwordButton = new QPushButton(this);
    passwordButton->setGeometry(1,1,dock_height,dock_height);
    passwordButton->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra());
    passwordButton->setCheckable(true);
    passwordButton->setChecked(false);
    passwordButton->setText("P");
    g.setBold(true);
    g.setPointSize(key_height/4);
    passwordButton->setFont(g);
    QRegion *region = new QRegion(*(new QRect(passwordButton->x()+2,passwordButton->y()+2,dock_height-6,dock_height-6)),QRegion::Ellipse);
    passwordButton->setMask(*region);
    connect(passwordButton,SIGNAL(clicked()),this,SLOT(togglePassword()));


    QHash<int, QList<unsigned int> > hash;
    QList<unsigned int> listtmp;
    for ( int i = 24 ; i < 36 ; ++i) {
        listtmp.append(i);
    }
    hash.insert(1,listtmp);
    listtmp.clear();
    for ( int j = 38 ; j < 49 ; ++j) {
        listtmp.append(j);
    }
    hash.insert(2,listtmp);
    listtmp.clear();
    for ( int k = 52 ; k < 61 ; ++k) {
        listtmp.append(k);
    }
    hash.insert(3,listtmp);
    listtmp.clear();
    Key *tmp;
    int posrow = key_width;
    int posy = dock_height;
    int posx;

    AlphaKey *tmp2;

    QString tmpLanguageLayout ="";
    if (Settings::getLanguage() == "trq") {
        tmpLanguageLayout = "TRQ";
    } else if (Settings::getLanguage() == "trf") {
        tmpLanguageLayout = "TRF";
    } else if (Settings::getLanguage() == "arabic") {
        tmpLanguageLayout = QString::fromUtf8("العربئة");
    }

    lang = new SpecialKey(settingsRectangle,0,dock_height,key_width,key_height,tmpLanguageLayout);
    connect(lang,SIGNAL(clicked()),this,SLOT(changeLanguage()));

    tmp2 = new AlphaKey(this,0,dock_height,key_width,key_height,9,"Esc"); //Escape
    alpha_keys.append(tmp2);

    change = new SpecialKey(this,0,key_height+dock_height,key_width*3/2,key_height,"?123+");
    connect(change,SIGNAL(clicked()),this,SLOT(toggleAlterns()));
    leftshift = new AlphaKey(this,0,key_height*2+dock_height,key_width*2,key_height,50,QString::fromUtf8("↑")); //caps
    alpha_keys.append(leftshift);
    connect(leftshift,SIGNAL(clicked()),this,SLOT(toggleCaps()));
    for (int y = 1 ; y<=3 ; ++y) {
        posx=posrow;
        for (int x =0; x < hash[y].length(); ++x) {
            if (y==2 && x==10) {
                tmp = new Key(this,posx,posy,key_width*3/2,key_height,hash[y].at(x));
            } else {
                tmp = new Key(this,posx,posy,key_width,key_height,hash[y].at(x));
            }
            keys.append(tmp);
            posx += key_width;
        }
        posy += key_height;
        posrow += key_width / 2;
    }
    tmp2 = new AlphaKey(this, posx, posy - key_height, key_width * 2, key_height, 22, QString::fromUtf8("⌫")); //backspace
    alpha_keys.append(tmp2);

    settingsButton = new QPushButton(this);
    settingsButton->setGeometry(0,posy,key_width,key_height);
    settingsButton->setStyleSheet(Settings::getStyleSheet());

    QPixmap pm(":/icons/gear.png");
    settingsButton->setIcon(QIcon(pm));
    settingsButton->setIconSize(QSize(settingsButton->width()*2/3,settingsButton->height()*2/3));

    connect(settingsButton,SIGNAL(clicked()),this,SLOT(toggleSettings()));

    hideButton = new QPushButton(this);
    hideButton->setGeometry(m_width-dock_height-1,1,dock_height,dock_height);
    QPixmap pm2(":/icons/window-close.png");
    hideButton->setIcon(QIcon(pm2));
    hideButton->setIconSize(QSize(hideButton->width(),hideButton->height()));

    connect(hideButton,SIGNAL(clicked()),this,SLOT(animationToggle()));

    colorButton = new QPushButton(settingsRectangle);
    colorButton->setGeometry(key_width,dock_height,key_width,key_height);
    colorButton->setStyleSheet(Settings::getStyleSheet());

    connect(colorButton,SIGNAL(clicked()),this,SLOT(toggleColor()));

    tmp = new Key(this,key_width,posy,key_width,key_height,20); //asterix
    bottom_keys.append(tmp);
    tmp = new Key(this,key_width*2,posy,key_width*13/2,key_height,65); // space
    bottom_keys.append(tmp);
    tmp = new Key(this,key_width*17/2,posy,key_width,key_height,51); // comma
    bottom_keys.append(tmp);
    tmp = new Key(this,key_width*19/2,posy,key_width,key_height,61); // dot
    bottom_keys.append(tmp);

    tmp2 = new AlphaKey(this,key_width*21/2,posy,key_width*5/2,key_height,36,QString::fromUtf8("↵")); // enter
    alpha_keys.append(tmp2);

    server = new EtaLocalServer(this);
    Q_CHECK_PTR(server);
    const QString fullServerName =  QString(QDir::homePath()+"/"+SERVER_NAME);

    QFile file(fullServerName);
    if (file.exists()) {
         file.remove();
    }
    if (server->listen(QDir::homePath()+"/"+SERVER_NAME)) {
        //qDebug() << "Listenning";
    } else {
        //qDebug() << "Failed to listen";
    }
    connect(server, SIGNAL(newCommand(char*)), this, SLOT(onNewCommand(char*)));
    anime = new QPropertyAnimation(this, "geometry");
    tog =  false;
    QList<QString> alternatives;

    alternatives.append("1");
    alternatives.append("2");
    alternatives.append("3");
    alternatives.append("4");
    alternatives.append("5");
    alternatives.append("6");
    alternatives.append("7");
    alternatives.append("8");
    alternatives.append("9");
    alternatives.append("0");
    alternatives.append("braceleft");
    alternatives.append("braceright");

    alternatives.append("at");
    alternatives.append("numbersign");
    alternatives.append("dollar");
    alternatives.append("percent");
    alternatives.append("ampersand");
    alternatives.append("parenleft");
    alternatives.append("parenright");
    alternatives.append("minus");
    alternatives.append("less");
    alternatives.append("greater");
    alternatives.append("exclam");

    alternatives.append("semicolon");
    alternatives.append("colon");
    alternatives.append("apostrophe");
    alternatives.append("quotedbl");
    alternatives.append("question");
    alternatives.append("slash");
    alternatives.append("plus");
    alternatives.append("equal");
    alternatives.append("underscore");

     for (int cnt = 0; cnt < keys.size(); ++cnt) {
         keys.at(cnt)->setAlternString(alternatives.at(cnt));
     }
}
Пример #10
0
void tst_orientationchange::resizeEventOnOrientationChange()
{
    // This will test that when orientation 'changes', then
    // at most one resize event is generated.

    TestWidget *normalWidget = new TestWidget();
    TestWidget *fullScreenWidget = new TestWidget();
    TestWidget *maximizedWidget = new TestWidget();

    fullScreenWidget->showFullScreen();
    maximizedWidget->showMaximized();
    normalWidget->show();

    QCoreApplication::sendPostedEvents();
    QCoreApplication::sendPostedEvents();

    QCOMPARE(fullScreenWidget->resizeEventCount, 1);
    QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
    QCOMPARE(maximizedWidget->resizeEventCount, 1);
    QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
    QCOMPARE(normalWidget->resizeEventCount, 1);
    QCOMPARE(normalWidget->size(), normalWidget->resizeEventSize);

    fullScreenWidget->reset();
    maximizedWidget->reset();
    normalWidget->reset();

    // Assumes that Qt application is AVKON application.
    CAknAppUi *appUi = static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi());

    // Determine 'opposite' orientation to the current orientation.

    CAknAppUi::TAppUiOrientation orientation = CAknAppUi::EAppUiOrientationLandscape;
    if (fullScreenWidget->size().width() > fullScreenWidget->size().height()) {
        orientation = CAknAppUi::EAppUiOrientationPortrait;
    }

    TRAPD(err, appUi->SetOrientationL(orientation));

    QCoreApplication::sendPostedEvents();
    QCoreApplication::sendPostedEvents();

    // setOrientationL is not guaranteed to change orientation
    // (if emulator configured to support just portrait or landscape, then
    //  setOrientationL call shouldn't do anything).
    // So let's ensure that we do not get resize event twice.

    QVERIFY(fullScreenWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
    }
    QVERIFY(maximizedWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
    }
    QCOMPARE(normalWidget->resizeEventCount, 0);

    QDesktopWidget desktop;
    QRect qtAvail = desktop.availableGeometry(normalWidget);
    TRect clientRect = static_cast<CEikAppUi*>(CCoeEnv::Static()-> AppUi())->ClientRect();
    QRect symbianAvail = qt_TRect2QRect(clientRect);
    QCOMPARE(qtAvail, symbianAvail);

    // Switch orientation back to original
    orientation = orientation == CAknAppUi::EAppUiOrientationPortrait
                                 ? CAknAppUi::EAppUiOrientationLandscape
                                 : CAknAppUi::EAppUiOrientationPortrait;


    fullScreenWidget->reset();
    maximizedWidget->reset();
    normalWidget->reset();

    TRAP(err, appUi->SetOrientationL(orientation));

    QCoreApplication::sendPostedEvents();
    QCoreApplication::sendPostedEvents();

    // setOrientationL is not guaranteed to change orientation
    // (if emulator configured to support just portrait or landscape, then
    //  setOrientationL call shouldn't do anything).
    // So let's ensure that we do not get resize event twice.

    QVERIFY(fullScreenWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
    }
    QVERIFY(maximizedWidget->resizeEventCount <= 1);
    if (fullScreenWidget->resizeEventCount) {
        QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
    }
    QCOMPARE(normalWidget->resizeEventCount, 0);

    qtAvail = desktop.availableGeometry(normalWidget);
    clientRect = static_cast<CEikAppUi*>(CCoeEnv::Static()-> AppUi())->ClientRect();
    symbianAvail = qt_TRect2QRect(clientRect);
    QCOMPARE(qtAvail, symbianAvail);

    TRAP(err, appUi->SetOrientationL(CAknAppUi::EAppUiOrientationUnspecified));

    delete normalWidget;
    delete fullScreenWidget;
    delete maximizedWidget;
}
Пример #11
0
QT_BEGIN_NAMESPACE

QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
{
    QWidget *widget = QWidget::find(window);
    if (!widget)
        return QPixmap();

    QRect grabRect = widget->frameGeometry();
    if (!widget->isWindow())
        grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint()));
    if (w < 0)
        w = widget->width() - x;
    if (h < 0)
        h = widget->height() - y;
    grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint()));

    QScreen *screen = qt_screen;
    QDesktopWidget *desktop = QApplication::desktop();
    if (!desktop)
        return QPixmap();
    if (desktop->numScreens() > 1) {
        const int screenNo = desktop->screenNumber(widget);
        if (screenNo != -1)
            screen = qt_screen->subScreens().at(screenNo);
        grabRect = grabRect.translated(-screen->region().boundingRect().topLeft());
    }

    if (screen->pixelFormat() == QImage::Format_Invalid) {
        qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer");
        return QPixmap();
    }

    if (screen->isTransformed()) {
        const QSize screenSize(screen->width(), screen->height());
        grabRect = screen->mapToDevice(grabRect, screenSize);
    }

    QWSDisplay::grab(false);
    QPixmap pixmap;
    QImage img(screen->base(),
               screen->deviceWidth(), screen->deviceHeight(),
               screen->linestep(), screen->pixelFormat());
    img = img.copy(grabRect);
    QWSDisplay::ungrab();

    if (screen->isTransformed()) {
        QMatrix matrix;
        switch (screen->transformOrientation()) {
        case 1: matrix.rotate(90); break;
        case 2: matrix.rotate(180); break;
        case 3: matrix.rotate(270); break;
        default: break;
        }
        img = img.transformed(matrix);
    }

    if (screen->pixelType() == QScreen::BGRPixel)
        img = img.rgbSwapped();

    return QPixmap::fromImage(img);
}
Пример #12
0
Wallpaper::Wallpaper(QMap<QString, QVariant> set, bool v, QWidget *parent) : MyWidget(parent) {

	this->setBorderArea(150,100);

	verbose = v;
	globSet = set;


	// The buttons to proceed or abort are always visible (i.e. not scrolled)
	ok = new CustomPushButton(tr("Okay, do it!"));
	cancel = new CustomPushButton(tr("Nooo, don't!"));
	QHBoxLayout *butLay = new QHBoxLayout;
	butLay->addStretch();
	butLay->addWidget(ok);
	butLay->addWidget(cancel);
	butLay->addStretch();

	CustomLine *line = new CustomLine;
	QVBoxLayout *botLay = new QVBoxLayout;
	botLay->addWidget(line);
	botLay->addLayout(butLay);

	this->addButtonLayout(botLay);

	connect(ok, SIGNAL(clicked()), this, SLOT(goAheadAndSetWallpaper()));
	connect(cancel, SIGNAL(clicked()), this, SLOT(animate()));

	QVBoxLayout *lay = new QVBoxLayout;

	// the widget title
	QLabel *title = new QLabel("<center><span style=\"font-size: 30pt; font-weight: bold\">" + tr("Set as Wallpaper") + "</span></center>");
	title->setStyleSheet("color: white");
	lay->addWidget(title);
	lay->addSpacing(10);


	// The filename is always set to this label
	filenameLabel = new CustomLabel("<center>---</center>");
	filenameLabel->setFontColor("lightgrey");
	filenameLabel->setItalic(true);
	lay->addWidget(filenameLabel);
	lay->addSpacing(20);


	// Label explaining the wm detection
	CustomLabel *wmDetectedLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Window Manager") + "</span></b> " + "<br><br>" + tr("PhotoQt tries to detect you window manager according to the environment variables set by your system. If it still got it wrong, you can change the window manager here manually."));
	wmDetectedLabel->setWordWrap(true);
	lay->addWidget(wmDetectedLabel);
	lay->addSpacing(10);

	// Combobox to change WM
	wm = new CustomComboBox;
	wm->setFontSize(15);
	wm->setBorder(1,"white");
	wm->addItem("KDE4","kde");
	wm->addItem("Gnome/Unity","gnome");
	wm->addItem("XFCE4","xfce");
	wm->addItem("Razor-Qt", "razor");
	wm->addItem(tr("Other"),"other");
	QHBoxLayout *wmLay = new QHBoxLayout;
	wmLay->addStretch();
	wmLay->addWidget(wm);
	wmLay->addStretch();
	lay->addLayout(wmLay);
	lay->addSpacing(10);


	// This message is used to show an (error or other) message depending on the window manager
	wmMessage = new CustomLabel;
	wmMessage->setAlignment(Qt::AlignCenter);
	wmMessage->setWordWrap(true);
	wmMessage->setVisible(false);
	lay->addSpacing(10);
	lay->addWidget(wmMessage);
	lay->addSpacing(20);

	connect(wm, SIGNAL(currentIndexChanged(int)), this, SLOT(wmSelected()));



	//////// GNOME SETTINGS /////////////

	// Some image options can be set (the label is globsl, because it is hidden/shown depending on wm choice)
	gnomePicOpsLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Picture Options") + "</span></b> " + "<br><br>" + tr("There are several picture options that can be set for the wallpaper image."));
	gnomePicOpsLabel->setMargin(5);
	gnomePicOpsLabel->setWordWrap(true);

	// A layout holding the image options
	QVBoxLayout *gnomePicOpsLayCenter = new QVBoxLayout;
	gnomeButGrp = new QButtonGroup;
	gnomePictureOptions.clear();
	// These options are possible
	QStringList picOpts;
	picOpts << "wallpaper";
	picOpts << "centered";
	picOpts << "scaled";
	picOpts << "zoom";
	picOpts << "spanned";
	// Setup radiobuttons, add to layout, to button group and store in QMap
	for(int i = 0; i < picOpts.size(); ++i) {
		CustomRadioButton *chk = new CustomRadioButton(picOpts.at(i));
		if(i == 3) chk->setChecked(true);
		gnomePicOpsLayCenter->addWidget(chk);
		gnomeButGrp->addButton(chk);
		gnomePictureOptions.insert(picOpts.at(i),chk);
	}
	// And center in a horizontal layout
	QHBoxLayout *gnomePicOpsLay = new QHBoxLayout;
	gnomePicOpsLay->addStretch();
	gnomePicOpsLay->addLayout(gnomePicOpsLayCenter);
	gnomePicOpsLay->addStretch();

	// Add label and button layout to central widget layout
	lay->addWidget(gnomePicOpsLabel);
	lay->addLayout(gnomePicOpsLay);



	////// THE FOLLOWING SCREEN SELECT IS USED BY DIFFERENT WMs //////

	QVBoxLayout *wmMonitorLayCenter = new QVBoxLayout;
	wmMonitorSelect.clear();
	QDesktopWidget desk;
	for(int i = 0; i < desk.screenCount(); ++i) {
		CustomCheckBox *mon = new CustomCheckBox(tr("Screen") + QString(" #%1").arg(i));
		mon->setChecked(true);
		wmMonitorLayCenter->addWidget(mon);
		wmMonitorSelect.insert(i,mon);
	}

	QHBoxLayout *wmMonitorLay = new QHBoxLayout;
	wmMonitorLay->addStretch();
	wmMonitorLay->addLayout(wmMonitorLayCenter);
	wmMonitorLay->addStretch();

	wmMonitorLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Select Monitors") + "</span></b> " + "<br><br>" + tr("The wallpaper can be set to either of the available monitors (or any combination)."));
	wmMonitorLabel->setWordWrap(true);
	wmMonitorLabel->setMargin(5);

	lay->addWidget(wmMonitorLabel);
	lay->addLayout(wmMonitorLay);



	/////// XFCE SETTINGS /////////////

	QVBoxLayout *xfcePicOpsLayCenter = new QVBoxLayout;

	xfceButGrp = new QButtonGroup;
	xfcePictureOptions.clear();
	QStringList xfcePicOpts;
	xfcePicOpts << "automatic";
	xfcePicOpts << "centered";
	xfcePicOpts << "tiled";
	xfcePicOpts << "spanned";
	xfcePicOpts << "scaled";
	xfcePicOpts << "magnified";
	for(int i = 0; i < xfcePicOpts.size(); ++i) {
		CustomRadioButton *chk = new CustomRadioButton(xfcePicOpts.at(i));
		if(i == 0) chk->setChecked(true);
		xfcePicOpsLayCenter->addWidget(chk);
		xfceButGrp->addButton(chk);
		xfcePictureOptions.insert(xfcePicOpts.at(i),chk);
	}

	QHBoxLayout *xfcePicOpsLay = new QHBoxLayout;
	xfcePicOpsLay->addStretch();
	xfcePicOpsLay->addLayout(xfcePicOpsLayCenter);
	xfcePicOpsLay->addStretch();

	xfcePicOpsLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Picture Options") + "</span></b> " + "<br><br>" + tr("There are several picture options that can be set for the wallpaper image."));
	xfcePicOpsLabel->setMargin(5);
	xfcePicOpsLabel->setWordWrap(true);

	lay->addWidget(xfcePicOpsLabel);
	lay->addLayout(xfcePicOpsLay);



	///////// OTHER SETTINGS ///////////

	otherFeh = new CustomRadioButton(tr("Use 'feh'"));
	otherFeh->setIndicatorImage(":/img/checkbox_checked.png",":/img/checkbox_checked.png",":/img/checkbox_unchecked.png",":/img/checkbox_unchecked.png");
	otherFeh->setChecked(true);
	otherNitrogen = new CustomRadioButton(tr("Use 'nitrogen'"));
	otherNitrogen->setIndicatorImage(":/img/checkbox_checked.png",":/img/checkbox_checked.png",":/img/checkbox_unchecked.png",":/img/checkbox_unchecked.png");

	QButtonGroup *otherGrp = new QButtonGroup;
	otherGrp->addButton(otherFeh);
	otherGrp->addButton(otherNitrogen);

	QHBoxLayout *externLay = new QHBoxLayout;
	externLay->addStretch();
	externLay->addWidget(otherFeh);
	externLay->addWidget(otherNitrogen);
	externLay->addStretch();
	connect(otherFeh, SIGNAL(clicked()), this, SLOT(swapFehNitrogen()));
	connect(otherNitrogen, SIGNAL(clicked()), this, SLOT(swapFehNitrogen()));

	otherNitrogenGrp = new QButtonGroup;
	otherNitrogenOptions.clear();
	QVBoxLayout *otherNitrogenPicOptLay = new QVBoxLayout;
	otherNitrogenPicOptLay->setMargin(5);
	QStringList listNitrogen;
	listNitrogen << "auto";
	listNitrogen << "centered";
	listNitrogen << "scaled";
	listNitrogen << "tiled";
	listNitrogen << "zoom";
	listNitrogen << "zoom-fill";
	QString eleN;
	foreach(eleN, listNitrogen) {
		CustomRadioButton *r = new CustomRadioButton("--set-" + eleN);
		r->setObjectName(eleN);
		if(eleN == "auto") r->setChecked(true);
		otherNitrogenPicOptLay->addWidget(r);
		otherNitrogenOptions.insert(eleN,r);
		otherNitrogenGrp->addButton(r);
	}
Пример #13
0
int main(int argc, char *argv[])
{
    signal(SIGINT, signalHandler);
    signal(SIGABRT, signalHandler);
    signal(SIGTERM, signalHandler);

    QApplication app(argc, argv);
    app.setOrganizationName("Genera");
#ifdef TEMPO
    app.setApplicationName("Tempo10");
#endif
#ifdef SNACK
    app.setApplicationName("Snack10");
#endif
#ifdef PRESENCIA
    app.setApplicationName("Presencia10");
    Utils::disableLeds();
#endif

    QString appPath = QApplication::applicationDirPath();

    QString configPath = "/mnt/jffs2/app.ini";
    settings = new QSettings(configPath, QSettings::IniFormat);

    QString lang = settings->value("lang", "es").toString();
    DEBUG("Language is: %s.", lang.toStdString().c_str());

    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
    QTranslator translator;
    if (lang == "es") {
        if (translator.load("app_es.qm", appPath + "/Resources/languages")) {
            app.installTranslator(&translator);
        } else {
            DEBUG("Unable to install app_es.qm translation.");
        }
    } else {
        if (translator.load("app_en.qm", appPath + "/Resources/languages")) {
            app.installTranslator(&translator);
        } else {
            DEBUG("Unable to install app_en.qm translation.");
        }
    }

    DEBUG("****************************************************************************");
    DEBUG("Equipo: %s", settings->value("tipoEquipo").toString().toStdString().c_str());
    DEBUG("NTP IP: %s", settings->value("ntpIP").toString().toStdString().c_str());
    DEBUG("Lang: %s", settings->value("lang").toString().toStdString().c_str());
    DEBUG("Empresa Holding: %s", settings->value("empresaHolding").toString().toStdString().c_str());
    DEBUG("serialEquipo: %s", settings->value("serialEquipo").toString().toStdString().c_str());
    DEBUG("identificadorEquipo: %s", settings->value("identificadorEquipo").toString().toStdString().c_str());
#ifdef PRESENCIA
    DEBUG("Tipo de Equipo: %s", (settings->value("presenciaType").toString() == "In") ? "Entrada" : "Salida");
#endif
    DEBUG("wsIp: %s", settings->value("wsIP").toString().toStdString().c_str());
    DEBUG("wsPort: %s", settings->value("wsPort").toString().toStdString().c_str());
    DEBUG("wsCargaMasivaURL: %s", settings->value("wsCargaMasivaURL").toString().toStdString().c_str());
    DEBUG("wsFirmwareUpdateURL: %s", settings->value("wsFirmwareUpdateURL").toString().toStdString().c_str());
    DEBUG("wsSincronizacionURL: %s", settings->value("wsSincronizacionURL").toString().toStdString().c_str());
    DEBUG("wsVerificaPersonaURL: %s", settings->value("wsVerificaPersonaURL").toString().toStdString().c_str());
    DEBUG("wsEnrollURL: %s", settings->value("wsEnrollURL").toString().toStdString().c_str());
    DEBUG("wsAlarmasURL: %s", settings->value("wsAlarmasURL").toString().toStdString().c_str());
    DEBUG("****************************************************************************");

    int WIDTH = 240;
    int HEIGHT = 320;
    int screenWidth, screenHeight;
    int x, y;

    window = new MainWindow(settings);
    QDesktopWidget *desktop = QApplication::desktop();

    screenWidth = desktop->width();
    screenHeight = desktop->height();

    x = (screenWidth - WIDTH) / 2;
    y = (screenHeight - HEIGHT) / 2;

    window->resize(WIDTH, HEIGHT);
    window->move(x, y);
    window->setWindowOpacity(1.0);
    window->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);

    window->showFullScreen();

    int rc = app.exec();

    if (window) {
        DEBUG("MainWindow Flag: %d", window->flag);
        if (window->flag == 500) {
            if (settings) {
                delete settings;
            }
            if (window)   {
                delete window;
            }

            DEBUG("Bye Bye...");
            fflush(stdout);
            fflush(stderr);
            execl("/sbin/reboot", "reboot", NULL);
            return 0;
        }
    }

    if (settings) {
        delete settings;
    }
    if (window)   {
        delete window;
    }

    DEBUG("Bye Bye...");
    fflush(stdout);
    fflush(stderr);
    return rc;
}
Пример #14
0
static void parseWindow(){
    // option defaults
    bool fullScreen = false; // should it be fullscreen?
    bool disabled = false;
    // what size? (default is fit around widgets. Ignored for fullscreen.)
    int width=-1,height=-1; 
    // if set, move the window to a screen of the given dimensions
    int swidth=-1,sheight=-1;
    // title if any
    char title[256];
    // "tab" number - used to generate a shortcut to pull this window
    // to the front
    int number=-1;
    
    title[0]=0;
    int screensetline=-1;
    
    // set this window to not inverse
    ConfigManager::inverse=false;
    
    // get window options
    bool done = false;
    while(!done){
        switch(tok.getnext()){
        case T_OCURLY:
            done = true;
            break;
        case T_TITLE:
            tok.getnextstring(title);
            break;
        case T_NUMBER:
            number = tok.getnextint();
            break;
        case T_INVERSE:
            ConfigManager::inverse=true;
            break;
        case T_FULLSCREEN:
            fullScreen = true;
            break;
        case T_SIZE: // size of window if not fullscreen
            width = tok.getnextint();
            tok.getnextcheck(T_COMMA);
            height = tok.getnextint();
            break;
        case T_SCREEN: // move to a screen of given dimensions
            swidth = tok.getnextint();
            tok.getnextcheck(T_COMMA);
            screensetline = tok.getline();
            sheight = tok.getnextint();
            break;
        case T_DISABLE: // the window is disabled and should be immediately closed
            disabled=true;
            break;
        }
    }
    
    // create a window
    Window *w = getApp()->createWindow();
    if(number>=0)
        getApp()->setWindowKey(number,w);
    ConfigManager::setStyle(w);
    // and parse the contents
    parseContainer(w->centralWidget());
    
    if(*title){
        w->setWindowTitle(title);
    }
    
    // move the window if we want to
    if(swidth>0){
        QDesktopWidget *dt = QApplication::desktop();
        QRect r;
        int i;
        for(i=0;i<dt->screenCount();i++){
            r = dt->screenGeometry(i);
            printf("Found display : %d x %d\n",r.width(),r.height());
            if(r.width() == swidth && r.height()==sheight)
                break;
        }
        if(i==dt->screenCount())
            throw Exception(screensetline).set("could not find display of %d x %d",swidth,sheight);
        w->move(r.topLeft());
    }
    
    
    // finally show the window and resize if required
    if(disabled){
        w->hide(); // marked "disabled" in the config
    } else {
        w->setWindowState(Qt::WindowActive);
        w->raise();
        w->activateWindow();
        if(fullScreen){
            w->showFullScreen();
        } else {
            if(width>0)
                w->resize(width,height);
            w->showNormal();
        }
    }
}
int QtWidgetsTweakletImpl::GetClosestScreenNumber(const QRect& r)
{
  QDesktopWidget *desktop = QApplication::desktop();
  return desktop->screenNumber(QPoint(r.x() + r.width()/2, r.y() + r.height()/2));
}
Пример #16
0
static void* ui_companion_qt_init(void)
{
   ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
   MainWindow *mainwindow = NULL;
   QHBoxLayout *browserButtonsHBoxLayout = NULL;
   QVBoxLayout *layout = NULL;
   QVBoxLayout *launchWithWidgetLayout = NULL;
   QHBoxLayout *coreComboBoxLayout = NULL;
   QMenuBar *menu = NULL;
   QDesktopWidget *desktop = NULL;
   QMenu *fileMenu = NULL;
   QMenu *editMenu = NULL;
   QMenu *viewMenu = NULL;
   QMenu *viewClosedDocksMenu = NULL;
   QRect desktopRect;
   QDockWidget *thumbnailDock = NULL;
   QDockWidget *thumbnail2Dock = NULL;
   QDockWidget *thumbnail3Dock = NULL;
   QDockWidget *browserAndPlaylistTabDock = NULL;
   QDockWidget *coreSelectionDock = NULL;
   QTabWidget *browserAndPlaylistTabWidget = NULL;
   QWidget *widget = NULL;
   QWidget *browserWidget = NULL;
   QWidget *playlistWidget = NULL;
   QWidget *coreSelectionWidget = NULL;
   QWidget *launchWithWidget = NULL;
   ThumbnailWidget *thumbnailWidget = NULL;
   ThumbnailWidget *thumbnail2Widget = NULL;
   ThumbnailWidget *thumbnail3Widget = NULL;
   QPushButton *browserDownloadsButton = NULL;
   QPushButton *browserUpButton = NULL;
   QPushButton *browserStartButton = NULL;
   ThumbnailLabel *thumbnail = NULL;
   ThumbnailLabel *thumbnail2 = NULL;
   ThumbnailLabel *thumbnail3 = NULL;
   QAction *editSearchAction = NULL;
   QAction *loadCoreAction = NULL;
   QAction *unloadCoreAction = NULL;
   QAction *exitAction = NULL;
   QComboBox *launchWithComboBox = NULL;
   QSettings *qsettings = NULL;

   if (!handle)
      return NULL;

   handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize());
   handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init());

   desktop = qApp->desktop();
   desktopRect = desktop->availableGeometry();

   mainwindow = handle->window->qtWindow;

   qsettings = mainwindow->settings();

   mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT));
   mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect));

   mainwindow->setWindowTitle("RetroArch");
   mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING);

   widget = new QWidget(mainwindow);
   widget->setObjectName("tableWidget");

   layout = new QVBoxLayout();
   layout->addWidget(mainwindow->contentTableWidget());

   widget->setLayout(layout);

   mainwindow->setCentralWidget(widget);

   menu = mainwindow->menuBar();

   fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE));

   loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked()));
   loadCoreAction->setShortcut(QKeySequence("Ctrl+L"));

   unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction()));
   unloadCoreAction->setObjectName("unloadCoreAction");
   unloadCoreAction->setEnabled(false);
   unloadCoreAction->setShortcut(QKeySequence("Ctrl+U"));

   exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close()));
   exitAction->setShortcut(QKeySequence::Quit);

   editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT));
   editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus()));
   editSearchAction->setShortcut(QKeySequence::Find);

   viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW));
   viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS));
   viewClosedDocksMenu->setObjectName("viewClosedDocksMenu");

   QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow()));

   viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog()));

   playlistWidget = new QWidget();
   playlistWidget->setLayout(new QVBoxLayout());
   playlistWidget->setObjectName("playlistWidget");

   playlistWidget->layout()->addWidget(mainwindow->playlistListWidget());

   browserWidget = new QWidget();
   browserWidget->setLayout(new QVBoxLayout());
   browserWidget->setObjectName("browserWidget");

   browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY));
   browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP));
   browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES));

   QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked()));
   QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked()));
   QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked()));

   browserButtonsHBoxLayout = new QHBoxLayout();
   browserButtonsHBoxLayout->addWidget(browserUpButton);
   browserButtonsHBoxLayout->addWidget(browserStartButton);
   browserButtonsHBoxLayout->addWidget(browserDownloadsButton);

   qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout);
   browserWidget->layout()->addWidget(mainwindow->dirTreeView());

   browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget();
   browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget");

   /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too
    * setCoreActions()
    * onTabWidgetIndexChanged()
    * onCurrentListItemChanged()
    */
   browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS));
   browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER));

   browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow);
   browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock");
   browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER));
   browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock);

   browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum));

   thumbnailWidget = new ThumbnailWidget();
   thumbnail2Widget = new ThumbnailWidget();
   thumbnail3Widget = new ThumbnailWidget();

   thumbnailWidget->setLayout(new QVBoxLayout());
   thumbnail2Widget->setLayout(new QVBoxLayout());
   thumbnail3Widget->setLayout(new QVBoxLayout());

   thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

   thumbnail = new ThumbnailLabel();
   thumbnail->setObjectName("thumbnail");

   thumbnail2 = new ThumbnailLabel();
   thumbnail2->setObjectName("thumbnail2");

   thumbnail3 = new ThumbnailLabel();
   thumbnail3->setObjectName("thumbnail3");

   thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

   QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&)));
   QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&)));
   QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&)));

   thumbnailWidget->layout()->addWidget(thumbnail);
   thumbnail2Widget->layout()->addWidget(thumbnail2);
   thumbnail3Widget->layout()->addWidget(thumbnail3);

   thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow);
   thumbnailDock->setObjectName("thumbnailDock");
   thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART));
   thumbnailDock->setWidget(thumbnailWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock);

   thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow);
   thumbnail2Dock->setObjectName("thumbnail2Dock");
   thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN));
   thumbnail2Dock->setWidget(thumbnail2Widget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock);

   thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow);
   thumbnail3Dock->setObjectName("thumbnail3Dock");
   thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT));
   thumbnail3Dock->setWidget(thumbnail3Widget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock);

   mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock);
   mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock);

   /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */
   thumbnailDock->raise();

   coreSelectionWidget = new QWidget();
   coreSelectionWidget->setLayout(new QVBoxLayout());

   launchWithComboBox = mainwindow->launchWithComboBox();

   launchWithWidgetLayout = new QVBoxLayout();

   launchWithWidget = new QWidget();
   launchWithWidget->setLayout(launchWithWidgetLayout);

   coreComboBoxLayout = new QHBoxLayout();

   mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
   mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
   mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));

   coreComboBoxLayout->addWidget(launchWithComboBox);
   coreComboBoxLayout->addWidget(mainwindow->startCorePushButton());
   coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton());
   coreComboBoxLayout->addWidget(mainwindow->runPushButton());
   coreComboBoxLayout->addWidget(mainwindow->stopPushButton());

   mainwindow->stopPushButton()->hide();

   coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1);

   launchWithWidgetLayout->addLayout(coreComboBoxLayout);

   coreSelectionWidget->layout()->addWidget(launchWithWidget);

   coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding));

   coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow);
   coreSelectionDock->setObjectName("coreSelectionDock");
   coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE));
   coreSelectionDock->setWidget(coreSelectionWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock);

   mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
   mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical);
#endif

   /* this should come last */
   mainwindow->resizeThumbnails(true, true, true);

   if (qsettings->contains("geometry"))
      if (qsettings->contains("save_geometry"))
         mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray());

   if (qsettings->contains("save_dock_positions"))
      if (qsettings->contains("dock_positions"))
         mainwindow->restoreState(qsettings->value("dock_positions").toByteArray());

   if (qsettings->contains("save_last_tab"))
   {
      if (qsettings->contains("last_tab"))
      {
         int lastTabIndex = qsettings->value("last_tab", 0).toInt();

         if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex)
            browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex);
      }
   }

   if (qsettings->contains("theme"))
   {
      QString themeStr = qsettings->value("theme").toString();
      MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr);

      if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM)
      {
         QString customThemeFilePath = qsettings->value("custom_theme").toString();

         mainwindow->setCustomThemeFile(customThemeFilePath);
      }

      mainwindow->setTheme(theme);
   }
   else
      mainwindow->setTheme();

   return handle;
}
Пример #17
0
void UpdateClass::moveWindowCenter(){
    // Запустим программу по центру экрана
    QDesktopWidget *desktop = QApplication::desktop();  // Определяем разрешение экрана
    dialogUpdate->move((desktop->width()-dialogUpdate->width())/2,(desktop->height()-dialogUpdate->height())/2);
}
Пример #18
0
void QScreenDistribution::computeSizesAndPositions()
{
    QDesktopWidget *desktop = QApplication::desktop();

    int minimumX = 0;
    int minimumY = 0;
    int maximumX = 0;
    int maximumY = 0;

    // Per cada pantalla
    for (int i = 0; i < desktop->screenCount(); i++)
    {
        // Agafem les seves coordenades
        QPoint topLeft = desktop->screenGeometry(i).topLeft();
        QPoint bottomRight = desktop->screenGeometry(i).bottomRight();

        m_screens.append(QRect(topLeft, bottomRight));

        // I calculem el tamany màxim que ocupa tot el conjunt de pantalles
        if (topLeft.x() < minimumX)
        {
            minimumX = topLeft.x();
        }
        if (bottomRight.x() > maximumX)
        {
            maximumX = bottomRight.x();
        }
        if (topLeft.y() < minimumY)
        {
            minimumY = topLeft.y();
        }
        if (bottomRight.y() > maximumY)
        {
            maximumY = bottomRight.y();
        }
    }

    int totalWidth = maximumX - minimumX;
    int totalHeight = maximumY - minimumY;

    // Calculem la proporció en que s'ha de dividir per que no es deformi el dibuix
    float widthDivisor = (float)totalWidth / ((float)width() - WidgetMargin * 2);
    float heightDivisor = (float)totalHeight / ((float)height() - WidgetMargin * 2);

    float divisor = (widthDivisor < heightDivisor) ? heightDivisor : widthDivisor;
    int offsetX = 0;
    int offsetY = 0;

    if (widthDivisor > heightDivisor)
    {
        float centering = (height() - WidgetMargin * 2 - (totalHeight / divisor)) / 2;
        offsetX = -1 * minimumX / divisor + WidgetMargin;
        offsetY = -1 * minimumY / divisor + WidgetMargin + centering;
    }
    else
    {
        float centering = (width() - WidgetMargin * 2 - (totalWidth / divisor)) / 2;
        offsetX = -1 * minimumX / divisor + WidgetMargin + centering;
        offsetY = -1 * minimumY / divisor + WidgetMargin;
    }

    // Adaptem les posicións a les posicions de dibuix escalades i centrades
    int minimumScreenHeight = 0;
    for (int i = 0; i < m_screens.count(); i++)
    {
        // Requadre
        QRect screen;
        screen.setLeft(m_screens.at(i).left() / divisor + offsetX + 3);
        screen.setTop(m_screens.at(i).top() / divisor + offsetY + 3);
        screen.setRight(m_screens.at(i).right() / divisor + offsetX - 3);
        screen.setBottom(m_screens.at(i).bottom() / divisor + offsetY - 3);
        m_screens.replace(i, screen);

        if (i == 0 || screen.height() < minimumScreenHeight)
        {
           minimumScreenHeight = screen.height();
        }
    }

    m_screenNumberPixelSize = (minimumScreenHeight - 15 < MaximumScreenNumberPixelSize)? minimumScreenHeight - 15: MaximumScreenNumberPixelSize;
}
Пример #19
0
void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
{
   core_info_list_t *cores = NULL;
   QStringList horizontal_header_labels;
   QDesktopWidget *desktop = qApp->desktop();
   QRect desktopRect = desktop->availableGeometry();
   unsigned i = 0;
   int j = 0;

   horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
   horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE_VERSION);

   core_info_get_list(&cores);

   m_table->clear();
   m_table->setColumnCount(0);
   m_table->setRowCount(0);
   m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
   m_table->setSelectionMode(QAbstractItemView::SingleSelection);
   m_table->setSortingEnabled(false);
   m_table->setRowCount(cores->count);
   m_table->setColumnCount(2);
   m_table->setHorizontalHeaderLabels(horizontal_header_labels);

   for (i = 0; i < cores->count; i++)
   {
      core_info_t *core = core_info_get(cores, i);
      QTableWidgetItem *name_item = NULL;
      QTableWidgetItem *version_item = new QTableWidgetItem(core->display_version);
      QVariantHash hash;
      const char *name = core->display_name;

      if (string_is_empty(name))
         name = path_basename(core->path);

      name_item = new QTableWidgetItem(name);

      hash["path"] = core->path;
      hash["extensions"] = QString(core->supported_extensions).split("|");

      name_item->setData(Qt::UserRole, hash);
      name_item->setFlags(name_item->flags() & ~Qt::ItemIsEditable);
      version_item->setFlags(version_item->flags() & ~Qt::ItemIsEditable);

      m_table->setItem(i, CORE_NAME_COLUMN, name_item);
      m_table->setItem(i, CORE_VERSION_COLUMN, version_item);
   }

   if (!extensionFilters.isEmpty())
   {
      QVector<int> rowsToHide;

      for (j = 0; j < m_table->rowCount(); j++)
      {
         bool found = false;
         QTableWidgetItem *item = m_table->item(j, CORE_NAME_COLUMN);
         QVariantHash hash;
         QStringList extensions;
         int k = 0;

         if (!item)
            continue;

         hash = item->data(Qt::UserRole).toHash();
         extensions = hash["extensions"].toStringList();

         if (!extensions.isEmpty())
         {
            for (k = 0; k < extensions.size(); k++)
            {
               QString ext = extensions.at(k).toLower();

               if (extensionFilters.contains(ext, Qt::CaseInsensitive))
               {
                  found = true;
                  break;
               }
            }

            if (!found)
               rowsToHide.append(j);
         }
      }

      if (rowsToHide.size() != m_table->rowCount())
      {
         int i = 0;

         for (i = 0; i < rowsToHide.count() && rowsToHide.count() > 0; i++)
         {
            const int &row = rowsToHide.at(i);
            m_table->setRowHidden(row, true);
         }
      }
   }

   m_table->setSortingEnabled(true);
   m_table->resizeColumnsToContents();
   m_table->sortByColumn(0, Qt::AscendingOrder);
   m_table->selectRow(0);
   m_table->setAlternatingRowColors(true);

   resize(qMin(desktopRect.width(), contentsMargins().left() + m_table->horizontalHeader()->length() + contentsMargins().right()), height());
}
Пример #20
0
void NotifyQt::startWaitingToasters()
{
	{
		//QMutexLocker lock(&waitingToasterMutex);

		if (waitingToasterList.empty()) {
			/* No toasters are waiting */
			return;
		}
	}

	{
		//QMutexLocker lock(&runningToasterMutex);

		if (runningToasterList.size() >= 3) {
			/* Don't show more than 3 toasters at once */
			return;
		}
	}

	ToasterItem *toaster = NULL;

	{
		//QMutexLocker lock(&waitingToasterMutex);

		if (waitingToasterList.size()) {
			/* Take one toaster of the waiting list */
			toaster = waitingToasterList.front();
			waitingToasterList.pop_front();
		}
	}

	if (toaster) {
		//QMutexLocker lock(&runningToasterMutex);

		/* Calculate positions */
		QSize size = toaster->widget->size();

		QDesktopWidget *desktop = QApplication::desktop();
		QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());

		switch (toaster->position) {
		case RshareSettings::TOASTERPOS_TOPLEFT:
			toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.top() - size.height());
			toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y());
			break;
		case RshareSettings::TOASTERPOS_TOPRIGHT:
			toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.top() - size.height());
			toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y());
			break;
		case RshareSettings::TOASTERPOS_BOTTOMLEFT:
			toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.bottom());
			toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y());
			break;
		case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default
		default:
			toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.bottom());
			toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y());
			break;
		}

		/* Initialize widget */
		toaster->widget->move(toaster->startPos);

		/* Initialize toaster */
		toaster->elapsedTimeToShow = 0;
		toaster->elapsedTimeToLive = 0;
		toaster->elapsedTimeToHide = 0;

		/* Add toaster to the running list */
		runningToasterList.push_front(toaster);
		if (runningToasterTimer->isActive() == false) {
			/* Start the toaster timer */
			runningToasterTimer->start();
		}
	}
}
void MediaSourceDesktop::CreateScreenshot()
{
    AVFrame             *tRGBFrame;
    int 				tCaptureResX = mSourceResX;
    int					tCaptureResY = mSourceResY;

    mMutexGrabberActive.lock();

    if (!mMediaSourceOpened)
    {
    	mMutexGrabberActive.unlock();
    	return;
    }

    if (mWidget == NULL)
    {
    	LOG(LOG_ERROR, "Capture widget is invalid");
    	mMutexGrabberActive.unlock();
    	return;
    }

    QTime tCurrentTime = QTime::currentTime();
    int tTimeDiff = mLastTimeGrabbed.msecsTo(tCurrentTime);

    //### skip capturing when we are too slow
    if (tTimeDiff < 1000 / (mFrameRate + 0.5 /* some tolerance! */))
    {
        #ifdef MSD_DEBUG_PACKETS
            LOG(LOG_VERBOSE, "Screen capturing skipped because system is too fast");
        #endif
		mMutexGrabberActive.unlock();
    	return;
    }

    if (mLastTimeGrabbed == QTime(0, 0, 0, 0))
    {
        mLastTimeGrabbed = tCurrentTime;
        mMutexGrabberActive.unlock();
        return;
    }else
        mLastTimeGrabbed = tCurrentTime;

    //### skip capturing when we are too slow
    if (tTimeDiff > 1000 / MIN_GRABBING_FPS)
    {
    	LOG(LOG_WARN, "Screen capturing skipped because system is too busy");
    	mMutexGrabberActive.unlock();
    	return;
    }

    //####################################################################
    //### AUTO DESKTOP
    //####################################################################
    if (mAutoDesktop)
    {
		#ifdef APPLE
    		tCaptureResX = CGDisplayPixelsWide(CGMainDisplayID());
    		tCaptureResY = CGDisplayPixelsHigh(CGMainDisplayID());
        #else
    		QDesktopWidget *tDesktop = QApplication::desktop();
			tCaptureResX = tDesktop->screenGeometry(tDesktop->primaryScreen()).width();
			tCaptureResY = tDesktop->screenGeometry(tDesktop->primaryScreen()).height();
			//LOG(LOG_VERBOSE, "Screen resolution: %d * %d", tCaptureResX, tCaptureResY);
		#endif
    }

    //####################################################################
    //### GRABBING
    //####################################################################
    QPixmap tSourcePixmap;
    // screen capturing
	#ifdef APPLE
		CGImageRef tOSXWindowImage = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionOnScreenOnly, mWidget->winId(), kCGWindowImageDefault);
		tSourcePixmap = QPixmap::fromMacCGImageRef(tOSXWindowImage).copy(mGrabOffsetX, mGrabOffsetY, tCaptureResX, tCaptureResY);
		CGImageRelease(tOSXWindowImage);
	#else
		tSourcePixmap = QPixmap::grabWindow(mWidget->winId(), mGrabOffsetX, mGrabOffsetY, tCaptureResX, tCaptureResY);
	#endif

	//####################################################################
	//### SCALING to source resolution
	//####################################################################
	if ((tSourcePixmap.width() != mSourceResX) || (tSourcePixmap.height() != mSourceResY))
	{// we have to adapt the assumed source resolution
		//LOG(LOG_VERBOSE, "Have to rescale from %d*%d to %d*%d", tSourcePixmap.width(), tSourcePixmap.height(), mSourceResX, mSourceResY);
		tSourcePixmap = tSourcePixmap.scaled(mSourceResX, mSourceResY);
	}

	//####################################################################
	//### MOUSE VISUALIZATION
	//####################################################################
	if (mMouseVisualization)
	{
		QPoint tMousePos = QCursor::pos();
		if ((tMousePos.x() < tSourcePixmap.width()) && (tMousePos.y() < tSourcePixmap.height()))
		{// mouse is in visible area
			int tMousePosInSourcePixmapX = mSourceResX * tMousePos.x() / tCaptureResX;
			int tMousePosInSourcePixmapY = mSourceResY * tMousePos.y() / tCaptureResY;

			//LOG(LOG_VERBOSE, "Mouse position: %d*%d", tMousePosInSourcePixmapX, tMousePosInSourcePixmapY);
			QPainter *tPainter = new QPainter(&tSourcePixmap);
			//TODO: add support for click visualization
			tPainter->drawPixmap(tMousePosInSourcePixmapX, tMousePosInSourcePixmapY, QPixmap(":/images/MouseBlack.png").scaled(16, 32));
			delete tPainter;
		}
	}

	if(!tSourcePixmap.isNull())
    {
		// record screenshot via ffmpeg
		if (mRecording)
		{
			if ((tRGBFrame = AllocFrame()) == NULL)
			{
				LOG(LOG_ERROR, "Unable to allocate memory for RGB frame");
			}else
			{
				QImage tSourceImage = QImage((unsigned char*)mOriginalScreenshot, mSourceResX, mSourceResY, QImage::Format_RGB32);
				QPainter *tSourcePainter = new QPainter(&tSourceImage);
				tSourcePainter->drawPixmap(0, 0, tSourcePixmap);
				delete tSourcePainter;

				// Assign appropriate parts of buffer to image planes in tRGBFrame
				FillFrame(tRGBFrame, mOriginalScreenshot, PIX_FMT_RGB32, mSourceResX, mSourceResY);

				// set frame number in corresponding entries within AVFrame structure
				tRGBFrame->pts = mRecorderChunkNumber;
				tRGBFrame->coded_picture_number = mRecorderChunkNumber;
				tRGBFrame->display_picture_number = mRecorderChunkNumber;
                mRecorderChunkNumber++;

				// emulate set FPS
				tRGBFrame->pts = GetPtsFromFpsEmulator();

				// re-encode the frame and write it to file
				RecordFrame(tRGBFrame);
			}
		}

		// get the scaled version of the capture screen segment
		QPixmap tTargetPixmap = tSourcePixmap.scaled(mTargetResX, mTargetResY);

		// lock screenshot buffer
		mMutexScreenshot.lock();
		QImage tTargetImage = QImage((unsigned char*)mOutputScreenshot, mTargetResX, mTargetResY, QImage::Format_RGB32);
		QPainter *tTargetPainter = new QPainter(&tTargetImage);
		tTargetPainter->drawPixmap(0, 0, tTargetPixmap);
		delete tTargetPainter;
		mScreenshotUpdated = true;
		// notify consumer about new screenshot
		mWaitConditionScreenshotUpdated.wakeAll();
		// unlock screenshot buffer again
		mMutexScreenshot.unlock();
    }else
    	LOG(LOG_ERROR, "Source pixmap is invalid");

    mMutexGrabberActive.unlock();
}
Пример #22
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    GlobalCache *globalCache = new GlobalCache();
    loginStatus = false;

    updateTimer = startTimer(100);

    QTimerEvent *e= new QTimerEvent(updateTimer);

    setWindowTitle("#precIsioN Billing Software 1.2");

    /* Setting height and width properties */
    QDesktopWidget *desktop = QApplication::desktop();
    int width = desktop->width();
    int height = desktop->height();
    GlobalCache::setScreenWidth(width);
    GlobalCache::setScreenHeight(height);
    resize(width/2, height/2);
    int sideWidth = 10; //width/48;
    int sideHeight = (height-50)/14;
    widgetWidth = width - 20; //sideWidth *46;
    widgetHeight = sideHeight * 14;

    /* Creating menu bar and status bar */
    menubar = new QMenuBar(this);
    setMenuBar(menubar);

    menuAdministrator = new QMenu(menubar);
    menuAdministrator->setTitle("Administrator");
    menubar->addMenu(menuAdministrator);

    QAction *homeAct = new QAction(("&Home"), this);
    homeAct->setShortcut(QKeySequence(tr("Ctrl+H")));
    menuAdministrator->addAction(homeAct);
    menuAdministrator->addSeparator();
    QAction *changePasswordAct = new QAction("Change Password", this);
    menuAdministrator->addAction(changePasswordAct);
    QAction *refreshAct = new QAction(("&Refresh"), this);
    refreshAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuAdministrator->addAction(refreshAct);
    QAction *fullScreenAct = new QAction(("&Full Screen"), this);
    fullScreenAct->setShortcut(Qt::Key_F11);
    menuAdministrator->addAction(fullScreenAct);
    QAction *restartAct = new QAction("Restart", this);
    restartAct->setShortcut(QKeySequence((tr("Shift+Ctrl+X"))));
    menuAdministrator->addAction(restartAct);
    QAction *quitAct = new QAction(("Quit Application"), this);
    quitAct->setShortcut(QKeySequence(tr("Ctrl+X")));
    menuAdministrator->addAction(quitAct);

    menuStock = new QMenu(menubar);
    menuStock->setTitle("Stock");
    menubar->addMenu(menuStock);

    QAction *manageStockAct = new QAction(("Manage Stock"), this);
    manageStockAct->setShortcut(QKeySequence(tr("Ctrl+M")));
    menuStock->addAction(manageStockAct);
    QAction *bulkStockUpdationAct = new QAction("Bulk Stock Updation", this);
    bulkStockUpdationAct->setShortcut(QKeySequence(tr("Ctrl+U")));
    menuStock->addAction(bulkStockUpdationAct);
    menuStock->addSeparator();
    QAction *stockPruchaseInvoiceAct = new QAction(("Stock Purchase Invoice"), this);
    menuStock->addAction(stockPruchaseInvoiceAct);
    QAction *oldStockPurchaseInvoiceAct = new QAction(("Old Stock Purchase Invoice"), this);
    menuStock->addAction(oldStockPurchaseInvoiceAct);
    menuStock->addSeparator();
    QAction *stockUpdationAct = new QAction(("Single Stock Updation"), this);
    menuStock->addAction(stockUpdationAct);
    menuStock->addSeparator();
    QAction *addNewStockAct = new QAction(("Add New Stock"), this);
    menuStock->addAction(addNewStockAct);
    QAction *deleteStockact = new QAction(("Remove Stock"), this);
    menuStock->addAction(deleteStockact);
    QAction *updateStockAct = new QAction(("Edit Stock Details"), this);
    menuStock->addAction(updateStockAct);
    menuStock->addSeparator();
    QAction *checkStockAct = new QAction("Check Stock", this);
    checkStockAct->setShortcut(QKeySequence("Ctrl+F"));
    menuStock->addAction(checkStockAct);

    menuInvoice = new QMenu(menubar);
    menuInvoice->setTitle("Invoice");
    menubar->addMenu(menuInvoice);

    QAction *invoiceAct = new QAction(("&New Invoice"), this);
    invoiceAct->setShortcut(QKeySequence(tr("Ctrl+N")));
    menuInvoice->addAction(invoiceAct);
    QAction *setInvoiceAct = new QAction(("Set Invoice No"), this);
    menuInvoice->addAction(setInvoiceAct);
    QAction *cancelInvoiceAct = new QAction(("Cancel Invoice"), this);
    menuInvoice->addAction(cancelInvoiceAct);
    QAction *oldInvoiceAct = new QAction(("Old Invoices"), this);
    menuInvoice->addAction(oldInvoiceAct);

    menuEstimate = new QMenu(menubar);
    menuEstimate->setTitle("Estimate");
    menubar->addMenu(menuEstimate);

    QAction *estimateAct = new QAction(("&New Estimate"), this);
    estimateAct->setShortcut(QKeySequence(tr("Ctrl+E")));
    menuEstimate->addAction(estimateAct);
    QAction *setEstimateAct = new QAction(("Set Estimate No"), this);
    menuEstimate->addAction(setEstimateAct);
    QAction *cancelEstimateAct = new QAction(("Cancel Estimate"), this);
    menuEstimate->addAction(cancelEstimateAct);
    QAction *oldEstimateAct = new QAction(("Old Estimates"), this);
    menuEstimate->addAction(oldEstimateAct);
    menuEstimate->addSeparator();
    QAction *itemEstimateAct = new QAction("Item Estimates", this);
    menuEstimate->addAction(itemEstimateAct);


    menuDealer = new QMenu(menubar);
    menuDealer->setTitle("Dealer");
//    menubar->addMenu(menuDealer);

    QAction *dealerHomeAct = new QAction(("&Dealer Home"), this);
    dealerHomeAct->setShortcut(QKeySequence(tr("Ctrl+D")));
    menuDealer->addAction(dealerHomeAct);
    QAction *salesDetailsAct = new QAction(("Sales De&tais"), this);
    salesDetailsAct->setShortcut(QKeySequence(tr("Ctrl+T")));
    menuDealer->addAction(salesDetailsAct);
    QAction *addNewDealerAct = new QAction(("Add New Dealer"), this);
    menuDealer->addAction(addNewDealerAct);
    QAction *deleteDealerAct = new QAction(("Delete Dealer"), this);
    menuDealer->addAction(deleteDealerAct);
    QAction *updateDealerAct = new QAction(("Edit Dealer Details"), this);
    menuDealer->addAction(updateDealerAct);

    menuAccounts = new QMenu(menubar);
    menuAccounts->setTitle("Accounts");
    menubar->addMenu(menuAccounts);

    QAction *accountsAct = new QAction(("Accounts"), this);
    accountsAct->setShortcut(QKeySequence(tr("Ctrl+A")));
    menuAccounts->addAction(accountsAct);

    menuReports = new QMenu(menubar);
    menuReports->setTitle("Reports");
    menubar->addMenu(menuReports);

    QAction *todaysItemSalesAct = new QAction(("Today's &Item Sales"), this);
    todaysItemSalesAct->setShortcut(QKeySequence(tr("Ctrl+I")));
    menuReports->addAction(todaysItemSalesAct);
    QAction *dailyReportAct = new QAction(("Daily Sales &Report"), this);
    dailyReportAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuReports->addAction(dailyReportAct);
    QAction *itemSalesReportAct = new QAction("Selected Item Sales Report", this);
    menuReports->addAction(itemSalesReportAct);
    QAction *historyItemSalesAct = new QAction(("History Item Sales"), this);
    menuReports->addAction(historyItemSalesAct);
    menuReports->addSeparator();
    QAction *purchaseReportAct = new QAction("Purchase Report", this);
    menuReports->addAction(purchaseReportAct);
    QAction *purchaseItemsAct = new QAction("Purchased Item Report", this);
    menuReports->addAction(purchaseItemsAct);

    menuSettings = new QMenu(menubar);
    menuSettings->setTitle("Settings");
    menubar->addMenu(menuSettings);

    QAction *configurationAct = new QAction(("Configure Product"), this);
    menuSettings->addAction(configurationAct);
    QAction *deleteDataAct = new QAction("Clear Data", this);
    menuSettings->addAction(deleteDataAct);
    QAction *backupAct = new QAction(("Backup"), this);
    menuSettings->addAction(backupAct);

    menuHelp = new QMenu(menubar);
    menuHelp->setTitle("Help");
    menubar->addMenu(menuHelp);

    QAction *shortcutAct = new QAction(("Shorcuts Used"), this);
    menuHelp->addAction(shortcutAct);
    QAction *aboutAct = new QAction(("About"), this);
    menuHelp->addAction(aboutAct);

    adminHome = new AdminHomeWidget(widgetWidth, this);
    adminHome->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    manageStock = new ManageStockWidget(widgetWidth, this);
    manageStock->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseInvoice = new StockPurchaseInvoiceWidget(widgetWidth, this);
    purchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldPurchaseInvoice = new OldPurchaseInvoiceWidget(widgetWidth, this);
    oldPurchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    invoice = new InvoiceWidget(widgetWidth, this);
    invoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    dailyReport = new DailySalesReportWidget(widgetWidth, this);
    dailyReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemSales = new TodaysItemSalesWidget(widgetWidth, this);
    itemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldInvoice = new OldInvoicesWidget(widgetWidth, this);
    oldInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    allInvoices = new AllInvoices(widgetWidth, this);
    allInvoices->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldEstimate = new OldEstimates(widgetWidth, this);
    oldEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemEstimate = new ItemEstimateWidget(widgetWidth, this);
    itemEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    estimate = new EstimateWidget(widgetWidth, this);
    estimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    salesDetails = new SalesDetailsWidget(widgetWidth, this);
    salesDetails->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    accounts = new AccountsWidget(widgetWidth, this);
    accounts->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseReport = new PurchaseReportWidget(widgetWidth, this);
    purchaseReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchasedItems = new PurchasedItemWidget(widgetWidth, this);
    purchasedItems->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyDsr = new HistoryDSRWidget(widgetWidth, this);
    historyDsr->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyItemSales = new HistoryItemSalesWidget(widgetWidth, this);
    historyItemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyinvoice = new HistoryInvoiceWidget(widgetWidth, this);
    historyinvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);

    /* Main Window setup */

    connect( homeAct, SIGNAL(triggered()), this, SLOT(getAdminHome()));
    connect( todaysItemSalesAct, SIGNAL(triggered()), this, SLOT(getItemSales()));
    connect( dailyReportAct, SIGNAL(triggered()), this, SLOT(getDailySalesReport()));
    connect( itemSalesReportAct, SIGNAL(triggered()), this, SLOT(getItemSalesReport()));
    connect( bulkStockUpdationAct, SIGNAL(triggered()), this, SLOT(getBulkStockUpdationDialog()));
    connect( stockUpdationAct, SIGNAL(triggered()), this, SLOT(getStockUpdationDialog()));
    connect( addNewStockAct, SIGNAL(triggered()), this, SLOT(getAddNewStockDialog()));
    connect( deleteStockact, SIGNAL(triggered()), this, SLOT(getDeleteStockDialog()));
    connect( updateStockAct, SIGNAL(triggered()), this, SLOT(getUpdateStockDialog()));
    connect( checkStockAct, SIGNAL(triggered()), this, SLOT(getCheckStockDialog()));
    connect( changePasswordAct, SIGNAL(triggered()), this, SLOT(getChangePasswordDialog()));
    connect( refreshAct, SIGNAL(triggered()), this, SLOT(refresh()));
    connect( fullScreenAct, SIGNAL(triggered()), this, SLOT(getFullScreen()));
    connect( restartAct, SIGNAL(triggered()), this, SLOT(restart()));
    connect( quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect( manageStockAct, SIGNAL(triggered()), this, SLOT(getManageStockWidget()));
    connect( stockPruchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getStockPurchaseInvoice()));
    connect( oldStockPurchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldStockPurchaseInvoice()));
    connect( invoiceAct, SIGNAL(triggered()), this, SLOT(getInvoice()));
    connect( setInvoiceAct, SIGNAL(triggered()), this, SLOT(getSetInvoiceDialog()));
    connect( cancelInvoiceAct, SIGNAL(triggered()), this, SLOT(cancelInvoice()));
    connect( oldInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldInvoice()));
    connect( estimateAct, SIGNAL(triggered()), this, SLOT(getEstimate()));
    connect( setEstimateAct, SIGNAL(triggered()), this, SLOT(getSetEstimateDialog()));
    connect( cancelEstimateAct, SIGNAL(triggered()), this, SLOT(cancelEstimate()));
    connect( oldEstimateAct, SIGNAL(triggered()), this, SLOT(getOldEstimates()));
    connect( itemEstimateAct, SIGNAL(triggered()), this, SLOT(getItemEstimate()));
    connect( salesDetailsAct, SIGNAL(triggered()), this, SLOT(getSalesDetails()));
    connect( accountsAct, SIGNAL(triggered()), this, SLOT(getAccountsWidget()));
    connect( purchaseReportAct, SIGNAL(triggered()), this, SLOT(getPurchaseReport()));
    connect( purchaseItemsAct, SIGNAL(triggered()), this, SLOT(getPurchasedItems()));
    connect( historyItemSalesAct, SIGNAL(triggered()), this, SLOT(getHistoryItemSales()));
    connect( configurationAct, SIGNAL(triggered()), this, SLOT(getConfiguration()));
    connect( deleteDataAct, SIGNAL(triggered()), this, SLOT(getDeleteDataAct()));
    connect( backupAct, SIGNAL(triggered()), this, SLOT(getBackup()));
    connect( shortcutAct, SIGNAL(triggered()), this, SLOT(shortcuts()));
    connect( aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));

    hideAllWidgets();
    showMinimized();
}
Пример #23
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

	// Setup the User Interface of the application.
    ui->setupUi(this);
    
    // Retrieve intel about the computer.
    QDesktopWidget dw;

    //this->setWindowTitle("DesignerEditor");
    // Set application window's size fixed and width button not pressed.  
    this->setFixedSize(dw.width() * 0.8, dw.height() * 0.8);
    this->widthButtonPressed = false;
    //this->move(dw.width() / 7, dw.height() / 8);

    //statusBar();
    QMenuBar * menuB = this->menuBar();
    QMenu * menuFichier = menuB->addMenu(tr("File"));

    QAction * open = new QAction(QIcon(":icons/images/open.png"), tr("&Open"), this);
    open->setToolTip(tr("Open existing file"));
    open->setStatusTip(tr("Open existing file"));
    open->setShortcut(tr("CTRL+O"));

    QAction * save = new QAction(QIcon(":icons/images/save.png"), tr("&Save"), this);
    save->setToolTip(tr("Save file"));
    save->setStatusTip(tr("Save file"));
    save->setShortcut(tr("CTRL+S"));

    QAction * exit = new QAction(QIcon(":icons/images/quit.png"), tr("&Exit"), this);
    exit->setToolTip(tr("Exit"));
    exit->setStatusTip(tr("Exit"));
    exit->setShortcut(tr("CTRL+E"));

    menuFichier->addAction(open);
    menuFichier->addAction(save);
    menuFichier->addAction(exit);

    QMenu * Tools = menuB->addMenu(tr("Tools"));

    //TODO The Polygon
    this->selectShape = new QActionGroup(this);
    selectShape->addAction(tr(CIRCLE_TEXT));
    selectShape->actions().back()->setToolTip(tr("Draw a Circle"));
    selectShape->actions().back()->setStatusTip(tr("Draw a Circle"));
    selectShape->actions().back()->setShortcut(tr("ALT+W"));
    //Circle reserved for the next release. There are still bugs to be fixed.
    selectShape->actions().back()->setEnabled(false);

    selectShape->addAction(tr(RECTANGLE_TEXT));
    selectShape->actions().back()->setToolTip(tr("Draw a Rectangle"));
    selectShape->actions().back()->setStatusTip(tr("Draw a Rectangle"));
    selectShape->actions().back()->setShortcut(tr("ALT+Z"));
    selectShape->addAction(tr(LINE_TEXT));
    selectShape->actions().back()->setToolTip(tr("Draw a Line"));
    selectShape->actions().back()->setStatusTip(tr("Draw a Line"));
    selectShape->actions().back()->setShortcut(tr("ALT+A"));
    selectShape->addAction(tr(ELLIPSE_TEXT));
    selectShape->actions().back()->setToolTip(tr("Draw an Ellipse"));
    selectShape->actions().back()->setStatusTip(tr("Draw an Ellipse"));
    selectShape->actions().back()->setShortcut(tr("ALT+Q"));
    selectShape->addAction(tr(POLYLINE_TEXT));
    selectShape->actions().back()->setToolTip(tr("Draw a Polyline"));
    selectShape->actions().back()->setStatusTip(tr("Draw a Polyline"));
    selectShape->actions().back()->setShortcut(tr("ALT+D"));

    selectShape->addAction(tr(SQUARE_TEXT));
    selectShape->actions().back()->setToolTip(tr("Draw a Square"));
    selectShape->actions().back()->setStatusTip(tr("Draw a Square"));
    selectShape->actions().back()->setShortcut(tr("ALT+X"));
    //Square reserved for the next release. There are still bugs to be fixed.
    selectShape->actions().back()->setEnabled(false);


    QMenu * Shapes = Tools->addMenu(tr("Shape"));
    Shapes->addActions(selectShape->actions());

    this->selectColor = new QActionGroup(this);
    selectColor->addAction(tr(RED_TEXT));
    selectColor->actions().back()->setToolTip(tr("Black ink"));
    selectColor->actions().back()->setStatusTip(tr("Red ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+R"));
    selectColor->addAction(tr(BLACK_TEXT));
    selectColor->actions().back()->setToolTip(tr("Red ink"));
    selectColor->actions().back()->setStatusTip(tr("Black ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+Z"));
    selectColor->addAction(tr(BLUE_TEXT));
    selectColor->actions().back()->setToolTip(tr("Blue ink"));
    selectColor->actions().back()->setStatusTip(tr("Blue ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+E"));
    selectColor->addAction(tr(YELLOW_TEXT));
    selectColor->actions().back()->setToolTip(tr("Yellow ink"));
    selectColor->actions().back()->setStatusTip(tr("Yellow ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+Q"));
    selectColor->addAction(tr(CYAN_TEXT));
    selectColor->actions().back()->setToolTip(tr("Cyan ink"));
    selectColor->actions().back()->setStatusTip(tr("Cyan ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+S"));
    selectColor->addAction(tr(MAGENTA_TEXT));
    selectColor->actions().back()->setToolTip(tr("Magenta ink"));
    selectColor->actions().back()->setStatusTip(tr("Magenta ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+D"));
    selectColor->addAction(tr(DARK_BLUE_TEXT));
    selectColor->actions().back()->setToolTip(tr("Dark Blue ink"));
    selectColor->actions().back()->setStatusTip(tr("Dark Blue ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+W"));
    selectColor->addAction(tr(DARK_RED_TEXT));
    selectColor->actions().back()->setToolTip(tr("Dark Red ink"));
    selectColor->actions().back()->setStatusTip(tr("Dark Red ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+X"));
    selectColor->addAction(tr(GREEN_TEXT));
    selectColor->actions().back()->setToolTip(tr("Green ink"));
    selectColor->actions().back()->setStatusTip(tr("Green ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+C"));
    selectColor->addAction(tr(DARK_GREEN_TEXT));
    selectColor->actions().back()->setToolTip(tr("Dark Green ink"));
    selectColor->actions().back()->setStatusTip(tr("Dark Green ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+F"));
    selectColor->addAction(tr(DARK_GREY_TEXT));
    selectColor->actions().back()->setToolTip(tr("Dark Gray ink"));
    selectColor->actions().back()->setStatusTip(tr("Dark Gray ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+A"));
    selectColor->addAction(tr(GRAY_TEXT));
    selectColor->actions().back()->setToolTip(tr("Gray ink"));
    selectColor->actions().back()->setStatusTip(tr("Gray ink"));
    selectColor->actions().back()->setShortcut(tr("SHIFT+V"));

    const QStringList colorIdentifiers = (QStringList()<<"Black"<<"Red"<<"Blue"
                                                  <<"Yellow"<<"Cyan"<<"Magenta"
                                                  <<"Dark Blue"<<"Dark Red"<<"Green"
                                                  <<"Dark Green"<<"Dark Gray"<<"Gray");

    this->ui->colorBox->addItems(colorIdentifiers);

    QObject::connect(this->ui->colorBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorBox_currentIndexChanged(int)));

    QMenu * Colors = Tools->addMenu(tr("Ink Color"));
    Colors->addActions(selectColor->actions());

    this->selectWidthPen = new QActionGroup(this);
    selectWidthPen->addAction(tr("Increase Width"));
    selectWidthPen->actions().back()->setToolTip(tr("Increase the width of the outline"));
    selectWidthPen->actions().back()->setStatusTip(tr("Increase the width of the outline"));
    selectWidthPen->actions().back()->setShortcut(Qt::Key_Up);
    selectWidthPen->addAction(tr("Decrease Width"));
    selectWidthPen->actions().back()->setToolTip(tr("Decrease the width of the outline"));
    selectWidthPen->actions().back()->setStatusTip(tr("Decrease the width of the outline"));
    selectWidthPen->actions().back()->setShortcut(Qt::Key_Down);
    selectWidthPen->addAction(tr("Increase Width Quickly"));
    selectWidthPen->actions().back()->setToolTip(tr("Increase the width of the outline quickly"));
    selectWidthPen->actions().back()->setStatusTip(tr("Increase the width of the outline quickly"));
    selectWidthPen->actions().back()->setShortcut(tr("Q"));
    selectWidthPen->addAction(tr("Decrease Width Quickly"));
    selectWidthPen->actions().back()->setToolTip(tr("Increase the width of the outline quickly"));
    selectWidthPen->actions().back()->setStatusTip(tr("Increase the width of the outline quickly"));
    selectWidthPen->actions().back()->setShortcut(tr("S"));

    QObject::connect(this->ui->WidthSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSlider_valueChanged(int)));

    QMenu * widthControl = Tools->addMenu(tr("Outline Width Editor"));
    widthControl->addActions(selectWidthPen->actions());

    this->widthActions = selectWidthPen->actions();

    for(int i = 0; i < widthActions.count(); i++ )
        QObject::connect(widthActions.at(i), SIGNAL(triggered()), this, SLOT(updateWidth()));

    this->selectBrushStyle = new QActionGroup(this);
    selectBrushStyle->addAction(tr("No Brush"));
    selectBrushStyle->actions().back()->setToolTip(tr("No Brush"));
    selectBrushStyle->actions().back()->setStatusTip(tr("No Brush"));
    selectBrushStyle->actions().back()->setShortcut(tr("A"));
    selectBrushStyle->addAction(tr("Solid Pattern"));
    selectBrushStyle->actions().back()->setToolTip(tr("Uniform color"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Uniform color"));
    selectBrushStyle->actions().back()->setShortcut(tr("Z"));
    selectBrushStyle->addAction(tr("Extremely Dense"));
    selectBrushStyle->actions().back()->setToolTip(tr("Extremely dense brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Extremely dense brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("E"));
    selectBrushStyle->addAction(tr("Very Dense"));
    selectBrushStyle->actions().back()->setToolTip(tr("Very dense brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Very dense brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("R"));
    selectBrushStyle->addAction(tr("Somewhat Dense"));
    selectBrushStyle->actions().back()->setToolTip(tr("Somewhat dense brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Somewhat dense brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("T"));
    selectBrushStyle->addAction(tr("Half Dense"));
    selectBrushStyle->actions().back()->setToolTip(tr("Half dense brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Half dense brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("Y"));
    selectBrushStyle->addAction(tr("Somewhat Sparse"));
    selectBrushStyle->actions().back()->setToolTip(tr("Somewhat sparse brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Somewhat sparse brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("U"));
    selectBrushStyle->addAction(tr("Very Sparse"));
    selectBrushStyle->actions().back()->setToolTip(tr("Very sparse brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Very sparse brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("I"));
    selectBrushStyle->addAction(tr("Extremely Sparse"));
    selectBrushStyle->actions().back()->setToolTip(tr("Extremely sparse brush pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Extremely sparse brush pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("O"));
    selectBrushStyle->addAction(tr("Horizontal lines"));
    selectBrushStyle->actions().back()->setToolTip(tr("Horizontal lines pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Horizontal lines pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("P"));
    selectBrushStyle->addAction(tr("Vertical lines"));
    selectBrushStyle->actions().back()->setToolTip(tr("Vertical lines pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Vertical lines pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("D"));
    selectBrushStyle->addAction(tr("Crossing horizontal and vertical lines"));
    selectBrushStyle->actions().back()->setToolTip(tr("Crossing horizontal and vertical lines pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Crossing horizontal and vertical lines pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("F"));
    selectBrushStyle->addAction(tr("Backward diagonal lines"));
    selectBrushStyle->actions().back()->setToolTip(tr("Backward diagonal lines pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Backward diagonal lines pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("G"));
    selectBrushStyle->addAction(tr("Forward diagonal lines"));
    selectBrushStyle->actions().back()->setToolTip(tr("Forward diagonal lines pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Forward diagonal lines pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("H"));
    selectBrushStyle->addAction(tr("Crossing diagonal lines"));
    selectBrushStyle->actions().back()->setToolTip(tr("Crossing diagonal lines pattern"));
    selectBrushStyle->actions().back()->setStatusTip(tr("Crossing diagonal lines pattern"));
    selectBrushStyle->actions().back()->setShortcut(tr("J"));

    const QStringList brushStylesIdentifiers = (QStringList()<<"No Brush"<<"Solid"<<"+++Dense"
                                                  <<"++Dense"<<"+Dense"<<"Dense"
                                                  <<"Sparse"<<"+Sparse"<<"++Sparse"
                                                  <<"- Lines"<<"| Lines"<<"X Lines"
                                                  <<"/ Backward"<<"/ Forward"<<"X / Lines");

    this->ui->brushBox->addItems(brushStylesIdentifiers);

    QObject::connect(this->ui->brushBox, SIGNAL(currentIndexChanged(int)), this, SLOT(brushBox_currentIndexChanged(int)));

    QMenu * brushStyles = Tools->addMenu(tr("Brush Pattern"));
    brushStyles->addActions(selectBrushStyle->actions());

    this->brushActions = selectBrushStyle->actions();

    for(int i = 0; i < brushActions.count(); i++ )
        QObject::connect(brushActions.at(i), SIGNAL(triggered()), this, SLOT(updateBrushPattern()));

    this->selectCapStyle = new QActionGroup(this);
    selectCapStyle->addAction(tr("Square"));
    selectCapStyle->actions().back()->setToolTip(tr("Square border curves"));
    selectCapStyle->actions().back()->setStatusTip(tr("Square border curves"));
    selectCapStyle->actions().back()->setShortcut(tr("K"));
    selectCapStyle->addAction(tr("Round"));
    selectCapStyle->actions().back()->setToolTip(tr("Round border curves"));
    selectCapStyle->actions().back()->setStatusTip(tr("Round border curves"));
    selectCapStyle->actions().back()->setShortcut(tr("L"));
    selectCapStyle->addAction(tr("Flat"));
    selectCapStyle->actions().back()->setToolTip(tr("Flat border curves"));
    selectCapStyle->actions().back()->setStatusTip(tr("Flat border curves"));
    selectCapStyle->actions().back()->setShortcut(tr("M"));

    this->selectMode = new QActionGroup(this);
    selectMode->addAction(QIcon("://icons/images/cut.png"), tr("Edit"));
    selectMode->actions().back()->setToolTip(tr("Select and Edit"));
    selectMode->actions().back()->setStatusTip(tr("Select and Edit"));
    selectMode->actions().back()->setShortcut(tr("W"));
    selectMode->addAction(QIcon("://icons/images/paintbrush-symbol_318-9145.jpg"), tr("Draw"));
    selectMode->actions().back()->setToolTip(tr("Draw"));
    selectMode->actions().back()->setStatusTip(tr("Draw"));
    selectMode->actions().back()->setShortcut(tr("X"));

    QMenu * Mode = menuB->addMenu(tr("Mode"));
    Mode->addActions(selectMode->actions());

    for(int i = 0; i < selectMode->actions().count(); i++ )
        QObject::connect(selectMode->actions().at(i), SIGNAL(triggered()), this, SLOT(updateMode()));


    QAction * translate = new QAction(QIcon("://icons/images/move_arrow_cursor_direction_shift_pan_arrows-512.png"), tr("&Translate"), this);
    translate->setToolTip(tr("Translate figure"));
    translate->setStatusTip(tr("Translate figure"));
    translate->setShortcut(tr("."));

    Mode->addAction(translate);
    QObject::connect(translate, SIGNAL(triggered()), this, SLOT(updateMode()));

    QMenu * capStyle = Tools->addMenu(tr("Cap Style"));
    capStyle->addActions(selectCapStyle->actions());

    this->capActions = selectCapStyle->actions();

    for(int i = 0; i < capActions.count(); i++ )
        QObject::connect(capActions.at(i), SIGNAL(triggered()), this, SLOT(updateCapStyle()));

    this->selectJoinStyle = new QActionGroup(this);
    selectJoinStyle->addAction(tr("BevelJoin"));
    selectJoinStyle->actions().back()->setToolTip(tr(""));
    selectJoinStyle->actions().back()->setStatusTip(tr(""));
    selectJoinStyle->actions().back()->setShortcut(tr("V"));
    selectJoinStyle->addAction(tr("MiterJoin"));
    selectJoinStyle->actions().back()->setToolTip(tr(""));
    selectJoinStyle->actions().back()->setStatusTip(tr(""));
    selectJoinStyle->actions().back()->setShortcut(tr("B"));
    selectJoinStyle->addAction(tr("RoundJoin"));
    selectJoinStyle->actions().back()->setToolTip(tr(""));
    selectJoinStyle->actions().back()->setStatusTip(tr(""));
    selectJoinStyle->actions().back()->setShortcut(tr("N"));

    QMenu * joinStyle = Tools->addMenu(tr("Join Style"));
    joinStyle->addActions(selectJoinStyle->actions());


    this->joinActions = selectJoinStyle->actions();

    for(int i = 0; i < joinActions.count(); i++ )
        QObject::connect(joinActions.at(i), SIGNAL(triggered()), this, SLOT(updateJoinStyle()));


    //this->mainTextView = new QTextEdit(this);
    this->mainDrawView = this->ui->mainDraw;//new ZoneDeDessin(this);
    this->mainDrawView->setSlider(this->ui->WidthSlider);
    //setCentralWidget(this->mainDrawView);


    //setCentralWidget(mainTextView);

    this->shapeActions = selectShape->actions();

    this->colorActions = selectColor->actions();

    for(int i = 0; i < this->shapeActions.count(); i++ )
        QObject::connect(this->shapeActions.at(i), SIGNAL(triggered()), this, SLOT(updateShape()));

    for(int i = 0; i < this->colorActions.count(); i++ )
        QObject::connect(this->colorActions.at(i), SIGNAL(triggered()), this, SLOT(updateColor()));

    this->eraseAll = new QAction(tr("&Erase All"), this);
    this->eraseAll->setToolTip(tr("Reset canvas"));
    this->eraseAll->setStatusTip(tr("Reset Canvas"));
    this->eraseAll->setShortcut(tr("DEL"));

    Tools->addAction(eraseAll);
    QObject::connect(eraseAll, SIGNAL(triggered()), this, SLOT(eraseAllCallback()));

    QToolBar * toolBar = this->ui->mainToolBar;//addToolBar(tr("File"));
    toolBar->addAction(open);
    toolBar->addAction(save);
    toolBar->addAction(this->selectMode->actions().back());
    toolBar->addAction(this->selectMode->actions().front());
    toolBar->addAction(translate);
    toolBar->addAction(exit);

    QObject::connect(open, SIGNAL(triggered()), this, SLOT(openFile()));
    QObject::connect(save, SIGNAL(triggered()), this, SLOT(saveFile()));
    QObject::connect(exit, SIGNAL(triggered()), this, SLOT(quitApp()));

}
Пример #24
0
void TupMainWindow::createGUI()
{
    // Adding the color palette to the left side of the interface 

    m_colorPalette = new TupColorPalette;
    colorView = addToolView(m_colorPalette, Qt::LeftDockWidgetArea, Animation, "Color Palette", QKeySequence(tr("Shift+P")));
    //colorView->setShortcut(QKeySequence(tr("Shift+P")));

    m_actionManager->insert(colorView->toggleViewAction(), "show palette");
    addToPerspective(colorView->toggleViewAction(), Animation);

    connectToDisplays(m_colorPalette);
    connectWidgetToPaintArea(m_colorPalette);

    // Adding the pen parameters widget to the left side of the interface 

    m_penWidget = new TupPenWidget;
    penView = addToolView(m_penWidget, Qt::LeftDockWidgetArea, Animation, "Pen", QKeySequence(tr("Shift+B")));
    m_actionManager->insert(penView->toggleViewAction(), "show pen");
    addToPerspective(penView->toggleViewAction(), Animation);

    connectToDisplays(m_penWidget);
    connectWidgetToPaintArea(m_penWidget);

    // Adding the objects library widget to the left side of the interface

    m_libraryWidget = new TupLibraryWidget(this);
    m_libraryWidget->setLibrary(m_projectManager->project()->library());

    libraryView = addToolView(m_libraryWidget, Qt::LeftDockWidgetArea, Animation, "Library", QKeySequence(tr("Shift+L")));
    m_actionManager->insert(libraryView->toggleViewAction(), "show library");
    addToPerspective(libraryView->toggleViewAction(), Animation);
    connectToDisplays(m_libraryWidget);

    new TAction(QPixmap(THEME_DIR + "icons/bitmap.png"), tr("Bitmap"), QKeySequence(tr("Alt+B")), m_libraryWidget, SLOT(importBitmap()),
                m_actionManager, "importbitmap");

    new TAction(QPixmap(THEME_DIR + "icons/bitmap_array.png"), tr("Bitmap Array"), QKeySequence(tr("Alt+Shift+B")), 
                m_libraryWidget, SLOT(importBitmapArray()), m_actionManager, "importbitmaparray");

    new TAction(QPixmap(THEME_DIR + "icons/svg.png"), tr("SVG File"), QKeySequence(tr("Alt+S")), m_libraryWidget, SLOT(importSvg()),
                m_actionManager, "importsvg");

    new TAction(QPixmap(THEME_DIR + "icons/svg_array.png"), tr("SVG Array"), QKeySequence(tr("Alt+Shift+S")), m_libraryWidget, 
                SLOT(importSvgArray()), m_actionManager, "importsvgarray");

    //new TAction(QPixmap(), tr("Audio File..."), QKeySequence(), m_libraryWidget, SLOT(importSound()),
    //            m_actionManager, "importaudiofile");

    // SQA: Temporary code
    //m_actionManager->enable("importsvg", false);
    //m_actionManager->enable("importsvgarray", false);

    connectWidgetToManager(m_libraryWidget);
    connectWidgetToLocalManager(m_libraryWidget);

    // Adding the scenes widget to the right side of the interface

    m_scenes = new TupScenesWidget;
    scenesView = addToolView(m_scenes, Qt::RightDockWidgetArea, Animation, "Scenes Manager", QKeySequence(tr("Shift+C")));
    m_actionManager->insert(scenesView->toggleViewAction(), "show scenes");
    addToPerspective(scenesView->toggleViewAction(), Animation);

    connectWidgetToManager(m_scenes);
    connectWidgetToLocalManager(m_scenes);
    connectToDisplays(m_scenes);

    // Adding the exposure sheet to the right side of the interface
    m_exposureSheet = new TupExposureSheet;
    exposureView = addToolView(m_exposureSheet, Qt::RightDockWidgetArea, Animation, "Exposure Sheet", QKeySequence(tr("Shift+E")));
    m_actionManager->insert(exposureView->toggleViewAction(), "show exposure");
    addToPerspective(exposureView->toggleViewAction(), Animation);

    connectWidgetToManager(m_exposureSheet);
    connectWidgetToLocalManager(m_exposureSheet);
    connectToDisplays(m_exposureSheet);

    // Adding the help widget to the right side of the interface

    m_helper = new TupHelpWidget(SHARE_DIR + "data/help/");
    helpView = addToolView(m_helper, Qt::RightDockWidgetArea, All, "Help", QKeySequence(tr("Shift+H")));
    m_actionManager->insert(helpView->toggleViewAction(), "show help");
    addToPerspective(helpView->toggleViewAction(), All);

    TViewButton *helpButton = helpView->button();

    connect(helpButton, SIGNAL(helpIsOpen()), this,
            SLOT(setHelpPerspective()));

    connect(m_helper, SIGNAL(pageLoaded(const QString &)), this, 
            SLOT(showHelpPage(const QString &)));
    connectToDisplays(m_helper);

    // Adding the time line widget to the bottom side of the interface
    m_timeLine = new TupTimeLine;
    m_timeLine->setLibrary(m_projectManager->project()->library());
    timeView = addToolView(m_timeLine, Qt::BottomDockWidgetArea, Animation, "Time Line", QKeySequence(tr("Shift+T")));
    m_actionManager->insert(timeView->toggleViewAction(), "show timeline");
    addToPerspective(timeView->toggleViewAction(), Animation);

    connectWidgetToManager(m_timeLine);
    connectWidgetToLocalManager(m_timeLine);
    connectToDisplays(m_timeLine);

#if defined(QT_GUI_LIB) && defined(K_DEBUG)
    QDesktopWidget desktop;
    m_debug = new TupDebugWidget(this, desktop.screenGeometry().width());
    debugView = addToolView(m_debug, Qt::BottomDockWidgetArea, Animation, "Debug Term", QKeySequence(tr("Shift+D")));
    m_actionManager->insert(debugView->toggleViewAction(), "show debug");
    addToPerspective(debugView->toggleViewAction(), Animation);
#endif

    // Adding the script editor to the bottom side, if kinas was enabled
    /*
#ifdef ENABLE_KINAS
    KinasWidget *m_scriptEditor = new KinasWidget;
    addToolView(m_scriptEditor, Qt::BottomDockWidgetArea, Animation, "Tupi Script", QKeySequence(tr("Shift+K"));
#endif
    */

    enableToolViews(false);
}
Пример #25
0
void View::mouseMoveEvent(QMouseEvent* pe)
{
    if (QApplication::mouseButtons() == Qt::LeftButton && DragEnabled)
    {
        //-----------Snaping----------------------------
        QDesktopWidget desktop;
        int scrHeight = desktop.availableGeometry(desktop.primaryScreen()).height();
        int scrWidth = desktop.availableGeometry(desktop.primaryScreen()).width();
        int top = this->frameGeometry().top();
        int bottom = this->frameGeometry().bottom();
        int left = this->frameGeometry().left();
        int right = this->frameGeometry().right();
        int height = this->frameGeometry().height();
        int width = this->frameGeometry().width();

        if (isSnaped[0] && top >= snapFactor)
            isSnaped[0] = false;
        if (isSnaped[1] && (scrHeight - bottom) >= snapFactor)
            isSnaped[1] = false;
        if (isSnaped[2] && left >= snapFactor)
            isSnaped[2] = false;
        if (isSnaped[3] && (scrWidth - right) >= snapFactor)
            isSnaped[3] = false;

        //--DeSnap----------

        //---Top
        if (isSnaped[0])
        {
            if (pe->pos().y() - m_ptPosition.y() >= snapFactor)
            {
                move(left, snapFactor + 1);
                return;
            }
            else
                if (pe->globalPos().x() - m_ptPosition.x() >= 0 &&
                    pe->globalPos().x() - m_ptPosition.x() <= scrWidth - width)
                    move(pe->globalPos().x() - m_ptPosition.x(), 0);
        }
        //---Bottom
        else if (isSnaped[1])
        {
            if (m_ptPosition.y() - pe->pos().y() >= snapFactor)
            {
                move(left, scrHeight - snapFactor - height - 1);
                return;
            }
            else
                if (pe->globalPos().x() - m_ptPosition.x() >= 0 &&
                    pe->globalPos().x() - m_ptPosition.x() <= scrWidth - width)
                    move(pe->globalPos().x() - m_ptPosition.x(), scrHeight - height);
        }
        //---Left
        else if (isSnaped[2])
        {
            if (pe->pos().x() - m_ptPosition.x() >= snapFactor)
            {
                move(snapFactor + 1, top);
                return;
            }
            else
                if (pe->globalPos().y() - m_ptPosition.y() >= 0 &&
                    pe->globalPos().y() - m_ptPosition.y() <= scrHeight - height)
                    move(0, pe->globalPos().y() - m_ptPosition.y());
        }
        //---Right
        else if (isSnaped[3])
        {
            if (m_ptPosition.x() - pe->pos().x() >= snapFactor)
            {
                move(scrWidth - width - snapFactor - 1, top);
                return;
            }
            else
                if (pe->globalPos().y() - m_ptPosition.y() >= 0 &&
                    pe->globalPos().y() - m_ptPosition.y() <= scrHeight - height)
                    move(scrWidth - width, pe->globalPos().y() - m_ptPosition.y());
        }
        else
            move(pe->globalPos() - m_ptPosition);

        //--Snap----------

        if (SnapEnabled)
        {
            //---Top
            if (!isSnaped[0] && !isAnymoreSnapped(0) && top < snapFactor)
            {
                this->move(left, 0);
                isSnaped[0] = true;
            }
            //---Bottom
            if (!isSnaped[1] && !isAnymoreSnapped(1) && (scrHeight - bottom) < snapFactor)
            {
                this->move(left, (scrHeight - height));
                isSnaped[1] = true;
            }
            //---Left
            if (!isSnaped[2] && !isAnymoreSnapped(2) && left < snapFactor)
            {
                this->move(0, top);
                isSnaped[2] = true;
            }
            //---Right
            if (!isSnaped[3] && !isAnymoreSnapped(3) && (scrWidth - right) < snapFactor)
            {
                this->move((scrWidth - width), top);
                isSnaped[3] = true;
            }
        }
    }
    QGraphicsView::mouseMoveEvent(pe);
}
Пример #26
0
void BrowserWindow::setupUi()
{
    int locationBarWidth;
    int websearchBarWidth;

    QDesktopWidget* desktop = mApp->desktop();
    int windowWidth = desktop->availableGeometry().width() / 1.3;
    int windowHeight = desktop->availableGeometry().height() / 1.3;

    Settings settings;
    settings.beginGroup("Browser-View-Settings");
    if (settings.value("WindowMaximised", false).toBool()) {
        resize(windowWidth, windowHeight);
        setWindowState(Qt::WindowMaximized);
    }
    else {
        // Let the WM decides where to put new browser window
        if ((m_windowType != Qz::BW_FirstAppWindow && m_windowType != Qz::BW_MacFirstWindow) && mApp->getWindow()) {
#ifdef Q_WS_WIN
            // Windows WM places every new window in the middle of screen .. for some reason
            QPoint p = mApp->getWindow()->geometry().topLeft();
            p.setX(p.x() + 30);
            p.setY(p.y() + 30);

            if (!desktop->availableGeometry(mApp->getWindow()).contains(p)) {
                p.setX(desktop->availableGeometry(mApp->getWindow()).x() + 30);
                p.setY(desktop->availableGeometry(mApp->getWindow()).y() + 30);
            }

            setGeometry(QRect(p, mApp->getWindow()->size()));
#else
            resize(mApp->getWindow()->size());
#endif
        }
        else if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) {
#ifdef Q_WS_WIN
            setGeometry(QRect(desktop->availableGeometry(mApp->getWindow()).x() + 30,
                              desktop->availableGeometry(mApp->getWindow()).y() + 30, windowWidth, windowHeight));
#else
            resize(windowWidth, windowHeight);
#endif
        }
    }

    locationBarWidth = settings.value("LocationBarWidth", 480).toInt();
    websearchBarWidth = settings.value("WebSearchBarWidth", 140).toInt();
    settings.endGroup();

    QWidget* widget = new QWidget(this);
    widget->setCursor(Qt::ArrowCursor);
    setCentralWidget(widget);

    m_mainLayout = new QVBoxLayout(widget);
    m_mainLayout->setContentsMargins(0, 0, 0, 0);
    m_mainLayout->setSpacing(0);
    m_mainSplitter = new QSplitter(this);
    m_mainSplitter->setObjectName("sidebar-splitter");
    m_tabWidget = new TabWidget(this);
    m_superMenu = new QMenu(this);
    m_navigationToolbar = new NavigationBar(this);
    m_navigationToolbar->setSplitterSizes(locationBarWidth, websearchBarWidth);
    m_bookmarksToolbar = new BookmarksToolbar(this);

    m_navigationContainer = new NavigationContainer(this);
    m_navigationContainer->addWidget(m_navigationToolbar);
    m_navigationContainer->addWidget(m_bookmarksToolbar);
    m_navigationContainer->setTabBar(m_tabWidget->tabBar());

    m_mainSplitter->addWidget(m_tabWidget);
    m_mainSplitter->setCollapsible(0, false);

    m_mainLayout->addWidget(m_navigationContainer);
    m_mainLayout->addWidget(m_mainSplitter);

    statusBar()->setObjectName("mainwindow-statusbar");
    statusBar()->setCursor(Qt::ArrowCursor);
    m_progressBar = new ProgressBar(statusBar());
    m_adblockIcon = new AdBlockIcon(this);
    m_ipLabel = new QLabel(this);
    m_ipLabel->setObjectName("statusbar-ip-label");
    m_ipLabel->setToolTip(tr("IP Address of current page"));

    statusBar()->addPermanentWidget(m_progressBar);
    statusBar()->addPermanentWidget(m_ipLabel);
    statusBar()->addPermanentWidget(m_adblockIcon);

    // Workaround for Oxygen tooltips not having transparent background
    QPalette pal = QToolTip::palette();
    QColor col = pal.window().color();
    col.setAlpha(0);
    pal.setColor(QPalette::Window, col);
    QToolTip::setPalette(pal);

    // Set some sane minimum width
    setMinimumWidth(300);
}
Пример #27
0
GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr)
{
    Pica::g_debug_context = Pica::DebugContext::Construct();

    ui.setupUi(this);
    statusBar()->hide();

    render_window = new GRenderWindow(this, emu_thread.get());
    render_window->hide();

    game_list = new GameList();
    ui.horizontalLayout->addWidget(game_list);

    profilerWidget = new ProfilerWidget(this);
    addDockWidget(Qt::BottomDockWidgetArea, profilerWidget);
    profilerWidget->hide();

#if MICROPROFILE_ENABLED
    microProfileDialog = new MicroProfileDialog(this);
    microProfileDialog->hide();
#endif

    disasmWidget = new DisassemblerWidget(this, emu_thread.get());
    addDockWidget(Qt::BottomDockWidgetArea, disasmWidget);
    disasmWidget->hide();

    registersWidget = new RegistersWidget(this);
    addDockWidget(Qt::RightDockWidgetArea, registersWidget);
    registersWidget->hide();

    callstackWidget = new CallstackWidget(this);
    addDockWidget(Qt::RightDockWidgetArea, callstackWidget);
    callstackWidget->hide();

    graphicsWidget = new GPUCommandStreamWidget(this);
    addDockWidget(Qt::RightDockWidgetArea, graphicsWidget);
    graphicsWidget ->hide();

    graphicsCommandsWidget = new GPUCommandListWidget(this);
    addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget);
    graphicsCommandsWidget->hide();

    auto graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(Pica::g_debug_context, this);
    addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget);
    graphicsBreakpointsWidget->hide();

    auto graphicsVertexShaderWidget = new GraphicsVertexShaderWidget(Pica::g_debug_context, this);
    addDockWidget(Qt::RightDockWidgetArea, graphicsVertexShaderWidget);
    graphicsVertexShaderWidget->hide();

    auto graphicsTracingWidget = new GraphicsTracingWidget(Pica::g_debug_context, this);
    addDockWidget(Qt::RightDockWidgetArea, graphicsTracingWidget);
    graphicsTracingWidget->hide();

    auto graphicsSurfaceViewerAction = new QAction(tr("Create Pica surface viewer"), this);
    connect(graphicsSurfaceViewerAction, SIGNAL(triggered()), this, SLOT(OnCreateGraphicsSurfaceViewer()));

    QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging"));
    debug_menu->addAction(graphicsSurfaceViewerAction);
    debug_menu->addSeparator();
    debug_menu->addAction(profilerWidget->toggleViewAction());
#if MICROPROFILE_ENABLED
    debug_menu->addAction(microProfileDialog->toggleViewAction());
#endif
    debug_menu->addAction(disasmWidget->toggleViewAction());
    debug_menu->addAction(registersWidget->toggleViewAction());
    debug_menu->addAction(callstackWidget->toggleViewAction());
    debug_menu->addAction(graphicsWidget->toggleViewAction());
    debug_menu->addAction(graphicsCommandsWidget->toggleViewAction());
    debug_menu->addAction(graphicsBreakpointsWidget->toggleViewAction());
    debug_menu->addAction(graphicsVertexShaderWidget->toggleViewAction());
    debug_menu->addAction(graphicsTracingWidget->toggleViewAction());

    // Set default UI state
    // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half
    QDesktopWidget* desktop = ((QApplication*)QApplication::instance())->desktop();
    QRect screenRect = desktop->screenGeometry(this);
    int x, y, w, h;
    w = screenRect.width() * 2 / 3;
    h = screenRect.height() / 2;
    x = (screenRect.x() + screenRect.width()) / 2 - w / 2;
    y = (screenRect.y() + screenRect.height()) / 2 - h * 55 / 100;
    setGeometry(x, y, w, h);

    // Restore UI state
    restoreGeometry(UISettings::values.geometry);
    restoreState(UISettings::values.state);
    render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
#if MICROPROFILE_ENABLED
    microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry);
    microProfileDialog->setVisible(UISettings::values.microprofile_visible);
#endif

    game_list->LoadInterfaceLayout();

    ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
    ToggleWindowMode();

    ui.actionDisplay_widget_title_bars->setChecked(UISettings::values.display_titlebar);
    OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked());

    // Prepare actions for recent files
    for (int i = 0; i < max_recent_files_item; ++i) {
        actions_recent_files[i] = new QAction(this);
        actions_recent_files[i]->setVisible(false);
        connect(actions_recent_files[i], SIGNAL(triggered()), this, SLOT(OnMenuRecentFile()));

        ui.menu_recent_files->addAction(actions_recent_files[i]);
    }
    UpdateRecentFiles();

    // Setup connections
    connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)), Qt::DirectConnection);
    connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(OnConfigure()));
    connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile()),Qt::DirectConnection);
    connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap()));
    connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot()));
    connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame()));
    connect(ui.action_Pause, SIGNAL(triggered()), this, SLOT(OnPauseGame()));
    connect(ui.action_Stop, SIGNAL(triggered()), this, SLOT(OnStopGame()));
    connect(ui.action_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode()));

    connect(this, SIGNAL(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*)));
    connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping()));
    connect(this, SIGNAL(EmulationStarting(EmuThread*)), registersWidget, SLOT(OnEmulationStarting(EmuThread*)));
    connect(this, SIGNAL(EmulationStopping()), registersWidget, SLOT(OnEmulationStopping()));
    connect(this, SIGNAL(EmulationStarting(EmuThread*)), render_window, SLOT(OnEmulationStarting(EmuThread*)));
    connect(this, SIGNAL(EmulationStopping()), render_window, SLOT(OnEmulationStopping()));
    connect(this, SIGNAL(EmulationStarting(EmuThread*)), graphicsTracingWidget, SLOT(OnEmulationStarting(EmuThread*)));
    connect(this, SIGNAL(EmulationStopping()), graphicsTracingWidget, SLOT(OnEmulationStopping()));


    // Setup hotkeys
    RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
    RegisterHotkey("Main Window", "Start Emulation");
    LoadHotkeys();

    connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile()));
    connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame()));

    std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
    setWindowTitle(window_title.c_str());

    show();

    game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);

    QStringList args = QApplication::arguments();
    if (args.length() >= 2) {
        BootGame(args[1].toStdString());
    }
}
QRect QtWidgetsTweakletImpl::GetAvailableScreenSize(int i)
{
  QDesktopWidget *desktop = QApplication::desktop();
  if (i < 0) return desktop->screen()->geometry();
  return desktop->availableGeometry(i);
}
Пример #29
0
void VersionInfo::init()
{
    setMinimumSize(QSize(16,400));
    QFont boldFont = this->font();
    boldFont.setBold(true);

    QDesktopWidget *desktop = QApplication::desktop();
    double imageScale = ((double)desktop->availableGeometry(desktop->screenNumber(this)).width())/400.0;
    if (imageScale > 1.0)
        imageScale = 1.0;
    int imageSize = (int)(55 * imageScale);
    int finalSize = (int)(60 * imageScale);

    QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
    vBoxLayout->setMargin( 0 );
    vBoxLayout->setSpacing( 0 );

    QGridLayout *gridLayout1 = new QGridLayout;
    gridLayout1->setSpacing( 4 );
    gridLayout1->setMargin( 0 );
    gridLayout1->setColumnMinimumWidth(0, 20 );

    QLabel *qtopiaLogo = new QLabel(this);
    QThumbnail thumbnail(":image/qpe-logo");
    qtopiaLogo->setPixmap(thumbnail.pixmap(QSize(imageSize, imageSize)));
    qtopiaLogo->setFixedSize( finalSize, finalSize );
    gridLayout1->addWidget(qtopiaLogo, 0, 0, 1, 1);

    QVBoxLayout *vBoxLayout1 = new QVBoxLayout;
    vBoxLayout1->setMargin( 0 );
    vBoxLayout1->setSpacing( 3 );
    QLabel *qtopiaName = new QLabel(this);
    qtopiaName->setFont(boldFont);
    qtopiaName->setText(tr("QtMoko"));
    vBoxLayout1->addWidget(qtopiaName);

    QLabel *qtopiaVersion = new QLabel(this);
    qtopiaVersion->setWordWrap(true);
    qtopiaVersion->setText(tr("Version:") + ' ' + Qtopia::version() + '\n' + tr("Qt version:") + ' ' + QT_VERSION_STR);
    vBoxLayout1->addWidget(qtopiaVersion);
    vBoxLayout1->addSpacing( 10 );

    QLabel *qtopiaCopyright = new QLabel(this);
    qtopiaCopyright->setText(tr( "Copyright \251 %1", "%1 = 'year'" ).arg(QT_EXTENDED_COPYRIGHT_YEAR));
    vBoxLayout1->addWidget(qtopiaCopyright);
    QLabel* qtopiaCopyright1 = new QLabel( this );
    qtopiaCopyright1->setWordWrap( true );
    qtopiaCopyright1->setText( QT_EXTENDED_COPYRIGHT_COMPANY );
    vBoxLayout1->addWidget(qtopiaCopyright1);

    vBoxLayout1->addSpacing( 10 );

    QLabel *qtopiaBuild = new QLabel(this);
    qtopiaBuild->setWordWrap( true );
    QString builder( BUILDER );
    int atIndex = builder.indexOf( QChar('@') );
    int dotIndex = -1;
    if ( atIndex >= 0 )
        dotIndex = builder.indexOf( QChar('.'), atIndex );
    if ( dotIndex >= 0 )
        builder = builder.left( dotIndex );
    qtopiaBuild->setText(tr("Built by\n%1", "%1 = name").arg(builder));
    vBoxLayout1->addWidget(qtopiaBuild);

    qtopiaBuild = new QLabel(this);
    qtopiaBuild->setText(tr("Built on %1","1=date").arg(__DATE__));
    vBoxLayout1->addWidget(qtopiaBuild);

    QSpacerItem *spacerItem = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
    vBoxLayout1->addItem(spacerItem);
    gridLayout1->addLayout(vBoxLayout1, 0, 1, 2, 1);
    vBoxLayout->addLayout(gridLayout1);

    QGridLayout *gridLayout2 = new QGridLayout;
    gridLayout2->setColumnMinimumWidth(0, 20 );
    gridLayout2->setSpacing( 4 );
    gridLayout2->setMargin( 0 );
    QLabel *linuxLogo = new QLabel(this);
    QThumbnail thumbnail2(":image/tux-logo");
    linuxLogo->setPixmap(thumbnail2.pixmap(QSize(imageSize, imageSize)));
    linuxLogo->setFixedSize( finalSize, finalSize );
    gridLayout2->addWidget(linuxLogo, 0, 0, 1, 1);

    QVBoxLayout *vBoxLayout2 = new QVBoxLayout;
    vBoxLayout2->setMargin( 0 );
    vBoxLayout2->setSpacing( 3 );
    QLabel *linuxName = new QLabel(this);
    linuxName->setFont(boldFont);
    linuxName->setText(tr("Linux Kernel"));
    vBoxLayout2->addWidget(linuxName);

    QString kernelVersionString;
    QString compiledByString;
    QFile file("/proc/version");
    if(file.open(QFile::ReadOnly))
    {
        QTextStream t( &file );
        QString v;
        t >> v; t >> v; t >> v;
        kernelVersionString = v.left( 20 );
        t >> v;
        compiledByString = v;
        file.close();
    }
Пример #30
0
bool WebCore::screenIsMonochrome(Widget *w)
{
    QDesktopWidget *d = QApplication::desktop();
    return d->screen(d->screenNumber(w->qwidget()))->numColors() < 2;
}