PreferencesDialog::PreferencesDialog(QWidget *parent) : ConfigDialog(parent, "PreferencesDialog") { iCount++; server = new ServerSettings(0); playback = new PlaybackSettings(0); files = new FileSettings(0); interface = new InterfaceSettings(0); context = new ContextSettings(0); cache = new CacheSettings(0); scrobbling = new ScrobblingSettings(0); server->load(); playback->load(); files->load(); interface->load(); context->load(); scrobbling->load(); addPage(QLatin1String("collection"), server, i18n("Collection"), Icons::self()->audioFileIcon, i18n("Collection Settings")); addPage(QLatin1String("playback"), playback, i18n("Playback"), Icon("media-playback-start"), i18n("Playback Settings")); addPage(QLatin1String("files"), files, i18n("Files"), Icons::self()->filesIcon, i18n("File Settings")); addPage(QLatin1String("interface"), interface, i18n("Interface"), Icon("preferences-other"), i18n("Interface Settings")); #ifdef ENABLE_STREAMS streams = new StreamsSettings(0); addPage(QLatin1String("streams"), streams, i18n("Streams"), Icons::self()->radioStreamIcon, i18n("Streams Settings")); streams->load(); #endif #ifdef ENABLE_ONLINE_SERVICES online = new OnlineSettings(0); addPage(QLatin1String("online"), online, i18n("Online"), Icon("applications-internet"), i18n("Online Providers")); online->load(); #endif addPage(QLatin1String("context"), context, i18n("Context"), Icons::self()->contextIcon, i18n("Context View Settings")); addPage(QLatin1String("scrobbling"), scrobbling, i18n("Scrobbling"), Icons::self()->lastFmIcon, i18n("Scrobbling Settings")); #ifdef ENABLE_HTTP_SERVER http = new HttpServerSettings(0); if (http->haveMultipleInterfaces()) { http->load(); Icon icon("network-server"); if (icon.isNull()) { icon=Icons::self()->streamIcon; } addPage(QLatin1String("http"), http, i18n("HTTP Server"), icon, i18n("HTTP Server Settings")); } else { http->deleteLater(); http=0; } #endif #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND audiocd = new AudioCdSettings(0); audiocd->load(); addPage(QLatin1String("cd"), audiocd, i18n("Audio CD"), Icon("media-optical"), i18n("Audio CD Settings")); #endif #ifdef ENABLE_PROXY_CONFIG proxy = new ProxySettings(0); proxy->load(); addPage(QLatin1String("proxy"), proxy, i18n("Proxy"), Icon("preferences-system-network"), i18nc("Qt-only", "Proxy Settings")); #endif #ifndef ENABLE_KDE_SUPPORT shortcuts = new ShortcutsSettingsPage(0); addPage(QLatin1String("shortcuts"), shortcuts, i18nc("Qt-only", "Shortcuts"), Icons::self()->shortcutsIcon, i18nc("Qt-only", "Keyboard Shortcut Settings")); shortcuts->load(); #endif addPage(QLatin1String("cache"), cache, i18n("Cache"), Icons::self()->folderIcon, i18n("Cached Items")); #ifdef Q_OS_MAC setCaption(i18n("Cantata Preferences")); #else setCaption(i18n("Configure")); #endif setAttribute(Qt::WA_DeleteOnClose); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setCurrentPage(QLatin1String("collection")); }
QPixmap KFileItemListView::createDragPixmap(const QSet<int>& indexes) const { if (!model()) { return QPixmap(); } const int itemCount = indexes.count(); Q_ASSERT(itemCount > 0); if (itemCount == 1) { return KItemListView::createDragPixmap(indexes); } // If more than one item is dragged, align the items inside a // rectangular grid. The maximum grid size is limited to 5 x 5 items. int xCount; int size; if (itemCount > 16) { xCount = 5; size = KIconLoader::SizeSmall; } else if (itemCount > 9) { xCount = 4; size = KIconLoader::SizeSmallMedium; } else { xCount = 3; size = KIconLoader::SizeMedium; } if (itemCount < xCount) { xCount = itemCount; } int yCount = itemCount / xCount; if (itemCount % xCount != 0) { ++yCount; } if (yCount > xCount) { yCount = xCount; } // Draw the selected items into the grid cells. QPixmap dragPixmap(xCount * size + xCount, yCount * size + yCount); dragPixmap.fill(Qt::transparent); QPainter painter(&dragPixmap); int x = 0; int y = 0; QSetIterator<int> it(indexes); while (it.hasNext()) { const int index = it.next(); QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>(); if (pixmap.isNull()) { KIcon icon(model()->data(index).value("iconName").toString()); pixmap = icon.pixmap(size, size); } else { KPixmapModifier::scale(pixmap, QSize(size, size)); } painter.drawPixmap(x, y, pixmap); x += size + 1; if (x >= dragPixmap.width()) { x = 0; y += size + 1; } if (y >= dragPixmap.height()) { break; } } return dragPixmap; }
bool EV_QtToolbar::synthesize(void) { // create a Qt toolbar from the info provided. const EV_Toolbar_ActionSet * pToolbarActionSet = m_pQtApp->getToolbarActionSet(); UT_ASSERT(pToolbarActionSet); XAP_Toolbar_ControlFactory * pFactory = m_pQtApp->getControlFactory(); UT_ASSERT(pFactory); UT_uint32 nrLabelItemsInLayout = m_pToolbarLayout->getLayoutItemCount(); UT_ASSERT(nrLabelItemsInLayout > 0); m_wToolbar = new QToolBar(); UT_ASSERT(m_wToolbar); Qt::ToolButtonStyle style = getStyle(); m_wToolbar->setToolButtonStyle(style); for (UT_uint32 k=0; (k < nrLabelItemsInLayout); k++) { EV_Toolbar_LayoutItem * pLayoutItem = m_pToolbarLayout->getLayoutItem(k); UT_continue_if_fail(pLayoutItem); XAP_Toolbar_Id id = pLayoutItem->getToolbarId(); EV_Toolbar_Action * pAction = pToolbarActionSet->getAction(id); UT_ASSERT(pAction); EV_Toolbar_Label * pLabel = m_pToolbarLabelSet->getLabel(id); UT_ASSERT(pLabel); const char * szToolTip = pLabel->getToolTip(); if (!szToolTip || !*szToolTip) szToolTip = pLabel->getStatusMsg(); switch (pLayoutItem->getToolbarLayoutFlags()) { case EV_TLF_Normal: { switch (pAction->getItemType()) { case EV_TBIT_PushButton: { UT_ASSERT(g_ascii_strcasecmp(pLabel->getIconName(),"NoIcon")!=0); if(pAction->getToolbarId() != AP_TOOLBAR_ID_INSERT_TABLE) { const char *icon_name = pLabel->getIconName(); QPixmap pixmap; pixmap = abi_pixmap_from_toolbar_id (icon_name); if(!pixmap.isNull()) { QIcon icon(pixmap); QString str = ""; QPushButton *item = new QPushButton(icon, str); m_wToolbar->addWidget(item); } } else { const char *icon_name = pLabel->getIconName(); QPixmap pixmap; pixmap = abi_pixmap_from_toolbar_id (icon_name); if(!pixmap.isNull()) { QIcon icon(pixmap); QString str = ""; QPushButton *item = new QPushButton(icon, str); m_wToolbar->addWidget(item); } } break; } case EV_TBIT_ToggleButton: case EV_TBIT_GroupButton: { UT_ASSERT(g_ascii_strcasecmp(pLabel->getIconName(),"NoIcon")!=0); const char *icon_name = pLabel->getIconName(); QPixmap pixmap; pixmap = abi_pixmap_from_toolbar_id (icon_name); if(!pixmap.isNull()) { QIcon icon(pixmap); QString str = ""; QPushButton *item = new QPushButton(icon, str); item->setCheckable(true); m_wToolbar->addWidget(item); } break; } case EV_TBIT_EditText: { break; } case EV_TBIT_DropDown: { break; } case EV_TBIT_ComboBox: { EV_Toolbar_Control * pControl = pFactory->getControl(this, id); UT_ASSERT(pControl); QComboBox *combo; bool isFontCombo = false; if(id == AP_TOOLBAR_ID_FMT_SIZE) { combo = new QComboBox(); } else if(id == AP_TOOLBAR_ID_FMT_FONT) { isFontCombo = true; combo = new QFontComboBox(); QString str = "AbiFontCombo"; combo->setAccessibleName(str); } else if(id == AP_TOOLBAR_ID_ZOOM) { combo = new QComboBox(); QString str = "AbiZoomCombo"; combo->setAccessibleName(str); } else if(id == AP_TOOLBAR_ID_FMT_STYLE) { combo = new QComboBox(); QString str = "AbiStyleCombo"; combo->setAccessibleName(str); } else { UT_ASSERT(0); } // populate it if (pControl) { pControl->populate(); const UT_GenericVector<const char*> * v = pControl->getContents(); UT_ASSERT(v); gint items = v->getItemCount(); if (isFontCombo) { for (gint m=0; m < items; m++) { QString str = v->getNthItem(m); combo->addItem(str); } } else { for (gint m=0; m < items; m++) { const char * sz = v->getNthItem(m); std::string sLoc; if (id == AP_TOOLBAR_ID_FMT_STYLE) { pt_PieceTable::s_getLocalisedStyleName(sz, sLoc); sz = sLoc.c_str(); } QString str = sz; combo->addItem(str); } } } m_wToolbar->addWidget(combo); // for now, we never repopulate, so can just toss it DELETEP(pControl); break; } case EV_TBIT_ColorFore: case EV_TBIT_ColorBack: { UT_ASSERT (g_ascii_strcasecmp(pLabel->getIconName(),"NoIcon") != 0); QComboBox *combo; if (pAction->getItemType() == EV_TBIT_ColorFore) { // TODO Some icon implementation const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet(); std::string sClear; pSS->getValueUTF8(XAP_STRING_ID_TB_ClearForeground,sClear); combo = new QComboBox(); QString str = sClear.c_str(); combo->setAccessibleName(str); } else { // TODO Some icon implementation const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet(); std::string sClear; pSS->getValueUTF8(XAP_STRING_ID_TB_ClearForeground,sClear); combo = new QComboBox(); QString str = sClear.c_str(); combo->setAccessibleName(str); } m_wToolbar->addWidget(combo); break; } case EV_TBIT_StaticLabel: { // TODO do these... break; } case EV_TBIT_Spacer: { break; } #ifdef ENABLE_MENUBUTTON case EV_TBIT_MenuButton: { break; } #endif case EV_TBIT_BOGUS: default: { break; } } break; } case EV_TLF_Spacer: { m_wToolbar->addSeparator(); break; } default: { UT_ASSERT(0); } } } QMainWindow * wTopLevel = static_cast<XAP_QtFrameImpl *>(m_pFrame->getFrameImpl())->getTopLevel(); wTopLevel->addToolBar(m_wToolbar); wTopLevel->show(); return true; }
//-------------------------------------------------------------------------------------- //! //-------------------------------------------------------------------------------------- void tWorkProfilesDialog::UpdateTable() { int currentRow = m_pProfilesTable->currentRow(); // clear all rows while ( m_pProfilesTable->rowCount() > 0 ) { // Remove and destroy the first row for ( int column = 0; column < eColumnCount; ++column ) { QTableWidgetItem* pItemToDelete = m_pProfilesTable->item( 0, column ); delete pItemToDelete; } m_pProfilesTable->removeRow( 0 ); } int row = 0; for ( int i = 0; i < tPilotMedusaInterface::cNumberOfWorkProfiles; ++i ) { tPilotMedusaInterface::tWorkProfileSettings workProfile; m_PilotDevice.GetMedusaInterface()->GetWorkProfileSettings( (unsigned char)i, &workProfile ); if ( workProfile.valid ) { m_pProfilesTable->insertRow( row ); QIcon icon( *tWorkProfile::Pixmap( workProfile.iconId ) ); QTableWidgetItem* pIconItem = new QTableWidgetItem( icon, "" ); pIconItem->setTextAlignment( Qt::AlignCenter ); m_pProfilesTable->setItem( row, eIconColumn, pIconItem ); QString name = tWorkProfile::ValidName( workProfile.name ); QTableWidgetItem* pNameItem = new QTableWidgetItem( name ); pNameItem->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter ); m_pProfilesTable->setItem( row, eNameColumn, pNameItem ); QTableWidgetItem* pEnabledItem = new QTableWidgetItem(); pEnabledItem->setCheckState( workProfile.enabled? Qt::Checked : Qt::Unchecked ); // Set the flags so the user can't change the checkbox state pEnabledItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); m_pProfilesTable->setItem( row, eEnabledColumn, pEnabledItem ); QTableWidgetItem* pActiveItem = new QTableWidgetItem(); bool active = ( i == m_PilotDevice.GetMedusaInterface()->GetWorkProfileActiveIndex() ); if ( active ) { pActiveItem->setCheckState( Qt::Checked ); } // Set the flags so the user can't change the checkbox state pActiveItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); m_pProfilesTable->setItem( row, eActiveColumn, pActiveItem ); ++row; } } if ( row < tPilotMedusaInterface::cNumberOfWorkProfiles ) { m_pProfilesTable->insertRow( row ); QTableWidgetItem* pIconItem = new QTableWidgetItem( "" ); m_pProfilesTable->setItem( row, eIconColumn, pIconItem ); QTableWidgetItem* pNewItem = new QTableWidgetItem( QString( tr( "New" ) + "..." ) ); pNewItem->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter ); m_pProfilesTable->setItem( row, eNameColumn, pNewItem ); } currentRow = currentRow < m_pProfilesTable->rowCount() ? currentRow : 0; m_pProfilesTable->selectRow( currentRow ); }
void pDockWidgetTitleBar::paintEvent( QPaintEvent* event ) { Q_UNUSED( event ); QRect rect = this->rect(); QPainter painter( this ); // native background paint for not common style / native paint if ( ( mUseNativePaint || style()->inherits( "QMacStyle" ) || style()->inherits( "Oxygen::Style" ) ) && qobject_cast<pDockWidget*>( mDock ) ) { QStyleOptionDockWidgetV2 optionDw; ((pDockWidget*)mDock)->initStyleOption( &optionDw ); optionDw.title.clear(); optionDw.closable = false; optionDw.floatable = false; optionDw.movable = false; optionDw.rect = rect; style()->drawControl( QStyle::CE_DockWidgetTitle, &optionDw, &painter, mDock ); } // custom background else { QColor topColor = palette().color( QPalette::Highlight ).lighter( 130 ); QColor bottomColor = palette().color( QPalette::Highlight ).darker( 130 ); QLinearGradient gradient( rect.topLeft(), rect.bottomLeft() ); topColor.setAlphaF( .7 ); bottomColor.setAlphaF( .7 ); gradient.setColorAt( 0, topColor ); gradient.setColorAt( 1, bottomColor ); if ( mDock->features() & QDockWidget::DockWidgetVerticalTitleBar ) { gradient.setFinalStop( rect.topRight() ); } painter.setPen( Qt::NoPen ); painter.setBrush( gradient ); painter.drawRect( rect ); painter.setPen( bottomColor.darker( 130 ) ); painter.setBrush( Qt::NoBrush ); painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); } if ( mDock->features() & QDockWidget::DockWidgetVerticalTitleBar ) { QTransform transform; rect.setSize( QSize( rect.height(), rect.width() ) ); transform.rotate( -90 ); transform.translate( -rect.width(), 0 ); painter.setTransform( transform ); } // icon / title QStyleOptionButton optionB; optionB.initFrom( mDock ); optionB.rect = rect.adjusted( 2, 0, -( orientation() == Qt::Horizontal ? minimumSizeHint().width() : minimumSizeHint().height() ), 0 ); optionB.text = mDock->windowTitle(); optionB.iconSize = windowIconSize(); optionB.icon = icon(); style()->drawControl( QStyle::CE_PushButtonLabel, &optionB, &painter, mDock ); }
// Constructor WxCasFrame::WxCasFrame ( const wxString & title ) : wxFrame ( ( wxFrame * ) NULL, -1, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE ) { // Give it an icon #ifdef __WINDOWS__ wxIcon icon(wxT("wxcas")); #else wxIcon icon; icon.CopyFromBitmap( WxCasPix::getPixmap( wxT( "wxcas" ) ) ); #endif SetIcon ( icon ); // Prefs wxConfigBase * prefs = wxConfigBase::Get(); m_maxLineCount = 0; // Check if we have a previous DL max hit double absoluteMaxDL = ( double ) ( prefs->Read ( WxCasCte::ABSOLUTE_MAX_DL_KEY, 0L ) ) / 1024.0; // Stored in bytes wxDateTime absoluteMaxDlDate( ( time_t ) ( prefs->Read ( WxCasCte::ABSOLUTE_MAX_DL_DATE_KEY, ( long ) ( wxDateTime::Now().GetTicks() ) ) ) ); // Stored in Ticks // Add Online Sig file m_aMuleSig = new OnLineSig ( wxFileName( prefs-> Read ( WxCasCte::AMULESIG_PATH_KEY, WxCasCte::DEFAULT_AMULESIG_PATH ), WxCasCte::AMULESIG_FILENAME ), absoluteMaxDL, absoluteMaxDlDate ); //Save absolute hit if we reach it during constructing if ( m_aMuleSig->IsSessionMaxDlChanged() ) { SaveAbsoluteHits(); } #ifdef __LINUX__ // System monitoring on Linux m_sysMonitor = new LinuxMon (); #endif // Status Bar CreateStatusBar (); SetStatusText ( _( "Welcome!" ) ); // Frame Vertical sizer m_frameVBox = new wxBoxSizer ( wxVERTICAL ); // Add Main panel to frame (needed by win32 for padding sub panels) m_mainPanel = new wxPanel ( this, -1 ); // Main Panel Vertical Sizer m_mainPanelVBox = new wxBoxSizer ( wxVERTICAL ); // Main Panel static line m_staticLine = new wxStaticLine ( m_mainPanel, -1 ); #ifdef __WINDOWS__ m_BottomStaticLine = new wxStaticLine ( m_mainPanel, -1 ); #endif // Statistics Static Vertical Box Sizer m_sigPanelSBox = new wxStaticBox ( m_mainPanel, -1, _( "aMule" ) ); m_sigPanelSBoxSizer = new wxStaticBoxSizer ( m_sigPanelSBox, wxVERTICAL ); // Hit Static Horizontal Box Sizer m_hitPanelSBox = new wxStaticBox ( m_mainPanel, -1, _( "Maximum DL rate since wxCas is running" ) ); m_hitPanelSBoxSizer = new wxStaticBoxSizer ( m_hitPanelSBox, wxHORIZONTAL ); // Hit Static Horizontal Box Sizer m_absHitPanelSBox = new wxStaticBox ( m_mainPanel, -1, _( "Absolute Maximum DL rate during wxCas previous runs" ) ); m_absHitPanelSBoxSizer = new wxStaticBoxSizer ( m_absHitPanelSBox, wxHORIZONTAL ); // Statistic labels m_statLine_1 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_1() ); m_statLine_2 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_2() ); m_statLine_3 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_3() ); m_statLine_4 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_4() ); m_statLine_5 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_5() ); m_statLine_6 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_6() ); m_statLine_7 = new wxStaticText ( m_mainPanel, -1, MakeStatLine_7() ); m_hitLine = new wxStaticText ( m_mainPanel, -1, MakeHitsLine_1() ); m_hitButton = new wxButton ( m_mainPanel, ID_HIT_BUTTON, wxString ( _( "Reset" ) ) ); m_absHitLine = new wxStaticText ( m_mainPanel, -1, MakeHitsLine_2() ); m_absHitButton = new wxButton ( m_mainPanel, ID_ABS_HIT_BUTTON, wxString ( _( "Reset" ) ) ); #ifdef __LINUX__ // System monitoring on Linux // Monitoring Static Vertical Box Sizer m_monPanelSBox = new wxStaticBox ( m_mainPanel, -1, _( "System" ) ); m_monPanelSBoxSizer = new wxStaticBoxSizer ( m_monPanelSBox, wxVERTICAL ); m_sysLine_1 = new wxStaticText ( m_mainPanel, -1, MakeSysLine_1() ); m_sysLine_2 = new wxStaticText ( m_mainPanel, -1, MakeSysLine_2() ); #endif // Statistic Panel Layout m_sigPanelSBoxSizer->Add ( m_statLine_1, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_sigPanelSBoxSizer->Add ( m_statLine_2, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_sigPanelSBoxSizer->Add ( m_statLine_3, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_sigPanelSBoxSizer->Add ( m_statLine_4, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_sigPanelSBoxSizer->Add ( m_statLine_5, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_sigPanelSBoxSizer->Add ( m_statLine_6, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_sigPanelSBoxSizer->Add ( m_statLine_7, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_hitPanelSBoxSizer->Add ( m_hitLine, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxGROW, 5 ); m_hitPanelSBoxSizer->Add ( m_hitButton, 0, wxALL | wxALIGN_RIGHT, 5 ); m_absHitPanelSBoxSizer->Add ( m_absHitLine, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxGROW, 5 ); m_absHitPanelSBoxSizer->Add ( m_absHitButton, 0, wxALL | wxALIGN_RIGHT, 5 ); #ifdef __LINUX__ // System monitoring on Linux m_monPanelSBoxSizer->Add ( m_sysLine_1, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); m_monPanelSBoxSizer->Add ( m_sysLine_2, 0, wxALL | wxALIGN_CENTER | wxGROW, 5 ); #endif // Main panel Layout m_mainPanelVBox->Add ( m_staticLine, 0, wxALL | wxALIGN_CENTER | wxGROW ); m_mainPanelVBox->Add ( m_sigPanelSBoxSizer, 0, wxALL | wxALIGN_CENTER | wxGROW, 10 ); #ifdef __LINUX__ // System monitoring on Linux m_mainPanelVBox->Add ( m_monPanelSBoxSizer, 0, wxALL | wxALIGN_CENTER | wxGROW, 10 ); #endif m_mainPanelVBox->Add ( m_hitPanelSBoxSizer, 0, wxALL | wxALIGN_CENTER | wxGROW, 10 ); m_mainPanelVBox->Add ( m_absHitPanelSBoxSizer, 0, wxALL | wxALIGN_CENTER | wxGROW, 10 ); #ifdef __WINDOWS__ m_mainPanelVBox->Add ( m_BottomStaticLine, 0, wxALL | wxALIGN_CENTER | wxGROW ); #endif // Toolbar Pixmaps m_toolBarBitmaps[ 0 ] = WxCasPix::getPixmap( wxT( "refresh" ) ); m_toolBarBitmaps[ 1 ] = WxCasPix::getPixmap( wxT( "save" ) ); m_toolBarBitmaps[ 2 ] = WxCasPix::getPixmap( wxT( "print" ) ); m_toolBarBitmaps[ 3 ] = WxCasPix::getPixmap( wxT( "about" ) ); m_toolBarBitmaps[ 4 ] = WxCasPix::getPixmap( wxT( "stop" ) ); m_toolBarBitmaps[ 5 ] = WxCasPix::getPixmap( wxT( "prefs" ) ); // Constructing toolbar m_toolbar = new wxToolBar ( this, -1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxTB_FLAT ); m_toolbar->SetToolBitmapSize ( wxSize ( 32, 32 ) ); m_toolbar->SetMargins ( 2, 2 ); m_toolbar->AddTool ( ID_BAR_REFRESH, wxT( "Refresh" ), m_toolBarBitmaps[ 0 ], _( "Stop Auto Refresh" ) ); m_toolbar->AddSeparator (); m_toolbar->AddTool ( ID_BAR_SAVE, wxT( "Save" ), m_toolBarBitmaps[ 1 ], _( "Save Online Statistics image" ) ); m_toolbar->AddTool ( ID_BAR_PRINT, wxT( "Print" ), m_toolBarBitmaps[ 2 ], _( "Print Online Statistics image" ) ); m_toolbar->AddTool ( ID_BAR_PREFS, wxT( "Prefs" ), m_toolBarBitmaps[ 5 ], _( "Preferences setting" ) ); m_toolbar->AddSeparator (); m_toolbar->AddTool ( ID_BAR_ABOUT, wxT( "About" ), m_toolBarBitmaps[ 3 ], _( "About wxCas" ) ); m_toolbar->Realize (); SetToolBar ( m_toolbar ); // Panel Layout m_mainPanel->SetAutoLayout( true ); m_mainPanel->SetSizer ( m_mainPanelVBox ); // Frame Layout m_frameVBox->Add ( m_mainPanel, 1, wxALL | wxGROW ); SetAutoLayout ( TRUE ); SetSizerAndFit ( m_frameVBox ); // Add refresh timer m_refresh_timer = new wxTimer ( this, ID_REFRESH_TIMER ); m_refresh_timer->Start ( 1000 * prefs->Read ( WxCasCte::REFRESH_RATE_KEY, WxCasCte::DEFAULT_REFRESH_RATE ) ); // s to ms // Add FTP update timer m_ftp_update_timer = new wxTimer ( this, ID_FTP_UPDATE_TIMER ); m_ftp_update_timer->Start ( 60000 * prefs->Read ( WxCasCte::FTP_UPDATE_RATE_KEY, WxCasCte::DEFAULT_FTP_UPDATE_RATE ) ); // min to ms }
QLayout* SceneLabelDialog::createContent() { logMessage("DSceneLabel::createContent()"); txtPointX = new ValueLineEdit(); txtPointY = new ValueLineEdit(); connect(txtPointX, SIGNAL(evaluated(bool)), this, SLOT(evaluated(bool))); connect(txtPointY, SIGNAL(evaluated(bool)), this, SLOT(evaluated(bool))); cmbMaterial = new QComboBox(); connect(cmbMaterial, SIGNAL(currentIndexChanged(int)), this, SLOT(doMaterialChanged(int))); btnMaterial = new QPushButton(icon("three-dots"), ""); btnMaterial->setMaximumSize(btnMaterial->sizeHint()); connect(btnMaterial, SIGNAL(clicked()), this, SLOT(doMaterialClicked())); txtArea = new ValueLineEdit(); txtArea->setMinimum(0.0); connect(txtArea, SIGNAL(evaluated(bool)), this, SLOT(evaluated(bool))); txtPolynomialOrder = new QSpinBox(this); txtPolynomialOrder->setMinimum(0); txtPolynomialOrder->setMaximum(10); // coordinates must be greater then or equal to 0 (axisymmetric case) if (Util::scene()->problemInfo()->problemType == ProblemType_Axisymmetric) txtPointX->setMinimum(0.0); // coordinates QFormLayout *layoutCoordinates = new QFormLayout(); layoutCoordinates->addRow(Util::scene()->problemInfo()->labelX() + " (m):", txtPointX); layoutCoordinates->addRow(Util::scene()->problemInfo()->labelY() + " (m):", txtPointY); QGroupBox *grpCoordinates = new QGroupBox(tr("Coordinates")); grpCoordinates->setLayout(layoutCoordinates); // marker QHBoxLayout *layoutMaterial = new QHBoxLayout(); layoutMaterial->addWidget(cmbMaterial); layoutMaterial->addWidget(btnMaterial); // order chkPolynomialOrder = new QCheckBox(); connect(chkPolynomialOrder, SIGNAL(stateChanged(int)), this, SLOT(doPolynomialOrder(int))); QHBoxLayout *layoutPolynomialOrder = new QHBoxLayout(); layoutPolynomialOrder->addWidget(chkPolynomialOrder); layoutPolynomialOrder->addWidget(txtPolynomialOrder); layoutPolynomialOrder->addWidget(new QLabel(tr("Global order is %1.").arg(Util::scene()->problemInfo()->polynomialOrder))); // area chkArea = new QCheckBox(); connect(chkArea, SIGNAL(stateChanged(int)), this, SLOT(doArea(int))); QHBoxLayout *layoutArea = new QHBoxLayout(); layoutArea->addWidget(chkArea); layoutArea->addWidget(txtArea); // mesh QFormLayout *layoutMeshParameters = new QFormLayout(); layoutMeshParameters->addRow(tr("Triangle area (m):"), layoutArea); layoutMeshParameters->addRow(tr("Polynomial order (-):"), layoutPolynomialOrder); QGroupBox *grpMeshParameters = new QGroupBox(tr("Mesh parameters")); grpMeshParameters->setLayout(layoutMeshParameters); QFormLayout *layout = new QFormLayout(); layout->addRow(tr("Material:"), layoutMaterial); layout->addRow(grpCoordinates); layout->addRow(grpMeshParameters); fillComboBox(); return layout; }
void PinEntryDialog::setError( const QString& txt ) { if( !txt.isNull() )_icon->setPixmap( icon( QStyle::SP_MessageBoxCritical ) ); _error->setText( txt ); _error->setVisible( !txt.isEmpty() ); }
PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name, int timeout, bool modal, bool enable_quality_bar ) : QDialog( parent, Qt::WindowStaysOnTopHint ), _grabbed( false ) { setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint ); if ( modal ) { setWindowModality( Qt::ApplicationModal ); } _icon = new QLabel( this ); _icon->setPixmap( icon() ); _error = new QLabel( this ); _error->setWordWrap(true); QPalette pal; pal.setColor( QPalette::WindowText, Qt::red ); _error->setPalette( pal ); _error->hide(); _desc = new QLabel( this ); _desc->setWordWrap(true); _desc->hide(); _prompt = new QLabel( this ); _prompt->hide(); _edit = new QSecureLineEdit( this ); _edit->setMaxLength( 256 ); _prompt->setBuddy( _edit ); if (enable_quality_bar) { _quality_bar_label = new QLabel( this ); _quality_bar_label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); _quality_bar = new QProgressBar( this ); _quality_bar->setAlignment( Qt::AlignCenter ); _have_quality_bar = true; } else _have_quality_bar = false; QDialogButtonBox* const buttons = new QDialogButtonBox( this ); buttons->setStandardButtons( QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); _ok = buttons->button( QDialogButtonBox::Ok ); _cancel = buttons->button( QDialogButtonBox::Cancel ); _ok->setDefault(true); if ( style()->styleHint( QStyle::SH_DialogButtonBox_ButtonsHaveIcons ) ) { _ok->setIcon( style()->standardIcon( QStyle::SP_DialogOkButton ) ); _cancel->setIcon( style()->standardIcon( QStyle::SP_DialogCancelButton ) ); } if (timeout > 0) { _timer = new QTimer(this); connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeout())); _timer->start(timeout*1000); } else _timer = NULL; connect( buttons, SIGNAL(accepted()), this, SLOT(accept()) ); connect( buttons, SIGNAL(rejected()), this, SLOT(reject()) ); connect( _edit, SIGNAL( textChanged(secqstring) ), this, SLOT( updateQuality(secqstring) ) ); _edit->setFocus(); QGridLayout* const grid = new QGridLayout( this ); grid->addWidget( _icon, 0, 0, 5, 1, Qt::AlignTop|Qt::AlignLeft ); grid->addWidget( _error, 1, 1, 1, 2 ); grid->addWidget( _desc, 2, 1, 1, 2 ); //grid->addItem( new QSpacerItem( 0, _edit->height() / 10, QSizePolicy::Minimum, QSizePolicy::Fixed ), 1, 1 ); grid->addWidget( _prompt, 3, 1 ); grid->addWidget( _edit, 3, 2 ); if( enable_quality_bar ) { grid->addWidget( _quality_bar_label, 4, 1 ); grid->addWidget( _quality_bar, 4, 2 ); } grid->addWidget( buttons, 5, 0, 1, 3 ); grid->setSizeConstraint( QLayout::SetFixedSize ); }
LayoutDlg::LayoutDlg(QWidget *parent, Qt::WindowFlags f) : QDialog(parent,f) { setWindowTitle(tr("User Infomation")); // create label1 = new QLabel(tr("User Name:")); label2 = new QLabel(tr("Name:")); label3 = new QLabel(tr("Sex")); label4 = new QLabel(tr("Department:")); label5 = new QLabel(tr("Age:")); labelOther = new QLabel(tr("Remark")); labelOther->setFrameStyle(QFrame::Panel|QFrame::Sunken); lineEditUser = new QLineEdit(); lineEditName = new QLineEdit(); comboBoxSex = new QComboBox(); comboBoxSex->insertItem(0,tr("Female")); comboBoxSex->insertItem(1,tr("Male")); textEditDepartment = new QTextEdit(); lineEditAge = new QLineEdit(); label7 = new QLabel(tr("Head")); labelIcon = new QLabel(); QPixmap icon(":/images/icon.png"); labelIcon->resize(icon.width(),icon.height()); labelIcon->setPixmap(icon); pushButtonIcon = new QPushButton(); pushButtonIcon->setText(tr("Change")); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setSpacing(20); hLayout->addWidget(label7); hLayout->addWidget(labelIcon); hLayout->addWidget(pushButtonIcon); label6 = new QLabel(tr("Individual:")); textEditDisc = new QTextEdit(); pushButtonOK = new QPushButton(tr("OK")); pushButtonExit = new QPushButton(tr("Cancel")); // Lay out // left layout -- is a grid layout QGridLayout * leftLayout = new QGridLayout(); int labelCol = 0; int contentCol = 1; leftLayout->addWidget(label1,0,labelCol); // user name row leftLayout->addWidget(lineEditUser,0,contentCol); leftLayout->addWidget(label2,1,labelCol); // name row leftLayout->addWidget(lineEditName,1,contentCol); leftLayout->addWidget(label3,2,labelCol); // sex row leftLayout->addWidget(comboBoxSex,2,contentCol); leftLayout->addWidget(label4,3,labelCol,Qt::AlignTop); // department row leftLayout->addWidget(textEditDepartment,3,contentCol); leftLayout->addWidget(label5,4,labelCol); // age row leftLayout->addWidget(lineEditAge,4,contentCol); leftLayout->addWidget(labelOther,5,labelCol,1,2); // other leftLayout->setColumnStretch(0,1); leftLayout->setColumnStretch(1,3); // right layout -- is a vBoxLayout QVBoxLayout *rightLayout = new QVBoxLayout(); rightLayout->setMargin(10); rightLayout->addLayout(hLayout); rightLayout->addWidget(label6); rightLayout->addWidget(textEditDisc); // buttom layout -- is a hBoxLayout QHBoxLayout * bottomLayout = new QHBoxLayout(); bottomLayout->addStretch(); bottomLayout->addWidget(pushButtonOK); bottomLayout->addWidget(pushButtonExit); // main layout -- is a GridLayout QGridLayout * mainLayout = new QGridLayout(this); mainLayout->setMargin(15); mainLayout->setSpacing(10); mainLayout->addLayout(leftLayout,0,0); mainLayout->addLayout(rightLayout,0,1); mainLayout->addLayout(bottomLayout,1,0,1,2); mainLayout->setSizeConstraint(QLayout::SetFixedSize); connect(pushButtonExit,SIGNAL(clicked()),this,SLOT(reject())); }
bool zip::parse(QTreeWidget * listv, QString bf, akuRatioWidget *ratioBar ) { // variabile che indica la presenza di file con password (header compreso) bool fileswithpass = false; bf.remove(0, (bf.indexOf("\n") + 1)); // elimino la prima riga bf.remove(bf.lastIndexOf("\n"), bf.size()); // elimino l'ultima riga // memorizzo l'ultima riga per conservare delle informazioni utili QString lastline = bf.mid((bf.lastIndexOf("\n") + 1), bf.size()); bf.remove(bf.lastIndexOf("\n"), bf.size()); bool crypted = false; QStringList flist = bf.split ( "\n" ); //splitto basandomi sul carattere di newline int numeroPezziPercorso; QRegExp sep("(\\s+)"); //inizio il ciclo per la visualizzazione dell'elenco for ( int i = 0; i < flist.size(); i++ ) { // estraggo prima il percorso del file a partire dal carattere 62 QString filepath = flist[i].mid(62, flist[i].size()); // questa funzione per quanto migliore, non prende i file che iniziano per spazio vuoto //QString filepath = flist[i].section(sep, 9 , -1); QStringList singleItem = filepath.split (QDir().separator()); //splitto i nomi delle cartelle //puts(singleItem.join(" ").toAscii()); numeroPezziPercorso = singleItem.size() - 1; QTreeWidgetItem *fitem; //nuovo elemento da allocare in lista QTreeWidgetItem *tmpItem; //puntatore a elemento temporaneo bool foldFound = false; //se ho trovato l'elemento... bool itemFound = false; for ( int j = 0; j < singleItem.size(); j++ ) {//per ogni cartella ramifico... itemFound = false; foldFound = false; //-------------------queste operazioni avvengono solo ed esclusivamente al primo ciclo---------------------// if ( j == 0 ) { //se e' il primo ciclo limitiamo la ricerca ai top level items for ( int c = 0; c < listv -> topLevelItemCount(); c++ ) { //se trovo l'elemento tra i top level setto il current if ( ( listv -> topLevelItem ( c ) ) -> text ( 0 ) == singleItem[j] ) { tmpItem = listv -> topLevelItem ( c ); foldFound = true; break; //se ho trovato l'elemento è inutile continuare il ciclo } } if ( foldFound == false ) { //altrimenti alloco in lista in topLevel.. Questo accade anche se non è stato eseguito nessun ciclo fitem = new QTreeWidgetItem ( listv ); fitem -> setText ( 0, singleItem[j] ); tmpItem = fitem; } } else { //------------------queste operazioni avvengono per tutti gli altri cicli-------------------// //cerco ciò che mi interessa tra i child dell currentItem() attuale for ( int c=0; c < tmpItem -> childCount(); c++ ) { if ( tmpItem->child ( c ) -> text ( 0 ) == singleItem[j] ) { tmpItem = tmpItem->child ( c ); //se lo trovo setto il current item itemFound = true; break; //se ho trovato l'elemento è inutile continuare il ciclo } } if (( itemFound == false ) && (!singleItem[j].isEmpty())) { //altrimenti alloco e setto il currentItem fitem = new QTreeWidgetItem ( tmpItem ); fitem -> setText ( 0, singleItem[j] ); tmpItem = fitem; } } } //flist[i].remove(62, flist[i].size()); QStringList dlist = (flist.at(i)).split(" ", QString::SkipEmptyParts ); // generiamo una lista contenente i parametri dei file //puts(dlist[4].toAscii() + dlist[6].toAscii()); //if (!((dlist[6] == "stor") && (dlist[4] == "bx"))) { //è inutile scrivere gli attributi della cartella // provo a vedere se basta leggere la "d" dai permessi per individuare una cartella invece di un controllo // fatto nella riga precedente. if (dlist[0][0] != QChar('d')) { fitem -> setText(4, dlist[7] + " " + dlist[8]); // modified QString size = KLocale( QString() ).formatByteSize(dlist[3].toDouble()); // 3 -> dimensione originale del file fitem -> setText(1, size); size = KLocale( QString() ).formatByteSize(dlist[5].toDouble()); // 5 -> dimensione packed del file fitem -> setText(2, size); fitem -> setText(5, dlist[0]); // attributi fitem -> setText(7, dlist[4] + " " + dlist[6]); // metodo if ((dlist[4][0] == QChar('B')) || (dlist[4][0] == QChar('T'))) crypted = true; else crypted = false; fitem -> setText(8, dlist[1] + " " + dlist[2]); // version and so // calcolo il ratio float ratio = 0; if (dlist[3].toInt() != 0) { ratio = (100.0 * dlist[5].toFloat() / dlist[3].toFloat()); ratio = abs(ratio - 100); } fitem -> setText(3, QString().setNum(ratio) + "%"); // // akuRatioWidget *ratioWidget = new akuRatioWidget(ratio); // // listv -> setItemWidget(fitem, 3, ratioWidget); // fitem -> setTextAlignment ( 1, Qt::AlignRight | Qt::AlignVCenter ); fitem -> setTextAlignment ( 2, Qt::AlignRight | Qt::AlignVCenter ); fitem -> setTextAlignment ( 3, Qt::AlignHCenter | Qt::AlignVCenter ); fitem -> setTextAlignment ( 5, Qt::AlignHCenter | Qt::AlignVCenter ); fitem -> setTextAlignment ( 7, Qt::AlignRight | Qt::AlignVCenter ); fitem -> setTextAlignment ( 8, Qt::AlignCenter | Qt::AlignVCenter ); KMimeType::Ptr mimePtr = KMimeType::findByUrl(KUrl(singleItem[numeroPezziPercorso])); KIcon icon(mimePtr -> iconName()); fitem -> setIcon (0, icon); fitem -> setText(9, mimePtr->name()); } if (crypted == true) { fitem -> setIcon(10, KIcon("dialog-password")); fileswithpass = true; } } QStringList archinfo; archinfo = lastline.split ( " ", QString::SkipEmptyParts ); archiveDetails << archinfo[0] << KLocale(archinfo[2] ).formatByteSize(archinfo[2].toULong()) << KLocale(archinfo[5] ).formatByteSize(archinfo[5].toULong()); QString ratio = archinfo.at (8); ratio.remove (ratio.length() - 1, 1); ratioBar -> setRatio (int(ratio.toFloat() + 0.5f)); return fileswithpass; }
Error Main::setup2() { OS::get_singleton()->initialize(video_mode,video_driver_idx,audio_driver_idx); if (init_use_custom_pos) { OS::get_singleton()->set_window_position(init_custom_pos); } register_core_singletons(); MAIN_PRINT("Main: Setup Logo"); bool show_logo=true; #ifdef JAVASCRIPT_ENABLED show_logo=false; #endif if (init_screen!=-1) { OS::get_singleton()->set_current_screen(init_screen); } if (init_windowed) { //do none.. } else if (init_maximized) { OS::get_singleton()->set_window_maximized(true); } else if (init_fullscreen) { OS::get_singleton()->set_window_fullscreen(true); } MAIN_PRINT("Main: Load Remaps"); path_remap->load_remaps(); if (show_logo) { //boot logo! String boot_logo_path=GLOBAL_DEF("application/boot_splash",String()); bool boot_logo_scale=GLOBAL_DEF("application/boot_splash_fullsize",true); Globals::get_singleton()->set_custom_property_info("application/boot_splash",PropertyInfo(Variant::STRING,"application/boot_splash",PROPERTY_HINT_FILE,"*.png")); Image boot_logo; boot_logo_path = boot_logo_path.strip_edges(); if (boot_logo_path!=String() /*&& FileAccess::exists(boot_logo_path)*/) { print_line("Boot splash path: "+boot_logo_path); Error err = boot_logo.load(boot_logo_path); } if (!boot_logo.empty()) { OS::get_singleton()->_msec_splash=OS::get_singleton()->get_ticks_msec(); Color clear = GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3)); VisualServer::get_singleton()->set_default_clear_color(clear); Color boot_bg = GLOBAL_DEF("application/boot_bg_color", clear); VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg,boot_logo_scale); #ifndef TOOLS_ENABLED //no tools, so free the boot logo (no longer needed) // Globals::get_singleton()->set("application/boot_logo",Image()); #endif } else { #ifndef NO_DEFAULT_BOOT_LOGO MAIN_PRINT("Main: Create bootsplash"); Image splash(boot_splash_png); MAIN_PRINT("Main: ClearColor"); VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color); MAIN_PRINT("Main: Image"); VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color,false); #endif MAIN_PRINT("Main: DCC"); VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3))); MAIN_PRINT("Main: END"); } Image icon(app_icon_png); OS::get_singleton()->set_icon(icon); } GLOBAL_DEF("application/icon",String()); Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp")); if (bool(GLOBAL_DEF("display/emulate_touchscreen",false))) { if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) { //only if no touchscreen ui hint, set emulation InputDefault *id = Input::get_singleton()->cast_to<InputDefault>(); if (id) id->set_emulate_touch(true); } } MAIN_PRINT("Main: Load Remaps"); MAIN_PRINT("Main: Load Scene Types"); register_scene_types(); register_server_types(); GLOBAL_DEF("display/custom_mouse_cursor",String()); GLOBAL_DEF("display/custom_mouse_cursor_hotspot",Vector2()); Globals::get_singleton()->set_custom_property_info("display/custom_mouse_cursor",PropertyInfo(Variant::STRING,"display/custom_mouse_cursor",PROPERTY_HINT_FILE,"*.png,*.webp")); if (String(Globals::get_singleton()->get("display/custom_mouse_cursor"))!=String()) { //print_line("use custom cursor"); Ref<Texture> cursor=ResourceLoader::load(Globals::get_singleton()->get("display/custom_mouse_cursor")); if (cursor.is_valid()) { // print_line("loaded ok"); Vector2 hotspot = Globals::get_singleton()->get("display/custom_mouse_cursor_hotspot"); Input::get_singleton()->set_custom_mouse_cursor(cursor,hotspot); } } #ifdef TOOLS_ENABLED EditorNode::register_editor_types(); ObjectTypeDB::register_type<PCKPacker>(); // todo: move somewhere else #endif MAIN_PRINT("Main: Load Scripts, Modules, Drivers"); register_module_types(); register_driver_types(); ScriptServer::init_languages(); MAIN_PRINT("Main: Load Translations"); translation_server->setup(); //register translations, load them, etc. if (locale!="") { translation_server->set_locale(locale); } translation_server->load_translations(); _start_success=true; locale=String(); MAIN_PRINT("Main: Done"); return OK; }
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) : QWidget(0, f), curAlignment(0) { // set reference point, paddings int paddingRight = 50; int paddingTop = 50; int titleVersionVSpace = 17; int titleCopyrightVSpace = 40; float fontFactor = 1.0; float devicePixelRatio = 1.0; #if QT_VERSION > 0x050100 devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio(); #endif // define text to place QString titleText = tr("Bitcoin Core"); QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion())); QString copyrightText = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers")); QString titleAddText = networkStyle->getTitleAddText(); QString font = QApplication::font().toString(); // create a bitmap according to device pixelratio QSize splashSize(480*devicePixelRatio,320*devicePixelRatio); pixmap = QPixmap(splashSize); #if QT_VERSION > 0x050100 // change to HiDPI if it makes sense pixmap.setDevicePixelRatio(devicePixelRatio); #endif QPainter pixPaint(&pixmap); pixPaint.setPen(QColor(100,100,100)); // draw a slightly radial gradient QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, QColor(247,247,247)); QRect rGradient(QPoint(0,0), splashSize); pixPaint.fillRect(rGradient, gradient); // draw the bitcoin icon, expected size of PNG: 1024x1024 QRect rectIcon(QPoint(-150,-122), QSize(430,430)); const QSize requiredSize(1024,1024); QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize)); pixPaint.drawPixmap(rectIcon, icon); // check font size and drawing with pixPaint.setFont(QFont(font, 33*fontFactor)); QFontMetrics fm = pixPaint.fontMetrics(); int titleTextWidth = fm.width(titleText); if(titleTextWidth > 160) { // strange font rendering, Arial probably not found fontFactor = 0.75; } pixPaint.setFont(QFont(font, 33*fontFactor)); fm = pixPaint.fontMetrics(); titleTextWidth = fm.width(titleText); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText); pixPaint.setFont(QFont(font, 15*fontFactor)); // if the version string is to long, reduce size fm = pixPaint.fontMetrics(); int versionTextWidth = fm.width(versionText); if(versionTextWidth > titleTextWidth+paddingRight-10) { pixPaint.setFont(QFont(font, 10*fontFactor)); titleVersionVSpace -= 5; } pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText); // draw copyright stuff pixPaint.setFont(QFont(font, 10*fontFactor)); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText); // draw additional text if special network if(!titleAddText.isEmpty()) { QFont boldFont = QFont(font, 10*fontFactor); boldFont.setWeight(QFont::Bold); pixPaint.setFont(boldFont); fm = pixPaint.fontMetrics(); int titleAddTextWidth = fm.width(titleAddText); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText); } pixPaint.end(); // Set window title setWindowTitle(titleText + " " + titleAddText); // Resize window and move to center of desktop, disallow resizing QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio)); resize(r.size()); setFixedSize(r.size()); move(QApplication::desktop()->screenGeometry().center() - r.center()); subscribeToCoreSignals(); }
QIcon QtPropertyBrowserUtils::fontValueIcon(const QFont &f) { QIcon icon(fontValuePixmap(f, 16)); icon.addPixmap(fontValuePixmap(f, 32)); return icon; }
QBitmap QWaylandMaterialDecoration::buttonIcon(const QString &name) const { QIcon icon(":/icons/" + name + ".svg"); QPixmap pixmap = icon.pixmap(QSize(BUTTON_WIDTH, BUTTON_WIDTH)); return pixmap.createMaskFromColor(QColor("black"), Qt::MaskOutColor); }
QIcon PokeGraphics::icon(const Pokemon::uniqueId &pokeid) { loadIcon(pokeid); return icon(); }
// Application initialization bool sipXezPhoneApp::OnInit() { if (!sipXezPhoneSettings::getInstance().loadSettings()) { # ifdef _WIN32 PROCESS_INFORMATION pi ; STARTUPINFO si ; memset(&si, 0, sizeof(si)) ; si.cb = sizeof(si) ; CreateProcess("ConfigWizard.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) ; // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); memset(&si, 0, sizeof(si)) ; si.cb = sizeof(si) ; CreateProcess("AVWizard.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) ; // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); sipXezPhoneSettings::getInstance().loadSettings() ; # endif } // check the command line arguements if (argc > 0) { // loop through command line args for (int i = 0; i < argc; i++) { if (strcmp(argv[i], "-test") == 0) { sipXezPhoneSettings::getInstance().setTestMode(true); } } } thePhoneApp = this; bool bLogo = false; int height = 378; #ifdef _WIN32 struct _stat buf; if (_stat("res/PhoneLogo.bmp", &buf) == 0) { bLogo = true; height = 460; } #endif // create a new frame mpFrame = new sipXezPhoneFrame( "sipXezPhone", wxDefaultPosition, wxSize(255, height), bLogo ); // set the icon // this icon type doesn't seem to work in Linux #ifdef _WIN32 wxIcon icon("res/sipXezPhone.ico", wxBITMAP_TYPE_ICO); mpFrame->SetIcon(icon); #endif // show the frame and put it on top mpFrame->Show( TRUE ); SetTopWindow( mpFrame ); return TRUE; }
int QWebFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: javaScriptWindowObjectCleared(); break; case 1: provisionalLoad(); break; case 2: titleChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 3: urlChanged((*reinterpret_cast< const QUrl(*)>(_a[1]))); break; case 4: initialLayoutCompleted(); break; case 5: iconChanged(); break; case 6: contentsSizeChanged((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 7: loadStarted(); break; case 8: loadFinished((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: { QVariant _r = evaluateJavaScript((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QVariant*>(_a[0]) = _r; } break; case 10: print((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break; default: ; } _id -= 11; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = textSizeMultiplier(); break; case 1: *reinterpret_cast< qreal*>(_v) = zoomFactor(); break; case 2: *reinterpret_cast< QString*>(_v) = title(); break; case 3: *reinterpret_cast< QUrl*>(_v) = url(); break; case 4: *reinterpret_cast< QUrl*>(_v) = requestedUrl(); break; case 5: *reinterpret_cast< QUrl*>(_v) = baseUrl(); break; case 6: *reinterpret_cast< QIcon*>(_v) = icon(); break; case 7: *reinterpret_cast< QSize*>(_v) = contentsSize(); break; case 8: *reinterpret_cast< QPoint*>(_v) = scrollPosition(); break; case 9: *reinterpret_cast< bool*>(_v) = hasFocus(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTextSizeMultiplier(*reinterpret_cast< qreal*>(_v)); break; case 1: setZoomFactor(*reinterpret_cast< qreal*>(_v)); break; case 3: setUrl(*reinterpret_cast< QUrl*>(_v)); break; case 8: setScrollPosition(*reinterpret_cast< QPoint*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
QLayout* SceneEdgeDialog::createContent() { logMessage("DSceneEdge::createContent()"); cmbNodeStart = new QComboBox(); cmbNodeEnd = new QComboBox(); connect(cmbNodeStart, SIGNAL(currentIndexChanged(int)), this, SLOT(doNodeChanged())); connect(cmbNodeEnd, SIGNAL(currentIndexChanged(int)), this, SLOT(doNodeChanged())); cmbBoundary = new QComboBox(); connect(cmbBoundary, SIGNAL(currentIndexChanged(int)), this, SLOT(doBoundaryChanged(int))); btnBoundary = new QPushButton(icon("three-dots"), ""); btnBoundary->setMaximumSize(btnBoundary->sizeHint()); connect(btnBoundary, SIGNAL(clicked()), this, SLOT(doBoundaryClicked())); txtAngle = new ValueLineEdit(); txtAngle->setMinimum(0.0); txtAngle->setMaximum(180.0); connect(txtAngle, SIGNAL(evaluated(bool)), this, SLOT(evaluated(bool))); txtRefineTowardsEdge = new QSpinBox(this); txtRefineTowardsEdge->setMinimum(0); txtRefineTowardsEdge->setMaximum(10); lblLength = new QLabel(); // coordinates QFormLayout *layoutCoordinates = new QFormLayout(); layoutCoordinates->addRow(tr("Start point:"), cmbNodeStart); layoutCoordinates->addRow(tr("End point:"), cmbNodeEnd); layoutCoordinates->addRow(tr("Angle (deg.):"), txtAngle); QGroupBox *grpCoordinates = new QGroupBox(tr("Coordinates")); grpCoordinates->setLayout(layoutCoordinates); // marker QHBoxLayout *layoutBoundary = new QHBoxLayout(); layoutBoundary->addWidget(cmbBoundary); layoutBoundary->addWidget(btnBoundary); // refine towards edge chkRefineTowardsEdge = new QCheckBox(); connect(chkRefineTowardsEdge, SIGNAL(stateChanged(int)), this, SLOT(doRefineTowardsEdge(int))); QHBoxLayout *layoutRefineTowardsEdge = new QHBoxLayout(); layoutRefineTowardsEdge->addStretch(1); layoutRefineTowardsEdge->addWidget(chkRefineTowardsEdge); layoutRefineTowardsEdge->addWidget(txtRefineTowardsEdge); // mesh QFormLayout *layoutMeshParameters = new QFormLayout(); layoutMeshParameters->addRow(tr("Refine towards edge:"), layoutRefineTowardsEdge); QGroupBox *grpMeshParameters = new QGroupBox(tr("Mesh parameters")); grpMeshParameters->setLayout(layoutMeshParameters); // layout QFormLayout *layout = new QFormLayout(); layout->addRow(tr("Boundary condition:"), layoutBoundary); layout->addRow(grpCoordinates); layout->addRow(grpMeshParameters); layout->addRow(tr("Length:"), lblLength); fillComboBox(); return layout; }
//create all sub-widgets and display everything void PlayScreen::display(int screenWidth, int screenHeight, int gridSize) { this->screenWidth = screenWidth; this->screenHeight = screenHeight; grid = gridSize; numMoves = 0; seconds = 0; percentComplete = grid*grid; QFont font("Helvectica", 13); //set up scene and view QGraphicsScene *gScene = new QGraphicsScene(this); QGraphicsView *gView = new QGraphicsView(gScene); gView->setFixedSize(screenWidth, screenHeight); gScene->setBackgroundBrush(Qt::black); //set up all GridLayouts QGridLayout *layout = new QGridLayout(gView); playGrid = new QGridLayout(); QGridLayout *menuGrid = new QGridLayout(); layout->setContentsMargins(0,0,0,0); playGrid->setContentsMargins(0,0,0,0); menuGrid->setContentsMargins(0,0,0,0); gView->setLayout(layout); layout->addLayout(playGrid, 0, 0); layout->addLayout(menuGrid, 1, 0); //timer and move labels movesLabel = new QLabel("Moves: " + QString::number(numMoves)); timerLabel = new QLabel("Time: 0:0"); percentLabel = new QLabel("Percent: 0%"); menuGrid->addWidget(movesLabel,0,0); menuGrid->addWidget(timerLabel,1,0); menuGrid->addWidget(percentLabel,2,0); movesLabel->setFont(font); timerLabel->setFont(font); percentLabel->setFont(font); //menu buttons QPushButton *winButton = new QPushButton("DEBUG WIN"); QPushButton *pauseButton = new QPushButton("Pause/Play"); QPushButton *giveUpButton = new QPushButton("Give Up"); menuGrid->addWidget(winButton, 0, 1); menuGrid->addWidget(pauseButton, 1, 1); menuGrid->addWidget(giveUpButton, 2, 1); winButton->setFont(font); pauseButton->setFont(font); giveUpButton->setFont(font); connect(winButton, SIGNAL(clicked()), this, SLOT(winButtonClicked())); connect(pauseButton, SIGNAL(clicked()), this, SLOT(pauseButtonClicked())); connect(giveUpButton, SIGNAL(clicked()), this, SLOT(giveUpButtonClicked())); //import image QImageReader reader(imgPath); reader.setScaledSize(QSize(screenWidth, screenWidth)); QImage image = reader.read(); int eHeight = image.height(); int eWidth = image.width(); //cut image into tiles and position them for(int i = 0; i < grid; i++){ for(int j = 0; j < grid; j++){ if(!(i==grid-1 && j==grid-1)){ QPixmap pixmap = QPixmap::fromImage(image.copy(i*(eWidth/grid), j*(eHeight/grid), eWidth/grid, eHeight/grid)); QIcon icon(pixmap); Tile *button = new Tile(i, j, icon); button->setIconSize(QSize(eWidth/grid, eHeight/grid)); playGrid->addWidget(button, j, i); connect(button, SIGNAL(tileClicked(Tile*)), this, SLOT(handleTileClick(Tile*))); } } }
/* * recognizes character constants; * ASSUMPTION: signed/unsigned integers are compatible on the host */ ux_t (clx_ccon)(lex_t *t, int *w) { int cbyte; sz_t len = 0; const char *ss, *s, *e; ux_t lim, c; #ifdef HAVE_ICONV iconv_t *cd; #endif /* HAVE_ICONV */ assert(t); assert(w); assert(BUFUNIT > 2); assert(ty_wuchartype); /* ensures types initialized */ assert(xgeu(xmxu, TG_UCHAR_MAX)); assert(xgeu(xmxu, TG_WUCHAR_MAX)); assert(ir_cur); ss = s = LEX_SPELL(t); if (*s == 'L') *w = 1, s++; e = ++s; /* skips ' */ if (*w) { cbyte = ty_wchartype->size; assert(cbyte <= BUFUNIT); lim = TG_WUCHAR_MAX; #ifdef HAVE_ICONV cd = main_ntow; #endif /* HAVE_ICONV */ } else { cbyte = 1; lim = TG_UCHAR_MAX; #ifdef HAVE_ICONV cd = main_ntoe; #endif /* HAVE_ICONV */ } switch(*e) { case '\'': /* empty; diagnosed elsewhere */ case '\0': /* unclosed; diagnosed elsewhere */ return xO; case '\\': /* escape sequences */ assert(sizeof(c) >= cbyte); c = lex_bs(t, ss, &e, lim, "character constant"); #if HAVE_ICONV if (cd && !(s[1] == 'x' || (s[1] >= '0' && s[1] <= '7'))) { char x = xnu(c); ICONV_DECL(&x, 1); assert(xe(xiu(x), c)); obuf = strg_sbuf, obufv = strg_sbuf; olen = strg_slen, olenv = strg_slen; ICONV_DO(cd, 1, {}); strg_sbuf = obuf, strg_slen = olen; /* for later reuse */ len = strg_slen - len - olenv; } else { #else /* !HAVE_ICONV */ { #endif /* HAVE_ICONV */ if (*w) memcpy(strg_sbuf, (char *)&c + ((LITTLE)? 0: sizeof(c)-cbyte), cbyte); else strg_sbuf[0] = xnu(c); len = cbyte; } break; default: /* ordinary chars */ #ifdef HAVE_ICONV if (cd) { do { e++; } while(!FIRSTUTF8(*e)); { ICONV_DECL((char *)s, e - s); obuf = strg_sbuf, obufv = strg_sbuf; olen = strg_slen, olenv = strg_slen; ICONV_DO(cd, 1, {}); strg_sbuf = obuf, strg_slen = olen; /* for later reuse */ len = strg_slen - len - olenv; } } else { #else /* !HAVE_ICONV */ { #endif /* HAVE_ICONV */ assert(TG_CHAR_BIT == CHAR_BIT); if (*w) { strg_sbuf[(LITTLE)? 0: cbyte-1] = *e; memset(strg_sbuf + ((LITTLE)? 1: 0), 0, cbyte-1); } else strg_sbuf[0] = *e; e++; len = cbyte; } break; } if (*e != '\'' && *e != '\0') { for (s = e; *e != '\0' && *e != '\''; e++) continue; err_dpos((FIRSTUTF8(*s))? lmap_spell(t, ss, s, e): t->pos, ERR_CONST_LARGECHAR); } else if (len != cbyte) { err_dpos(t->pos, (*w)? ERR_CONST_WIDENOTFIT: ERR_CONST_MBNOTFIT); return xO; } c = xO; memcpy(&c, strg_sbuf + ((LITTLE)? 0: sizeof(c)-cbyte), cbyte); if (*w) { switch(main_opt()->wchart) { case 0: /* long */ c = SYM_CROPSL(c); break; case 1: /* ushort */ c = SYM_CROPUS(c); break; case 2: /* int */ c = SYM_CROPSI(c); break; } } else /* int from char */ c = (main_opt()->uchar)? SYM_CROPUC(c): SYM_CROPSC(c); return c; } /* * recognizes string literals */ static sz_t scon(lex_t *t, int *w) { int cbyte; lex_t *n; sz_t clen = 0, len = 0; const char *ss, *s, *e; ux_t lim; #ifdef HAVE_ICONV iconv_t *cd; #endif assert(t); assert(w); assert(BUFUNIT > 2); assert(ty_wuchartype); /* ensures types initialized */ assert(xgeu(xmxu, TG_UCHAR_MAX)); assert(xgeu(xmxu, TG_WUCHAR_MAX)); assert(ir_cur); ss = s = LEX_SPELL(t); if (*s == 'L') *w = 1, s++; e = ++s; /* skips " */ while ((n = lst_peekns())->id == LEX_SCON) { if (*n->spell == 'L') { if (!*w) { /* mb + wide = wide */ err_dmpos(n->pos, ERR_CONST_MBWIDE, t->pos, NULL); err_dmpos(n->pos, ERR_CONST_MBWIDESTD, t->pos, NULL); *w = 2; /* silences warnings */ } } else if (*w == 1) { /* wide + mb = wide */ err_dmpos(n->pos, ERR_CONST_MBWIDE, t->pos, NULL); err_dmpos(n->pos, ERR_CONST_MBWIDESTD, t->pos, NULL); *w = 2; /* silences warnings */ } while ((t = lst_append(t, lst_next()))->id != LEX_SCON) continue; } clx_cpos = lmap_range(t->next->pos, t->pos); if (*w) { cbyte = ty_wchartype->size; assert(cbyte <= BUFUNIT); lim = TG_WUCHAR_MAX; #ifdef HAVE_ICONV cd = main_ntow; #endif /* HAVE_ICONV */ } else { cbyte = 1; lim = TG_UCHAR_MAX; #ifdef HAVE_ICONV cd = main_ntoe; #endif /* HAVE_ICONV */ } n = t->next; while (1) { while (1) { while (*e != '\\' && *e != '"' && *e != '\0') e++; if (e > s) { /* ordinary chars */ #ifdef HAVE_ICONV if (cd) { ICONV_DECL((char *)s, e - s); obuf = strg_sbuf, obufv = strg_sbuf + len; olen = strg_slen, olenv = strg_slen - len; ICONV_INIT(cd); ICONV_DO(cd, 0, {}); strg_sbuf = obuf, strg_slen = olen; /* for later reuse */ len += (strg_slen - len - olenv); } else { #else /* !HAVE_ICONV */ { #endif /* HAVE_ICONV */ sz_t d = e - s; assert(TG_CHAR_BIT == CHAR_BIT); while (len + (d*cbyte) > strg_slen) /* rarely iterates */ MEM_RESIZE(strg_sbuf, strg_slen += BUFUNIT); if (*w) { while (s < e) { strg_sbuf[len + ((ir_cur->f.little_endian)? 0: cbyte-1)] = *s++; memset(strg_sbuf + len + ((ir_cur->f.little_endian)? 1: 0), 0, cbyte-1); len += cbyte; } } else { memcpy(&strg_sbuf[len], s, d); len += d; } } for (; s < e; s++) if (FIRSTUTF8(*s)) clen++; } if (*e == '\\') { /* escape sequences */ ux_t c; assert(sizeof(c) >= cbyte); c = lex_bs(n, ss, &e, lim, "string literal"); #if HAVE_ICONV if (cd) { /* inserts initial seq before every esc seq */ ICONV_DECL(NULL, 0); UNUSED(ilenv); UNUSED(ibufv); obuf = strg_sbuf, obufv = strg_sbuf + len; olen = strg_slen, olenv = strg_slen - len; ICONV_INIT(cd); strg_sbuf = obuf, strg_slen = olen; /* for later reuse */ len += (strg_slen - len - olenv); } if (cd && !(s[1] == 'x' || (s[1] >= '0' && s[1] <= '7'))) { char x = xnu(c); ICONV_DECL(&x, 1); assert(xe(xiu(x), c)); obuf = strg_sbuf, obufv = strg_sbuf + len; olen = strg_slen, olenv = strg_slen - len; ICONV_DO(cd, 0, {}); strg_sbuf = obuf, strg_slen = olen; /* for later reuse */ len += (strg_slen - len - olenv); } else { #else /* !HAVE_ICONV */ { #endif /* HAVE_ICONV */ if (len + cbyte > strg_slen) MEM_RESIZE(strg_sbuf, strg_slen += BUFUNIT); if (*w) { if (LITTLE != ir_cur->f.little_endian) CHGENDIAN(c, sizeof(c)); memcpy(strg_sbuf+len, &c + ((ir_cur->f.little_endian)? 0: sizeof(c)-cbyte), cbyte); len += cbyte; } else strg_sbuf[len++] = xnu(c); } clen++; s = e; continue; } break; /* " or NUL */ } if (n == t) { if (len + cbyte > strg_slen) MEM_RESIZE(strg_sbuf, strg_slen += BUFUNIT); memset(strg_sbuf+len, 0, cbyte); len += cbyte; clen++; break; } while ((n = n->next)->id != LEX_SCON) if (n->id < 0) strg_free((arena_t *)n->spell); ss = s = LEX_SPELL(n); if (*s == 'L') s++; e = ++s; /* skips " */ } if (len % cbyte != 0) err_dpos(clx_cpos, ERR_CONST_WIDENOTFIT); if (*w) clen = (len /= cbyte); if (clen - 1 > TL_STR_STD) { /* -1 for NUL; note TL_STR_STD may warp around */ err_dpos(clx_cpos, ERR_CONST_LONGSTR); err_dpos(clx_cpos, ERR_CONST_LONGSTRSTD, (unsigned long)TL_STR_STD); } return len; } #define N 0 /* no suffix */ #define U 1 /* suffix: U */ #define L 2 /* suffix: L */ #define X 3 /* suffix: UL */ #ifdef SUPPORT_LL #define M 4 /* suffix: LL */ #define Z 5 /* suffix: ULL */ #endif /* SUPPORT_LL */ #define D 0 /* base: decimal */ #define H 1 /* base: octal or hexadecimal */ /* * determines the type of an integer constant */ static const char *icon(const char *cs, ux_t n, int ovf, int base, const lmap_t *pos) { static struct tab { ux_t limit; ty_t *type; #ifdef SUPPORT_LL } tab[Z+1][H+1][7]; #else /* !SUPPORT_LL */ } tab[X+1][H+1][5]; #endif /* SUPPORT_LL */ int suffix; struct tab *p; assert(cs); assert(pos); assert(ty_inttype); #ifdef SUPPORT_LL assert(xgeu(xmxu, TG_ULLONG_MAX)); #else /* !SUPPORT_LL */ assert(xgeu(xmxu, TG_ULONG_MAX)); #endif /* SUPPORT_LL */ if (xe(tab[N][D][0].limit, xO)) { /* no suffix, decimal; different in C90 */ tab[N][D][0].limit = TG_INT_MAX; tab[N][D][0].type = ty_inttype; tab[N][D][1].limit = TG_LONG_MAX; tab[N][D][1].type = ty_longtype; #ifdef SUPPORT_LL tab[N][D][2].limit = TG_LLONG_MAX; tab[N][D][2].type = ty_llongtype; tab[N][D][3].limit = TG_ULLONG_MAX; tab[N][D][3].type = ty_ullongtype; tab[N][D][4].limit = xmxu; tab[N][D][4].type = ty_inttype; #else /* SUPPORT_LL */ tab[N][D][2].limit = TG_ULONG_MAX; tab[N][D][2].type = ty_ulongtype; tab[N][D][3].limit = xmxu; tab[N][D][3].type = ty_inttype; #endif /* SUPPORT_LL */ /* no suffix, octal or hex */ tab[N][H][0].limit = TG_INT_MAX; tab[N][H][0].type = ty_inttype; tab[N][H][1].limit = TG_UINT_MAX; tab[N][H][1].type = ty_unsignedtype; tab[N][H][2].limit = TG_LONG_MAX; tab[N][H][2].type = ty_longtype; tab[N][H][3].limit = TG_ULONG_MAX; tab[N][H][3].type = ty_ulongtype; #ifdef SUPPORT_LL tab[N][H][4].limit = TG_LLONG_MAX; tab[N][H][4].type = ty_llongtype; tab[N][H][5].limit = TG_ULLONG_MAX; tab[N][H][5].type = ty_ullongtype; tab[N][H][6].limit = xmxu; tab[N][H][6].type = ty_inttype; #else /* !SUPPORT_LL */ tab[N][H][4].limit = xmxu; tab[N][H][4].type = ty_inttype; #endif /* SUPPORT_LL */ /* U, decimal, octal or hex */ tab[U][H][0].limit = tab[U][D][0].limit = TG_UINT_MAX; tab[U][H][0].type = tab[U][D][0].type = ty_unsignedtype; tab[U][H][1].limit = tab[U][D][1].limit = TG_ULONG_MAX; tab[U][H][1].type = tab[U][D][1].type = ty_ulongtype; #ifdef SUPPORT_LL tab[U][H][2].limit = tab[U][D][2].limit = TG_ULLONG_MAX; tab[U][H][2].type = tab[U][D][2].type = ty_ullongtype; tab[U][H][3].limit = tab[U][D][3].limit = xmxu; tab[U][H][3].type = tab[U][D][3].type = ty_inttype; #else /* !SUPPORT_LL */ tab[U][H][2].limit = tab[U][D][2].limit = xmxu; tab[U][H][2].type = tab[U][D][2].type = ty_inttype; #endif /* SUPPORT_LL */ /* L, decimal; different in C90 */ tab[L][D][0].limit = TG_LONG_MAX; tab[L][D][0].type = ty_longtype; #ifdef SUPPORT_LL tab[L][D][1].limit = TG_LLONG_MAX; tab[L][D][1].type = ty_llongtype; tab[L][D][2].limit = TG_ULLONG_MAX; tab[L][D][2].type = ty_ullongtype; tab[L][D][3].limit = xmxu; tab[L][D][3].type = ty_inttype; #else /* !SUPPORT_LL */ tab[L][D][1].limit = TG_ULONG_MAX; tab[L][D][1].type = ty_ulongtype; tab[L][D][2].limit = xmxu; tab[L][D][2].type = ty_inttype; #endif /* SUPPORT_LL */ /* L, octal or hex */ tab[L][H][0].limit = TG_LONG_MAX; tab[L][H][0].type = ty_longtype; tab[L][H][1].limit = TG_ULONG_MAX; tab[L][H][1].type = ty_ulongtype; #ifdef SUPPORT_LL tab[L][H][2].limit = TG_LLONG_MAX; tab[L][H][2].type = ty_llongtype; tab[L][H][3].limit = TG_ULLONG_MAX; tab[L][H][3].type = ty_ullongtype; tab[L][H][4].limit = xmxu; tab[L][H][4].type = ty_inttype; #else /* !SUPPORT_LL */ tab[L][H][2].limit = xmxu; tab[L][H][2].type = ty_inttype; #endif /* SUPPORT_LL */ /* UL, decimal, octal or hex */ tab[X][H][0].limit = tab[X][D][0].limit = TG_ULONG_MAX; tab[X][H][0].type = tab[X][D][0].type = ty_ulongtype; #ifdef SUPPORT_LL tab[X][H][1].limit = tab[X][D][1].limit = TG_ULLONG_MAX; tab[X][H][1].type = tab[X][D][1].type = ty_ullongtype; tab[X][H][2].limit = tab[X][D][2].limit = xmxu; tab[X][H][2].type = tab[X][D][2].type = ty_inttype; #else /* !SUPPORT_LL */ tab[X][H][1].limit = tab[X][D][1].limit = xmxu; tab[X][H][1].type = tab[X][D][1].type = ty_inttype; #endif /* SUPPORT_LL */ #ifdef SUPPORT_LL /* LL, decimal, octal or hex */ tab[M][H][0].limit = tab[M][D][0].limit = TG_LLONG_MAX; tab[M][H][0].type = tab[M][D][0].type = ty_llongtype; tab[M][H][1].limit = tab[M][D][1].limit = TG_ULLONG_MAX; tab[M][H][1].type = tab[M][D][1].type = ty_ullongtype; tab[M][H][2].limit = tab[M][D][2].limit = xmxu; tab[M][H][2].type = tab[M][D][2].type = ty_inttype; /* ULL, decimal, octal or hex */ tab[Z][H][0].limit = tab[Z][D][0].limit = TG_ULLONG_MAX; tab[Z][H][0].type = tab[Z][D][0].type = ty_ullongtype; tab[Z][H][1].limit = tab[Z][D][1].limit = xmxu; tab[Z][H][1].type = tab[Z][D][1].type = ty_inttype; #endif /* SUPPORT_LL */ } base = (base == 10)? D: H; suffix = N; if (tolower((unsigned char)cs[0]) == 'l') { #ifdef SUPPORT_LL if (cs[1] == cs[0]) cs += 2, suffix = M; else #endif /* SUPPORT_LL */ cs++, suffix = L; } if (tolower((unsigned char)cs[0]) == 'u') cs++, suffix++; if (suffix <= U && tolower((unsigned char)cs[0]) == 'l') { #ifdef SUPPORT_LL if (cs[1] == cs[0]) cs += 2, suffix += M; else #endif /* SUPPORT_LL */ cs++, suffix += L; } for (p = tab[suffix][base]; xgu(n, p->limit); p++) continue; if (ovf || (xe(p->limit, xmxu) && p->type == ty_inttype)) { err_dpos(pos, ERR_CONST_LARGEINT); #ifdef SUPPORT_LL n = TG_ULLONG_MAX; tval.type = ty_ullongtype; #else /* !SUPPORT_LL */ n = TG_ULONG_MAX; tval.type = ty_ulongtype; #endif /* SUPPORT_LL */ } else tval.type = p->type; #ifdef SUPPORT_LL if (suffix % 2 == 0 && base == D && TY_ISUNSIGN(p->type)) err_dpos(pos, ERR_CONST_LARGEUNSIGN); else if (tval.type == ty_llongtype && (suffix == N || suffix == L) && xleu(n, TG_ULONG_MAX)) { err_dpos(pos, ERR_CONST_UNSIGNINC90); if (main_opt()->std == 1) tval.type = ty_ulongtype; } if ((TY_ISLLONG(tval.type) || TY_ISULLONG(tval.type))) err_dpos(pos, ERR_CONST_LLONGINC90, tval.type); #endif /* SUPPORT_LL */ #ifdef SUPPORT_LL if (tval.type->op == TY_INT || tval.type->op == TY_LONG || tval.type->op == TY_LLONG) #else /* !SUPPORT_LL */ if (tval.type->op == TY_INT || tval.type->op == TY_LONG) #endif /* SUPPORT_LL */ tval.u.c.v.s = n; else tval.u.c.v.u = n; return cs; } #undef H #undef D #undef Z #undef M #undef X #undef L #undef U #undef N /* * determines the type of a floating constant; * ASSUMPTION: fp types of the host are same as those of the target */ static const char *fcon(const char *cs, long double ld, const lmap_t *pos) { assert(cs); assert(pos); assert(ty_floattype); /* ensures types initiailized */ switch(*cs) { case 'f': case 'F': cs++; /* skips f or F */ if ((OVF(ld) && errno == ERANGE) || ld > TG_FLT_MAX) { err_dpos(pos, ERR_CONST_LARGEFP); ld = TG_FLT_MAX; } else if ((ld == 0.0 && errno == ERANGE) || (ld > 0.0 && ld < TG_FLT_MIN)) { err_dpos(pos, ERR_CONST_TRUNCFP); ld = 0.0f; } tval.type = ty_floattype; tval.u.c.v.f = (float)ld; break; case 'l': case 'L': cs++; /* skips l or L */ if ((OVF(ld) && errno == ERANGE) || ld > TG_LDBL_MAX) { err_dpos(pos, ERR_CONST_LARGEFP); ld = TG_LDBL_MAX; } else if ((ld == 0.0 && errno == ERANGE) || (ld > 0.0 && ld < TG_LDBL_MIN)) err_dpos(pos, ERR_CONST_TRUNCFP); tval.type = ty_ldoubletype; tval.u.c.v.ld = (long double)ld; break; default: if ((OVF(ld) && errno == ERANGE) || ld > TG_DBL_MAX) { err_dpos(pos, ERR_CONST_LARGEFP); ld = (double)TG_DBL_MAX; } else if ((ld == 0.0 && errno == ERANGE) || (ld > 0.0 && ld < TG_DBL_MIN)) { err_dpos(pos, ERR_CONST_TRUNCFP); ld = 0.0; } tval.type = ty_doubletype; tval.u.c.v.d = (double)ld; break; } return cs; } /* * recognizes integer or floating constants; * ASSUMPTION: strtold() supported on the host */ static int ifcon(lex_t *t) { ux_t n; int b, d; long double ld; int err = 0, ovf = 0; const char *ss, *s; char *p = "0123456789abcdef"; /* no const for reuse with strtold() */ assert(t); ss = s = LEX_SPELL(t); if (*s == '.') goto fcon; n = xO; if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X') && isxdigit(((unsigned char *)s)[2])) { /* 0x[0-9] */ b = 16; s++; /* skips 0 */ while (isxdigit(*(unsigned char *)++s)) { d = strchr(p, tolower(*(unsigned char *)s)) - p; if (xt(xba(n, xbc(xsrl(xmxu, 4))))) ovf = 1; n = xau(xsl(n, 4), xiu(d)); } s = icon(s, n, ovf, b, t->pos); b = LEX_ICON; } else { /* 0 or other digits */ b = (*s == '0')? 8: 10; if (b == 8) while (isdigit(*(unsigned char *)s)) { d = *s++ - '0'; if (*s == '8' || *s == '9') p = (char *)s, err = 1; if (xt(xba(n, xbc(xsrl(xmxu, 3))))) ovf = 1; n = xau(xsl(n, 3), xiu(d)); } else /* b == 10 */ while (isdigit(*(unsigned char *)s)) { d = *s++ - '0'; if (xgu(n, xdu(xsu(xmxu, xiu(d)), xiu(10)))) ovf = 1; n = xau(xmu(xiu(10), n), xiu(d)); } fcon: if (b != 16 && (*s == '.' || *s == 'e' || *s == 'E')) { if (*s == '.') do { s++; /* skips . and digits */ } while(isdigit(*s)); if (*s == 'e' || *s == 'E') { if (*++s == '-' || *s == '+') /* skips e or E */ s++; /* skips - or + */ if (!isdigit(*s)) { err_dpos(lmap_spell(t, ss, s, s+1), ERR_CONST_NOEXPDIG); err = 1; } } if (!err) { errno = 0; ld = strtold(ss, &p); s = fcon((s = p), ld, t->pos); } b = LEX_FCON; } else { if (err) err_dpos(lmap_spell(t, ss, p, p+1), ERR_CONST_ILLOCTESC); else s = icon(s, n, ovf, b, t->pos); b = LEX_ICON; } } if (*s && !err) { for (p = (char *)s; *p; p++) continue; err_dpos(lmap_spell(t, ss, s, p), ERR_CONST_PPNUMSFX, s, b); err = 1; } clx_sym = (err)? NULL: &tval; return b; }
SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) : QWidget(0, f), curAlignment(0), m_node(node) { // set reference point, paddings int paddingRight = 50; int paddingTop = 50; int titleVersionVSpace = 17; int titleCopyrightVSpace = 40; float fontFactor = 1.0; float devicePixelRatio = 1.0; #if QT_VERSION > 0x050100 devicePixelRatio = static_cast<QGuiApplication*>(QCoreApplication::instance())->devicePixelRatio(); #endif // define text to place QString titleText = tr(PACKAGE_NAME); QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion())); QString copyrightText = QString::fromUtf8(CopyrightHolders(strprintf("\xc2\xA9 %u-%u ", 2009, COPYRIGHT_YEAR)).c_str()); QString titleAddText = networkStyle->getTitleAddText(); QString font = QApplication::font().toString(); // create a bitmap according to device pixelratio QSize splashSize(480*devicePixelRatio,320*devicePixelRatio); pixmap = QPixmap(splashSize); #if QT_VERSION > 0x050100 // change to HiDPI if it makes sense pixmap.setDevicePixelRatio(devicePixelRatio); #endif QPainter pixPaint(&pixmap); pixPaint.setPen(QColor(100,100,100)); // draw a slightly radial gradient QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, QColor(247,247,247)); QRect rGradient(QPoint(0,0), splashSize); pixPaint.fillRect(rGradient, gradient); // draw the digibyte icon, expected size of PNG: 1024x1024 QRect rectIcon(QPoint(-150,-122), QSize(430,430)); const QSize requiredSize(1024,1024); QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize)); pixPaint.drawPixmap(rectIcon, icon); // check font size and drawing with pixPaint.setFont(QFont(font, 33*fontFactor)); QFontMetrics fm = pixPaint.fontMetrics(); int titleTextWidth = fm.width(titleText); if (titleTextWidth > 176) { fontFactor = fontFactor * 176 / titleTextWidth; } pixPaint.setFont(QFont(font, 33*fontFactor)); fm = pixPaint.fontMetrics(); titleTextWidth = fm.width(titleText); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText); pixPaint.setFont(QFont(font, 15*fontFactor)); // if the version string is too long, reduce size fm = pixPaint.fontMetrics(); int versionTextWidth = fm.width(versionText); if(versionTextWidth > titleTextWidth+paddingRight-10) { pixPaint.setFont(QFont(font, 10*fontFactor)); titleVersionVSpace -= 5; } pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText); // draw copyright stuff { pixPaint.setFont(QFont(font, 10*fontFactor)); const int x = pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight; const int y = paddingTop+titleCopyrightVSpace; QRect copyrightRect(x, y, pixmap.width() - x - paddingRight, pixmap.height() - y); pixPaint.drawText(copyrightRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, copyrightText); } // draw additional text if special network if(!titleAddText.isEmpty()) { QFont boldFont = QFont(font, 10*fontFactor); boldFont.setWeight(QFont::Bold); pixPaint.setFont(boldFont); fm = pixPaint.fontMetrics(); int titleAddTextWidth = fm.width(titleAddText); pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText); } pixPaint.end(); // Set window title setWindowTitle(titleText + " " + titleAddText); // Resize window and move to center of desktop, disallow resizing QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio)); resize(r.size()); setFixedSize(r.size()); move(QApplication::desktop()->screenGeometry().center() - r.center()); subscribeToCoreSignals(); installEventFilter(this); }
QSize pDockWidgetTitleBar::windowIconSize() const { const int size = orientation() == Qt::Horizontal ? height() -2 : width() -2; return icon().isNull() ? QSize() : QSize( size, size ); }
/// Constructor AlcFrame::AlcFrame (const wxString & title): wxFrame ((wxFrame *) NULL, -1, title) { // Give it an icon #ifdef __WXMSW__ wxIcon icon(wxT("alc")); #else wxIcon icon; icon.CopyFromBitmap(AlcPix::getPixmap(wxT("alc"))); #endif SetIcon (icon); // Status Bar CreateStatusBar (); SetStatusText (_("Welcome!")); // Unused dialog for now m_progressBar = NULL; // Frame Vertical sizer m_frameVBox = new wxBoxSizer (wxVERTICAL); // Add Main panel to frame (needed by win32 for padding sub panels) m_mainPanel = new wxPanel (this, -1); // Main Panel Vertical Sizer m_mainPanelVBox = new wxBoxSizer (wxVERTICAL); // Main Panel static line m_staticLine = new wxStaticLine (m_mainPanel, -1); m_mainPanelVBox->Add (m_staticLine, 0, wxALL | wxGROW); // Input Parameters m_inputSBox = new wxStaticBox (m_mainPanel, -1, _("Input parameters")); m_inputSBoxSizer = new wxStaticBoxSizer (m_inputSBox, wxHORIZONTAL); // Input Grid m_inputFlexSizer = new wxFlexGridSizer (6, 2, 5, 10); // Left col is growable m_inputFlexSizer->AddGrowableCol (0); // Static texts m_inputFileStaticText=new wxStaticText(m_mainPanel, -1, _("File to Hash"), wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE); m_inputAddStaticText=new wxStaticText(m_mainPanel, -1, _("Add Optional URLs for this file"), wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE); // Text ctrls m_inputFileTextCtrl = new wxTextCtrl (m_mainPanel,-1,wxEmptyString, wxDefaultPosition, wxSize(300,-1)); m_inputFileTextCtrl-> SetToolTip (_ ("Enter here the file you want to compute the eD2k link")); m_inputAddTextCtrl = new wxTextCtrl (m_mainPanel,-1,wxEmptyString, wxDefaultPosition, wxSize(300,-1)); m_inputAddTextCtrl-> SetToolTip (_ ("Enter here the URL you want to add to the eD2k link: Add / at the end to let aLinkCreator append the current file name")); // List box m_inputUrlListBox = new wxListBox(m_mainPanel, -1, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB | wxLB_HSCROLL); // Buttons m_inputFileBrowseButton = new wxButton (m_mainPanel, ID_BROWSE_BUTTON, wxString (_("Browse"))); m_inputAddButton = new wxButton (m_mainPanel, ID_ADD_BUTTON, wxString (_("Add"))); // Button bar m_buttonUrlVBox = new wxBoxSizer (wxVERTICAL); m_removeButton = new wxButton (m_mainPanel, ID_REMOVE_BUTTON, wxString (_("Remove"))); m_clearButton = new wxButton (m_mainPanel, ID_CLEAR_BUTTON, wxString (_("Clear"))); m_buttonUrlVBox->Add (m_removeButton, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 5); m_buttonUrlVBox->Add (m_clearButton, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 5); // Check button m_parthashesCheck = new wxCheckBox (m_mainPanel, ID_PARTHASHES_CHECK, _ ("Create link with part-hashes")); m_parthashesCheck->SetValue(false); m_parthashesCheck-> SetToolTip (_ ("Help to spread new and rare files faster, at the cost of an increased link size")); // Add to sizers m_inputFlexSizer->Add (m_inputFileStaticText, 1, wxGROW | wxALIGN_BOTTOM | wxTOP, 10); m_inputFlexSizer->Add (1,1); m_inputFlexSizer->Add (m_inputFileTextCtrl, 1, wxGROW | wxALIGN_TOP , 0); m_inputFlexSizer->Add (m_inputFileBrowseButton, 0, wxGROW | wxALIGN_TOP , 0); m_inputFlexSizer->Add (m_inputAddStaticText, 1, wxGROW | wxALIGN_BOTTOM | wxTOP, 10); m_inputFlexSizer->Add (1,1); m_inputFlexSizer->Add (m_inputAddTextCtrl, 1, wxGROW | wxALIGN_TOP , 0); m_inputFlexSizer->Add (m_inputAddButton, 0, wxGROW | wxALIGN_TOP , 0); m_inputFlexSizer->Add (m_inputUrlListBox, 0, wxGROW | wxALIGN_CENTER , 0); m_inputFlexSizer->Add (m_buttonUrlVBox, 0, wxGROW | wxALIGN_CENTER , 0); m_inputFlexSizer->Add (m_parthashesCheck, 0, wxGROW | wxALIGN_CENTER | wxTOP, 10); m_inputFlexSizer->Add (1,1); m_inputSBoxSizer->Add (m_inputFlexSizer, 1, wxGROW | wxALIGN_CENTER | wxALL, 10); m_mainPanelVBox->Add (m_inputSBoxSizer, 0, wxGROW | wxALIGN_CENTER | wxALL, 10); #ifdef WANT_MD4SUM // MD4 Hash Vertical Box Sizer m_md4HashSBox = new wxStaticBox (m_mainPanel, -1, _("MD4 File Hash")); m_md4HashSBoxSizer = new wxStaticBoxSizer (m_md4HashSBox, wxHORIZONTAL); // MD4 Hash results m_md4HashTextCtrl = new wxTextCtrl( m_mainPanel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); m_md4HashSBoxSizer->Add (m_md4HashTextCtrl, 1, wxALL | wxALIGN_CENTER, 5); m_mainPanelVBox->Add( m_md4HashSBoxSizer, 0, wxALL | wxGROW, 10 ); #endif // Hash Vertical Box Sizer m_e2kHashSBox = new wxStaticBox (m_mainPanel, -1, _("eD2k File Hash")); m_e2kHashSBoxSizer = new wxStaticBoxSizer (m_e2kHashSBox, wxHORIZONTAL); // Hash results m_e2kHashTextCtrl = new wxTextCtrl( m_mainPanel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); m_e2kHashSBoxSizer->Add (m_e2kHashTextCtrl, 1, wxALL | wxALIGN_CENTER, 5); m_mainPanelVBox->Add( m_e2kHashSBoxSizer, 0, wxALL | wxGROW, 10 ); // Ed2k Vertical Box Sizer m_ed2kSBox = new wxStaticBox (m_mainPanel, -1, _("eD2k link")); m_ed2kSBoxSizer = new wxStaticBoxSizer (m_ed2kSBox, wxVERTICAL); // Ed2k results m_ed2kTextCtrl = new wxTextCtrl( m_mainPanel, -1, wxEmptyString, wxDefaultPosition, wxSize(-1,60), wxTE_MULTILINE|wxTE_READONLY|wxVSCROLL ); m_ed2kSBoxSizer->Add (m_ed2kTextCtrl, 1, wxALL | wxGROW, 5); m_mainPanelVBox->Add( m_ed2kSBoxSizer, 1, wxALL | wxGROW, 10 ); // Button bar m_buttonHBox = new wxBoxSizer (wxHORIZONTAL); m_startButton = new wxButton (m_mainPanel, ID_START_BUTTON, wxString (_("Start"))); m_saveButton = new wxButton (m_mainPanel, ID_SAVEAS_BUTTON, wxString (_("Save"))); m_copyButton = new wxButton (m_mainPanel, ID_COPY_BUTTON, wxString (_("Copy to clipboard"))); m_closeButton = new wxButton (m_mainPanel, ID_EXIT_BUTTON, wxString (_("Exit"))); m_buttonHBox->Add (m_copyButton, 0, wxALIGN_LEFT | wxALL, 5); m_buttonHBox->Add(1,1,1); m_buttonHBox->Add (m_startButton, 0, wxALIGN_RIGHT | wxALL, 5); m_buttonHBox->Add (m_saveButton, 0, wxALIGN_RIGHT | wxALL, 5); m_buttonHBox->Add (m_closeButton, 0, wxALIGN_RIGHT | wxALL, 5); m_mainPanelVBox->Add (m_buttonHBox, 0, wxALL | wxGROW, 5); // Toolbar Pixmaps m_toolBarBitmaps[0] = AlcPix::getPixmap(wxT("open")); m_toolBarBitmaps[1] = AlcPix::getPixmap(wxT("copy")); m_toolBarBitmaps[2] = AlcPix::getPixmap(wxT("saveas")); m_toolBarBitmaps[3] = AlcPix::getPixmap(wxT("about")); // Constructing toolbar m_toolbar = new wxToolBar (this, -1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxTB_FLAT); m_toolbar->SetToolBitmapSize (wxSize (32, 32)); m_toolbar->SetMargins (2, 2); m_toolbar->AddTool (ID_BAR_OPEN, _("Open"), m_toolBarBitmaps[0], _("Open a file to compute its eD2k link")); m_toolbar->AddTool (ID_BAR_COPY, _("Copy"), m_toolBarBitmaps[1], _("Copy computed eD2k link to clipboard")); m_toolbar->AddTool (ID_BAR_SAVEAS, _("Save as"), m_toolBarBitmaps[2], _("Save computed eD2k link to file")); m_toolbar->AddSeparator (); m_toolbar->AddTool (ID_BAR_ABOUT, _("About"), m_toolBarBitmaps[3], _("About aLinkCreator")); m_toolbar->Realize (); SetToolBar (m_toolbar); // Main panel Layout m_mainPanel->SetAutoLayout(true); m_mainPanel->SetSizerAndFit (m_mainPanelVBox); // Frame Layout m_frameVBox->Add (m_mainPanel, 1, wxALL | wxGROW, 0); SetAutoLayout (true); SetSizerAndFit (m_frameVBox); m_startButton->SetFocus(); }
MainWindow::MainWindow(void): wxFrame(NULL, wxID_ANY, wxString(wxT("CNC – øídicí systém")), wxDefaultPosition, wxSize(1000, 600), wxDEFAULT_FRAME_STYLE | wxMAXIMIZE) { //Naètení ikony hlavního okna wxIcon icon(wxT("IDI_ICON1"), wxBITMAP_TYPE_ICO_RESOURCE); if(!icon.IsOk()) { PostErrorMessage(wxT("Nepodaøilo ase naèíst ikonu hlavního okna")); } SetIcon(icon); //StatusBar statusBar = CreateStatusBar(4); statusBar->SetStatusText(wxT("Nepøipojeno k intepolátoru"), 0); statusBar->SetStatusText(wxT("Žádný program"), 1); statusBar->SetStatusText(wxT("Neznámá pozice"), 2); statusBar->SetStatusText(wxT("Stav neurèen"), 3); //Menu menu = new wxMenuBar; file = new wxMenu; file->Append(wxID_OPEN, wxT("Otevøít soubor s intrukcemi"), wxT("Otevøít soubor s programem"), false); file->Append(ID_OPEN_GCODE, wxT("Otevøít G-kód"), wxT("Otevøít soubor s programem"), false); file->Append(wxID_EXIT, wxT("&Konec")); menu->Append(file, wxT("&Soubor")); view = new wxMenu; view->Append(ID_RESETVIEW, wxT("Resetovat zobrazení drah"), wxT("Obnoví zobrazení"), false); view->Append(ID_RESETTRAJECTORY, wxT("Smazat stopu"), wxT("Smaže stopu nástroje"), false); view->Append(ID_TOGGLETRAJECTORY, wxT("Vypnout/zapnout stopu"), wxT(""), false); menu->Append(view, wxT("&Náhled")); SetMenuBar(menu); //Connect menus and buttons to the functions Connect(wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainWindow::OnOpen)); Connect(ID_OPEN_GCODE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainWindow::OnOpenGcode)); Connect(ID_RESETVIEW, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainWindow::OnViewReset)); Connect(ID_RESETTRAJECTORY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainWindow::OnTrajectoryReset)); Connect(ID_TOGGLETRAJECTORY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainWindow::OnTrajectoryToggle)); //Toolbar toolbar = CreateToolBar(); toolbar->SetToolBitmapSize(wxSize(48, 48)); toolbar->AddSeparator(); toolbar->AddTool(2, wxBitmap(wxT("IDB_STARTPROGRAM"), wxBITMAP_TYPE_BMP_RESOURCE), wxT("Spustit program")); toolbar->AddTool(3, wxBitmap(wxT("IDB_PAUSEPROGRAM"), wxBITMAP_TYPE_BMP_RESOURCE), wxT("Pozastavit program")); toolbar->AddTool(4, wxBitmap(wxT("IDB_STOPPROGRAM"), wxBITMAP_TYPE_BMP_RESOURCE), wxT("Zastavit program")); toolbar->Realize(); toolbar->EnableTool(1, false); toolbar->EnableTool(3, false); toolbar->EnableTool(4, false); SetStatusBarPane(-1); //Connect icons to the function Connect(2, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainWindow::OnRunProgram)); Connect(3, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainWindow::OnPauseProgram)); Connect(4, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainWindow::OnStopProgram)); //Splitter window topSplit = new wxSplitterWindow(this); //Content of the left leftPanel = new wxPanel(topSplit, 0, 0, 150, 150); //Content of the right downSplit = new wxSplitterWindow(topSplit); //Content of the downSplit middlePanel = new PreviewWindow(downSplit, 0, 0, 150, 150); rightPanel = new wxPanel(downSplit, 0, 0, 150, 150); //Split the windows topSplit->SplitVertically(leftPanel, downSplit, 250); downSplit->SplitVertically(middlePanel, rightPanel, -300); middlePanel->Reset(); topSplit->SetSashGravity(0); downSplit->SetSashGravity(1); topSplit->SetMinimumPaneSize(150); downSplit->SetMinimumPaneSize(200); //Content of the right panel codeView = new wxTextCtrl(rightPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_AUTO_SCROLL | wxTE_READONLY | wxTE_RICH2 | wxHSCROLL | wxTE_NOHIDESEL); wxBoxSizer *sizeRight = new wxBoxSizer(wxVERTICAL); sizeRight->Add(codeView, 1, wxEXPAND | wxALL, 0); rightPanel->SetSizer(sizeRight); //Set the font wxFont codeFont(15, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL, false); codeView->SetDefaultStyle(wxTextAttr(wxColour((unsigned long)(0)), wxNullColour, codeFont)); //Initialization of USB - receivng messages obaout device state HWND hwnd = HWND(GetHWND()); DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) ); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_classguid = DEVICE_INTERFACE; if(!RegisterDeviceNotification(hwnd, (void*)(&NotificationFilter), DEVICE_NOTIFY_WINDOW_HANDLE)) { wxString err; err << wxT("Chyba pøi incializaci notifikace pro zaøízení - chyba ") << GetLastError(); PostErrorMessage(err); } //Centre window Center(); Maximize(); middlePanel->Reset(); }
/** * Produce a data siutable for view */ QVariant ClangCodeCompletionItem::data( const QModelIndex& index , const int role , const bool use_prefix_column ) const { assert("Sanity check" && index.isValid()); // auto result = QVariant{}; switch (role) { #if 0 // WARNING Assigning match quality doesn't looks (literally) a good idea! // It's really look ugly... case KTextEditor::CodeCompletionModel::MatchQuality: result = int(100u - m_priority) * 10; break; #endif case KTextEditor::CodeCompletionModel::IsExpandable: result = !m_comment.isEmpty(); break; case KTextEditor::CodeCompletionModel::ExpandingWidget: { auto* label = new QLabel{m_comment}; label->setWordWrap(true); label->setAlignment(Qt::AlignLeft | Qt::AlignTop); label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); label->resize(label->minimumSizeHint()); result.setValue<QWidget*>(label); break; } case KTextEditor::CodeCompletionModel::CompletionRole: result = completionProperty(); break; case Qt::DecorationRole: if (!use_prefix_column && index.column() == KTextEditor::CodeCompletionModel::Icon) result = icon(); break; case Qt::DisplayRole: switch (index.column()) { case KTextEditor::CodeCompletionModel::Prefix: if (use_prefix_column) result = renderPrefix(); break; case KTextEditor::CodeCompletionModel::Name: if (use_prefix_column) result = m_text; else result = QString{renderPrefix() + " " + m_text}; break; case KTextEditor::CodeCompletionModel::Postfix: if (m_deprecated) result = DEPRECATED_STR; break; case KTextEditor::CodeCompletionModel::Arguments: result = renderPlaceholders(m_after); break; // NOTE This would just merge `scope` text w/ name and finally // everything would look ugly... Anyway we have groups to join // completion items by parent/scope and it looks better than this feature... case KTextEditor::CodeCompletionModel::Scope: break; default: break; } break; default: #if 0 kDebug(DEBUG_AREA) << "Role" << role << "requested for" << index; #endif break; } return result; }
void ProjectLeafNode::openItem( ProjectTree& tree ) { std::string pathToResource = getRelativePath(); ResourceManagementUtil::editResource( pathToResource, icon(0) ); }
TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent ) : QSystemTrayIcon( parent ) , m_currentAnimationFrame( 0 ) , m_showWindowAction( 0 ) , m_stopContinueAfterTrackAction( 0 ) , m_loveTrackAction( 0 ) { #ifdef Q_OS_MAC QIcon icon( RESPATH "icons/tomahawk-grayscale-icon-128x128.png" ); #else QIcon icon( RESPATH "icons/tomahawk-icon-128x128.png" ); #endif setIcon( icon ); refreshToolTip(); m_contextMenu = new QMenu(); setContextMenu( m_contextMenu ); m_loveTrackAction = new QAction( this ); m_stopContinueAfterTrackAction = new QAction( this ); ActionCollection *ac = ActionCollection::instance(); m_contextMenu->addAction( ac->getAction( "playPause" ) ); m_contextMenu->addAction( ac->getAction( "stop" ) ); m_contextMenu->addSeparator(); m_contextMenu->addAction( m_loveTrackAction ); m_contextMenu->addAction( m_stopContinueAfterTrackAction ); m_contextMenu->addSeparator(); m_contextMenu->addAction( ac->getAction( "previousTrack" ) ); m_contextMenu->addAction( ac->getAction( "nextTrack" ) ); m_contextMenu->addSeparator(); m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) ); #ifdef Q_OS_MAC // On mac you can close the windows while leaving the app open. We then need a way to show the main window again m_contextMenu->addSeparator(); m_showWindowAction = m_contextMenu->addAction( tr( "Hide Tomahawk Window" ) ); m_showWindowAction->setData( true ); connect( m_showWindowAction, SIGNAL( triggered() ), this, SLOT( showWindow() ) ); connect( m_contextMenu, SIGNAL( aboutToShow() ), this, SLOT( menuAboutToShow() ) ); #endif m_contextMenu->addSeparator(); m_contextMenu->addAction( ac->getAction( "quit" ) ); connect( m_loveTrackAction, SIGNAL( triggered() ), SLOT( loveTrackTriggered() ) ); connect( m_stopContinueAfterTrackAction, SIGNAL( triggered() ), SLOT( stopContinueAfterTrackActionTriggered() ) ); connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) ); connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlay() ) ); connect( AudioEngine::instance(), SIGNAL( resumed() ), SLOT( onResume() ) ); connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onStop() ) ); connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( onPause() ) ); connect( AudioEngine::instance(), SIGNAL( stopAfterTrackChanged() ), SLOT( onStopContinueAfterTrackChanged() ) ); connect( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) ); connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) ); onStop(); show(); }
/*! Use icon() instead. */ QIcon QToolButton::onIconSet() const { return icon(); }
int main(int argc, char *argv[]) { QString error; QString arg; QString collectionFile; QString configFile; QString basePath; bool showHelp = false; bool showVersion = false; QCoreApplication app(argc, argv); #ifndef Q_OS_WIN32 QTranslator translator; QTranslator qtTranslator; QTranslator qt_helpTranslator; QString sysLocale = QLocale::system().name(); QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir) && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir) && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) { app.installTranslator(&translator); app.installTranslator(&qtTranslator); app.installTranslator(&qt_helpTranslator); } #endif // Q_OS_WIN32 for (int i=1; i<argc; ++i) { arg = QString::fromLocal8Bit(argv[i]); if (arg == QLatin1String("-o")) { if (++i < argc) { QFileInfo fi(QString::fromLocal8Bit(argv[i])); collectionFile = fi.absoluteFilePath(); } else { error = QCG::tr("Missing output file name."); } } else if (arg == QLatin1String("-h")) { showHelp = true; } else if (arg == QLatin1String("-v")) { showVersion = true; } else { QFileInfo fi(arg); configFile = fi.absoluteFilePath(); basePath = fi.absolutePath(); } } if (showVersion) { fputs(qPrintable(QCG::tr("Qt Collection Generator version 1.0 (Qt %1)\n") .arg(QT_VERSION_STR)), stdout); return 0; } if (configFile.isEmpty() && !showHelp) error = QCG::tr("Missing collection config file."); QString help = QCG::tr("\nUsage:\n\n" "qcollectiongenerator <collection-config-file> [options]\n\n" " -o <collection-file> Generates a collection file\n" " called <collection-file>. If\n" " this option is not specified\n" " a default name will be used.\n" " -v Displays the version of\n" " qcollectiongenerator.\n\n"); if (showHelp) { fputs(qPrintable(help), stdout); return 0; }else if (!error.isEmpty()) { fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help)); return -1; } QFile file(configFile); if (!file.open(QIODevice::ReadOnly)) { fputs(qPrintable(QCG::tr("Could not open %1.\n").arg(configFile)), stderr); return -1; } if (collectionFile.isEmpty()) { QFileInfo fi(configFile); collectionFile = basePath + QDir::separator() + fi.baseName() + QLatin1String(".qhc"); } fputs(qPrintable(QCG::tr("Reading collection config file...\n")), stdout); CollectionConfigReader config; config.readData(file.readAll()); if (config.hasError()) { fputs(qPrintable(QCG::tr("Collection config file error: %1\n") .arg(config.errorString())), stderr); return -1; } QMap<QString, QString>::const_iterator it = config.filesToGenerate().constBegin(); while (it != config.filesToGenerate().constEnd()) { fputs(qPrintable(QCG::tr("Generating help for %1...\n").arg(it.key())), stdout); QHelpProjectData helpData; if (!helpData.readData(absoluteFileName(basePath, it.key()))) { fprintf(stderr, "%s\n", qPrintable(helpData.errorMessage())); return -1; } HelpGenerator helpGenerator; if (!helpGenerator.generate(&helpData, absoluteFileName(basePath, it.value()))) { fprintf(stderr, "%s\n", qPrintable(helpGenerator.error())); return -1; } ++it; } fputs(qPrintable(QCG::tr("Creating collection file...\n")), stdout); QFileInfo colFi(collectionFile); if (colFi.exists()) { if (!colFi.dir().remove(colFi.fileName())) { fputs(qPrintable(QCG::tr("The file %1 cannot be overwritten.\n") .arg(collectionFile)), stderr); return -1; } } QHelpEngineCore helpEngine(collectionFile); if (!helpEngine.setupData()) { fprintf(stderr, "%s\n", qPrintable(helpEngine.error())); return -1; } foreach (const QString &file, config.filesToRegister()) { if (!helpEngine.registerDocumentation(absoluteFileName(basePath, file))) { fprintf(stderr, "%s\n", qPrintable(helpEngine.error())); return -1; } } if (!config.filesToRegister().isEmpty()) CollectionConfiguration::updateLastRegisterTime(helpEngine); if (!config.title().isEmpty()) CollectionConfiguration::setWindowTitle(helpEngine, config.title()); if (!config.homePage().isEmpty()) { CollectionConfiguration::setDefaultHomePage(helpEngine, config.homePage()); } if (!config.startPage().isEmpty()) { CollectionConfiguration::setLastShownPages(helpEngine, QStringList(config.startPage())); } if (!config.currentFilter().isEmpty()) { helpEngine.setCurrentFilter(config.currentFilter()); } if (!config.cacheDirectory().isEmpty()) { CollectionConfiguration::setCacheDir(helpEngine, config.cacheDirectory(), config.cacheDirRelativeToCollection()); } CollectionConfiguration::setFilterFunctionalityEnabled(helpEngine, config.enableFilterFunctionality()); CollectionConfiguration::setFilterToolbarVisible(helpEngine, !config.hideFilterFunctionality()); CollectionConfiguration::setDocumentationManagerEnabled(helpEngine, config.enableDocumentationManager()); CollectionConfiguration::setAddressBarEnabled(helpEngine, config.enableAddressBar()); CollectionConfiguration::setAddressBarVisible(helpEngine, !config.hideAddressBar()); CollectionConfiguration::setCreationTime(helpEngine, QDateTime::currentDateTime().toTime_t()); CollectionConfiguration::setFullTextSearchFallbackEnabled(helpEngine, config.fullTextSearchFallbackEnabled()); if (!config.applicationIcon().isEmpty()) { QFile icon(absoluteFileName(basePath, config.applicationIcon())); if (!icon.open(QIODevice::ReadOnly)) { fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr); return -1; } CollectionConfiguration::setApplicationIcon(helpEngine, icon.readAll()); } if (config.aboutMenuTexts().count()) { QByteArray ba; QDataStream s(&ba, QIODevice::WriteOnly); QMap<QString, QString>::const_iterator it = config.aboutMenuTexts().constBegin(); while (it != config.aboutMenuTexts().constEnd()) { s << it.key(); s << it.value(); ++it; } CollectionConfiguration::setAboutMenuTexts(helpEngine, ba); } if (!config.aboutIcon().isEmpty()) { QFile icon(absoluteFileName(basePath, config.aboutIcon())); if (!icon.open(QIODevice::ReadOnly)) { fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr); return -1; } CollectionConfiguration::setAboutIcon(helpEngine, icon.readAll()); } if (config.aboutTextFiles().count()) { QByteArray ba; QDataStream s(&ba, QIODevice::WriteOnly); QMap<QString, QString>::const_iterator it = config.aboutTextFiles().constBegin(); QMap<QString, QByteArray> imgData; QRegExp srcRegExp(QLatin1String("src=(\"(.+)\"|([^\"\\s]+)).*>")); srcRegExp.setMinimal(true); QRegExp imgRegExp(QLatin1String("(<img[^>]+>)")); imgRegExp.setMinimal(true); while (it != config.aboutTextFiles().constEnd()) { s << it.key(); QFileInfo fi(absoluteFileName(basePath, it.value())); QFile f(fi.absoluteFilePath()); if (!f.open(QIODevice::ReadOnly)) { fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(f.fileName())), stderr); return -1; } QByteArray data = f.readAll(); s << data; QString contents = QString::fromUtf8(data); int pos = 0; while ((pos = imgRegExp.indexIn(contents, pos)) != -1) { QString imgTag = imgRegExp.cap(1); pos += imgRegExp.matchedLength(); if (srcRegExp.indexIn(imgTag, 0) != -1) { QString src = srcRegExp.cap(2); if (src.isEmpty()) src = srcRegExp.cap(3); QFile img(fi.absolutePath() + QDir::separator() + src); if (img.open(QIODevice::ReadOnly)) { if (!imgData.contains(src)) imgData.insert(src, img.readAll()); } else { fputs(qPrintable(QCG::tr("Cannot open referenced image file %1.\n") .arg(img.fileName())), stderr); } } } ++it; } CollectionConfiguration::setAboutTexts(helpEngine, ba); if (imgData.count()) { QByteArray imageData; QBuffer buffer(&imageData); buffer.open(QIODevice::WriteOnly); QDataStream out(&buffer); out << imgData; CollectionConfiguration::setAboutImages(helpEngine, imageData); } } return 0; }