Developing WordPress Theme with MDBootstrap and Collapse Button and Modals don't work - bootstrap-modal

I’m building a WordPress theme on my own. First, I’ve made it with html, css, and Material Design bootstrap. Then, I installed it into Wordpress. But the toggle button of navbar and modals don’t work… what is the problem?
here's my functions.php
add_action( 'after_setup_theme', 'my_theme_setup' );
function my_assets() {
/* Enqueue CSS files */
wp_enqueue_style( 'Font_Awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css' );
wp_enqueue_style( 'Google_Fonts', 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900' );
wp_enqueue_style( 'MDB_Icons', get_template_directory_uri() . '/img/mdb-favicon.ico" type="image/x-icon' );
wp_enqueue_style( 'Box_Icons', 'https://unpkg.com/boxicons#2.1.4/css/boxicons.min.css' );
wp_enqueue_style( 'Bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'MDB', get_template_directory_uri() . '/css/mdb.min.css' );
wp_enqueue_style( 'core', get_template_directory_uri() . '/style.css' );
/* Enqueue JS files */
wp_enqueue_script( 'Tether', get_template_directory_uri() . '/js/tether.min.js',array('jquery'));
wp_enqueue_script( 'Popper', get_template_directory_uri() . '/js/popper.min.js', array('jquery'));
wp_enqueue_script( 'Bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'));
wp_enqueue_script( 'MDB', get_template_directory_uri() . '/js/mdb.js', array('jquery'));
wp_enqueue_script('CustomJS', get_template_directory_uri() . '/js/custom-js.js', array('jquery'), '1.0.0', true);
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/bootstrap/js/bootstrap.bundle.min.js', array( 'jquery' ) );
if(is_singular() && comments_open() && get_option( 'thread_comments' )) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://code.jquery.com/jquery-3.6.0.min.js');
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
I tried the order of list of wp_enqueue_scripts, and also dequeued the default WordPress jQuery library and enqueued the latest version of jQuery....but still cannot make it work

Related

Remove all canvas margins & spacing in Qwt

I have a QwtPlot which consists in a single horizontal QwtPlotMultiBarChart. I would like to have the canvas height, the y axis length and the barchart height to be all the same. I tried settings all margins/spacing to zero and switch layout policies.
seriesPlot = new QwtPlot(this);
seriesPlot->plotLayout()->setCanvasMargin(0);
seriesPlot->plotLayout()->setSpacing(0);
seriesPlot->canvas()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
seriesPlot->canvas()->setContentsMargins(0,0,0,0);
d_barChartItem = new QwtPlotMultiBarChart();
d_barChartItem->setLayoutPolicy( QwtPlotMultiBarChart::ScaleSampleToCanvas );
d_barChartItem->setStyle( QwtPlotMultiBarChart::Stacked );
d_barChartItem->attach( seriesPlot );
populate();
d_barChartItem->setSpacing(0);
d_barChartItem->setMargin( 0 );
QwtPlot::Axis axis2 = QwtPlot::xBottom;
QwtPlot::Axis axis1 = QwtPlot::yLeft;
d_barChartItem->setOrientation( Qt::Horizontal );
seriesPlot->setAxisScale( axis1,-0.2,0.2 );
seriesPlot->setAxisAutoScale( axis2 );
QwtScaleDraw *scaleDraw1 = seriesPlot->axisScaleDraw( axis1 );
scaleDraw1->enableComponent( QwtScaleDraw::Backbone, false );
scaleDraw1->setSpacing(0);
scaleDraw1->enableComponent( QwtScaleDraw::Ticks, false );
scaleDraw1->enableComponent( QwtScaleDraw::Labels, false );
QwtScaleDraw *scaleDraw2 = seriesPlot->axisScaleDraw( axis2 );
scaleDraw2->enableComponent( QwtScaleDraw::Backbone, false );
scaleDraw2->enableComponent( QwtScaleDraw::Ticks, true );
seriesPlot->plotLayout()->setAlignCanvasToScale( axis1, true);
seriesPlot->updateAxes();
seriesPlot->plotLayout()->setCanvasMargin( 0 );
seriesPlot->updateCanvasMargins();
seriesPlot->updateLayout();
seriesPlot->replot();
seriesPlot->setAutoReplot( true );
And here is a picture of the two margins that i would like to remove:
I found the solution:
d_barChartItem->setLayoutHint(0.75);

How to remove caret cursor in Gtk entry

I have a Gtk entry. I need to completely remove this caret cursor, how can I do this? I searched for information about this for a long time but found only how to remove the blinking of Gtk entry.
Until you find a better one use CSS.
Just set the caret-color background to the same background-color of the entry:
main.c
#include <gtk/gtk.h>
int main ( void )
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *entry;
/// ***
gtk_init ( NULL, NULL );
/// ***
window = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
gtk_window_set_title ( GTK_WINDOW ( window ), "Hello There!" );
gtk_window_set_default_size ( GTK_WINDOW ( window ), 200, 100 );
g_signal_connect ( window, "destroy", gtk_main_quit, NULL );
///***
grid = gtk_grid_new();
gtk_container_add ( GTK_CONTAINER ( window ), grid );
///***
entry = gtk_entry_new();
g_object_set ( entry, "margin-top", 30, NULL );
g_object_set ( entry, "margin-left", 20, NULL );
gtk_grid_attach ( GTK_GRID ( grid ), entry, 0, 0, 1, 1 );
/// ***
gtk_widget_show_all ( window );
gtk_main();
}
CSS:
window
{
background-color: red;
}
entry
{
background-color: yellow;
caret-color: yellow;
}
rezult:

QGraphicsLinearLayout not aligning widgets as expected

I have got a QGraphicsScene that I have added a QGraphicsWidget.
I initially setup the widget this way
AGraphicsWidget::AGraphicsWidget( QGraphicsItem* parent, QGraphicsScene* scene )
: QGraphicsWidget( parent )
, m_mainLayout( new QGraphicsLinearLayout( Qt::Vertical ) )
, m_titleLabel( new QLabel( "Title" ) )
, m_executionPin( new NodeExecutionPin() )
{
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
setGraphicsItem( this );
setFlag( ItemIsMovable, true );
m_mainLayout->setInstantInvalidatePropagation( true );
auto* labelProxy = scene->addWidget( m_titleLabel );
auto* secondLabel = scene->addWidget( new QLabel( "Subtitle" ) );
auto* button = scene->addWidget( new QPushButton( "Another" ) );
m_mainLayout->addItem( labelProxy );
m_mainLayout->addItem( secondLabel );
m_mainLayout->addItem( button );
setLayout( m_mainLayout );
}
This setup does not do what I expect which would be a vertically aligned set of widgets instead I get this
However when I add a text edit as the last element like this
AGraphicsWidget::AGraphicsWidget( QGraphicsItem* parent, QGraphicsScene* scene )
: QGraphicsWidget( parent )
, m_mainLayout( new QGraphicsLinearLayout( Qt::Vertical ) )
, m_titleLabel( new QLabel( "Title" ) )
, m_executionPin( new NodeExecutionPin() )
{
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
setGraphicsItem( this );
setFlag( ItemIsMovable, true );
m_mainLayout->setInstantInvalidatePropagation( true );
auto* labelProxy = scene->addWidget( m_titleLabel );
auto* secondLabel = scene->addWidget( new QLabel( "Subtitle" ) );
auto* button = scene->addWidget( new QPushButton( "Another" ) );
auto* edit = scene->addWidget( new QTextEdit() );
m_mainLayout->addItem( labelProxy );
m_mainLayout->addItem( secondLabel );
m_mainLayout->addItem( button );
m_mainLayout->addItem( edit );
setLayout( m_mainLayout );
}
It works as expected, I get the nice vertical layout, I get the same non alignment as above if I try and nest any QGraphicsLinearLayouts any further where they will overlap each other, what is happening here?
Thanks in advance.

How to set Qt QStateMachine animation duration

I'm trying to learn the Qt framework. My QStateMachine code does the correct thing (pressing the button makes the chat window popup change size).
I can't change the speed of the animation to get a nice visual transition.
Any suggestions?
Here's the code:
MainWindow::MainWindow()
{
widget.setupUi( this );
// chat window - Chat button opens
ChatWindowClosedState = new QState();
ChatWindowOpenState = new QState();
ChatWindowOpenGeometry = widget.groupBox->geometry();
ChatWindowClosedGeometry = widget.pushButton->geometry();
ChatWindowClosedGeometry.translate( -ChatWindowClosedGeometry.width(), 0 );
ChatWindowClosedState->assignProperty( widget.groupBox, "geometry", ChatWindowClosedGeometry );
ChatWindowOpenState->assignProperty( widget.groupBox, "geometry", ChatWindowOpenGeometry );
ChatWindowCloseTransition = ChatWindowClosedState->addTransition( widget.pushButton, SIGNAL( clicked() ), ChatWindowOpenState );
ChatWindowCloseAnimation = new QPropertyAnimation( widget.pushButton, "geometry" );
ChatWindowCloseAnimation->setDuration( 5000 );
ChatWindowCloseTransition->addAnimation( ChatWindowCloseAnimation );
ChatWindowOpenTransition = ChatWindowOpenState->addTransition( widget.pushButton, SIGNAL( clicked() ), ChatWindowClosedState );
ChatWindowOpenAnimation = new QPropertyAnimation( widget.pushButton, "geometry" );
ChatWindowOpenAnimation->setDuration( 5000 );
ChatWindowOpenTransition->addAnimation( ChatWindowOpenAnimation );
machine = new QStateMachine( this );
machine->addState( ChatWindowClosedState );
machine->addState( ChatWindowOpenState );
machine->setInitialState( ChatWindowClosedState );
machine->start();
}
The code
ChatWindowOpenAnimation = new QPropertyAnimation( widget.pushButton, "geometry" );
should be
ChatWindowOpenAnimation = new QPropertyAnimation( widget.groupBox, "geometry" );
The animation was being applied to the wrong widget.

openCV and Threads issue

I'm trying to fit facedetect from openCV on my QT code, all run fine until i decided to create a thread for my openCV code so I can run another things while the face detect is on.
the problem is if i call class->start(); my program breaks in the while loop in the run() but if i call the class.run(); (like a normal function) it runs as usual! what can be wrong?
code:
faceTracker::faceTracker()
{
qDebug("teste1");
filename = "/Users/marcomartins/Documents/QT/DisplUM/haarcascades/haarcascade_frontalface_alt_tree.xml";
/* load the classifier
note that I put the file in the same directory with this code */
cascade = ( CvHaarClassifierCascade* )cvLoad( filename, 0, 0, 0 );
/* setup memory buffer; needed by the face detector */
storage = cvCreateMemStorage( 0 );
/* initialize camera */
capture = cvCaptureFromCAM( 0 );
/* always check */
assert( cascade && storage && capture );
/* create a window */
cvNamedWindow( "video DisplUM", 1 );
}
void faceTracker::detectFaces( IplImage *img )
{
/* detect faces */
faces = cvHaarDetectObjects(
img,
cascade,
storage,
1.1,
3,
0 /*CV_HAAR_DO_CANNY_PRUNNING*/,
cvSize( 40, 40 ) );
/* for each face found, draw a red box */
for( i = 0 ; i < ( faces ? faces->total : 0 ) ; i++ ) {
CvRect *r = ( CvRect* )cvGetSeqElem( faces, i );
cvRectangle( img,
cvPoint( r->x, r->y ),
cvPoint( r->x + r->width, r->y + r->height ),
CV_RGB( 255, 0, 0 ), 1, 8, 0 );
qDebug("caras: %d", faces->total);
}
/* display video */
cvShowImage( "video", img );
}
void faceTracker::run( )
{
qDebug("teste2");
while( key != 'q' ) {
/* get a frame */
frame = cvQueryFrame( capture );
qDebug("teste3");
/* always check */
if( !frame ) break;
/* 'fix' frame */
cvFlip( frame, frame, 1 );
frame->origin = 0;
/* detect faces and display video */
detectFaces( frame );
/* quit if user press 'q' */
key = cvWaitKey( 10 );
}
/* free memory */
cvReleaseCapture( &capture );
cvDestroyWindow( "video" );
cvReleaseHaarClassifierCascade( &cascade );
cvReleaseMemStorage( &storage );
}
main code:
int main(int argc, char *argv[])
{
faceTracker * ft = new faceTracker();
ft->start();
}
thanks a lot!
The loop will only break if cvQueryFrame() returns a NULL frame or if the user presses q on the keyboard.
Add a debug so you know when the first situation happens:
frame = cvQueryFrame( capture );
if( !frame )
{
qDebug("cvQueryFrame failed!");
break;
}
Are you sure cvCaptureFromCAM(0) works ? Depending on the OS I have to pass -1 for it. But the fact is that you'll never know if cvCaptureFromCAM(0)succeeded because you don't check the return, and this might be the problem!
capture = cvCaptureFromCAM(0);
if (!capture)
{
qDebug("cvCaptureFromCAM failed!");
//exit(0); or whatever
}
EDIT:
Pay huge attention to this: you are creating a window named "video DisplUM" but you are trying to display the frames on a different window, named "video".
Anyway, it's also better if you change the window creation function to use the appropriate enum:
cvNamedWindow("video DisplUM", CV_WINDOW_AUTOSIZE);
and on faceTracker::run( ) comment detectFaces() for now and add a call to cvShowImage( "video DisplUM", frame );
Always be sure your application works with the minimum requirements before adding fancy stuffs, like face detection. My final suggestion is: write enough code just to capture the images from one thread and display them on a window, and then go from there.
Solution:
I can't create windows outside the main thread, that is why it was crashing. If i comment the window creation all works good (face detection included)
I ran into a similar issue. What I found is that I had to rebuild OpenCV and include the TBB libraries. This adds threading support to OpenCV. Once I did this, I was able to pop up windows in any thread I chose. I've tested this on versions 2.1 and 2.2, using both C and C++ implementations.