Skip to content

Commit

Permalink
Export the launcher dialog as a shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
giucam committed Feb 8, 2017
1 parent 3d68695 commit 2bd5f46
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 5 deletions.
1 change: 1 addition & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ endif()
# UI launcher
if(HAVE_QT_CONCURRENT AND GAMMARAY_BUILD_UI)
add_subdirectory(ui)
gammaray_install_headers(${CMAKE_CURRENT_BINARY_DIR}/ui/gammaray_launcher_dialog_export.h ui/launcherdialog.h)
endif()
endif()
6 changes: 6 additions & 0 deletions launcher/launchoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <QHash>
#include <QSharedDataPointer>
#include <QUrl>

QT_BEGIN_NAMESPACE
class QStringList;
Expand Down Expand Up @@ -65,6 +66,8 @@ class GAMMARAY_LAUNCHER_EXPORT LaunchOptions
/** Returns @c true if we are supposed to attach rather than start a new process. */
bool isAttach() const;

bool isConnect() const;

/** Returns @c true if no valid launch arguments or process id are set. */
bool isValid() const;

Expand All @@ -84,6 +87,9 @@ class GAMMARAY_LAUNCHER_EXPORT LaunchOptions
void setPid(int pid);
int pid() const;

void setUrl(const QUrl &url);
QUrl url() const;

/** UI mode. */
UiMode uiMode() const;
void setUiMode(UiMode mode);
Expand Down
22 changes: 22 additions & 0 deletions launcher/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ target_link_libraries(gammaray_launcher_ui_internal
gammaray_ui
)

install(TARGETS gammaray_launcher_ui_internal EXPORT GammaRayTargets ${INSTALL_TARGETS_DEFAULT_ARGS})

set(gammaray_launcher_ui_srcs main.cpp)
# TODO we don't need all the class icons here, so split the qrc file accordingly
qt4_add_resources(gammaray_launcher_ui_srcs ${CMAKE_SOURCE_DIR}/resources/gammaray.qrc)
Expand All @@ -55,5 +57,25 @@ set_target_properties(gammaray-launcher PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${LIBEXEC_INSTALL_DIR}"
)

set(gammaray_launcher_dialog_srcs launcherdialog.cpp)
add_library(gammaray_launcher_dialog SHARED ${gammaray_launcher_dialog_srcs})
target_link_libraries(gammaray_launcher_dialog
${QT_QTGUI_LIBRARIES}
gammaray_common
gammaray_launcher_ui_internal
)

install(TARGETS gammaray_launcher_dialog EXPORT GammaRayTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
generate_export_header(gammaray_launcher_dialog)

ecm_generate_pri_file(BASE_NAME GammaRayLauncherDialog
LIB_NAME gammaray_launcher_dialog
DEPS "core gui GammaRayCommon GammaRayLauncher"
FILENAME_VAR PRI_FILENAME
INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR})

install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})


install(TARGETS gammaray-launcher DESTINATION ${LIBEXEC_INSTALL_DIR})

5 changes: 5 additions & 0 deletions launcher/ui/attachdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ int AttachDialog::pid() const
return ui.view->currentIndex().data(ProcessModel::PIDRole).toInt();
}

QString AttachDialog::name() const
{
return ui.view->currentIndex().data(ProcessModel::NameRole).toString();
}

void AttachDialog::updateProcesses()
{
QFutureWatcher<ProcDataList> *watcher = new QFutureWatcher<ProcDataList>(this);
Expand Down
1 change: 1 addition & 0 deletions launcher/ui/attachdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AttachDialog : public QWidget

LaunchOptions launchOptions() const;
int pid() const;
QString name() const;

/// Returns @c true if a valid process is selected.
bool isValid() const;
Expand Down
9 changes: 7 additions & 2 deletions launcher/ui/connectpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,18 @@ bool ConnectPage::isValid() const
return !ui->host->text().isEmpty();
}

void ConnectPage::launchClient()
QUrl ConnectPage::url() const
{
QUrl url;
url.setScheme(QStringLiteral("tcp"));
url.setHost(ui->host->text());
url.setPort(ui->port->value());
ClientLauncher::launchDetached(url);
return url;
}

void ConnectPage::launchClient()
{
ClientLauncher::launchDetached(url());
}

void ConnectPage::writeSettings()
Expand Down
1 change: 1 addition & 0 deletions launcher/ui/connectpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ConnectPage : public QWidget

bool isValid() const;
void writeSettings();
QUrl url() const;

public slots:
void launchClient();
Expand Down
5 changes: 3 additions & 2 deletions launcher/ui/launcherwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@

using namespace GammaRay;

LauncherWindow::LauncherWindow(QWidget *parent)
LauncherWindow::LauncherWindow(bool launchClient, QWidget *parent)
: QDialog(parent)
, ui(new Ui::LauncherWindow)
, m_launchClient(launchClient)
{
ui->setupUi(this);
ui->aboutLabel->setText(AboutData::aboutText());
Expand Down Expand Up @@ -101,7 +102,7 @@ void LauncherWindow::accept()
ui->attachPage->writeSettings();
ui->connectPage->writeSettings();

if (ui->tabWidget->currentWidget() == ui->connectPage)
if (ui->tabWidget->currentWidget() == ui->connectPage && m_launchClient)
ui->connectPage->launchClient();

QDialog::accept();
Expand Down
5 changes: 4 additions & 1 deletion launcher/ui/launcherwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LauncherWindow : public QDialog
{
Q_OBJECT
public:
explicit LauncherWindow(QWidget *parent = nullptr);
explicit LauncherWindow(bool launchClient = true, QWidget *parent = nullptr);
~LauncherWindow();

/// returns all information required to perform the launch/attach
Expand All @@ -55,6 +55,9 @@ private slots:

private:
Ui::LauncherWindow *ui;
bool m_launchClient;

friend class LauncherDialog;
};
}

Expand Down

0 comments on commit 2bd5f46

Please sign in to comment.