Skip to content

Commit

Permalink
Send a widget ID with Shift-F6 for automated testing
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Nov 15, 2017
1 parent 5b7a782 commit 939ca1e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/YQDialog.cc
Expand Up @@ -635,6 +635,11 @@ YQDialog::keyPressEvent( QKeyEvent * event )
}
return;
}
else if ( event->key() == Qt::Key_F6 && // Shift-F6: ask for a widget ID and send it
event->modifiers() == Qt::ShiftModifier )
{
YQUI::ui()->askSendWidgetID();
}
else if ( event->key() == Qt::Key_F7 && // Shift-F7: toggle debug logging
event->modifiers() == Qt::ShiftModifier )
{
Expand Down
41 changes: 41 additions & 0 deletions src/YQUI.cc
Expand Up @@ -36,6 +36,8 @@
#include <QCursor>
#include <QLocale>
#include <QMessageLogContext>
#include <QMessageBox>
#include <QInputDialog>


#define YUILogComponent "qt-ui"
Expand All @@ -55,6 +57,8 @@
#include "YQWidgetFactory.h"
#include "YQOptionalWidgetFactory.h"

#include "YQWizardButton.h"

#include "YQi18n.h"
#include "utf8.h"

Expand Down Expand Up @@ -608,6 +612,43 @@ bool YQUI::close()
}


void YQUI::askSendWidgetID()
{
QWidget * parent = 0;
YDialog * dialog = YDialog::currentDialog( false );; // doThrow

if ( dialog )
parent = (QWidget *) dialog->widgetRep();

QString id = QInputDialog::getText( parent,
_( "Widget ID" ), // dialog title
_( "Enter Widget ID:" ) // label
);
if ( ! id.isEmpty() )
{
try
{
YWidget * widget = sendWidgetID( toUTF8( id ) );
YQGenericButton * yqButton = dynamic_cast<YQGenericButton *>( widget );

if ( yqButton )
{
yuiMilestone() << "Activating " << widget << endl;
yqButton->activate();
}
}
catch ( YUIWidgetNotFoundException & ex )
{
YUI_CAUGHT( ex );
QMessageBox::warning( parent,
"Error", // title
QString( "No widget with ID \"%1\"" ).arg( id ) );
}
}
}





YQUISignalReceiver::YQUISignalReceiver()
Expand Down
10 changes: 8 additions & 2 deletions src/YQUI.h
Expand Up @@ -216,6 +216,12 @@ class YQUI: public YUI
**/
void askPlayMacro();

/**
* Open a pop-up dialog to ask the user for a widget ID and then send it
* with sendWidgetID().
**/
void askSendWidgetID();

/**
* Block (or unblock) events. If events are blocked, any event sent
* should be ignored until events are unblocked again.
Expand Down Expand Up @@ -274,12 +280,12 @@ class YQUI: public YUI
* Returns the application name for the window title (e.g. "YaST2@hostname")
**/
QString applicationTitle() { return _applicationTitle; }

/**
* Sets the application name for the window title
**/
void setApplicationTitle(const QString& title) { _applicationTitle=title; }

protected:

/**
Expand Down

0 comments on commit 939ca1e

Please sign in to comment.