void KisOpenGL::initialize() { if (initialized) return; setDefaultFormat(); // we need a QSurface active to get our GL functions from the context QWindow surface; surface.setSurfaceType( QSurface::OpenGLSurface ); surface.create(); QOpenGLContext context; context.create(); context.makeCurrent( &surface ); QOpenGLFunctions *funcs = context.functions(); funcs->initializeOpenGLFunctions(); qDebug() << "OpenGL Info"; qDebug() << " Vendor: " << reinterpret_cast<const char *>(funcs->glGetString(GL_VENDOR)); qDebug() << " Renderer: " << reinterpret_cast<const char *>(funcs->glGetString(GL_RENDERER)); qDebug() << " Version: " << reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION)); qDebug() << " Shading language: " << reinterpret_cast<const char *>(funcs->glGetString(GL_SHADING_LANGUAGE_VERSION)); qDebug() << " Requested format: " << QSurfaceFormat::defaultFormat(); qDebug() << " Current format: " << context.format(); glMajorVersion = context.format().majorVersion(); glMinorVersion = context.format().minorVersion(); supportsDeprecatedFunctions = (context.format().options() & QSurfaceFormat::DeprecatedFunctions); initialized = true; }
ClientTextEdit::ClientTextEdit(QWidget* parent) : QTextEdit(parent) { setReadOnly(true); setOverwriteMode(true); setUndoRedoEnabled(false); setDocumentTitle("mClient"); setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); setTabChangesFocus(false); //_doc->setMaximumBlockCount(Config().scrollbackSize); // max number of lines? document()->setUndoRedoEnabled(false); QTextFrame* frame = document()->rootFrame(); _cursor = frame->firstCursorPosition(); // Default Colors _foregroundColor = Qt::lightGray; _backgroundColor = Qt::black; _blackColor = Qt::darkGray; _redColor = Qt::darkRed; _greenColor = Qt::darkGreen; _yellowColor = Qt::darkYellow; _blueColor = Qt::darkBlue; _magentaColor = Qt::darkMagenta; _cyanColor = Qt::darkCyan; _grayColor = Qt::lightGray; _darkGrayColor = Qt::gray; _brightRedColor = Qt::red; _brightGreenColor = Qt::green; _brightYellowColor = Qt::yellow; _brightBlueColor = Qt::blue; _brightMagentaColor = Qt::magenta; _brightCyanColor = Qt::cyan; _whiteColor = Qt::white; // Default Fonts _serverOutputFont = QFont("Monospace", 10); _inputLineFont = QFont("Monospace", 10); //QApplication::font(); _serverOutputFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias); QTextFrameFormat frameFormat = frame->frameFormat(); frameFormat.setBackground(_backgroundColor); frameFormat.setForeground(_foregroundColor); frame->setFrameFormat(frameFormat); _format = _cursor.charFormat(); setDefaultFormat(_format); _defaultFormat = _format; _cursor.setCharFormat(_format); QFontMetrics fm(_serverOutputFont); setTabStopWidth(fm.width(" ") * 8); // A tab is 8 spaces wide QScrollBar* scrollbar = verticalScrollBar(); scrollbar->setSingleStep(fm.leading()+fm.height()); connect(scrollbar, SIGNAL(sliderReleased()), this, SLOT(scrollBarReleased())); previous = 0; }
RenameDialog::RenameDialog( QList<TagItem*> tagitems, QWidget *parent ) : QDialog(parent){ setupUi(this); // this sets up GUI settings = Global::guiSettings(); connect( RenameButton, SIGNAL( clicked() ), this, SLOT(rename() ) ); tagItems = tagitems; defaultReplaceFormat<<"\\"<<"_"<<"/"<<"_"<<"*"<<"_"<<":"<<"_"<<"?"<<"_"<<"<"<<"_"<<">"<<"_"<<"|"<<"_"<<"\""<<"_"; replaceFormat = settings->value("RenameDialog/replaceFormat",defaultReplaceFormat).toStringList(); notAllowedCharacters<<"\\"<<"/"<<"*"<<":"<<"?"<<"<"<<">"<<"|"<<"\""; QString renameFormat = settings->value("RenameDialog/renameFormat","%artist% - %title%").toString(); this->restoreGeometry(settings->value("RenameDialog/geometry").toByteArray()); Format->setText(renameFormat); int k=0; ReplaceTable->setRowCount(2); ReplaceTable->setColumnCount(9); for(int i=0;i<replaceFormat.size();i=i+2){ QTableWidgetItem *item1 = new QTableWidgetItem; item1->setText(replaceFormat[i]); item1->setFlags( item1->flags() ^ Qt::ItemIsEditable ); QTableWidgetItem *item2 = new QTableWidgetItem; item2->setText(replaceFormat[i+1]); ReplaceTable->setItem(0,k,item1); ReplaceTable->setItem(1,k,item2); //qDebug()<<replaceFormat[i]<<replaceFormat[i+1]<<k; k++; } QStringList vHeaders; vHeaders << "To be replaced" << "Replacement"; ReplaceTable->setVerticalHeaderLabels(vHeaders); connect( this, SIGNAL( finished( int ) ), this, SLOT( finito( int ) ) ); //connect( Format, SIGNAL( textChanged( const QString & ) ), this, SLOT( updateFormat( const QString & ) ) ); connect( ReplaceTable, SIGNAL( itemChanged( QTableWidgetItem* ) ), this, SLOT( updateReplaceFormat( QTableWidgetItem* ) ) ); QAction* setDefaultFormatAction = new QAction(tr("Inset default replace format"), this); connect(setDefaultFormatAction, SIGNAL(triggered()), this, SLOT(setDefaultFormat())); ReplaceTable->setContextMenuPolicy(Qt::ActionsContextMenu); ReplaceTable->addAction(setDefaultFormatAction); ReplaceTable->resizeColumnsToContents(); Info->setText(QString::number(tagitems.size())+" files selected"); }