mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
added hide flag to executables
This commit is contained in:
@@ -97,6 +97,7 @@ EditExecutablesDialog::EditExecutablesDialog(OrganizerCore& oc, int sel, QWidget
|
||||
connect(ui->steamAppID, &QLineEdit::textChanged, [&]{ save(); });
|
||||
connect(ui->mods, &QComboBox::currentTextChanged, [&]{ save(); });
|
||||
connect(ui->useApplicationIcon, &QCheckBox::toggled, [&]{ save(); });
|
||||
connect(ui->hide, &QCheckBox::toggled, [&]{ save(); });
|
||||
connect(ui->list->model(), &QAbstractItemModel::rowsMoved, [&]{ saveOrder(); });
|
||||
}
|
||||
|
||||
@@ -316,6 +317,8 @@ void EditExecutablesDialog::clearEdits()
|
||||
ui->configureLibraries->setEnabled(false);
|
||||
ui->useApplicationIcon->setEnabled(false);
|
||||
ui->useApplicationIcon->setChecked(false);
|
||||
ui->hide->setEnabled(false);
|
||||
ui->hide->setChecked(false);
|
||||
|
||||
m_lastGoodTitle = "";
|
||||
}
|
||||
@@ -330,6 +333,7 @@ void EditExecutablesDialog::setEdits(const Executable& e)
|
||||
ui->steamAppID->setEnabled(!e.steamAppID().isEmpty());
|
||||
ui->steamAppID->setText(e.steamAppID());
|
||||
ui->useApplicationIcon->setChecked(e.usesOwnIcon());
|
||||
ui->hide->setChecked(e.hide());
|
||||
|
||||
m_lastGoodTitle = e.title();
|
||||
|
||||
@@ -375,6 +379,7 @@ void EditExecutablesDialog::setEdits(const Executable& e)
|
||||
ui->useApplicationIcon->setEnabled(true);
|
||||
ui->createFilesInMod->setEnabled(true);
|
||||
ui->forceLoadLibraries->setEnabled(true);
|
||||
ui->hide->setEnabled(true);
|
||||
}
|
||||
|
||||
void EditExecutablesDialog::save()
|
||||
@@ -434,6 +439,12 @@ void EditExecutablesDialog::save()
|
||||
e->flags(e->flags() & (~Executable::UseApplicationIcon));
|
||||
}
|
||||
|
||||
if (ui->hide->isChecked()) {
|
||||
e->flags(e->flags() | Executable::Hide);
|
||||
} else {
|
||||
e->flags(e->flags() & (~Executable::Hide));
|
||||
}
|
||||
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ Right now the only case I know of where this needs to be overwritten is for the
|
||||
<string>If this is enabled, new files are created in the specified mod instead of the "Overwrite" mod.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Files in Mod instead of Overwrite (*)</string>
|
||||
<string>Create files in mod instead of overwrite (*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -399,7 +399,7 @@ Right now the only case I know of where this needs to be overwritten is for the
|
||||
<string>If this is enabled, the configured libraries will be automatically loaded when this executable is launched.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Force Load Libraries (*)</string>
|
||||
<string>Force load libraries (*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -431,14 +431,27 @@ Right now the only case I know of where this needs to be overwritten is for the
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useApplicationIcon">
|
||||
<property name="text">
|
||||
<string>Use Application's Icon for desktop shortcuts</string>
|
||||
<string>Use application's icon for desktop shortcuts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hide">
|
||||
<property name="toolTip">
|
||||
<string>This executable will not appear in the list, on the toolbar or in the menu. It will still be visible in this dialog.</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>This executable will not appear in the list, on the toolbar or in the menu. It will still be visible in this dialog.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide in user interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>(*) Profile Specific</string>
|
||||
<string>(*) Profile specific</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
|
||||
+13
-3
@@ -84,6 +84,9 @@ void ExecutablesList::load(const MOBase::IPluginGame* game, const Settings& s)
|
||||
if (map["ownicon"].toBool())
|
||||
flags |= Executable::UseApplicationIcon;
|
||||
|
||||
if (map["hide"].toBool())
|
||||
flags |= Executable::Hide;
|
||||
|
||||
if (map.contains("custom")) {
|
||||
// the "custom" setting only exists in older versions
|
||||
needsUpgrade = true;
|
||||
@@ -116,6 +119,7 @@ void ExecutablesList::store(Settings& s)
|
||||
map["title"] = item.title();
|
||||
map["toolbar"] = item.isShownOnToolbar();
|
||||
map["ownicon"] = item.usesOwnIcon();
|
||||
map["hide"] = item.hide();
|
||||
map["binary"] = item.binaryInfo().absoluteFilePath();
|
||||
map["arguments"] = item.arguments();
|
||||
map["workingDirectory"] = item.workingDirectory();
|
||||
@@ -343,6 +347,10 @@ void ExecutablesList::dump() const
|
||||
flags.push_back("icon");
|
||||
}
|
||||
|
||||
if (e.flags() & Executable::Hide) {
|
||||
flags.push_back("hide");
|
||||
}
|
||||
|
||||
log::debug(
|
||||
" . executable '{}'\n"
|
||||
" binary: {}\n"
|
||||
@@ -456,11 +464,13 @@ bool Executable::usesOwnIcon() const
|
||||
return m_flags.testFlag(UseApplicationIcon);
|
||||
}
|
||||
|
||||
bool Executable::hide() const
|
||||
{
|
||||
return m_flags.testFlag(Hide);
|
||||
}
|
||||
|
||||
void Executable::mergeFrom(const Executable& other)
|
||||
{
|
||||
// flags on plugin executables that the user is allowed to change
|
||||
const auto allow = ShowInToolbar;
|
||||
|
||||
// this happens after executables are loaded from settings and plugin
|
||||
// executables are being added, or when users are modifying executables
|
||||
|
||||
|
||||
@@ -39,8 +39,9 @@ class Executable
|
||||
public:
|
||||
enum Flag
|
||||
{
|
||||
ShowInToolbar = 0x02,
|
||||
UseApplicationIcon = 0x04
|
||||
ShowInToolbar = 0x02,
|
||||
UseApplicationIcon = 0x04,
|
||||
Hide = 0x08
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(Flags, Flag);
|
||||
@@ -69,6 +70,7 @@ public:
|
||||
bool isShownOnToolbar() const;
|
||||
void setShownOnToolbar(bool state);
|
||||
bool usesOwnIcon() const;
|
||||
bool hide() const;
|
||||
|
||||
void mergeFrom(const Executable& other);
|
||||
|
||||
|
||||
+103
-42
@@ -757,7 +757,7 @@ void MainWindow::updatePinnedExecutables()
|
||||
bool hasLinks = false;
|
||||
|
||||
for (const auto& exe : *m_OrganizerCore.executablesList()) {
|
||||
if (exe.isShownOnToolbar()) {
|
||||
if (!exe.hide() && exe.isShownOnToolbar()) {
|
||||
hasLinks = true;
|
||||
|
||||
QAction *exeAction = new QAction(
|
||||
@@ -1792,23 +1792,44 @@ bool MainWindow::refreshProfiles(bool selectProfile)
|
||||
|
||||
void MainWindow::refreshExecutablesList()
|
||||
{
|
||||
QComboBox* executablesList = findChild<QComboBox*>("executablesListBox");
|
||||
executablesList->setEnabled(false);
|
||||
executablesList->clear();
|
||||
executablesList->addItem(tr("<Edit...>"));
|
||||
QAbstractItemModel *model = ui->executablesListBox->model();
|
||||
|
||||
QAbstractItemModel *model = executablesList->model();
|
||||
auto add = [&](const QString& title, const QFileInfo& binary) {
|
||||
QIcon icon;
|
||||
if (!binary.fileName().isEmpty()) {
|
||||
icon = iconForExecutable(binary.filePath());
|
||||
}
|
||||
|
||||
ui->executablesListBox->addItem(icon, title);
|
||||
|
||||
const auto i = ui->executablesListBox->count() - 1;
|
||||
|
||||
model->setData(
|
||||
model->index(i, 0),
|
||||
QSize(0, ui->executablesListBox->iconSize().height() + 4),
|
||||
Qt::SizeHintRole);
|
||||
};
|
||||
|
||||
|
||||
ui->executablesListBox->setEnabled(false);
|
||||
ui->executablesListBox->clear();
|
||||
|
||||
add(tr("<Edit...>"), {});
|
||||
|
||||
int i = 0;
|
||||
for (const auto& exe : *m_OrganizerCore.executablesList()) {
|
||||
QIcon icon = iconForExecutable(exe.binaryInfo().filePath());
|
||||
executablesList->addItem(icon, exe.title());
|
||||
model->setData(model->index(i, 0), QSize(0, executablesList->iconSize().height() + 4), Qt::SizeHintRole);
|
||||
++i;
|
||||
if (!exe.hide()) {
|
||||
add(exe.title(), exe.binaryInfo());
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->executablesListBox->count() == 1) {
|
||||
// all executables are hidden, add an empty one to at least be able to
|
||||
// switch to edit
|
||||
add(tr("(no executables)"), QFileInfo(":badfile"));
|
||||
}
|
||||
|
||||
ui->executablesListBox->setCurrentIndex(1);
|
||||
executablesList->setEnabled(true);
|
||||
ui->executablesListBox->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -2321,27 +2342,42 @@ void MainWindow::installMod(QString fileName)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_startButton_clicked() {
|
||||
ui->startButton->setEnabled(false);
|
||||
void MainWindow::on_startButton_clicked()
|
||||
{
|
||||
try {
|
||||
const Executable &selectedExecutable(getSelectedExecutable());
|
||||
QString customOverwrite = m_OrganizerCore.currentProfile()->setting("custom_overwrites", selectedExecutable.title()).toString();
|
||||
auto forcedLibraries = m_OrganizerCore.currentProfile()->determineForcedLibraries(selectedExecutable.title());
|
||||
if (!m_OrganizerCore.currentProfile()->forcedLibrariesEnabled(selectedExecutable.title())) {
|
||||
const Executable* selectedExecutable = getSelectedExecutable();
|
||||
if (!selectedExecutable) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui->startButton->setEnabled(false);
|
||||
|
||||
auto* profile = m_OrganizerCore.currentProfile();
|
||||
|
||||
const QString customOverwrite = profile->setting(
|
||||
"custom_overwrites", selectedExecutable->title()).toString();
|
||||
|
||||
auto forcedLibraries = profile->determineForcedLibraries(
|
||||
selectedExecutable->title());
|
||||
|
||||
if (!profile->forcedLibrariesEnabled(selectedExecutable->title())) {
|
||||
forcedLibraries.clear();
|
||||
}
|
||||
|
||||
m_OrganizerCore.spawnBinary(
|
||||
selectedExecutable.binaryInfo(), selectedExecutable.arguments(),
|
||||
selectedExecutable.workingDirectory().length() != 0
|
||||
? selectedExecutable.workingDirectory()
|
||||
: selectedExecutable.binaryInfo().absolutePath(),
|
||||
selectedExecutable.steamAppID(),
|
||||
customOverwrite,
|
||||
forcedLibraries);
|
||||
selectedExecutable->binaryInfo(),
|
||||
selectedExecutable->arguments(),
|
||||
selectedExecutable->workingDirectory().length() != 0 ?
|
||||
selectedExecutable->workingDirectory() :
|
||||
selectedExecutable->binaryInfo().absolutePath(),
|
||||
selectedExecutable->steamAppID(),
|
||||
customOverwrite,
|
||||
forcedLibraries);
|
||||
} catch (...) {
|
||||
ui->startButton->setEnabled(true);
|
||||
throw;
|
||||
}
|
||||
|
||||
ui->startButton->setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -2376,7 +2412,13 @@ void MainWindow::on_executablesListBox_currentIndexChanged(int index)
|
||||
|
||||
if (index == 0) {
|
||||
modifyExecutablesDialog(previousIndex - 1);
|
||||
ui->executablesListBox->setCurrentIndex(previousIndex);
|
||||
const auto newCount = ui->executablesListBox->count();
|
||||
|
||||
if (previousIndex >= 0 && previousIndex < newCount) {
|
||||
ui->executablesListBox->setCurrentIndex(previousIndex);
|
||||
} else {
|
||||
ui->executablesListBox->setCurrentIndex(newCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2452,8 +2494,14 @@ void MainWindow::on_actionAdd_Profile_triggered()
|
||||
void MainWindow::on_actionModify_Executables_triggered()
|
||||
{
|
||||
const auto sel = (m_OldExecutableIndex > 0 ? m_OldExecutableIndex - 1 : 0);
|
||||
|
||||
if (modifyExecutablesDialog(sel)) {
|
||||
ui->executablesListBox->setCurrentIndex(m_OldExecutableIndex);
|
||||
const auto newCount = ui->executablesListBox->count();
|
||||
if (m_OldExecutableIndex >= 0 && m_OldExecutableIndex < newCount) {
|
||||
ui->executablesListBox->setCurrentIndex(m_OldExecutableIndex);
|
||||
} else {
|
||||
ui->executablesListBox->setCurrentIndex(newCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4972,33 +5020,43 @@ void MainWindow::on_savegameList_customContextMenuRequested(const QPoint &pos)
|
||||
|
||||
void MainWindow::linkToolbar()
|
||||
{
|
||||
Executable& exe = getSelectedExecutable();
|
||||
Executable* exe = getSelectedExecutable();
|
||||
if (!exe) {
|
||||
return;
|
||||
}
|
||||
|
||||
exe.setShownOnToolbar(!exe.isShownOnToolbar());
|
||||
exe->setShownOnToolbar(!exe->isShownOnToolbar());
|
||||
updatePinnedExecutables();
|
||||
}
|
||||
|
||||
void MainWindow::linkDesktop()
|
||||
{
|
||||
env::Shortcut(getSelectedExecutable()).toggle(env::Shortcut::Desktop);
|
||||
if (auto* exe=getSelectedExecutable()) {
|
||||
env::Shortcut(*exe).toggle(env::Shortcut::Desktop);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::linkMenu()
|
||||
{
|
||||
env::Shortcut(getSelectedExecutable()).toggle(env::Shortcut::StartMenu);
|
||||
if (auto* exe=getSelectedExecutable()) {
|
||||
env::Shortcut(*exe).toggle(env::Shortcut::StartMenu);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_linkButton_pressed()
|
||||
{
|
||||
const Executable& exe = getSelectedExecutable();
|
||||
const Executable* exe = getSelectedExecutable();
|
||||
if (!exe) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QIcon addIcon(":/MO/gui/link");
|
||||
const QIcon removeIcon(":/MO/gui/remove");
|
||||
|
||||
env::Shortcut shortcut(exe);
|
||||
env::Shortcut shortcut(*exe);
|
||||
|
||||
m_LinkToolbar->setIcon(
|
||||
exe.isShownOnToolbar() ? removeIcon : addIcon);
|
||||
exe->isShownOnToolbar() ? removeIcon : addIcon);
|
||||
|
||||
m_LinkDesktop->setIcon(
|
||||
shortcut.exists(env::Shortcut::Desktop) ? removeIcon : addIcon);
|
||||
@@ -6327,16 +6385,19 @@ void MainWindow::on_groupCombo_currentIndexChanged(int index)
|
||||
modFilterActive(m_ModListSortProxy->isFilterActive());
|
||||
}
|
||||
|
||||
const Executable &MainWindow::getSelectedExecutable() const
|
||||
Executable* MainWindow::getSelectedExecutable()
|
||||
{
|
||||
const QString name = ui->executablesListBox->itemText(ui->executablesListBox->currentIndex());
|
||||
return m_OrganizerCore.executablesList()->get(name);
|
||||
}
|
||||
const QString name = ui->executablesListBox->itemText(
|
||||
ui->executablesListBox->currentIndex());
|
||||
|
||||
Executable &MainWindow::getSelectedExecutable()
|
||||
{
|
||||
const QString name = ui->executablesListBox->itemText(ui->executablesListBox->currentIndex());
|
||||
return m_OrganizerCore.executablesList()->get(name);
|
||||
try
|
||||
{
|
||||
return &m_OrganizerCore.executablesList()->get(name);
|
||||
}
|
||||
catch(std::runtime_error&)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_showHiddenBox_toggled(bool checked)
|
||||
|
||||
+1
-2
@@ -397,8 +397,7 @@ private:
|
||||
// when painting the count
|
||||
QIcon m_originalNotificationIcon;
|
||||
|
||||
Executable const &getSelectedExecutable() const;
|
||||
Executable &getSelectedExecutable();
|
||||
Executable* getSelectedExecutable();
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user