Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercury13 committed May 7, 2022
1 parent dabe85a commit 89296ce
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 16 deletions.
4 changes: 2 additions & 2 deletions UTranslator/FmMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@ void FmMain::loadObject(tr::UiObject& obj)
ui->chkIdless->setChecked(fi->isIdless);
bool canAddFiles = project->info.canAddFiles();
ui->pageFile->setEnabled(canAddFiles);
ui->wiId->show();
ui->wiId->setEnabled(canAddFiles);
} else if (auto tr = obj.translatable()) { // mutually exclusive with fileInfo
ui->wiId->setEnabled(project->info.canEditOriginal());
if (project->info.canEditOriginal()) {
ui->stackOriginal->setCurrentWidget(ui->pageOriginal);
setMemo(ui->grpOriginal, ui->memoOriginal, tr->original);
Expand All @@ -631,7 +631,7 @@ void FmMain::loadObject(tr::UiObject& obj)
}
setMemo(ui->grpTranslation, ui->memoTranslation, tr->translationSv());
} else {
ui->wiId->setVisible(project->info.canEditOriginal());
ui->wiId->setEnabled(false);
ui->stackOriginal->setCurrentWidget(ui->pageOriginal);
ui->grpOriginal->setEnabled(false);
ui->grpTranslation->setEnabled(false);
Expand Down
14 changes: 11 additions & 3 deletions UTranslator/FmMain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ QLabel {
<number>5</number>
</property>
<item>
<widget class="QLabel" name="lbUpdate">
<widget class="ElidedLabel" name="lbUpdate">
<property name="text">
<string notr="true">[lbUpdate] update update update here!</string>
</property>
Expand Down Expand Up @@ -301,8 +301,11 @@ QLabel {
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,1">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="lbRealPath">
<property name="text">
<string>File’s real path</string>
</property>
Expand Down Expand Up @@ -935,6 +938,11 @@ QLabel {
</action>
</widget>
<customwidgets>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header>ElidedLabel.h</header>
</customwidget>
<customwidget>
<class>WiFind</class>
<extends>QWidget</extends>
Expand All @@ -947,12 +955,12 @@ QLabel {
<tabstop>btStartOpen</tabstop>
<tabstop>treeStrings</tabstop>
<tabstop>edId</tabstop>
<tabstop>lineEdit</tabstop>
<tabstop>memoOriginal</tabstop>
<tabstop>chkIdless</tabstop>
<tabstop>btFileFormat</tabstop>
<tabstop>memoTranslation</tabstop>
<tabstop>memoComment</tabstop>
<tabstop>browContext</tabstop>
<tabstop>edCompatId</tabstop>
<tabstop>btEditCompatId</tabstop>
<tabstop>btStartEdit</tabstop>
Expand Down
2 changes: 1 addition & 1 deletion UTranslator/FmNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void FmNew::reenableSettingsPage()
if (project) {
ui->edOriginal->setCurrentText(QString::fromStdString(project->info.orig.lang));
}
ui->wiOriginal->setEnabled(tr::PrjInfo::isOrigUnlocked(type));
ui->wiOriginal->setEnabled(tr::PrjInfo::canAddFiles(type));
ui->wiTranslation->setVisible(tr::PrjInfo::isTranslation(type));
}

Expand Down
4 changes: 2 additions & 2 deletions UTranslator/TrProject/TrDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ bool tr::PrjInfo::canEditOriginal() const
}


bool tr::PrjInfo::isOrigUnlocked(PrjType type)
bool tr::PrjInfo::canAddFiles(PrjType type)
{
switch (type) {
case PrjType::ORIGINAL:
return true;
case PrjType::FULL_TRANSL:
return false;
}
throw std::logic_error("[isOrigUnlocked] Strange project type");
throw std::logic_error("[canAddFiles] Strange project type");
}


Expand Down
34 changes: 26 additions & 8 deletions UTranslator/TrProject/TrDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,43 @@ namespace tr {

/// @return [+] can edit original, incl. adding files
bool canEditOriginal() const;
/// @return [+] can add/remove files

/// @return [+] can add/remove files, edit orig. settings
/// @warning canEditOriginal → canAddFiles
/// (the converse is false for freestyle project)
/// @todo [freestyle, #12] we’ll have freestyle translation,
/// ot can edit files, but cannot edit original
bool canAddFiles() const { return canEditOriginal(); }
/// @return [+] Original’s settings are unlocked
static bool isOrigUnlocked(PrjType type);
bool isOrigUnlocked() const { return isOrigUnlocked(type); }
/// it can edit files, but cannot edit original
static bool canAddFiles(PrjType type);
bool canAddFiles() const { return canAddFiles(type); }

/// @return [+] Everything translation-related is available,
/// incl. column, transl. settings…
/// incl. two new channels (translation, translator’s comment),
/// translation settings…
static bool isTranslation(PrjType type);
bool isTranslation() const { return isTranslation(type); }

/// @return [+] is full translation, e.g. empty translation automatically needs attention.
/// @warning isFullTranslation → isTranslation
/// @todo [patch, #23] what to do?
bool isFullTranslation() const { return isTranslation(); }

/// @return [+] original path matters
/// @warning hasOriginalPath → isTranslation
/// the converse is false for freestyle translation,
/// bilingual
static bool hasOriginalPath(PrjType type);
bool hasOriginalPath() { return hasOriginalPath(type); }
bool hasOriginalPath() const { return hasOriginalPath(type); }
};

// Project types
// Original Bilingual Normal Freestyle
// canAddFiles YES YES no YES
// canEditOriginal YES YES no no
// isTranslation no YES YES YES
// isFullTranslation no depends depends depends
// hasOriginalPath no no YES no
//

struct FileInfo {
CloningUptr<tf::FileFormat> format;
std::filesystem::path origPath, translPath;
Expand Down

0 comments on commit 89296ce

Please sign in to comment.