Compare commits
7 Commits
wip/clipar
...
wip/dynami
Author | SHA1 | Date | |
---|---|---|---|
2df37212dd | |||
b13815a924 | |||
bb74d156c9 | |||
f9038f3098 | |||
042b53a0be | |||
64d3223fb2 | |||
adfb065358 |
@ -25,7 +25,7 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
// TODO: better exception class
|
||||
throw new std::runtime_error("Failed to open file");
|
||||
throw std::runtime_error("Failed to open file");
|
||||
}
|
||||
QTextStream stream(&file);
|
||||
// There should be nothing preceding this group in the desktop entry file but possibly one or more comments.
|
||||
@ -120,7 +120,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
// TODO: better exception class
|
||||
throw new std::runtime_error("Failed to open file");
|
||||
throw std::runtime_error("Failed to open file");
|
||||
}
|
||||
QHash<QString, QString> map;
|
||||
QTextStream stream(&file);
|
||||
@ -131,7 +131,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
int spacePos = line.indexOf(' ');
|
||||
if(spacePos == -1)
|
||||
{
|
||||
throw new ConfigFormatException("misformated line in .qsrun config file " + path.toStdString());
|
||||
throw ConfigFormatException("misformated line in .qsrun config file " + path.toStdString());
|
||||
}
|
||||
|
||||
QString key = line.mid(0, spacePos);
|
||||
@ -139,7 +139,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
|
||||
if(key == "" || value == "")
|
||||
{
|
||||
throw new ConfigFormatException("empty key or value in .qsrun config file " + path.toStdString());
|
||||
throw ConfigFormatException("empty key or value in .qsrun config file " + path.toStdString());
|
||||
}
|
||||
map[key] = value;
|
||||
}
|
||||
@ -154,7 +154,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ConfigFormatException("Error attempting to read inherited entry");
|
||||
throw ConfigFormatException("Error attempting to read inherited entry");
|
||||
}
|
||||
}
|
||||
QString type = map["type"];
|
||||
@ -162,7 +162,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
{
|
||||
if(type == "system")
|
||||
{
|
||||
throw new ConfigFormatException(".qsrun files cannot be designated as system entries " +
|
||||
throw ConfigFormatException(".qsrun files cannot be designated as system entries " +
|
||||
path.toStdString());
|
||||
}
|
||||
else if(type == "inherit")
|
||||
@ -175,7 +175,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ConfigFormatException("Invalid value for type provided in file: " + path.toStdString());
|
||||
throw ConfigFormatException("Invalid value for type provided in file: " + path.toStdString());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -309,7 +309,10 @@ void EntryProvider::saveUserEntry(const EntryConfig &config)
|
||||
outStream << "row" << " " << config.row << endl;
|
||||
outStream << "col" << " " << config.col << endl;
|
||||
outStream << "hidden" << " " << config.hidden << endl;
|
||||
if(!config.key.isEmpty())
|
||||
{
|
||||
outStream << "key" << " " << config.key << endl;
|
||||
}
|
||||
if(config.type == EntryType::USER)
|
||||
{
|
||||
if(!config.name.isEmpty())
|
||||
|
@ -19,7 +19,8 @@ enum EntryType
|
||||
{
|
||||
USER,
|
||||
INHERIT,
|
||||
SYSTEM
|
||||
SYSTEM,
|
||||
DYNAMIC
|
||||
};
|
||||
|
||||
class EntryConfig
|
||||
|
@ -106,7 +106,7 @@ void EntryPushButton::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
this->userEntryMenu.exec(QCursor::pos());
|
||||
}
|
||||
else
|
||||
else if(this->config.type == EntryType::SYSTEM)
|
||||
{
|
||||
this->systemEntryMenu.exec(QCursor::pos());
|
||||
}
|
||||
@ -116,7 +116,7 @@ void EntryPushButton::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void EntryPushButton::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if(this->config.type == EntryType::SYSTEM)
|
||||
if(this->config.type == EntryType::SYSTEM || this->config.type == EntryType::DYNAMIC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void Window::populateGrid(const QVector<EntryPushButton *> &list)
|
||||
|
||||
void Window::executeConfig(const EntryConfig &config)
|
||||
{
|
||||
if(config.isTerminalCommand)
|
||||
if(config.isTerminalCommand || QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier))
|
||||
{
|
||||
QString cmd = settingsProvider->getTerminalCommand();
|
||||
cmd.replace("%c", config.command);
|
||||
@ -166,6 +166,7 @@ void Window::addToFavourites(const EntryConfig &config)
|
||||
when we add it to the favourites. the alternative would be to reload the whole config,
|
||||
but that's probably overkill. */
|
||||
userConfig.update(config);
|
||||
userConfig.key = "";
|
||||
userEntryButtons.append(createEntryButton(userConfig));
|
||||
}
|
||||
|
||||
@ -265,6 +266,7 @@ void Window::addPATHSuggestion(const QString &text)
|
||||
e.row = 0;
|
||||
e.command = suggestions[0];
|
||||
e.iconPath = suggestions[0];
|
||||
e.type = EntryType::DYNAMIC;
|
||||
EntryPushButton *button = createEntryButton(e);
|
||||
clearGrid();
|
||||
grid->addWidget(button, 0, 0);
|
||||
@ -342,6 +344,7 @@ void Window::lineEditTextChanged(QString text)
|
||||
}
|
||||
e.command = arguments[0];
|
||||
e.iconPath = "utilities-terminal";
|
||||
e.type = EntryType::DYNAMIC;
|
||||
|
||||
EntryPushButton *button = createEntryButton(e);
|
||||
clearGrid();
|
||||
@ -380,9 +383,12 @@ void Window::keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
|
||||
for(EntryPushButton *button : buttonsInGrid)
|
||||
{
|
||||
if(!button->getEntryConfig().key.isEmpty())
|
||||
{
|
||||
button->showShortcut();
|
||||
}
|
||||
}
|
||||
|
||||
QKeySequence seq(event->key());
|
||||
QString key = seq.toString().toLower();
|
||||
|
Reference in New Issue
Block a user