From eaafc489fc625d71e4ce797cebb28056746896bc Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Thu, 9 Jul 2015 18:58:34 +0100 Subject: Reworking the Custom Executables list and the shortcut popup. Certainly fixes the issue where the 'toolbar' entry doesn't lose the cross. One of the 'find' methods ignored case but none of the others did, so I've made it not ignore case either. Also made the code to get the desktop/startmenu paths use a more up-to-date API --- src/executableslist.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index badf0813..91bfd39e 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -55,14 +55,6 @@ static QDataStream &operator>>(QDataStream &in, Executable &obj) return in; } - -void registerExecutable() -{ - qRegisterMetaType("Executable"); - qRegisterMetaTypeStreamOperators("Executable"); -} - - ExecutablesList::ExecutablesList() { } @@ -102,23 +94,23 @@ void ExecutablesList::getExecutables(std::vector::const_iterator &be const Executable &ExecutablesList::find(const QString &title) const { - for (std::vector::const_iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Title == title) { - return *iter; + for (Executable const &exe : m_Executables) { + if (exe.m_Title == title) { + return exe; } } - throw std::runtime_error("invalid name"); + throw std::runtime_error("invalid name " + title.toStdString()); } Executable &ExecutablesList::find(const QString &title) { for (Executable &exe : m_Executables) { - if (QString::compare(exe.m_Title, title, Qt::CaseInsensitive) == 0) { + if (exe.m_Title == title) { return exe; } } - throw std::runtime_error("invalid name"); + throw std::runtime_error("invalid name " + title.toStdString()); } @@ -220,7 +212,7 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executa void ExecutablesList::remove(const QString &title) { for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Custom && (iter->m_Title == title)) { + if (iter->m_Custom && iter->m_Title == title) { m_Executables.erase(iter); break; } -- cgit v1.3.1 From 050309749476aaa07afb00e7160abb4e5e693dcb Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sat, 18 Jul 2015 10:44:49 +0100 Subject: Allow user to select app icon or mo icon for generated shortcuts Also fixes 'x' for toolbar not disappearing when it should Issue 701 --- src/editexecutablesdialog.cpp | 23 ++++++++++++++++------- src/editexecutablesdialog.ui | 39 +++++++++++++++++++++++++-------------- src/executableslist.cpp | 30 +++++++++++++++--------------- src/executableslist.h | 3 ++- src/mainwindow.cpp | 18 ++++++++++++++++-- src/organizercore.cpp | 4 +++- 6 files changed, 77 insertions(+), 40 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 48d33c79..4ae0b351 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -84,18 +84,25 @@ void EditExecutablesDialog::resetInput() ui->appIDOverwriteEdit->clear(); ui->overwriteAppIDBox->setChecked(false); ui->closeCheckBox->setChecked(false); + ui->useAppIconCheckBox->setChecked(false); m_CurrentItem = nullptr; } void EditExecutablesDialog::saveExecutable() { - m_ExecutablesList.addExecutable(ui->titleEdit->text(), QDir::fromNativeSeparators(ui->binaryEdit->text()), - ui->argumentsEdit->text(), QDir::fromNativeSeparators(ui->workingDirEdit->text()), - (ui->closeCheckBox->checkState() == Qt::Checked) ? ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE - : ExecutableInfo::CloseMOStyle::DEFAULT_STAY, - ui->overwriteAppIDBox->isChecked() ? ui->appIDOverwriteEdit->text() : "", - true, false); + m_ExecutablesList.addExecutable(ui->titleEdit->text(), + QDir::fromNativeSeparators(ui->binaryEdit->text()), + ui->argumentsEdit->text(), + QDir::fromNativeSeparators(ui->workingDirEdit->text()), + (ui->closeCheckBox->checkState() == Qt::Checked) ? + ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE + : ExecutableInfo::CloseMOStyle::DEFAULT_STAY, + ui->overwriteAppIDBox->isChecked() ? + ui->appIDOverwriteEdit->text() : "", + true, + false, + ui->useAppIconCheckBox->isChecked()); } @@ -207,7 +214,8 @@ bool EditExecutablesDialog::executableChanged() || selectedExecutable.m_SteamAppID != ui->appIDOverwriteEdit->text() || selectedExecutable.m_WorkingDirectory != QDir::fromNativeSeparators(ui->workingDirEdit->text()) || selectedExecutable.m_BinaryInfo.absoluteFilePath() != QDir::fromNativeSeparators(ui->binaryEdit->text()) - || (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE) != ui->closeCheckBox->isChecked(); + || (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE) != ui->closeCheckBox->isChecked() + || selectedExecutable.m_UseOwnIcon != ui->useAppIconCheckBox->isChecked(); } else { return false; } @@ -288,5 +296,6 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur } else { ui->appIDOverwriteEdit->clear(); } + ui->useAppIconCheckBox->setChecked(selectedExecutable.m_UseOwnIcon); } } diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index 5a1137c9..abb6fe68 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -7,7 +7,7 @@ 0 0 384 - 362 + 446 @@ -164,21 +164,28 @@ Right now the only case I know of where this needs to be overwritten is for the + + + + If checked, MO will be closed once the specified executable is run. + + + If checked, MO will be closed once the specified executable is run. + + + Close MO when started + + + + + + + Use Application's Icon for shortcuts + + + - - - - If checked, MO will be closed once the specified executable is run. - - - If checked, MO will be closed once the specified executable is run. - - - Close MO when started - - - @@ -240,6 +247,10 @@ Right now the only case I know of where this needs to be overwritten is for the + executablesListBox + closeButton + closeCheckBox + useAppIconCheckBox diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 91bfd39e..1f5fee51 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -39,7 +39,7 @@ static QDataStream &operator<<(QDataStream &out, const Executable &obj) << obj.m_SteamAppID << obj.m_WorkingDirectory << obj.m_Custom - << obj.m_Toolbar; + << obj.m_Toolbar << obj.m_UseOwnIcon; return out; } @@ -48,7 +48,7 @@ static QDataStream &operator>>(QDataStream &in, Executable &obj) QString binaryTemp; int closeStyleTemp; in >> obj.m_Title >> binaryTemp >> obj.m_Arguments >> closeStyleTemp - >> obj.m_SteamAppID >> obj.m_WorkingDirectory >> obj.m_Custom >> obj.m_Toolbar; + >> obj.m_SteamAppID >> obj.m_WorkingDirectory >> obj.m_Custom >> obj.m_Toolbar >> obj.m_UseOwnIcon; obj.m_CloseMO = static_cast(closeStyleTemp); obj.m_BinaryInfo.setFile(binaryTemp); @@ -166,9 +166,15 @@ void ExecutablesList::position(const QString &title, bool toolbar, int pos) } -void ExecutablesList::addExecutable(const QString &title, const QString &executableName, const QString &arguments, - const QString &workingDirectory, ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, - bool custom, bool toolbar, int pos) +void ExecutablesList::addExecutable(const QString &title, + const QString &executableName, + const QString &arguments, + const QString &workingDirectory, + ExecutableInfo::CloseMOStyle closeMO, + const QString &steamAppID, + bool custom, + bool toolbar, + bool ownicon) { QFileInfo file(executableName); auto existingExe = findExe(title); @@ -184,11 +190,7 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executa existingExe->m_Arguments = arguments; existingExe->m_WorkingDirectory = workingDirectory; existingExe->m_SteamAppID = steamAppID; - } - if (pos >= 0) { - Executable temp = *existingExe; - m_Executables.erase(existingExe); - m_Executables.insert(m_Executables.begin() + pos, temp); + existingExe->m_UseOwnIcon = ownicon; } } else { Executable newExe; @@ -200,11 +202,8 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executa newExe.m_SteamAppID = steamAppID; newExe.m_Custom = true; newExe.m_Toolbar = toolbar; - if ((pos < 0) || (pos >= static_cast(m_Executables.size()))) { - m_Executables.push_back(newExe); - } else { - m_Executables.insert(m_Executables.begin() + pos, newExe); - } + newExe.m_UseOwnIcon = ownicon; + m_Executables.push_back(newExe); } } @@ -235,6 +234,7 @@ void ExecutablesList::addExecutableInternal(const QString &title, const QString newExe.m_SteamAppID = steamAppID; newExe.m_Custom = false; newExe.m_Toolbar = false; + newExe.m_UseOwnIcon = false; m_Executables.push_back(newExe); } } diff --git a/src/executableslist.h b/src/executableslist.h index cf2fbac3..8eda38f5 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -41,6 +41,7 @@ struct Executable { bool m_Custom; bool m_Toolbar; + bool m_UseOwnIcon; }; @@ -121,7 +122,7 @@ public: **/ void addExecutable(const QString &title, const QString &executableName, const QString &arguments, const QString &workingDirectory, MOBase::ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, - bool custom, bool toolbar, int pos = -1); + bool custom, bool toolbar, bool ownicon); /** * @brief change position of an executable which is expected to exist diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 946f3a73..bd880dac 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1626,6 +1626,7 @@ void MainWindow::on_startButton_clicked() static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments, LPCSTR linkFileName, LPCWSTR description, + LPCTSTR iconFileName, int iconNumber, LPCWSTR currentDirectory) { HRESULT result = E_INVALIDARG; @@ -1676,6 +1677,15 @@ static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments, } } + if (iconFileName != nullptr) { + result = shellLink->SetIconLocation(iconFileName, iconNumber); + if (!SUCCEEDED(result)) { + qCritical("failed to load program icon: %ls %d", iconFileName, iconNumber); + shellLink->Release(); + return result; + } + } + IPersistFile *persistFile; result = shellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&persistFile); if (SUCCEEDED(result)) { @@ -3283,16 +3293,20 @@ void MainWindow::addWindowsLink(Shortcut_Type const mapping) } else { QFileInfo const exeInfo(qApp->applicationFilePath()); // create link + QString executable = QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath()); + std::wstring targetFile = ToWString(exeInfo.absoluteFilePath()); - std::wstring parameter = ToWString(QString("\"%1\" %2").arg(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath())) + std::wstring parameter = ToWString(QString("\"%1\" %2").arg(executable) .arg(selectedExecutable.m_Arguments)); std::wstring description = ToWString(selectedExecutable.m_BinaryInfo.fileName()); + std::wstring iconFile = ToWString(executable); std::wstring currentDirectory = ToWString(QDir::toNativeSeparators(exeInfo.absolutePath())); if (CreateShortcut(targetFile.c_str() , parameter.c_str() , QDir::toNativeSeparators(linkName).toUtf8().constData() , description.c_str() + , (selectedExecutable.m_UseOwnIcon ? iconFile.c_str() : nullptr), 0 , currentDirectory.c_str()) == 0) { ui->linkButton->menu()->actions().at(static_cast(mapping))->setIcon(QIcon(":/MO/gui/remove")); } else { @@ -3530,7 +3544,7 @@ void MainWindow::addAsExecutable() m_OrganizerCore.executablesList()->addExecutable(name, binaryInfo.absoluteFilePath(), arguments, targetInfo.absolutePath(), ExecutableInfo::CloseMOStyle::DEFAULT_STAY, QString(), - true, false); + true, false, false); refreshExecutablesList(); } } break; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 8b2a755d..01141dd7 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -230,6 +230,7 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName) settings.setValue("workingDirectory", item.m_WorkingDirectory); settings.setValue("closeOnStart", item.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE); settings.setValue("steamAppID", item.m_SteamAppID); + settings.setValue("ownicon", item.m_UseOwnIcon); } } settings.endArray(); @@ -336,7 +337,8 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) closeMO, settings.value("steamAppID", "").toString(), settings.value("custom", true).toBool(), - settings.value("toolbar", false).toBool()); + settings.value("toolbar", false).toBool(), + settings.value("ownicon", false).toBool()); } settings.endArray(); -- cgit v1.3.1 From e1c8d00979793dd00a90d312ccdd275cf48dc4ad Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sat, 18 Jul 2015 13:34:10 +0100 Subject: Reworked executable lists to not use 3 bools in addExecutable Think it's more readable --- src/editexecutablesdialog.cpp | 15 ++++++----- src/executableslist.cpp | 61 +++++++++---------------------------------- src/executableslist.h | 49 ++++++++++++++++++++++++---------- src/mainwindow.cpp | 25 +++++++++++------- src/organizercore.cpp | 20 +++++++++----- 5 files changed, 83 insertions(+), 87 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 4ae0b351..97154789 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -60,7 +60,7 @@ void EditExecutablesDialog::refreshExecutablesWidget() for(; current != end; ++current) { QListWidgetItem *newItem = new QListWidgetItem(current->m_Title); - newItem->setTextColor(current->m_Custom ? QColor(Qt::black) : QColor(Qt::darkGray)); + newItem->setTextColor(current->m_Type == Executable::Type::Custom ? QColor(Qt::black) : QColor(Qt::darkGray)); ui->executablesListBox->addItem(newItem); } @@ -100,9 +100,10 @@ void EditExecutablesDialog::saveExecutable() : ExecutableInfo::CloseMOStyle::DEFAULT_STAY, ui->overwriteAppIDBox->isChecked() ? ui->appIDOverwriteEdit->text() : "", - true, - false, - ui->useAppIconCheckBox->isChecked()); + Executable::Type::Custom, + Executable::Toolbar::Disabled, + ui->useAppIconCheckBox->isChecked() ? + Executable::Icon::Application : Executable::Icon::MO); } @@ -215,7 +216,7 @@ bool EditExecutablesDialog::executableChanged() || selectedExecutable.m_WorkingDirectory != QDir::fromNativeSeparators(ui->workingDirEdit->text()) || selectedExecutable.m_BinaryInfo.absoluteFilePath() != QDir::fromNativeSeparators(ui->binaryEdit->text()) || (selectedExecutable.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE) != ui->closeCheckBox->isChecked() - || selectedExecutable.m_UseOwnIcon != ui->useAppIconCheckBox->isChecked(); + || selectedExecutable.usesOwnIcon() != ui->useAppIconCheckBox->isChecked(); } else { return false; } @@ -289,13 +290,13 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur ui->closeCheckBox->setEnabled(true); ui->closeCheckBox->setToolTip(tr("If checked, MO will be closed once the specified executable is run.")); } - ui->removeButton->setEnabled(selectedExecutable.m_Custom); + ui->removeButton->setEnabled(selectedExecutable.isCustom()); ui->overwriteAppIDBox->setChecked(!selectedExecutable.m_SteamAppID.isEmpty()); if (!selectedExecutable.m_SteamAppID.isEmpty()) { ui->appIDOverwriteEdit->setText(selectedExecutable.m_SteamAppID); } else { ui->appIDOverwriteEdit->clear(); } - ui->useAppIconCheckBox->setChecked(selectedExecutable.m_UseOwnIcon); + ui->useAppIconCheckBox->setChecked(selectedExecutable.usesOwnIcon()); } } diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 1f5fee51..ba2b5616 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -30,31 +30,6 @@ using namespace MOBase; using namespace MOShared; -static QDataStream &operator<<(QDataStream &out, const Executable &obj) -{ - out << obj.m_Title - << obj.m_BinaryInfo.absoluteFilePath() - << obj.m_Arguments - << static_cast::type>(obj.m_CloseMO) - << obj.m_SteamAppID - << obj.m_WorkingDirectory - << obj.m_Custom - << obj.m_Toolbar << obj.m_UseOwnIcon; - return out; -} - -static QDataStream &operator>>(QDataStream &in, Executable &obj) -{ - QString binaryTemp; - int closeStyleTemp; - in >> obj.m_Title >> binaryTemp >> obj.m_Arguments >> closeStyleTemp - >> obj.m_SteamAppID >> obj.m_WorkingDirectory >> obj.m_Custom >> obj.m_Toolbar >> obj.m_UseOwnIcon; - - obj.m_CloseMO = static_cast(closeStyleTemp); - obj.m_BinaryInfo.setFile(binaryTemp); - return in; -} - ExecutablesList::ExecutablesList() { } @@ -154,43 +129,31 @@ void ExecutablesList::addExecutable(const Executable &executable) } -void ExecutablesList::position(const QString &title, bool toolbar, int pos) -{ - auto existingExe = findExe(title); - if (existingExe != m_Executables.end()) { - Executable temp = *existingExe; - temp.m_Toolbar = toolbar; - m_Executables.erase(existingExe); - m_Executables.insert(m_Executables.begin() + pos, temp); - } -} - - void ExecutablesList::addExecutable(const QString &title, const QString &executableName, const QString &arguments, const QString &workingDirectory, ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, - bool custom, - bool toolbar, - bool ownicon) + Executable::Type custom, + Executable::Toolbar toolbar, + Executable::Icon ownicon) { QFileInfo file(executableName); auto existingExe = findExe(title); if (existingExe != m_Executables.end()) { existingExe->m_Title = title; - existingExe->m_Custom = custom; + existingExe->m_Type = custom; existingExe->m_CloseMO = closeMO; existingExe->m_Toolbar = toolbar; - if (custom) { + if (custom == Executable::Type::Custom) { // for pre-configured executables don't overwrite settings we didn't store existingExe->m_BinaryInfo = file; existingExe->m_Arguments = arguments; existingExe->m_WorkingDirectory = workingDirectory; existingExe->m_SteamAppID = steamAppID; - existingExe->m_UseOwnIcon = ownicon; + existingExe->m_Icon = ownicon; } } else { Executable newExe; @@ -200,9 +163,9 @@ void ExecutablesList::addExecutable(const QString &title, newExe.m_Arguments = arguments; newExe.m_WorkingDirectory = workingDirectory; newExe.m_SteamAppID = steamAppID; - newExe.m_Custom = true; + newExe.m_Type = Executable::Type::Custom; newExe.m_Toolbar = toolbar; - newExe.m_UseOwnIcon = ownicon; + newExe.m_Icon = ownicon; m_Executables.push_back(newExe); } } @@ -211,7 +174,7 @@ void ExecutablesList::addExecutable(const QString &title, void ExecutablesList::remove(const QString &title) { for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Custom && iter->m_Title == title) { + if (iter->isCustom() && iter->m_Title == title) { m_Executables.erase(iter); break; } @@ -232,9 +195,9 @@ void ExecutablesList::addExecutableInternal(const QString &title, const QString newExe.m_Arguments = arguments; newExe.m_WorkingDirectory = workingDirectory; newExe.m_SteamAppID = steamAppID; - newExe.m_Custom = false; - newExe.m_Toolbar = false; - newExe.m_UseOwnIcon = false; + newExe.m_Type = Executable::Type::Game; + newExe.m_Toolbar = Executable::Toolbar::Disabled; + newExe.m_Icon = Executable::Icon::MO; m_Executables.push_back(newExe); } } diff --git a/src/executableslist.h b/src/executableslist.h index 8eda38f5..4e1ad644 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -39,9 +39,32 @@ struct Executable { QString m_SteamAppID; QString m_WorkingDirectory; - bool m_Custom; - bool m_Toolbar; - bool m_UseOwnIcon; + enum class Type { + Game, + Custom + }; + + enum class Toolbar { + Disabled, + Enabled + }; + + enum class Icon { + MO, + Application + }; + + Type m_Type; + Toolbar m_Toolbar; + Icon m_Icon; + + bool isCustom() const { return m_Type == Type::Custom; } + + bool shownOnToolbar() const { return m_Toolbar == Toolbar::Enabled; } + + void showOnToolbar(bool state) { m_Toolbar = state ? Toolbar::Enabled : Toolbar::Disabled; } + + bool usesOwnIcon() const { return m_Icon == Icon::Application; } }; @@ -120,17 +143,15 @@ public: * @param arguments arguments to pass to the executable * @param closeMO if true, MO will be closed when the binary is started **/ - void addExecutable(const QString &title, const QString &executableName, const QString &arguments, - const QString &workingDirectory, MOBase::ExecutableInfo::CloseMOStyle closeMO, const QString &steamAppID, - bool custom, bool toolbar, bool ownicon); - - /** - * @brief change position of an executable which is expected to exist - * @param title title of the executable - * @param toolbar enable/disable placement on the toolbar - * @param pos new position for the executable - */ - void position(const QString &title, bool toolbar, int pos); + void addExecutable(const QString &title, + const QString &executableName, + const QString &arguments, + const QString &workingDirectory, + MOBase::ExecutableInfo::CloseMOStyle closeMO, + const QString &steamAppID, + Executable::Type custom, + Executable::Toolbar toolbar, + Executable::Icon ownicon); /** * @brief remove the executable with the specified file name. This needs to be an absolute file path diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bd880dac..2e7797d2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -486,7 +486,7 @@ void MainWindow::updateToolBar() std::vector::iterator begin, end; m_OrganizerCore.executablesList()->getExecutables(begin, end); for (auto iter = begin; iter != end; ++iter) { - if (iter->m_Toolbar) { + if (iter->shownOnToolbar()) { QAction *exeAction = new QAction(iconForExecutable(iter->m_BinaryInfo.filePath()), iter->m_Title, ui->toolBar); @@ -3256,8 +3256,8 @@ void MainWindow::on_savegameList_customContextMenuRequested(const QPoint &pos) void MainWindow::linkToolbar() { Executable &exe(getSelectedExecutable()); - exe.m_Toolbar = !exe.m_Toolbar; - ui->linkButton->menu()->actions().at(static_cast(Shortcut_Type::Toolbar))->setIcon(exe.m_Toolbar ? QIcon(":/MO/gui/remove") : QIcon(":/MO/gui/link")); + exe.showOnToolbar(!exe.shownOnToolbar()); + ui->linkButton->menu()->actions().at(static_cast(Shortcut_Type::Toolbar))->setIcon(exe.shownOnToolbar() ? QIcon(":/MO/gui/remove") : QIcon(":/MO/gui/link")); updateToolBar(); } @@ -3306,7 +3306,7 @@ void MainWindow::addWindowsLink(Shortcut_Type const mapping) , parameter.c_str() , QDir::toNativeSeparators(linkName).toUtf8().constData() , description.c_str() - , (selectedExecutable.m_UseOwnIcon ? iconFile.c_str() : nullptr), 0 + , (selectedExecutable.usesOwnIcon() ? iconFile.c_str() : nullptr), 0 , currentDirectory.c_str()) == 0) { ui->linkButton->menu()->actions().at(static_cast(mapping))->setIcon(QIcon(":/MO/gui/remove")); } else { @@ -3541,10 +3541,15 @@ void MainWindow::addAsExecutable() tr("Please enter a name for the executable"), QLineEdit::Normal, targetInfo.baseName()); if (!name.isEmpty()) { - m_OrganizerCore.executablesList()->addExecutable(name, binaryInfo.absoluteFilePath(), - arguments, targetInfo.absolutePath(), - ExecutableInfo::CloseMOStyle::DEFAULT_STAY, QString(), - true, false, false); + m_OrganizerCore.executablesList()->addExecutable(name, + binaryInfo.absoluteFilePath(), + arguments, + targetInfo.absolutePath(), + ExecutableInfo::CloseMOStyle::DEFAULT_STAY, + QString(), + Executable::Type::Custom, + Executable::Toolbar::Disabled, + Executable::Icon::MO); refreshExecutablesList(); } } break; @@ -4121,7 +4126,7 @@ void MainWindow::removeFromToolbar() { try { Executable &exe = m_OrganizerCore.executablesList()->find(m_ContextAction->text()); - exe.m_Toolbar = false; + exe.showOnToolbar(false); } catch (const std::runtime_error&) { qDebug("executable doesn't exist any more"); } @@ -4240,7 +4245,7 @@ void MainWindow::on_linkButton_pressed() QFileInfo const linkDesktopFile(getDesktopLinkfile(selectedExecutable)); QFileInfo const linkMenuFile(getStartMenuLinkfile(selectedExecutable)); - ui->linkButton->menu()->actions().at(static_cast(Shortcut_Type::Toolbar))->setIcon(selectedExecutable.m_Toolbar ? removeIcon : addIcon); + ui->linkButton->menu()->actions().at(static_cast(Shortcut_Type::Toolbar))->setIcon(selectedExecutable.shownOnToolbar() ? removeIcon : addIcon); ui->linkButton->menu()->actions().at(static_cast(Shortcut_Type::Windows_Desktop))->setIcon(linkDesktopFile.exists() ? removeIcon : addIcon); ui->linkButton->menu()->actions().at(static_cast(Shortcut_Type::Windows_StartMenu))->setIcon(linkMenuFile.exists() ? removeIcon : addIcon); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 01141dd7..589a1595 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -222,15 +222,15 @@ QSettings::Status OrganizerCore::storeSettings(const QString &fileName) const Executable &item = *current; settings.setArrayIndex(count++); settings.setValue("title", item.m_Title); - settings.setValue("custom", item.m_Custom); - settings.setValue("toolbar", item.m_Toolbar); - if (item.m_Custom) { + settings.setValue("custom", item.isCustom()); + settings.setValue("toolbar", item.shownOnToolbar()); + settings.setValue("ownicon", item.usesOwnIcon()); + if (item.isCustom()) { settings.setValue("binary", item.m_BinaryInfo.absoluteFilePath()); settings.setValue("arguments", item.m_Arguments); settings.setValue("workingDirectory", item.m_WorkingDirectory); settings.setValue("closeOnStart", item.m_CloseMO == ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE); settings.setValue("steamAppID", item.m_SteamAppID); - settings.setValue("ownicon", item.m_UseOwnIcon); } } settings.endArray(); @@ -330,15 +330,21 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) ExecutableInfo::CloseMOStyle closeMO = settings.value("closeOnStart").toBool() ? ExecutableInfo::CloseMOStyle::DEFAULT_CLOSE : ExecutableInfo::CloseMOStyle::DEFAULT_STAY; + Executable::Type type = + settings.value("custom", true).toBool() ? Executable::Type::Custom : Executable::Type::Game; + Executable::Toolbar toolbar = + settings.value("toolbar", false).toBool() ? Executable::Toolbar::Enabled : Executable::Toolbar::Disabled; + Executable::Icon icon = + settings.value("ownicon", false).toBool() ? Executable::Icon::Application : Executable::Icon::MO; m_ExecutablesList.addExecutable(settings.value("title").toString(), settings.value("binary").toString(), settings.value("arguments").toString(), settings.value("workingDirectory", "").toString(), closeMO, settings.value("steamAppID", "").toString(), - settings.value("custom", true).toBool(), - settings.value("toolbar", false).toBool(), - settings.value("ownicon", false).toBool()); + type, + toolbar, + icon); } settings.endArray(); -- cgit v1.3.1