1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

* Fixed TWK-451: Properly parent the friends auth / add dialog.

This commit is contained in:
Christian Muehlhaeuser 2011-08-30 00:53:29 +02:00
parent f774302623
commit a554ee0fa8
4 changed files with 85 additions and 88 deletions

View File

@ -537,93 +537,89 @@ setNam( QNetworkAccessManager* nam )
s_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
#ifndef TOMAHAWK_HEADLESS
#if defined(Q_WS_X11)
void
bringToFront()
{
qDebug() << Q_FUNC_INFO;
QWidgetList widgetList = qApp->topLevelWidgets();
int i = 0;
while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" )
i++;
if ( i == widgetList.count() )
{
qDebug() << Q_FUNC_INFO << " could not find main TH window";
return;
}
QWidget *widget = widgetList.at( i );
widget->show();
widget->activateWindow();
widget->raise();
QWidget*
tomahawkWindow()
{
QWidgetList widgetList = qApp->topLevelWidgets();
int i = 0;
while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" )
i++;
WId wid = widget->winId();
NETWM::init();
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW;
e.xclient.display = QX11Info::display();
e.xclient.window = wid;
e.xclient.format = 32;
e.xclient.data.l[0] = 2;
e.xclient.data.l[1] = QX11Info::appTime();
e.xclient.data.l[2] = 0;
e.xclient.data.l[3] = 0l;
e.xclient.data.l[4] = 0l;
XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e );
}
#elif defined(Q_WS_WIN)
void
bringToFront()
{
qDebug() << Q_FUNC_INFO;
QWidgetList widgetList = qApp->topLevelWidgets();
int i = 0;
while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" )
i++;
if ( i == widgetList.count() )
{
qDebug() << Q_FUNC_INFO << " could not find main TH window";
return;
}
QWidget *widget = widgetList.at( i );
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
SetForegroundWindow( wid );
SetFocus( wid );
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
}
}
#else
#ifndef Q_OS_MAC
void
bringToFront()
{
}
#endif
#endif
#else
void
bringToFront()
if ( i == widgetList.count() )
{
qDebug() << Q_FUNC_INFO << "could not find main Tomahawk mainwindow";
Q_ASSERT( false );
return 0;
}
QWidget *widget = widgetList.at( i );
return widget;
}
void
bringToFront()
{
#if defined(Q_WS_X11)
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
NETWM::init();
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW;
e.xclient.display = QX11Info::display();
e.xclient.window = wid;
e.xclient.format = 32;
e.xclient.data.l[0] = 2;
e.xclient.data.l[1] = QX11Info::appTime();
e.xclient.data.l[2] = 0;
e.xclient.data.l[3] = 0l;
e.xclient.data.l[4] = 0l;
XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e );
}
#elif defined(Q_WS_WIN)
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
SetForegroundWindow( wid );
SetFocus( wid );
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
}
}
#endif
}
#endif
QPixmap
createAvatarFrame( const QPixmap &avatar )

View File

@ -93,6 +93,7 @@ namespace TomahawkUtils
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory );
DLLEXPORT void setNam( QNetworkAccessManager* nam );
DLLEXPORT QWidget* tomahawkWindow();
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
DLLEXPORT void bringToFront();

View File

@ -20,6 +20,8 @@
#include "googlewrapper.h"
#include "ui_configwidget.h"
#include "utils/tomahawkutils.h"
#include <QtPlugin>
#include <QInputDialog>
@ -69,9 +71,8 @@ void
GoogleWrapper::showAddFriendDialog()
{
bool ok;
QString id = QInputDialog::getText( 0, tr( "Add Friend" ),
tr( "Enter Google Address:" ), QLineEdit::Normal,
"", &ok );
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
tr( "Enter Google Address:" ), QLineEdit::Normal, "", &ok );
if ( !ok )
return;

View File

@ -455,9 +455,8 @@ void
JabberPlugin::showAddFriendDialog()
{
bool ok;
QString id = QInputDialog::getText( 0, tr( "Add Friend" ),
tr( "Enter Jabber ID:" ), QLineEdit::Normal,
"", &ok );
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
tr( "Enter Jabber ID:" ), QLineEdit::Normal, "", &ok );
if ( !ok )
return;
@ -692,7 +691,7 @@ void JabberPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, co
tr( "Authorize User" ),
QString( tr( "Do you want to grant <b>%1</b> access to your Collection?" ) ).arg(presence.from().bare()),
QMessageBox::Yes | QMessageBox::No,
0
TomahawkUtils::tomahawkWindow()
);
// add confirmBox to m_subscriptionConfirmBoxes