IntSize SVGImage::size() const { IntSize defaultSize(300, 150); // FIXME: Eventually we'll be passed in the dest size and can scale against that IntSize destSize = defaultSize; if (!m_frame || !m_frame->document()) return IntSize(); SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); if (!rootElement) return defaultSize; SVGLength width = rootElement->width(); SVGLength height = rootElement->height(); IntSize svgSize; if (width.unitType() == LengthTypePercentage) svgSize.setWidth(static_cast<int>(width.valueInSpecifiedUnits() * destSize.width())); else svgSize.setWidth(static_cast<int>(width.value())); if (height.unitType() == LengthTypePercentage) svgSize.setHeight(static_cast<int>(height.valueInSpecifiedUnits() * destSize.height())); else svgSize.setHeight(static_cast<int>(height.value())); return svgSize; }
AddresseeEditorDialog::AddresseeEditorDialog( KAB::Core *core, QWidget *parent, const char *name ) : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, KDialogBase::Ok, parent, name, false ) { // Set this to be the group leader for all subdialogs - this means // modal subdialogs will only affect this dialog, not the other windows setWFlags( getWFlags() | WGroupLeader ); kdDebug(5720) << "AddresseeEditorDialog()" << endl; QWidget *page = plainPage(); QVBoxLayout *layout = new QVBoxLayout( page ); if ( KABPrefs::instance()->editorType() == KABPrefs::SimpleEditor ) { mEditorWidget = new SimpleAddresseeEditor( page ); } else { mEditorWidget = new AddresseeEditorWidget( page ); } connect( mEditorWidget, SIGNAL( modified() ), SLOT( widgetModified() ) ); layout->addWidget( mEditorWidget ); enableButton( KDialogBase::Apply, false ); KConfig config( "kaddressbookrc" ); config.setGroup( "AddresseeEditor" ); QSize defaultSize( 750, 570 ); resize( config.readSizeEntry( "Size", &defaultSize ) ); }
void QwtGraphic::render( QPainter *painter, const QPointF &pos, Qt::Alignment alignment ) const { QRectF r( pos, defaultSize() ); if ( alignment & Qt::AlignLeft ) { r.moveLeft( pos.x() ); } else if ( alignment & Qt::AlignHCenter ) { r.moveCenter( QPointF( pos.x(), r.center().y() ) ); } else if ( alignment & Qt::AlignRight ) { r.moveRight( pos.x() ); } if ( alignment & Qt::AlignTop ) { r.moveTop( pos.y() ); } else if ( alignment & Qt::AlignVCenter ) { r.moveCenter( QPointF( r.center().x(), pos.y() ) ); } else if ( alignment & Qt::AlignBottom ) { r.moveBottom( pos.y() ); } render( painter, r ); }
TeamBuilder::TeamBuilder(ClientPluginManager *p, TeamHolder *team, bool load) : m_team(team), teamMenu(nullptr) { // QStringList undone; // for (int i = 1;i <= 718; i++) { // if (!PokemonInfo::Exists(i, 6)) // undone.push_back(PokemonInfo::Name(i)); // } ui = new _ui(); ui->stack = new QStackedWidget(); setCentralWidget(ui->stack); setDockNestingEnabled(true); setWindowFlags(Qt::Widget); setWindowTitle(tr("Teambuilder")); ui->stack->addWidget(trainer = new TrainerMenu(team)); trainer->setMainWindow(this); pokemonModel = new PokeTableModel(team->team().gen(), this); if (load) { loadSettings(this, defaultSize()); } connect(trainer, SIGNAL(teamChanged()), SLOT(markTeamUpdated())); connect(trainer, SIGNAL(done()), SIGNAL(done())); connect(trainer, SIGNAL(openBoxes()), SLOT(openBoxes())); connect(trainer, SIGNAL(editPoke(int)), SLOT(editPoke(int))); p->launchTeambuilder(this); pluginManager = p; }
/** Read config settings */ void KControlAddEdit::configRead() { KConfig *config = KGlobal::config(); config->setGroup("AddModify Window"); QSize defaultSize(500,400); resize( config->readSizeEntry("Geometry", &defaultSize ) ); }
void PMSettingsDialog::restoreConfig( KConfig* cfg ) { cfg->setGroup( "Appearance" ); QSize defaultSize( 640, 400 ); s_size = cfg->readSizeEntry( "SettingsDialogSize", &defaultSize ); }
QSize HelpWindowWidget::sizeHint() const { // Suggest a default size for the help widget // Note: this is critical if we want a docked widget, with a help widget on // it, to have a decent size when docked to the main window... return defaultSize(0.2); }
QPageSize::PageSizeId KReportPageSize::pageSize(const QString &size) { for (int i = 0; pageSizeInfo[i].pageSize != QPageSize::LastPageSize ;i++) { if (QLatin1String(pageSizeInfo[i].name) == size) { return pageSizeInfo[i].pageSize; } } return defaultSize(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), canvasWidget(new CanvasWidget(this)), gameIsPaused(true), thereIsAnotherDialog(false) { Item::setCanvas(canvasWidget); new Background; // the background put's itself into the canvasWidget gameEngine = new GameEngine(this); // must be called after Item::setCanvas() #if defined ANDROID setAttribute(Qt::WA_AcceptTouchEvents); #endif connect(canvasWidget, SIGNAL(mouseMoved(int)), gameEngine, SLOT(moveBar(int))); connect(canvasWidget, SIGNAL(barMovedLeft()), gameEngine, SLOT(moveBarLeft())); connect(canvasWidget, SIGNAL(barMovedRight()), gameEngine, SLOT(moveBarRight())); connect(canvasWidget, SIGNAL(focusLost()), this, SLOT(pauseGame())); connect(gameEngine, SIGNAL(gamePaused()), canvasWidget, SLOT(handleGamePaused())); connect(gameEngine, SIGNAL(gameResumed()), canvasWidget, SLOT(handleGameResumed())); connect(gameEngine, SIGNAL(gameResumed()), this, SLOT(handleGameResumed())); connect(gameEngine, SIGNAL(resetMousePosition()), canvasWidget, SLOT(handleResetMousePosition())); connect(gameEngine, SIGNAL(gameEnded(int,int,int)), SLOT(handleEndedGame(int,int,int))); // cheating keys, debugging and testing only TODO: REMOVE connect(canvasWidget, SIGNAL(cheatSkipLevel()), gameEngine, SLOT(cheatSkipLevel())); connect(canvasWidget, SIGNAL(cheatAddLife()), gameEngine, SLOT(cheatAddLife())); connect(gameEngine, SIGNAL(levelChanged()), this, SLOT(handleLevelChanged())); connect(Settings::self(), SIGNAL(themeChanged()), canvasWidget, SLOT(reloadSprites())); setCentralWidget(canvasWidget); setupActions(); setFocusProxy(canvasWidget); QSize defaultSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // show here (instead of in main) else the mouse can't be grabbed show(); gameEngine->start(Settings::self()->getLevelset()); }
/** Read settings */ void KEducaPrefs::configRead() { KConfig *config = KGlobal::config(); config->setGroup("Options"); QSize defaultSize(500,400); resize( config->readSizeEntry("Geometry", &defaultSize ) ); config->readBoolEntry("ResultFinish", true ) ? _resultAfterFinish->setChecked(true) : _resultAfterNext->setChecked(true); config->readBoolEntry("RandomQuestions", false ) ? _randomQuestions->setChecked(true) : _randomQuestions->setChecked(false); config->readBoolEntry("RandomAnswers", false ) ? _randomAnswers->setChecked(true) : _randomAnswers->setChecked(false); }
void TulipViewSettings::setDefaultSize(ElementType elem, const Size& size) { if (size == defaultSize(elem)) return; if (elem == NODE) { _defaultNodeSize = size; } else { _defaultEdgeSize = size; } sendEvent(ViewSettingsEvent(elem, size)); }
LayoutSize RenderVideo::calculateIntrinsicSize() { HTMLVideoElement* video = videoElement(); // Spec text from 4.8.6 // // The intrinsic width of a video element's playback area is the intrinsic width // of the video resource, if that is available; otherwise it is the intrinsic // width of the poster frame, if that is available; otherwise it is 300 CSS pixels. // // The intrinsic height of a video element's playback area is the intrinsic height // of the video resource, if that is available; otherwise it is the intrinsic // height of the poster frame, if that is available; otherwise it is 150 CSS pixels. MediaPlayer* player = mediaElement()->player(); if (player && video->readyState() >= HTMLVideoElement::HAVE_METADATA) { LayoutSize size = player->naturalSize(); if (!size.isEmpty()) return size; } if (video->shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && !imageResource()->errorOccurred()) return m_cachedImageSize; // When the natural size of the video is unavailable, we use the provided // width and height attributes of the video element as the intrinsic size until // better values become available. if (video->hasAttribute(widthAttr) && video->hasAttribute(heightAttr)) return LayoutSize(video->width(), video->height()); // <video> in standalone media documents should not use the default 300x150 // size since they also have audio-only files. By setting the intrinsic // size to 300x1 the video will resize itself in these cases, and audio will // have the correct height (it needs to be > 0 for controls to render properly). if (video->ownerDocument() && video->ownerDocument()->isMediaDocument()) return LayoutSize(defaultSize().width(), 1); return defaultSize(); }
void Camera::zoom(float factor) { sf::Vector2f defaultSize(400.f, 400.f); // Window size sf::Vector2f size = getSize(); m_zoom += factor; size.x += defaultSize.x * factor; size.y += defaultSize.y * factor; // TODO: setar centro de acordo com a proporcao do zoom, de modo que o centro permaneca no mesmo lugar // TODO: limitar zoom setSize(size); }
void loop() { // clears the screen and select font size and style char instr1[] = { clearScreen(), defaultSize(), selectSize(), // tall selectSize(), // wide selectSize(), // big textStyle(), NULL }; const char message[] = "Hi GLO!"; Serial1.print(instr1); // print message according to prior instructions Serial1.print(message); }
void ChatDlg::init() { initUi(); initActions(); setShortcuts(); // TODO: this have to be moved to chatEditCreated() chatView()->setDialog(this); chatEdit()->setDialog(this); chatEdit()->installEventFilter(this); connect(chatView(), SIGNAL(selectionChanged()), SLOT(logSelectionChanged())); // SyntaxHighlighters modify the QTextEdit in a QTimer::singleShot(0, ...) call // so we need to install our hooks after it fired for the first time QTimer::singleShot(10, this, SLOT(initComposing())); connect(this, SIGNAL(composing(bool)), SLOT(updateIsComposing(bool))); setAcceptDrops(TRUE); updateContact(jid(), true); X11WM_CLASS("chat"); setLooks(); updatePGP(); connect(account(), SIGNAL(pgpKeyChanged()), SLOT(updatePGP())); connect(account(), SIGNAL(encryptedMessageSent(int, bool, int, const QString &)), SLOT(encryptedMessageSent(int, bool, int, const QString &))); account()->dialogRegister(this, jid()); chatView()->setFocusPolicy(Qt::NoFocus); chatEdit()->setFocus(); // TODO: port to restoreSavedSize() (and adapt it from restoreSavedGeometry()) QSize size = PsiOptions::instance()->getOption("options.ui.chat.size").toSize(); if (!size.isEmpty()) { resize(size); } else { resize(defaultSize()); } }
reportView::reportView(const QString &reportLocation) : KDialogBase( (QWidget *)0, "report", false, QString::null, Close ), m_locationCode(reportLocation) { QVBox *vbox = makeVBoxMainWidget(); m_reportView = new KHTMLPart(vbox, "m_reportView"); KConfig config( "weather_panelappletrc" ); config.setGroup( "General Options" ); QSize defaultSize( 450, 325 ); resize( config.readSizeEntry( "reportview_size", &defaultSize ) ); centerOnScreen( this ); m_weatherService = new WeatherService_stub( "KWeatherService", "WeatherService" ); QPixmap icon = m_weatherService->icon( m_locationCode ); setIcon( icon ); render(); }
/*! \brief Convert the graphic to a QPixmap All pixels of the pixmap get initialized by Qt::transparent before the graphic is scaled and rendered on it. The size of the pixmap is the default size ( ceiled to integers ) of the graphic. \sa defaultSize(), toImage(), render() */ QPixmap QwtGraphic::toPixmap() const { if ( isNull() ) return QPixmap(); const QSizeF sz = defaultSize(); const int w = qCeil( sz.width() ); const int h = qCeil( sz.height() ); QPixmap pixmap( w, h ); pixmap.fill( Qt::transparent ); const QRectF r( 0.0, 0.0, sz.width(), sz.height() ); QPainter painter( &pixmap ); render( &painter, r, Qt::KeepAspectRatio ); painter.end(); return pixmap; }
/*! \brief Convert the graphic to a QImage All pixels of the image get initialized by 0 ( transparent ) before the graphic is scaled and rendered on it. The format of the image is QImage::Format_ARGB32_Premultiplied. The size of the image is the default size ( ceiled to integers ) of the graphic. \sa defaultSize(), toPixmap(), render() */ QImage QwtGraphic::toImage() const { if ( isNull() ) return QImage(); const QSizeF sz = defaultSize(); const int w = qCeil( sz.width() ); const int h = qCeil( sz.height() ); QImage image( w, h, QImage::Format_ARGB32 ); image.fill( 0 ); const QRect r( 0, 0, sz.width(), sz.height() ); QPainter painter( &image ); render( &painter, r, Qt::KeepAspectRatio ); painter.end(); return image; }
//! \return Ceiled defaultSize() QSize QwtGraphic::sizeMetrics() const { const QSizeF sz = defaultSize(); return QSize( qCeil( sz.width() ), qCeil( sz.height() ) ); }
void MainWindow::loadSettings() { mainLog.Log("Loading settings..."); QSettings settings; if(settings.allKeys().size() == 0) { mainLog.Log("Settings is empty. Default values will be used."); } else mainLog.Log("Loading settings from %s.", settings.fileName().toLocal8Bit().data()); QPoint defaultPosition; QSize defaultSize(800,600); if(!settings.contains("MainWindow/size") || !settings.contains("MainWindow/pos")) { int frameWidth = 0; int frameTop = 0; int frameBottom = 0; bool screenHack = true; //If we want to get frame geometry (which is apparently a pain in qt). if(screenHack) { //The following from a post on stackoverflow by TonyK // BIG PAIN: We want to get the dialog box to caluclate its own size. But there is // no simple way to do this. The following seems to work, but only if processEvents // is called at least twice. God knows why: setAttribute (Qt::WA_DontShowOnScreen, true) ; // Prevent screen flicker show() ; QEventLoop EventLoop (this) ; for (int i = 0 ; i < 10 ; i++) if (!EventLoop.processEvents()) break ; hide() ; setAttribute (Qt::WA_DontShowOnScreen, false) ; //End code section from TonyK frameWidth = frameGeometry().width()-geometry().width(); frameTop = abs(geometry().top()-frameGeometry().top()); frameBottom = abs(frameGeometry().bottom()-geometry().bottom()); } //Ensure sane positioning for first run (i.e. not split across multiple monitors QDesktopWidget* desk = QApplication::desktop(); int usedScreen = 0; const QRect available = desk->availableGeometry(usedScreen); if((available.x()+available.width())/2 >= defaultSize.width()/2+frameWidth/2) { defaultPosition.setX((available.x()+available.width())/2-(defaultSize.width()/2+frameWidth/2)); } else { defaultPosition.setX(available.x()); defaultSize.setWidth(available.width()-frameWidth); } if((available.y()+available.height())/2 >= defaultSize.height()/2 + (frameTop+frameBottom)/2) { defaultPosition.setY((available.y()+available.height())/2-defaultSize.height()/2); } else { defaultPosition.setY(available.y()); defaultSize.setHeight(available.height()-(frameTop+frameBottom)); } mainLog.Log("Positioning window at (%d, %d) with size (%d, %d) on screen %d/%d",defaultPosition.x(),defaultPosition.y(),defaultSize.width(),defaultSize.height(),usedScreen,desk->screenCount()); } mainLog.setLogPriority(settings.value("LoggingLevels/mainLog",DEFAULT_PRIORITY).toInt()); levelLog.setLogPriority(settings.value("LoggingLevels/levelLog",DEFAULT_PRIORITY).toInt()); int levelPriorities[NUMBER_OF_BLOCKS]; levelPriorities[BLOCK_TEXTURES] = settings.value("LoggingLevels/blockTextures",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_MODELS] = settings.value("LoggingLevels/blockModels",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_WORLD] = settings.value("LoggingLevels/blockWorld",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_RANDOM_MODEL_PLACEMENT] = settings.value("LoggingLevels/blockRandomModelPlacement",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_TEXTURE_DEFINITIONS] = settings.value("LoggingLevels/blockTextureDefinitions",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_ROAD_TABLE] = settings.value("LoggingLevels/blockRoadTable",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_ROAD_CONNECTIONS] = settings.value("LoggingLevels/blockRoadConnections",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_INTERSECTIONS] = settings.value("LoggingLevels/blockIntersections",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_HEIGHTMAP_TILES] = settings.value("LoggingLevels/blockHeightmapTiles",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_HEIGHTMAP] = settings.value("LoggingLevels/blockHeightmap",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_MODEL_NAMES] = settings.value("LoggingLevels/blockModelNames",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_EVENT_MODELS] = settings.value("LoggingLevels/blockEventModels",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_VISIBILITY] = settings.value("LoggingLevels/blockVisibility",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_SECTOR_TEXTURE_USAGE] = settings.value("LoggingLevels/blockSectorTextureUsage",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_ROAD_SECTIONS] = settings.value("LoggingLevels/blockRoadSections",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_INTERSECTION_POSITIONS] = settings.value("LoggingLevels/blockIntersectionPositions",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_LAMPS] = settings.value("LoggingLevels/blockLamps",levelLog.getLogPriority()).toInt(); levelPriorities[BLOCK_CHAIR_PLACEMENT] = settings.value("LoggingLevels/blockChairPlacement",levelLog.getLogPriority()).toInt(); level.setLogPriorities(levelPriorities); resize(settings.value("MainWindow/size",defaultSize).toSize()); move(settings.value("MainWindow/pos", defaultPosition).toPoint()); if(settings.value("MainWindow/maximized",false).toBool()) showMaximized(); else showNormal(); show(); customLevelDialog->setLastDirectory(settings.value("directories/lastOpenFileDir","C:\\Program Files\\GT Interactive\\Driver\\Levels").toString()); if(settings.value("firstRun",true).toBool()) { int ret = QMessageBox::No; QMessageBox msgBox(centralWindow); msgBox.setText(tr("<b>It looks like this is the first run.</b>")); msgBox.setInformativeText(tr("It is recommended that you set the default Driver directory. Would you like to do this now? The directory can be changed later in the settings menu. ")+rootDir); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); ret = msgBox.exec(); if(ret == QMessageBox::Yes) { QString newRootDir = QFileDialog::getExistingDirectory(centralWindow,tr("Choose the root Driver directory."),"C:\\Program Files\\GT Interactive\\Driver"); if(!newRootDir.isEmpty()) { settings.setValue("directories/rootDir",newRootDir); } } } rootDir = QDir::toNativeSeparators(settings.value("directories/rootDir").toString()); if(!rootDir.isEmpty()) setConvenienceActionsEnabled(true); textureBrowser->loadSettings(); modelViewPanel->loadSettings(); mainLog.Log("Finished loading settings."); };
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), server(NULL), clearTimer(NULL), scControls(NULL), scAbout(NULL), scLayout(NULL), scExit(NULL), scPreferences(NULL) { ui->setupUi(this); // Get user folder and create app folder this->userFolder = QDir::homePath() + "/.maurina/"; QDir dir; if (!dir.exists(this->userFolder)) dir.mkdir(this->userFolder); // Set default values this->serverIp = QHostAddress::LocalHost; this->serverPort = 1947; // Maurina's year of birth this->timeoutEnabled = true; this->timeoutValue = 2; this->logCount.resize(5); this->tabCaptions << "Log 1" << "Log 2" << "Log 3" << "Log4" << "Log5"; this->controlsVisible = true; this->layoutType = DetailedLayout; // Set default styles QString defaultSize("font-size : 12px;"); QString defaultFont("font-family : monospace;"); #ifdef Q_OS_WIN32 defaultFont = "font-family : Consolas;"; #endif #ifdef Q_OS_MAC defaultFont = "font-family : Monaco;"; #endif #ifdef Q_OS_LINUX defaultFont = "font-family : \"Liberation Mono\";"; #endif this->styles["time"] = defaultFont + " color : #aaaaaa; " + defaultSize; this->styles["pre"] = defaultFont + " color : #000000; " + defaultSize; this->styles["var"] = defaultFont + " color : #000000; " + defaultSize; this->styles["h1"] = defaultFont + " color : #b50000; " + defaultSize; this->styles["h2"] = defaultFont + " color : #009C39; " + defaultSize; this->styles["h3"] = defaultFont + " color : #000000; " + defaultSize; this->styles["h4"] = defaultFont + " color : #000000; " + defaultSize; this->styles["h5"] = defaultFont + " color : #000000; " + defaultSize; this->styles["h6"] = defaultFont + " color : #000000; " + defaultSize; // Load config this->loadConfig(); // Set up UI ui->uiTimeoutEnabled->setChecked(this->timeoutEnabled); ui->uiTimeoutValue->setValue(this->timeoutValue); QString title = "Maurina v."; title += VERSION; this->setWindowTitle(title); ui->actionE_xit->setShortcut(QKeySequence::Quit); ui->action_About->setShortcut(QKeySequence::HelpContents); ui->action_Preferences->setShortcut(QKeySequence(tr("Ctrl+P"))); ui->action_HideCntrls->setShortcut(QKeySequence(tr("Ctrl+H"))); ui->actionChangeLayout->setShortcut(QKeySequence(tr("Ctrl+L"))); ui->frameCompactLayoutTop->hide(); ui->frameCompactLayoutBottom->hide(); ui->tabWidgetA->tabBar()->hide(); ui->tabWidgetB->tabBar()->hide(); ui->tabWidgetC->tabBar()->hide(); ui->tabWidgetD->tabBar()->hide(); ui->tabWidgetE->tabBar()->hide(); // UI connections connect(ui->uiTimeoutEnabled, SIGNAL(stateChanged(int)), this, SLOT(slTimeoutChanged(int))); connect(ui->uiTimeoutValue, SIGNAL(valueChanged(int)), this, SLOT(slTimeoutChanged(int))); connect(ui->uiClearNow, SIGNAL(clicked()), this, SLOT(slClearLogs())); connect(ui->actionE_xit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->action_About, SIGNAL(triggered()), this, SLOT(slShowAbout())); connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(slShowPreferences())); connect(ui->action_HideCntrls, SIGNAL(triggered()), this, SLOT(slToggleControls())); connect(ui->actionChangeLayout, SIGNAL(triggered()), this, SLOT(slChangeLayout())); this->updateControls(); this->updateLayout(); // Start server this->startServer(); }