How to use QWinJumpList to show QWidget on Jumplist item click. Windows 10



  • Hi. QtWinExtras is a great module but it appears to missing some functionality that is critical to my application design. My application does not have a main window, instead I am using dialog windows. I would like to be able to show dialog windows when items in the jump list are clicked but I don't see support for this in QWinJumplist. There appears to be no signal I can connect to for when a jumplist item is clicked either.

    How can I achieve the desired behavior? Even a hack solution would do fine for my purpose. Cheers.

    alt text

    #include "jumplistview.h"
    
    #include <QDialog>
    
    JumpListView::JumpListView() // inherits QWinJumpList no parent
    {
        m_launcherCategory = new QWinJumpListCategory("Launcher");
        this->addCategory(m_launcherCategory);
    
        // For demonstration purposes
        m_myDialog = new QDialog();
        m_myDialog->setWindowTitle("My Dialog");
        this->addDialogLink(m_myDialog);
    
        m_launcherCategory->setVisible(true);
    }
    
    void JumpListView::addDialogLink(QDialog *dialog)
    {
        QWinJumpListItem *jumpListItem = new QWinJumpListItem(QWinJumpListItem::Link);
    
        jumpListItem->setTitle(dialog->windowTitle());
    
        // ??? "connect" jumplist item click to dialog show slot
    
        m_launcherCategory->addItem(jumpListItem);
    }
    
    


  • The problem is due to the fact that QWinJumpListItem is not a QObject.
    The workaround I'd use is to create a separate executable that based on the argument it is started with sends different messages using QLocalSocket, the main application should receive this messages and react opening the dialogs. This way you can use QWinJumpListCategory::addLink to call the utility from the jump list.

    Schematically:
    click the jumplist item -> starts the utility application with an argument -> the utility application connects to the main one using QLocalSocket and notifies the main app of what argument it was provided -> the main app opens the dialog corresponding to that argument



  • Thanks. I will give that a go. So in that case I will have an additional utility console application that simply relays QLocalSocket messages that my application receives and then shows the window. I'll just use the QDialog object name as the string. I've never used QLocalSocket so it's going to take me a while to implement. Will let you know how it goes.


  • Moderators

    @JGruber
    maybe then it's easier for you to call your application's exe again and integrate QtSingleApplication? If it also meets your requirement that only 1 instance at the time of your application should be open.



  • @raven-worx
    Could you please explain that in another way? We're building a commercial product so there is some reluctance to integrate 3rd-party libraries for support reasons.


  • Moderators

    @JGruber
    QtSingleApplication is an more or less official (former Qt Solutions) "extension".
    It ensures in a cross platform way that only 1 instance of the application is running. If a second instance is started it signals a message to the already running application.
    It comes in BSD license and it's enough to copy the few files to your source tree.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.