2015-10-12

Qt: Dynamic Copy File in the Thread example, requires Wraparound class


  • Wraparound class


ThreadCopyFile::ThreadCopyFile(QObject *parent) : QObject(parent)
{
    qDebug() << this << "Created";

    this->v_thread = new QThread();
    this->v_copyFile = new CopyFile();
     

    connect(v_thread,SIGNAL(started()),v_copyFile,SLOT(Copy()));
    connect(v_copyFile,SIGNAL(done()),v_thread,SLOT(quit()));
    connect(v_thread,SIGNAL(finished()),this,SLOT(finished()));

    this->v_copyFile->moveToThread(this->v_thread);
    this->v_thread->start();

}

ThreadCopyFile::~ThreadCopyFile()
{
    delete this->v_thread;
    delete this->v_copyFile;
}

public slots:


void ThreadCopyFile::finished()
{
    qDebug() << this << "Finished";
    this->~ThreadCopyFile();
    qDebug() << this << "Destroyed";
}



  • Class for actual work


CopyFile::CopyFile(QObject *parent) : QObject(parent)
{
    qDebug() << this << "Created";


}

CopyFile::~CopyFile()
{
    qDebug() << this << "Destroyed";
}


signals:


    void done();

public slots:

void CopyFile::Copy(void)
{

    QString src = "/media/data/torrent/linuxmint-17.2-mate-32bit.iso";
    QString dst = "/tmp/linuxmint-17.2-mate-32bit.iso";

    if(QFile::exists(dst))
    {

        qDebug() << "file exists";

        if(QFile::remove(dst))
        {
            qDebug() << "Files removed";
        }
        else
        {
            qDebug() << "Files  fail to remove";
        }
    }

    qDebug() << "Copy File started";

    if(QFile::copy(src,dst))
    {
        qDebug() << "Copy File finished";
    }
    else
    {
        qDebug() << "Copy File fail";
    }

    emit done();
}



UI runs on other thread, everything work nicely :)


2015-10-10

Update Linux Kernel on Mint or Ubuntu


for upgrade you need three packages, depending on you architecture:

linux-headers ... ... ... amd64.deb
linux-headers ... ... ... all.deb
linux-image   ... ... ... amd64.deb

if you use Ubuntu based Linux distro, you can pick one of these: 


for example:

$ sudo update-grub


If for some reason you want to downgrade the kernel, it loads the newest kernel by default, so just uninstall new one (three packages that I mentioned) and it will load second on the list after reboot. Make sure you have at least one kernel installed! :)




2015-10-02

GIT ANNEX on RASPBIAN JESSIE

https://github.com/tradloff/git-annex-RPi

Problem:

git-annex: error while loading shared libraries: libgnutls.so.26: cannot open shared object file: No such file or directory
fatal: 'annex' appears to be a git command, but we were not
able to execute it. Maybe git-annex is broken?

Solution:

sudo ln -s /usr/lib/arm-linux-gnueabihf/libgnutls.so /usr/lib/arm-linux-gnueabihf/libgnutls.so.26