Fix representer actions when show result as tooltip
This commit is contained in:
		
							parent
							
								
									c5b57d1d7a
								
							
						
					
					
						commit
						4fb3af6cbf
					
				@ -107,6 +107,8 @@ void Manager::updateSettings()
 | 
			
		||||
  setupProxy(*settings_);
 | 
			
		||||
  setupUpdates(*settings_);
 | 
			
		||||
 | 
			
		||||
  tray_->setTaskActionsEnabled(false);
 | 
			
		||||
 | 
			
		||||
  models_->update(settings_->tessdataPath);
 | 
			
		||||
 | 
			
		||||
  tray_->updateSettings();
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,12 @@ Representer::~Representer() = default;
 | 
			
		||||
 | 
			
		||||
void Representer::showLast()
 | 
			
		||||
{
 | 
			
		||||
  if (settings_.resultShowType == ResultMode::Tooltip) {
 | 
			
		||||
    SOFT_ASSERT(lastTooltipTask_, return );
 | 
			
		||||
    showTooltip(lastTooltipTask_);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  SOFT_ASSERT(!widgets_.empty(), return );
 | 
			
		||||
  for (auto &widget : widgets_) {
 | 
			
		||||
    SOFT_ASSERT(widget->task(), continue);
 | 
			
		||||
@ -38,6 +44,12 @@ void Representer::showLast()
 | 
			
		||||
 | 
			
		||||
void Representer::clipboardLast()
 | 
			
		||||
{
 | 
			
		||||
  if (settings_.resultShowType == ResultMode::Tooltip) {
 | 
			
		||||
    SOFT_ASSERT(lastTooltipTask_, return );
 | 
			
		||||
    clipboardText(lastTooltipTask_);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  SOFT_ASSERT(!widgets_.empty(), return );
 | 
			
		||||
  SOFT_ASSERT(widgets_.front()->task(), return );
 | 
			
		||||
  clipboardText(widgets_.front()->task());
 | 
			
		||||
@ -70,6 +82,7 @@ void Representer::hide()
 | 
			
		||||
 | 
			
		||||
void Representer::updateSettings()
 | 
			
		||||
{
 | 
			
		||||
  lastTooltipTask_.reset();
 | 
			
		||||
  if (widgets_.empty())
 | 
			
		||||
    return;
 | 
			
		||||
  for (auto &w : widgets_) w->updateSettings();
 | 
			
		||||
@ -128,12 +141,16 @@ bool Representer::eventFilter(QObject * /*watched*/, QEvent *event)
 | 
			
		||||
 | 
			
		||||
void Representer::showTooltip(const TaskPtr &task)
 | 
			
		||||
{
 | 
			
		||||
  SOFT_ASSERT(task, return );
 | 
			
		||||
  lastTooltipTask_ = task;
 | 
			
		||||
 | 
			
		||||
  auto message = task->recognized + " - " + task->translated;
 | 
			
		||||
  tray_.showInformation(message);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Representer::showWidget(const TaskPtr &task)
 | 
			
		||||
{
 | 
			
		||||
  SOFT_ASSERT(task, return );
 | 
			
		||||
  generation_ = task->generation;
 | 
			
		||||
 | 
			
		||||
  auto index = 0u;
 | 
			
		||||
 | 
			
		||||
@ -40,4 +40,5 @@ private:
 | 
			
		||||
  Generation generation_{};
 | 
			
		||||
  std::vector<std::unique_ptr<ResultWidget>> widgets_;
 | 
			
		||||
  std::unique_ptr<ResultEditor> editor_;
 | 
			
		||||
  TaskPtr lastTooltipTask_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user