1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 21:57:41 +02: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,34 +537,48 @@ setNam( QNetworkAccessManager* nam )
s_nam = QWeakPointer< QNetworkAccessManager >( nam ); s_nam = QWeakPointer< QNetworkAccessManager >( nam );
} }
#ifndef TOMAHAWK_HEADLESS #ifndef TOMAHAWK_HEADLESS
#if defined(Q_WS_X11)
void QWidget*
bringToFront() tomahawkWindow()
{ {
qDebug() << Q_FUNC_INFO;
QWidgetList widgetList = qApp->topLevelWidgets(); QWidgetList widgetList = qApp->topLevelWidgets();
int i = 0; int i = 0;
while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" ) while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" )
i++; i++;
if ( i == widgetList.count() ) if ( i == widgetList.count() )
{ {
qDebug() << Q_FUNC_INFO << " could not find main TH window"; qDebug() << Q_FUNC_INFO << "could not find main Tomahawk mainwindow";
return; Q_ASSERT( false );
return 0;
} }
QWidget *widget = widgetList.at( i ); 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->show();
widget->activateWindow(); widget->activateWindow();
widget->raise(); widget->raise();
WId wid = widget->winId(); WId wid = widget->winId();
NETWM::init(); NETWM::init();
XEvent e; XEvent e;
e.xclient.type = ClientMessage; e.xclient.type = ClientMessage;
e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW; e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW;
e.xclient.display = QX11Info::display(); e.xclient.display = QX11Info::display();
@@ -578,22 +592,13 @@ setNam( QNetworkAccessManager* nam )
XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e ); XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e );
} }
#elif defined(Q_WS_WIN) #elif defined(Q_WS_WIN)
void
bringToFront()
{ {
qDebug() << Q_FUNC_INFO; 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 ); QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show(); widget->show();
widget->activateWindow(); widget->activateWindow();
@@ -610,20 +615,11 @@ setNam( QNetworkAccessManager* nam )
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE); AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
} }
} }
#else
#ifndef Q_OS_MAC
void
bringToFront()
{
}
#endif
#endif
#else
void
bringToFront()
{
}
#endif #endif
}
#endif
QPixmap QPixmap
createAvatarFrame( const QPixmap &avatar ) createAvatarFrame( const QPixmap &avatar )

View File

@@ -93,6 +93,7 @@ namespace TomahawkUtils
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory ); DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory );
DLLEXPORT void setNam( QNetworkAccessManager* nam ); 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 /// 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(); DLLEXPORT void bringToFront();

View File

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

View File

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