Ejemplo n.º 1
0
Frame::Frame(QFrame *parent)
    : DBlurEffectWidget(parent),
      m_wallpaperList(new WallpaperList(this)),
      m_closeButton(new DImageButton(":/images/close_round_normal.svg",
                                 ":/images/close_round_hover.svg",
                                 ":/images/close_round_press.svg", this)),
      m_dbusAppearance(new ComDeepinDaemonAppearanceInterface(AppearanceServ,
                                                              AppearancePath,
                                                              QDBusConnection::sessionBus(),
                                                              this)),
      m_mouseArea(new DRegionMonitor(this))
{
    // 截止到dtkwidget 2.0.10版本,在多个屏幕设置不同缩放比时
    // DRegionMonitor 计算的缩放后的坐标可能是错误的
    m_mouseArea->setCoordinateType(DRegionMonitor::Original);

    setFocusPolicy(Qt::StrongFocus);
    setWindowFlags(Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
    setAttribute(Qt::WA_TranslucentBackground);

    setBlendMode(DBlurEffectWidget::BehindWindowBlend);
    setMaskColor(DBlurEffectWidget::DarkColor);

    initUI();
    initSize();

    connect(m_mouseArea, &DRegionMonitor::buttonPress, [this](const QPoint &p, const int button){
        if (button == 4) {
            m_wallpaperList->prevPage();
        } else if (button == 5) {
            m_wallpaperList->nextPage();
        } else {
            qDebug() << "button pressed on blank area, quit.";

            qreal scale = devicePixelRatioF();
            const QRect sRect = this->windowHandle()->screen()->geometry();
            QRect nativeRect = geometry();

            // 获取窗口真实的geometry
            nativeRect.moveTopLeft((nativeRect.topLeft() - sRect.topLeft()) * scale + sRect.topLeft());
            nativeRect.setSize(nativeRect.size() * scale);

            if (!nativeRect.contains(p)) {
                hide();
            }
        }
    });

    m_closeButton->hide();
    connect(m_wallpaperList, &WallpaperList::mouseOverItemChanged,
            this, &Frame::handleNeedCloseButton);
    connect(m_wallpaperList, &WallpaperList::itemPressed,
            this, &Frame::onItemPressed);

    QTimer::singleShot(0, this, &Frame::initListView);
}
Ejemplo n.º 2
0
void Map::resize(QSize size, QSize oldSize)
{
    if (size != oldSize)
    {
        initSize(size.width(), size.height());
        mInitGL = false;
        mNext = All;
    }
    return;
}
Ejemplo n.º 3
0
bool GraphicBuffer::reallocate(unsigned int w, unsigned int h, unsigned int f, unsigned int reqUsage)
{
	if(handle && w == (unsigned int)width && h == (unsigned int)height && f == (unsigned int)format && reqUsage == (unsigned int)usage)
		return true;
	if(handle)
	{
		allocDev->free(allocDev, handle);
		handle = nullptr;
	}
	return initSize(w, h, f, reqUsage);
}
Ejemplo n.º 4
0
void Map::init(unsigned int width, unsigned int height, QUrl url, bool debug, QString player)
{
    initSize(width, height);
    mUrl = url;
    mDebug = debug;
    mPlayer = player;
    updateDataProvince();
    mInit = true;

    return;
}
GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h,
        PixelFormat reqFormat, uint32_t reqUsage, uint32_t bufferSize)
    : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
      mInitCheck(NO_ERROR), mIndex(-1)
{
    width  =
    height =
    stride =
    format =
    usage  = 0;
    handle = NULL;
    mInitCheck = initSize(w, h, reqFormat, reqUsage, bufferSize);
}
Ejemplo n.º 6
0
// ResidualVM specific method
Graphics::PixelBuffer OSystem_Android::setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d, bool isGame) {
	_opengl = accel3d;
	initViewport();

	_touchControls.init(this, _egl_surface_width, _egl_surface_height);

	if (_opengl) {
		// resize game texture
		initSize(screenW, screenH, 0);
		if (isGame)
			_game_texture->setGameTexture();
		// format is not used by the gfx_opengl driver, use fake format
		_game_pbuf.set(Graphics::PixelFormat(), 0);

	} else {
		Graphics::PixelFormat format = GLES565Texture::pixelFormat();
		initSize(screenW, screenH, &format);
		// as there is no support for the texture surface's lock/unlock mechanism in gfx_tinygl/...
		// do not use _game_texture->surface()->pixels directly
		_game_pbuf.create(_game_texture->getPixelFormat(),
				_game_texture->width() * _game_texture->height(), DisposeAfterUse::YES);
	}
	return _game_pbuf;
}
Ejemplo n.º 7
0
void Asteroid::init()
{
	mShouldDeleteBody = true;

	initSize();

	b2Vec2 position;
	//position.x = SCREEN_WIDTH / 2.0f;
	//position.y = SCREEN_HEIGHT / 2.0f;
	int xRand = rand() % 2, yRand = rand() % 2;
	xRand == 0 ? position.x = static_cast<float>(rand() % 150 - 300) : position.x = static_cast<float>(SCREEN_WIDTH + (rand() % 150 + 150));
	yRand == 0 ? position.y = static_cast<float>(rand() % 150 - 300) : position.y = static_cast<float>(SCREEN_HEIGHT + (rand() % 150 + 150));
	initPhysics(position);
	initSprite(rand() % 3);
}
status_t GraphicBuffer::reallocate(uint32_t w, uint32_t h, PixelFormat f,
        uint32_t reqUsage)
{
    if (mOwner != ownData)
        return INVALID_OPERATION;

    if (handle && w==width && h==height && f==format && reqUsage==usage)
        return NO_ERROR;

    if (handle) {
        GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
        allocator.free(handle);
        handle = 0;
    }
    return initSize(w, h, f, reqUsage);
}
Ejemplo n.º 9
0
bool BlockManager::init(int row, int col, GameLayer * layer)
{
	bool bRet = false;
	do 
	{
		_row = row;
		_col = col;
		_layer = layer;
		initSize();
		createBGImg();
		createBlock();

		bRet = true;
	} while (0);
	return bRet;
}
Ejemplo n.º 10
0
    ParserKeyword::ParserKeyword(const Json::JsonObject& jsonConfig) {

      if (jsonConfig.has_item("name")) {
            ParserKeywordSizeEnum sizeType = UNKNOWN;
            commonInit(jsonConfig.get_string("name"), sizeType);
        } else
            throw std::invalid_argument("Json object is missing the 'name' property");

        if (jsonConfig.has_item("deck_names") || jsonConfig.has_item("deck_name_regex") )
            // if either the deck names or the regular expression for deck names are
            // explicitly specified, we do not implicitly add the contents of the 'name'
            // item to the deck names...
            clearDeckNames();

        initSize(jsonConfig);
        initDeckNames(jsonConfig);
        initSectionNames(jsonConfig);
        initMatchRegex(jsonConfig);

        if (jsonConfig.has_item("items") && jsonConfig.has_item("records"))
            throw std::invalid_argument("Fatal error in " + getName() + " configuration. Can NOT have both records: and items:");

        if (jsonConfig.has_item("items")) {
            const Json::JsonObject itemsConfig = jsonConfig.get_item("items");
            addItems(itemsConfig);
        }

        if (jsonConfig.has_item("records")) {
            const Json::JsonObject recordsConfig = jsonConfig.get_item("records");
            if (recordsConfig.is_array()) {
                size_t num_records = recordsConfig.size();
                for (size_t i = 0; i < num_records; i++) {
                    const Json::JsonObject itemsConfig = recordsConfig.get_array_item(i);
                    addItems(itemsConfig);
                }
            } else
                throw std::invalid_argument("The records item must point to an array item");
        }

        if (jsonConfig.has_item("data"))
            initData(jsonConfig);

        if (jsonConfig.has_item("description")) {
            m_Description = jsonConfig.get_string("description");
        }

    }
Ejemplo n.º 11
0
void OSystem_SDL::endGFXTransaction(void) {
	// for each engine we run initCommonGFX() as first thing in the transaction
	// and initSize() is called later. If user runs launcher at 320x200 with
	// 2x overlay, setting to Nomral1x sclaler in that case will be suppressed
	// and backend is forced to 2x
	//
	// This leads to bad results such as 1280x960 window for 640x480 engines.
	// To prevent that we rerun setGraphicsMode() if there was 1x scaler request
	if (_transactionDetails.normal1xScaler)
		setGraphicsMode(GFX_NORMAL);

	assert (_transactionMode == kTransactionActive);

	_transactionMode = kTransactionCommit;
	if (_transactionDetails.modeChanged)
		setGraphicsMode(_transactionDetails.mode);

	if (_transactionDetails.sizeChanged)
		initSize(_transactionDetails.w, _transactionDetails.h);

	if (_transactionDetails.arChanged)
		setAspectRatioCorrection(_transactionDetails.ar);

	if (_transactionDetails.needUnload) {
		unloadGFXMode();
		loadGFXMode();
		clearOverlay();
	} else {
		if (!_transactionDetails.fsChanged) {
			if (_transactionDetails.needHotswap)
				hotswapGFXMode();
			else if (_transactionDetails.needUpdatescreen)
				internUpdateScreen();
		}
	}

	if (_transactionDetails.fsChanged)
		setFullscreenMode(_transactionDetails.fs);

	_transactionMode = kTransactionNone;
}
Ejemplo n.º 12
0
LLDBTooltip::LLDBTooltip(wxWindow* parent, LLDBPlugin* plugin)
    : LLDBTooltipBase(parent)
    , m_plugin(plugin)
    , m_dragging(false)
{
    int initialSizeW = clConfig::Get().Read(kConfigLLDBTooltipW, wxNOT_FOUND);
    int initialSizeH = clConfig::Get().Read(kConfigLLDBTooltipH, wxNOT_FOUND);

    if(initialSizeH != wxNOT_FOUND && initialSizeW != wxNOT_FOUND) {
        wxSize initSize(initialSizeW, initialSizeH);

        if(initSize.GetWidth() > 200 && initSize.GetHeight() > 150) {
            SetSize(initSize);

        } else {
            SetSize(wxSize(200, 150));
        }
    }

    m_plugin->GetLLDB()->Bind(wxEVT_LLDB_VARIABLE_EXPANDED, &LLDBTooltip::OnLLDBVariableExpanded, this);
    m_panelStatus->Bind(wxEVT_MOUSE_CAPTURE_LOST, &LLDBTooltip::OnCaptureLost, this);
}
Ejemplo n.º 13
0
void GraphicsManager::init() {
	Common::enforceMainThread();

	uint32 sdlInitFlags = SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK;

	// TODO: Is this actually needed on any systems? It seems to make MacOS X fail to
	//       receive any events, too.
/*
// Might be needed on unixoid OS, but it crashes Windows. Nice.
#ifndef WIN32
	sdlInitFlags |= SDL_INIT_EVENTTHREAD;
#endif
*/

	if (SDL_Init(sdlInitFlags) < 0)
		throw Common::Exception("Failed to initialize SDL: %s", SDL_GetError());

	int  width  = ConfigMan.getInt ("width"     , 800);
	int  height = ConfigMan.getInt ("height"    , 600);
	bool fs     = ConfigMan.getBool("fullscreen", false);

	initSize(width, height, fs);
	setupScene();

	// Try to change the FSAA settings to the config value
	if (_fsaa != ConfigMan.getInt("fsaa"))
		if (!setFSAA(ConfigMan.getInt("fsaa")))
			// If that fails, set the config to the current level
			ConfigMan.setInt("fsaa", _fsaa);

	// Set the gamma correction to what the config specifies
	if (ConfigMan.hasKey("gamma"))
		setGamma(ConfigMan.getDouble("gamma", 1.0));

	// Set the window title to our name
	setWindowTitle(PACKAGE_STRING);

	_ready = true;
}
Ejemplo n.º 14
0
void MainWindow::init() {
	Expects(!windowHandle());
	createWinId();

	initHook();
	updateWindowIcon();

	connect(windowHandle(), &QWindow::activeChanged, this, [this] { handleActiveChanged(); }, Qt::QueuedConnection);
	connect(windowHandle(), &QWindow::windowStateChanged, this, [this](Qt::WindowState state) { handleStateChanged(state); });

	_positionUpdatedTimer->setSingleShot(true);
	connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer()));

	updatePalette();

	if ((_title = Platform::CreateTitleWidget(this))) {
		_title->init();
	}

	initSize();
	updateUnreadCounter();
}
Ejemplo n.º 15
0
PrefsDialog::PrefsDialog( Window *frame, Window *parent ) :
  Dialog( frame, parent, Strings::get( 168 ),
          AWindow::CENTER | AWindow::ISMODAL | AWindow::ADJUSTSIZE,
          0, 0, 500, 365 )
{
  char *namestr = "PrefsDialog";
  name = new char[strlen(namestr)+1];
  strcpy( name, namestr );

  getGraphics()->setDialogFont();

  int margin = 10, fontHeight = Graphics::dialogDesignFontHeight,
      yStart = getClientHeight() - fontHeight*2 - 20,
      interSpace = fontHeight + fontHeight / 2;

  prevUseBigFont = AGraphics::useBigFont;

  Notebook *notebook =
	  new Notebook( this, 0, 50, getClientWidth(), getClientHeight() - 50, 
		              Color::BKGR, 0 );

	asciiDialog = new AsciiDialog( notebook, notebook );
	ascii2Dialog = new Ascii2Dialog( notebook, notebook );
	hexDialog = new HexDialog( notebook, notebook );
	editorDialog = new EditorDialog( notebook, notebook );
	displayDialog = new DisplayDialog( notebook, notebook );
	miscDialog = new MiscDialog( notebook, notebook );

	notebook->add( editorDialog, Strings::get(188) );
	notebook->add( displayDialog, Strings::get(190) );
	notebook->add( asciiDialog, Strings::get(166) );
	notebook->add( ascii2Dialog, Strings::get(209) );
	notebook->add( hexDialog, Strings::get(179) );
	notebook->add( miscDialog, Strings::get(196) );

  OKButton = new Button( this, Strings::get(8), AWindow::ISDEFAULT|ISTABSTOP,
                             10, 10, 70, 30 );
  OKButton->setYMove( FOLLOW );

  cancelButton = new Button( this, Strings::get(9), ISTABSTOP, 90, 10, 70, 30 );
  cancelButton->setYMove( FOLLOW );

	setControlsVisible();
  notebook->setTab( 0 );

  OKButton->addButtonListener( this );
  cancelButton->addButtonListener( this );

  adjustForFontSize();

  // Save/restore window position

  initSize();

  int x = getX(), y = getY(), width = getWidth(), height = getHeight();
  WinProperties::retrieveProperty( name, x, y, width, height );

  setSize( width, height );
  center( x, y );
  setPos( x, y );
}
Ejemplo n.º 16
0
KSplitTransactionDlg::KSplitTransactionDlg(const MyMoneyTransaction& t,
        const MyMoneySplit& s,
        const MyMoneyAccount& acc,
        const bool amountValid,
        const bool deposit,
        const MyMoneyMoney& calculatedValue,
        const QMap<QString, MyMoneyMoney>& priceInfo,
        QWidget* parent) :
    KSplitTransactionDlgDecl(parent),
    m_account(acc),
    m_split(s),
    m_precision(2),
    m_amountValid(amountValid),
    m_isDeposit(deposit),
    m_calculatedValue(calculatedValue)
{
    setModal(true);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    setLayout(mainLayout);
    mainLayout->addWidget(horizontalLayoutWidget);

    m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
    QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok);
    okButton->setDefault(true);
    okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
    QPushButton *user1Button = new QPushButton;
    m_buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
    QPushButton *user2Button = new QPushButton;
    m_buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
    QPushButton *user3Button = new QPushButton;
    m_buttonBox->addButton(user3Button, QDialogButtonBox::ActionRole);
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    m_buttonBox->setOrientation(Qt::Vertical);
    mainLayout->addWidget(m_buttonBox);

    //set custom buttons
    //clearAll button
    user1Button->setText(i18n("Clear &All"));
    user1Button->setToolTip(i18n("Clear all splits"));
    user1Button->setWhatsThis(i18n("Use this to clear all splits of this transaction"));
    user1Button->setIcon(QIcon::fromTheme("edit-clear"));

    //clearZero button
    user2Button->setText(i18n("Clear &Zero"));
    user2Button->setToolTip(i18n("Removes all splits that have a value of zero"));
    user2Button->setIcon(QIcon::fromTheme("edit-clear"));

    //merge button
    user3Button->setText(i18n("&Merge"));
    user3Button->setToolTip(i18n("Merges splits with the same category to one split"));
    user3Button->setWhatsThis(i18n("In case you have multiple split entries to the same category and you like to keep them as a single split"));

    // make finish the default
    m_buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true);

    // setup the focus
    m_buttonBox->button(QDialogButtonBox::Cancel)->setFocusPolicy(Qt::NoFocus);
    okButton->setFocusPolicy(Qt::NoFocus);
    user1Button->setFocusPolicy(Qt::NoFocus);

    // connect signals with slots
    connect(transactionsTable, SIGNAL(transactionChanged(MyMoneyTransaction)),
            this, SLOT(slotSetTransaction(MyMoneyTransaction)));
    connect(transactionsTable, SIGNAL(createCategory(QString,QString&)), this, SLOT(slotCreateCategory(QString,QString&)));
    connect(transactionsTable, SIGNAL(objectCreation(bool)), this, SIGNAL(objectCreation(bool)));

    connect(transactionsTable, SIGNAL(returnPressed()), this, SLOT(accept()));
    connect(transactionsTable, SIGNAL(escapePressed()), this, SLOT(reject()));
    connect(transactionsTable, SIGNAL(editStarted()), this, SLOT(slotEditStarted()));
    connect(transactionsTable, SIGNAL(editFinished()), this, SLOT(slotUpdateButtons()));

    connect(m_buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
    connect(m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
    connect(user1Button, SIGNAL(clicked()), this, SLOT(slotClearAllSplits()));
    connect(user3Button, SIGNAL(clicked()), this, SLOT(slotMergeSplits()));
    connect(user2Button, SIGNAL(clicked()), this, SLOT(slotClearUnusedSplits()));

    // setup the precision
    try {
        MyMoneySecurity currency = MyMoneyFile::instance()->currency(t.commodity());
        m_precision = MyMoneyMoney::denomToPrec(m_account.fraction(currency));
    } catch (const MyMoneyException &) {
    }

    slotSetTransaction(t);

    // pass on those vars
    transactionsTable->setup(priceInfo, m_precision);

    QSize size(width(), height());
    KConfigGroup grp = KSharedConfig::openConfig()->group("SplitTransactionEditor");
    size = grp.readEntry("Geometry", size);
    size.setHeight(size.height() - 1);
    QDialog::resize(size.expandedTo(minimumSizeHint()));

    // Trick: it seems, that the initial sizing of the dialog does
    // not work correctly. At least, the columns do not get displayed
    // correct. Reason: the return value of transactionsTable->visibleWidth()
    // is incorrect. If the widget is visible, resizing works correctly.
    // So, we let the dialog show up and resize it then. It's not really
    // clean, but the only way I got the damned thing working.
    QTimer::singleShot(10, this, SLOT(initSize()));
}