Geometrize  1.0
An application for geometrizing images into geometric primitives
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::LaunchWindow::LaunchWindowImpl Class Reference
Collaboration diagram for geometrize::dialog::LaunchWindow::LaunchWindowImpl:
Collaboration graph
[legend]

Public Member Functions

 LaunchWindowImpl (LaunchWindow *pQ)
 
LaunchWindowImpl operator= (const LaunchWindowImpl &)=delete
 
 LaunchWindowImpl (const LaunchWindowImpl &)=delete
 
 ~LaunchWindowImpl ()=default
 
void handleCommand (const geometrize::script::Command &command)
 
std::string getCommandHandlerName () const
 
void setCommandHandlerName (const std::string &name)
 
void setConsoleVisibility (const bool visible)
 
void loadConsoleHistory ()
 
void saveConsoleHistory ()
 
void loadGlobalSettingsTemplate ()
 
void saveGlobalSettingsTemplate () const
 
void onLanguageChange ()
 

Static Public Member Functions

static std::vector< LaunchWindow * > getTopLevelLaunchWindows ()
 

Private Member Functions

void populateUi ()
 
void updateLogoTaskProgress ()
 
void setupLogo ()
 

Private Attributes

std::unique_ptr< Ui::LaunchWindow > ui
 
LaunchWindowq
 
std::unique_ptr< chaiscript::ChaiScript > m_engine
 
std::unique_ptr< task::ImageTaskm_logoTask
 
const std::size_t m_maxLogoTaskSteps {300ULL}
 
std::size_t m_logoTaskSteps {0}
 

Constructor & Destructor Documentation

◆ LaunchWindowImpl() [1/2]

geometrize::dialog::LaunchWindow::LaunchWindowImpl::LaunchWindowImpl ( LaunchWindow pQ)
inline
34  : ui{std::make_unique<Ui::LaunchWindow>()}, q{pQ}, m_engine{script::createLaunchWindowEngine()}
35  {
36  q->setAttribute(Qt::WA_DeleteOnClose);
37  ui->setupUi(q);
38  populateUi();
39 
40  // Hide the run script button by default (it's not useful to casual users at the moment, the task queue is better)
41  ui->runScriptButton->setHidden(true);
42 
43  // Set up recent items list
44  if(preferences::getGlobalPreferences().shouldPopulateRecentItemsOnLaunch()) {
45  ui->recentsList->setRecentItems(&geometrize::getRecentItems());
46  }
47 
48  // Set up console widget
49  ui->consoleWidget->setEngine(m_engine.get());
50 
52 
53  if(preferences::getGlobalPreferences().shouldShowLaunchConsoleByDefault()) {
55  } else {
56  setConsoleVisibility(false);
57  }
58 
59  connect(ui->actionScript_Console, &QAction::toggled, [this](const bool checked) {
60  setConsoleVisibility(checked);
61  });
62 
63  // Set up templates search and grid
64  connect(ui->templateGrid, &dialog::TemplateGrid::signal_templateLoaded, [this](const QString& templateFolder, const bool /*success*/) {
65  ui->templatesSearchEdit->addToCompletionList(QString::fromStdString(util::getTemplateManifest(templateFolder.toStdString()).getName()));
66  });
67  connect(ui->templatesSearchEdit, &dialog::CompletionBox::textChanged, [this](const QString& text) {
68  ui->templateGrid->setItemFilter(text);
69  });
70 
71  if(preferences::getGlobalPreferences().shouldPopulateTemplatesOnLaunch()) {
72  ui->templateGrid->loadTemplates();
73  }
74 
75  // Set up the logo
76  setupLogo();
77  }

◆ LaunchWindowImpl() [2/2]

geometrize::dialog::LaunchWindow::LaunchWindowImpl::LaunchWindowImpl ( const LaunchWindowImpl )
delete

◆ ~LaunchWindowImpl()

geometrize::dialog::LaunchWindow::LaunchWindowImpl::~LaunchWindowImpl ( )
default

Member Function Documentation

◆ getCommandHandlerName()

std::string geometrize::dialog::LaunchWindow::LaunchWindowImpl::getCommandHandlerName ( ) const
inline
161  {
162  return q->objectName().toStdString();
163  }

◆ getTopLevelLaunchWindows()

static std::vector<LaunchWindow*> geometrize::dialog::LaunchWindow::LaunchWindowImpl::getTopLevelLaunchWindows ( )
inlinestatic
83  {
84  std::vector<LaunchWindow*> windows;
85 
86  QWidgetList topLevelWidgets{QApplication::topLevelWidgets()};
87  for(QWidget* w : topLevelWidgets) {
88  if(LaunchWindow* lw = dynamic_cast<LaunchWindow*>(w)) {
89  windows.push_back(lw);
90  }
91  }
92 
93  return windows;
94  }
Here is the caller graph for this function:

◆ handleCommand()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::handleCommand ( const geometrize::script::Command command)
inline
97  {
98  const QString s = QString::fromStdString(command.getCommand());
99  if(s == "search_sample_images") {
100  ui->templatesSearchEdit->setText(QString::fromStdString(command.getStringArg("search_term")));
101  }
102 
103  // File menu options
104  if(s == "show_file_menu") {
105  ui->menuFile->exec(q->mapToGlobal(ui->menuBar->pos()));
106  }
107  if(s == "file_menu_clear_recent_items") {
109  }
110  if(s == "file_menu_open_global_preferences") {
112  }
113  if(s == "file_menu_load_global_preferences") {
115  }
116  if(s == "file_menu_save_global_preferences") {
118  }
119  if(s == "file_menu_exit") {
121  }
122 
123  if(s == "show_view_menu") {
124  ui->menuView->exec(q->mapToGlobal(ui->menuBar->pos()));
125  }
126  if(s == "view_menu_toggle_script_console") {
127  ui->actionScript_Console->toggle();
128  }
129  if(s == "view_menu_show_script_console") {
130  ui->actionScript_Console->setChecked(true);
131  }
132  if(s == "view_menu_hide_script_console") {
133  ui->actionScript_Console->setChecked(false);
134  }
135 
136  if(s == "show_help_menu") {
137  ui->menuHelp->popup(q->mapToGlobal(ui->menuBar->pos()));
138  }
139  if(s == "help_menu_show_tutorials") {
140  ui->actionTutorials->trigger();
141  }
142  if(s == "help_menu_show_support") {
143  ui->actionSupport->trigger();
144  }
145  if(s == "help_menu_show_about") {
146  ui->actionAbout->trigger();
147  }
148 
149  if(s == "click_open_image") {
150  ui->openImageButton->click();
151  }
152  if(s == "click_open_link") {
153  ui->openLinkButton->click();
154  }
155  if(s == "click_open_task_queue") {
156  ui->openTaskQueueButton->click();
157  }
158  }
Here is the call graph for this function:

◆ loadConsoleHistory()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::loadConsoleHistory ( )
inline
179  {
181  ui->consoleWidget->setHistory(history);
182  }
Here is the call graph for this function:

◆ loadGlobalSettingsTemplate()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::loadGlobalSettingsTemplate ( )
inline
191  {
192  const QString path{common::ui::openLoadGlobalSettingsDialog(q)};
193  if(path.isEmpty()) {
194  return;
195  }
197  }
Here is the call graph for this function:

◆ onLanguageChange()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::onLanguageChange ( )
inline
209  {
210  ui->retranslateUi(q);
211  populateUi();
212  }
Here is the call graph for this function:

◆ operator=()

LaunchWindowImpl geometrize::dialog::LaunchWindow::LaunchWindowImpl::operator= ( const LaunchWindowImpl )
delete

◆ populateUi()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::populateUi ( )
inlineprivate
216  {
217  const QString windowTitle{geometrize::strings::Strings::getApplicationName()
218  .append(" ")
220 
221  q->setWindowTitle(windowTitle);
222 
223  const QString moreResourcesLabel{tr("Get more online", "Text on a button the user presses to open a page containing more resources for using the app, such as extra images, information and help")};
224  ui->moreResourcesLink->setText(R"(<a href=")" + constants::MORE_RESOURCES_URL + R"(" style="text-decoration:none;">)" + moreResourcesLabel + R"(</a>)");
225 
226  const QString tutorialsLabel{tr("Video tutorials", "Text on a button the user presses to open a page containing video tutorials explaining how to use the app")};
227  ui->tutorialsLink->setText(R"(<a href=")" + constants::VIDEO_TUTORIAL_URL + R"(" style="text-decoration:none;">)" + tutorialsLabel + R"(</a>)");
228 
230  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveConsoleHistory()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::saveConsoleHistory ( )
inline
185  {
186  const std::vector<std::string> history{ui->consoleWidget->getHistory()};
188  }
Here is the call graph for this function:

◆ saveGlobalSettingsTemplate()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::saveGlobalSettingsTemplate ( ) const
inline
200  {
201  const QString path{common::ui::openSaveGlobalSettingsDialog(q)};
202  if(path.isEmpty()) {
203  return;
204  }
206  }
Here is the call graph for this function:

◆ setCommandHandlerName()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::setCommandHandlerName ( const std::string &  name)
inline
166  {
167  q->setObjectName(QString::fromStdString(name));
168  }

◆ setConsoleVisibility()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::setConsoleVisibility ( const bool  visible)
inline
171  {
172  if(ui->actionScript_Console->isChecked() != visible) {
173  ui->actionScript_Console->setChecked(visible);
174  }
175  ui->consoleWidget->setVisible(visible);
176  }

◆ setupLogo()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::setupLogo ( )
inlineprivate
245  {
246  const QString logoPath{":/logos/logo_small.png"};
247 
248  if(!geometrize::preferences::getGlobalPreferences().shouldGeometrizeAppLogoOnLaunch()) {
249  ui->logoLabel->setPixmap(logoPath);
250  } else {
251  QImage image(logoPath);
252  image = image.convertToFormat(QImage::Format_RGBA8888); // Note doing this to guarantee format is RGBA8888
253 
254  geometrize::Bitmap logoBitmap{image::createBitmap(image)};
255  geometrize::Bitmap initialBitmap{logoBitmap.getWidth(), logoBitmap.getHeight(), geometrize::rgba{0, 0, 0, 0}};
256  m_logoTask = std::make_unique<task::ImageTask>(logoBitmap, initialBitmap, Qt::QueuedConnection);
257  m_logoTask->getPreferences().setShapeTypes(geometrize::ShapeTypes::RECTANGLE);
258  m_logoTask->getPreferences().setShapeAlpha(255U);
259 
260  ui->logoLabel->setPixmap(image::createPixmap(m_logoTask->getCurrent()));
261 
262  connect(m_logoTask.get(), &task::ImageTask::signal_modelDidStep, [this](std::vector<geometrize::ShapeResult> /*results*/) {
263  const QPixmap pixmap{image::createPixmap(m_logoTask->getCurrent())};
264  ui->logoLabel->setPixmap(pixmap);
265 
267 
268  m_logoTaskSteps++;
270  m_logoTask->stepModel();
271  }
272  });
273  m_logoTask->stepModel();
274  }
275  }
Here is the call graph for this function:

◆ updateLogoTaskProgress()

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::updateLogoTaskProgress ( )
inlineprivate
233  {
234  if(!geometrize::preferences::getGlobalPreferences().shouldGeometrizeAppLogoOnLaunch()) {
235  ui->logoLabel->setToolTip("");
236  return;
237  }
238 
239  const QString logoToolTip{tr("%1/%2 shapes", "Text showing the number of shapes that have been created to replicate an image so far e.g. 230/300 shapes")
240  .arg(QLocale().toString(static_cast<qlonglong>(m_logoTaskSteps))).arg(QLocale().toString(static_cast<qlonglong>(m_maxLogoTaskSteps)))};
241  ui->logoLabel->setToolTip(logoToolTip);
242  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_engine

std::unique_ptr<chaiscript::ChaiScript> geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_engine
private

◆ m_logoTask

std::unique_ptr<task::ImageTask> geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_logoTask
private

◆ m_logoTaskSteps

std::size_t geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_logoTaskSteps {0}
private

◆ m_maxLogoTaskSteps

const std::size_t geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_maxLogoTaskSteps {300ULL}
private

◆ q

LaunchWindow* geometrize::dialog::LaunchWindow::LaunchWindowImpl::q
private

◆ ui

std::unique_ptr<Ui::LaunchWindow> geometrize::dialog::LaunchWindow::LaunchWindowImpl::ui
private

The documentation for this class was generated from the following file:
geometrize::preferences::GlobalPreferences::load
bool load(const std::string &filePath)
load Loads the global preferences from a file.
Definition: globalpreferences.cpp:448
geometrize::dialog::LaunchWindow::LaunchWindow
LaunchWindow()
Definition: launchwindow.cpp:286
geometrize::dialog::ScriptConsole::launchConsoleHistoryFilename
static const std::string launchConsoleHistoryFilename
The name of the console history settings file used by the console embedded in the launch window.
Definition: scriptconsole.h:33
geometrize::constants::MORE_RESOURCES_URL
const QString MORE_RESOURCES_URL
URL to a webpage providing additional templates, scripts and/or helpful links.
Definition: constants.h:14
geometrize::dialog::LaunchWindow::on_actionSave_Global_Preferences_triggered
void on_actionSave_Global_Preferences_triggered()
Definition: launchwindow.cpp:362
geometrize::dialog::LaunchWindow::LaunchWindowImpl::ui
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:277
geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_maxLogoTaskSteps
const std::size_t m_maxLogoTaskSteps
Definition: launchwindow.cpp:282
geometrize::dialog::LaunchWindow::LaunchWindowImpl::updateLogoTaskProgress
void updateLogoTaskProgress()
Definition: launchwindow.cpp:232
geometrize::dialog::LaunchWindow::on_actionClear_Recents_triggered
void on_actionClear_Recents_triggered()
Definition: launchwindow.cpp:367
geometrize::version::getApplicationVersionString
QString getApplicationVersionString()
getApplicationVersionString Gets the application version as a string in VERSION.MAJOR....
Definition: versioninfo.cpp:13
geometrize::constants::VIDEO_TUTORIAL_URL
const QString VIDEO_TUTORIAL_URL
The video tutorial webpage URL for the software.
Definition: constants.h:15
geometrize::dialog::LaunchWindow::on_actionGlobal_Preferences_triggered
void on_actionGlobal_Preferences_triggered()
Definition: launchwindow.cpp:352
geometrize::getRecentItems
RecentItems & getRecentItems()
getRecentItems Gets a reference to the recent files list.
Definition: recentitems.cpp:206
geometrize::image::createBitmap
Bitmap createBitmap(const QImage &image)
createBitmap Creates a bitmap data object from the given image.
Definition: imageloader.cpp:22
geometrize::preferences::GlobalPreferences::save
bool save(const std::string &filePath)
save Saves the global preferences to a file.
Definition: globalpreferences.cpp:453
geometrize::strings::Strings::getApplicationName
static QString getApplicationName()
getApplicationName Gets the name of the application.
Definition: strings.cpp:9
geometrize::script::Command::getStringArg
std::string getStringArg(const std::string &key) const
Definition: command.cpp:20
geometrize::dialog::LaunchWindow::LaunchWindowImpl::populateUi
void populateUi()
Definition: launchwindow.cpp:215
geometrize::image::createPixmap
QPixmap createPixmap(const Bitmap &data)
createPixmap Creates a pixmap from the bitmap data object. Assumes RGBA8888 format.
Definition: imageloader.cpp:59
geometrize::common::ui::openSaveGlobalSettingsDialog
QString openSaveGlobalSettingsDialog(QWidget *parent)
Definition: uiactions.cpp:236
geometrize::script::Command::getCommand
std::string getCommand() const
Definition: command.cpp:15
geometrize::dialog::LaunchWindow::LaunchWindowImpl::loadConsoleHistory
void loadConsoleHistory()
Definition: launchwindow.cpp:178
geometrize::common::ui::openLoadGlobalSettingsDialog
QString openLoadGlobalSettingsDialog(QWidget *parent)
Definition: uiactions.cpp:228
geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_logoTaskSteps
std::size_t m_logoTaskSteps
Definition: launchwindow.cpp:283
geometrize::util::writeStringVector
void writeStringVector(const std::vector< std::string > &vec, const std::string &filePath)
writeStringVector Writes the string vector to the given filepath as JSON. Will attempt to overwrite a...
Definition: serializationutil.cpp:37
geometrize::dialog::LaunchWindow::on_actionLoad_Global_Preferences_triggered
void on_actionLoad_Global_Preferences_triggered()
Definition: launchwindow.cpp:357
geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_engine
std::unique_ptr< chaiscript::ChaiScript > m_engine
Definition: launchwindow.cpp:279
geometrize::dialog::TemplateGrid::signal_templateLoaded
void signal_templateLoaded(QString, bool)
geometrize::dialog::LaunchWindow::LaunchWindowImpl::setConsoleVisibility
void setConsoleVisibility(const bool visible)
Definition: launchwindow.cpp:170
geometrize::dialog::LaunchWindow::LaunchWindowImpl::q
LaunchWindow * q
Definition: launchwindow.cpp:278
geometrize::dialog::LaunchWindow::on_actionExit_triggered
void on_actionExit_triggered()
Definition: launchwindow.cpp:372
geometrize::util::getAppDataLocation
std::string getAppDataLocation()
getAppDataLocation Returns a directory location where persistent application data can be stored.
Definition: util.cpp:319
geometrize::preferences::getGlobalPreferences
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
geometrize::task::ImageTask::signal_modelDidStep
void signal_modelDidStep(std::vector< geometrize::ShapeResult > shapes)
signal_modelDidStep Signal that is emitted immediately after the underlying image task model is stepp...
geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_logoTask
std::unique_ptr< task::ImageTask > m_logoTask
Definition: launchwindow.cpp:281
geometrize::dialog::LaunchWindow::LaunchWindowImpl::setupLogo
void setupLogo()
Definition: launchwindow.cpp:244
geometrize::script::createLaunchWindowEngine
std::unique_ptr< chaiscript::ChaiScript > createLaunchWindowEngine()
createLaunchWindowEngine Creates a Chaiscript engine object for the launch window script console.
Definition: chaiscriptcreator.cpp:37
geometrize::util::readStringVector
std::vector< std::string > readStringVector(const std::string &filePath)
readStringVector Reads the JSON file containing the vector of strings at the given filepath....
Definition: serializationutil.cpp:20