[PC-BSD Dev] QSingleApplication port

Kris Moore kris at pcbsd.org
Tue Jul 19 11:13:36 PDT 2011


On 07/11/2011 11:36, Yuri Momotiuk wrote:
>
>
> 2011/7/7 Yuri Momotiuk <yurkis at gmail.com <mailto:yurkis at gmail.com>>
>
>     Hello
>
>     I trying to ctreate port for qsingleapplication library from qt
>     solutions. It may be useful for turning current pc-bsd tools to
>     single instance applications.
>     See port in attachment. This is early version, so it may contain
>     bugs. Can someone review that port? This is my first port creation
>     expirience.
>     Thanks.
>
>     -- 
>     Best regards, Yuri Momotyuk
>
>
> I have just finished prototype of single application mechanism for 
> pc-controlpanel. I use QtSingleApplication class from port above. You 
> can try single instance pc-controlpanel from my assembla repo:
>
> svn co 
> http://subversion.assembla.com/svn/pcbsd-extras/trunk/approved/src-qt4
>
> Don't forget to install qt4-qtsolutions-singleapplication port from 
> previous message.
>
> QtSingleApplication has one issue. It can not show window which is 
> displayed in another workspace. For example:
> 1. I launch pc-controlpanel on 1st workspace (desktop)
> 2. I switch to another workspace (for example to 2nd)
> 3. I launch pc-controlpanel again. Application can see another 
> instance but window is not shown on 2nd workspace :(
>
> As workaround I hide window before show it again. Window is blink but 
> seems it works :(
>
> To turn pc-controlpanel to single instance I did:
>
> _main.cpp:_
>
> *#include <qtsingleapplication.h>*
> *
> *
> *...**
> *
>
> int main(int argc, char *argv[])
> {
> / // Turn application to single instance. Use QtSingleInstance class/
> *      QtSingleApplication* a(argc, argv);
> /// Check for running instance/
> *if (a.isRunning())
>       {
> */ // If other instance is running- send message and exit /
> *          return !(a.sendMessage("show"));
>       }*
> *
> *
> *...
> *
> *
> *
> **    MainWnd w;*
> */// Use own function to show window on message./
> *    QObject::connect( &a, SIGNAL( messageReceived( const QString & ) ),
> &w, SLOT( on_SingleInstance( ) ) );
>
> * w.show();
>
>    return a.exec();
> }*
> *
>
> _mainwnd.h_
> *...**
> *
> *public slots:**
> **      void on_SingleInstance();*_
> _
> *
> *
> _mainwnd.cpp_*
> *
> _
> _
> *void MainWnd::on_SingleInstance()
> {
> */// Hide window first. This is workaround to show window if it on 
> other workspace. Only hide-show sequence is working for me :(/
> *    this->hide();
>     this->showNormal();
>     this->activateWindow();
>     this->raise();
> }*_
> _
> *
> *
> PS Sorry again for my english. I hope you can understand this.*
> *
>
>
> _______________________________________________
> Dev mailing list
> Dev at lists.pcbsd.org
> http://lists.pcbsd.org/mailman/listinfo/dev

Very cool! I was able to convert life-preserver to only allow a single 
instance now, and it seems to work well. The new port for 
QSingleApplication will be in the next snapshot now as well :)


-- 
Kris Moore
PC-BSD Software
iXsystems

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pcbsd.org/pipermail/dev/attachments/20110719/01f5e833/attachment.html>


More information about the Dev mailing list