Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
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 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

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 
72  ui->templateGrid->loadTemplates();
73  }
74 
75  // Set up the logo
76  setupLogo();
77  }
void setupLogo()
Definition: launchwindow.cpp:170
void signal_templateLoaded(QString, bool)
std::unique_ptr< chaiscript::ChaiScript > m_engine
Definition: launchwindow.cpp:205
TemplateManifest getTemplateManifest(const std::string &templateFolder)
Definition: taskutil.cpp:93
std::unique_ptr< chaiscript::ChaiScript > createLaunchWindowEngine()
createLaunchWindowEngine Creates a Chaiscript engine object for the launch window.
Definition: chaiscriptcreator.cpp:37
RecentItems & getRecentItems()
getRecentItems Gets a reference to the recent files list.
Definition: recentitems.cpp:206
bool shouldPopulateTemplatesOnLaunch() const
shouldPopulateTemplatesOnLaunch Gets the preference for whether to populate the task templates on the...
Definition: globalpreferences.cpp:488
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
void setConsoleVisibility(const bool visible)
Definition: launchwindow.cpp:96
void populateUi()
Definition: launchwindow.cpp:141
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
void loadConsoleHistory()
Definition: launchwindow.cpp:104
LaunchWindow * q
Definition: launchwindow.cpp:204

Here is the call graph for this function:

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

Member Function Documentation

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  }
LaunchWindow()
Definition: launchwindow.cpp:212

Here is the caller graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::loadConsoleHistory ( )
inline
105  {
107  ui->consoleWidget->setHistory(history);
108  }
std::string getAppDataLocation()
getAppDataLocation Returns a directory location where persistent application data can be stored...
Definition: util.cpp:261
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
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
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

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::loadGlobalSettingsTemplate ( )
inline
117  {
118  const QString path{common::ui::openLoadGlobalSettingsDialog(q)};
119  if(path.isEmpty()) {
120  return;
121  }
123  }
bool load(const std::string &filePath)
load Loads the global preferences from a file.
Definition: globalpreferences.cpp:448
QString openLoadGlobalSettingsDialog(QWidget *parent)
Definition: uiactions.cpp:228
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
LaunchWindow * q
Definition: launchwindow.cpp:204

Here is the call graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::onLanguageChange ( )
inline
135  {
136  ui->retranslateUi(q);
137  populateUi();
138  }
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
void populateUi()
Definition: launchwindow.cpp:141
LaunchWindow * q
Definition: launchwindow.cpp:204
LaunchWindowImpl geometrize::dialog::LaunchWindow::LaunchWindowImpl::operator= ( const LaunchWindowImpl )
delete
void geometrize::dialog::LaunchWindow::LaunchWindowImpl::populateUi ( )
inlineprivate
142  {
143  const QString windowTitle{geometrize::strings::Strings::getApplicationName()
144  .append(" ")
146 
147  q->setWindowTitle(windowTitle);
148 
149  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")};
150  ui->moreResourcesLink->setText(R"(<a href=")" + constants::MORE_RESOURCES_URL + R"(" style="text-decoration:none;">)" + moreResourcesLabel + R"(</a>)");
151 
152  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")};
153  ui->tutorialsLink->setText(R"(<a href=")" + constants::VIDEO_TUTORIAL_URL + R"(" style="text-decoration:none;">)" + tutorialsLabel + R"(</a>)");
154 
156  }
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
const QString MORE_RESOURCES_URL
URL to a webpage providing additional templates, scripts and/or helpful links.
Definition: constants.h:14
void updateLogoTaskProgress()
Definition: launchwindow.cpp:158
QString getApplicationVersionString()
getApplicationVersionString Gets the application version as a string in VERSION.MAJOR.MINOR format e.g. "1.0.0", "2.7.13".
Definition: versioninfo.cpp:13
LaunchWindow * q
Definition: launchwindow.cpp:204
static QString getApplicationName()
getApplicationName Gets the name of the application.
Definition: strings.cpp:9
const QString VIDEO_TUTORIAL_URL
The video tutorial webpage URL for the software.
Definition: constants.h:15

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::saveConsoleHistory ( )
inline
111  {
112  const std::vector<std::string> history{ui->consoleWidget->getHistory()};
114  }
std::string getAppDataLocation()
getAppDataLocation Returns a directory location where persistent application data can be stored...
Definition: util.cpp:261
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
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
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

Here is the call graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::saveGlobalSettingsTemplate ( ) const
inline
126  {
127  const QString path{common::ui::openSaveGlobalSettingsDialog(q)};
128  if(path.isEmpty()) {
129  return;
130  }
132  }
bool save(const std::string &filePath)
save Saves the global preferences to a file.
Definition: globalpreferences.cpp:453
QString openSaveGlobalSettingsDialog(QWidget *parent)
Definition: uiactions.cpp:236
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
LaunchWindow * q
Definition: launchwindow.cpp:204

Here is the call graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::setConsoleVisibility ( const bool  visible)
inline
97  {
98  if(ui->actionScript_Console->isChecked() != visible) {
99  ui->actionScript_Console->setChecked(visible);
100  }
101  ui->consoleWidget->setVisible(visible);
102  }
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203

Here is the caller graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::setupLogo ( )
inlineprivate
171  {
172  const QString logoPath{":/logos/logo_small.png"};
173 
174  if(!geometrize::preferences::getGlobalPreferences().shouldGeometrizeAppLogoOnLaunch()) {
175  ui->logoLabel->setPixmap(logoPath);
176  } else {
177  QImage image(logoPath);
178  image = image.convertToFormat(QImage::Format_RGBA8888); // Note doing this to guarantee format is RGBA8888
179 
180  geometrize::Bitmap logoBitmap{image::createBitmap(image)};
181  geometrize::Bitmap initialBitmap{logoBitmap.getWidth(), logoBitmap.getHeight(), geometrize::rgba{0, 0, 0, 0}};
182  m_logoTask = std::make_unique<task::ImageTask>(logoBitmap, initialBitmap, Qt::QueuedConnection);
183  m_logoTask->getPreferences().setShapeTypes(geometrize::ShapeTypes::RECTANGLE);
184  m_logoTask->getPreferences().setShapeAlpha(255U);
185 
186  ui->logoLabel->setPixmap(image::createPixmap(m_logoTask->getCurrent()));
187 
188  connect(m_logoTask.get(), &task::ImageTask::signal_modelDidStep, [this](std::vector<geometrize::ShapeResult> /*results*/) {
189  const QPixmap pixmap{image::createPixmap(m_logoTask->getCurrent())};
190  ui->logoLabel->setPixmap(pixmap);
191 
193 
194  m_logoTaskSteps++;
196  m_logoTask->stepModel();
197  }
198  });
199  m_logoTask->stepModel();
200  }
201  }
void signal_modelDidStep(std::vector< geometrize::ShapeResult > shapes)
signal_modelDidStep Signal that is emitted immediately after the underlying image task model is stepp...
const std::size_t m_maxLogoTaskSteps
Definition: launchwindow.cpp:208
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
std::unique_ptr< task::ImageTask > m_logoTask
Definition: launchwindow.cpp:207
std::size_t m_logoTaskSteps
Definition: launchwindow.cpp:209
void updateLogoTaskProgress()
Definition: launchwindow.cpp:158
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
QPixmap createPixmap(const Bitmap &data)
createPixmap Creates a pixmap from the bitmap data object. Assumes RGBA8888 format.
Definition: imageloader.cpp:57
Bitmap createBitmap(const QImage &image)
createBitmap Creates a bitmap data object from the given image.
Definition: imageloader.cpp:20

Here is the call graph for this function:

void geometrize::dialog::LaunchWindow::LaunchWindowImpl::updateLogoTaskProgress ( )
inlineprivate
159  {
160  if(!geometrize::preferences::getGlobalPreferences().shouldGeometrizeAppLogoOnLaunch()) {
161  ui->logoLabel->setToolTip("");
162  return;
163  }
164 
165  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")
166  .arg(QLocale().toString(static_cast<qlonglong>(m_logoTaskSteps))).arg(QLocale().toString(static_cast<qlonglong>(m_maxLogoTaskSteps)))};
167  ui->logoLabel->setToolTip(logoToolTip);
168  }
const std::size_t m_maxLogoTaskSteps
Definition: launchwindow.cpp:208
std::unique_ptr< Ui::LaunchWindow > ui
Definition: launchwindow.cpp:203
std::size_t m_logoTaskSteps
Definition: launchwindow.cpp:209
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32

Here is the call graph for this function:

Member Data Documentation

std::unique_ptr<chaiscript::ChaiScript> geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_engine
private
std::unique_ptr<task::ImageTask> geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_logoTask
private
std::size_t geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_logoTaskSteps {0}
private
const std::size_t geometrize::dialog::LaunchWindow::LaunchWindowImpl::m_maxLogoTaskSteps {300ULL}
private
LaunchWindow* geometrize::dialog::LaunchWindow::LaunchWindowImpl::q
private
std::unique_ptr<Ui::LaunchWindow> geometrize::dialog::LaunchWindow::LaunchWindowImpl::ui
private

The documentation for this class was generated from the following file: