[PC-BSD Dev] QSingleApplication port
Yuri Momotiuk
yurkis at gmail.com
Mon Jul 11 08:36:20 PDT 2011
2011/7/7 Yuri Momotiuk <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.*
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pcbsd.org/pipermail/dev/attachments/20110711/e599e737/attachment.html>
More information about the Dev
mailing list