比較提交
3 次程式碼提交
wip/termin
...
ac5498990b
作者 | SHA1 | 日期 | |
---|---|---|---|
ac5498990b | |||
38cc87fbcd | |||
2d14b01c5c |
@ -13,6 +13,11 @@ EntryProvider::EntryProvider(QStringList userEntriesDirsPaths, QStringList syste
|
|||||||
<< "%u";
|
<< "%u";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntryProvider::isSavable(const EntryConfig &config) const
|
||||||
|
{
|
||||||
|
return ! config.entryPath.isEmpty() && (config.type == EntryType::USER || config.type == EntryType::INHERIT);
|
||||||
|
}
|
||||||
|
|
||||||
EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
||||||
{
|
{
|
||||||
EntryConfig result;
|
EntryConfig result;
|
||||||
@ -223,6 +228,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
|||||||
}
|
}
|
||||||
result.col = map["col"].toInt();
|
result.col = map["col"].toInt();
|
||||||
result.row = map["row"].toInt();
|
result.row = map["row"].toInt();
|
||||||
|
result.isTerminalCommand = map["terminal"] == "true";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +290,7 @@ QVector<EntryConfig> EntryProvider::getSystemEntries()
|
|||||||
|
|
||||||
void EntryProvider::saveUserEntry(const EntryConfig &config)
|
void EntryProvider::saveUserEntry(const EntryConfig &config)
|
||||||
{
|
{
|
||||||
if(config.type == EntryType::SYSTEM || config.entryPath.isEmpty())
|
if(!isSavable(config))
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Only user/inherited entries can be saved");
|
throw std::runtime_error("Only user/inherited entries can be saved");
|
||||||
}
|
}
|
||||||
@ -338,7 +344,7 @@ void EntryProvider::saveUserEntry(const EntryConfig &config)
|
|||||||
|
|
||||||
bool EntryProvider::deleteUserEntry(const EntryConfig &config)
|
bool EntryProvider::deleteUserEntry(const EntryConfig &config)
|
||||||
{
|
{
|
||||||
if(config.type == EntryType::SYSTEM || config.entryPath.isEmpty())
|
if(!isSavable(config))
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Only user/inherited entries can be deleted");
|
throw std::runtime_error("Only user/inherited entries can be deleted");
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ class EntryProvider
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths);
|
EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths);
|
||||||
|
bool isSavable(const EntryConfig &config) const;
|
||||||
QVector<EntryConfig> getUserEntries();
|
QVector<EntryConfig> getUserEntries();
|
||||||
QVector<EntryConfig> getSystemEntries();
|
QVector<EntryConfig> getSystemEntries();
|
||||||
void saveUserEntry(const EntryConfig &config);
|
void saveUserEntry(const EntryConfig &config);
|
||||||
|
@ -23,7 +23,15 @@ EntryPushButton::EntryPushButton(const EntryConfig &config) : QPushButton()
|
|||||||
{
|
{
|
||||||
this->setText(config.name);
|
this->setText(config.name);
|
||||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
QIcon icon = resolveIcon(config.iconPath);
|
QIcon icon;
|
||||||
|
if(config.isTerminalCommand && config.iconPath.isEmpty())
|
||||||
|
{
|
||||||
|
icon = resolveIcon("utilities-terminal");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon = resolveIcon(config.iconPath);
|
||||||
|
}
|
||||||
this->setIcon(icon);
|
this->setIcon(icon);
|
||||||
if(!icon.availableSizes().isEmpty())
|
if(!icon.availableSizes().isEmpty())
|
||||||
{
|
{
|
||||||
|
新增問題並參考
封鎖使用者