Exemplo n.º 1
0
 LRESULT dpi_changed_handler(LPARAM lparam) {
   
   plx::RectL r(plx::SizeL(
         static_cast<long>(dpi().to_physical_x(width_)),
         static_cast<long>(dpi().to_physical_x(height_))));
   
   auto suggested = reinterpret_cast<const RECT*> (lparam);
   ::AdjustWindowRectEx(&r, 
       ::GetWindowLong(window(), GWL_STYLE),
       FALSE,
       ::GetWindowLong(window(), GWL_EXSTYLE));
   ::SetWindowPos(window(), nullptr, suggested->left, suggested->top,
                  r.width(), r.height(),
                  SWP_NOACTIVATE | SWP_NOZORDER);
   return 0;
 }
Exemplo n.º 2
0
void loadfile(QString filename)
{
  // Typical FAX resolutions are:
  // Standard: 203 dpi x 98 dpi
  // Fine: 203 dpi x 196 lpi
  // Super Fine: 203 dpi y 392 lpi,  or
  //             406 dpi x 392 lpi
  QSize dpi(203,196);

  KFileMetaInfo metaInfo(filename);
  if (metaInfo.isValid() && metaInfo.item("Resolution").isValid())
  {
    QSize s = metaInfo.item("Resolution").value().toSize();
    if (s.width() >= 100 && s.height() >= 100)
	dpi = s;
  }

  (void) notetiff(QFile::encodeName(filename));

  struct pagenode *pn;
  for(pn = firstpage; pn; pn = pn->next) 
   if (!pn->dpiX) {
	pn->dpiX = dpi.width();
	pn->dpiY = dpi.height();
   }
}
Exemplo n.º 3
0
void KbPerf::baseDpiIdx(int newIdx) {
    if (pushedDpis.isEmpty() && dpiBaseIdx == newIdx)
        return;
    pushedDpis.clear();
    dpiBaseIdx = newIdx;
    _curDpi(dpi(dpiBaseIdx));
    _needsUpdate = _needsSave = true; 
}
Exemplo n.º 4
0
void GSRasterizer::DrawLine(const GSVertexSW* v, const GSVector4i& scissor)
{
	GSVertexSW dv = v[1] - v[0];

	GSVector4 dp = dv.p.abs();
	GSVector4i dpi(dp);

	if(dpi.y == 0)
	{
		if(dpi.x > 0)
		{
			// shortcut for horizontal lines

			GSVector4 mask = (v[0].p > v[1].p).xxxx();

			GSVertexSW l, dl;

			l.p = v[0].p.blend8(v[1].p, mask);
			l.t = v[0].t.blend8(v[1].t, mask);
			l.c = v[0].c.blend8(v[1].c, mask);

			GSVector4 r;

			r = v[1].p.blend8(v[0].p, mask);

			GSVector4i p(l.p);

			if(scissor.y <= p.y && p.y < scissor.w)
			{
				GSVertexSW dscan = dv / dv.p.xxxx();

				(m_ds->*m_dsf.sp)(v, dscan);

				l.p = l.p.upl(r).xyzw(l.p); // r.x => l.y

				DrawTriangleSection(p.y, p.y + 1, l, dl, dscan, scissor);
			}
		}

		return;
	}

	int i = dpi.x > dpi.y ? 0 : 1;

	GSVertexSW edge = v[0];
	GSVertexSW dedge = dv / dp.v[i];

	// TODO: prestep + clip with the scissor

	int steps = dpi.v[i];

	while(steps-- > 0)
	{
		DrawPoint(&edge, scissor);

		edge += dedge;
	}
}
Exemplo n.º 5
0
int UnitsAttached::dp() const
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
    return m_multiplier;
#else
    auto dp = dpi() / 160;

    return dp > 0 ? dp * m_multiplier : m_multiplier;
#endif
}
Exemplo n.º 6
0
bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page * > &pagesVector )
{
    //kDebug(DviDebug) << "file:" << fileName;
    KUrl base( fileName );

    (void)userMutex();

    m_dviRenderer = new dviRenderer(documentMetaData("TextHinting", QVariant()).toBool());
    connect( m_dviRenderer, SIGNAL( error(QString,int) ), this, SIGNAL( error(QString,int) ) );
    connect( m_dviRenderer, SIGNAL( warning(QString,int) ), this, SIGNAL( warning(QString,int) ) );
    connect( m_dviRenderer, SIGNAL( notice(QString,int) ), this, SIGNAL( notice(QString,int) ) );
#ifdef DVI_OPEN_BUSYLOOP
    static const ushort s_waitTime = 800; // milliseconds
    static const int s_maxIterations = 10;
    int iter = 0;
    for ( ; !m_dviRenderer->isValidFile( fileName ) && iter < s_maxIterations; ++iter )
    {
        kDebug(DviDebug).nospace() << "file not valid after iteration #" << iter << "/" << s_maxIterations << ", waiting for " << s_waitTime;
#ifdef Q_OS_WIN
        Sleep( uint( s_waitTime ) );
#else
        struct timespec ts = { 0, s_waitTime * 1000 * 1000 };
        nanosleep( &ts, NULL );
#endif
    }
    if ( iter >= s_maxIterations && !m_dviRenderer->isValidFile( fileName ) )
    {
        kDebug(DviDebug) << "file still not valid after" << s_maxIterations;
        delete m_dviRenderer;
        m_dviRenderer = 0;
        return false;
    }
#else
    if ( !m_dviRenderer->isValidFile( fileName ) )
    {
        delete m_dviRenderer;
        m_dviRenderer = 0;
        return false;
    }
#endif
    if ( ! m_dviRenderer->setFile( fileName, base ) )
    {
        delete m_dviRenderer;
        m_dviRenderer = 0;
        return false;
    }

    kDebug(DviDebug) << "# of pages:" << m_dviRenderer->dviFile->total_pages;

    m_resolution = dpi().height();
    loadPages( pagesVector );

    return true;
}
Exemplo n.º 7
0
Screen::DisplayDensity Screen::displayDensity() const
{
    const qreal sdpi = dpi();
    if (sdpi < DISPLAY_DENSITY_LIMIT_SMALL)
        return Low;
    else if (sdpi < DISPLAY_DENSITY_LIMIT_MEDIUM)
        return Medium;
    else if (sdpi < DISPLAY_DENSITY_LIMIT_LARGE)
        return High;

    return ExtraHigh;
}
Exemplo n.º 8
0
void KbPerf::popDpi(quint64 pushIdx){
    if(!pushedDpis.contains(pushIdx)) {   
      return;
    }
    pushedDpis.remove(pushIdx);
    if (pushedDpis.isEmpty()) {
        _curDpi(dpi(dpiBaseIdx));
    } else {
        // Set the DPI to the last-pushed value still on the stack
        _curDpi(map_last(pushedDpis));
    } 
    _needsUpdate = _needsSave = true;
}
Exemplo n.º 9
0
void RWinColorPaletteWell::OnPaint( )
{
	CPaintDC dc( this );

	CRect rect;
	GetClientRect( rect );

	if (m_crColor.GetFillMethod() != RColor::kTransparent)
	{
		// The bounding rect is in logical units, so we
		// need to create a transform to scale from logical
		// units to device units.  We also divide by 2 to
		// account for the scaling in the bounding rect to
		// make the texture more visible in such a small area.
		RRealSize dpi( ::GetScreenDPI() );
		R2dTransform transform;
		transform.PostScale( 
			dpi.m_dx / kSystemDPI * 0.5, 
			dpi.m_dy / kSystemDPI * 0.5 );

		RColor crFillColor = m_crColor;
		crFillColor *= transform;

		RIntRect rRect( rect );
		RDcDrawingSurface ds;
		ds.Initialize( (HDC) dc );

		RColor oldColor = ds.GetFillColor();
		ds.SetFillColor( crFillColor );
		ds.FillRectangle( rRect );
		ds.SetFillColor( oldColor );
		ds.DetachDCs();
	}
	else
	{
		dc.FillSolidRect( rect, RGB( 255, 255, 255 ) );

		CString strText ;
		GetWindowText( strText );
		CRect rcTextRect( rect );
		rcTextRect.DeflateRect( 1, 1 );

		CFont* pFont = dc.SelectObject( GetParent()->GetFont() );
		dc.DrawText( strText, rcTextRect, DT_CENTER | DT_VCENTER );
		dc.SelectObject( pFont );
	}

	dc.MoveTo( rect.left, rect.bottom - 1 );
	dc.LineTo( rect.left, rect.top );
	dc.LineTo( rect.right, rect.top );
}
Exemplo n.º 10
0
void GLESettings::writeAll()
{
	// Store the application settings
	settingStore->setValue("application/position", position());
	settingStore->setValue("application/size", size());
	settingStore->setValue("application/mainstate", mainWindowState());
	settingStore->setValue("application/drawingsize", drawingAreaSize());
	settingStore->setValue("application/storeSize", storeSize());
	settingStore->setValue("application/storeDirectory", storeDirectory());
	settingStore->setValue("application/saveOnPreview", saveOnPreview());
	settingStore->setValue("application/autoScaleOnOpen", autoScaleOnOpen());
	settingStore->setValue("application/libGSLocation", getLibGSLocation());
	settingStore->setValue("application/editorLocation", editorLocation());
	settingStore->setValue("application/resolution", dpi());
	settingStore->setValue("application/monitorOpenFile", monitorOpenFile());
	settingStore->setValue("application/monitorAutoReload", monitorAutoReloadFile());
	settingStore->setValue("application/askAboutKeepingObjects", askAboutObjects());
	settingStore->setValue("application/splitterSizes", splitterPosition());
	settingStore->setValue("application/consoleAutoShowSize", getConsoleWindowAutoShowSize());
	settingStore->setValue("application/emulateGLEVersion", getEmulateGLEVersion());
	settingStore->setValue("application/exportFormat", getExportFormat());
	settingStore->setValue("application/exportPageSize", getExportPageSize());
	settingStore->setValue("application/previewPageSize", getPreviewPageSize());
	settingStore->setValue("application/openExportedFigure", isOpenExportedFigure());
	settingStore->setValue("application/exportGrayScale", isExportGrayScale());
	settingStore->setValue("application/exportTransparent", isExportTransparent());
	settingStore->setValue("application/exportBitmapResolution", getExportBitmapResolution());
	settingStore->setValue("application/exportVectorResolution", getExportVectorResolution());
	settingStore->setValue("application/renderUsingCairo", isRenderUsingCairo());

	if (storeDirectory())
		settingStore->setValue("application/workingDirectory", pwd());

	// Store the server settings
	settingStore->setValue("server/portNumber", port());
	settingStore->setValue("server/autoStart", autoStartServer());

	// Store the drawing settings
	settingStore->setValue("drawing/gridX", grid().x());
	settingStore->setValue("drawing/gridY", grid().y());
	settingStore->setValue("drawing/equalGrid", equalGrid());

	settingStore->setValue("drawing/polarSnapStartAngle", polarSnapStartAngle());
	settingStore->setValue("drawing/polarSnapIncAngle", polarSnapIncAngle());
	settingStore->setValue("drawing/osnapOnStart", osnapOnStart());
	settingStore->setValue("drawing/orthoSnapOnStart", orthoSnapOnStart());
	settingStore->setValue("drawing/polarSnapOnStart", polarSnapOnStart());
	settingStore->setValue("drawing/polarTrackOnStart", polarSnapOnStart());
	settingStore->setValue("drawing/gridSnapOnStart", gridSnapOnStart());
}
Exemplo n.º 11
0
bool CDpiForDialog::ProcessDpiMessages(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
	switch (nMsg)
	{
	case WM_DPICHANGED:
		{
			DpiValue dpi(wParam);
			LPRECT lprcSuggested = (LPRECT)lParam;
			SetDialogDPI(dpi, lprcSuggested);
			SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0);
		}
		return true;
	}
	return false;
}
Exemplo n.º 12
0
Screen::DisplayType Screen::displayType() const
{
    int w = width();
    int h = height();
    const qreal diagonal = qSqrt(static_cast<qreal>(w*w + h*h)) / dpi();

    if (diagonal < DISPLAY_TYPE_LIMIT_SMALL)
        return Small;
    else if (diagonal < DISPLAY_TYPE_LIMIT_NORMAL)
        return Normal;
    else if (diagonal < DISPLAY_TYPE_LIMIT_LARGE)
        return Large;
    // neither of these, so return desktop (tablets belong here) type
    return Desktop;
}
Exemplo n.º 13
0
KbPerf::KbPerf(KbMode* parent, const KbPerf& other) :
    QObject(parent), dpiCurX(other.dpiCurX), dpiCurY(other.dpiCurY), dpiBaseIdx(other.dpiBaseIdx), runningPushIdx(1),
    _iOpacity(other._iOpacity), light100Color(other.light100Color), muteNAColor(other.muteNAColor), _dpiIndicator(other._dpiIndicator),
    _liftHeight(other._liftHeight), _angleSnap(other._angleSnap),
    _needsUpdate(true), _needsSave(true) {
    memcpy(dpiX, other.dpiX, sizeof(dpiX));
    memcpy(dpiY, other.dpiY, sizeof(dpiY));
    for(int i = 0; i < DPI_COUNT + 1; i++)
        dpiClr[i] = other.dpiClr[i];
    memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
    for(int i = 0; i < I_COUNT; i++){
        iColor[i][0] = other.iColor[i][0];
        iColor[i][1] = other.iColor[i][1];
    }
    memcpy(iEnable, other.iEnable, sizeof(iEnable));
    memcpy(hwIType, other.hwIType, sizeof(hwIType));
    // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
    _curDpi(dpi(dpiBaseIdx));
}
Exemplo n.º 14
0
const KbPerf& KbPerf::operator= (const KbPerf& other){
    dpiCurX = other.dpiCurX; dpiCurY = other.dpiCurY; dpiBaseIdx = other.dpiBaseIdx; runningPushIdx = 1;
    _iOpacity = other._iOpacity; light100Color = other.light100Color; muteNAColor = other.muteNAColor; _dpiIndicator = other._dpiIndicator;
    _liftHeight = other._liftHeight; _angleSnap = other._angleSnap;
    _needsUpdate = true; _needsSave = true;
    memcpy(dpiX, other.dpiX, sizeof(dpiX));
    memcpy(dpiY, other.dpiY, sizeof(dpiY));
    for(int i = 0; i < DPI_COUNT + 1; i++)
        dpiClr[i] = other.dpiClr[i];
    memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
    for(int i = 0; i < I_COUNT; i++){
        iColor[i][0] = other.iColor[i][0];
        iColor[i][1] = other.iColor[i][1];
    }
    memcpy(iEnable, other.iEnable, sizeof(iEnable));
    memcpy(hwIType, other.hwIType, sizeof(hwIType));
    // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
    _curDpi(dpi(dpiBaseIdx));
    return other;
}
Exemplo n.º 15
0
int main(int argc, char **argv)
{
	g_log_level=ds_Console;
	_logfile=stderr;
	bool daemonise = false;
	const char *profile = NULL;
	const char *logpath = NULL;
	const char *pid = NULL;

	{
		bool dohelp = true;
		int i;
		
		for (i = 1; i < argc; i++)
		{
			if (!strcmp(argv[i],"-i")) {
				log_printf(ds_Console,"Interactive!");
				daemonise = false;
				dohelp = false;
			}
			else if (!strcmp(argv[i],"-L")) {
				char *szLI2;
				szLI2=(char*)malloc(sK0[3]);
				safe_strncpy(szLI2,(char*)sK1[3],sK0[3]);
				dpi(szLI2,4);
				RelpaceCr(szLI2);
				fprintf(_logfile,"\n\n%s\n",szLI2);
				memset(szLI2,0,sK0[3]);free(szLI2);
				return 1;
			}
			else if (!strcmp(argv[i],"-d")) {
				daemonise = true;
				if (++i < argc) {
					logpath = argv[i];
					dohelp = false;
				}
				else
					break;
			}
			else if (!strcmp(argv[i],"-p")) {
				if (++i < argc) {
					profile = argv[i];
					dohelp = false;
				}
				else
					break;
			}
			else if (!strcmp(argv[i],"-P")) {
				if (++i < argc) {
					pid = argv[i];
					FILE *pidfile = fopen(pid,"w");
					if (pidfile != NULL) {
						fprintf(pidfile, "%i\n", (int)getpid() );
						fclose(pidfile);
					}
					dohelp = false;
				}
				else
					break;
			}
			else
				break;
		}

		if (dohelp) {
			char *szCR2;
			szCR2=(char*)malloc(sK0[1]);
			safe_strncpy(szCR2,(char*)sK1[1],sK0[1]);
			dpi(szCR2,2);
			RelpaceCr(szCR2);

			log_printf(ds_Console,
				"%s\n"
				"%s\n"
				"\n"
				"Usage: wastesrv [-p <profile>] [-L] [-i] [-P <PID file>| [-d <logfile>]\n"
				"\t -L print license\n"
				"\t -p profile to use (default)\n"
				"\t -i interactive mode\n"
				"\t -P PID file to write PID in\n"
				"\t -d daemon mode (on *nix this will put wastesrv in the background)\n"
				"\n"
				"\twastesrv.ini must to be present on Windows\n"
				"\tthe config is default.pr0 to default.pr4\n",
				g_nameverstr,
				szCR2
				);
			memset(szCR2,0,sK0[1]);free(szCR2);
			return 1;
		}
	}

	if (daemonise) {
		assert(logpath);
		log_printf(ds_Console,"Forking DAEMON!");
		log_UpdatePath(logpath, true);
		#ifndef _WIN32
			daemon(1,0);
		#endif
		log_printf(ds_Console,"DAEMON!");
	}

    if (!profile)
		profile = "default";

	// TODO: gvdl should take a directory argument
	SetProgramDirectory(argv[0]);

	installsighandler();

	log_printf(ds_Console,"%s starting up...%s.pr0",g_nameverstr, profile);

	MYSRAND();
	if (!g_exit) //emergency break!
	{
		strcat(g_config_prefix, profile);

		#ifdef _WIN32
			WSADATA wsaData;
			if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
				memset(&g_key,0,sizeof(g_key));
				MessageBox(NULL,"Error initializing Winsock\n",APP_NAME " Error",0);
				return 1;
			}
		#endif

		UnifiedReadConfig();

		InitialLoadDb();

		PrepareDownloadDirectory();

		if (!g_key.bits) {
			reloadKey(
				g_config->ReadInt(CONFIG_storepass,CONFIG_storepass_DEFAULT),
				(char *) g_config->ReadString(CONFIG_keypass,CONFIG_keypass_DEFAULT));
		};

		InitializeNetworkparts();

		//main_AddNodes();
		LoadNetQ();
		
		// run loop

		while (!g_exit)
		{
			DoMainLoop();
			Sleep(33);
		};

		// exit
		log_printf(ds_Console,"cleaning up");

		SaveDbToDisk();

		delete g_listen;
		delete g_dns;
		if (g_newdatabase != g_database) delete g_newdatabase;
		delete g_database;
	};

	SaveNetQ();

	int x;
	for (x = 0; x < g_recvs.GetSize(); x ++) delete g_recvs.Get(x);
	for (x = 0; x < g_sends.GetSize(); x ++) delete g_sends.Get(x);
	for (x = 0; x < g_new_net.GetSize(); x ++) delete g_new_net.Get(x);
	for (x = 0; x < g_uploads.GetSize(); x ++) free(g_uploads.Get(x));
	if (g_aclist) free(g_aclist);
	KillPkList();

	delete g_mql;

	delete g_config;
	memset(&g_key,0,sizeof(g_key));

	#ifdef _WIN32
		WSACleanup();
	#endif
	log_UpdatePath(NULL);
	return 0;
}
Exemplo n.º 16
0
void GSRasterizer::DrawLine(const GSVertexSW* v, const GSVector4i& scissor)
{
	GSVertexSW dv = v[1] - v[0];

	GSVector4 dp = dv.p.abs();

	if(m_dsf.ssle)
	{
		int i = (dp < dp.yxwz()).mask() & 1; // |x| <= |y|

		GSVertexSW dscan;

		dscan.p = GSVector4::zero();
		dscan.t = GSVector4::zero();
		dscan.c = GSVector4::zero();

		m_dsf.ssp(v, dscan);

		DrawEdge(v[0], v[1], dv, scissor, i, 0);
		DrawEdge(v[0], v[1], dv, scissor, i, 1);

		return;
	}

	GSVector4i dpi(dp);

	if(dpi.y == 0)
	{
		if(dpi.x > 0)
		{
			// shortcut for horizontal lines

			GSVector4 mask = (v[0].p > v[1].p).xxxx();

			GSVertexSW l, dl;

			l.p = v[0].p.blend8(v[1].p, mask);
			l.t = v[0].t.blend8(v[1].t, mask);
			l.c = v[0].c.blend8(v[1].c, mask);

			GSVector4 r;

			r = v[1].p.blend8(v[0].p, mask);

			GSVector4i p(l.p);

			if(scissor.top <= p.y && p.y < scissor.bottom)
			{
				GSVertexSW dscan = dv / dv.p.xxxx();

				m_dsf.ssp(v, dscan);

				l.p = l.p.upl(r).xyzw(l.p); // r.x => l.y

				GSVector4 fscissor(scissor);

				DrawTriangleSection(p.y, p.y + 1, l, dl, dscan, fscissor);
			}
		}

		return;
	}

	int i = dpi.x > dpi.y ? 0 : 1;

	GSVertexSW edge = v[0];
	GSVertexSW dedge = dv / dp.v[i];

	// TODO: prestep + clip with the scissor

	int steps = dpi.v[i];

	while(steps-- > 0)
	{
		DrawPoint(&edge, scissor);

		edge += dedge;
	}
}
Exemplo n.º 17
0
void KbPerf::load(CkbSettings& settings){
    pushedDpis.clear();
    runningPushIdx = 1;
    _needsSave = false;
    bool readIndicators = true;
    if(!settings.containsGroup("Performance/Indicators")){
        // Read old indicator settings from the lighting group, if present
        // (ckb <= v0.2.0)
        SGroup group(settings, "Lighting");
        if(settings.contains("InactiveIndicators")){
            bool inOk = false;
            int inactive = settings.value("InactiveIndicators").toInt(&inOk);
            if(!inOk || inactive > 2)
                inactive = 2;
            if(inactive == 1)
                _iOpacity = 0.75f;
            else if(inactive == 0)
                _iOpacity = 0.5f;
            else if(inactive < 0){
                // Indicators disabled
                iEnable[MODE] = iEnable[MACRO] = iEnable[LIGHT] = iEnable[LOCK]  = iEnable[MUTE] = false;
            }
            bool showMute = (settings.value("ShowMute").toInt(&inOk) != 0);
            if(inOk && !showMute)
                iEnable[MUTE] = false;
            readIndicators = false;
        }
    }
    SGroup group(settings, "Performance");
    // Read DPI settings
    {
        SGroup group(settings, "DPI");
        for(int i = 0; i < DPI_COUNT; i++){
            QString iStr = QString::number(i);
            QPoint value = settings.value(iStr).toPoint();
            if(value.isNull())
                continue;
            dpiX[i] = value.x(); dpiY[i] = value.y();
            QColor color = settings.value(iStr + "RGB").toString();
            if(color.isValid())
                dpiClr[i] = color;
            if(i != 0)
                dpiOn[i] = !settings.value(iStr + "Disabled").toBool();
        }
        QColor color = settings.value("6RGB").toString();
        if(color.isValid())
            dpiClr[OTHER] = color;
        if (settings.contains("CurIdx")) {
            dpiBaseIdx = settings.value("CurIdx").toInt();
        } else {
            // If there isn't a setting for current DPI stage, pick the first
            // enabled one. Failing that just pick stage 1.
            dpiBaseIdx = 1;
            for (int i = 1; i < DPI_COUNT; i++) {
                if (dpiOn[i]) {
                    dpiBaseIdx = i;
                    break;
                }
            }	 
        }
        _curDpi(dpi(dpiBaseIdx));
    }
    // Read misc. mouse settings
    _liftHeight = (height)settings.value("LiftHeight").toInt();
    if(_liftHeight < LOW || _liftHeight > HIGH)
        _liftHeight = MEDIUM;
    _angleSnap = settings.value("AngleSnap").toBool();
    if(settings.contains("NoIndicator")){
        // ckb <= v0.2.0
        _dpiIndicator = !settings.value("NoIndicator").toBool();
    } else {
        _dpiIndicator = settings.value("Indicators/DPI", true).toBool();
    }
    // Read indicator settings
    if(readIndicators){
        SGroup group(settings, "Indicators");
        _iOpacity = settings.value("Opacity", 100).toInt() / 100.f;
        for(int i = 0; i < I_COUNT; i++){
            SGroup group(settings, QString::number(i));
            QColor color = settings.value("RGB0").toString();
            if(color.isValid())
                iColor[i][0] = color;
            color = settings.value("RGB1").toString();
            if(color.isValid())
                iColor[i][1] = color;
            if(i == LIGHT){
                color = settings.value("RGB2").toString();
                if(color.isValid())
                    light100Color = color;
            } else if(i == MUTE){
                color = settings.value("RGB2").toString();
                if(color.isValid())
                    muteNAColor = color;
            }
            if(i <= HW_IMAX){
                iEnable[i] = settings.value("Enable", false).toBool();
                hwIType[i] = (i_hw)settings.value("Hardware", (int)NORMAL).toInt();
            } else {
                iEnable[i] = settings.value("Enable", true).toBool();
            }
        }
    }
    emit didLoad();
}
Exemplo n.º 18
0
int AbstractTemplateModel::mm(double m) const
{
    return m * (dpi() / 25.4);
}
Exemplo n.º 19
0
int waste_srvmain_start(int argc, char **argv)
{
	SetProgramDirectory(argv[0]);

	g_log_level=ds_Console;
	_logfile=stderr;

	{
		bool dohelp=false;
		if (argc<2) {
			dohelp=true;
		}
		else {
			if (!strcmp(argv[1],"-i")) {
				log_printf(ds_Console,"Interactive!");
			}
			else if (!strcmp(argv[1],"-L")) {
				char *szLI2;
				szLI2=(char*)malloc(sK0[3]);
				safe_strncpy(szLI2,(char*)sK1[3],sK0[3]);
				dpi(szLI2,4);
				RelpaceCr(szLI2);
				fprintf(_logfile,"\n\n%s\n",szLI2);
				memset(szLI2,0,sK0[3]);free(szLI2);
				return 1;
			}
			else if (!strcmp(argv[1],"-d")) {
				if (argc==3) {
					log_printf(ds_Console,"Forking DAEMON!");
					log_UpdatePath(argv[2],true);
					#ifndef _WIN32
						daemon(1,0);
					#endif
					log_printf(ds_Console,"DAEMON!");
				}
				else {
					dohelp=true;
				};
			}
			else {
				dohelp=true;
			};
		};
		if (dohelp) {
			char *szCR2;
			szCR2=(char*)malloc(sK0[1]);
			safe_strncpy(szCR2,(char*)sK1[1],sK0[1]);
			dpi(szCR2,2);
			RelpaceCr(szCR2);

			log_printf(ds_Console,
				"%s\n"
				"%s\n"
				"\n"
				"Usage: wastesrv <-i> | -d <logfile>\n"
				"\t -L print license\n"
				"\t -i interactive mode\n"
				"\t -d daemon mode (on linux this will put wastesrv in the background)\n"
				"\n"
				"\twastesrv.ini must to be present on Windows\n"
				"\tthe config is default.pr0 to default.pr4\n",
				g_nameverstr,
				szCR2
				);
			memset(szCR2,0,sK0[1]);free(szCR2);
			return 1;
		};
	};

	installsighandler();

	log_printf(ds_Console,"%s starting up...",g_nameverstr);

	MYSRAND();

	if (!g_exit) //emergency break!
	{
		strcat(g_config_prefix,"default");

		#ifdef _WIN32
			WSADATA wsaData;
			if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
				memset(&g_key,0,sizeof(g_key));
				MessageBox(NULL,"Error initializing Winsock\n",APP_NAME " Error",0);
				return 1;
			}
		#endif

		UnifiedReadConfig();

		InitialLoadDb();

		PrepareDownloadDirectory();

		if (!g_key.bits) {
			reloadKey(
				g_config->ReadInt(CONFIG_storepass,CONFIG_storepass_DEFAULT)?
				g_config->ReadString(CONFIG_keypass,CONFIG_keypass_DEFAULT):
				NULL
				);
		};

		InitializeNetworkparts();
		}
		return (g_exit);
}