Skip to content

Commit

Permalink
Quick conversion from a different currency
Browse files Browse the repository at this point in the history
  • Loading branch information
Advaith3600 committed Jan 23, 2024
1 parent 6c04ac1 commit 76af59d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>Community.PowerToys.Run.Plugin.CurrencyConverter</RootNamespace>
<AssemblyName>Community.PowerToys.Run.Plugin.CurrencyConverter</AssemblyName>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platforms>AnyCPU;x64;ARM64</Platforms>
Expand Down
10 changes: 9 additions & 1 deletion Community.PowerToys.Run.Plugin.CurrencyConverter/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public List<Result> Query(Query query)
{
double amountToConvert = 0;
var parts = query.Search.Trim().Split(" ");
if (! ((parts.Length == 1 || parts.Length == 4) && double.TryParse(parts[0], out amountToConvert)))
if (! ((parts.Length == 1 || parts.Length == 2 || parts.Length == 4) && double.TryParse(parts[0], out amountToConvert)))
{
return new List<Result>();
}
Expand All @@ -150,6 +150,14 @@ public List<Result> Query(Query query)
GetConversion(amountToConvert, fromCurrency, toCurrency),
GetConversion(amountToConvert, toCurrency, fromCurrency)
};
}
else if (parts.Length == 2)
{
return new List<Result>
{
GetConversion(amountToConvert, parts[1], ConversionDirection == 0 ? GlobalCurrency : LocalCurrency),
GetConversion(amountToConvert, parts[1], ConversionDirection == 0 ? LocalCurrency : GlobalCurrency)
};
}

return new List<Result>
Expand Down
4 changes: 2 additions & 2 deletions Community.PowerToys.Run.Plugin.CurrencyConverter/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"ActionKeyword": "$$",
"Name": "Currency Converter",
"Author": "advaith3600",
"Version": "1.0.2",
"Version": "1.0.3",
"Language": "csharp",
"Website": "https://github.com/advaith3600/PowerToys-Run-Currency-Converter",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.CurrencyConverter.dll",
"IsGlobal": false,
"IcoPathDark": "images\\icon-white.png",
"IcoPathLight": "images\\icon-black.png"
}
}
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Example Usage:
$$ 1 btc to usd
```

![Screenshot](screenshots/screenshot2.png)
![Screenshot](screenshots/screenshot5.png)

### Quick Conversions

Expand All @@ -42,6 +42,14 @@ $$ 102.2

![Screenshot](screenshots/screenshot3.png)

Or, you can convert any currency to your local and globally by:

```
$$ 1 eur
```

![Screenshot](screenshots/screenshot4.png)

Your local currency, global currency and the quick conversion direction can also be changed from the settings page in PowerToys Run under this plugin.

## Installation
Expand All @@ -50,6 +58,6 @@ Your local currency, global currency and the quick conversion direction can also
2. Extract the zip file's contents to your PowerToys modules directory (usually `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Plugins`).
3. Restart PowerToys.

## Conversion API
## Conversion API

This plugin internally uses [Currency API](https://github.com/fawazahmed0/currency-api) for the latest conversion rates.
Binary file modified screenshots/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 76af59d

Please sign in to comment.