7 Commity

4 změnil soubory, kde provedl 23 přidání a 13 odebrání

Zobrazit soubor

@ -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;
outStream << "key" << " " << config.key << endl;
if(!config.key.isEmpty())
{
outStream << "key" << " " << config.key << endl;
}
if(config.type == EntryType::USER)
{
if(!config.name.isEmpty())

Zobrazit soubor

@ -19,7 +19,8 @@ enum EntryType
{
USER,
INHERIT,
SYSTEM
SYSTEM,
DYNAMIC
};
class EntryConfig

Zobrazit soubor

@ -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;
}

Zobrazit soubor

@ -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();
@ -381,7 +384,10 @@ void Window::keyPressEvent(QKeyEvent *event)
for(EntryPushButton *button : buttonsInGrid)
{
button->showShortcut();
if(!button->getEntryConfig().key.isEmpty())
{
button->showShortcut();
}
}
QKeySequence seq(event->key());